コード例 #1
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::MILESTONE_ID, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID);
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
 }
コード例 #2
0
 public function __construct()
 {
     parent::__construct(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::MILESTONE_ID, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID);
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
 }
コード例 #3
0
        case TBGCustomDatatype::MILESTONE_CHOICE:
            $object = null;
            $value = null;
            try {
                switch ($info['type']) {
                    case TBGCustomDatatype::EDITIONS_CHOICE:
                        $object = TBGEditionsTable::getTable()->selectById($info['name']);
                        break;
                    case TBGCustomDatatype::COMPONENTS_CHOICE:
                        $object = TBGComponentsTable::getTable()->selectById($info['name']);
                        break;
                    case TBGCustomDatatype::RELEASES_CHOICE:
                        $object = TBGBuildsTable::getTable()->selectById($info['name']);
                        break;
                    case TBGCustomDatatype::MILESTONE_CHOICE:
                        $object = TBGMilestonesTable::getTable()->selectById($info['name']);
                        break;
                }
                $value = is_object($object) ? $object->getName() : null;
            } catch (Exception $e) {
            }
            ?>
									<span id="<?php 
            echo $field;
            ?>
_name"<?php 
            if (!$info['name_visible']) {
                ?>
 style="display: none;"<?php 
            }
            ?>
コード例 #4
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runFilterGetDynamicChoices(TBGRequest $request)
 {
     $subproject_ids = explode(',', $request['subprojects']);
     $existing_ids = $request['existing_ids'];
     $results = array();
     $projects = $request['project_id'] != '' ? TBGProject::getAllByIDs(explode(',', $request['project_id'])) : TBGProject::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'] = TBGSearchFilter::createFilter('build');
     $filters['edition'] = TBGSearchFilter::createFilter('edition');
     $filters['component'] = TBGSearchFilter::createFilter('component');
     $filters['milestone'] = TBGSearchFilter::createFilter('milestone');
     if (isset($existing_ids['build'])) {
         foreach (TBGBuildsTable::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 (TBGEditionsTable::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 (TBGComponentsTable::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 (TBGMilestonesTable::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->getTemplateHTML('search/interactivefilterdynamicchoicelist', array('filter' => $filters[$k], 'items' => $items[$k]));
     }
     return $this->renderJSON(compact('results'));
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 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())));
     }
 }
コード例 #6
0
 /**
  * Figure out this milestones status
  */
 public function updateStatus()
 {
     if ($this->countClosedIssues() == $this->countIssues()) {
         TBGMilestonesTable::getTable()->setReached($this->getID());
         $this->_reacheddate = NOW;
     } elseif ($this->hasReachedDate()) {
         TBGMilestonesTable::getTable()->clearReached($this->getID());
         $this->_reacheddate = null;
     }
 }
コード例 #7
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 /**
  * Sets an issue field to a specified value
  * 
  * @param TBGRequest $request
  */
 public function runIssueSetField(TBGRequest $request)
 {
     if ($issue_id = $request['issue_id']) {
         try {
             $issue = TBGIssuesTable::getTable()->selectById($issue_id);
         } catch (Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderText('fail');
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderText('no issue');
     }
     TBGContext::loadLibrary('common');
     if (!$issue instanceof TBGIssue) {
         return false;
     }
     switch ($request['field']) {
         case 'description':
             if (!$issue->canEditDescription()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setDescription($request->getRawParameter('value'));
             $issue->setDescriptionSyntax($request->getParameter('value_syntax'));
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isDescriptionChanged(), 'field' => array('id' => (int) ($issue->getDescription() != ''), 'name' => $issue->getParsedDescription(array('issue' => $issue))), 'description' => $issue->getParsedDescription(array('issue' => $issue))));
             break;
         case 'reproduction_steps':
             if (!$issue->canEditReproductionSteps()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setReproductionSteps($request->getRawParameter('value'));
             $issue->setReproductionStepsSyntax($request->getParameter('value_syntax'));
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isReproductionStepsChanged(), 'field' => array('id' => (int) ($issue->getReproductionSteps() != ''), 'name' => $issue->getParsedReproductionSteps(array('issue' => $issue))), 'reproduction_steps' => $issue->getParsedReproductionSteps(array('issue' => $issue))));
             break;
         case 'title':
             if (!$issue->canEditTitle()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request['value'] == '') {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You have to provide a title')));
             } else {
                 $issue->setTitle($request->getRawParameter('value'));
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isTitleChanged(), 'field' => array('id' => 1, 'name' => strip_tags($issue->getTitle()))));
             }
             break;
         case 'percent_complete':
             if (!$issue->canEditPercentage()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             $issue->setPercentCompleted($request['percent']);
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'field' => 'percent_complete', 'changed' => $issue->isPercentCompletedChanged(), 'percent' => $issue->getPercentCompleted()));
             break;
         case 'estimated_time':
             if (!$issue->canEditEstimatedTime()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if (!$issue->isUpdateable()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('This issue cannot be updated')));
             }
             if ($request['estimated_time']) {
                 $issue->setEstimatedTime($request['estimated_time']);
             } elseif ($request->hasParameter('value')) {
                 $issue->setEstimatedTime($request['value']);
             } else {
                 $issue->setEstimatedMonths($request['months']);
                 $issue->setEstimatedWeeks($request['weeks']);
                 $issue->setEstimatedDays($request['days']);
                 $issue->setEstimatedHours($request['hours']);
                 $issue->setEstimatedPoints($request['points']);
             }
             if ($request['do_save']) {
                 $issue->save();
             }
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isEstimatedTimeChanged(), 'field' => $issue->hasEstimatedTime() ? array('id' => 1, 'name' => TBGIssue::getFormattedTime($issue->getEstimatedTime())) : array('id' => 0), 'values' => $issue->getEstimatedTime()));
             break;
         case 'posted_by':
         case 'owned_by':
         case 'assigned_to':
             if ($request['field'] == 'posted_by' && !$issue->canEditPostedBy()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'owned_by' && !$issue->canEditOwner()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'assigned_to' && !$issue->canEditAssignee()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request->hasParameter('value')) {
                 if ($request->hasParameter('identifiable_type')) {
                     if (in_array($request['identifiable_type'], array('team', 'user')) && $request['value'] != 0) {
                         switch ($request['identifiable_type']) {
                             case 'user':
                                 $identified = TBGContext::factory()->TBGUser($request['value']);
                                 break;
                             case 'team':
                                 $identified = TBGContext::factory()->TBGTeam($request['value']);
                                 break;
                         }
                         if ($identified instanceof TBGUser || $identified instanceof TBGTeam) {
                             if ((bool) $request->getParameter('teamup', false)) {
                                 $team = new TBGTeam();
                                 $team->setName($identified->getBuddyname() . ' & ' . $this->getUser()->getBuddyname());
                                 $team->setOndemand(true);
                                 $team->save();
                                 $team->addMember($identified);
                                 $team->addMember($this->getUser());
                                 $identified = $team;
                             }
                             if ($request['field'] == 'owned_by') {
                                 $issue->setOwner($identified);
                             } elseif ($request['field'] == 'assigned_to') {
                                 $issue->setAssignee($identified);
                             }
                         }
                     } else {
                         if ($request['field'] == 'owned_by') {
                             $issue->clearOwner();
                         } elseif ($request['field'] == 'assigned_to') {
                             $issue->clearAssignee();
                         }
                     }
                 } elseif ($request['field'] == 'posted_by') {
                     $identified = TBGContext::factory()->TBGUser($request['value']);
                     if ($identified instanceof TBGUser) {
                         $issue->setPostedBy($identified);
                     }
                 }
                 if ($request['field'] == 'posted_by') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isPostedByChanged(), 'field' => array('id' => $issue->getPostedByID(), 'name' => $this->getComponentHTML('main/userdropdown', array('user' => $issue->getPostedBy())))));
                 }
                 if ($request['field'] == 'owned_by') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isOwnerChanged(), 'field' => $issue->isOwned() ? array('id' => $issue->getOwner()->getID(), 'name' => $issue->getOwner() instanceof TBGUser ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getOwner()))) : array('id' => 0)));
                 }
                 if ($request['field'] == 'assigned_to') {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isAssigneeChanged(), 'field' => $issue->isAssigned() ? array('id' => $issue->getAssignee()->getID(), 'name' => $issue->getAssignee() instanceof TBGUser ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getAssignee())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getAssignee()))) : array('id' => 0)));
                 }
             }
             break;
         case 'spent_time':
             if (!$issue->canEditSpentTime()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             if ($request['spent_time'] != TBGContext::getI18n()->__('Enter time spent here') && $request['spent_time']) {
                 $issue->addSpentTime($request['spent_time']);
             } elseif ($request->hasParameter('value')) {
                 $issue->addSpentTime($request['value']);
             } else {
                 $issue->addSpentMonths($request['months']);
                 $issue->addSpentWeeks($request['weeks']);
                 $issue->addSpentDays($request['days']);
                 $issue->addSpentHours($request['hours']);
                 $issue->addSpentPoints($request['points']);
             }
             return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => $issue->isSpentTimeChanged(), 'field' => $issue->hasSpentTime() ? array('id' => 1, 'name' => TBGIssue::getFormattedTime($issue->getSpentTime())) : array('id' => 0), 'values' => $issue->getSpentTime()));
             break;
         case 'category':
         case 'resolution':
         case 'severity':
         case 'reproducability':
         case 'priority':
         case 'milestone':
         case 'issuetype':
         case 'status':
         case 'pain_bug_type':
         case 'pain_likelihood':
         case 'pain_effect':
             if ($request['field'] == 'category' && !$issue->canEditCategory()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'resolution' && !$issue->canEditResolution()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'severity' && !$issue->canEditSeverity()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'reproducability' && !$issue->canEditReproducability()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'priority' && !$issue->canEditPriority()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'milestone' && !$issue->canEditMilestone()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'issuetype' && !$issue->canEditIssuetype()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif ($request['field'] == 'status' && !$issue->canEditStatus()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             } elseif (in_array($request['field'], array('pain_bug_type', 'pain_likelihood', 'pain_effect')) && !$issue->canEditUserPain()) {
                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'error' => TBGContext::getI18n()->__('You do not have permission to perform this action')));
             }
             try {
                 $classname = null;
                 $parameter_name = mb_strtolower($request['field']);
                 $parameter_id_name = "{$parameter_name}_id";
                 $is_pain = in_array($parameter_name, array('pain_bug_type', 'pain_likelihood', 'pain_effect'));
                 if ($is_pain) {
                     switch ($parameter_name) {
                         case 'pain_bug_type':
                             $set_function_name = 'setPainBugType';
                             $is_changed_function_name = 'isPainBugTypeChanged';
                             $get_pain_type_label_function = 'getPainBugTypeLabel';
                             break;
                         case 'pain_likelihood':
                             $set_function_name = 'setPainLikelihood';
                             $is_changed_function_name = 'isPainLikelihoodChanged';
                             $get_pain_type_label_function = 'getPainLikelihoodLabel';
                             break;
                         case 'pain_effect':
                             $set_function_name = 'setPainEffect';
                             $is_changed_function_name = 'isPainEffectChanged';
                             $get_pain_type_label_function = 'getPainEffectLabel';
                             break;
                     }
                 } else {
                     $classname = 'TBG' . ucfirst($parameter_name);
                     $lab_function_name = $classname;
                     $set_function_name = 'set' . ucfirst($parameter_name);
                     $is_changed_function_name = 'is' . ucfirst($parameter_name) . 'Changed';
                 }
                 if ($request->hasParameter($parameter_id_name)) {
                     $parameter_id = $request->getParameter($parameter_id_name);
                     if ($parameter_id !== 0) {
                         $is_valid = $is_pain ? in_array($parameter_id, array_keys(TBGIssue::getPainTypesOrLabel($parameter_name))) : $parameter_id == 0 || ($parameter = TBGContext::factory()->{$lab_function_name}($parameter_id)) instanceof $classname;
                     }
                     if ($parameter_id == 0 || $parameter_id !== 0 && $is_valid) {
                         if ($classname == 'TBGIssuetype') {
                             $visible_fields = $issue->getIssuetype() instanceof TBGIssuetype ? $issue->getProject()->getVisibleFieldsArray($issue->getIssuetype()->getID()) : array();
                         } else {
                             $visible_fields = null;
                         }
                         $issue->{$set_function_name}($parameter_id);
                         if ($is_pain) {
                             if (!$issue->{$is_changed_function_name}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false, 'field' => array('id' => 0), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText()));
                             }
                             return $parameter_id == 0 ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText())) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => $parameter_id, 'name' => $issue->{$get_pain_type_label_function}()), 'user_pain' => $issue->getUserPain(), 'user_pain_diff_text' => $issue->getUserPainDiffText()));
                         } else {
                             if (!$issue->{$is_changed_function_name}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             if (isset($parameter)) {
                                 $name = $parameter->getName();
                             } else {
                                 $name = null;
                             }
                             $field = array('id' => $parameter_id, 'name' => $name);
                             if ($classname == 'TBGIssuetype') {
                                 TBGContext::loadLibrary('ui');
                                 $field['src'] = htmlspecialchars(TBGContext::getTBGPath() . 'iconsets/' . TBGSettings::getThemeName() . '/' . $issue->getIssuetype()->getIcon() . '_small.png');
                             }
                             if ($parameter_id == 0) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0)));
                             } else {
                                 $options = array('issue_id' => $issue->getID(), 'changed' => true, 'visible_fields' => $visible_fields, 'field' => $field);
                                 if ($request['field'] == 'milestone') {
                                     $options['field']['url'] = $this->getRouting()->generate('project_milestone_details', array('project_key' => $issue->getProject()->getKey(), 'milestone_id' => $issue->getMilestone()->getID()));
                                 }
                                 if ($request['field'] == 'status') {
                                     $options['field']['color'] = $issue->getStatus()->getItemdata();
                                 }
                                 return $this->renderJSON($options);
                             }
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('error' => $e->getMessage()));
             }
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('error' => TBGContext::getI18n()->__('No valid field value specified')));
             break;
         default:
             if ($customdatatype = TBGCustomDatatype::getByKey($request['field'])) {
                 $key = $customdatatype->getKey();
                 $customdatatypeoption_value = $request->getParameter("{$key}_value");
                 if (!$customdatatype->hasCustomOptions()) {
                     switch ($customdatatype->getType()) {
                         case TBGCustomDatatype::EDITIONS_CHOICE:
                         case TBGCustomDatatype::COMPONENTS_CHOICE:
                         case TBGCustomDatatype::RELEASES_CHOICE:
                         case TBGCustomDatatype::STATUS_CHOICE:
                         case TBGCustomDatatype::MILESTONE_CHOICE:
                         case TBGCustomDatatype::USER_CHOICE:
                         case TBGCustomDatatype::TEAM_CHOICE:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 switch ($customdatatype->getType()) {
                                     case TBGCustomDatatype::EDITIONS_CHOICE:
                                         $temp = TBGEditionsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::COMPONENTS_CHOICE:
                                         $temp = TBGComponentsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::RELEASES_CHOICE:
                                         $temp = TBGBuildsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::MILESTONE_CHOICE:
                                         $temp = TBGMilestonesTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::STATUS_CHOICE:
                                         $temp = TBGStatus::getB2DBTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::USER_CHOICE:
                                         $temp = TBGUsersTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                     case TBGCustomDatatype::TEAM_CHOICE:
                                         $temp = TBGTeamsTable::getTable()->selectById($request->getRawParameter("{$key}_value"));
                                         break;
                                 }
                                 $finalvalue = $temp->getName();
                                 $issue->setCustomField($key, $request->getRawParameter("{$key}_value"));
                             }
                             if ($customdatatype->getType() == TBGCustomDatatype::STATUS_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = '<div class="status_badge" style="background-color: ' . $temp->getColor() . ';"><span>' . $finalvalue . '</span></div>';
                             } elseif ($customdatatype->getType() == TBGCustomDatatype::USER_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = $this->getComponentHTML('main/userdropdown', array('user' => $temp));
                             } elseif ($customdatatype->getType() == TBGCustomDatatype::TEAM_CHOICE && isset($temp) && is_object($temp)) {
                                 $finalvalue = $this->getComponentHTML('main/teamdropdown', array('team' => $temp));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => $finalvalue)));
                             break;
                         case TBGCustomDatatype::INPUT_TEXTAREA_MAIN:
                         case TBGCustomDatatype::INPUT_TEXTAREA_SMALL:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getRawParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => tbg_parse_text($request->getRawParameter("{$key}_value")))));
                             break;
                         case TBGCustomDatatype::DATE_PICKER:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => date('Y-m-d', (int) $request->getRawParameter("{$key}_value")))));
                             break;
                         default:
                             if ($customdatatypeoption_value == '') {
                                 $issue->setCustomField($key, "");
                             } else {
                                 $issue->setCustomField($key, $request->getParameter("{$key}_value"));
                             }
                             $changed_methodname = "isCustomfield{$key}Changed";
                             if (!$issue->{$changed_methodname}()) {
                                 return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                             }
                             return $customdatatypeoption_value == '' ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $key, 'name' => filter_var($customdatatypeoption_value, FILTER_VALIDATE_URL) !== false ? "<a href=\"{$customdatatypeoption_value}\">{$customdatatypeoption_value}</a>" : $customdatatypeoption_value)));
                             break;
                     }
                 }
                 $customdatatypeoption = $customdatatypeoption_value ? TBGCustomDatatypeOption::getB2DBTable()->selectById($customdatatypeoption_value) : null;
                 if ($customdatatypeoption instanceof TBGCustomDatatypeOption) {
                     $issue->setCustomField($key, $customdatatypeoption->getID());
                 } else {
                     $issue->setCustomField($key, null);
                 }
                 $changed_methodname = "isCustomfield{$key}Changed";
                 if (!$issue->{$changed_methodname}()) {
                     return $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => false));
                 }
                 return !$customdatatypeoption instanceof TBGCustomDatatypeOption ? $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('id' => 0))) : $this->renderJSON(array('issue_id' => $issue->getID(), 'changed' => true, 'field' => array('value' => $customdatatypeoption->getID(), 'name' => $customdatatypeoption->getName())));
             }
             break;
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => TBGContext::getI18n()->__('No valid field specified (%field)', array('%field' => $request['field']))));
 }
コード例 #8
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 private function _fixTimestamps()
 {
     // Unlimited execution time
     set_time_limit(0);
     foreach (TBGScope::getAll() as $scope) {
         TBGContext::setScope($scope);
         // The first job is to work out the offsets that need applying
         $offsets = array('system', 'users');
         $offsets['users'] = array();
         $offsets['system'] = (int) TBGSettings::getGMToffset() * 3600;
         $settingstable = TBGSettingsTable::getTable();
         $crit = $settingstable->getCriteria();
         $crit->addWhere(TBGSettingsTable::NAME, 'timezone');
         $crit->addWhere(TBGSettingsTable::MODULE, 'core');
         $crit->addWhere(TBGSettingsTable::UID, 0, \b2db\Criteria::DB_NOT_EQUALS);
         $crit->addWhere(TBGSettingsTable::VALUE, 0, \b2db\Criteria::DB_NOT_EQUALS);
         $crit->addWhere(TBGSettingsTable::VALUE, 'sys', \b2db\Criteria::DB_NOT_EQUALS);
         $crit->addWhere(TBGSettingsTable::SCOPE, $scope->getID());
         $res = $settingstable->doSelect($crit);
         if ($res instanceof \b2db\Resultset) {
             while ($user = $res->getNextRow()) {
                 $offsets['users']['uid_' . $user->get(TBGSettingsTable::UID)] = (int) $user->get(TBGSettingsTable::VALUE) * 3600;
             }
         }
         // Now go through every thing which requires updating
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB');
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes');
         // ARTICLE HISTORY
         $this->_fixUserDependentTimezone($offsets, TBGArticleHistoryTable::getTable(), TBGArticleHistoryTable::AUTHOR, TBGArticleHistoryTable::DATE, $scope);
         // ARTICLES
         $this->_fixUserDependentTimezone($offsets, TBGArticlesTable::getTable(), TBGArticlesTable::AUTHOR, TBGArticlesTable::DATE, $scope);
         // BUILDS
         $this->_fixNonUserDependentTimezone($offsets, TBGBuildsTable::getTable(), TBGBuildsTable::RELEASE_DATE, $scope, TBGBuildsTable::RELEASED);
         // COMMENTS
         $this->_fixUserDependentTimezone($offsets, TBGCommentsTable::getTable(), array('a' => TBGCommentsTable::POSTED_BY, 'b' => TBGCommentsTable::UPDATED_BY), array('a' => TBGCommentsTable::POSTED, 'b' => TBGCommentsTable::UPDATED), $scope);
         // EDITIONS
         $this->_fixNonUserDependentTimezone($offsets, TBGEditionsTable::getTable(), TBGEditionsTable::RELEASE_DATE, $scope, TBGEditionsTable::RELEASED);
         // ISSUES
         // This is a bit more complex so do this manually - we have to poke around with the issue log
         $table = TBGIssuesTable::getTable();
         $crit = $table->getCriteria();
         $crit->addWhere(TBGIssuesTable::SCOPE, $scope->getID());
         $crit->addWhere(TBGIssuesTable::DELETED, false);
         $res = $table->doSelect($crit);
         if ($res) {
             while ($row = $res->getNextRow()) {
                 $crit = TBGLogTable::getTable()->getCriteria();
                 $crit->addSelectionColumn(TBGLogTable::UID);
                 $crit->addWhere(TBGLogTable::CHANGE_TYPE, TBGLogTable::LOG_ISSUE_ASSIGNED);
                 $crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID));
                 $crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE);
                 $crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC);
                 $crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC);
                 if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) {
                     $assigned_by = $row2->get(TBGLogTable::UID);
                 }
                 $crit = TBGLogTable::getTable()->getCriteria();
                 $crit->addSelectionColumn(TBGLogTable::UID);
                 $crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID));
                 $crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE);
                 $crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC);
                 $crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC);
                 if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) {
                     $updated_by = $row2->get(TBGLogTable::UID);
                 }
                 unset($crit);
                 unset($row2);
                 if (array_key_exists('uid_' . $row->get(TBGIssuesTable::POSTED_BY), $offsets['users'])) {
                     $offset = $offsets['users']['uid_' . $row->get(TBGIssuesTable::POSTED_BY)];
                 } else {
                     $offset = $offsets['system'];
                 }
                 if (isset($updated_by) && array_key_exists('uid_' . $updated_by, $offsets['users'])) {
                     $offset2 = $offsets['users']['uid_' . $updated_by];
                 } elseif (isset($updated_by)) {
                     $offset2 = $offsets['system'];
                 }
                 if (isset($assigned_by) && array_key_exists('uid_' . $assigned_by, $offsets['users'])) {
                     $offset3 = $offsets['users']['uid_' . $assigned_by];
                 } elseif (isset($assigned_by)) {
                     $offset3 = $offsets['system'];
                 }
                 $crit2 = $table->getCriteria();
                 $crit2->addUpdate(TBGIssuesTable::POSTED, (int) $row->get(TBGIssuesTable::POSTED) + $offset);
                 if (isset($offset2)) {
                     $crit2->addUpdate(TBGIssuesTable::LAST_UPDATED, (int) $row->get(TBGIssuesTable::LAST_UPDATED) + $offset2);
                     unset($offset2);
                 }
                 if (isset($offset3)) {
                     $crit2->addUpdate(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE, (int) $row->get(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE) + $offset3);
                     unset($offset3);
                 }
                 $crit2->addWhere(TBGIssuesTable::ID, $row->get(TBGIssuesTable::ID));
                 $table->doUpdate($crit2);
             }
         }
         // LOG
         $this->_fixUserDependentTimezone($offsets, TBGLogTable::getTable(), TBGLogTable::UID, TBGLogTable::TIME, $scope);
         // MILESTONES
         // The conditions are a bit different here so do it manually
         $table = TBGMilestonesTable::getTable();
         $crit = $table->getCriteria();
         $crit->addWhere(TBGMilestonesTable::SCOPE, $scope->getID());
         $res = $table->doSelect($crit);
         if ($res) {
             while ($row = $res->getNextRow()) {
                 $offset = $offsets['system'];
                 $crit2 = $table->getCriteria();
                 $added = 0;
                 if ($row->get(TBGMilestonesTable::REACHED) > 0) {
                     $crit2->addUpdate(TBGMilestonesTable::REACHED, (int) $row->get(TBGMilestonesTable::REACHED) + $offset);
                     $added = 1;
                 }
                 if ($row->get(TBGMilestonesTable::SCHEDULED) > 0) {
                     $crit2->addUpdate(TBGMilestonesTable::SCHEDULED, (int) $row->get(TBGMilestonesTable::SCHEDULED) + $offset);
                     $added = 1;
                 }
                 if ($row->get(TBGMilestonesTable::STARTING) > 0) {
                     $crit2->addUpdate(TBGMilestonesTable::STARTING, (int) $row->get(TBGMilestonesTable::STARTING) + $offset);
                     $added = 1;
                 }
                 // Only do something if at least one call to addUpdate is done
                 if ($added == 1) {
                     $crit2->addWhere(TBGMilestonesTable::ID, $row->get(TBGMilestonesTable::ID));
                     $table->doUpdate($crit2);
                 }
             }
         }
         // PROJECTS
         $this->_fixNonUserDependentTimezone($offsets, TBGProjectsTable::getTable(), TBGProjectsTable::RELEASE_DATE, $scope, TBGProjectsTable::RELEASED);
         // VCS INTEGRATION
         // check if module is loaded
         $modules = TBGModulesTable::getTable()->getModulesForScope($scope->getID());
         if ($modules['vcs_integration'] == true) {
             TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'vcs_integration' . DS . 'classes' . DS . 'B2DB');
             TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'vcs_integration' . DS . 'classes');
             $this->_fixUserDependentTimezone($offsets, TBGVCSIntegrationTable::getTable(), TBGVCSIntegrationTable::AUTHOR, TBGVCSIntegrationTable::DATE, $scope);
         }
     }
 }
コード例 #9
0
 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);
 }
コード例 #10
0
ファイル: TBGIssue.class.php プロジェクト: oparoz/thebuggenie
 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;
         }
     }
 }