/** * * @param \b2db\Criteria $crit * @param array|\thebuggenie\core\entities\SearchFilter $filters * @param \b2db\Criterion $ctn * @return null */ public function addToCriteria($crit, $filters, $ctn = null) { $filter_key = $this->getFilterKey(); if (in_array($this['operator'], array('=', '!=', '<=', '>=', '<', '>'))) { if ($filter_key == 'text') { if ($this['value'] != '') { $searchterm = mb_strpos($this['value'], '%') !== false ? $this['value'] : "%{$this['value']}%"; $issue_no = Issue::extractIssueNoFromNumber($this['value']); if ($this['operator'] == '=') { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_LIKE); } $ctn->addOr(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_NOT_LIKE); } $ctn->addWhere(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addWhere(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); } return $ctn; } } elseif (in_array($filter_key, self::getValidSearchFilters())) { if ($filter_key == 'subprojects') { if (framework\Context::isProjectContext()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::PROJECT_ID, framework\Context::getCurrentProject()->getID()); } if ($this->hasValue()) { foreach ($this->getValues() as $value) { switch ($value) { case 'all': $subprojects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject()); foreach ($subprojects as $subproject) { if ($subproject->getID() == framework\Context::getCurrentProject()->getID()) { continue; } $ctn->addOr(tables\Issues::PROJECT_ID, $subproject->getID()); } break; case 'none': case '': break; default: $ctn->addOr(tables\Issues::PROJECT_ID, (int) $value); break; } } } return $ctn; } } elseif (in_array($filter_key, array('build', 'edition', 'component'))) { switch ($filter_key) { case 'component': $tbl = tables\IssueAffectsComponent::getTable(); $fk = tables\IssueAffectsComponent::ISSUE; break; case 'edition': $tbl = tables\IssueAffectsEdition::getTable(); $fk = tables\IssueAffectsEdition::ISSUE; break; case 'build': $tbl = tables\IssueAffectsBuild::getTable(); $fk = tables\IssueAffectsBuild::ISSUE; break; } $crit->addJoin($tbl, $fk, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.' . $filter_key, $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { if ($filter_key == 'project_id' && in_array('subprojects', $filters)) { return null; } $values = $this->getValues(); $num_values = 0; if ($filter_key == 'status') { if ($this->hasValue('open')) { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_OPEN); $num_values++; } if ($this->hasValue('closed')) { $num_values++; if (isset($c)) { $c->addWhere(tables\Issues::STATE, Issue::STATE_CLOSED); } else { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_CLOSED); } } if (isset($c)) { if (count($values) == $num_values) { return $c; } else { $crit->addWhere($c); } } } $dbname = tables\Issues::getTable()->getB2DBName(); foreach ($values as $value) { $operator = $this['operator']; $or = true; if ($filter_key == 'status' && in_array($value, array('open', 'closed'))) { continue; } else { $field = $dbname . '.' . $filter_key; if ($operator == '!=' || in_array($filter_key, array('posted', 'last_updated'))) { $or = false; } } if ($ctn === null) { $ctn = $crit->returnCriterion($field, $value, urldecode($operator)); } elseif ($or) { $ctn->addOr($field, $value, urldecode($operator)); } else { $ctn->addWhere($field, $value, urldecode($operator)); } } return $ctn; } } elseif (CustomDatatype::doesKeyExist($filter_key)) { $customdatatype = CustomDatatype::getByKey($filter_key); if (in_array($this->getFilterType(), CustomDatatype::getInternalChoiceFieldsAsArray())) { $tbl = clone tables\IssueCustomFields::getTable(); $crit->addJoin($tbl, tables\IssueCustomFields::ISSUE_ID, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.customfields_id', $customdatatype->getID()), array($tbl->getB2DBAlias() . '.customfieldoption_id', $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { foreach ($this->getValues() as $value) { if ($customdatatype->hasCustomOptions()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } } } return $ctn; } } } }
/** * 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]; }
<div style="position: relative;"> <?php if ($show_edit) { ?> <?php if ($action->isCustomSetAction() && in_array(\thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType())->getType(), array(\thebuggenie\core\entities\CustomDatatype::USER_CHOICE, \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE, \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE))) { ?> <button id="workflowtransitionaction_<?php echo $action->getID(); ?> _edit_button" class="dropper"><?php echo __('Edit'); ?> </button> <?php switch (\thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType())->getType()) { case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE: echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a user'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected user'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => true, 'include_teams' => false, 'include_clients' => false, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown')); break; case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE: echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a team'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected team'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => false, 'include_teams' => true, 'include_clients' => false, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown')); break; case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE: echo include_component('main/identifiableselector', array('html_id' => 'workflowtransitionaction_' . $action->getID() . '_edit', 'header' => __('Select a client'), 'callback' => "TBG.Config.Workflows.Transition.Actions.update('" . make_url('configure_workflow_transition_update_action', array('workflow_id' => $action->getWorkflow()->getID(), 'transition_id' => $action->getTransition()->getID(), 'action_id' => $action->getID())) . "?target_value=%identifiable_value', '" . $action->getID() . "')", 'clear_link_text' => __('Clear currently selected client'), 'base_id' => 'workflowtransitionaction_' . $action->getID(), 'include_users' => false, 'include_teams' => false, 'include_clients' => true, 'absolute' => true, 'hidden' => false, 'classes' => 'leftie popup_box more_actions_dropdown')); break; } ?> <?php } else { ?> <button id="workflowtransitionaction_<?php
} break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_POSTED: echo image_tag('icon_user.png'); if ($item->hasChangeDetails()) { $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getNameWithUsername()) : __('Unknown') : __('Not determined'); $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getNameWithUsername()) : __('Unknown') : __('Not determined'); echo __("Posted by changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>')); } break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED: echo image_tag('icon_customdatatype.png'); if ($item->hasChangeDetails()) { $key_data = explode(':', $item->getText()); $key = $key_data[0]; $customdatatype = \thebuggenie\core\entities\CustomDatatype::getByKey($key); if ($customdatatype instanceof \thebuggenie\core\entities\CustomDatatype) { $old_value = $item->getPreviousValue(); $new_value = $item->getCurrentValue(); switch ($customdatatype->getType()) { case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXT: case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL: case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN: break; case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER: $old_value = $old_value != null ? date('Y-m-d', (int) $old_value) : \thebuggenie\core\framework\Context::getI18n()->__('Not determined'); $new_value = $new_value != null ? date('Y-m-d', (int) $new_value) : \thebuggenie\core\framework\Context::getI18n()->__('Not determined'); break; case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE: case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE: case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
case 'estimated_time': echo __("You don't have access to estimate the issue"); break; case 'spent_time': echo __("You don't have access to specify time already spent working on the issue"); break; case 'percent_complete': echo __("You don't have access to specify how many percent complete the issue is"); break; } ?> <?php } else { ?> <?php echo __('You don\'t have access to enter "%field_name"', array('%field_name' => \thebuggenie\core\entities\CustomDatatype::getByKey($key)->getDescription())); ?> <?php } ?> </li> <?php } else { ?> <li><?php echo $p_error; ?> </li> <?php } ?>
/** * Returns the custom field object used in the validation rule * * @return CustomDatatype */ public function getCustomField() { return CustomDatatype::getByKey($this->getCustomFieldname()); }
public function runConfigureWorkflowTransition(framework\Request $request) { $this->workflow = null; $this->transition = null; try { $this->workflow = tables\Workflows::getTable()->selectById((int) $request['workflow_id']); if ($request->hasParameter('transition_id')) { $mode = $request['mode']; $this->transition = tables\WorkflowTransitions::getTable()->selectById((int) $request['transition_id']); if ($request->isPost()) { if ($mode == 'edit') { if (!$this->transition->isInitialTransition()) { $this->transition->setName($request['transition_name']); $this->transition->setDescription($request['transition_description']); if ($request['template']) { $this->transition->setTemplate($request['template']); } else { $this->transition->setTemplate(null); } } try { $step = tables\WorkflowSteps::getTable()->selectById((int) $request['outgoing_step_id']); $this->transition->setOutgoingStep($step); } catch (\Exception $e) { } $this->transition->save(); $transition = $this->transition; $redirect_transition = true; } elseif ($mode == 'delete') { $this->transition->deleteTransition($request['direction'], $request['step_id']); $this->forward(framework\Context::getRouting()->generate('configure_workflow_step', array('workflow_id' => $this->workflow->getID(), 'step_id' => $request['step_id']))); } elseif ($mode == 'delete_action') { $this->action = tables\WorkflowTransitionActions::getTable()->selectById((int) $request['action_id']); $this->action->delete(); return $this->renderJSON(array('message' => $this->getI18n()->__('The action has been deleted'))); } elseif ($mode == 'new_action') { $action = new entities\WorkflowTransitionAction(); $action->setActionType($request['action_type']); $action->setTransition($this->transition); $action->setWorkflow($this->workflow); $action->setTargetValue(''); $action->save(); return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/workflowtransitionaction', array('action' => $action)))); } elseif ($mode == 'update_action') { $this->action = tables\WorkflowTransitionActions::getTable()->selectById((int) $request['action_id']); $this->action->setTargetValue($request['target_value']); $this->action->save(); $text = $request['target_value']; switch ($this->action->getActionType()) { case entities\WorkflowTransitionAction::ACTION_ASSIGN_ISSUE: if ($this->action->hasTargetValue()) { $target_details = explode('_', $this->action->getTargetValue()); $text = $target_details[0] == 'user' ? entities\User::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : entities\Team::getB2DBTable()->selectById((int) $target_details[1])->getName(); } else { $text = $this->getI18n()->__('User specified during transition'); } break; case entities\WorkflowTransitionAction::ACTION_SET_RESOLUTION: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Resolution specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_REPRODUCABILITY: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Reproducability specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_STATUS: $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Status provided by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_PRIORITY: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Priority specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_MILESTONE: $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Milestone specified by user'); break; case entities\WorkflowTransitionAction::CUSTOMFIELD_SET_PREFIX . $this->action->getCustomActionType(): switch (\thebuggenie\core\entities\CustomDatatype::getByKey($this->action->getCustomActionType())->getType()) { case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN: case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL: break; case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER: return $this->renderJSON(array('content' => date('Y-m-d', (int) $text))); break; case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE: return $this->renderJSON(array('content' => $this->getComponentHTML('main/userdropdown', array('user' => $text)))); break; case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE: return $this->renderJSON(array('content' => $this->getComponentHTML('main/teamdropdown', array('team' => $text)))); break; case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE: if (is_numeric($this->action->getTargetValue())) { $text = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT: default: if (is_numeric($this->action->getTargetValue())) { $text = $this->action->getTargetValue() ? tables\CustomFieldOptions::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user'); } break; } break; } return $this->renderJSON(array('content' => $text)); } elseif ($mode == 'delete_validation_rule') { $this->rule = tables\WorkflowTransitionValidationRules::getTable()->selectById((int) $request['rule_id']); $this->rule->delete(); return $this->renderJSON(array('message' => $this->getI18n()->__('The validation rule has been deleted'))); } elseif ($mode == 'new_validation_rule') { if (!in_array($request['postorpre'], array('post', 'pre'))) { throw new \InvalidArgumentException($this->getI18n()->__('Invalid transition definition')); } $rule = new entities\WorkflowTransitionValidationRule(); if ($request['postorpre'] == 'post') { $exists = (bool) $this->transition->hasPostValidationRule($request['rule']); if (!$exists) { $rule->setPost(); } } elseif ($request['postorpre'] == 'pre') { $exists = (bool) $this->transition->hasPreValidationRule($request['rule']); if (!$exists) { $rule->setPre(); } } if ($exists) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => $this->getI18n()->__('This validation rule already exist'))); } $rule->setRule($request['rule']); $rule->setRuleValue(''); $rule->setTransition($this->transition); $rule->setWorkflow($this->workflow); $rule->save(); return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/workflowtransitionvalidationrule', array('rule' => $rule)))); } elseif ($mode == 'update_validation_rule') { $rule = tables\WorkflowTransitionValidationRules::getTable()->selectById((int) $request['rule_id']); $text = null; if ($rule->isCustom()) { switch ($rule->getCustomType()) { case entities\CustomDatatype::RADIO_CHOICE: case entities\CustomDatatype::DROPDOWN_CHOICE_TEXT: case entities\CustomDatatype::TEAM_CHOICE: case entities\CustomDatatype::STATUS_CHOICE: case entities\CustomDatatype::MILESTONE_CHOICE: case entities\CustomDatatype::CLIENT_CHOICE: case entities\CustomDatatype::COMPONENTS_CHOICE: case entities\CustomDatatype::EDITIONS_CHOICE: case entities\CustomDatatype::RELEASES_CHOICE: $rule->setRuleValue(join(',', $request['rule_value'] ?: array())); $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value'); break; } } else { switch ($rule->getRule()) { case entities\WorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES: $rule->setRuleValue($request['rule_value']); $text = $rule->getRuleValue() ? $rule->getRuleValue() : $this->getI18n()->__('Unlimited'); break; case entities\WorkflowTransitionValidationRule::RULE_PRIORITY_VALID: case entities\WorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID: case entities\WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID: case entities\WorkflowTransitionValidationRule::RULE_STATUS_VALID: case entities\WorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID: case entities\WorkflowTransitionValidationRule::RULE_ISSUE_IN_MILESTONE_VALID: $rule->setRuleValue(join(',', $request['rule_value'] ?: array())); $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value'); break; } } $rule->save(); $this->rule = $rule; return $this->renderJSON(array('content' => $text)); } } } elseif ($request->isPost() && $request->hasParameter('step_id')) { $step = tables\WorkflowSteps::getTable()->selectById((int) $request['step_id']); if ($request['add_transition_type'] == 'existing' && $request->hasParameter('existing_transition_id')) { $transition = tables\WorkflowTransitions::getTable()->selectById((int) $request['existing_transition_id']); $redirect_transition = false; } else { if ($request['transition_name'] && $request['outgoing_step_id'] && $request->hasParameter('template')) { if (($outgoing_step = tables\WorkflowSteps::getTable()->selectById((int) $request['outgoing_step_id'])) && $step instanceof entities\WorkflowStep) { if (!$request['template'] || array_key_exists($request['template'], entities\WorkflowTransition::getTemplates())) { $transition = new entities\WorkflowTransition(); $transition->setWorkflow($this->workflow); $transition->setName($request['transition_name']); $transition->setDescription($request['transition_description']); $transition->setOutgoingStep($outgoing_step); $transition->setTemplate($request['template']); $transition->save(); $step->addOutgoingTransition($transition); $redirect_transition = true; } else { throw new \InvalidArgumentException($this->getI18n()->__('Please select a valid template')); } } else { throw new \InvalidArgumentException($this->getI18n()->__('Please select a valid outgoing step')); } } else { throw new \InvalidArgumentException($this->getI18n()->__('Please fill in all required fields')); } } $step->addOutgoingTransition($transition); } else { throw new \InvalidArgumentException('Invalid action'); } } catch (\InvalidArgumentException $e) { $this->error = $e->getMessage(); } catch (\Exception $e) { $this->error = $this->getI18n()->__('This workflow / transition does not exist'); } if (isset($redirect_transition) && $redirect_transition) { $this->forward(framework\Context::getRouting()->generate('configure_workflow_transition', array('workflow_id' => $this->workflow->getID(), 'transition_id' => $transition->getID()))); } elseif (isset($redirect_transition)) { $this->forward(framework\Context::getRouting()->generate('configure_workflow_steps', array('workflow_id' => $this->workflow->getID()))); } }
protected function _processChanges() { $related_issues_to_save = array(); $changed_properties = $this->_getChangedProperties(); if (count($changed_properties)) { $is_saved_estimated = false; $is_saved_spent = false; $is_saved_assignee = false; $is_saved_owner = false; foreach ($changed_properties as $property => $value) { $compare_value = is_object($this->{$property}) ? $this->{$property}->getID() : $this->{$property}; $original_value = $value['original_value']; if ($original_value != $compare_value) { switch ($property) { case '_title': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_TITLE, framework\Context::getI18n()->__("Title updated"), $original_value, $compare_value); break; case '_shortname': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_SHORTNAME, framework\Context::getI18n()->__("Issue label updated"), $original_value, $compare_value); break; case '_description': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_DESCRIPTION, framework\Context::getI18n()->__("Description updated"), $original_value, $compare_value); break; case '_reproduction_steps': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_REPRODUCTIONSTEPS, framework\Context::getI18n()->__("Reproduction steps updated"), $original_value, $compare_value); break; case '_category': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getCategory() instanceof Datatype ? $this->getCategory()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_CATEGORY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_bug_type': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_bug_type', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_bug_type', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_BUG_TYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_effect': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_effect', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_effect', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_EFFECT, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_likelihood': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_likelihood', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_likelihood', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_user_pain': $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' ⇒ ' . $value['current_value']); break; case '_status': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getStatus() instanceof Datatype ? $this->getStatus()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_STATUS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_reproducability': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getReproducability() instanceof Datatype ? $this->getReproducability()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_REPRODUCABILITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_priority': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Priority::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getPriority() instanceof Datatype ? $this->getPriority()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PRIORITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_assignee_team': case '_assignee_user': if (!$is_saved_assignee) { $new_name = $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->getName() : framework\Context::getI18n()->__('Not assigned'); if ($this->getAssignee() instanceof \thebuggenie\core\entities\User) { $this->startWorkingOnIssue($this->getAssignee()); } $this->addLogEntry(tables\Log::LOG_ISSUE_ASSIGNED, $new_name); $is_saved_assignee = true; } break; case '_posted_by': $old_identifiable = $original_value ? \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value) : framework\Context::getI18n()->__('Unknown'); $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown'); $new_name = $this->getPostedBy()->getName(); $this->addLogEntry(tables\Log::LOG_ISSUE_POSTED, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_being_worked_on_by_user': if ($original_value != 0) { $old_identifiable = \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value); $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not being worked on'); } $new_name = $this->getUserWorkingOnIssue() instanceof \thebuggenie\core\entities\User ? $this->getUserWorkingOnIssue()->getName() : framework\Context::getI18n()->__('Not being worked on'); $this->addLogEntry(tables\Log::LOG_ISSUE_USERS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_owner_team': case '_owner_user': if (!$is_saved_owner) { $new_name = $this->getOwner() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getOwner()->getName() : framework\Context::getI18n()->__('Not owned by anyone'); $this->addLogEntry(tables\Log::LOG_ISSUE_OWNED, $new_name); $is_saved_owner = true; } break; case '_percent_complete': $this->addLogEntry(tables\Log::LOG_ISSUE_PERCENT, $original_value . '% ⇒ ' . $this->getPercentCompleted() . '', $original_value, $compare_value); break; case '_resolution': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getResolution() instanceof Datatype ? $this->getResolution()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_RESOLUTION, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_severity': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Severity::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getSeverity() instanceof Datatype ? $this->getSeverity()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_SEVERITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_milestone': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getMilestone() instanceof \thebuggenie\core\entities\Milestone ? $this->getMilestone()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_MILESTONE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); $this->_milestone_order = 0; break; case '_issuetype': if ($original_value != 0) { $old_name = ($old_item = Issuetype::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Unknown'); } $new_name = $this->getIssuetype() instanceof \thebuggenie\core\entities\Issuetype ? $this->getIssuetype()->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_ISSUETYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_estimated_months': case '_estimated_weeks': case '_estimated_days': case '_estimated_hours': case '_estimated_points': if (!$is_saved_estimated) { $old_time = array('months' => $this->getChangedPropertyOriginal('_estimated_months'), 'weeks' => $this->getChangedPropertyOriginal('_estimated_weeks'), 'days' => $this->getChangedPropertyOriginal('_estimated_days'), 'hours' => $this->getChangedPropertyOriginal('_estimated_hours'), 'points' => $this->getChangedPropertyOriginal('_estimated_points')); $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('Not estimated'); $new_formatted_time = $this->hasEstimatedTime() ? Issue::getFormattedTime($this->getEstimatedTime()) : framework\Context::getI18n()->__('Not estimated'); $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_ESTIMATED, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getEstimatedTime())); $is_saved_estimated = true; } break; case '_spent_months': case '_spent_weeks': case '_spent_days': case '_spent_hours': case '_spent_points': if (!$is_saved_spent) { $old_time = array('months' => $this->getChangedPropertyOriginal('_spent_months'), 'weeks' => $this->getChangedPropertyOriginal('_spent_weeks'), 'days' => $this->getChangedPropertyOriginal('_spent_days'), 'hours' => round($this->getChangedPropertyOriginal('_spent_hours') / 100, 2), 'points' => $this->getChangedPropertyOriginal('_spent_points')); $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('No time spent'); $new_formatted_time = $this->hasSpentTime() ? Issue::getFormattedTime($this->getSpentTime()) : framework\Context::getI18n()->__('No time spent'); $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_SPENT, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getSpentTime())); $is_saved_spent = true; } break; case '_state': if ($this->isClosed()) { $this->addLogEntry(tables\Log::LOG_ISSUE_CLOSE); if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) { if ($this->getMilestone()->isSprint()) { if (!$this->getIssueType()->isTask()) { $this->setSpentPoints($this->getEstimatedPoints()); } else { if ($this->getSpentHours() < $this->getEstimatedHours()) { $this->setSpentHours($this->getEstimatedHours()); } foreach ($this->getParentIssues() as $parent_issue) { if ($parent_issue->checkTaskStates()) { $related_issues_to_save[$parent_issue->getID()] = true; } } } } $this->getMilestone()->updateStatus(); $this->getMilestone()->save(); } } else { $this->addLogEntry(tables\Log::LOG_ISSUE_REOPEN); } break; case '_blocking': if ($this->isBlocking()) { $this->addLogEntry(tables\Log::LOG_ISSUE_BLOCKED); } else { $this->addLogEntry(tables\Log::LOG_ISSUE_UNBLOCKED); } break; default: if (mb_substr($property, 0, 12) == '_customfield') { $key = mb_substr($property, 12); $customdatatype = CustomDatatype::getByKey($key); switch ($customdatatype->getType()) { case CustomDatatype::INPUT_TEXT: $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value); break; case CustomDatatype::INPUT_TEXTAREA_SMALL: case CustomDatatype::INPUT_TEXTAREA_MAIN: $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value); break; case CustomDatatype::EDITIONS_CHOICE: case CustomDatatype::COMPONENTS_CHOICE: case CustomDatatype::RELEASES_CHOICE: case CustomDatatype::MILESTONE_CHOICE: case CustomDatatype::STATUS_CHOICE: case CustomDatatype::TEAM_CHOICE: case CustomDatatype::USER_CHOICE: case CustomDatatype::CLIENT_CHOICE: $old_object = null; $new_object = null; try { switch ($customdatatype->getType()) { case CustomDatatype::EDITIONS_CHOICE: $old_object = Edition::getB2DBTable()->selectById($original_value); break; case CustomDatatype::COMPONENTS_CHOICE: $old_object = Component::getB2DBTable()->selectById($original_value); break; case CustomDatatype::RELEASES_CHOICE: $old_object = Build::getB2DBTable()->selectById($original_value); break; case CustomDatatype::MILESTONE_CHOICE: $old_object = Milestone::getB2DBTable()->selectById($original_value); break; case CustomDatatype::STATUS_CHOICE: $old_object = Status::getB2DBTable()->selectById($original_value); break; case CustomDatatype::TEAM_CHOICE: $old_object = Team::getB2DBTable()->selectById($original_value); break; case CustomDatatype::USER_CHOICE: $old_object = User::getB2DBTable()->selectById($original_value); break; case CustomDatatype::CLIENT_CHOICE: $old_object = Client::getB2DBTable()->selectById($original_value); break; } } catch (\Exception $e) { } try { switch ($customdatatype->getType()) { case CustomDatatype::EDITIONS_CHOICE: case CustomDatatype::COMPONENTS_CHOICE: case CustomDatatype::RELEASES_CHOICE: case CustomDatatype::MILESTONE_CHOICE: case CustomDatatype::STATUS_CHOICE: case CustomDatatype::TEAM_CHOICE: case CustomDatatype::USER_CHOICE: case CustomDatatype::CLIENT_CHOICE: $new_object = $this->getCustomField($key); break; } } catch (\Exception $e) { } $old_value = is_object($old_object) ? $old_object->getName() : framework\Context::getI18n()->__('Unknown'); $new_value = is_object($new_object) ? $new_object->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' ⇒ ' . $new_value, $original_value, $compare_value); break; default: $old_item = null; try { $old_item = $original_value ? new CustomDatatypeOption($original_value) : null; } catch (\Exception $e) { } $old_value = $old_item instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); $new_value = $this->getCustomField($key) instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $this->getCustomField($key)->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' ⇒ ' . $new_value, $original_value, $compare_value); break; } } break; } } } if ($is_saved_estimated) { tables\IssueEstimates::getTable()->saveEstimate($this->getID(), $this->_estimated_months, $this->_estimated_weeks, $this->_estimated_days, $this->_estimated_hours, $this->_estimated_points); } } return $related_issues_to_save; }
/** * Reverts an issue field back to the original value * * @param \thebuggenie\core\framework\Request $request */ public function runIssueRevertField(framework\Request $request) { if ($issue_id = $request['issue_id']) { try { $issue = entities\Issue::getB2DBTable()->selectById($issue_id); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderText('fail'); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderText('no issue'); } $field = null; framework\Context::loadLibrary('common'); switch ($request['field']) { case 'description': $issue->revertDescription(); $issue->revertDescription_Syntax(); $field = array('id' => (int) ($issue->getDescription() != ''), 'name' => $issue->getParsedDescription(array('issue' => $issue)), 'form_value' => $issue->getDescription()); break; case 'reproduction_steps': $issue->revertReproduction_Steps(); $issue->revertReproduction_Steps_Syntax(); $field = array('id' => (int) ($issue->getReproductionSteps() != ''), 'name' => $issue->getParsedReproductionSteps(array('issue' => $issue)), 'form_value' => $issue->getReproductionSteps()); break; case 'title': $issue->revertTitle(); $field = array('id' => 1, 'name' => strip_tags($issue->getTitle())); break; case 'shortname': $issue->revertShortname(); $field = array('id' => 1, 'name' => strip_tags($issue->getShortname())); break; case 'category': $issue->revertCategory(); $field = $issue->getCategory() instanceof entities\Category ? array('id' => $issue->getCategory()->getID(), 'name' => $issue->getCategory()->getName()) : array('id' => 0); break; case 'resolution': $issue->revertResolution(); $field = $issue->getResolution() instanceof entities\Resolution ? array('id' => $issue->getResolution()->getID(), 'name' => $issue->getResolution()->getName()) : array('id' => 0); break; case 'severity': $issue->revertSeverity(); $field = $issue->getSeverity() instanceof entities\Severity ? array('id' => $issue->getSeverity()->getID(), 'name' => $issue->getSeverity()->getName()) : array('id' => 0); break; case 'reproducability': $issue->revertReproducability(); $field = $issue->getReproducability() instanceof entities\Reproducability ? array('id' => $issue->getReproducability()->getID(), 'name' => $issue->getReproducability()->getName()) : array('id' => 0); break; case 'priority': $issue->revertPriority(); $field = $issue->getPriority() instanceof entities\Priority ? array('id' => $issue->getPriority()->getID(), 'name' => $issue->getPriority()->getName()) : array('id' => 0); break; case 'percent_complete': $issue->revertPercentCompleted(); $field = $issue->getPercentCompleted(); break; case 'status': $issue->revertStatus(); $field = $issue->getStatus() instanceof entities\Status ? array('id' => $issue->getStatus()->getID(), 'name' => $issue->getStatus()->getName(), 'color' => $issue->getStatus()->getColor()) : array('id' => 0); break; case 'pain_bug_type': $issue->revertPainBugType(); $field = $issue->hasPainBugType() ? array('id' => $issue->getPainBugType(), 'name' => $issue->getPainBugTypeLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'pain_likelihood': $issue->revertPainLikelihood(); $field = $issue->hasPainLikelihood() ? array('id' => $issue->getPainLikelihood(), 'name' => $issue->getPainLikelihoodLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'pain_effect': $issue->revertPainEffect(); $field = $issue->hasPainEffect() ? array('id' => $issue->getPainEffect(), 'name' => $issue->getPainEffectLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'issuetype': $issue->revertIssuetype(); $field = $issue->getIssuetype() instanceof entities\Issuetype ? array('id' => $issue->getIssuetype()->getID(), 'name' => $issue->getIssuetype()->getName(), 'src' => htmlspecialchars(framework\Context::getWebroot() . 'images/' . $issue->getIssuetype()->getIcon() . '_small.png')) : array('id' => 0); $visible_fields = $issue->getIssuetype() instanceof entities\Issuetype ? $issue->getProject()->getVisibleFieldsArray($issue->getIssuetype()->getID()) : array(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field, 'visible_fields' => $visible_fields)); break; case 'milestone': $issue->revertMilestone(); $field = $issue->getMilestone() instanceof entities\Milestone ? array('id' => $issue->getMilestone()->getID(), 'name' => $issue->getMilestone()->getName()) : array('id' => 0); break; case 'estimated_time': $issue->revertEstimatedTime(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasEstimatedTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getEstimatedTime(true, true))) : array('id' => 0), 'values' => $issue->getEstimatedTime(true, true), 'percentbar' => $this->getComponentHTML('main/percentbar', array('percent' => $issue->getEstimatedPercentCompleted(), 'height' => 3)))); break; case 'spent_time': $issue->revertSpentTime(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasSpentTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getSpentTime(true, true))) : array('id' => 0), 'values' => $issue->getSpentTime(true, true))); break; case 'owned_by': $issue->revertOwner(); return $this->renderJSON(array('changed' => $issue->isOwnerChanged(), 'field' => $issue->isOwned() ? array('id' => $issue->getOwner()->getID(), 'name' => $issue->getOwner() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getOwner()))) : array('id' => 0))); break; case 'assigned_to': $issue->revertAssignee(); return $this->renderJSON(array('changed' => $issue->isAssigneeChanged(), 'field' => $issue->isAssigned() ? array('id' => $issue->getAssignee()->getID(), 'name' => $issue->getAssignee() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getAssignee())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getAssignee()))) : array('id' => 0))); break; case 'posted_by': $issue->revertPostedBy(); return $this->renderJSON(array('changed' => $issue->isPostedByChanged(), 'field' => array('id' => $issue->getPostedByID(), 'name' => $this->getComponentHTML('main/userdropdown', array('user' => $issue->getPostedBy()))))); break; default: if ($customdatatype = entities\CustomDatatype::getByKey($request['field'])) { $key = $customdatatype->getKey(); $revert_methodname = "revertCustomfield{$key}"; $issue->{$revert_methodname}(); if ($customdatatype->hasCustomOptions()) { $field = $issue->getCustomField($key) instanceof entities\CustomDatatypeOption ? array('value' => $issue->getCustomField($key)->getID(), 'name' => $issue->getCustomField($key)->getName()) : array('id' => 0); } else { switch ($customdatatype->getType()) { case entities\CustomDatatype::INPUT_TEXTAREA_MAIN: case entities\CustomDatatype::INPUT_TEXTAREA_SMALL: $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => tbg_parse_text($issue->getCustomField($key))) : array('id' => 0); break; default: $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => $issue->getCustomField($key)) : array('id' => 0); break; } } } break; } if ($field !== null) { return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field)); } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('No valid field specified (%field)', array('%field' => $request['field'])))); } }
} ?> "> <?php if ($swimlane->getBoard()->hasIssueFieldValues()) { ?> <?php foreach ($issue_custom_fields_of_type as $key => $value) { ?> <?php if (!$swimlane->getBoard()->hasIssueFieldValue($key)) { continue; } ?> <div class="issue_component issue_date" title="<?php echo \thebuggenie\core\entities\CustomDatatype::getByKey($key)->getDescription(); ?> "><?php echo tbg_formattime($value, 14); ?> </div> <?php } ?> <?php } ?> </div> <?php } ?>
public function componentIssueFields() { $this->items = array(); $this->showitems = true; $this->iscustom = false; $types = entities\Datatype::getTypes(); if (array_key_exists($this->type, $types)) { $this->items = call_user_func(array($types[$this->type], 'getAll')); } else { $customtype = entities\CustomDatatype::getByKey($this->type); $this->showitems = $customtype->hasCustomOptions(); $this->iscustom = true; if ($this->showitems) { $this->items = $customtype->getOptions(); } $this->customtype = $customtype; } }