示例#1
0
    /**
     * Show all the cc addresses of all the artifacts in $change_ids
     * @param group_id: the group id
     * @param group_artifact_id: the artifact type ID
     * @param change_ids: all the ids of the artifacts affected
     */
    function showCCList($change_ids)
    {
        $hp = Codendi_HTMLPurifier::instance();
        global $Language;
        $out = "";
        $result = $this->getCC($change_ids);
        if (db_numrows($result) > 0) {
            $title_arr = array();
            $title_arr[] = $Language->getText('tracker_include_artifact', 'cc_address');
            $title_arr[] = $Language->getText('tracker_include_type', 'occurrence');
            $title_arr[] = $Language->getText('tracker_include_canned', 'delete');
            $out .= html_build_list_table_top($title_arr);
            $fmt = "\n" . '<TR class="%s"><td>%s</td><td align="center">%s</td><td align="center">%s</td></tr>';
            // Loop through the cc and format them
            $email = "";
            $row_color = 0;
            $i = 0;
            while ($row = db_fetch_array($result)) {
                if ($row['email'] != $email) {
                    if ($email != "") {
                        $html_delete = '
		<INPUT TYPE="CHECKBOX" NAME="delete_cc[]" VALUE="' . $hp->purify($delete_ids, CODENDI_PURIFIER_CONVERT_HTML) . '">';
                        $out .= sprintf($fmt, util_get_alt_row_color($row_color), $href_cc, $i, $html_delete);
                        $row_color++;
                        $i = 0;
                    }
                    $email = $row['email'];
                    $res_username = user_get_result_set_from_unix($email);
                    if ($res_username && db_numrows($res_username) == 1) {
                        $href_cc = util_user_link($email);
                    } else {
                        $href_cc = "<a href=\"mailto:" . util_normalize_email($email) . "\">" . $hp->purify($email, CODENDI_PURIFIER_CONVERT_HTML) . '</a>';
                    }
                    $delete_ids = $row['artifact_cc_id'];
                } else {
                    $delete_ids .= "," . $row['artifact_cc_id'];
                }
                $i++;
            }
            $html_delete = '
		<INPUT TYPE="CHECKBOX" NAME="delete_cc[]" VALUE="' . $delete_ids . '">';
            $out .= sprintf($fmt, util_get_alt_row_color($row_color), $href_cc, $i, $html_delete);
            $out .= "</TABLE>";
        }
        return $out;
    }
示例#2
0
 /**
  * return a field for the given user.
  * 
  * @protected
  **/
 function _getFieldLabelAndValueForUser($group_id, $group_artifact_id, &$field, $user_id, $force_read_only = false)
 {
     $html = false;
     if ($field->userCanRead($group_id, $group_artifact_id, $user_id)) {
         $read_only = $force_read_only || !$field->userCanUpdate($group_id, $group_artifact_id, $user_id);
         // For multi select box, we need to retrieve all the values
         if ($field->isMultiSelectBox()) {
             $field_value = $field->getValues($this->getID());
         } else {
             $field_value = $this->getValue($field->getName());
         }
         $field_html = new ArtifactFieldHtml($field);
         $label = $field_html->labelDisplay(false, false, !$read_only);
         $label .= $field->isEmptyOk() ? '' : '<span class="highlight"><big>*</big></b></span>';
         // original submission field must be displayed read-only,
         // except for site admin, tracker admin and for the artifact submitter
         if ($field->getName() == 'details') {
             if (user_is_super_user() || $this->ArtifactType->userIsAdmin() || $this->getSubmittedBy() == $user_id) {
                 // original submission is editable
                 $value = $field_html->display($this->ArtifactType->getID(), $field_value, false, false, $read_only);
             } else {
                 $value = util_make_links($field_html->display($this->ArtifactType->getID(), $field_value, false, false, true), $group_id, $group_artifact_id);
             }
         } else {
             if ($field->getName() == 'submitted_by') {
                 $value = util_user_link(user_getname($field_value));
             } else {
                 if ($field->getName() == 'open_date') {
                     $value = format_date($GLOBALS['Language']->getText('system', 'datefmt'), $field_value);
                 } else {
                     if ($field->getName() == 'last_update_date') {
                         $value = format_date($GLOBALS['Language']->getText('system', 'datefmt'), $field_value);
                     } else {
                         $value = $field_html->display($this->ArtifactType->getID(), $field_value, false, false, $read_only);
                         if ($read_only) {
                             $value = util_make_links($value, $group_id, $group_artifact_id);
                         }
                     }
                 }
             }
         }
         $html = array('label' => $label, 'value' => $value);
     }
     return $html;
 }
示例#3
0
function show_commitslist($result, $offset, $total_rows, $set = 'any', $commiter = '100', $tag = '100', $branch = '100', $srch = '', $chunksz = 15, $morder = '', $msort = 0)
{
    global $group_id, $Language;
    /*
    	Accepts a result set from the commits table. Should include all columns from
    	the table, and it should be joined to USER to get the user_name.
    */
    $url = '?func=browse&group_id=' . $group_id . '&set=' . $set . '&msort=' . $msort;
    if ($set == 'custom') {
        $url .= $pref_stg;
    }
    $url_nomorder = $url;
    $url .= "&morder={$morder}";
    if ($morder != '') {
        $orderstr = ' ' . $Language->getText('cvs_commit_utils', 'sorted_by') . ' ' . commit_criteria_list_to_text($morder, $url_nomorder);
    } else {
        $orderstr = '';
    }
    echo '<A name="results"></A>';
    echo '<h3>' . $total_rows . ' ' . $Language->getText('cvs_commit_utils', 'matching') . ($totalrows > 1 ? 's' : '') . $orderstr . '</h3>';
    $nav_bar = '<table width= "100%"><tr>';
    $nav_bar .= '<td width="20%" align ="left">';
    if ($msort) {
        $url_alternate_sort = str_replace('msort=1', 'msort=0', $url) . '&order=#results';
        $text = $Language->getText('cvs_commit_utils', 'deactivate');
    } else {
        $url_alternate_sort = str_replace('msort=0', 'msort=1', $url) . '&order=#results';
        $text = $Language->getText('cvs_commit_utils', 'activate');
    }
    echo '<P>' . $Language->getText('cvs_commit_utils', 'sort_msg', array($url . '&order=#results', $url_alternate_sort, $text));
    // If all bugs on screen so no prev/begin pointer at all
    if ($total_rows > $chunksz) {
        if ($offset > 0) {
            $nav_bar .= '<A HREF="' . $url . '&offset=0#results"><B>&lt;&lt;  ' . $Language->getText('global', 'begin') . '</B></A>' . '&nbsp;&nbsp;&nbsp;&nbsp;' . '<A HREF="' . $url . '&offset=' . ($offset - $chunksz) . '#results"><B>< ' . $Language->getText('global', 'prev') . ' ' . $chunksz . '</B></A></td>';
        } else {
            $nav_bar .= '<span class="disable">&lt;&lt; ' . $Language->getText('global', 'begin') . '&nbsp;&nbsp;&lt; ' . $Language->getText('global', 'prev') . ' ' . $chunksz . '</span>';
        }
    }
    $nav_bar .= '</td>';
    $offset_last = min($offset + $chunksz - 1, $total_rows - 1);
    $nav_bar .= '<td width= "60% " align = "center" class="small">Items ' . ($offset + 1) . ' - ' . ($offset_last + 1) . "</td>\n";
    $nav_bar .= '<td width="20%" align ="right">';
    // If all bugs on screen, no next/end pointer at all
    if ($total_rows > $chunksz) {
        if ($offset + $chunksz < $total_rows) {
            $offset_end = $total_rows - $total_rows % $chunksz;
            if ($offset_end == $total_rows) {
                $offset_end -= $chunksz;
            }
            $nav_bar .= '<A HREF="' . $url . '&offset=' . ($offset + $chunksz) . '#results" class="small"><B>' . $Language->getText('global', 'next') . ' ' . $chunksz . ' &gt;</B></A>' . '&nbsp;&nbsp;&nbsp;&nbsp;' . '<A HREF="' . $url . '&offset=' . $offset_end . '#results" class="small"><B>' . $Language->getText('global', 'end') . ' &gt;&gt;</B></A></td>';
        } else {
            $nav_bar .= '<span class="disable">' . $Language->getText('global', 'next') . ' ' . $chunksz . ' &gt;&nbsp;&nbsp;' . $Language->getText('global', 'end') . ' &gt;&gt;</span>';
        }
    }
    $nav_bar .= '</td>';
    $nav_bar .= "</tr></table>\n";
    echo $nav_bar;
    $filter_str = '';
    if ($commiter != '100') {
        $filter_str = "&commiter='{$commiter}'";
    }
    if ($tag != '100') {
        $filter_str = $filter_str . "&tag='{$tag}'";
    }
    if ($branch != '100') {
        $filter_str = $filter_str . "&branch='{$branch}'";
    }
    if ($srch != '') {
        $filter_str = $filter_str . "&srch='{$srch}'";
    }
    $rows = db_numrows($result);
    $url .= "&order=";
    $title_arr = array();
    $title_arr[] = $Language->getText('cvs_commit_utils', 'id');
    $title_arr[] = $Language->getText('cvs_commit_utils', 'description');
    $title_arr[] = $Language->getText('cvs_commit_utils', 'date');
    $title_arr[] = $Language->getText('cvs_commit_utils', 'who');
    $links_arr = array();
    $links_arr[] = $url . 'id#results';
    $links_arr[] = $url . 'description#results';
    $links_arr[] = $url . 'f_when#results';
    $links_arr[] = $url . 'user_name#results';
    $url_nomorder = $url;
    $url .= "&morder={$morder}";
    echo html_build_list_table_top($title_arr, $links_arr);
    for ($i = 0; $i < $rows; $i++) {
        $filename = db_result($result, $i, 'filename');
        if (!$filename) {
            $filename = '';
        }
        ##$commits_url = '<A HREF="/commits/download.php/Commits'.$commit_id.'.txt?commit_id='.$id.'">'.$filename.'</a>';
        ## if (commits.id == '0', will fetch on desc id, else on commit_id
        $id_str = db_result($result, $i, 'id');
        $id_link = '&commit_id=' . $id_str;
        $id_sublink = '';
        if ($id_str == '0') {
            $id_str = ' ? ';
            $id_link = "&checkin_id=" . db_result($result, $i, 'did') . "&when=" . db_result($result, $i, 'c_when') . $filter_string;
        }
        echo '
			<TR class="' . util_get_alt_row_color($i) . '">' . '<TD class="small"><b><A HREF="?func=detailcommit&group_id=' . $group_id . $id_link . $filter_string . '">' . $id_str . '</b></A></TD>' . '<TD class="small">' . util_make_links(join('<br>', split("\n", db_result($result, $i, 'description'))), $group_id) . $id_sublink . '</TD>' . '<TD class="small">' . uniformat_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'c_when')) . '</TD>' . '<TD class="small">' . util_user_link(db_result($result, $i, 'who')) . '</TD></TR>';
    }
    /*
    	Show extra rows for <-- Prev / Next -->
    */
    echo '</TD></TR></TABLE>';
    echo $nav_bar;
}
示例#4
0
 /**
  * Display the list of attached files
  *
  * @param group_id: the group id
  * @param group_artifact_id: the artifact type ID
  * @param ascii: ascii mode
  *
  * @return void
  */
 function showAttachedFiles($group_id, $group_artifact_id, $ascii = false, $pv = 0)
 {
     global $Language;
     $hp = $this->getHtmlPurifier();
     //
     //  show the files attached to this artifact
     //
     $result = $this->getAttachedFiles();
     $rows = db_numrows($result);
     // No file attached -> return now
     if ($rows <= 0) {
         if ($ascii) {
             $out = $Language->getText('tracker_include_artifact', 'no_file_attached') . $GLOBALS['sys_lf'];
         } else {
             $out = '<H4>' . $Language->getText('tracker_include_artifact', 'no_file_attached') . '</H4>';
         }
         return $out;
     }
     // Header first
     if ($ascii) {
         $out = $Language->getText('tracker_include_artifact', 'file_attachment') . $GLOBALS['sys_lf'] . str_repeat("*", strlen($Language->getText('tracker_include_artifact', 'file_attachment')));
     } else {
         $title_arr = array();
         $title_arr[] = $Language->getText('tracker_include_artifact', 'name');
         $title_arr[] = $Language->getText('tracker_include_artifact', 'desc');
         $title_arr[] = $Language->getText('tracker_include_artifact', 'size_kb');
         $title_arr[] = $Language->getText('global', 'by');
         $title_arr[] = $Language->getText('tracker_include_artifact', 'posted_on');
         if ($pv == 0) {
             $title_arr[] = $Language->getText('tracker_include_canned', 'delete');
         }
         $out = html_build_list_table_top($title_arr);
     }
     // Determine what the print out format is based on output type (Ascii, HTML)
     if ($ascii) {
         $fmt = $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . "------------------------------------------------------------------" . $GLOBALS['sys_lf'] . $Language->getText('tracker_import_utils', 'date') . ": %s  " . $Language->getText('tracker_include_artifact', 'name') . ": %s  " . $Language->getText('tracker_include_artifact', 'size') . ": %dKB   " . $Language->getText('global', 'by') . ": %s" . $GLOBALS['sys_lf'] . "%s" . $GLOBALS['sys_lf'] . "%s";
     } else {
         $fmt = "" . $GLOBALS['sys_lf'] . '<TR class="%s"><td>%s</td><td>%s</td><td align="center">%s</td><td align="center">%s</td><td align="center">%s</td>';
         if ($pv == 0) {
             $fmt .= '<td align="center">%s</td>';
         }
         $fmt .= '</tr>';
     }
     // Determine which protocl to use for embedded URL in ASCII format
     $server = get_server_url();
     // Loop throuh the attached files and format them
     for ($i = 0; $i < $rows; $i++) {
         $artifact_file_id = db_result($result, $i, 'id');
         $href = "/tracker/download.php?artifact_id=" . (int) $this->getID() . "&id=" . (int) $artifact_file_id;
         if ($ascii) {
             $out .= sprintf($fmt, format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'adddate')), db_result($result, $i, 'filename'), intval(db_result($result, $i, 'filesize') / 1024), db_result($result, $i, 'user_name'), SimpleSanitizer::unsanitize(db_result($result, $i, 'description')), $server . $href);
         } else {
             // show CC delete icon if one of the condition is met:
             // (a) current user is group member
             // (b) the current user is the person who added a gieven name in CC list
             if (user_ismember($this->ArtifactType->getGroupID()) || user_getname(user_getid()) == db_result($result, $i, 'user_name')) {
                 $html_delete = '<a href="?func=delete_file&group_id=' . (int) $group_id . "&atid=" . (int) $group_artifact_id . "&aid=" . (int) $this->getID() . "&id=" . (int) db_result($result, $i, 'id') . '" ' . ' onClick="return confirm(\'' . $Language->getText('tracker_include_artifact', 'delete_attachment') . '\')">' . '<IMG SRC="' . util_get_image_theme("ic/trash.png") . '" HEIGHT="16" WIDTH="16" BORDER="0" ALT="' . $Language->getText('global', 'btn_delete') . '"></A>';
             } else {
                 $html_delete = '-';
             }
             $out .= sprintf($fmt, util_get_alt_row_color($i), '<a href="' . $href . '">' . $hp->purify(db_result($result, $i, 'filename'), CODENDI_PURIFIER_CONVERT_HTML) . '</a>', $hp->purify(SimpleSanitizer::unsanitize(db_result($result, $i, 'description')), CODENDI_PURIFIER_BASIC, $group_id), intval(db_result($result, $i, 'filesize') / 1024), util_user_link(db_result($result, $i, 'user_name')), format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'adddate')), $html_delete);
         }
     }
     // for
     // final touch...
     $out .= $ascii ? "" . $GLOBALS['sys_lf'] . "" : "</TABLE>";
     return $out;
 }
示例#5
0
function util_multi_user_link($usernames)
{
    $users = explode(", ", $usernames);
    if (count($users) > 1) {
        // Multiple users
        $str = "";
        for ($i = 0; $i < count($users) - 1; $i++) {
            $str .= util_user_link($users[$i]) . ", ";
        }
        $str .= util_user_link($users[$i]);
        return $str;
    } else {
        // Single user name
        return util_user_link($usernames);
    }
}