예제 #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
 /**
  * Display the list of CC addresses
  *
  * @param group_id: the group id
  * @param group_artifact_id: the artifact type ID
  * @param ascii: ascii mode
  *
  * @return void
  */
 function showCCList($group_id, $group_artifact_id, $ascii = false, $pv = 0)
 {
     $hp = Codendi_HTMLPurifier::instance();
     global $Language;
     //
     //      format the CC list for this artifact
     //
     $result = $this->getCCList();
     $rows = db_numrows($result);
     $out = '';
     // Nobody in the CC list -> return now
     if ($rows <= 0) {
         if ($ascii) {
             $out = $Language->getText('tracker_include_artifact', 'cc_empty') . $GLOBALS['sys_lf'];
         } else {
             $out = '<H4>' . $Language->getText('tracker_include_artifact', 'cc_empty') . '</H4>';
         }
         return $out;
     }
     // Header first an determine what the print out format is
     // based on output type (Ascii, HTML)
     if ($ascii) {
         $out .= $Language->getText('tracker_include_artifact', 'cc_list') . $GLOBALS['sys_lf'] . str_repeat("*", strlen($Language->getText('tracker_include_artifact', 'cc_list'))) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'];
         $fmt = "%-35s | %s" . $GLOBALS['sys_lf'];
         $out .= sprintf($fmt, $Language->getText('tracker_include_artifact', 'cc_address'), $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt'));
         $out .= "------------------------------------------------------------------" . $GLOBALS['sys_lf'];
     } else {
         $title_arr = array();
         $title_arr[] = $Language->getText('tracker_include_artifact', 'cc_address');
         $title_arr[] = $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt');
         $title_arr[] = $Language->getText('tracker_include_artifact', 'added_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);
         $fmt = "\n" . '<TR class="%s"><td>%s</td><td>%s</td><td align="center">%s</td><td align="center">%s</td>';
         if ($pv == 0) {
             $fmt .= '<td align="center">%s</td>';
         }
         $fmt .= '</tr>';
     }
     // Loop through the cc and format them
     for ($i = 0; $i < $rows; $i++) {
         $email = db_result($result, $i, 'email');
         $artifact_cc_id = db_result($result, $i, 'artifact_cc_id');
         // if the CC is a user point to its user page else build a mailto: URL
         $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) . '">' . $email . '</a>';
         }
         if ($ascii) {
             $out .= sprintf($fmt, $email, SimpleSanitizer::unsanitize(db_result($result, $i, 'comment')));
         } else {
             // show CC delete icon if one of the condition is met:
             // (a) current user is a group member
             // (b) the CC name is the current user
             // (c) the CC email address matches the one of the current user
             // (d) the current user is the person who added a gieven name in CC list
             if (user_ismember($this->ArtifactType->getGroupID()) || user_getname(user_getid()) == $email || user_getemail(user_getid()) == $email || user_getname(user_getid()) == db_result($result, $i, 'user_name')) {
                 $html_delete = '<a href="?func=delete_cc&group_id=' . (int) $group_id . '&aid=' . (int) $this->getID() . '&atid=' . (int) $group_artifact_id . '&artifact_cc_id=' . (int) $artifact_cc_id . '" ' . ' onClick="return confirm(\'' . $Language->getText('tracker_include_artifact', 'delete_cc') . '\')">' . '<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), $href_cc, $hp->purify(SimpleSanitizer::unsanitize(db_result($result, $i, 'comment')), CODENDI_PURIFIER_BASIC, $this->ArtifactType->getGroupId()), util_user_link(db_result($result, $i, 'user_name')), format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'date')), $html_delete);
         }
         // for
     }
     // final touch...
     $out .= $ascii ? $GLOBALS['sys_lf'] : "</TABLE>";
     return $out;
 }