Пример #1
0
         exit_permission_denied();
         return;
     }
     if (!user_ismember($group_id, 'A')) {
         exit_permission_denied();
         return;
     }
     $ath->adminTrackersHeader(array('title' => $ath->getName() . ' ' . $Language->getText('tracker_admin_field_usage', 'tracker_admin'), 'help' => 'tracker-v3.html#tracker-administration'));
     if (!$ath->preDelete()) {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_admin_index', 'deletion_failed', $hp->purify(SimpleSanitizer::unsanitize($ath->getName()), CODENDI_PURIFIER_CONVERT_HTML)));
     } else {
         //@see  preDeleteArtifactType @common/tracker/ArtifactTypeFactory.class.php
         $GLOBALS['Response']->addFeedback('info', $Language->getText('tracker_admin_index', 'delete_success', $hp->purify(SimpleSanitizer::unsanitize($ath->getName()), CODENDI_PURIFIER_CONVERT_HTML)));
         echo $Language->getText('tracker_admin_index', 'tracker_deleted', array($hp->purify(SimpleSanitizer::unsanitize($ath->getName()), CODENDI_PURIFIER_CONVERT_HTML), $GLOBALS['sys_email_admin']));
         require_once 'common/tracker/ArtifactRulesManager.class.php';
         $arm = new ArtifactRulesManager();
         $arm->deleteRulesByArtifactType($atid);
         // Delete related reference if it exists
         // NOTE: there is no way to know if the reference is actually related to this tracker.
         $reference_manager =& ReferenceManager::instance();
         $ref =& $reference_manager->loadReferenceFromKeywordAndNumArgs(strtolower($ath->getItemName()), $group_id, 1);
         if ($ref) {
             if ($reference_manager->deleteReference($ref)) {
                 $GLOBALS['Response']->addFeedback('info', $Language->getText('project_reference', 't_r_deleted'));
             }
         }
     }
     $ath->footer(array());
     break;
 case 'permissions':
     require './tracker_permissions.php';
Пример #2
0
     exit_error($Language->getText('tracker_index', 'artifact_has_changed_title'), $Language->getText('tracker_index', 'artifact_has_changed', "/tracker/?func=detail&aid={$aid}&atid={$atid}&group_id={$group_id}"));
 }
 // First check parameters
 // CC
 $add_cc = $request->get('add_cc');
 $array_add_cc = split('[,;]', $add_cc);
 if ($add_cc && !util_validateCCList($array_add_cc, $message)) {
     exit_error($Language->getText('tracker_index', 'cc_list_invalid'), $message);
 }
 // Files
 if (isset($_FILES['input_file']['error']) && $_FILES['input_file']['error'] != UPLOAD_ERR_NO_FILE && !util_check_fileupload($_FILES['input_file']['tmp_name'])) {
     exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'invalid_filename'));
 }
 //Check Field Dependencies
 require_once 'common/tracker/ArtifactRulesManager.class.php';
 $arm = new ArtifactRulesManager();
 if (!$arm->validate($atid, $art_field_fact->extractFieldList(), $art_field_fact)) {
     exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'invalid_field_dependency'));
 }
 //data control layer
 $canned_response = $request->get('canned_response');
 $changed = $ah->handleUpdate($request->get('artifact_id_dependent'), $canned_response, $changes);
 if (!$changed) {
     $GLOBALS['Response']->redirect('?group_id=' . (int) $group_id . '&atid=' . (int) $atid . '&func=browse');
     exit;
 }
 //
 //  Attach file to this Artifact.
 //
 if (isset($_FILES['input_file']['error']) && $_FILES['input_file']['error'] != UPLOAD_ERR_NO_FILE) {
     $afh = new ArtifactFileHtml($ah);
 function saveRule($source, $source_value, $target, $target_values)
 {
     parent::saveRule($this->artifact_type->getId(), $source, $source_value, $target, $target_values);
 }
Пример #4
0
 /**
  *	create - use this to create a new ArtifactType in the database.
  *
  *  @param  group_id: the group id of the new tracker
  *	@param	group_id_template: the template group id (used for the copy)
  *	@param	atid_template: the template artfact type id 
  *	@param	name: the name of the new tracker
  *	@param	description: the description of the new tracker
  *	@param	itemname: the itemname of the new tracker
  *	@return id on success, false on failure.
  */
 function create($group_id, $group_id_template, $atid_template, $name, $description, $itemname, $ugroup_mapping = false, &$report_mapping = array())
 {
     global $Language;
     if (!$name || !$description || !$itemname || trim($name) == "" || trim($description) == "" || trim($itemname) == "") {
         $this->setError('ArtifactTypeFactory: ' . $Language->getText('tracker_common_type', 'name_requ'));
         return false;
     }
     // Necessary test to avoid issues when exporting the tracker to a DB (e.g. '-' not supported as table name)
     if (!eregi("^[a-zA-Z0-9_]+\$", $itemname)) {
         $this->setError($Language->getText('tracker_common_type', 'invalid_shortname', $itemname));
         return false;
     }
     $reference_manager = ReferenceManager::instance();
     if ($reference_manager->_isKeywordExists($itemname, $group_id)) {
         $this->setError($Language->getText('tracker_common_type', 'shortname_already_exists', $itemname));
         return false;
     }
     if ($this->isNameExists($name, $group_id)) {
         $this->setError($Language->getText('tracker_common_type', 'name_already_exists', $name));
         return false;
     }
     //	get the template Group object
     $pm = ProjectManager::instance();
     $template_group = $pm->getProject($group_id_template);
     if (!$template_group || !is_object($template_group) || $template_group->isError()) {
         $this->setError('ArtifactTypeFactory: ' . $Language->getText('tracker_common_type', 'invalid_templ'));
     }
     // get the Group object of the new tracker
     $pm = ProjectManager::instance();
     $group = $pm->getProject($group_id);
     if (!$group || !is_object($group) || $group->isError()) {
         $this->setError('ArtifactTypeFactory: ' . $Language->getText('tracker_common_type', 'invalid_templ'));
     }
     // We retrieve allow_copy from template
     $at_template = new ArtifactType($template_group, $atid_template);
     $id_sharing = new TrackerIdSharingDao();
     if ($id = $id_sharing->generateTrackerId()) {
         // First, we create a new ArtifactType into artifact_group_list
         // By default, set 'instantiate_for_new_projects' to '1', so that a project that is not yet a
         // template will be able to have its trackers cloned by default when it becomes a template.
         $sql = "INSERT INTO \n                artifact_group_list \n                (group_artifact_id, group_id, name, description, item_name, allow_copy,\n                             submit_instructions,browse_instructions,instantiate_for_new_projects,stop_notification\n                             ) \n                VALUES \n                ({$id},\n                '" . db_ei($group_id) . "',\n                '" . db_es($name) . "',\n                '" . db_es($description) . "',\n                '" . db_es($itemname) . "',\n                            '" . db_ei($at_template->allowsCopy()) . "',\n                            '" . db_es($at_template->getSubmitInstructions()) . "',\n                            '" . db_es($at_template->getBrowseInstructions()) . "',1,0)";
         //echo $sql;
         $res = db_query($sql);
         if (!$res || db_affected_rows($res) <= 0) {
             $this->setError('ArtifactTypeFactory: ' . db_error());
             return false;
         } else {
             //No need to get the last insert id since we already know the id : $id
             //$id = db_insertid($res,'artifact_group_list','group_artifact_id');
             $at_new = new ArtifactType($group, $id);
             if (!$at_new->fetchData($id)) {
                 $this->setError('ArtifactTypeFactory: ' . $Language->getText('tracker_common_type', 'load_fail'));
                 return false;
             } else {
                 //create global notifications
                 $sql = "INSERT INTO artifact_global_notification (tracker_id, addresses, all_updates, check_permissions)\n                    SELECT " . db_ei($id) . ", addresses, all_updates, check_permissions\n                    FROM artifact_global_notification\n                    WHERE tracker_id = " . db_ei($atid_template);
                 $res = db_query($sql);
                 if (!$res || db_affected_rows($res) <= 0) {
                     $this->setError('ArtifactTypeFactory: ' . db_error());
                 }
                 // Create fieldset factory
                 $art_fieldset_fact = new ArtifactFieldSetFactory($at_template);
                 // Then copy all the field sets.
                 $mapping_field_set_array = $art_fieldset_fact->copyFieldSets($atid_template, $id);
                 if (!$mapping_field_set_array) {
                     $this->setError('ArtifactTypeFactory: ' . $art_fieldset_fact->getErrorMessage());
                     return false;
                 }
                 // Create field factory
                 $art_field_fact = new ArtifactFieldFactory($at_template);
                 // Then copy all the fields informations
                 if (!$art_field_fact->copyFields($id, $mapping_field_set_array, $ugroup_mapping)) {
                     $this->setError('ArtifactTypeFactory: ' . $art_field_fact->getErrorMessage());
                     return false;
                 }
                 // Then copy all the reports informations
                 // Create field factory
                 $art_report_fact = new ArtifactReportFactory();
                 if (!($report_mapping = $art_report_fact->copyReports($atid_template, $id))) {
                     $this->setError('ArtifactTypeFactory: ' . $art_report_fact->getErrorMessage());
                     return false;
                 }
                 $em =& EventManager::instance();
                 $pref_params = array('atid_source' => $atid_template, 'atid_dest' => $id);
                 $em->processEvent('artifactType_created', $pref_params);
                 // Copy artifact_notification_event and artifact_notification_role
                 if (!$at_new->copyNotificationEvent($id)) {
                     return false;
                 }
                 if (!$at_new->copyNotificationRole($id)) {
                     return false;
                 }
                 // Create user permissions: None for group members and Admin for group admin
                 if (!$at_new->createUserPerms($id)) {
                     return false;
                 }
                 // Create canned responses
                 $canned_new = new ArtifactCanned($at_new);
                 $canned_template = $at_template->getCannedResponses();
                 if ($canned_template && db_numrows($canned_template) > 0) {
                     while ($row = db_fetch_array($canned_template)) {
                         $canned_new->create($row['title'], $row['body']);
                     }
                 }
                 //Copy template permission
                 permission_copy_tracker_and_field_permissions($atid_template, $id, $group_id_template, $group_id, $ugroup_mapping);
                 //Copy Rules
                 require_once 'ArtifactRulesManager.class.php';
                 $arm = new ArtifactRulesManager();
                 $arm->copyRules($atid_template, $id);
             }
         }
     }
     return $id;
 }
Пример #5
0
 /**
  * updateArtifact - update the artifact $artifact_id in tracker $group_artifact_id of the project $group_id with given values
  *
  * @param string $sessionKey the session hash associated with the session opened by the person who calls the service
  * @param int $group_id the ID of the group we want to update the artifact
  * @param int $group_artifact_id the ID of the tracker we want to update the artifact
  * @param int $artifact_id the ID of the artifact we want to update
  * @param int $status_id the ID of the status of the artifact
  * @param int $close_date the close date of the artifact. The date format is timestamp
  * @param string $summary the summary of the artifact
  * @param string $details the details (original submission) of the artifact
  * @param int $severity the severity of the artifact
  * @param array{SOAPArtifactFieldValue} $extra_fields the extra_fields of the artifact (non standard fields)
  * @return int the ID of the artifact, 
  *              or a soap fault if :
  *              - group_id does not match with a valid project, 
  *              - group_artifact_id does not match with a valid tracker,
  *              - artifact_id does not match with a valid artifact,
  *              - the given values are breaking a field dependency rule
  *              - the artifact modification failed.
  */
 function updateArtifact($sessionKey, $group_id, $group_artifact_id, $artifact_id, $status_id, $close_date, $summary, $details, $severity, $extra_fields)
 {
     global $art_field_fact, $ath;
     if (session_continue($sessionKey)) {
         try {
             $pm = ProjectManager::instance();
             $grp = $pm->getGroupByIdForSoap($group_id, 'updateArtifact');
         } catch (SoapFault $e) {
             return $e;
         }
         $ath = new ArtifactType($grp, $group_artifact_id);
         if (!$ath || !is_object($ath)) {
             return new SoapFault(get_artifact_type_fault, 'ArtifactType could not be created', 'updateArtifact');
         }
         if ($ath->isError()) {
             return new SoapFault(get_artifact_type_fault, $ath->getErrorMessage(), 'updateArtifact');
         }
         // Check if this tracker is valid (not deleted)
         if (!$ath->isValid()) {
             return new SoapFault(get_artifact_type_fault, 'This tracker is no longer valid.', 'updateArtifact');
         }
         $art_field_fact = new ArtifactFieldFactory($ath);
         if (!$art_field_fact || !is_object($art_field_fact)) {
             return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldFactory', 'updateArtifact');
         } elseif ($art_field_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_field_fact->getErrorMessage(), 'updateArtifact');
         }
         $a = new Artifact($ath, $artifact_id);
         if (!$a || !is_object($a)) {
             return new SoapFault(get_artifact_fault, 'Could Not Get Artifact', 'updateArtifact');
         } elseif ($a->isError()) {
             return new SoapFault(get_artifact_fault, $a->getErrorMessage(), 'updateArtifact');
         }
         $data = setArtifactData($status_id, $close_date, $summary, $details, $severity, $extra_fields);
         //Check Field Dependencies
         require_once 'common/tracker/ArtifactRulesManager.class.php';
         $arm = new ArtifactRulesManager();
         if (!$arm->validate($ath->getID(), $data, $art_field_fact)) {
             return new SoapFault(invalid_field_dependency_fault, 'Invalid Field Dependency', 'updateArtifact');
         }
         if (!$a->handleUpdate($artifact_id_dependent, $canned_response, $changes, false, $data, true)) {
             return new SoapFault(update_artifact_fault, $a->getErrorMessage(), 'updateArtifact');
         } else {
             if ($a->isError()) {
                 return new SoapFault(get_artifact_type_fault, $a->getErrorMessage(), 'updateArtifact');
             }
             // Update last_update_date field
             $a->update_last_update_date();
             // Send the notification
             if ($changes) {
                 $agnf = new ArtifactGlobalNotificationFactory();
                 $addresses = $agnf->getAllAddresses($ath->getID(), true);
                 $a->mailFollowupWithPermissions($addresses, $changes);
             }
             return $a->getID();
         }
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session ', 'updateArtifact');
     }
 }