Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / showhistory.php
index ebef405970a74726972d56001c0f378d5a2d5f1e..25bca98717f9f201f5ce4525d9b2ba7a33788659 100644 (file)
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Bugdar
-|| # Copyright ©2002-2007 Blue Static
+|| # Copyright (c)2004-2009 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
@@ -24,14 +24,13 @@ $fetchtemplates = array(
        'history_bit'
 );
 
-define('SVN', '$Id$');
 
 $focus['showreport'] = 'focus';
 
 require_once('./global.php');
 require_once('./includes/api_user.php');
 
-$bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $bugsys->input_clean('bugid', TYPE_UINT));
+$bug = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $input->inputClean('bugid', TYPE_UINT));
 if (!$bug)
 {
        $message->error(L_INVALID_ID);
@@ -60,11 +59,11 @@ $customfields = $db->query("
        LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
                ON (bugfield.fieldid = permission.fieldid)
        WHERE mask <> 0
-       AND permission.usergroupid IN ({$bugsys->userinfo['usergroupid']}" . (sizeof($bugsys->userinfo['groupids']) != 0 ? ',' . implode(',', $bugsys->userinfo['groupids']) : '') . ")
+       AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ")
        GROUP BY (bugfield.fieldid)"
 );
 
-while ($field = $db->fetch_array($customfields))
+foreach ($customfields as $field)
 {
        $fieldlist["$field[fieldid]"] = sprintf(T('Custom Field %1$s (%2$s)'), $field['fieldid'], $field['name']);
 }
@@ -79,9 +78,9 @@ $logs_fetch = $db->query("
                ON (user.userid = history.userid)
        WHERE bugid = $bug[bugid]"
 );
-while ($log = $db->fetch_array($logs_fetch))
+foreach ($logs_fetch as $log)
 {
-       $log['date'] = $datef->format($bugsys->options['dateformat'], $log['dateline']);
+       $log['date'] = $datef->format(bugdar::$options['dateformat'], $log['dateline']);
        $log['user'] = construct_user_display($log);
        
        $logs["$log[dateline]"]["$log[historyid]"] = $log;
@@ -133,35 +132,39 @@ foreach ($logs AS $dateline => $logitems)
                        if (isset($lookupfields["$matches[1]"]))
                        {
                                $lookup = $matches[1];
-                               $log['original'] = $bugsys->datastore["$lookup"]["$log[original]"][ $lookupfields["$lookup"] ];
-                               $log['changed'] = $bugsys->datastore["$lookup"]["$log[changed]"][ $lookupfields["$lookup"] ];
+                               $log['original'] = bugdar::$datastore["$lookup"]["$log[original]"][ $lookupfields["$lookup"] ];
+                               $log['changed'] = bugdar::$datastore["$lookup"]["$log[changed]"][ $lookupfields["$lookup"] ];
                        }
                        else if ($matches[1] == 'assignto' OR $matches[1] == 'assignedto')
                        {
                                if ($log['original'])
                                {
-                                       $user = new UserAPI($bugsys);
+                                       $user = new UserAPI();
                                        $user->set('userid', $log['original']);
-                                       $user->set_condition();
+                                       $user->setCondition();
                                        $user->fetch();
-                                       $log['original'] = construct_user_display($user->objdata);
+                                       $log['original'] = construct_user_display($user->record);
                                }
                                
                                if ($log['changed'])
                                {
-                                       $user = new UserAPI($bugsys);
+                                       $user = new UserAPI();
                                        $user->set('userid', $log['changed']);
-                                       $user->set_condition();
+                                       $user->setCondition();
                                        $user->fetch();
-                                       $log['changed'] = construct_user_display($user->objdata);
+                                       $log['changed'] = construct_user_display($user->record);
                                }
                        }
                }
                
-               $funct->exec_swap_bg('', 'altcolor');
-               $bgcolor = $funct->bgcolour;
+               BSFunctions::swap_css_classes('', 'altcolor');
                
-               eval('$history .= "' . $template->fetch('history_bit') . '";');
+               $tpl = new BSTemplate('history_bit');
+               $tpl->vars = array(
+                       'bgcolor'       => BSFunctions::$cssClass,
+                       'log'           => $log
+               );
+               $history .= $tpl->evaluate()->getTemplate();
                $show['group'] = false;
        }
 }
@@ -172,12 +175,11 @@ if (sizeof($toKill) > 0)
        $db->query("DELETE FROM " . TABLE_PREFIX . "history WHERE historyid IN (" . implode(',', $toKill) . ")");
 }
 
-eval('$template->flush("' . $template->fetch('history') . '");');
+$tpl = new BSTemplate('history');
+$tpl->vars = array(
+       'history'       => $history,
+       'bug'           => $bug
+);
+$tpl->evaluate()->flush();
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file