public function runConfigureWorkflowSteps(TBGRequest $request) { $this->workflow = null; $this->mode = $request->getParameter('mode', 'list'); try { $this->workflow = TBGContext::factory()->TBGWorkflow($request->getParameter('workflow_id')); if ($this->mode == 'copy_workflow') { if ($new_name = $request->getParameter('new_name')) { $new_workflow = $this->workflow->copy($new_name); return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflow', array('workflow' => $new_workflow)), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } else { $this->error = TBGContext::getI18n()->__('Please enter a valid name'); } } elseif ($this->mode == 'delete_workflow') { $this->workflow->delete(); return $this->renderJSON(array('success' => true, 'message' => TBGContext::getI18n()->__('The workflow was deleted'), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } } catch (Exception $e) { if ($request->getRequestedFormat() == 'json') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('success' => false, 'message' => TBGContext::getI18n()->__('An error occured'), 'error' => $e->getMessage())); } else { $this->error = TBGContext::getI18n()->__('This workflow does not exist'); } } }
<select name="workflow_id[<?php echo $issuetype->getID(); ?> ]"> <option value=""<?php if (!$workflow_scheme->hasWorkflowAssociatedWithIssuetype($issuetype)) { ?> selected<?php } ?> ><?php echo __('No workflow selected - will use default workflow'); ?> </option> <?php foreach (TBGWorkflow::getAll() as $workflow) { ?> <option value="<?php echo $workflow->getID(); ?> "<?php if ($workflow_scheme->hasWorkflowAssociatedWithIssuetype($issuetype) && $workflow_scheme->getWorkflowForIssuetype($issuetype)->getID() == $workflow->getID()) { ?> selected<?php } ?> ><?php echo $workflow->getName(); ?> </option> <?php
public function hasCustomWorkflowsAvailable() { if ($this->isCustomWorkflowsEnabled()) { return $this->getMaxWorkflowsLimit() ? TBGWorkflow::getCustomWorkflowsCount() < $this->getMaxWorkflowsLimit() : true; } else { return false; } }
public function runConfigureWorkflowSteps(TBGRequest $request) { $this->workflow = null; $this->mode = $request->getParameter('mode', 'list'); try { $this->workflow = TBGContext::factory()->TBGWorkflow($request['workflow_id']); // $transition = new TBGWorkflowTransition(); // $step = TBGWorkflowStepsTable::getTable()->selectById(9); // $transition->setOutgoingStep($step); // $transition->setName('Initial transition'); // $transition->setWorkflow($this->workflow); // $transition->setScope(TBGContext::getScope()); // $transition->setDescription('This is the initial transition for issues using this workflow'); // $transition->save(); // $this->workflow->setInitialTransition($transition); // $this->workflow->save(); if ($this->mode == 'copy_workflow') { if ($new_name = $request['new_name']) { $new_workflow = $this->workflow->copy($new_name); return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflow', array('workflow' => $new_workflow)), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } else { $this->error = $this->getI18n()->__('Please enter a valid name'); } } elseif ($this->mode == 'delete_workflow') { $this->workflow->delete(); return $this->renderJSON(array('success' => true, 'message' => $this->getI18n()->__('The workflow was deleted'), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } } catch (Exception $e) { if ($request->getRequestedFormat() == 'json') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('success' => false, 'message' => $this->getI18n()->__('An error occured'), 'error' => $e->getMessage())); } else { $this->error = $this->getI18n()->__('This workflow does not exist'); } } }
public function copy($new_name) { $new_workflow = new TBGWorkflow(); $new_workflow->setName($new_name); $new_workflow->save(); $step_mapper = array(); $transition_mapper = array(); foreach ($this->getSteps() as $key => $step) { $this->_steps[$key] = $step->copy($new_workflow); $step_mapper[$key] = $this->_steps[$key]->getID(); } foreach ($this->getTransitions() as $key => $transition) { $old_id = $transition->getID(); $this->_transitions[$key] = $transition->copy($new_workflow); $transition_mapper[$old_id] = $this->_transitions[$key]->getID(); } TBGWorkflowStepTransitionsTable::getTable()->copyByWorkflowIDs($this->getID(), $new_workflow->getID()); TBGWorkflowStepTransitionsTable::getTable()->reMapStepIDsByWorkflowID($new_workflow->getID(), $step_mapper); TBGWorkflowTransitionsTable::getTable()->reMapByWorkflowID($new_workflow->getID(), $step_mapper); TBGWorkflowStepTransitionsTable::getTable()->reMapTransitionIDsByWorkflowID($new_workflow->getID(), $transition_mapper); $new_initial_transition = $this->getInitialTransition()->copy($new_workflow); $new_initial_transition->setOutgoingStepID($step_mapper[$this->getInitialTransition()->getOutgoingStep()->getID()]); $new_initial_transition->save(); $new_workflow->setInitialTransition($new_initial_transition); $new_workflow->save(); return $new_workflow; }
?> </div> <div class="content"> <?php echo __('Workflow lets you define the lifecycle of an issue. You can define steps, transitions and more, that makes an issue move through its defined lifecycle.'); ?> <?php echo __('You can read more about how the workflow in The Bug Genie works and is set up in %link_to_wiki_workflow%.', array('%link_to_wiki_workflow%' => link_tag(make_url('publish_article', array('article_name' => 'TheBugGenie:Workflow')), 'TheBugGenie:Workflow'))); ?> </div> <?php if (TBGContext::getScope()->getMaxWorkflowsLimit()) { ?> <div class="faded_out dark" style="margin: 12px 0;"> <?php echo __('This instance is currently using %num% of max %max% custom workflows', array('%num%' => '<b id="current_workflow_num_count">' . TBGWorkflow::getCustomWorkflowsCount() . '</b>', '%max%' => '<b>' . TBGContext::getScope()->getMaxWorkflowsLimit() . '</b>')); ?> </div> <?php } ?> <br style="clear: both;"> <div class="tab_menu" style="margin-top: 20px;"> <ul id="workflow_menu"> <li<?php if ($selected_tab == 'workflows') { ?> class="selected"<?php } ?> ><?php
protected function _upgradeFrom3dot1() { // Add classpath for existing old tables used for upgrade TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.1'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes' . DS . 'B2DB'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes'); // Create new tables TBGDashboardViewsTable::getTable()->create(); TBGOpenIdAccountsTable::getTable()->create(); TBGProjectAssignedUsersTable::getTable()->create(); TBGProjectAssignedTeamsTable::getTable()->create(); TBGEditionAssignedUsersTable::getTable()->create(); TBGEditionAssignedTeamsTable::getTable()->create(); TBGComponentAssignedUsersTable::getTable()->create(); TBGComponentAssignedTeamsTable::getTable()->create(); TBGRolePermissionsTable::getTable()->create(); TBGUserScopesTable::getTable()->create(); // Upgrade existing tables TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot1::getTable()); TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot1::getTable()); TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot1::getTable()); TBGIssueTypesTable::getTable()->upgrade(TBGIssueTypesTable3dot1::getTable()); TBGListTypesTable::getTable()->upgrade(TBGListTypesTable3dot1::getTable()); TBGEditionsTable::getTable()->upgrade(TBGEditionsTable3dot1::getTable()); TBGBuildsTable::getTable()->upgrade(TBGBuildsTable3dot1::getTable()); TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot1::getTable()); TBGComponentsTable::getTable()->upgrade(TBGComponentsTable3dot1::getTable()); TBGCustomFieldsTable::getTable()->upgrade(TBGCustomFieldsTable3dot1::getTable()); TBGCustomFieldOptionsTable::getTable()->upgrade(TBGCustomFieldOptionsTable3dot1::getTable()); TBGIssueCustomFieldsTable::getTable()->upgrade(TBGIssueCustomFieldsTable3dot1::getTable()); // Create new module tables TBGIncomingEmailAccountTable::getTable()->create(); // Add new indexes TBGArticlesTable::getTable()->createIndexes(); TBGCommentsTable::getTable()->createIndexes(); TBGIssueAffectsBuildTable::getTable()->createIndexes(); TBGIssueAffectsComponentTable::getTable()->createIndexes(); TBGIssueAffectsEditionTable::getTable()->createIndexes(); TBGIssueFieldsTable::getTable()->createIndexes(); TBGIssueFilesTable::getTable()->createIndexes(); TBGIssuesTable::getTable()->createIndexes(); TBGIssuetypeSchemesTable::getTable()->createIndexes(); TBGPermissionsTable::getTable()->createIndexes(); TBGProjectsTable::getTable()->createIndexes(); TBGSettingsTable::getTable()->createIndexes(); TBGTeamMembersTable::getTable()->createIndexes(); TBGUserIssuesTable::getTable()->createIndexes(); TBGUsersTable::getTable()->createIndexes(); TBGUserScopesTable::getTable()->createIndexes(); if (TBGContext::getRequest()->getParameter('fix_my_timestamps', false)) { $this->_fixTimestamps(); } foreach (TBGScope::getAll() as $scope) { TBGRole::loadFixtures($scope); foreach (TBGDatatype::getTypes() as $type => $class) { TBGContext::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID()); } TBGContext::setPermission('page_confirm_scope_access', 0, 'core', 0, 0, 0, true, $scope->getID()); if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOW, 'core', $scope->getID())) { $workflow_id = TBGWorkflowsTable::getTable()->getFirstIdByScope($scope->getID()); if ($workflow_id) { TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOW, $workflow_id, 'core', $scope->getID()); } else { TBGWorkflow::loadFixtures($scope); } } if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, 'core', $scope->getID())) { $workflow_scheme_id = TBGWorkflowSchemesTable::getTable()->getFirstIdByScope($scope->getID()); if ($workflow_scheme_id) { TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, $workflow_scheme_id, 'core', $scope->getID()); } else { TBGWorkflowScheme::loadFixtures($scope); } } if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, 'core', $scope->getID())) { $issuetype_scheme_id = TBGIssuetypeSchemesTable::getTable()->getFirstIdByScope($scope->getID()); if ($issuetype_scheme_id) { TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, $issuetype_scheme_id, 'core', $scope->getID()); } else { TBGIssuetypeScheme::loadFixtures($scope); } } TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_ID, 0, 'core', $scope->getID()); TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_TYPE, 0, 'core', $scope->getID()); TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_ID, 0, 'core', $scope->getID()); TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_TYPE, 0, 'core', $scope->getID()); } $linkstable = TBGLinksTable::getTable(); $crit = $linkstable->getCriteria(); $crit->addUpdate(TBGLinksTable::URL, 'http://issues.thebuggenie.com'); $crit->addWhere(TBGLinksTable::URL, 'http://thebuggenie.com/thebuggenie'); $crit->addOr(TBGLinksTable::URL, 'http://www.thebuggenie.com/thebuggenie'); $linkstable->doUpdate($crit); $listtypestable = TBGListTypesTable::getTable(); $crit = $listtypestable->getCriteria(); $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'role'); $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'projectrole'); $listtypestable->doUpdate($crit); $crit = $listtypestable->getCriteria(); $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'priority'); $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'b2_prioritytypes'); $listtypestable->doUpdate($crit); TBGWorkflowTransitionsTable::getTable()->upgradeFrom3dot1(); TBGSettings::saveSetting(TBGSettings::SETTING_ICONSET, TBGSettings::get(TBGSettings::SETTING_THEME_NAME)); TBGContext::setPermission('readarticle', 0, 'publish', 0, 0, 0, true); foreach (TBGProject::getAll() as $project) { TBGDashboardViewsTable::getTable()->setDefaultViews($project->getID(), TBGDashboardViewsTable::TYPE_PROJECT); if (!$project->getKey()) { $project->setName($project->getName()); } } $this->upgrade_complete = true; }
public function associateIssuetypeWithWorkflow(TBGIssuetype $issuetype, TBGWorkflow $workflow) { TBGWorkflowIssuetypeTable::getTable()->setWorkflowIDforIssuetypeIDwithSchemeID($workflow->getID(), $issuetype->getID(), $this->getID()); }
/** * Get all steps in this workflow * * @return array An array of TBGWorkflowStep objects */ public function getWorkflowForIssuetype(TBGIssuetype $issuetype) { $this->_populateAssociatedWorkflows(); if (array_key_exists($issuetype->getID(), $this->_issuetype_workflows)) { return $this->_issuetype_workflows[$issuetype->getID()]; } else { return TBGWorkflow::getCoreWorkflow(); } }