Ejemplo n.º 1
0
 /**
  * Assign a user story to a milestone id
  *
  * @Route(url="/assign/issue/milestone/:milestone_id")
  *
  * @param framework\Request $request
  */
 public function runAssignMilestone(framework\Request $request)
 {
     $this->forward403if(framework\Context::getCurrentProject()->isArchived());
     $this->forward403unless($this->_checkProjectPageAccess('project_scrum') && framework\Context::getUser()->canAssignScrumUserStories($this->selected_project));
     try {
         $issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $request['issue_id']);
         $milestone = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
         if (!$issue instanceof \thebuggenie\core\entities\Issue) {
             throw new \Exception($this->getI18n()->__('This is not a valid issue'));
         }
         $issue->setMilestone($milestone);
         $issue->save();
         foreach ($issue->getChildIssues() as $child_issue) {
             $child_issue->setMilestone($milestone);
             $child_issue->save();
         }
         $new_issues = $milestone instanceof \thebuggenie\core\entities\Milestone ? $milestone->countIssues() : 0;
         $new_e_points = $milestone instanceof \thebuggenie\core\entities\Milestone ? $milestone->getPointsEstimated() : 0;
         $new_e_hours = $milestone instanceof \thebuggenie\core\entities\Milestone ? $milestone->getHoursEstimated() : 0;
         return $this->renderJSON(array('issue_id' => $issue->getID(), 'issues' => $new_issues, 'points' => $new_e_points, 'hours' => $new_e_hours));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Ejemplo n.º 2
0
 protected function _upgradeFrom3dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable());
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable());
     \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable());
     \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable());
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable());
     \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable());
     \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable());
     \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable());
     \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable());
     \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable());
     \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable());
     \thebuggenie\core\entities\Dashboard::getB2DBTable()->create();
     \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable());
     \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create();
     \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manual_password'];
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 if ($field == 'username' && trim($user->getUsername())) {
                     $user->setPassword(trim($user->getUsername()));
                     $user->save();
                 } elseif ($field == 'email' && trim($user->getEmail())) {
                     $user->setPassword(trim($user->getEmail()));
                     $user->save();
                 }
             }
             break;
     }
     $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id);
         if ($scope instanceof \thebuggenie\core\entities\Scope) {
             $epic = new \thebuggenie\core\entities\Issuetype();
             $epic->setName('Epic');
             $epic->setIcon('epic');
             $epic->setDescription('Issue type suited for entering epics');
             $epic->setScope($scope_id);
             $epic->save();
             framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id);
             foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new \thebuggenie\core\entities\WorkflowTransition();
                 $steps = $workflow->getSteps();
                 $step = array_shift($steps);
                 $step->setLinkedStatusID((int) $status_id);
                 $step->save();
                 $transition->setOutgoingStep($step);
                 $transition->setName('Issue created');
                 $transition->setWorkflow($workflow);
                 $transition->setScope($scope);
                 $transition->setDescription('This is the initial transition for issues using this workflow');
                 $transition->save();
                 $workflow->setInitialTransition($transition);
                 $workflow->save();
             }
             \thebuggenie\core\entities\ActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     framework\Context::finishUpgrading();
     foreach (framework\Context::getModules() as $module) {
         $module->upgrade();
     }
     $this->upgrade_complete = true;
 }
Ejemplo n.º 3
0
 public function preloadValues()
 {
     static $preloaded = false;
     if (!$preloaded) {
         $milestones = tables\Milestones::getTable()->getByProjectID($this->getID());
         unset($milestones);
         $issuetypes = IssueType::getAll();
         unset($issuetypes);
         tables\ListTypes::getTable()->populateItemCache();
     }
     $preloaded = true;
 }
Ejemplo n.º 4
0
 protected function _upgradeFrom4dot1(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_41\Milestone::getB2DBTable());
     $this->upgrade_complete = true;
     $this->current_version = '4.1.1';
 }
Ejemplo n.º 5
0
 public function runGetMilestoneRoadmapIssues(framework\Request $request)
 {
     try {
         $i18n = framework\Context::getI18n();
         if ($request->hasParameter('milestone_id')) {
             $milestone = tables\Milestones::getTable()->selectById($request['milestone_id']);
             return $this->renderJSON(array('content' => $this->getComponentHTML('project/milestoneissues', array('milestone' => $milestone))));
         } else {
             throw new \Exception($i18n->__('Invalid milestone'));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\ListTypes::getTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . ($action->getTargetValue() ? $target->getName() : __('Value provided by user')) . '</span>'));
             break;
         case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT:
         default:
             $target = $action->getTargetValue() ? \thebuggenie\core\entities\CustomDatatypeOption::getB2DBTable()->selectById((int) $action->getTargetValue()) : null;
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? $target->getName() : __('Value provided by user')) . '</span>'));
             break;
     }
     ?>
             <?php 
 }
 public function getRuleValueAsJoinedString()
 {
     $is_core = in_array($this->_name, array(self::RULE_STATUS_VALID, self::RULE_RESOLUTION_VALID, self::RULE_REPRODUCABILITY_VALID, self::RULE_PRIORITY_VALID, self::RULE_TEAM_MEMBERSHIP_VALID, self::RULE_ISSUE_IN_MILESTONE_VALID));
     $is_custom = $this->isCustom();
     $customtype = $this->getCustomType();
     if ($this->_name == self::RULE_STATUS_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Status';
     } elseif ($this->_name == self::RULE_RESOLUTION_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Resolution';
     } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Reproducability';
     } elseif ($this->_name == self::RULE_PRIORITY_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Priority';
     } elseif ($this->_name == self::RULE_TEAM_MEMBERSHIP_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Team';
     } elseif ($this->_name == self::RULE_ISSUE_IN_MILESTONE_VALID) {
         $fieldname = '\\thebuggenie\\core\\entities\\Milestone';
     }
     if ($is_core || $is_custom) {
         $values = explode(',', $this->getRuleValue());
         if ($is_custom) {
             $custom_field_key = substr($this->_name, strlen(self::CUSTOMFIELD_VALIDATE_PREFIX) - 1);
             $custom_field = tables\CustomFields::getTable()->getByKey($custom_field_key);
         }
         $return_values = array();
         foreach ($values as $value) {
             try {
                 if ($is_core) {
                     $field = $fieldname::getB2DBTable()->selectByID((int) $value);
                 } elseif ($is_custom) {
                     switch ($customtype) {
                         case CustomDatatype::RADIO_CHOICE:
                         case CustomDatatype::DROPDOWN_CHOICE_TEXT:
                             $field = tables\CustomFieldOptions::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::TEAM_CHOICE:
                             $field = Teams::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::STATUS_CHOICE:
                             $field = ListTypes::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::MILESTONE_CHOICE:
                             $field = Milestones::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::CLIENT_CHOICE:
                             $field = Clients::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::COMPONENTS_CHOICE:
                             $field = Components::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::EDITIONS_CHOICE:
                             $field = Editions::getTable()->selectById((int) $value);
                             break;
                         case CustomDatatype::RELEASES_CHOICE:
                             $field = Builds::getTable()->selectById((int) $value);
                             break;
                     }
                 }
                 if ($field instanceof \thebuggenie\core\entities\common\Identifiable) {
                     if ($field instanceof Milestone || $field instanceof Component || $field instanceof Edition || $field instanceof Build) {
                         $return_values[] = $field->getProject()->getName() . ' - ' . $field->getName();
                     } elseif ($field instanceof Status) {
                         $return_values[] = '<span class="status_badge" style="background-color: ' . $field->getColor() . '; color: ' . $field->getTextColor() . ';">' . $field->getName() . '</span>';
                     } else {
                         $return_values[] = $field->getName();
                     }
                 }
             } catch (\Exception $e) {
             }
         }
         return join(' / ', $return_values);
     } else {
         $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::getRuleValueAsJoinedString', $this);
         $event->triggerUntilProcessed();
         return $event->getReturnValue();
     }
 }
Ejemplo n.º 8
0
 protected function _populateOptions()
 {
     if ($this->_options === null) {
         if ($this->hasCustomOptions()) {
             $this->_b2dbLazyload('_options');
         } else {
             switch ($this->getType()) {
                 case self::RELEASES_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getBuilds() : \thebuggenie\core\entities\tables\Builds::getTable()->selectAll();
                     break;
                 case self::COMPONENTS_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getComponents() : \thebuggenie\core\entities\tables\Components::getTable()->selectAll();
                     break;
                 case self::EDITIONS_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getEditions() : \thebuggenie\core\entities\tables\Editions::getTable()->selectAll();
                     break;
                 case self::MILESTONE_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getMilestonesForIssues() : \thebuggenie\core\entities\tables\Milestones::getTable()->selectAll();
                     break;
                 case self::STATUS_CHOICE:
                     $this->_options = \thebuggenie\core\entities\Status::getAll();
                     break;
             }
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Return the value of a custom field
  *
  * @param string $key
  *
  * @return mixed
  */
 public function getCustomField($key)
 {
     $var_name = "_customfield{$key}";
     if (property_exists($this, $var_name)) {
         $customtype = CustomDatatype::getByKey($key);
         if ($customtype->getType() == CustomDatatype::CALCULATED_FIELD) {
             $result = null;
             $options = $customtype->getOptions();
             if (!empty($options)) {
                 $formula = array_pop($options)->getValue();
                 preg_match_all('/{([[:alnum:]]+)}/', $formula, $matches);
                 $hasValues = false;
                 for ($i = 0; $i < count($matches[0]); $i++) {
                     $value = $this->getCustomField($matches[1][$i]);
                     if ($value instanceof \thebuggenie\core\entities\CustomDatatypeOption) {
                         $value = $value->getValue();
                     }
                     if (is_numeric($value)) {
                         $hasValues = true;
                     }
                     $value = floatval($value);
                     $formula = str_replace($matches[0][$i], $value, $formula);
                 }
                 // Check to verify formula only includes numbers and allowed operators
                 if ($hasValues && !preg_match('/[^0-9\\+-\\/*\\(\\)%]/', $formula)) {
                     try {
                         $m = new \Webit\Util\EvalMath\EvalMath();
                         $m->suppress_errors = true;
                         $result = $m->evaluate($formula);
                         if (!empty($m->last_error)) {
                             $result = $m->last_error;
                         } else {
                             $result = round($result, 2);
                         }
                     } catch (\Exception $e) {
                         $result = 'N/A';
                     }
                 }
             }
             return $result;
         } elseif ($this->{$var_name} && $customtype->hasCustomOptions() && !$this->{$var_name} instanceof \thebuggenie\core\entities\CustomDatatypeOption) {
             $this->{$var_name} = tables\CustomFieldOptions::getTable()->selectById($this->{$var_name});
         } elseif ($this->{$var_name} && $customtype->hasPredefinedOptions() && !$this->{$var_name} instanceof \thebuggenie\core\entities\common\Identifiable) {
             try {
                 switch ($customtype->getType()) {
                     case CustomDatatype::EDITIONS_CHOICE:
                         $this->{$var_name} = tables\Editions::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::COMPONENTS_CHOICE:
                         $this->{$var_name} = tables\Components::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::RELEASES_CHOICE:
                         $this->{$var_name} = tables\Builds::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::MILESTONE_CHOICE:
                         $this->{$var_name} = tables\Milestones::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::CLIENT_CHOICE:
                         $this->{$var_name} = tables\Clients::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::USER_CHOICE:
                         $this->{$var_name} = tables\Users::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::TEAM_CHOICE:
                         $this->{$var_name} = tables\Teams::getTable()->selectById($this->{$var_name});
                         break;
                     case CustomDatatype::STATUS_CHOICE:
                         $this->{$var_name} = Status::getB2DBTable()->selectById($this->{$var_name});
                         break;
                 }
             } catch (\Exception $e) {
             }
         }
         return $this->{$var_name};
     } else {
         return null;
     }
 }
Ejemplo n.º 10
0
 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())));
     }
 }
Ejemplo n.º 11
0
 /**
  * Partial backdrop loader
  *
  * @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*")
  * @AnonymousRoute
  *
  * @param framework\Request $request
  *
  * @return bool
  */
 public function runGetBackdropPartial(framework\Request $request)
 {
     if (!$request->isAjaxCall()) {
         return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly'));
     }
     try {
         $template_name = null;
         if ($request->hasParameter('issue_id')) {
             $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
             $options = array('issue' => $issue);
         } else {
             $options = array();
         }
         switch ($request['key']) {
             case 'usercard':
                 $template_name = 'main/usercard';
                 if ($user_id = $request['user_id']) {
                     $user = entities\User::getB2DBTable()->selectById($user_id);
                     $options['user'] = $user;
                 }
                 break;
             case 'login':
                 $template_name = 'main/loginpopup';
                 $options = $request->getParameters();
                 $options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login')));
                 $options['mandatory'] = false;
                 break;
             case 'uploader':
                 $template_name = 'main/uploader';
                 $options = $request->getParameters();
                 $options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard';
                 break;
             case 'attachlink':
                 $template_name = 'main/attachlink';
                 break;
             case 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 $options['first_notification_id'] = $request['first_notification_id'];
                 $options['last_notification_id'] = $request['last_notification_id'];
                 break;
             case 'workflow_transition':
                 $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 if ($request->hasParameter('issue_ids')) {
                     $options['issues'] = array();
                     foreach ($request['issue_ids'] as $issue_id) {
                         $options['issues'][$issue_id] = new entities\Issue($issue_id);
                     }
                 } else {
                     $options['issue'] = new entities\Issue($request['issue_id']);
                 }
                 $options['show'] = true;
                 $options['interactive'] = true;
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) {
                     $template_name = 'main/reportissuecontainer';
                     $options['selected_project'] = $this->selected_project;
                     $options['selected_issuetype'] = $this->selected_issuetype;
                     $options['locked_issuetype'] = $this->locked_issuetype;
                     $options['selected_milestone'] = $this->_getMilestoneFromRequest($request);
                     $options['parent_issue'] = $this->_getParentIssueFromRequest($request);
                     $options['board'] = $this->_getBoardFromRequest($request);
                     $options['selected_build'] = $this->_getBuildFromRequest($request);
                     $options['issuetypes'] = $this->issuetypes;
                     $options['errors'] = array();
                 } else {
                     throw new \Exception($this->getI18n()->__('You are not allowed to do this'));
                 }
                 break;
             case 'move_issue':
                 $template_name = 'main/moveissue';
                 $options['multi'] = (bool) $request->getParameter('multi', false);
                 break;
             case 'issue_permissions':
                 $template_name = 'main/issuepermissions';
                 break;
             case 'issue_subscribers':
                 $template_name = 'main/issuesubscribers';
                 break;
             case 'issue_spenttimes':
                 $template_name = 'main/issuespenttimes';
                 $options['initial_view'] = $request->getParameter('initial_view', 'list');
                 break;
             case 'issue_spenttime':
                 $template_name = 'main/issuespenttime';
                 $options['entry_id'] = $request->getParameter('entry_id');
                 break;
             case 'relate_issue':
                 $template_name = 'main/relateissue';
                 break;
             case 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = entities\Build::getB2DBTable()->selectById($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 $target_module = $request['target_module'] !== 'core' ? $request['target_module'] : null;
                 if ($details = framework\Context::getPermissionDetails($options['key'], null, $target_module)) {
                     $template_name = 'configuration/permissionspopup';
                     $options['mode'] = $request['mode'];
                     $options['module'] = $request['target_module'];
                     $options['target_id'] = $request['target_id'];
                     $options['item_name'] = $details['description'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'issuefield_permissions':
                 $options['item_key'] = $request['item_key'];
                 if ($details = framework\Context::getPermissionDetails($options['item_key'])) {
                     $template_name = 'configuration/issuefieldpermissions';
                     $options['item_name'] = $details['description'];
                     $options['item_id'] = $request['item_id'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = entities\Edition::getB2DBTable()->selectById($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = entities\Client::getB2DBTable()->selectById($request['client_id']);
                 $template_name = 'main/clientusers';
                 break;
             case 'dashboard_config':
                 $template_name = 'main/dashboardconfig';
                 $options['tid'] = $request['tid'];
                 $options['target_type'] = $request['target_type'];
                 $options['previous_route'] = $request['previous_route'];
                 $options['mandatory'] = true;
                 break;
             case 'archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['mandatory'] = true;
                 break;
             case 'team_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'team';
                 $options['id'] = $request['tid'];
                 $options['mandatory'] = true;
                 break;
             case 'client_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'client';
                 $options['id'] = $request['cid'];
                 $options['mandatory'] = true;
                 break;
             case 'project_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'project';
                 $options['id'] = $request['pid'];
                 $options['mandatory'] = true;
                 break;
             case 'bulk_workflow':
                 $template_name = 'search/bulkworkflow';
                 $options['issue_ids'] = $request['issue_ids'];
                 break;
             case 'confirm_username':
                 $template_name = 'main/confirmusername';
                 $options['username'] = $request['username'];
                 break;
             case 'add_dashboard_view':
                 $template_name = 'main/adddashboardview';
                 break;
             case 'userscopes':
                 if (!framework\Context::getScope()->isDefault()) {
                     throw new \Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new entities\User((int) $request['user_id']);
                 break;
             case 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
                 }
                 break;
             default:
                 $event = new \thebuggenie\core\framework\Event('core', 'get_backdrop_partial', $request['key']);
                 $event->triggerUntilProcessed();
                 $options = $event->getReturnList();
                 $template_name = $event->getReturnValue();
         }
         if ($template_name !== null) {
             return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options)));
         }
     } catch (\Exception $e) {
         $this->getResponse()->cleanBuffer();
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = framework\Context::isDebugMode() ? framework\Context::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
Ejemplo n.º 12
0
 /**
  * @Listener(module='core', identifier='get_backdrop_partial')
  * @param \thebuggenie\core\framework\Event $event
  */
 public function listen_get_backdrop_partial(framework\Event $event)
 {
     $request = framework\Context::getRequest();
     $options = array();
     switch ($event->getSubject()) {
         case 'agileboard':
             $template_name = 'agile/editagileboard';
             $board = $request['board_id'] ? entities\tables\AgileBoards::getTable()->selectById($request['board_id']) : new entities\AgileBoard();
             if (!$board->getID()) {
                 $board->setAutogeneratedSearch(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES);
                 $board->setTaskIssuetype(framework\Settings::get('issuetype_task'));
                 $board->setEpicIssuetype(framework\Settings::get('issuetype_epic'));
                 $board->setIsPrivate($request->getParameter('is_private', true));
                 $board->setProject($request['project_id']);
             }
             $options['board'] = $board;
             break;
         case 'milestone_finish':
             $template_name = 'agile/milestonefinish';
             $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
             $options['board'] = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
             $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
             if (!$options['milestone']->hasReachedDate()) {
                 $options['milestone']->setReachedDate(time());
             }
             break;
         case 'agilemilestone':
             $template_name = 'agile/milestone';
             $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
             $options['board'] = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
             if ($request->hasParameter('milestone_id')) {
                 $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
             }
             break;
         default:
             return;
     }
     foreach ($options as $key => $value) {
         $event->addToReturnList($value, $key);
     }
     $event->setReturnValue($template_name);
     $event->setProcessed();
 }
                 echo '</div>';
                 break;
             case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\tables\ListTypes::getTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
             case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT:
             default:
                 echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\CustomDatatypeOption::getB2DBTable()->selectById((int) $action->getTargetValue())->getName() : __('Value provided by user')) . '</span>'));
                 break;
         }
         ?>
                 <?php 
     }
     ?>
             <?php 
 } elseif ($action->getTargetValue()) {
Ejemplo n.º 14
0
 public function runFilterGetDynamicChoices(framework\Request $request)
 {
     $subproject_ids = explode(',', $request['subprojects']);
     $existing_ids = $request['existing_ids'];
     $results = array();
     $projects = $request['project_id'] != '' ? entities\Project::getAllByIDs(explode(',', $request['project_id'])) : entities\Project::getAll();
     $items = array('build' => array(), 'edition' => array(), 'component' => array(), 'milestone' => array());
     foreach ($projects as $project) {
         foreach ($project->getBuilds() as $build) {
             $items['build'][$build->getID()] = $build;
         }
         foreach ($project->getEditions() as $edition) {
             $items['edition'][$edition->getID()] = $edition;
         }
         foreach ($project->getComponents() as $component) {
             $items['component'][$component->getID()] = $component;
         }
         foreach ($project->getMilestones() as $milestone) {
             $items['milestone'][$milestone->getID()] = $milestone;
         }
     }
     $filters = array();
     $filters['build'] = entities\SearchFilter::createFilter('build');
     $filters['edition'] = entities\SearchFilter::createFilter('edition');
     $filters['component'] = entities\SearchFilter::createFilter('component');
     $filters['milestone'] = entities\SearchFilter::createFilter('milestone');
     if (isset($existing_ids['build'])) {
         foreach (tables\Builds::getTable()->getByIDs($existing_ids['build']) as $build) {
             $items['build'][$build->getID()] = $build;
         }
         $filters['build']->setValue(join(',', $existing_ids['build']));
     }
     if (isset($existing_ids['edition'])) {
         foreach (tables\Editions::getTable()->getByIDs($existing_ids['edition']) as $edition) {
             $items['edition'][$edition->getID()] = $edition;
         }
         $filters['edition']->setValue(join(',', $existing_ids['edition']));
     }
     if (isset($existing_ids['component'])) {
         foreach (tables\Components::getTable()->getByIDs($existing_ids['component']) as $component) {
             $items['component'][$component->getID()] = $component;
         }
         $filters['component']->setValue(join(',', $existing_ids['component']));
     }
     if (isset($existing_ids['milestone'])) {
         foreach (tables\Milestones::getTable()->getByIDs($existing_ids['milestone']) as $milestone) {
             $items['milestone'][$milestone->getID()] = $milestone;
         }
         $filters['milestone']->setValue(join(',', $existing_ids['milestone']));
     }
     foreach (array('build', 'edition', 'component', 'milestone') as $k) {
         $results[$k] = $this->getComponentHTML('search/interactivefilterdynamicchoicelist', array('filter' => $filters[$k], 'items' => $items[$k]));
     }
     return $this->renderJSON(compact('results'));
 }
Ejemplo n.º 15
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::MILESTONE_ID, Milestones::getTable(), Milestones::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, Projects::getTable(), Projects::ID);
 }