protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID); parent::_addForeignKeyColumn(self::FROM_STEP_ID, TBGWorkflowStepsTable::getTable(), TBGWorkflowStepsTable::ID); parent::_addForeignKeyColumn(self::TRANSITION_ID, TBGWorkflowTransitionsTable::getTable(), TBGWorkflowTransitionsTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable()); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable()); parent::_addForeignKeyColumn(self::WORKFLOW_SCHEME_ID, TBGWorkflowSchemesTable::getTable()); parent::_addForeignKeyColumn(self::ISSUETYPE_ID, TBGIssueTypesTable::getTable()); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID); parent::_addForeignKeyColumn(self::FROM_STEP_ID, TBGWorkflowStepsTable::getTable(), TBGWorkflowStepsTable::ID); parent::_addForeignKeyColumn(self::TRANSITION_ID, TBGWorkflowTransitionsTable::getTable(), TBGWorkflowTransitionsTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addVarchar(self::ACTION_TYPE, 100); parent::_addVarchar(self::TARGET_VALUE, 200); parent::_addForeignKeyColumn(self::TRANSITION_ID, TBGWorkflowTransitionsTable::getTable(), TBGWorkflowTransitionsTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID); parent::_addVarchar(self::NAME, 200); parent::_addText(self::DESCRIPTION, false); parent::_addForeignKeyColumn(self::OUTGOING_STEP_ID, TBGWorkflowStepsTable::getTable(), TBGWorkflowStepsTable::ID); parent::_addVarchar(self::TEMPLATE, 200); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addForeignKeyColumn(self::STATUS_ID, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_ID, TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID); parent::_addVarchar(self::NAME, 200); parent::_addText(self::DESCRIPTION, false); parent::_addBoolean(self::EDITABLE); parent::_addBoolean(self::CLOSED); }
public function runConfigureWorkflowTransition(TBGRequest $request) { $this->workflow = null; $this->transition = null; try { $this->workflow = TBGWorkflowsTable::getTable()->selectById((int) $request['workflow_id']); if ($request->hasParameter('transition_id')) { $mode = $request['mode']; $this->transition = TBGWorkflowTransitionsTable::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 = TBGWorkflowStepsTable::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']); return $this->renderJSON('ok'); } elseif ($mode == 'delete_action') { $this->action = TBGWorkflowTransitionActionsTable::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 TBGWorkflowTransitionAction(); $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 = TBGWorkflowTransitionActionsTable::getTable()->selectById((int) $request['action_id']); $this->action->setTargetValue($request['target_value']); $this->action->save(); $text = $request['target_value']; switch ($this->action->getActionType()) { case TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE: if ($this->action->hasTargetValue()) { $target_details = explode('_', $this->action->getTargetValue()); $text = $target_details[0] == 'user' ? TBGUser::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : TBGTeam::getB2DBTable()->selectById((int) $target_details[1])->getName(); } else { $text = $this->getI18n()->__('User specified during transition'); } break; case TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION: $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Resolution specified by user'); break; case TBGWorkflowTransitionAction::ACTION_SET_REPRODUCABILITY: $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Reproducability specified by user'); break; case TBGWorkflowTransitionAction::ACTION_SET_STATUS: $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Status specified by user'); break; case TBGWorkflowTransitionAction::ACTION_SET_PRIORITY: $text = $this->action->getTargetValue() ? TBGListTypesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Priority specified by user'); break; case TBGWorkflowTransitionAction::ACTION_SET_MILESTONE: $text = $this->action->getTargetValue() ? TBGMilestonesTable::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Milestone specified by user'); break; } return $this->renderJSON(array('content' => $text)); } elseif ($mode == 'delete_validation_rule') { $this->rule = TBGWorkflowTransitionValidationRulesTable::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') { $rule = new TBGWorkflowTransitionValidationRule(); 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->getTemplateHTML('configuration/workflowtransitionvalidationrule', array('rule' => $rule)))); } elseif ($mode == 'update_validation_rule') { $this->rule = TBGWorkflowTransitionValidationRulesTable::getTable()->selectById((int) $request['rule_id']); $text = null; switch ($this->rule->getRule()) { case TBGWorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES: $this->rule->setRuleValue($request['rule_value']); $text = $this->rule->getRuleValue() ? $this->rule->getRuleValue() : $this->getI18n()->__('Unlimited'); break; case TBGWorkflowTransitionValidationRule::RULE_PRIORITY_VALID: case TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID: case TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID: case TBGWorkflowTransitionValidationRule::RULE_STATUS_VALID: case TBGWorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID: $this->rule->setRuleValue(join(',', $request['rule_value'])); $text = $this->rule->getRuleValue() ? $this->rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value'); break; } $this->rule->save(); return $this->renderJSON(array('content' => $text)); } } } elseif ($request->isPost() && $request->hasParameter('step_id')) { $step = TBGWorkflowStepsTable::getTable()->selectById((int) $request['step_id']); /*if ($step->isCore() || $workflow->isCore()) { throw new InvalidArgumentException("The default workflow cannot be edited"); }*/ if ($request['add_transition_type'] == 'existing' && $request->hasParameter('existing_transition_id')) { $transition = TBGWorkflowTransitionsTable::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 = TBGWorkflowStepsTable::getTable()->selectById((int) $request['outgoing_step_id'])) && $step instanceof TBGWorkflowStep) { if (array_key_exists($request['template'], TBGWorkflowTransition::getTemplates())) { $transition = new TBGWorkflowTransition(); $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) { //throw $e; $this->error = $e->getMessage(); } catch (Exception $e) { throw $e; $this->error = $this->getI18n()->__('This workflow / transition does not exist'); } if (isset($redirect_transition) && $redirect_transition) { $this->forward(TBGContext::getRouting()->generate('configure_workflow_transition', array('workflow_id' => $this->workflow->getID(), 'transition_id' => $transition->getID()))); } elseif (isset($redirect_transition)) { $this->forward(TBGContext::getRouting()->generate('configure_workflow_steps', array('workflow_id' => $this->workflow->getID()))); } }
public static function getWorkflowsCount() { if (self::$_num_workflows === null) { if (self::$_workflows !== null) { self::$_num_workflows = count(self::$_workflows); } else { self::$_num_workflows = TBGWorkflowsTable::getTable()->countWorkflows(); } } return self::$_num_workflows; }
protected function _upgradeFrom3dot2(TBGRequest $request) { set_time_limit(0); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2'); foreach (array('publish', 'mailing') as $module) { TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes' . DS . 'B2DB'); } TBGMilestonesTable::getTable()->upgrade(TBGMilestonesTable3dot2::getTable()); TBGArticlesTable::getTable()->upgrade(TBGArticlesTable3dot2::getTable()); TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot2::getTable()); TBGLogTable::getTable()->upgrade(TBGLogTable3dot2::getTable()); TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot2::getTable()); TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot2::getTable()); TBGWorkflowsTable::getTable()->upgrade(TBGWorkflowsTable3dot2::getTable()); TBGIncomingEmailAccountTable::getTable()->upgrade(TBGIncomingEmailAccountTable3dot2::getTable()); TBGIssueSpentTimesTable::getTable()->upgrade(TBGIssueSpentTimesTable3dot2::getTable()); TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot2::getTable()); TBGSavedSearchesTable::getTable()->upgrade(TBGSavedSearchesTable3dot2::getTable()); TBGSettingsTable::getTable()->upgrade(TBGSettingsTable3dot2::getTable()); TBGNotificationsTable::getTable()->upgrade(TBGNotificationsTable3dot2::getTable()); TBGPermissionsTable::getTable()->upgrade(TBGPermissionsTable3dot2::getTable()); TBGUserArticlesTable::getTable()->create(); TBGApplicationPasswordsTable::getTable()->create(); TBGUserNotificationSettingsTable::getTable()->create(); $transaction = \b2db\Core::startTransaction(); // Upgrade user passwords switch ($request['upgrade_passwords']) { case 'manual': $password = $request['manul_password']; foreach (TBGUsersTable::getTable()->selectAll() as $user) { $user->setPassword($password); $user->save(); } break; case 'auto': $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email'; foreach (TBGUsersTable::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 = TBGUsersTable::getTable()->selectById(1); $adminuser->setPassword($request['admin_password']); $adminuser->save(); // Add new settings TBGSettings::saveSetting(TBGSettings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1); foreach ($request->getParameter('status') as $scope_id => $status_id) { $scope = TBGScopesTable::getTable()->selectById((int) $scope_id); if ($scope instanceof TBGScope) { foreach (TBGWorkflowsTable::getTable()->getAll((int) $scope_id) as $workflow) { $transition = new TBGWorkflowTransition(); $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(); } TBGActivityType::loadFixtures($scope); } } $transaction->commitAndEnd(); TBGContext::finishUpgrading(); TBGContext::getModule('mailing')->upgradeFrom3dot2(); $this->upgrade_complete = true; }
public function getAllByWorkflowSchemeID($scheme_id) { $crit = $this->getCriteria(); $crit->addJoin(TBGWorkflowsTable::getTable(), TBGWorkflowsTable::ID, self::WORKFLOW_ID, array(), Criteria::DB_INNER_JOIN); $crit->addJoin(TBGWorkflowIssuetypeTable::getTable(), TBGWorkflowIssuetypeTable::WORKFLOW_ID, self::WORKFLOW_ID, array(), Criteria::DB_INNER_JOIN); $crit->addWhere(TBGWorkflowIssuetypeTable::WORKFLOW_SCHEME_ID, $scheme_id); $res = $this->doSelect($crit); $steps = array(); if ($res) { while ($row = $res->getNextRow()) { $step_id = $row->get(self::ID); $steps[$step_id] = $step_id; } } return $steps; }