r212: Fixed a problem where the last post would be off if we did not have permission...
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 30 May 2005 05:03:29 +0000 (05:03 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 30 May 2005 05:03:29 +0000 (05:03 +0000)
docs/schema_changes.sql
docs/update_bug_table_cache.php
editcomment.php
index.php
newcomment.php
newreport.php

index ab76e7ad188e1f39aa4fc1059e2522fe1d0194b7..7431b3a67f03844f7a958f7eb1fc377b445c32eb 100644 (file)
@@ -52,4 +52,6 @@ CREATE TABLE `bugvaluefill` (
 
 ALTER TABLE `bug` ADD `hidden` INT(2) UNSIGNED NOT NULL AFTER `assignedto`;
 
-ALTER TABLE `comment` ADD `hidden` INT(2) UNSIGNED NOT NULL;
\ No newline at end of file
+ALTER TABLE `comment` ADD `hidden` INT(2) UNSIGNED NOT NULL;
+
+ALTER TABLE `bug` ADD `hiddenlastposttime` INT(10) UNSIGNED NOT NULL, ADD `hiddenlastpostby` INT(10) UNSIGNED NOT NULL;
\ No newline at end of file
index 009874809e4e7dd8f72af676714ba26b64f8c8bd..87a59562b29c073b4134357fcdda1ea8da40df16 100644 (file)
@@ -3,20 +3,40 @@
 chdir('./../');
 require_once('./global.php');
 
-$comments = $db->query("SELECT * FROM comment ORDER BY bugid, dateline ASC");
+$comments = $db->query("SELECT * FROM " . TABLE_PREFIX . "comment ORDER BY bugid, dateline ASC");
 
 while ($comment = $db->fetch_array($comments))
 {
        if (!isset($replace["$comment[bugid]"]))
        {
-               $replace["$comment[bugid]"] = array('initialreport' => $comment['commentid'], 'dateline' => $comment['dateline'], 'lastposttime' => $comment['dateline'], 'lastpostby' => $comment['userid']);
+               $replace["$comment[bugid]"] = array(
+                       'initialreport' => $comment['commentid'],
+                       'dateline' => $comment['dateline'],
+                       'lastposttime' => $comment['dateline'],
+                       'lastpostby' => $comment['userid']
+               );
        }
+       if (!$comment['hidden'] AND !isset($replace["$comment[bugid]"]['hiddenlastposttime']))
+       {
+               $replace["$comment[bugid]"]['hiddenlastposttime'] = $comment['dateline'];
+               $replace["$comment[bugid]"]['hiddenlastpostby'] = $comment['userid'];
+       }
+       
        $replace["$comment[bugid]"]['lastposttime'] = $comment['dateline'];
 }
 
 foreach ($replace AS $bugid => $newfields)
 {
-       $db->query("UPDATE bug SET initialreport = $newfields[initialreport], dateline = $newfields[dateline], lastposttime = $newfields[lastposttime], lastpostby = $newfields[lastpostby] WHERE bugid = $bugid");
+       $db->query("
+               UPDATE " . TABLE_PREFIX . "bug
+               SET initialreport = $newfields[initialreport],
+                       dateline = $newfields[dateline],
+                       lastposttime = $newfields[lastposttime],
+                       lastpostby = $newfields[lastpostby],
+                       hiddenlastposttime = $newfields[hiddenlastposttime],
+                       hiddenlastpostby = $newfields[hiddenlastpostby]
+               WHERE bugid = $bugid"
+       );
        echo "<p>Updated $bugid</p>";
 }
 
index 1f3e767533b04dacf9a8fbe6779acaf929d65ff7..07ebe19d751efb1a4293cb38a7f92087a5fc97c7 100644 (file)
@@ -81,6 +81,15 @@ if ($_POST['do'] == 'update')
        $log->log();
        $log->log($log->diff('hidden', $comment['hidden'], intval($bugsys->in['hidden'])));
        
+       $lastgood = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC");
+       print_r($lastgood);
+       $db->query("
+               UPDATE " . TABLE_PREFIX . "bug
+               SET hiddenlastposttime = $lastgood[dateline],
+                       hiddenlastpostby = $lastgood[userid]
+               WHERE bugid = $bug[bugid]"
+       );
+       
        $message->redirect('comment saved', "showreport.php?bugid=$bug[bugid]");
 }
 
index bbb4c4ce6a66014e54248b4fec42f3b4fedbea83..812ed176813af5502e2a554dadee8b5b9112a95d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -27,14 +27,16 @@ if (!can_perform('canviewbugs'))
 // #*# pagination needs to be done here
 
 $bugs_fetch = $db->query("
-       SELECT bug.*, user1.displayname AS firstreport, user2.displayname AS lastpost
+       SELECT bug.*, user1.displayname AS firstreport, user2.displayname AS lastpost, user3.displayname AS hiddenlastpost
        FROM " . TABLE_PREFIX . "bug AS bug
        LEFT JOIN user AS user1
                ON (bug.userid = user1.userid)
        LEFT JOIN user AS user2
-               ON (bug.lastpostby = user2.userid)" . ((!can_perform('canviewhidden')) ? "
+               ON (bug.lastpostby = user2.userid)
+       LEFT JOIN user AS user3
+               ON (bug.hiddenlastpostby = user3.userid)" . ((!can_perform('canviewhidden')) ? "
        WHERE !hidden" : "") . "
-       ORDER BY bug.lastposttime DESC"
+       ORDER BY bug." . ((can_perform('canviewhidden')) ? "lastposttime" : "hiddenlastposttime") . " DESC"
 );
 
 while ($bug = $db->fetch_array($bugs_fetch))
@@ -44,7 +46,14 @@ while ($bug = $db->fetch_array($bugs_fetch))
        $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
        $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
        $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
+       
+       $bug['hiddendisplay'] = ((!can_perform('canviewhidden') AND $bug['hiddenlastposttime']) ? true : false);
+       
+       $bug['lastposttime'] = (($bug['hiddendisplay']) ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
+       $bug['lastpost'] = (($bug['hiddendisplay']) ? $bug['hiddenlastpost'] : $bug['lastpost']);
+       
        $bug['lastpostinfo'] = datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'];
+       
        eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
 }
 
index 85b6e3216edd63c9d76b416ebe2b150cb398794a..055cd8142d02a0b0d4fbc5e8d8282c13192aa0fb 100644 (file)
@@ -53,7 +53,14 @@ if ($_POST['do'] == 'insert')
        
        $commentid = $db->insert_id();
        
-       $db->query("UPDATE " . TABLE_PREFIX . "bug SET lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = " . intval($bugsys->in['bugid']));
+       $db->query("
+               UPDATE " . TABLE_PREFIX . "bug
+               SET lastposttime = $time,
+                       lastpostby = " . $bugsys->userinfo['userid'] . ",
+                       hiddenlastposttime = $time,
+                       hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
+               WHERE bugid = " . intval($bugsys->in['bugid'])
+       );
        
        // setup logging
        require_once('./includes/class_history.php');
index 3c643156ca2b8249d57b7e95f96fc6c8f636584f..cdb56f8640fdae5e223de12171cc497db18ad50e 100755 (executable)
@@ -127,7 +127,16 @@ if ($_POST['do'] == 'insert')
        
        $initialreport = $db->insert_id();
        
-       $db->query("UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid");
+       $db->query("
+               UPDATE " . TABLE_PREFIX . "bug
+               SET dateline = $time,
+                       initialreport = $initialreport,
+                       lastposttime = $time,
+                       lastpostby = " . $bugsys->userinfo['userid'] . ",
+                       hiddenlastposttime = $time,
+                       hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
+               WHERE bugid = $bugid"
+       );
        
        $message->redirect('bug is done!', "showreport.php?bugid=$bugid");
 }