Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / showreport.php
index 591e00ebded112f1ac0edf4eb36a775015360ca1..8d0c9ba8d66cf3885a4a4754b1f4ff307f957e07 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
@@ -27,7 +27,6 @@ $fetchtemplates = array(
        'bugfield_static_text'
 );
 
-define('SVN', '$Id$');
 
 $focus['showreport'] = 'focus';
 
@@ -53,7 +52,9 @@ if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch')
                }
        }
        
-       eval('$template->flush("' . $template->fetch('quicksearch') . '");');
+       $tpl = new BSTemplate('quicksearch');
+       $tpl->vars = array('error' => $error);
+       $tpl->evaluate()->flush();
        exit;
 }
 
@@ -118,7 +119,7 @@ if ($show['edit'])
                }
        }
        
-       $productSelect = ConstructProductSelect('canviewbugs', "$bug[product],$bug[component],$bug[version]");
+       $productSelect = construct_product_select('canviewbugs', "$bug[product],$bug[component],$bug[version]");
        
        if ($bug['duplicateof'])
        {
@@ -252,11 +253,11 @@ foreach ($words AS $word)
 
 // -------------------------------------------------------------------
 // attachments
-$show['getattachments'] = ((can_perform('cangetattach', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? true : false);
-$show['putattachments'] = ((can_perform('canputattach', $bug['productid']) OR can_perform('caneditattach', $bug['productid'])) ? true : false);
-$show['attachments'] = ($show['getattachments'] OR $show['putattachments']) ? true : false;
+$show['getattachments'] = (can_perform('cangetattach', $bug['productid']) || can_perform('caneditattach', $bug['productid']));
+$show['putattachments'] = (can_perform('canputattach', $bug['productid']) || can_perform('caneditattach', $bug['productid']));
+$show['attachments'] = ($show['getattachments'] || $show['putattachments']);
 
-if ($show['getattachments'] OR $show['putattachments'])
+if ($show['getattachments'] || $show['putattachments'])
 {
        $attachments_fetch = $db->query("
                SELECT attachment.attachmentid, attachment.filename,
@@ -274,13 +275,18 @@ if ($show['getattachments'] OR $show['putattachments'])
        foreach ($attachments_fetch as $attachment)
        {
                $attaches = true;
-               $show['editattach'] = ((can_perform('caneditattach', $bug['productid']) OR ($attachment['userid'] == bugdar::$userinfo['userid'] AND can_perform('canputattach', $bug['productid']))) ? true : false);
+               $show['editattach'] = (can_perform('caneditattach', $bug['productid']) || ($attachment['userid'] == bugdar::$userinfo['userid'] && can_perform('canputattach', $bug['productid'])));
                $attachment['date'] = $datef->format(bugdar::$options['dateformat'], $attachment['dateline']);
                $attachment['user'] = construct_user_display($attachment, false);
-               eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
+               
+               $tpl = new BSTemplate('showreport_attachment');
+               $tpl->vars = array(
+                       'attachment'    => $attachment
+               );
+               $attachments .= $tpl->evaluate()->getTemplate();
        }
        
-       $show['attachments'] = (!$show['putattachments'] AND !$attaches) ? false : true;
+       $show['attachments'] = ($show['putattachments'] && $attaches);
 }
 
 // -------------------------------------------------------------------
@@ -313,6 +319,7 @@ $comments_fetch = $db->query("
                AND !hidden" : '') . "
        ORDER BY comment.dateline ASC"
 );
+$description = null;
 foreach ($comments_fetch as $comment)
 {
        $comment['posttime'] = $datef->format(bugdar::$options['dateformat'], $comment['dateline']);
@@ -335,7 +342,15 @@ foreach ($comments_fetch as $comment)
        
        $tpl = new BSTemplate('showreport_comment');
        $tpl->vars = array('comment' => $comment);
-       $comments .= $tpl->evaluate()->getTemplate();
+       $temp = $tpl->evaluate()->getTemplate();
+       if ($description == null)
+       {
+               $description = $temp;
+       }
+       else
+       {
+               $comments .= $temp;
+       }
 }
 
 $show['newreply'] = (can_perform('canpostcomments', $bug['productid']) ? true : false);
@@ -358,14 +373,10 @@ $tpl->vars = array(
        'select'                => $select,
        'vote'                  => $vote,
        'favoritetext'  => $favoritetext,
-       'customfields'  => $customfields
+       'customfields'  => $customfields,
+       'attachments'   => $attachments,
+       'productSelect' => $productSelect
 );
 $tpl->evaluate()->flush();
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file