예제 #1
0
 $resolutionbox_id = $aef->getID();
 if (!$resolutionbox_id) {
     echo "\nCould Not Get resolutionbox_id " . $aef->getErrorMessage();
     db_rollback();
     exit(12);
 }
 $resc = db_query("SELECT * FROM artifact_resolution");
 for ($j = 0; $j < db_numrows($resc); $j++) {
     $resolution_id = db_result($resc, $j, 'id');
     $resolution_name = addslashes(db_result($resc, $j, 'resolution_name'));
     if (strlen($resolution_name) < 1) {
         $resolution_name = '[empty]';
     }
     $efe = new ArtifactExtraFieldElement($aef);
     //	$efe->create($resolution_name);
     if (!$efe->create($resolution_name)) {
         echo 'Group: ' . $group_id . ' Could not create resolution element: ' . $resolution_name . ' ' . $efe->getErrorMessage();
         db_rollback();
         exit(5);
     }
     //echo 'Artifact Group: Group: '.$group_id;
     //print_r($efe->data_array);
     $efe_id = $efe->getID();
     if (!$efe_id) {
         echo "\nDid Not Get efe_id";
         db_rollback();
         exit(13);
     }
     $res2 = db_query("INSERT INTO artifact_extra_field_data (artifact_id,field_data,extra_field_id)\n\t\t\t\tSELECT artifact_id,{$efe_id},{$resolutionbox_id} FROM artifact \n\t\t\t\tWHERE resolution_id='{$resolution_id}' AND group_artifact_id='{$gaid}'");
     if (!$res2) {
         echo "Could Not Insert AEFD for resolution " . db_error();
예제 #2
0
 /**
  *	createTrackers - creates all the standard trackers for a given Group.
  *
  *	@return	boolean	success.
  */
 function createTrackers()
 {
     // first, check if trackers already exist
     $res = db_query("SELECT * FROM artifact_group_list \n\t\t\tWHERE group_id='" . $this->Group->getID() . "' AND datatype > 0");
     if (db_numrows($res) > 0) {
         return true;
     }
     include $GLOBALS['gfcommon'] . 'tracker/artifact_type_definitions.php';
     db_begin();
     foreach ($trackers as $trk) {
         $at = new ArtifactType($this->Group);
         if (!$at || !is_object($at)) {
             db_rollback();
             $this->setError('Error Getting Tracker Object');
             return false;
         }
         //
         //	Create a tracker
         //
         if (!$at->create(addslashes($trk[0]), addslashes($trk[1]), $trk[2], $trk[3], $trk[4], $trk[5], $trk[6], $trk[7], $trk[8], $trk[9], $trk[10])) {
             db_rollback();
             $this->setError('Error Creating Tracker: ' . $at->getErrorMessage());
             return false;
         } else {
             //
             //	Create each field in the tracker
             //
             foreach ($trk[11] as $fld) {
                 $aef = new ArtifactExtraField($at);
                 //print($fld[0])."***|";
                 if (!$aef->create(addslashes($fld[0]), $fld[1], $fld[2], $fld[3], $fld[4])) {
                     db_rollback();
                     $this->setError('Error Creating Extra Field: ' . $aef->getErrorMessage());
                     return false;
                 } else {
                     //
                     //	create each element in the field
                     //
                     foreach ($fld[5] as $el) {
                         //print($el)."**";
                         $aefe = new ArtifactExtraFieldElement($aef);
                         /*	 Allow us to provide a list as an element
                         			 value - in doing so, we can provide a
                         			 status field value for people wanting to
                         			 set up custom statuses. The first element
                         			 of any given array is the name, the second
                         			 is the status_id (0, 1 or 2)*/
                         $el_name = $el;
                         $el_status = 0;
                         if (is_array($el) && $fld[1] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
                             $el_name = $el[0];
                             $el_status = $el[1];
                         }
                         if (!$aefe->create(addslashes($el_name), $el_status)) {
                             db_rollback();
                             $this->setError('Error Creating Extra Field Element: ' . $aefe->getErrorMessage());
                             return false;
                         }
                     }
                 }
             }
         }
     }
     db_commit();
     return true;
 }
예제 #3
0
 /**
  *	cloneFieldsFrom - clone all the fields and elements from another tracker
  *
  *	@return	boolean	true/false on success
  */
 function cloneFieldsFrom($clone_tracker_id)
 {
     global $sys_template_group;
     $g =& group_get_object($sys_template_group);
     if (!$g || !is_object($g)) {
         $this->setError('Could Not Get Template Group');
         return false;
     } elseif ($g->isError()) {
         $this->setError('Template Group Error ' . $g->getErrorMessage());
         return false;
     }
     $at =& new ArtifactType($g, $clone_tracker_id);
     if (!$at || !is_object($at)) {
         $this->setError('Could Not Get Tracker To Clone');
         return false;
     } elseif ($at->isError()) {
         $this->setError('Clone Tracker Error ' . $at->getErrorMessage());
         return false;
     }
     $efs =& $at->getExtraFields();
     //
     //	Iterate list of extra fields
     //
     db_begin();
     foreach ($efs as $ef) {
         //new field in this tracker
         $nef = new ArtifactExtraField($this);
         if (!$nef->create(addslashes(util_unconvert_htmlspecialchars($ef['field_name'])), $ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], $ef['alias'])) {
             db_rollback();
             $this->setError('Error Creating New Extra Field: ' . $nef->getErrorMessage());
             return false;
         }
         //
         //	Iterate the elements
         //
         $resel = db_query("SELECT * FROM artifact_extra_field_elements WHERE extra_field_id='" . $ef['extra_field_id'] . "'");
         while ($el =& db_fetch_array($resel)) {
             //new element
             $nel = new ArtifactExtraFieldElement($nef);
             if (!$nel->create(addslashes(util_unconvert_htmlspecialchars($el['element_name'])), $el['status_id'])) {
                 db_rollback();
                 $this->setError('Error Creating New Extra Field Element: ' . $nel->getErrorMessage());
                 return false;
             }
         }
     }
     db_commit();
     return true;
 }