Main Page | Directories | File List | File Members

format.php File Reference

Go to the source code of this file.

Functions

 format_item_details ($item_id, $group_id, $ascii=false, $item_assigned_to=false, $quoted=false)
 format_item_changes ($changes, $item_id, $group_id)
 format_item_attached_files ($item_id, $group_id, $ascii=false, $sober=false)
 format_item_cc_list ($item_id, $group_id, $ascii=false)


Function Documentation

format_item_attached_files item_id,
group_id,
ascii = false,
sober = false
 

Definition at line 306 of file format.php.

References $GLOBALS, $HTML, $out, $result, $rows, db_numrows(), db_result, format_date(), group_id, member_check(), member_create_tracker_flag(), nbsp, s, trackers_data_get_attached_files(), and utils_filesize().

00307 {
00308 
00309   global $sys_datefmt, $HTML;
00310 
00311   # ASCII must not be translated
00312 
00313   if (!$sober)
00314     {
00315       $result=trackers_data_get_attached_files($item_id);
00316     }
00317   else
00318     {
00319       # In sober output, we assume that files are interesting in their
00320       # chronological order.
00321       # For instance, on the cookbook, if screenshots are provided, the author
00322       # of the item is likely to have posted them in the order of their use.
00323       # On the other hand, on non-sober output, what matters is the latest
00324       # submitted item.
00325       $result=trackers_data_get_attached_files($item_id, 'ASC');
00326     }
00327   $rows=db_numrows($result);
00328 
00329   # No file attached -> return now
00330   if ($rows <= 0)
00331     {
00332       if ($ascii)
00333         $out = "";
00334       else
00335         $out = '<span class="warn">'._("No files currently attached").'</span>';
00336       return $out;
00337     }
00338 
00339   # Header first
00340   if ($ascii)
00341     {
00342       $out .= "    _______________________________________________________\n\nFile Attachments:\n\n";
00343     }
00344   else
00345     {
00346       if (!$sober)
00347         {
00348           $out .= $HTML->box_top(_("Attached Files"),'',1);
00349         }
00350     }
00351 
00352   # Determine what the print out format is based on output type (Ascii, HTML
00353   if ($ascii)
00354     {
00355       $fmt = "\n-------------------------------------------------------\n".
00356          "Date: %s  Name: %s  Size: %s   By: %s\n%s\n%s";
00357     }
00358 
00359   # Loop throuh the attached files and format them
00360   for ($i=0; $i < $rows; $i++)
00361     {
00362 
00363       $item_file_id = db_result($result, $i, 'file_id');
00364       if ($ascii)
00365         {
00366           $href = $GLOBALS['sys_home'].ARTIFACT."/download.php?file_id=$item_file_id";
00367         }
00368       else
00369         {
00370           $href = $GLOBALS['sys_home'].ARTIFACT."/download.php?file_id=$item_file_id";
00371         }
00372 
00373       if ($ascii)
00374         {
00375           $out .= sprintf($fmt,
00376                           format_date($sys_datefmt,db_result($result, $i, 'date')),
00377                           db_result($result, $i, 'filename'),
00378                           utils_filesize(0, intval(db_result($result, $i, 'filesize'))),
00379                           db_result($result, $i, 'user_name'),
00380                           db_result($result, $i, 'description'),
00381                           '<http://'.$GLOBALS['sys_default_domain'].utils_unconvert_htmlspecialchars($href).'>');
00382         }
00383       else
00384         {
00385           unset($html_delete);
00386           if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2') && !$sober)
00387             {
00388               $html_delete = '<span class="trash"><a href="'.$PHP_SELF.'?func=delete_file&amp;item_id='.$item_id.'&amp;item_file_id='.$item_file_id.'">'.
00389                 '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/trash.png" class="icon" alt="'._("Delete").'" /></a></span>';
00390             }
00391 
00392 
00393           if (!$sober)
00394             {
00395               $out .= '<div class="'.utils_get_alt_row_color($i).'">'.$html_delete;
00396             }
00397           else
00398             {
00399               $out .= '<div>&nbsp;&nbsp;&nbsp;- ';
00400             }
00401 
00402           $out .= '<a href="'.$href.'">file #'.$item_file_id.'</a>'._(": ").'&nbsp;';
00403 
00404           if (!$sober)
00405             {
00406               $out .= sprintf(_('%s added by %s'), '<a href="'.$href.'">'.db_result($result, $i, 'filename').'</a>', utils_user_link(db_result($result, $i, 'user_name')));
00407             }
00408           else
00409             {
00410               $out .= '<a href="'.$href.'">'.db_result($result, $i, 'filename').'</a>';
00411             }
00412 
00413           $out .= ' <span class="smaller">('.utils_filesize(0, intval(db_result($result, $i, 'filesize')));
00414 
00415           if (db_result($result, $i, 'filetype'))
00416             {
00417               $out .= ' - '.db_result($result, $i, 'filetype');
00418             }
00419 
00420           if (db_result($result, $i, 'description'))
00421             {
00422               $out .= ' - '
00423                 .utils_basic_markup(db_result($result, $i, 'description'));
00424             }
00425           $out .= ')</span></div>';
00426         }
00427     }
00428 
00429   # final touch...
00430 
00431   if ($ascii || $sober)
00432   {
00433     $out .= "\n";
00434   }
00435   else
00436   {
00437     $out .= $HTML->box_bottom(1);
00438   }
00439 
00440   return($out);
00441 
00442 }

format_item_cc_list item_id,
group_id,
ascii = false
 

Definition at line 446 of file format.php.

References $HTML, $out, $result, $rows, db_numrows(), db_result, group_id, member_check(), member_create_tracker_flag(), s, trackers_data_get_cc_list(), user_get_result_set_from_unix(), and utils_email().

00447 {
00448 # ASCII must not be translated
00449   global $sys_datefmt, $HTML;
00450 
00451   /*
00452           show the files attached to this bug
00453   */
00454 
00455   $result=trackers_data_get_cc_list($item_id);
00456   $rows=db_numrows($result);
00457 
00458   # No file attached -> return now
00459   if ($rows <= 0)
00460     {
00461       if ($ascii)
00462         {
00463           $out .= "";
00464         }
00465       else
00466         {
00467           $out = '<span class="warn">'._("CC list is empty").'</span>';
00468         }
00469       return $out;
00470     }
00471 
00472   # Header first an determine what the print out format is
00473   # based on output type (Ascii, HTML)
00474   if ($ascii)
00475     {
00476       $out .= "    _______________________________________________________\n\n"."Carbon-Copy List:\n\n";
00477       $fmt = "%-35s | %s\n";
00478       $out .= sprintf($fmt, 'CC Address', 'Comment');
00479       $out .= "------------------------------------+-----------------------------\n";
00480     }
00481   else
00482     {
00483       $out .= $HTML->box_top(_("Carbon-Copy List"),'',1);
00484     }
00485 
00486   # Loop through the cc and format them
00487   for ($i=0; $i < $rows; $i++)
00488     {
00489 
00490       if ($ascii)
00491         {
00492           # We wont provide the CC address in the mail, we keep that
00493           # information only on the web interface
00494           $email = "Available only the item webpage";
00495         }
00496       else
00497         {
00498           $email = utils_email(db_result($result, $i, 'email'));
00499         }
00500       $item_cc_id = db_result($result, $i, 'bug_cc_id');
00501 
00502       # If the CC is a user point to its user page.
00503       # Do not build mailto, we do not need to help spammers.
00504       $res_username = user_get_result_set_from_unix($email);
00505       if ($res_username && (db_numrows($res_username) == 1))
00506         { $href_cc = utils_user_link($email); }
00507       else
00508         { $href_cc = $email; }
00509 
00510       if ($ascii)
00511         {
00512           $out .= sprintf($fmt, $email, db_result($result, $i, 'comment'));
00513         }
00514       else
00515         {
00516 
00517           # show CC delete icon if one of the condition is met:
00518           # a) current user is a tracker manager
00519           # b) then CC name is the current user
00520           # c) the CC email address matches the one of the current user
00521           # d) the current user is the person who added a given name in CC list
00522           if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2') ||
00523               (user_getname(user_getid()) == $email) ||
00524               (user_getemail(user_getid()) == $email) ||
00525               (user_getname(user_getid()) == db_result($result, $i, 'user_name') ))
00526             {
00527 $html_delete = '<span class="trash"><a href="'.$PHP_SELF.'?func=delete_cc&amp;item_id='.$item_id.'&amp;item_cc_id='.$item_cc_id.'">'.
00528                  '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/trash.png" class="icon" alt="'._("Delete").'" /></a></span>';
00529             }
00530           else
00531             {
00532               $html_delete = '';
00533             }
00534 
00535           $out .= '<li class="'.utils_get_alt_row_color($i).'">'.$html_delete.
00536           sprintf(_('%s added by %s'), $email, utils_user_link(db_result($result, $i, 'user_name')));
00537           if (db_result($result, $i, 'comment'))
00538            {
00539              $out .= ' <span class="smaller">('.utils_basic_markup(db_result($result, $i, 'comment')).')</span>';
00540            }
00541 
00542 #$href_cc,
00543 #                         format_date($sys_datefmt,db_result($result, $i, 'date')),
00544 #                         $html_delete);
00545         }
00546     }
00547 
00548   # final touch...
00549   $out .= ($ascii ? "\n" : $HTML->box_bottom(1));
00550 
00551   return($out);
00552 
00553 }

format_item_changes changes,
item_id,
group_id
 

Definition at line 213 of file format.php.

References $changes, $field, $item_id, $label, $out, Error, group_id, trackers_data_get_followups(), trackers_data_get_label(), and utils_unconvert_htmlspecialchars().

00214 {
00215 
00216 
00217   # ASCII must not be translated
00218 
00219   global $sys_datefmt;
00220 
00221   # FIXME: strange, with %25s it does not behave exactly like
00222   # trackers_field_label_display
00223   $fmt = "%24s: %23s => %-23s\n";
00224 
00225   $separator = "\n    _______________________________________________________\n\n";
00226 
00227   # Process most of the fields
00228   reset($changes);
00229   while (list($field,$h) = each($changes))
00230     {
00231 
00232       # If both removed and added items are empty skip - Sanity check
00233       if (!$h['del'] && !$h['add'])
00234         { continue; }
00235 
00236       if ($field == "details" || $field == "attach")
00237         { continue; }
00238 
00239       # Since details is used for followups (creepy!), we are forced to play
00240       # with "realdetails" non existant field.
00241       if ($field == "realdetails")
00242         { $field = "details"; }
00243 
00244       $label = trackers_data_get_label($field);
00245       if (!$label)
00246         { $label = $field; }
00247       $out .= sprintf($fmt, $label, $h['del'],$h['add']);
00248     }
00249 
00250   if ($out)
00251     {
00252       $out = "Update of ".utils_get_tracker_prefix(ARTIFACT)." #".$item_id." (project ".group_getunixname($group_id)."):\n\n".$out;
00253     }
00254 
00255 
00256   # Process special cases: follow-up comments
00257   if ($changes['details'])
00258     {
00259 
00260       if ($out)
00261         { $out .= $separator; }
00262 
00263       $out_com = "Follow-up Comment #".db_numrows(trackers_data_get_followups($item_id));
00264       if (!$out)
00265         {
00266           $out_com .= ", ".utils_get_tracker_prefix(ARTIFACT)." #".$item_id." (project ".group_getunixname($group_id).")";
00267         }
00268 
00269       $out_com .= ":\n\n";
00270       if ($changes['details']['type'] != 'None' && $changes['details']['type'] != '(Error - Not Found)')
00271         {
00272           $out_com .= '['.$changes['details']['type']."]\n";
00273         }
00274       $out_com .= utils_unconvert_htmlspecialchars($changes['details']['add']);
00275       unset($changes['details']);
00276 
00277       $out .= $out_com;
00278     }
00279 
00280 
00281   # Process special cases: file attachment
00282   if ($changes['attach'])
00283     {
00284       if ($out)
00285         { $out .= $separator; }
00286 
00287       $out_att = "Additional Item Attachment";
00288       if (!$out)
00289         {
00290           $out_att .= ", ".utils_get_tracker_prefix(ARTIFACT)." #".$item_id." (project ".group_getunixname($group_id).")";
00291         }
00292       $out_att .= ":\n\n";
00293       $out_att .= sprintf("File name: %-30s Size:%d KB\n",$changes['attach']['name'],
00294                           intval($changes['attach']['size']/1024) );
00295       $out_att .= $changes['attach']['description']."\n".'<'.$changes['attach']['href'].'>';
00296       unset($changes['attach']);
00297 
00298       $out .= $out_att;
00299     }
00300 
00301   return $out;
00302 
00303 }

format_item_details item_id,
group_id,
ascii = false,
item_assigned_to = false,
quoted = false
 

Definition at line 28 of file format.php.

References $i, $icon, $name, $out, $previous, $result, $rows, $title_arr, db_numrows(), db_result, format_date(), group_id, member_check(), trackers_data_get_followups(), and utils_unconvert_htmlspecialchars().

00029 {
00030   ## ASCII must not be translated
00031 
00032 
00033   #  Format the details rows from trackers_history
00034   global $sys_datefmt;
00035 
00036   if (!$ascii && user_get_preference("reverse_comments_order"))
00037     { $result = trackers_data_get_followups($item_id, false); }
00038   else
00039     { $result=trackers_data_get_followups($item_id); }
00040   $rows=db_numrows($result);
00041 
00042   # No followup comment -> return now
00043   if ($rows <= 0)
00044     {
00045       if ($ascii)
00046         $out = "";
00047       else
00048         $out = '<span class="warn">'._("No Followups Have Been Posted").'</span>';
00049       return $out;
00050     }
00051 
00052   # Header first
00053   if ($ascii)
00054     {
00055       $out .= "    _______________________________________________________\n\nFollow-up Comments:\n\n";
00056     }
00057   else
00058     {
00059       $title_arr=array();
00060       $title_arr[]=_("Comment");
00061       $title_arr[]=_("Posted By");
00062 
00063       $out .= html_build_list_table_top ($title_arr);
00064     }
00065 
00066   # Loop throuh the follow-up comments and format them
00067   for ($i=0; $i < $rows; $i++)
00068     {
00069 
00070       $comment_type = db_result($result, $i, 'comment_type');
00071       if ($comment_type == 'None')
00072         { $comment_type = ''; }
00073       else
00074         { $comment_type = '['.$comment_type.']'; }
00075 
00076       if ($ascii)
00077         {
00078           $fmt = "\n-------------------------------------------------------\n".
00079              "Date: %-30sBy: %s\n";
00080           if ($comment_type)
00081             { $fmt .= "%s\n%s"; }
00082           else
00083             { $fmt .= "%s%s"; }
00084           $fmt .= "\n";
00085         }
00086 
00087       # I wish we had sprintf argument swapping in PHP3 but
00088       # we dont so do it the ugly way...
00089       if ($ascii)
00090         {
00091           if (db_result($result, $i, 'realname'))
00092             {
00093               $name = db_result($result, $i, 'realname')." <".db_result($result, $i, 'user_name').">";
00094             }
00095           else
00096             {
00097               $name = "Anonymous"; # must no be translated, part of mails notifs
00098                                      }
00099           $out .= sprintf($fmt,
00100                           format_date($sys_datefmt,db_result($result, $i, 'date')),
00101                           $name,
00102                           $comment_type,
00103                           utils_unconvert_htmlspecialchars(db_result($result, $i, 'old_value'))
00104                           );
00105         }
00106       else
00107         {
00108           if ($comment_type)
00109             {
00110               # put the comment type in strong
00111               $comment_type = '<strong>'.$comment_type.'</strong><br />';
00112             }
00113 
00114           if (!user_get_preference("reverse_comments_order"))
00115             {
00116               $comment_number = ($rows-$i);
00117             }
00118           else
00119             {
00120               $comment_number = ($i+1);
00121             }
00122 
00123           $class = utils_get_alt_row_color($i);
00124           unset($icon, $assignee);
00125 
00126           # Find out the user id of the comment author
00127           $poster_id = user_getid(db_result($result, $i, 'user_name'));
00128 
00129           # Ignore user 100 (anonymous)
00130           if ($poster_id != 100)
00131             {
00132 
00133               # Cosmetics if the user is assignee
00134               if ($item_assigned_to == db_result($result, $i, 'user_name'))
00135                 {
00136                   # Highlight the latest comment of the assignee
00137                   if ($previous != 1)
00138                     {
00139                       $class = "boxhighlight";
00140                       $previous = 1;
00141                     }
00142 
00143                   $assignee = 1;
00144                 }
00145 
00146               # Cosmetics if the user is project member (we wont go as far
00147               # as presenting a different icon for specific roles, like
00148               # manager etc..
00149 
00150               if (member_check($poster_id, $group_id, 'A'))
00151                 {
00152                   # Project admin case: if the group is the admin group,
00153                   # show the specific site admin icon
00154                   if ($group_id == $GLOBALS[sys_group_id])
00155                     {
00156                       $icon = "site-admin";
00157                       $icon_alt = _("Site Administrator");
00158                     }
00159                   else
00160                     {
00161                       $icon = "project-admin";
00162                       $icon_alt = _("Project Administrator");
00163                     }
00164                 }
00165               elseif (member_check($poster_id, $group_id))
00166                 {
00167                   # Simple project member
00168                   $icon = "project-member";
00169                   $icon_alt = _("Project Member");
00170                 }
00171             }
00172 
00173               if (! $quoted)
00174                 {
00175                   $text_to_markup = db_result($result, $i, 'old_value');
00176                 }
00177               else
00178                 {
00179                   $text_to_markup = str_replace("\n", "&gt; ",
00180                     wordwrap("\n".db_result($result, $i, 'old_value'), 78, "\r\n"));
00181                 }
00182 
00183               $out .= "\n".'<tr class="'.$class.'"><td valign="top">';
00184               $out .= '<a name="comment'.$comment_number.'" href="#comment'.$comment_number.'" class="preinput">';
00185               $out .= format_date($sys_datefmt,db_result($result, $i, 'date'));
00186               $out .= ', '.sprintf(_("comment #%s:"), $comment_number).'</a>'.$comment_type;
00187               $out .= utils_rich_markup($text_to_markup).'</td>';
00188               $out .= '<td valign="top" align="center">'.utils_user_link(db_result($result, $i, 'user_name'),db_result($result, $i, 'realname'));
00189 
00190           if ($icon)
00191             {
00192               $out .= '<br /><span class="help" title="'.$icon_alt.'"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/'.$icon.'.png" alt="'.$icon_alt.'" /></span>';
00193             }
00194 
00195           if ($assignee)
00196             {
00197               $out .= '<span class="help" title="'._("In charge of this item.").'"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/assignee.png" alt="'._("In charge of this item.").'" /></span>';
00198             }
00199 
00200           $out .= '</td></tr>';
00201 
00202         }
00203     }
00204 
00205   # final touch...
00206   $out .= ($ascii ? "\n\n\n" : "</table>");
00207 
00208   return($out);
00209 }


Generated on Sun Feb 26 13:23:05 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4