protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::COMPONENT_ID, TBGComponentsTable::getTable());
     parent::_addForeignKeyColumn(self::USER_ID, TBGUsersTable::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, TBGListTypesTable::getTable());
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable());
 }
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, TBGListTypesTable::getTable());
     parent::_addForeignKeyColumn(self::TEAM_ID, TBGTeamsTable::getTable());
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable());
 }
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addBoolean(self::CONFIRMED);
     parent::_addForeignKeyColumn(self::BUILD, Core::getTable('TBGBuildsTable'), TBGBuildsTable::ID);
     parent::_addForeignKeyColumn(self::ISSUE, TBGIssuesTable::getTable(), TBGIssuesTable::ID);
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
     parent::_addForeignKeyColumn(self::STATUS, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
 }
 public function __construct()
 {
     parent::__construct(self::B2DBNAME, self::ID);
     parent::_addBoolean(self::CONFIRMED);
     parent::_addForeignKeyColumn(self::COMPONENT, B2DB::getTable('TBGComponentsTable'), TBGComponentsTable::ID);
     parent::_addForeignKeyColumn(self::ISSUE, TBGIssuesTable::getTable(), TBGIssuesTable::ID);
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
     parent::_addForeignKeyColumn(self::STATUS, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
 }
 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);
 }
 /**
  * Returns all severities available
  * 
  * @return array 
  */
 public static function getAll()
 {
     if (self::$_items === NULL) {
         self::$_items = array();
         if ($items = TBGListTypesTable::getTable()->getAllByItemType(self::SEVERITY)) {
             foreach ($items as $row_id => $row) {
                 self::$_items[$row_id] = TBGContext::factory()->TBGSeverity($row_id, $row);
             }
         }
     }
     return self::$_items;
 }
Exemplo n.º 7
0
 /**
  * Returns all statuses available
  * 
  * @return array 
  */
 public static function getAll()
 {
     if (self::$_items === null) {
         self::$_items = array();
         if ($items = TBGListTypesTable::getTable()->getAllByItemType(self::STATUS)) {
             foreach ($items as $row_id => $row) {
                 self::$_items[$row_id] = TBGContext::factory()->TBGStatus($row_id, $row);
             }
         }
     }
     return self::$_items;
 }
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addVarchar(self::PERMISSION_TYPE, 100);
     parent::_addVarchar(self::TARGET_ID, 200, 0);
     parent::_addBoolean(self::ALLOWED);
     parent::_addVarchar(self::MODULE, 50);
     parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable());
     parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable());
     parent::_addForeignKeyColumn(self::TID, TBGTeamsTable::getTable());
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, TBGListTypesTable::getTable());
 }
 protected function _populateItemCache()
 {
     if (self::$_item_cache === null) {
         self::$_item_cache = array();
         $crit = $this->getCriteria();
         $crit->addWhere(self::SCOPE, TBGContext::getScope()->getID());
         $crit->addOrderBy(self::ORDER, Criteria::SORT_ASC);
         $items = $this->select($crit);
         foreach ($items as $item) {
             self::$_item_cache[$item->getItemtype()][$item->getID()] = $item;
         }
     }
 }
 protected function _populateItemCache()
 {
     if (self::$_item_cache === null) {
         self::$_item_cache = array();
         $crit = $this->getCriteria();
         $crit->addWhere(self::SCOPE, TBGContext::getScope()->getID());
         $crit->addOrderBy(self::ORDER, B2DBCriteria::SORT_ASC);
         if ($res = $this->doSelect($crit, false)) {
             while ($row = $res->getNextRow()) {
                 self::$_item_cache[$row->get(self::ITEMTYPE)][$row->get(self::ID)] = $row;
             }
         }
     }
 }
Exemplo n.º 11
0
 public function findIssues($filters = array(), $results_per_page = 30, $offset = 0, $groupby = null, $grouporder = null, $sortfields = array(self::LAST_UPDATED => 'asc'))
 {
     $crit = $this->getCriteria();
     $crit->addWhere(self::DELETED, false);
     $crit->addWhere(self::SCOPE, TBGContext::getScope()->getID());
     if (count($filters) > 0) {
         $crit->addJoin(TBGIssueCustomFieldsTable::getTable(), TBGIssueCustomFieldsTable::ISSUE_ID, TBGIssuesTable::ID);
         $crit->addJoin(TBGIssueAffectsComponentTable::getTable(), TBGIssueAffectsComponentTable::ISSUE, self::ID);
         $crit->addJoin(TBGIssueAffectsEditionTable::getTable(), TBGIssueAffectsEditionTable::ISSUE, self::ID);
         $crit->addJoin(TBGIssueAffectsBuildTable::getTable(), TBGIssueAffectsBuildTable::ISSUE, self::ID);
         $filter_keys = array_keys($filters);
         foreach ($filters as $filter) {
             self::parseFilter($crit, $filter, $filter_keys);
         }
     }
     $crit->addSelectionColumn(self::ID);
     $crit->setDistinct();
     if ($offset != 0) {
         $crit->setOffset($offset);
     }
     $crit2 = clone $crit;
     $count = $this->doCount($crit2);
     if ($count > 0) {
         $crit3 = $this->getCriteria();
         if ($results_per_page != 0) {
             $crit->setLimit($results_per_page);
         }
         if ($offset != 0) {
             $crit->setOffset($offset);
         }
         if ($groupby !== null) {
             $grouporder = $grouporder !== null ? $grouporder == 'asc' ? Criteria::SORT_ASC : Criteria::SORT_DESC : Criteria::SORT_ASC;
             switch ($groupby) {
                 case 'category':
                     $crit->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::CATEGORY);
                     $crit->addSelectionColumn(TBGListTypesTable::NAME);
                     $crit->addOrderBy(TBGListTypesTable::NAME, $grouporder);
                     $crit3->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::CATEGORY);
                     $crit3->addOrderBy(TBGListTypesTable::NAME, $grouporder);
                     break;
                 case 'status':
                     $crit->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::STATUS);
                     $crit->addSelectionColumn(self::STATUS);
                     $crit->addOrderBy(TBGListTypesTable::ORDER, Criteria::SORT_DESC);
                     $crit3->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::STATUS);
                     $crit3->addOrderBy(TBGListTypesTable::ORDER, Criteria::SORT_DESC);
                     break;
                 case 'milestone':
                     $crit->addSelectionColumn(self::MILESTONE);
                     $crit->addSelectionColumn(self::PERCENT_COMPLETE);
                     $crit->addOrderBy(self::MILESTONE, $grouporder);
                     $crit->addOrderBy(self::PERCENT_COMPLETE, 'desc');
                     $crit3->addOrderBy(self::MILESTONE, $grouporder);
                     $crit3->addOrderBy(self::PERCENT_COMPLETE, 'desc');
                     break;
                 case 'assignee':
                     $crit->addSelectionColumn(self::ASSIGNEE_TEAM);
                     $crit->addSelectionColumn(self::ASSIGNEE_USER);
                     $crit->addOrderBy(self::ASSIGNEE_TEAM);
                     $crit->addOrderBy(self::ASSIGNEE_USER, $grouporder);
                     $crit3->addOrderBy(self::ASSIGNEE_TEAM);
                     $crit3->addOrderBy(self::ASSIGNEE_USER, $grouporder);
                     break;
                 case 'state':
                     $crit->addSelectionColumn(self::STATE);
                     $crit->addOrderBy(self::STATE, $grouporder);
                     $crit3->addOrderBy(self::STATE, $grouporder);
                     break;
                 case 'severity':
                     $crit->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::SEVERITY);
                     $crit->addSelectionColumn(self::SEVERITY);
                     $crit->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     $crit3->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::SEVERITY);
                     $crit3->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     break;
                 case 'user_pain':
                     $crit->addSelectionColumn(self::USER_PAIN);
                     $crit->addOrderBy(self::USER_PAIN, $grouporder);
                     $crit3->addOrderBy(self::USER_PAIN, $grouporder);
                     break;
                 case 'votes':
                     $crit->addSelectionColumn(self::VOTES_TOTAL);
                     $crit->addOrderBy(self::VOTES_TOTAL, $grouporder);
                     $crit3->addOrderBy(self::VOTES_TOTAL, $grouporder);
                     break;
                 case 'resolution':
                     $crit->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::RESOLUTION);
                     $crit->addSelectionColumn(self::RESOLUTION);
                     $crit->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     $crit3->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::RESOLUTION);
                     $crit3->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     break;
                 case 'priority':
                     $crit->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::PRIORITY);
                     $crit->addSelectionColumn(self::PRIORITY);
                     $crit->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     $crit3->addJoin(TBGListTypesTable::getTable(), TBGListTypesTable::ID, self::PRIORITY);
                     $crit3->addOrderBy(TBGListTypesTable::ORDER, $grouporder);
                     break;
                 case 'issuetype':
                     $crit->addJoin(TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID, self::ISSUE_TYPE);
                     $crit->addSelectionColumn(TBGIssueTypesTable::NAME);
                     $crit->addOrderBy(TBGIssueTypesTable::NAME, $grouporder);
                     $crit3->addJoin(TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID, self::ISSUE_TYPE);
                     $crit3->addOrderBy(TBGIssueTypesTable::NAME, $grouporder);
                     break;
                 case 'edition':
                     $crit->addJoin(TBGIssueAffectsEditionTable::getTable(), TBGIssueAffectsEditionTable::ISSUE, self::ID);
                     $crit->addJoin(TBGEditionsTable::getTable(), TBGEditionsTable::ID, TBGIssueAffectsEditionTable::EDITION, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsEditionTable::getTable());
                     $crit->addSelectionColumn(TBGEditionsTable::NAME);
                     $crit->addOrderBy(TBGEditionsTable::NAME, $grouporder);
                     $crit3->addJoin(TBGIssueAffectsEditionTable::getTable(), TBGIssueAffectsEditionTable::ISSUE, self::ID);
                     $crit3->addJoin(TBGEditionsTable::getTable(), TBGEditionsTable::ID, TBGIssueAffectsEditionTable::EDITION, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsEditionTable::getTable());
                     $crit3->addOrderBy(TBGEditionsTable::NAME, $grouporder);
                     break;
                 case 'build':
                     $crit->addJoin(TBGIssueAffectsBuildTable::getTable(), TBGIssueAffectsBuildTable::ISSUE, self::ID);
                     $crit->addJoin(TBGBuildsTable::getTable(), TBGBuildsTable::ID, TBGIssueAffectsBuildTable::BUILD, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsBuildTable::getTable());
                     $crit->addSelectionColumn(TBGBuildsTable::NAME);
                     $crit->addOrderBy(TBGBuildsTable::NAME, $grouporder);
                     $crit3->addJoin(TBGIssueAffectsBuildTable::getTable(), TBGIssueAffectsBuildTable::ISSUE, self::ID);
                     $crit3->addJoin(TBGBuildsTable::getTable(), TBGBuildsTable::ID, TBGIssueAffectsBuildTable::BUILD, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsBuildTable::getTable());
                     $crit3->addOrderBy(TBGBuildsTable::NAME, $grouporder);
                     break;
                 case 'component':
                     $crit->addJoin(TBGIssueAffectsComponentTable::getTable(), TBGIssueAffectsComponentTable::ISSUE, self::ID);
                     $crit->addJoin(TBGComponentsTable::getTable(), TBGComponentsTable::ID, TBGIssueAffectsComponentTable::COMPONENT, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsComponentTable::getTable());
                     $crit->addSelectionColumn(TBGComponentsTable::NAME);
                     $crit->addOrderBy(TBGComponentsTable::NAME, $grouporder);
                     $crit3->addJoin(TBGIssueAffectsComponentTable::getTable(), TBGIssueAffectsComponentTable::ISSUE, self::ID);
                     $crit3->addJoin(TBGComponentsTable::getTable(), TBGComponentsTable::ID, TBGIssueAffectsComponentTable::COMPONENT, array(), Criteria::DB_LEFT_JOIN, TBGIssueAffectsComponentTable::getTable());
                     $crit3->addOrderBy(TBGComponentsTable::NAME, $grouporder);
                     break;
             }
         }
         foreach ($sortfields as $field => $sortorder) {
             $crit->addSelectionColumn($field);
             $crit->addOrderBy($field, $sortorder);
         }
         $res = $this->doSelect($crit, 'none');
         $ids = array();
         if ($res) {
             while ($row = $res->getNextRow()) {
                 $ids[] = $row->get(self::ID);
             }
             $ids = array_reverse($ids);
             $crit3->addWhere(self::ID, $ids, Criteria::DB_IN);
             foreach ($sortfields as $field => $sortorder) {
                 $crit3->addOrderBy($field, $sortorder);
             }
             $res = $this->doSelect($crit3);
             $rows = $res->getAllRows();
         } else {
             $rows = array();
         }
         unset($res);
         return array($rows, $count, $ids);
     } else {
         return array(null, 0, array());
     }
 }
Exemplo n.º 12
0
 protected function _saveCustomFieldValues()
 {
     foreach (TBGCustomDatatype::getAll() as $key => $customdatatype) {
         switch ($customdatatype->getType()) {
             case TBGCustomDatatype::INPUT_TEXT:
             case TBGCustomDatatype::INPUT_TEXTAREA_SMALL:
             case TBGCustomDatatype::INPUT_TEXTAREA_MAIN:
             case TBGCustomDatatype::DATE_PICKER:
                 $option_id = $this->getCustomField($key);
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldValue($option_id, $customdatatype->getID(), $this->getID());
                 break;
             case TBGCustomDatatype::EDITIONS_CHOICE:
             case TBGCustomDatatype::COMPONENTS_CHOICE:
             case TBGCustomDatatype::RELEASES_CHOICE:
             case TBGCustomDatatype::MILESTONE_CHOICE:
             case TBGCustomDatatype::STATUS_CHOICE:
             case TBGCustomDatatype::USER_CHOICE:
             case TBGCustomDatatype::TEAM_CHOICE:
                 $option_object = null;
                 try {
                     switch ($customdatatype->getType()) {
                         case TBGCustomDatatype::EDITIONS_CHOICE:
                             $option_object = TBGEditionsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::COMPONENTS_CHOICE:
                             $option_object = TBGComponentsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::RELEASES_CHOICE:
                             $option_object = TBGBuildsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::MILESTONE_CHOICE:
                             $option_object = TBGMilestonesTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::STATUS_CHOICE:
                             $option_object = TBGListTypesTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::USER_CHOICE:
                             $option_object = TBGUsersTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::TEAM_CHOICE:
                             $option_object = TBGTeamsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                     }
                 } catch (Exception $e) {
                 }
                 $option_id = is_object($option_object) ? $option_object->getID() : null;
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldOption($option_id, $customdatatype->getID(), $this->getID());
                 break;
             default:
                 $option_id = $this->getCustomField($key) instanceof TBGCustomDatatypeOption ? $this->getCustomField($key)->getID() : null;
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldOption($option_id, $customdatatype->getID(), $this->getID());
                 break;
         }
     }
 }
Exemplo n.º 13
0
 /**
  * Returns all severities available
  *
  * @return array
  */
 public static function getAll()
 {
     return TBGListTypesTable::getTable()->getAllByItemType(static::ITEMTYPE);
 }
Exemplo n.º 14
0
 /**
  * Returns all project roles available for a specific project
  *
  * @return array
  */
 public static function getByProjectID($project_id)
 {
     return TBGListTypesTable::getTable()->getAllByItemTypeAndItemdata(self::ROLE, $project_id);
 }
Exemplo n.º 15
0
 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())));
     }
 }
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addInteger(self::ISSUE_NO, 10);
     parent::_addVarchar(self::TITLE, 200);
     parent::_addInteger(self::POSTED, 10);
     parent::_addInteger(self::LAST_UPDATED, 10);
     parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID);
     parent::_addText(self::DESCRIPTION, false);
     parent::_addBoolean(self::STATE);
     parent::_addForeignKeyColumn(self::POSTED_BY, TBGUsersTable::getTable(), TBGUsersTable::ID);
     parent::_addInteger(self::OWNER, 10);
     parent::_addInteger(self::OWNER_TYPE, 2);
     parent::_addFloat(self::USER_PAIN, 3);
     parent::_addInteger(self::PAIN_BUG_TYPE, 3);
     parent::_addInteger(self::PAIN_EFFECT, 3);
     parent::_addInteger(self::PAIN_LIKELIHOOD, 3);
     parent::_addInteger(self::ASSIGNED_TO, 10);
     parent::_addText(self::REPRODUCTION_STEPS, false);
     parent::_addForeignKeyColumn(self::RESOLUTION, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addForeignKeyColumn(self::ISSUE_TYPE, TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID);
     parent::_addForeignKeyColumn(self::STATUS, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addForeignKeyColumn(self::PRIORITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addForeignKeyColumn(self::CATEGORY, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addForeignKeyColumn(self::SEVERITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addForeignKeyColumn(self::REPRODUCABILITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID);
     parent::_addVarchar(self::SCRUMCOLOR, 7, '#FFFFFF');
     parent::_addInteger(self::ESTIMATED_MONTHS, 10);
     parent::_addInteger(self::ESTIMATED_WEEKS, 10);
     parent::_addInteger(self::ESTIMATED_DAYS, 10);
     parent::_addInteger(self::ESTIMATED_HOURS, 10);
     parent::_addInteger(self::ESTIMATED_POINTS);
     parent::_addInteger(self::SPENT_MONTHS, 10);
     parent::_addInteger(self::SPENT_WEEKS, 10);
     parent::_addInteger(self::SPENT_DAYS, 10);
     parent::_addInteger(self::SPENT_HOURS, 10);
     parent::_addInteger(self::VOTES_TOTAL, 10);
     parent::_addInteger(self::SPENT_POINTS);
     parent::_addInteger(self::PERCENT_COMPLETE, 2);
     parent::_addInteger(self::ASSIGNED_TYPE, 2);
     parent::_addInteger(self::DUPLICATE_OF, 10);
     parent::_addBoolean(self::DELETED);
     parent::_addBoolean(self::BLOCKING);
     parent::_addBoolean(self::LOCKED);
     parent::_addForeignKeyColumn(self::BEING_WORKED_ON_BY_USER, TBGUsersTable::getTable(), TBGUsersTable::ID);
     parent::_addInteger(self::BEING_WORKED_ON_BY_USER_SINCE, 10);
     parent::_addForeignKeyColumn(self::MILESTONE, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID);
     parent::_addForeignKeyColumn(self::WORKFLOW_STEP_ID, TBGWorkflowStepsTable::getTable(), TBGWorkflowStepsTable::ID);
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
 }
Exemplo n.º 17
0
 public function runUpgrade(TBGRequest $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != '3.3';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2');
         $this->statuses = TBGListTypesTable::getTable()->getStatusListForUpgrade();
         $this->adminusername = TBGUsersTable3dot2::getTable()->getAdminUsername();
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isPost()) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
             case '3.1':
                 $this->_upgradeFrom3dot1();
             case '3.2':
                 $this->_upgradeFrom3dot2($request);
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', TBGSettings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             $prev_error_reportiong_level = error_reporting(0);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             error_reporting($prev_error_reportiong_level);
             if (file_exists(THEBUGGENIE_PATH . 'upgrade')) {
                 $this->upgrade_file_failed = true;
             }
             $this->current_version = TBGSettings::getVersion(false, false);
             $this->upgrade_available = false;
         }
     } elseif ($this->upgrade_available) {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } elseif ($this->upgrade_complete) {
         $this->forward(TBGContext::getRouting()->generate('home'));
     }
 }
Exemplo n.º 18
0
 /**
  * Create a new field option and return the row
  *
  * @param string $name
  * @param string $itemtype
  * @param mixed $itemdata
  *
  * @return B2DBResultset
  */
 protected static function _createNew($name, $itemtype, $itemdata = null)
 {
     $res = TBGListTypesTable::getTable()->createNew($name, $itemtype, $itemdata);
     return $res;
 }