diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-03-30 07:45:20 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-03-30 07:45:20 +0000 |
commit | 9e94bb610136ceb8cfedf2cc139c4b34ed7a46c4 (patch) | |
tree | 176d85b021b3d0b64d96a7a227d6508168002fdb | |
parent | 630277cc89546d8ba913bfec0a6bb3daedd4fe47 (diff) | |
download | brdo-9e94bb610136ceb8cfedf2cc139c4b34ed7a46c4.tar.gz brdo-9e94bb610136ceb8cfedf2cc139c4b34ed7a46c4.tar.bz2 |
- Patch #130366 by webchick and steven: improved signature handling. Step 1 of 2.
-rw-r--r-- | modules/comment/comment.module | 40 | ||||
-rw-r--r-- | modules/user/user.module | 15 | ||||
-rw-r--r-- | themes/bluemarine/comment.tpl.php | 9 | ||||
-rw-r--r-- | themes/chameleon/chameleon.theme | 8 | ||||
-rw-r--r-- | themes/engines/phptemplate/comment.tpl.php | 5 | ||||
-rw-r--r-- | themes/engines/phptemplate/phptemplate.engine | 1 | ||||
-rw-r--r-- | themes/garland/comment.tpl.php | 5 | ||||
-rw-r--r-- | themes/pushbutton/comment.tpl.php | 9 |
8 files changed, 64 insertions, 28 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 4065f4017..ff29b34f0 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -454,26 +454,9 @@ function comment_nodeapi(&$node, $op, $arg = 0) { /** * Implementation of hook_user(). - * - * Provides signature customization for the user's comments. */ function comment_user($type, $edit, &$user, $category = NULL) { - if ($type == 'form' && $category == 'account') { - // when user tries to edit his own data - $form['comment_settings'] = array( - '#type' => 'fieldset', - '#title' => t('Comment settings'), - '#collapsible' => TRUE, - '#weight' => 4); - $form['comment_settings']['signature'] = array( - '#type' => 'textarea', - '#title' => t('Signature'), - '#default_value' => $edit['signature'], - '#description' => t('Your signature will be publicly displayed at the end of your comments.')); - - return $form; - } - elseif ($type == 'delete') { + if ($type == 'delete') { db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); } @@ -647,7 +630,7 @@ function comment_reply($node, $pid = NULL) { // $pid indicates that this is a reply to a comment. if ($pid) { // load the comment whose cid = $pid - if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) { + if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) { // If that comment exists, make sure that the current comment and the parent comment both // belong to the same parent node. if ($comment->nid != $node->nid) { @@ -658,6 +641,7 @@ function comment_reply($node, $pid = NULL) { // Display the parent comment $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; + $comment->signature = check_markup($comment->signature, $comment->format); $output .= theme('comment_view', $comment); } else { @@ -951,7 +935,7 @@ function comment_render($node, $cid = 0) { if ($cid) { // Single comment view. - $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; + $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; $query_args = array($cid); if (!user_access('administer comments')) { $query .= ' AND c.status = %d'; @@ -962,6 +946,7 @@ function comment_render($node, $cid = 0) { if ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; + $comment->signature = check_markup($comment->signature, $comment->format); $links = module_invoke_all('link', 'comment', $comment, 1); drupal_alter('link', $links, $node); @@ -971,7 +956,7 @@ function comment_render($node, $cid = 0) { else { // Multiple comment view $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d'; - $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; + $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; $query_args = array($nid); if (!user_access('administer comments')) { @@ -1016,6 +1001,7 @@ function comment_render($node, $cid = 0) { while ($comment = db_fetch_object($result)) { $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; + $comment->signature = check_markup($comment->signature, $comment->format); $comment->depth = count(explode('.', $comment->thread)) - 1; if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) { @@ -1537,9 +1523,6 @@ function comment_form($edit, $title = NULL) { if (!empty($edit['comment'])) { $default = $edit['comment']; } - elseif (isset($user->signature)) { - $default = $user->signature; - } else { $default = ''; } @@ -1617,6 +1600,11 @@ function comment_form_add_preview($form, $edit) { if ($account) { $comment->uid = $account->uid; $comment->name = check_plain($account->name); + $comment->signature = check_markup($account->signature, $comment->format); + } + else { + $comment->name = variable_get('anonymous', t('Anonymous')); + $comment->signature = ''; } $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time(); $output .= theme('comment_view', $comment); @@ -1631,9 +1619,10 @@ function comment_form_add_preview($form, $edit) { $output = ''; if ($edit['pid']) { - $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED)); + $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; + $comment->signature = check_markup($comment->signature, $comment->format); $output .= theme('comment_view', $comment); } else { @@ -1787,6 +1776,7 @@ function theme_comment($comment, $links = array()) { $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) . ' ' . theme('mark', $comment->new) ."</div>\n"; $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n"; $output .= '<div class="body">'. $comment->comment .'</div>'; + $output .= '<div class="user-signature clear">'. $comment->signature .'</div>'; $output .= '<div class="links">'. theme('links', $links) .'</div>'; $output .= '</div>'; return $output; diff --git a/modules/user/user.module b/modules/user/user.module index df04992ac..5bce664a9 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1435,6 +1435,21 @@ function user_edit_form($uid, $edit, $register = FALSE) { } } + // Signature: + if (module_exists('comment') && !$register) { + $form['signature_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Signature settings'), + '#weight' => 1, + ); + $form['signature_settings']['signature'] = array( + '#type' => 'textarea', + '#title' => t('Signature'), + '#default_value' => $edit['signature'], + '#description' => t('Your signature will be publicly displayed at the end of your comments.'), + ); + } + // Picture/avatar: if (variable_get('user_pictures', 0) && !$register) { $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1); diff --git a/themes/bluemarine/comment.tpl.php b/themes/bluemarine/comment.tpl.php index 02eee299c..810204fc2 100644 --- a/themes/bluemarine/comment.tpl.php +++ b/themes/bluemarine/comment.tpl.php @@ -4,6 +4,13 @@ } ?> <h3 class="title"><?php print $title; ?></h3><?php if ($new != '') { ?><span class="new"><?php print $new; ?></span><?php } ?> <div class="submitted"><?php print $submitted; ?></div> - <div class="content"><?php print $content; ?></div> + <div class="content"> + <?php print $content; ?> + <?php if ($signature): ?> + <div class="user-signature clear-block"> + <?php print $signature ?> + </div> + <?php endif; ?> + </div> <div class="links">» <?php print $links; ?></div> </div> diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index f4b5b702f..c3da58a40 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -163,7 +163,13 @@ function chameleon_comment($comment, $links = "") { $output = "<div class=\"comment". ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') ."\">\n"; $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n"; - $output .= " <div class=\"content\">". $comment->comment ."</div>\n"; + $output .= " <div class=\"content\">". $comment->comment; + if ($signature) { + $output .= " <div class=\"user-signature clear-block\">"; + $output .= $signature ."\n"; + $output .= " </div>\n"; + } + $output .= " </div>\n"; $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n"; $output .= "</div>\n"; diff --git a/themes/engines/phptemplate/comment.tpl.php b/themes/engines/phptemplate/comment.tpl.php index c7211b9bf..ac4eeb88a 100644 --- a/themes/engines/phptemplate/comment.tpl.php +++ b/themes/engines/phptemplate/comment.tpl.php @@ -14,6 +14,11 @@ <div class="content"> <?php print $content ?> + <?php if ($signature): ?> + <div class="user-signature clear-block"> + <?php print $signature ?> + </div> + <?php endif; ?> </div> <?php print $links ?> diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine index 329762d8d..acde67a34 100644 --- a/themes/engines/phptemplate/phptemplate.engine +++ b/themes/engines/phptemplate/phptemplate.engine @@ -313,6 +313,7 @@ function phptemplate_comment($comment, $links = 0) { 'date' => format_date($comment->timestamp), 'links' => isset($links) ? theme('links', $links) : '', 'new' => $comment->new ? t('new') : '', + 'signature' => $comment->signature, 'picture' => theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : '', 'submitted' => t('Submitted by !a on @b.', array('!a' => theme('username', $comment), diff --git a/themes/garland/comment.tpl.php b/themes/garland/comment.tpl.php index 30c5ff937..1ca545f12 100644 --- a/themes/garland/comment.tpl.php +++ b/themes/garland/comment.tpl.php @@ -16,6 +16,11 @@ <div class="content"> <?php print $content ?> + <?php if ($signature): ?> + <div class="user-signature clear-block"> + <?php print $signature ?> + </div> + <?php endif; ?> </div> </div> diff --git a/themes/pushbutton/comment.tpl.php b/themes/pushbutton/comment.tpl.php index 2f2113b8e..20949e774 100644 --- a/themes/pushbutton/comment.tpl.php +++ b/themes/pushbutton/comment.tpl.php @@ -4,7 +4,14 @@ <?php endif; ?> <h3 class="title"><?php print $title ?></h3> <div class="submitted"><?php print $submitted ?><?php if ($comment->new) : ?><span class="new"> *<?php print $new ?></span><?php endif; ?></div> - <div class="content"><?php print $content ?></div> + <div class="content"> + <?php print $content ?> + <?php if ($signature): ?> + <div class="user-signature clear-block"> + <?php print $signature ?> + </div> + <?php endif; ?> + </div> <!-- BEGIN: links --> <div class="links">» <?php print $links ?></div> <!-- END: links --> |