]> git.mjollnir.org Git - s9y.git/commitdiff
Fix gazillion comment count bug
authorgarvinhicking <garvinhicking>
Mon, 23 Oct 2006 07:32:37 +0000 (07:32 +0000)
committergarvinhicking <garvinhicking>
Mon, 23 Oct 2006 07:32:37 +0000 (07:32 +0000)
docs/NEWS
include/admin/comments.inc.php
include/functions_comments.inc.php

index e6c5d3674e9178ac64bc5e5ade75e5fee8cbf4d5..c65fb6c9edadb058ee74f5594107fe23a4796337 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -1,5 +1,12 @@
 # $Id$
 
+Version 1.1 ()
+------------------------------------------------------------------------
+
+    * Fix possible integer wraparound in comment count leading to
+      a gazillion counter state. Also now show links to the entries
+      within the administration comment panel. Thanks to Julian Finn!
+
 Version 1.1-beta5 (October 18th, 2006)
 ------------------------------------------------------------------------
 
index 5807f5a9100bba7167813266fdb09ba2f36f5e3c..ef0e43d4582b03e9e306c3b76fa773fbd30b440c 100644 (file)
@@ -10,7 +10,7 @@ if (!serendipity_checkPermission('adminComments')) {
     return;
 }
 
-$commentsPerPage = (!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10);
+$commentsPerPage = (int)(!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10);
 $summaryLength = 200;
 
 if ( $serendipity['POST']['formAction'] == 'multiDelete' && sizeof($serendipity['POST']['delete']) != 0 && serendipity_checkFormToken()) {
@@ -114,7 +114,7 @@ if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminActi
 $filters = array('author', 'email', 'ip', 'url', 'body', 'referer');
 
 /* Compress the filters into an "AND" SQL query, and a querystring */
-foreach ( $filters as $filter ) {
+foreach ($filters as $filter) {
     $and          .= (!empty($serendipity['GET']['filter'][$filter]) ? "AND c.". $filter ." LIKE '%". serendipity_db_escape_string($serendipity['GET']['filter'][$filter]) ."%'" : "");
     $searchString .= (!empty($serendipity['GET']['filter'][$filter]) ? "&amp;serendipity[filter][". $filter ."]=". $serendipity['GET']['filter'][$filter] : "");
 }
@@ -139,6 +139,20 @@ if ($serendipity['GET']['filter']['type'] == 'TRACKBACK') {
     $c_type = null;
 }
 
+if ($serendipity['GET']['filter']['type'] == 'TRACKBACK') {
+    $c_type = 'TRACKBACK';
+    $searchString .= "&amp;serendipity[filter][type]=TRACKBACK";
+} elseif ($serendipity['GET']['filter']['type'] == 'NORMAL') {
+    $c_type = 'NORMAL';
+    $searchString .= "&amp;serendipity[filter][type]=NORMAL";
+} else {
+    $c_type = null;
+}
+
+if ($commentsPerPage != 10) {
+    $searchString .= '&amp;serendipity[filter][perpage]=' . $commentsPerPage;
+}
+
 $searchString .= '&amp;' . serendipity_setFormToken('url');
 
 /* Paging */
@@ -171,7 +185,7 @@ function FT_toggle(id) {
     if ( document.getElementById(id + '_full').style.display == '' ) {
         document.getElementById(id + '_full').style.display='none';
         document.getElementById(id + '_summary').style.display='';
-        document.getElementById(id + '_text').innerHTML = '<?php echo VIEW ?>';
+        document.getElementById(id + '_text').innerHTML = '<?php echo TOGGLE_ALL ?>';
     } else {
         document.getElementById(id + '_full').style.display='';
         document.getElementById(id + '_summary').style.display='none';
@@ -226,7 +240,7 @@ function highlightComment(id, checkvalue) {
     <tr>
         <td><?php echo COMMENTS; ?>:</td>
         <td><select name="serendipity[filter][perpage]">
-        <?php 
+        <?php
             $filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL);
             foreach($filter_vals AS $filter_val) { ?>
             <option value="<?php echo $filter_val; ?>" <?php echo ($commentsPerPage == $filter_val ? ' selected="selected"' : ''); ?>><?php echo $filter_val; ?></option>
@@ -297,11 +311,13 @@ foreach ($sql as $rs) {
         'referer'   => $rs['referer'],
         'url'       => $rs['url'],
         'ip'        => $rs['ip'],
+        'entry_url' => serendipity_archiveURL($rs['entry_id'], $rs['title']),
         'email'     => $rs['email'],
         'author'    => (empty($rs['author']) ? ANONYMOUS : $rs['author']),
         'entry_id'  => $rs['entry_id']
     );
 
+    $entrylink = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id'];
     if (strlen($comment['fullBody']) > strlen($comment['summary']) ) {
         $comment['summary'] .= ' ...';
         $comment['excerpt'] = true;
@@ -314,14 +330,14 @@ foreach ($sql as $rs) {
 
         $comment['fullBody'] = $comment['summary'] = nl2br(htmlspecialchars($comment['fullBody']));
     }
-    
-    serendipity_plugin_api::hook_event('backend_view_comment', $comment);
+
+    serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&amp;serendipity[page]='. $page . $searchString);
     $class = 'serendipity_admin_list_item_' . (($i % 2 == 0 ) ? 'even' : 'uneven');
     $header_class = ($comment['status'] == 'pending' ? 'serendipityAdminMsgNote' : '');
 ?>
 <tr>
     <td class="<?php echo $header_class; ?>"><a name="c<?php echo $comment['id'] ?>"></a>
-        <?php echo ($comment['type'] == 'NORMAL' ? COMMENT : TRACKBACK) . ' #'. $comment['id'] .', '. IN_REPLY_TO .' <strong>'. $comment['title'] .'</strong>, '. ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime('%b %e %Y, %H:%M', $comment['timestamp']))?>
+        <?php echo ($comment['type'] == 'NORMAL' ? COMMENT : TRACKBACK) . ' #'. $comment['id'] .', '. IN_REPLY_TO .' <strong><a href="' . $comment['entry_url'] . '">'. $comment['title'] .'</a></strong>, '. ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime('%b %e %Y, %H:%M', $comment['timestamp']))?>
     </td>
 </tr>
 <tr>
@@ -386,8 +402,9 @@ foreach ($sql as $rs) {
           <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo APPROVE; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/accept.png'); ?>" alt="<?php echo APPROVE ?>" /><?php echo APPROVE ?></a>
 <?php } ?>
 <?php if ($comment['excerpt']) { ?>
-          <a href="#c<?php echo $comment['id'] ?>" onclick="FT_toggle(<?php echo $comment['id'] ?>); return false;" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo VIEW; ?>" /><span id="<?php echo $comment['id'] ?>_text"><?php echo VIEW ?></span></a>
+          <a href="#c<?php echo $comment['id'] ?>" onclick="FT_toggle(<?php echo $comment['id'] ?>); return false;" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo TOGGLE_ALL; ?>" /><span id="<?php echo $comment['id'] ?>_text"><?php echo TOGGLE_ALL ?></span></a>
 <?php } ?>
+          <a target="_blank" href="<?php echo $entrylink; ?>" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo VIEW; ?>" /><?php echo VIEW ?></a>
           <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" title="<?php echo EDIT; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT; ?>" /><?php echo EDIT ?></a>
           <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" onclick='return confirm("<?php echo sprintf(COMMENT_DELETE_CONFIRM, $comment['id'], htmlspecialchars($comment['author'])) ?>")' title="<?php echo DELETE ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE; ?>" /><?php echo DELETE ?></a>
           <?php echo $comment['action_more']; ?>
index bc7a29feb288941e3c9c52412bc6046f95004b78..ffab9c85e78a19ac4a86604624bf85f58e81d1fb 100644 (file)
@@ -430,7 +430,7 @@ function serendipity_deleteComment($id, $entry_id, $type='comments') {
                 } else {
                     $type = 'comments';
                 }
-                serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id ." $admin");
+                serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id ." AND $type > 0 $admin");
             }
 
             serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = " . $id);