示例#1
0
 /**
  * Return an array specifying visibility, requirement and choices for fields in issues
  *
  * @param integer $issue_type
  * @param boolean $reportable [optional] Whether to only include fields that can be reported
  *
  * @return array
  */
 protected function _getFieldsArray($issue_type, $reportable = true)
 {
     $issue_type = is_object($issue_type) ? $issue_type->getID() : $issue_type;
     if (!isset($this->_fieldsarrays[$issue_type][(int) $reportable])) {
         $retval = array();
         $res = tables\IssueFields::getTable()->getBySchemeIDandIssuetypeID($this->getIssuetypeScheme()->getID(), $issue_type);
         if ($res) {
             $builtin_types = Datatype::getAvailableFields(true);
             while ($row = $res->getNextRow()) {
                 if (!$reportable || (bool) $row->get(tables\IssueFields::REPORTABLE) == true) {
                     if ($reportable) {
                         if (in_array($row->get(tables\IssueFields::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(tables\IssueFields::FIELD_KEY)) && !($row->get(tables\IssueFields::REQUIRED) && $reportable))) {
                             continue;
                         } elseif (!in_array($row->get(tables\IssueFields::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(tables\IssueFields::FIELD_KEY), true) && !($row->get(tables\IssueFields::REQUIRED) && $reportable))) {
                             continue;
                         }
                     }
                     $field_key = $row->get(tables\IssueFields::FIELD_KEY);
                     $retval[$field_key] = array('required' => (bool) $row->get(tables\IssueFields::REQUIRED), 'additional' => (bool) $row->get(tables\IssueFields::ADDITIONAL));
                     if (!in_array($field_key, $builtin_types)) {
                         $retval[$field_key]['custom'] = true;
                         $custom_type = CustomDatatype::getByKey($field_key);
                         if ($custom_type instanceof \thebuggenie\core\entities\CustomDatatype) {
                             $retval[$field_key]['custom_type'] = $custom_type->getType();
                         } else {
                             unset($retval[$field_key]);
                         }
                     }
                 }
             }
             if (array_key_exists('user_pain', $retval)) {
                 $retval['pain_bug_type'] = array('required' => $retval['user_pain']['required']);
                 $retval['pain_likelihood'] = array('required' => $retval['user_pain']['required']);
                 $retval['pain_effect'] = array('required' => $retval['user_pain']['required']);
             }
             if ($reportable) {
                 foreach ($retval as $key => $return_details) {
                     if ($key == 'edition' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::EDITIONS_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getEditions() as $edition) {
                             $retval[$key]['values'][$edition->getID()] = $edition->getName();
                         }
                         if (!$this->isEditionsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'status' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::STATUS_CHOICE) {
                         $retval[$key]['values'] = array();
                         foreach (Status::getAll() as $status) {
                             $retval[$key]['values'][$status->getID()] = $status->getName();
                         }
                         if (empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'component' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::COMPONENTS_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getComponents() as $component) {
                             $retval[$key]['values'][$component->getID()] = $component->getName();
                         }
                         if (!$this->isComponentsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                         if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) {
                             asort($retval[$key]['values'], SORT_STRING);
                         }
                     } elseif ($key == 'build' || array_key_exists('custom', $return_details) && $return_details['custom'] && $return_details['custom_type'] == CustomDatatype::RELEASES_CHOICE) {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getBuilds() as $build) {
                             if ($build->isLocked()) {
                                 continue;
                             }
                             $retval[$key]['values'][$build->getID()] = $build->getName() . ' (' . $build->getVersion() . ')';
                         }
                         if (!$this->isBuildsEnabled() || empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                     } elseif ($key == 'milestone') {
                         $retval[$key]['values'] = array();
                         $retval[$key]['values'][''] = framework\Context::getI18n()->__('None');
                         foreach ($this->getOpenMilestones() as $milestone) {
                             if (!$milestone->hasAccess()) {
                                 continue;
                             }
                             $retval[$key]['values'][$milestone->getID()] = $milestone->getName();
                         }
                         if (empty($retval[$key]['values'])) {
                             if (!$retval[$key]['required']) {
                                 unset($retval[$key]);
                             } else {
                                 unset($retval[$key]['values']);
                             }
                         }
                     }
                 }
             }
         }
         $this->_fieldsarrays[$issue_type][(int) $reportable] = $retval;
     }
     return $this->_fieldsarrays[$issue_type][(int) $reportable];
 }
示例#2
0
 protected function _preDelete()
 {
     tables\CustomFieldOptions::getTable()->deleteCustomFieldOptions($this->getID());
     tables\IssueFields::getTable()->deleteByIssueFieldKey($this->getKey());
 }
示例#3
0
 public function setFieldAvailableForIssuetype(Issuetype $issuetype, $key, $details = array())
 {
     tables\IssueFields::getTable()->addFieldAndDetailsBySchemeIDandIssuetypeID($this->getID(), $issuetype->getID(), $key, $details);
 }
示例#4
0
 /**
  * Configure issue fields
  *
  * @param framework\Request $request The request object
  */
 public function runConfigureIssuetypes(framework\Request $request)
 {
     $this->mode = $request->getParameter('mode', 'issuetypes');
     if ($this->mode == 'issuetypes' || $this->mode == 'scheme') {
         $this->issue_types = entities\Issuetype::getAll();
         $this->icons = entities\Issuetype::getIcons();
     } elseif ($this->mode == 'schemes') {
         $this->issue_type_schemes = entities\IssuetypeScheme::getAll();
     }
     if ($request->hasParameter('scheme_id')) {
         $this->scheme = entities\IssuetypeScheme::getB2DBTable()->selectById((int) $request['scheme_id']);
         if ($this->mode == 'copy_scheme') {
             if ($new_name = $request['new_name']) {
                 $new_scheme = new entities\IssuetypeScheme();
                 $new_scheme->setName($new_name);
                 $new_scheme->save();
                 foreach ($this->scheme->getIssuetypes() as $issuetype) {
                     $new_scheme->setIssuetypeEnabled($issuetype);
                     $new_scheme->setIssuetypeRedirectedAfterReporting($issuetype, $this->scheme->isIssuetypeRedirectedAfterReporting($issuetype));
                     $new_scheme->setIssuetypeReportable($issuetype, $this->scheme->isIssuetypeReportable($issuetype));
                 }
                 tables\IssueFields::getTable()->copyBySchemeIDs($this->scheme->getID(), $new_scheme->getID());
                 return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/issuetypescheme', array('scheme' => $new_scheme))));
             } else {
                 $this->error = framework\Context::getI18n()->__('Please enter a valid name');
             }
         } elseif ($this->mode == 'delete_scheme') {
             $this->scheme->delete();
             return $this->renderJSON(array('success' => true, 'message' => framework\Context::getI18n()->__('The issuetype scheme was deleted')));
         }
     }
 }
示例#5
0
 public function loadFixtures()
 {
     // Load initial settings
     tables\Settings::getTable()->loadFixtures($this);
     \thebuggenie\core\framework\Settings::loadSettings();
     // Load group, users and permissions fixtures
     Group::loadFixtures($this);
     // Load initial teams
     Team::loadFixtures($this);
     // Set up user states, like "available", "away", etc
     Userstate::loadFixtures($this);
     // Set up data types
     list($b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id) = Issuetype::loadFixtures($this);
     $scheme = IssuetypeScheme::loadFixtures($this);
     tables\IssueFields::getTable()->loadFixtures($this, $scheme, $b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id);
     Datatype::loadFixtures($this);
     // Set up workflows
     Workflow::loadFixtures($this);
     WorkflowScheme::loadFixtures($this);
     tables\WorkflowIssuetype::getTable()->loadFixtures($this);
     // Set up left menu links
     tables\Links::getTable()->loadFixtures($this);
 }