case 'field_delete': if (!user_isloggedin()) { exit_not_logged_in(); return; } if (!$ath->userIsAdmin()) { exit_permission_denied(); return; } $field_id = $request->getValidated('field_id', 'uint', 0); $field = $art_field_fact->getFieldFromId($field_id); if ($field) { $em = EventManager::instance(); $em->processEvent('tracker_admin_field_delete', array('field' => $field, 'ath' => $ath)); //clear permissions permission_clear_all_fields_tracker($group_id, $atid, $field->getID()); if (!$field->delete($atid)) { exit_error($Language->getText('global', 'error'), $field->getErrorMessage()); } else { require_once 'common/tracker/ArtifactRulesManager.class.php'; $arm = new ArtifactRulesManager(); $arm->deleteRulesByFieldId($atid, $field_id); // Reload the field factory $art_field_fact = new ArtifactFieldFactory($ath); // Reload the fieldset factory $art_fieldset_fact = new ArtifactFieldSetFactory($ath); $GLOBALS['Response']->addFeedback('info', $Language->getText('tracker_admin_index', 'field_deleted')); } } require './field_usage.php'; break;
/** * * Delete all the fields informations for a tracker * * @param atid: the tracker id * * @return boolean */ function deleteFields($atid) { // // Remove fields permissions // foreach ($this->USAGE_BY_ID as $field_id => $field) { permission_clear_all_fields_tracker($this->ArtifactType->getGroupID(), $atid, $field_id); } // // Delete artifact_field records // $sql = 'DELETE ' . 'FROM artifact_field ' . 'WHERE group_artifact_id=' . db_ei($atid); //echo $sql; $res = db_query($sql); // // Delete artifact_field_usage records // $sql = 'DELETE ' . 'FROM artifact_field_usage ' . 'WHERE group_artifact_id=' . db_ei($atid); //echo $sql; $res = db_query($sql); // // Delete artifact_field_value_list records // $sql = 'DELETE ' . 'FROM artifact_field_value_list ' . 'WHERE group_artifact_id=' . db_ei($atid); //echo $sql; $res = db_query($sql); return true; }