Esempio n. 1
0
                     $import->displayCSVInput($atid, $user_id);
                 }
             }
         }
     } else {
         exit_no_group();
     }
     break;
 case 'export':
     require './export.php';
     break;
 case 'updatecomment':
     $artifact_id = $request->get('artifact_id');
     if (user_isloggedin() && $request->exist('followup_update')) {
         $followup_update = $request->get('followup_update');
         $ah = new ArtifactHtml($ath, $artifact_id);
         $vFormat = new Valid_WhiteList('comment_format', array(Artifact::FORMAT_HTML, Artifact::FORMAT_TEXT));
         $comment_format = $request->getValidated('comment_format', $vFormat, Artifact::FORMAT_TEXT);
         if ($ah->updateFollowupComment($request->get('artifact_history_id'), $followup_update, $changes, $comment_format)) {
             $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('tracker_common_artifact', 'followup_upd_succ'));
             $agnf = new ArtifactGlobalNotificationFactory();
             $addresses = $agnf->getAllAddresses($ath->getID(), true);
             $ah->mailFollowupWithPermissions($addresses, $changes);
         } else {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('tracker_common_artifact', 'followup_upd_fail'));
         }
     }
     $GLOBALS['Response']->redirect('?group_id=' . (int) $group_id . '&atid=' . (int) $atid . '&aid=' . (int) $artifact_id . '&func=detail');
     break;
 case 'browse':
     $masschange = false;
Esempio n. 2
0
/**
 * Prepare the column values in the artifact record
 *
 * @param ArtifactType (tracker) $at the tracker the artifact to prepare blelong to
 * @param array{ArtifactField} $fields the fields of the artifact to export 
 * @param int $group_artifact_id the tracker ID
 * @param array $record array 'field_name' => 'field_value'
 * @param string $export type of export ('csv' or 'database' : for date format, csv will take user preference, wheareas for database the format will be mysql format.)
 */
function prepare_artifact_record($at, $fields, $group_artifact_id, &$record, $export)
{
    global $datetime_fmt, $sys_lf, $Language;
    /* $record:          
          Input: a row from the artifact table (passed by reference.
          Output: the same row with values transformed for export
       */
    reset($fields);
    $line = '';
    while (list(, $field) = each($fields)) {
        if ($field->isSelectBox() || $field->isMultiSelectBox()) {
            $values = array();
            if ($field->isStandardField()) {
                $values[] = $record[$field->getName()];
            } else {
                $values = $field->getValues($record['artifact_id']);
            }
            $label_values = $field->getLabelValues($group_artifact_id, $values);
            $record[$field->getName()] = SimpleSanitizer::unsanitize(join(",", $label_values));
        } else {
            if ($field->isTextArea() || $field->isTextField() && $field->getDataType() == $field->DATATYPE_TEXT) {
                // all text fields converted from HTML to ASCII
                $record[$field->getName()] = prepare_textarea($record[$field->getName()]);
            } else {
                if ($field->isDateField()) {
                    // replace the date fields (unix time) with human readable dates that
                    // is also accepted as a valid format in future import
                    if ($record[$field->getName()] == '') {
                        // if date undefined then set datetime to 0. Ideally should
                        // NULL as well but if we pass NULL it is interpreted as a string
                        // later in the process
                        $record[$field->getName()] = '0';
                    } else {
                        if ($export == 'database') {
                            $record[$field->getName()] = format_date($datetime_fmt, $record[$field->getName()]);
                        } else {
                            $record[$field->getName()] = format_date(util_get_user_preferences_export_datefmt(), $record[$field->getName()]);
                        }
                    }
                } else {
                    if ($field->isFloat()) {
                        $record[$field->getName()] = number_format($record[$field->getName()], 2);
                    }
                }
            }
        }
    }
    // Follow ups
    $ah = new ArtifactHtml($at, $record['artifact_id']);
    $sys_lf_sav = $sys_lf;
    $sys_lf = "\n";
    $record['follow_ups'] = $ah->showFollowUpComments($at->Group->getID(), true, Artifact::OUTPUT_EXPORT);
    $sys_lf = $sys_lf_sav;
    // Dependencies
    $result = $ah->getDependencies();
    $rows = db_numrows($result);
    $dependent = '';
    for ($i = 0; $i < $rows; $i++) {
        $dependent_on_artifact_id = db_result($result, $i, 'is_dependent_on_artifact_id');
        $dependent .= $dependent_on_artifact_id . ",";
    }
    $record['is_dependent_on'] = $dependent !== '' ? substr($dependent, 0, strlen($dependent) - 1) : $Language->getText('global', 'none');
    //CC
    $cc_list = $ah->getCCList();
    $rows = db_numrows($cc_list);
    $cc = array();
    for ($i = 0; $i < $rows; $i++) {
        $cc_email = db_result($cc_list, $i, 'email');
        $cc[] = $cc_email;
    }
    $record['cc'] = implode(',', $cc);
}
Esempio n. 3
0
 /**
  * Delete an email address in the CC list
  *
  * @param artifact_cc_id: cc list id
  * @param changes (OUT): list of changes
  *
  * @return boolean
  */
 function deleteCC($delete_cc)
 {
     $ok = true;
     while (list(, $artifact_ccs) = each($delete_cc)) {
         $artifact_cc_ids = explode(",", $artifact_ccs);
         $i = 0;
         while (list(, $artifact_cc_id) = each($artifact_cc_ids)) {
             $sql = "SELECT artifact_id from artifact_cc WHERE artifact_cc_id=" . db_ei($artifact_cc_id);
             $res = db_query($sql);
             if (db_numrows($res) > 0) {
                 $i++;
                 $aid = db_result($res, 0, 'artifact_id');
                 $ah = new ArtifactHtml($this, $aid);
                 $ok &= $ah->deleteCC($artifact_cc_id, $changes, true);
             }
         }
     }
     return $ok;
 }