/**
  * Permit CSV file input,parse the CSV file and show the parse report
  *
  *
  */
 function displayParse($csv_filename)
 {
     global $Language;
     if (!file_exists($csv_filename) || !is_readable($csv_filename)) {
         exit_missing_param();
     }
     $is_tmp = false;
     //}
     if (array_key_exists('notify', $_REQUEST) && $_REQUEST['notify']) {
         user_set_preference('tracker_import_notify_' . $this->ath->getID(), 1);
     } else {
         user_set_preference('tracker_import_notify_' . $this->ath->getID(), 0);
     }
     $ok = $this->parse($csv_filename, $is_tmp, $artifacts_data, $number_inserts, $number_updates);
     $this->ath->header(array('title' => $Language->getText('tracker_import', 'art_import') . $this->ath->getID() . ' - ' . $this->ath->getName(), 'pagename' => 'tracker', 'atid' => $this->ath->getID(), 'sectionvals' => array($this->group->getPublicName()), 'help' => 'tracker-v3.html#tracker-artifact-import'));
     echo '<div id="tracker_toolbar_clear"></div>' . PHP_EOL;
     echo '<h2>' . $Language->getText('tracker_import', 'parse_report') . '</h2>';
     if (!$ok) {
         $this->showErrors();
     } else {
         echo $Language->getText('tracker_import', 'ready', array($number_inserts + $number_updates, $number_inserts, $number_updates)) . "<br><br>\n";
         echo $Language->getText('tracker_import', 'check_data');
         $this->showParseResults($this->parsed_labels, $artifacts_data);
     }
     $this->ath->footer(array());
 }
示例#2
0
/* message moderation
	by Daniel Perez - 2005
*/
require_once '../../env.inc.php';
require_once $gfwww . 'include/pre.php';
require_once $gfwww . 'forum/include/ForumHTML.class.php';
require_once $gfwww . 'forum/admin/ForumAdmin.class.php';
require_once $gfcommon . 'forum/Forum.class.php';
require_once $gfcommon . 'forum/ForumMessage.class.php';
$msg_id = getIntFromRequest("msg_id");
$group_id = getIntFromRequest('group_id');
$forum_id = getIntFromRequest("forum_id");
global $HTML;
$fa = new ForumAdmin();
if (!$forum_id || !$group_id || !$msg_id) {
    exit_missing_param();
}
if ($fa->Authorized($group_id)) {
    //user authorized, continue check
    if ($fa->isForumAdmin($forum_id)) {
        //print the message
        forum_header(array());
        $g =& $fa->GetGroupObject();
        $f = new Forum($g, $forum_id);
        if (!$f || !is_object($f)) {
            exit_error(_('Error'), "Error getting new Forum");
        } elseif ($f->isError()) {
            exit_error(_('Error'), $f->getErrorMessage());
        }
        $fm = new ForumMessage($f, $msg_id, false, true);
        //create the pending message
示例#3
0
 /**
  *  Update an artifact. Rk: vfl is an variable list of fields, Vary from one project to another
  *  return true if artifact updated, false if nothing changed or DB update failed
  *
  * @param artifact_id_dependent: artifact dependencies
  * @param canned_response: canned responses
  * @param changes (OUT): array of changes (for notifications)
  *
  *  @return boolean
  */
 function handleUpdate($artifact_id_dependent, $canned_response, &$changes, $masschange = false, $vfl = false, $import = false)
 {
     global $art_field_fact, $HTTP_POST_VARS, $Language;
     if ($masschange && !$this->ArtifactType->userIsAdmin()) {
         exit_permission_denied();
     }
     if (!$import) {
         // Retrieve HTTP GET variables and store them in $vfl array
         $vfl = $art_field_fact->extractFieldList();
         // make sure  required fields are not empty
         if ($art_field_fact->checkEmptyFields($vfl) == false) {
             exit_missing_param();
         }
     }
     //get this artifact from the db
     $result = $this->getFieldsValues();
     //
     //  See which fields changed during the modification
     //  and if we must keep history then do it. Also add them to the update
     //  statement
     //
     $reference_manager =& ReferenceManager::instance();
     $text_value_list = array();
     $changes = array();
     $upd_list = '';
     reset($vfl);
     while (list($field_name, $value) = each($vfl)) {
         $field = $art_field_fact->getFieldFromName($field_name);
         // skip over special fields  except for details which in this
         // particular case can be processed normally
         if ($field->isSpecial()) {
             continue;
         }
         if ($field->isInt() && $value == '' && $field->getRequired() == 0) {
             $value = 0;
         }
         // we check if the given value is authorized for this field (for select box fields only)
         // we don't check here the none value, we have already check it before (we can't check here the none value because the function checkValueInPredefinedValues don't take the none value into account)
         // if the value did not change, we don't do the check (because of stored values that can be deleted now)
         if (!$masschange && $result[$field_name] != $value && $field->isSelectBox() && $value != 100 && !$field->checkValueInPredefinedValues($this->ArtifactType->getID(), $value)) {
             $this->setError($Language->getText('tracker_common_artifact', 'bad_field_value', array($field->getLabel(), $value)));
             return false;
         }
         if (!$masschange && $field->isMultiSelectBox()) {
             if (is_array($value)) {
                 foreach ($value as $a_value) {
                     if ($a_value != 100 && !$field->checkValueInPredefinedValues($this->ArtifactType->getID(), $a_value)) {
                         $this->setError($Language->getText('tracker_common_artifact', 'bad_field_value', array($field->getLabel(), $value)));
                         return false;
                     }
                 }
             }
         }
         $is_text = $field->isTextField() || $field->isTextArea();
         if ($field->isMultiSelectBox() && is_array($value)) {
             if ($masschange && in_array($Language->getText('global', 'unchanged'), $value)) {
                 continue;
             }
             // The field is a multi values field and it has multi assigned values
             $values = $value;
             // check if the user can update the field or not
             if (!$field->userCanUpdate($this->ArtifactType->getGroupID(), $this->ArtifactType->getID(), user_getid())) {
                 // we only throw an error if the values has changed
                 $old_values = $field->getValues($this->getID());
                 list($deleted_values, $added_values) = util_double_diff_array($old_values, $values);
                 if (count($deleted_values) > 0 || count($added_values) > 0) {
                     // The user does not have the permissions to update the current field,
                     // we exit the function with an error message
                     $this->setError($Language->getText('tracker_common_artifact', 'bad_field_permission_update', $field->getLabel()));
                     return false;
                 }
             }
             //don't take into account the none value if there are several values selected
             if (count($values) > 1) {
                 $temp = array();
                 while (list($i, $v) = each($values)) {
                     if ($v == 100) {
                         unset($values[$i]);
                         $unset = true;
                     } else {
                         $temp[] = $v;
                     }
                 }
                 if (isset($unset) && $unset) {
                     $values = $temp;
                 }
             }
             $old_values = $field->getValues($this->getID());
             list($deleted_values, $added_values) = util_double_diff_array($old_values, $values);
             // Check if there are some differences
             if (count($deleted_values) > 0 || count($added_values) > 0) {
                 // Add values in the history
                 $a = $field->getLabelValues($this->ArtifactType->getID(), $old_values);
                 $val = join(",", $a);
                 $b = $field->getLabelValues($this->ArtifactType->getID(), $values);
                 $new_val = join(",", $b);
                 $this->addHistory($field, $val, $new_val);
                 // Update the field value
                 if (!$field->updateValues($this->getID(), $values)) {
                     $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_common_artifact', 'field_upd_fail', $field->getLabel()));
                 }
                 if ($is_text) {
                     //Log for Cross references
                     $text_value_list[] = $values;
                 }
                 // Keep track of the change
                 $field_html = new ArtifactFieldHtml($field);
                 if (count($deleted_values) > 0) {
                     $val = join(",", $field->getLabelValues($this->ArtifactType->getID(), $deleted_values));
                     $changes[$field_name]['del'] = $val;
                 }
                 if (count($added_values) > 0) {
                     $val = join(",", $field->getLabelValues($this->ArtifactType->getID(), $added_values));
                     $changes[$field_name]['add'] = $val;
                 }
             }
         } else {
             if ($masschange && $value == $Language->getText('global', 'unchanged')) {
                 continue;
             }
             $old_value = $result[$field_name];
             if ($is_text) {
                 $differ = $old_value != htmlspecialchars($value);
                 //Log for Cross references
                 $text_value_list[] = $value;
             } else {
                 if ($field->isDateField()) {
                     // if it's a date we must convert the format to unix time
                     if ($value != '') {
                         list($value, $ok) = util_date_to_unixtime($value);
                     } else {
                         $value = '0';
                     }
                     //first have a look if both dates are uninitialized
                     if (($old_value == 0 || $old_value == '') && ($value == 0 || !$ok)) {
                         $differ = false;
                     } else {
                         // and make also sure that the old_value has been treated as the new value
                         // i.e. old_value (unix timestamp) -> local date (with hours cut off, so change the date by x  hours) -> unixtime
                         $old_date = format_date("Y-m-j", $old_value);
                         list($old_val, $ok) = util_date_to_unixtime($old_date);
                         $differ = $old_val != $value;
                     }
                 } else {
                     $differ = $old_value != $value;
                 }
             }
             if ($differ) {
                 // The userCanUpdate test is only done on modified fields
                 if ($field->userCanUpdate($this->ArtifactType->getGroupID(), $this->ArtifactType->getID(), user_getid())) {
                     if ($is_text) {
                         if ($field->isStandardField()) {
                             $upd_list .= "{$field_name}='" . db_es(htmlspecialchars($value)) . "',";
                         } else {
                             $update_value = htmlspecialchars($value);
                         }
                         $this->addHistory($field, $old_value, $value);
                         $value = stripslashes($value);
                     } else {
                         if ($field->isStandardField()) {
                             $upd_list .= "{$field_name}='" . db_es($value) . "',";
                         } else {
                             $update_value = $value;
                         }
                         $this->addHistory($field, $old_value, $value);
                     }
                     // Update the field value
                     if (!$field->isStandardField()) {
                         if (!$field->updateValue($this->getID(), $update_value)) {
                             $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_common_artifact', 'field_upd_fail', $field->getLabel()));
                         }
                     }
                     // Keep track of the change
                     $field_html = new ArtifactFieldHtml($field);
                     $changes[$field_name]['del'] = $field_html->display($this->ArtifactType->getID(), $old_value, false, false, true, true);
                     $changes[$field_name]['add'] = $field_html->display($this->ArtifactType->getID(), $value, false, false, true, true);
                 } else {
                     // The user does not have the permissions to update the current field,
                     // we exit the function with an error message
                     $this->setError($Language->getText('tracker_common_artifact', 'bad_field_permission_update', $field->getLabel()));
                     return false;
                 }
             }
         }
     }
     // while
     for ($i = 0; $i < sizeof($text_value_list); $i++) {
         $reference_manager->extractCrossRef($text_value_list[$i], $this->getID(), ReferenceManager::REFERENCE_NATURE_ARTIFACT, $this->ArtifactType->getGroupID());
     }
     $request = HTTPRequest::instance();
     //for masschange look at the special case of changing the submitted_by param
     if ($masschange) {
         reset($HTTP_POST_VARS);
         while (list($key, $val) = each($HTTP_POST_VARS)) {
             $val = $request->get($key);
             //Don't use HTTP_POST_VARS
             if ($key == 'submitted_by' && $val != $Language->getText('global', 'unchanged')) {
                 $sql = "UPDATE artifact SET submitted_by=" . db_ei($val) . " WHERE artifact_id = " . db_ei($this->getID());
                 $res = db_query($sql);
                 $field = $art_field_fact->getFieldFromName('submitted_by');
                 if ($this->getSubmittedBy() != $val) {
                     $this->addHistory('submitted_by', $this->getSubmittedBy(), $val);
                 }
             }
         }
     }
     // Comment field history is handled a little differently. Followup comments
     // are added in the bug history along with the comment type.
     //
     // If a canned response is given it overrides anything typed in the followup
     // comment text area.
     $comment = $request->get('comment');
     $comment_type_id = array_key_exists('comment_type_id', $vfl) ? $vfl['comment_type_id'] : '';
     $vFormat = new Valid_WhiteList('comment_format', array(self::FORMAT_HTML, self::FORMAT_TEXT));
     $comment_format = $request->getValidated('comment_format', $vFormat, self::FORMAT_TEXT);
     $this->addFollowUpComment($comment, $comment_type_id, $canned_response, $changes, $comment_format);
     //
     //  Enter the timestamp if we are changing to closed or declined
     //
     if (isset($changes['status_id']) && $this->isStatusClosed($vfl['status_id'])) {
         $now = time();
         $upd_list .= "close_date='{$now}',";
         $field = $art_field_fact->getFieldFromName('close_date');
         if ($field) {
             $this->addHistory($field, $result['close_date'], '');
         }
     }
     //
     //  Reset the timestamp if we are changing from closed or declined
     //
     if (isset($changes['status_id']) && !$this->isStatusClosed($vfl['status_id'])) {
         $upd_list .= "close_date='',";
         $field = $art_field_fact->getFieldFromName('close_date');
         if ($field) {
             $this->addHistory($field, $result['close_date'], '');
         }
     }
     //
     //  Insert the list of dependencies
     //
     if ($import && $artifact_id_dependent) {
         if (!$this->deleteAllDependencies()) {
             return false;
         }
         if ($artifact_id_dependent == $Language->getText('global', 'none')) {
             unset($artifact_id_dependent);
         }
     }
     if (isset($artifact_id_dependent)) {
         if (!$this->addDependencies($artifact_id_dependent, $changes, $masschange, $import)) {
             return false;
         }
     }
     //
     //  Finally, build the full SQL query and update the artifact itself (if need be)
     //
     $res_upd = true;
     if ($upd_list) {
         // strip the excess comma at the end of the update field list
         $upd_list = substr($upd_list, 0, -1);
         $sql = "UPDATE artifact SET {$upd_list} " . " WHERE artifact_id=" . db_ei($this->getID());
         $res_upd = db_query($sql);
     }
     if (!$res_upd) {
         exit_error($Language->getText('tracker_common_artifact', 'upd_fail') . ': ' . $sql, $Language->getText('tracker_common_artifact', 'upd_fail'));
         return false;
     } else {
         if (!$request->exist('change_permissions') || $request->get('change_permissions')) {
             $this->setPermissions($request->get('use_artifact_permissions_name'), $request->get('ugroups'));
         }
         return true;
     }
 }