示例#1
0
 protected function _postIssue()
 {
     $fields_array = $this->selected_project->getReportableFieldsArray($this->issuetype_id);
     $issue = new TBGIssue();
     $issue->setTitle($this->title);
     $issue->setIssuetype($this->issuetype_id);
     $issue->setProject($this->selected_project);
     if (isset($fields_array['description'])) {
         $issue->setDescription($this->selected_description);
     }
     if (isset($fields_array['description_syntax'])) {
         $issue->setDescriptionSyntax($this->selected_description_syntax);
     }
     if (isset($fields_array['reproduction_steps'])) {
         $issue->setReproductionSteps($this->selected_reproduction_steps);
     }
     if (isset($fields_array['reproduction_steps_syntax'])) {
         $issue->setReproductionStepsSyntax($this->selected_reproduction_steps_syntax);
     }
     if (isset($fields_array['category']) && $this->selected_category instanceof TBGDatatype) {
         $issue->setCategory($this->selected_category->getID());
     }
     if (isset($fields_array['status']) && $this->selected_status instanceof TBGDatatype) {
         $issue->setStatus($this->selected_status->getID());
     }
     if (isset($fields_array['reproducability']) && $this->selected_reproducability instanceof TBGDatatype) {
         $issue->setReproducability($this->selected_reproducability->getID());
     }
     if (isset($fields_array['resolution']) && $this->selected_resolution instanceof TBGDatatype) {
         $issue->setResolution($this->selected_resolution->getID());
     }
     if (isset($fields_array['severity']) && $this->selected_severity instanceof TBGDatatype) {
         $issue->setSeverity($this->selected_severity->getID());
     }
     if (isset($fields_array['priority']) && $this->selected_priority instanceof TBGDatatype) {
         $issue->setPriority($this->selected_priority->getID());
     }
     if (isset($fields_array['estimated_time'])) {
         $issue->setEstimatedTime($this->selected_estimated_time);
     }
     if (isset($fields_array['spent_time'])) {
         $issue->setSpentTime($this->selected_spent_time);
     }
     if (isset($fields_array['milestone']) || isset($this->selected_milestone)) {
         $issue->setMilestone($this->selected_milestone);
     }
     if (isset($fields_array['percent_complete'])) {
         $issue->setPercentCompleted($this->selected_percent_complete);
     }
     if (isset($fields_array['pain_bug_type'])) {
         $issue->setPainBugType($this->selected_pain_bug_type);
     }
     if (isset($fields_array['pain_likelihood'])) {
         $issue->setPainLikelihood($this->selected_pain_likelihood);
     }
     if (isset($fields_array['pain_effect'])) {
         $issue->setPainEffect($this->selected_pain_effect);
     }
     foreach (TBGCustomDatatype::getAll() as $customdatatype) {
         if (!isset($fields_array[$customdatatype->getKey()])) {
             continue;
         }
         if ($customdatatype->hasCustomOptions()) {
             if (isset($fields_array[$customdatatype->getKey()]) && $this->selected_customdatatype[$customdatatype->getKey()] instanceof TBGCustomDatatypeOption) {
                 $selected_option = $this->selected_customdatatype[$customdatatype->getKey()];
                 $issue->setCustomField($customdatatype->getKey(), $selected_option->getID());
             }
         } else {
             $issue->setCustomField($customdatatype->getKey(), $this->selected_customdatatype[$customdatatype->getKey()]);
         }
     }
     // FIXME: If we set the issue assignee during report issue, this needs to be set INSTEAD of this
     if ($this->selected_project->canAutoassign()) {
         if (isset($fields_array['component']) && $this->selected_component instanceof TBGComponent && $this->selected_component->hasLeader()) {
             $issue->setAssignee($this->selected_component->getLeader());
         } elseif (isset($fields_array['edition']) && $this->selected_edition instanceof TBGEdition && $this->selected_edition->hasLeader()) {
             $issue->setAssignee($this->selected_edition->getLeader());
         } elseif ($this->selected_project->hasLeader()) {
             $issue->setAssignee($this->selected_project->getLeader());
         }
     }
     $issue->save();
     if (isset($this->parent_issue)) {
         $issue->addParentIssue($this->parent_issue);
     }
     if (isset($fields_array['edition']) && $this->selected_edition instanceof TBGEdition) {
         $issue->addAffectedEdition($this->selected_edition);
     }
     if (isset($fields_array['build']) && $this->selected_build instanceof TBGBuild) {
         $issue->addAffectedBuild($this->selected_build);
     }
     if (isset($fields_array['component']) && $this->selected_component instanceof TBGComponent) {
         $issue->addAffectedComponent($this->selected_component);
     }
     return $issue;
 }