コード例 #1
0
             case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
                 $old_object = \thebuggenie\core\entities\Build::getB2DBTable()->selectById($old_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                 $old_object = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($old_value);
                 break;
         }
     } catch (\Exception $e) {
     }
     try {
         switch ($customdatatype->getType()) {
             case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Edition::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Component::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
                 $new_object = \thebuggenie\core\entities\Build::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($new_value);
                 break;
         }
     } catch (\Exception $e) {
     }
     $old_value = is_object($old_object) ? $old_object->getName() : \thebuggenie\core\framework\Context::getI18n()->__('Unknown');
     $new_value = is_object($new_object) ? $new_object->getName() : \thebuggenie\core\framework\Context::getI18n()->__('Unknown');
     break;
 default:
     $old_item = null;
コード例 #2
0
ファイル: Main.php プロジェクト: JonathanRH/thebuggenie
 /**
  * Edit a component
  *
  * @param framework\Request $request The request object
  */
 public function runEditComponent(framework\Request $request)
 {
     $i18n = framework\Context::getI18n();
     if ($this->getUser()->canManageProject($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project)) {
         try {
             $component = entities\Component::getB2DBTable()->selectById($request['component_id']);
             if (is_null($request['mode'])) {
                 $content = $this->getComponentHTML('project/projectcomponent', array('component' => $component, 'access_level' => $this->access_level));
                 return $this->renderJSON(array('content' => $content));
             } else {
                 if ($request['mode'] == 'update') {
                     if (($c_name = $request['c_name']) && trim($c_name) != '') {
                         if ($c_name == $component->getName()) {
                             return $this->renderJSON(array('newname' => $c_name));
                         }
                         if (in_array($c_name, $component->getProject()->getComponents())) {
                             throw new \Exception($i18n->__('This component already exists for this project'));
                         }
                         $component->setName($c_name);
                         $component->save();
                         return $this->renderJSON(array('failed' => false, 'newname' => $component->getName()));
                     } else {
                         throw new \Exception($i18n->__('You need to specify a name for this component'));
                     }
                 } elseif ($request['mode'] == 'delete') {
                     $this->selected_project = $component->getProject();
                     $component->delete();
                     $count = $this->selected_project->countComponents();
                     return $this->renderJSON(array('deleted' => true, 'itemcount' => $count, 'message' => framework\Context::getI18n()->__('Component deleted')));
                 }
             }
         } catch (\Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array("error" => framework\Context::getI18n()->__('Could not edit this component') . ", " . $e->getMessage()));
         }
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array("error" => $i18n->__("You don't have access to modify components")));
 }
コード例 #3
0
ファイル: Issue.php プロジェクト: AzerothShard/thebuggenie
 protected function _processChanges()
 {
     $related_issues_to_save = array();
     $changed_properties = $this->_getChangedProperties();
     if (count($changed_properties)) {
         $is_saved_estimated = false;
         $is_saved_spent = false;
         $is_saved_assignee = false;
         $is_saved_owner = false;
         foreach ($changed_properties as $property => $value) {
             $compare_value = is_object($this->{$property}) ? $this->{$property}->getID() : $this->{$property};
             $original_value = $value['original_value'];
             if ($original_value != $compare_value) {
                 switch ($property) {
                     case '_title':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_TITLE, framework\Context::getI18n()->__("Title updated"), $original_value, $compare_value);
                         break;
                     case '_shortname':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_SHORTNAME, framework\Context::getI18n()->__("Issue label updated"), $original_value, $compare_value);
                         break;
                     case '_description':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_DESCRIPTION, framework\Context::getI18n()->__("Description updated"), $original_value, $compare_value);
                         break;
                     case '_reproduction_steps':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_REPRODUCTIONSTEPS, framework\Context::getI18n()->__("Reproduction steps updated"), $original_value, $compare_value);
                         break;
                     case '_category':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getCategory() instanceof Datatype ? $this->getCategory()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_CATEGORY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_bug_type':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_bug_type', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_bug_type', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_BUG_TYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_effect':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_effect', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_effect', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_EFFECT, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_likelihood':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_likelihood', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_likelihood', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_user_pain':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' ⇒ ' . $value['current_value']);
                         break;
                     case '_status':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getStatus() instanceof Datatype ? $this->getStatus()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_STATUS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_reproducability':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getReproducability() instanceof Datatype ? $this->getReproducability()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_REPRODUCABILITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_priority':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Priority::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getPriority() instanceof Datatype ? $this->getPriority()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PRIORITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_assignee_team':
                     case '_assignee_user':
                         if (!$is_saved_assignee) {
                             $new_name = $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->getName() : framework\Context::getI18n()->__('Not assigned');
                             if ($this->getAssignee() instanceof \thebuggenie\core\entities\User) {
                                 $this->startWorkingOnIssue($this->getAssignee());
                             }
                             $this->addLogEntry(tables\Log::LOG_ISSUE_ASSIGNED, $new_name);
                             $is_saved_assignee = true;
                         }
                         break;
                     case '_posted_by':
                         $old_identifiable = $original_value ? \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value) : framework\Context::getI18n()->__('Unknown');
                         $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         $new_name = $this->getPostedBy()->getName();
                         $this->addLogEntry(tables\Log::LOG_ISSUE_POSTED, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_being_worked_on_by_user':
                         if ($original_value != 0) {
                             $old_identifiable = \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value);
                             $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not being worked on');
                         }
                         $new_name = $this->getUserWorkingOnIssue() instanceof \thebuggenie\core\entities\User ? $this->getUserWorkingOnIssue()->getName() : framework\Context::getI18n()->__('Not being worked on');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_USERS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_owner_team':
                     case '_owner_user':
                         if (!$is_saved_owner) {
                             $new_name = $this->getOwner() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getOwner()->getName() : framework\Context::getI18n()->__('Not owned by anyone');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_OWNED, $new_name);
                             $is_saved_owner = true;
                         }
                         break;
                     case '_percent_complete':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PERCENT, $original_value . '% ⇒ ' . $this->getPercentCompleted() . '', $original_value, $compare_value);
                         break;
                     case '_resolution':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getResolution() instanceof Datatype ? $this->getResolution()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_RESOLUTION, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_severity':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Severity::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getSeverity() instanceof Datatype ? $this->getSeverity()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_SEVERITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_milestone':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getMilestone() instanceof \thebuggenie\core\entities\Milestone ? $this->getMilestone()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_MILESTONE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         $this->_milestone_order = 0;
                         break;
                     case '_issuetype':
                         if ($original_value != 0) {
                             $old_name = ($old_item = Issuetype::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Unknown');
                         }
                         $new_name = $this->getIssuetype() instanceof \thebuggenie\core\entities\Issuetype ? $this->getIssuetype()->getName() : framework\Context::getI18n()->__('Unknown');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_ISSUETYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_estimated_months':
                     case '_estimated_weeks':
                     case '_estimated_days':
                     case '_estimated_hours':
                     case '_estimated_points':
                         if (!$is_saved_estimated) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_estimated_months'), 'weeks' => $this->getChangedPropertyOriginal('_estimated_weeks'), 'days' => $this->getChangedPropertyOriginal('_estimated_days'), 'hours' => $this->getChangedPropertyOriginal('_estimated_hours'), 'points' => $this->getChangedPropertyOriginal('_estimated_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('Not estimated');
                             $new_formatted_time = $this->hasEstimatedTime() ? Issue::getFormattedTime($this->getEstimatedTime()) : framework\Context::getI18n()->__('Not estimated');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_ESTIMATED, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getEstimatedTime()));
                             $is_saved_estimated = true;
                         }
                         break;
                     case '_spent_months':
                     case '_spent_weeks':
                     case '_spent_days':
                     case '_spent_hours':
                     case '_spent_points':
                         if (!$is_saved_spent) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_spent_months'), 'weeks' => $this->getChangedPropertyOriginal('_spent_weeks'), 'days' => $this->getChangedPropertyOriginal('_spent_days'), 'hours' => round($this->getChangedPropertyOriginal('_spent_hours') / 100, 2), 'points' => $this->getChangedPropertyOriginal('_spent_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('No time spent');
                             $new_formatted_time = $this->hasSpentTime() ? Issue::getFormattedTime($this->getSpentTime()) : framework\Context::getI18n()->__('No time spent');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_SPENT, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getSpentTime()));
                             $is_saved_spent = true;
                         }
                         break;
                     case '_state':
                         if ($this->isClosed()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_CLOSE);
                             if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
                                 if ($this->getMilestone()->isSprint()) {
                                     if (!$this->getIssueType()->isTask()) {
                                         $this->setSpentPoints($this->getEstimatedPoints());
                                     } else {
                                         if ($this->getSpentHours() < $this->getEstimatedHours()) {
                                             $this->setSpentHours($this->getEstimatedHours());
                                         }
                                         foreach ($this->getParentIssues() as $parent_issue) {
                                             if ($parent_issue->checkTaskStates()) {
                                                 $related_issues_to_save[$parent_issue->getID()] = true;
                                             }
                                         }
                                     }
                                 }
                                 $this->getMilestone()->updateStatus();
                                 $this->getMilestone()->save();
                             }
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_REOPEN);
                         }
                         break;
                     case '_blocking':
                         if ($this->isBlocking()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_BLOCKED);
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_UNBLOCKED);
                         }
                         break;
                     default:
                         if (mb_substr($property, 0, 12) == '_customfield') {
                             $key = mb_substr($property, 12);
                             $customdatatype = CustomDatatype::getByKey($key);
                             switch ($customdatatype->getType()) {
                                 case CustomDatatype::INPUT_TEXT:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::INPUT_TEXTAREA_SMALL:
                                 case CustomDatatype::INPUT_TEXTAREA_MAIN:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::EDITIONS_CHOICE:
                                 case CustomDatatype::COMPONENTS_CHOICE:
                                 case CustomDatatype::RELEASES_CHOICE:
                                 case CustomDatatype::MILESTONE_CHOICE:
                                 case CustomDatatype::STATUS_CHOICE:
                                 case CustomDatatype::TEAM_CHOICE:
                                 case CustomDatatype::USER_CHOICE:
                                 case CustomDatatype::CLIENT_CHOICE:
                                     $old_object = null;
                                     $new_object = null;
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                                 $old_object = Edition::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                                 $old_object = Component::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::RELEASES_CHOICE:
                                                 $old_object = Build::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::MILESTONE_CHOICE:
                                                 $old_object = Milestone::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::STATUS_CHOICE:
                                                 $old_object = Status::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::TEAM_CHOICE:
                                                 $old_object = Team::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::USER_CHOICE:
                                                 $old_object = User::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $old_object = Client::getB2DBTable()->selectById($original_value);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                             case CustomDatatype::RELEASES_CHOICE:
                                             case CustomDatatype::MILESTONE_CHOICE:
                                             case CustomDatatype::STATUS_CHOICE:
                                             case CustomDatatype::TEAM_CHOICE:
                                             case CustomDatatype::USER_CHOICE:
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $new_object = $this->getCustomField($key);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = is_object($old_object) ? $old_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = is_object($new_object) ? $new_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                                 default:
                                     $old_item = null;
                                     try {
                                         $old_item = $original_value ? new CustomDatatypeOption($original_value) : null;
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = $old_item instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = $this->getCustomField($key) instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $this->getCustomField($key)->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                             }
                         }
                         break;
                 }
             }
         }
         if ($is_saved_estimated) {
             tables\IssueEstimates::getTable()->saveEstimate($this->getID(), $this->_estimated_months, $this->_estimated_weeks, $this->_estimated_days, $this->_estimated_hours, $this->_estimated_points);
         }
     }
     return $related_issues_to_save;
 }
コード例 #4
0
ファイル: Issue.php プロジェクト: AzerothShard/thebuggenie
 /**
  * Set status for affected component
  *
  * @see setAffectedItemStatus()
  * @see setAffectedBuildStatus()
  * @see setAffectedEditionStatus()
  *
  * @param \thebuggenie\core\entities\Component $item The component to set status for
  * @param \thebuggenie\core\entities\Datatype $status The status to set
  *
  * @return boolean
  */
 public function setAffectedComponentStatus($item, $status)
 {
     if (tables\IssueAffectsComponent::getTable()->setStatusByIssueIDandComponentID($this->getID(), $item->getID(), $status->getID())) {
         $this->touch();
         $this->addLogEntry(tables\Log::LOG_AFF_DELETE, framework\Context::getI18n()->__("'%item_name' -> '%status_name", array('%item_name' => $item->getName(), '%status_name' => $status->getName())));
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: Main.php プロジェクト: nrensen/thebuggenie
 public function runAddAffected(framework\Request $request)
 {
     framework\Context::loadLibrary('ui');
     try {
         $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
         $statuses = entities\Status::getAll();
         switch ($request['item_type']) {
             case 'edition':
                 if (!$issue->getProject()->isEditionsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Editions are disabled')));
                 } elseif (!$issue->canEditAffectedEditions()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $edition = entities\Edition::getB2DBTable()->selectById($request['which_item_edition']);
                 if (tables\IssueAffectsEdition::getTable()->getByIssueIDandEditionID($issue->getID(), $edition->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $edition->getName()))));
                 }
                 $result = $issue->addAffectedEdition($edition);
                 if ($result !== false) {
                     $itemtype = 'edition';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Edition');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Edition <b>%edition</b> is now affected by this issue', array('%edition' => $edition->getName()), true);
                 break;
             case 'component':
                 if (!$issue->getProject()->isComponentsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Components are disabled')));
                 } elseif (!$issue->canEditAffectedComponents()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $component = entities\Component::getB2DBTable()->selectById($request['which_item_component']);
                 if (tables\IssueAffectsComponent::getTable()->getByIssueIDandComponentID($issue->getID(), $component->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $component->getName()))));
                 }
                 $result = $issue->addAffectedComponent($component);
                 if ($result !== false) {
                     $itemtype = 'component';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Component');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Component <b>%component</b> is now affected by this issue', array('%component' => $component->getName()), true);
                 break;
             case 'build':
                 if (!$issue->getProject()->isBuildsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Releases are disabled')));
                 } elseif (!$issue->canEditAffectedBuilds()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $build = entities\Build::getB2DBTable()->selectById($request['which_item_build']);
                 if (tables\IssueAffectsBuild::getTable()->getByIssueIDandBuildID($issue->getID(), $build->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $build->getName()))));
                 }
                 $result = $issue->addAffectedBuild($build);
                 if ($result !== false) {
                     $itemtype = 'build';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Release');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Release <b>%build</b> is now affected by this issue', array('%build' => $build->getName()), true);
                 break;
             default:
                 throw new \Exception('Internal error');
         }
         $editions = array();
         $components = array();
         $builds = array();
         if ($issue->getProject()->isEditionsEnabled()) {
             $editions = $issue->getEditions();
         }
         if ($issue->getProject()->isComponentsEnabled()) {
             $components = $issue->getComponents();
         }
         if ($issue->getProject()->isBuildsEnabled()) {
             $builds = $issue->getBuilds();
         }
         $count = count($editions) + count($components) + count($builds);
         return $this->renderJSON(array('content' => $content, 'message' => $message, 'itemcount' => $count));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
コード例 #6
0
ファイル: Edition.php プロジェクト: pkdevboxy/thebuggenie
 /**
  * Removes an existing component from the edition
  *
  * @param \thebuggenie\core\entities\Component|integer $component
  */
 public function removeComponent($component)
 {
     $component_id = $component instanceof \thebuggenie\core\entities\Component ? $component->getID() : $component;
     tables\EditionComponents::getTable()->removeEditionComponent($this->getID(), $component_id);
 }