Updating showreport.php for attachments
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 20:20:21 +0000 (16:20 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 20:20:21 +0000 (16:20 -0400)
showreport.php
templates/showreport_attachment.tpl

index 591e00ebded112f1ac0edf4eb36a775015360ca1..fac0811323e6571c5d7c22f13e68e8d1891b8fb0 100644 (file)
@@ -252,11 +252,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 +274,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);
 }
 
 // -------------------------------------------------------------------
@@ -358,7 +363,8 @@ $tpl->vars = array(
        'select'                => $select,
        'vote'                  => $vote,
        'favoritetext'  => $favoritetext,
-       'customfields'  => $customfields
+       'customfields'  => $customfields,
+       'attachments'   => $attachments
 );
 $tpl->evaluate()->flush();
 
index 0a09992e9d6127cc0cbd9586a1bfecce5d09d14b..042789d6e55da80a0cc1cdd081e78d9b94b1e66a 100644 (file)
@@ -1,6 +1,6 @@
                <div>
                        <% if ($show['editattach']): %><span style="float: <%- $stylevar['right'] %>; font-size: 10px">[<a href="attachment.php?do=edit&amp;attachmentid=<%- $attachment['attachmentid'] %>"><%-T("Edit")%></a>]</span><% endif %>
-                       <strong><a href="viewattachment.php?attachmentid=<%- $attachment['attachmentid'] %>" target="_blank"<% if ($attachment['obsolete']): %> style="text-decoration: line-through"<% endif %> title="<lang 1="$attachment[user]">{@"Posted by %1$s"}</lang>\n(<%- $attachment['date'] %>)"><%- $attachment['filename'] %></a></strong>
+                       <strong><a href="viewattachment.php?attachmentid=<%- $attachment['attachmentid'] %>" target="_blank"<% if ($attachment['obsolete']): %> style="text-decoration: line-through"<% endif %> title="<%- sprintf(T('Posted by %1$s'), $attachment['user']) %>\n(<%- $attachment['date'] %>)"><%- $attachment['filename'] %></a></strong>
                        <span style="font-size: 10px"><%- $attachment['description'] %></span>
                </div>