public function __construct($label, $name, $value, $with_none = false, $onchange = "", $desc = "")
 {
     parent::__construct($label, $name, $value, $with_none, $onchange, $desc);
     require_once 'common/tracker/ArtifactFieldFactory.class.php';
     require_once 'common/tracker/ArtifactType.class.php';
     $at = new ArtifactType($GLOBALS['ath']->Group, $GLOBALS['ath']->getID(), false);
     $aff = new ArtifactFieldFactory($at);
     foreach ($aff->getAllUsedFields() as $field) {
         if ($field->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) {
             if ($field->isdateField()) {
                 $selected = $this->value == $field->getName();
                 $this->addOption(new HTML_Element_Option($field->getLabel(), $field->getName(), $selected));
             }
         }
     }
 }
Esempio n. 2
0
 /**
  *  fetchData - re-fetch the data for this Artifact from the database.
  *
  *  @param  int             The artifact ID.
  *  @return boolean success.
  */
 function fetchData($artifact_id)
 {
     global $art_field_fact, $Language;
     if (!$art_field_fact) {
         $art_field_fact = new ArtifactFieldFactory($this->ArtifactType);
     }
     // first fetch values of standard fields
     $sql = "SELECT * FROM artifact WHERE artifact_id='" . db_ei($artifact_id) . "' AND group_artifact_id='" . db_ei($this->ArtifactType->getID()) . "'";
     $res = db_query($sql);
     if (!$res || db_numrows($res) < 1) {
         $this->setError('Artifact: ' . $Language->getText('tracker_common_artifact', 'invalid_id'));
         return false;
     }
     $this->data_array = db_fetch_array($res);
     db_free_result($res);
     // now get the values for generic fields if any
     $sql = "SELECT * FROM artifact_field_value WHERE artifact_id='" . db_ei($artifact_id) . "'";
     $res = db_query($sql);
     if (!$res || db_numrows($res) < 1) {
         // if no result then it is possible that there isn't any generic fields
         return true;
     }
     while ($row = db_fetch_array($res)) {
         $data_fields[$row['field_id']] = $row;
     }
     // Get the list of all fields used by this tracker and append
     // the values for these generic fields to data_array
     $fields = $art_field_fact->getAllUsedFields();
     while (list($key, $field) = each($fields)) {
         //echo $field->getName()."-".$field->getID()."<br>";
         // Skip! Standard field values fectched in previous query
         // and comment_type_id is not stored in artifact_field_value table
         if ($field->isStandardField() || $field->getName() == "comment_type_id") {
             continue;
         }
         $this->data_array[$field->getName()] = $data_fields[$field->getID()][$field->getValueFieldName()];
     }
     return true;
 }
Esempio n. 3
0
         $rep_default = 1;
     } else {
         $rep_default = 0;
     }
     $report_id = $arh->create(user_getid(), $rep_name, $rep_desc, $rep_scope, $rep_default);
     if (!$report_id) {
         if ($arh->isError()) {
             exit_error($Language->getText('global', 'error'), $Language->getText('tracker_admin_index', 'not_created_report') . ': ' . $arh->getErrorMessage());
         }
         exit_error($Language->getText('global', 'error'), $Language->getText('tracker_admin_index', 'not_created_report'));
     }
     $GLOBALS['Response']->addFeedback('info', $Language->getText('tracker_admin_index', 'new_report_created'));
 }
 // now insert all the field entries in the artifact_report_field table
 $aff = new ArtifactFieldFactory(&$ath);
 $fields = $aff->getAllUsedFields();
 while (list($key, $field) = each($fields)) {
     $cb_search = 'CBSRCH_' . $field->getName();
     $cb_report = 'CBREP_' . $field->getName();
     $tf_search = 'TFSRCH_' . $field->getName();
     $tf_report = 'TFREP_' . $field->getName();
     $tf_colwidth = 'TFCW_' . $field->getName();
     $cb_search_val = $request->getValidated($cb_search) ? '1' : '0';
     $cb_report_val = $request->getValidated($cb_report) ? '1' : '0';
     $tf_search_val = $request->getValidated($tf_search);
     $tf_report_val = $request->getValidated($tf_report);
     $tf_colwidth_val = $request->getValidated($tf_colwidth);
     if ($cb_search_val || $cb_report_val || $tf_search_val || $tf_report_val) {
         $arh->add_report_field($field->getName(), $cb_search_val, $cb_report_val, $tf_search_val, $tf_report_val, $tf_colwidth_val);
     }
 }
Esempio n. 4
0
                 } else {
                     $result = db_query($sql);
                     while ($arr = db_fetch_array($result)) {
                         prepare_artifact_record($at, $fields, $atid, $arr, 'database');
                         insert_record_in_table($dbname, $tbl_name, $col_list, $arr);
                     }
                 }
             } else {
                 $feedback .= $Language->getText('project_export_artifact_deps_export', 'create_proj_err', array($tbl_name, db_project_error()));
             }
             // MV add
             // Export table structure
             // Create table
             $tbl_struct_name = "artifact_struct_" . $at_arr[$j]->getItemName();
             $tbl_struct_name = str_replace(' ', '_', $tbl_struct_name);
             $fieldsList = $art_field_fact->getAllUsedFields();
             db_project_query($dbname, 'DROP TABLE IF EXISTS ' . $tbl_struct_name);
             $struct_table_create = 'CREATE TABLE ' . $tbl_struct_name . '(' . ' field_name VARCHAR(255), ' . ' field_label VARCHAR(255)' . ')';
             db_project_query($dbname, $struct_table_create);
             // Populate table
             $struct_col_list = array('field_name', 'field_label');
             foreach ($fieldsList as $art_field) {
                 $struct_arr['field_name'] = $art_field->getName();
                 $struct_arr['field_label'] = $art_field->getLabel();
                 insert_record_in_table($dbname, $tbl_struct_name, $struct_col_list, $struct_arr);
             }
         }
         // for
     }
     // if
 } else {
 function getAllTargetFields($source_id)
 {
     $targets = array();
     $art_field_fact = new ArtifactFieldFactory($this->artifact_type);
     $used_fields = $art_field_fact->getAllUsedFields();
     foreach ($used_fields as $field) {
         if ($field->getName() != 'submitted_by') {
             if ($field->isMultiSelectBox() || $field->isSelectBox()) {
                 if (!$source_id || !$this->fieldIsAForbiddenTarget($this->artifact_type->getId(), $field->getId(), $source_id)) {
                     $targets[$field->getId()] = $field;
                 }
             }
         }
     }
     return $targets;
 }
Esempio n. 6
0
 /**
  * Get permissions for all fields based on the ugroups the user is part of
  *
  */
 function getFieldPermissions($ugroups)
 {
     $art_field_fact = new ArtifactFieldFactory($this);
     $used_fields = $art_field_fact->getAllUsedFields();
     $field_perm = array();
     reset($used_fields);
     foreach ($used_fields as $field) {
         $perm = $field->getPermissionForUgroups($ugroups, $this->getID());
         if ($perm && !empty($perm)) {
             $field_perm[$field->getName()] = $perm;
         }
     }
     return $field_perm;
 }