public static function getAvailablePostValidationRules() { $initial_list = array(); $i18n = framework\Context::getI18n(); $initial_list[self::RULE_PRIORITY_VALID] = $i18n->__('Validate specified priority'); $initial_list[self::RULE_REPRODUCABILITY_VALID] = $i18n->__('Validate specified reproducability'); $initial_list[self::RULE_RESOLUTION_VALID] = $i18n->__('Validate specified resolution'); $initial_list[self::RULE_STATUS_VALID] = $i18n->__('Validate specified status'); foreach (CustomDatatype::getAll() as $key => $details) { $initial_list[self::CUSTOMFIELD_VALIDATE_PREFIX . $key] = $i18n->__('Validate specified %key', array('%key' => $key)); } $initial_list[self::RULE_TEAM_MEMBERSHIP_VALID] = $i18n->__('Validate team membership of assignee'); $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::getAvailablePostValidationRules', null, array(), $initial_list); $event->trigger(); return $event->getReturnList(); }
protected static function _populateAvailableActions() { if (self::$_available_actions === null) { $initial_list = array('special' => array(), 'set' => array(), 'clear' => array()); $i18n = framework\Context::getI18n(); $initial_list['special'][self::ACTION_ASSIGN_ISSUE] = $i18n->__('Assign the issue to a user'); $initial_list['special'][self::ACTION_ASSIGN_ISSUE_SELF] = $i18n->__('Assign the issue to the current user'); $initial_list['special'][self::ACTION_CLEAR_DUPLICATE] = $i18n->__('Mark as not duplicate'); $initial_list['special'][self::ACTION_SET_DUPLICATE] = $i18n->__('Possibly mark as duplicate'); $initial_list['special'][self::ACTION_USER_START_WORKING] = $i18n->__('Start logging time'); $initial_list['special'][self::ACTION_USER_STOP_WORKING] = $i18n->__('Stop logging time and optionally add time spent'); $initial_list['clear'][self::ACTION_CLEAR_ASSIGNEE] = $i18n->__('Clear issue assignee'); $initial_list['clear'][self::ACTION_CLEAR_PRIORITY] = $i18n->__('Clear issue priority'); $initial_list['clear'][self::ACTION_CLEAR_PERCENT] = $i18n->__('Clear issue percent'); $initial_list['clear'][self::ACTION_CLEAR_REPRODUCABILITY] = $i18n->__('Clear issue reproducability'); $initial_list['clear'][self::ACTION_CLEAR_RESOLUTION] = $i18n->__('Clear issue resolution'); $initial_list['clear'][self::ACTION_CLEAR_MILESTONE] = $i18n->__('Clear issue milestone'); $initial_list['set'][self::ACTION_SET_PRIORITY] = $i18n->__('Set issue priority'); $initial_list['set'][self::ACTION_SET_PERCENT] = $i18n->__('Set issue percent'); $initial_list['set'][self::ACTION_SET_REPRODUCABILITY] = $i18n->__('Set issue reproducability'); $initial_list['set'][self::ACTION_SET_RESOLUTION] = $i18n->__('Set issue resolution'); $initial_list['set'][self::ACTION_SET_STATUS] = $i18n->__('Set issue status'); $initial_list['set'][self::ACTION_SET_MILESTONE] = $i18n->__('Set issue milestone'); foreach (CustomDatatype::getAll() as $key => $details) { $initial_list['clear'][self::CUSTOMFIELD_CLEAR_PREFIX . $key] = $i18n->__('Clear issue field %key', array('%key' => $key)); $initial_list['set'][self::CUSTOMFIELD_SET_PREFIX . $key] = $i18n->__('Set issue field %key', array('%key' => $key)); } $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionAction::getAvailableTransitionActions', null, array(), $initial_list); $event->trigger(); self::$_available_actions = $event->getReturnList(); } }
protected function _postIssueValidation(framework\Request $request, &$errors, &$permission_errors) { $i18n = framework\Context::getI18n(); if (!$this->selected_project instanceof entities\Project) { $errors['project'] = $i18n->__('You have to select a valid project'); } if (!$this->selected_issuetype instanceof entities\Issuetype) { $errors['issuetype'] = $i18n->__('You have to select a valid issue type'); } if (empty($errors)) { $fields_array = $this->selected_project->getReportableFieldsArray($this->issuetype_id); $this->title = $request->getRawParameter('title'); $this->selected_shortname = $request->getRawParameter('shortname', null); $this->selected_description = $request->getRawParameter('description', null); $this->selected_description_syntax = $request->getRawParameter('description_syntax', null); $this->selected_reproduction_steps = $request->getRawParameter('reproduction_steps', null); $this->selected_reproduction_steps_syntax = $request->getRawParameter('reproduction_steps_syntax', null); if ($edition_id = (int) $request['edition_id']) { $this->selected_edition = entities\Edition::getB2DBTable()->selectById($edition_id); } if ($build_id = (int) $request['build_id']) { $this->selected_build = entities\Build::getB2DBTable()->selectById($build_id); } if ($component_id = (int) $request['component_id']) { $this->selected_component = entities\Component::getB2DBTable()->selectById($component_id); } if (trim($this->title) == '' || $this->title == $this->default_title) { $errors['title'] = true; } if (isset($fields_array['shortname']) && $fields_array['shortname']['required'] && trim($this->selected_shortname) == '') { $errors['shortname'] = true; } if (isset($fields_array['description']) && $fields_array['description']['required'] && trim($this->selected_description) == '') { $errors['description'] = true; } if (isset($fields_array['reproduction_steps']) && !$request->isAjaxCall() && $fields_array['reproduction_steps']['required'] && trim($this->selected_reproduction_steps) == '') { $errors['reproduction_steps'] = true; } if (isset($fields_array['edition']) && $edition_id && !in_array($edition_id, array_keys($fields_array['edition']['values']))) { $errors['edition'] = true; } if (isset($fields_array['build']) && $build_id && !in_array($build_id, array_keys($fields_array['build']['values']))) { $errors['build'] = true; } if (isset($fields_array['component']) && $component_id && !in_array($component_id, array_keys($fields_array['component']['values']))) { $errors['component'] = true; } if ($category_id = (int) $request['category_id']) { $category = entities\Category::getB2DBTable()->selectById($category_id); if (!$category->hasAccess()) { $errors['category'] = true; } else { $this->selected_category = $category; } } if ($status_id = (int) $request['status_id']) { $this->selected_status = entities\Status::getB2DBTable()->selectById($status_id); } if ($reproducability_id = (int) $request['reproducability_id']) { $this->selected_reproducability = entities\Reproducability::getB2DBTable()->selectById($reproducability_id); } if ($milestone_id = (int) $request['milestone_id']) { $milestone = $this->_getMilestoneFromRequest($request); if (!$milestone instanceof entities\Milestone) { $errors['milestone'] = true; } else { $this->selected_milestone = $milestone; } } if ($parent_issue_id = (int) $request['parent_issue_id']) { $this->parent_issue = entities\Issue::getB2DBTable()->selectById($parent_issue_id); } if ($resolution_id = (int) $request['resolution_id']) { $this->selected_resolution = entities\Resolution::getB2DBTable()->selectById($resolution_id); } if ($severity_id = (int) $request['severity_id']) { $this->selected_severity = entities\Severity::getB2DBTable()->selectById($severity_id); } if ($priority_id = (int) $request['priority_id']) { $this->selected_priority = entities\Priority::getB2DBTable()->selectById($priority_id); } if ($request['estimated_time']) { $this->selected_estimated_time = $request['estimated_time']; } if ($request['spent_time']) { $this->selected_spent_time = $request['spent_time']; } if (is_numeric($request['percent_complete'])) { $this->selected_percent_complete = (int) $request['percent_complete']; } if ($pain_bug_type_id = (int) $request['pain_bug_type_id']) { $this->selected_pain_bug_type = $pain_bug_type_id; } if ($pain_likelihood_id = (int) $request['pain_likelihood_id']) { $this->selected_pain_likelihood = $pain_likelihood_id; } if ($pain_effect_id = (int) $request['pain_effect_id']) { $this->selected_pain_effect = $pain_effect_id; } $selected_customdatatype = array(); foreach (entities\CustomDatatype::getAll() as $customdatatype) { $customdatatype_id = $customdatatype->getKey() . '_id'; $customdatatype_value = $customdatatype->getKey() . '_value'; if ($customdatatype->hasCustomOptions()) { $selected_customdatatype[$customdatatype->getKey()] = null; if ($request->hasParameter($customdatatype_id)) { $customdatatype_id = (int) $request->getParameter($customdatatype_id); $selected_customdatatype[$customdatatype->getKey()] = new entities\CustomDatatypeOption($customdatatype_id); } } else { $selected_customdatatype[$customdatatype->getKey()] = null; switch ($customdatatype->getType()) { case entities\CustomDatatype::INPUT_TEXTAREA_MAIN: case entities\CustomDatatype::INPUT_TEXTAREA_SMALL: if ($request->hasParameter($customdatatype_value)) { $selected_customdatatype[$customdatatype->getKey()] = $request->getParameter($customdatatype_value, null, false); } break; default: if ($request->hasParameter($customdatatype_value)) { $selected_customdatatype[$customdatatype->getKey()] = $request->getParameter($customdatatype_value); } elseif ($request->hasParameter($customdatatype_id)) { $selected_customdatatype[$customdatatype->getKey()] = $request->getParameter($customdatatype_id); } break; } } } $this->selected_customdatatype = $selected_customdatatype; foreach ($fields_array as $field => $info) { if ($field == 'user_pain') { if ($info['required']) { if (!($this->selected_pain_bug_type != 0 && $this->selected_pain_likelihood != 0 && $this->selected_pain_effect != 0)) { $errors['user_pain'] = true; } } } elseif ($info['required']) { $var_name = "selected_{$field}"; if (in_array($field, entities\Datatype::getAvailableFields(true)) && ($this->{$var_name} === null || $this->{$var_name} === 0) || !in_array($field, entities\DatatypeBase::getAvailableFields(true)) && !in_array($field, array('pain_bug_type', 'pain_likelihood', 'pain_effect')) && (array_key_exists($field, $selected_customdatatype) && $selected_customdatatype[$field] === null)) { $errors[$field] = true; } } else { if (in_array($field, entities\Datatype::getAvailableFields(true)) || in_array($field, array('pain_bug_type', 'pain_likelihood', 'pain_effect'))) { if (!$this->selected_project->fieldPermissionCheck($field)) { $permission_errors[$field] = true; } } elseif (!$this->selected_project->fieldPermissionCheck($field, true, true)) { $permission_errors[$field] = true; } } } $event = new \thebuggenie\core\framework\Event('core', 'mainActions::_postIssueValidation', null, array(), $errors); $event->trigger(); $errors = $event->getReturnList(); } return !(bool) (count($errors) + count($permission_errors)); }