Squash-merging the ISSO3 branch back onto master
[bugdar.git] / favorite.php
index b9a59513910158d26ce7f16da1afeb46dae4cf81..5bc8889f97aec3e2681351d1623deb414748602c 100644 (file)
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Bugdar
-|| # Copyright ©2002-2007 Blue Static
+|| # Copyright (c)2004-2008 Blue Static
 || #
 || # This program is free software; you can redistribute it and/or modify
 || # it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
 || ###################################################################
 \*=====================================================================*/
 
-define('SVN', '$Id$');
 
 if (empty($_REQUEST['do']))
 {
@@ -41,8 +40,8 @@ require_once('./includes/class_sort.php');
 
 if ($_REQUEST['do'] == 'handle')
 {
-       $bugsys->input_clean('bugid', TYPE_UINT);
-       $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $bugsys->in['bugid']);
+       $input->inputClean('bugid', TYPE_UINT);
+       $bug = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $input->in['bugid']);
        if (!check_bug_permissions($bug))
        {
                $message->errorPermission();
@@ -53,15 +52,15 @@ if ($_REQUEST['do'] == 'handle')
                $message->errorPermission();
        }
        
-       if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . $bugsys->in['bugid']))
+       if ($db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid'] . " AND bugid = " . $input->in['bugid']))
        {
-               $db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . $bugsys->in['bugid']);
-               $message->redirect(T('This bug has been removed from your favorites list.'), "showreport.php?bugid=" . $bugsys->in['bugid']);
+               $db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid'] . " AND bugid = " . $input->in['bugid']);
+               $message->redirect(T('This bug has been removed from your favorites list.'), "showreport.php?bugid=" . $input->in['bugid']);
        }
        else
        {
-               $db->query("INSERT INTO " . TABLE_PREFIX . "favorite (userid, bugid) VALUES (" . $bugsys->userinfo['userid'] . ", " . $bugsys->in['bugid'] . ")");
-               $message->redirect(T('This bug has been added to your favorites list.'), "showreport.php?bugid=" . $bugsys->in['bugid']);
+               $db->query("INSERT INTO " . TABLE_PREFIX . "favorite (userid, bugid) VALUES (" . bugdar::$userinfo['userid'] . ", " . $input->in['bugid'] . ")");
+               $message->redirect(T('This bug has been added to your favorites list.'), "showreport.php?bugid=" . $input->in['bugid']);
        }
 }
 
@@ -78,11 +77,11 @@ if ($_REQUEST['do'] == 'manage')
                SELECT favorite.bugid, bug.* FROM " . TABLE_PREFIX . "favorite AS favorite
                RIGHT JOIN " . TABLE_PREFIX . "bug AS bug
                        ON (favorite.bugid = bug.bugid)
-               WHERE favorite.userid = " . $bugsys->userinfo['userid'] . "
-               AND (!bug.hidden OR (bug.hidden AND bug.product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (bug.hidden AND bug.userid = " . $bugsys->userinfo['userid'] . " AND bug.product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
+               WHERE favorite.userid = " . bugdar::$userinfo['userid'] . "
+               AND (!bug.hidden OR (bug.hidden AND bug.product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (bug.hidden AND bug.userid = " . bugdar::$userinfo['userid'] . " AND bug.product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
        ");
        
-       if ($db->num_rows($favorites) < 1)
+       if ($favorites->size() < 1)
        {
                $message->error(T('You do not have any favorites in your list. To add a bug to your list, while viewing the report, click the [Add to Favorites] link next to the bug\'s ID.'));
        }
@@ -91,20 +90,19 @@ if ($_REQUEST['do'] == 'manage')
        
        $headers = $sort->constructColumnHeaders(false);
        
-       while ($bug = $db->fetch_array($favorites))
+       foreach ($favorites as $bug)
        {
-               $funct->exec_swap_bg('altcolor', '');
-               $bug = ProcessBugDataForDisplay($bug, $funct->bgcolour);
+               BSFunctions::swap_css_classes('altcolor', '');
+               $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
                $bugs .= $sort->constructRow($bug);
        }
        
-       eval('$template->flush("' . $template->fetch('favorites') . '");');
+       $tpl = new BSTemplate('favorites');
+       $tpl->vars = array(
+               'bugs'          => $bugs,
+               'headers'       => $headers
+       );
+       $tpl->evaluate()->flush();
 }
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file