protected function _populateMilestoneSwimlanes(\thebuggenie\core\entities\Milestone $milestone)
 {
     if (!array_key_exists($milestone->getID(), $this->_swimlanes)) {
         $this->_swimlanes[$milestone->getID()] = array();
         $swimlanes = array();
         if ($this->usesSwimlanes()) {
             switch ($this->getSwimlaneType()) {
                 case self::SWIMLANES_EXPEDITE:
                 case self::SWIMLANES_GROUPING:
                     switch ($this->getSwimlaneIdentifier()) {
                         case 'priority':
                             $items = \thebuggenie\core\entities\Priority::getAll();
                             break;
                         case 'severity':
                             $items = \thebuggenie\core\entities\Severity::getAll();
                             break;
                         case 'category':
                             $items = \thebuggenie\core\entities\Category::getAll();
                             break;
                         default:
                             $items = array();
                             break;
                     }
                     if ($this->getSwimlaneType() == self::SWIMLANES_EXPEDITE) {
                         $expedite_items = array();
                         foreach ($this->getSwimlaneFieldValues() as $value) {
                             if (array_key_exists($value, $items)) {
                                 $expedite_items[$items[$value]->getID()] = $items[$value];
                                 unset($items[$value]);
                             }
                         }
                         $swimlanes[] = array('identifiables' => $expedite_items);
                         $swimlanes[] = array('identifiables' => $items);
                         $swimlanes[] = array('identifiables' => 0);
                     } else {
                         foreach ($items as $item) {
                             $swimlanes[] = array('identifiables' => $item);
                         }
                         $swimlanes[] = array('identifiables' => 0);
                     }
                     break;
                 case self::SWIMLANES_ISSUES:
                     foreach ($milestone->getIssues() as $issue) {
                         if ($issue->isChildIssue()) {
                             foreach ($issue->getParentIssues() as $parent) {
                                 if ($parent->getIssueType()->getID() != $this->getEpicIssuetypeID()) {
                                     continue 2;
                                 }
                             }
                         }
                         if (in_array($issue->getIssueType()->getID(), $this->getSwimlaneFieldValues())) {
                             $swimlanes[] = array('identifiables' => $issue);
                         }
                     }
                     $swimlanes[] = array('identifiables' => 0);
                     break;
             }
         } else {
             $swimlanes[] = array('identifiables' => 0);
         }
         foreach ($swimlanes as $details) {
             $swimlane = new BoardSwimlane();
             $swimlane->setBoard($this);
             $swimlane->setIdentifiables($details['identifiables']);
             $swimlane->setMilestone($milestone);
             $this->_swimlanes[$milestone->getID()][] = $swimlane;
         }
     }
 }
 public function hasValidTarget()
 {
     if (!$this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             $target_details = explode('_', $this->_target_value);
             return (bool) ($target_details[0] == 'user') ? \thebuggenie\core\entities\User::doesIDExist($target_details[1]) : Team::doesIDExist($target_details[1]);
             break;
         case self::ACTION_SET_PERCENT:
             return (bool) ($this->_target_value > -1);
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) Milestone::doesIDExist($this->_target_value);
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) Priority::has($this->_target_value);
             break;
         case self::ACTION_SET_STATUS:
             return (bool) Status::has($this->_target_value);
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) Reproducability::has($this->_target_value);
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) Resolution::has($this->_target_value);
             break;
         default:
             return true;
     }
 }
Example #3
0
 /**
  * The project board whiteboard page
  *
  * @Route(url="/boards/:board_id/whiteboard/issues/*")
  * @CsrfProtected
  *
  * @param framework\Request $request
  */
 public function runWhiteboardIssues(framework\Request $request)
 {
     $this->forward403unless($this->_checkProjectPageAccess('project_planning'));
     $this->board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
     $this->forward403unless($this->board instanceof entities\AgileBoard);
     try {
         if ($request->isPost()) {
             $issue = \thebuggenie\core\entities\tables\Issues::getTable()->selectById((int) $request['issue_id']);
             $column = entities\BoardColumn::getB2DBTable()->selectById((int) $request['column_id']);
             $milestone = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById((int) $request['milestone_id']);
             $swimlane = null;
             if ($request['swimlane_identifier']) {
                 foreach ($column->getBoard()->getMilestoneSwimlanes($milestone) as $swimlane) {
                     if ($swimlane->getIdentifier() == $request['swimlane_identifier']) {
                         break;
                     }
                 }
             }
             if ($request->hasParameter('transition_id')) {
                 $transitions = array(\thebuggenie\core\entities\tables\WorkflowTransitions::getTable()->selectById((int) $request['transition_id']));
                 if ($transitions[0]->hasTemplate()) {
                     return $this->renderJSON(array('component' => $this->getComponentHTML('main/issue_workflow_transition', compact('issue')), 'transition_id' => $transitions[0]->getID()));
                 }
                 if (!$transitions[0]->transitionIssueToOutgoingStepWithoutRequest($issue)) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('There was an error trying to move this issue to the next step in the workflow'), 'message' => preg_replace('/\\s+/', ' ', $this->getComponentHTML('main/issue_transition_error'))));
                 }
             } else {
                 list($status_ids, $transitions, $rule_status_valid) = $issue->getAvailableWorkflowStatusIDsAndTransitions();
                 $available_statuses = array_intersect($status_ids, $column->getStatusIds());
                 if ($rule_status_valid && count($available_statuses) == 1 && count($transitions[reset($available_statuses)]) == 1 && $transitions[reset($available_statuses)][0]->hasTemplate()) {
                     return $this->renderJSON(array('component' => $this->getComponentHTML('main/issue_workflow_transition', compact('issue')), 'transition_id' => $transitions[reset($available_statuses)][0]->getID()));
                 }
                 if (empty($available_statuses)) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => $this->getI18n()->__('There are no valid transitions to any states in this column')));
                 }
                 if (count($available_statuses) > 1 || count($available_statuses) == 1 && count($transitions[reset($available_statuses)]) > 1) {
                     return $this->renderJSON(array('component' => $this->getComponentHTML('agile/whiteboardtransitionselector', array('issue' => $issue, 'transitions' => $transitions, 'statuses' => $available_statuses, 'new_column' => $column, 'board' => $column->getBoard(), 'swimlane_identifier' => $request['swimlane_identifier']))));
                 }
                 if (!$transitions[reset($available_statuses)][0]->transitionIssueToOutgoingStepWithoutRequest($issue)) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('There was an error trying to move this issue to the next step in the workflow'), 'message' => preg_replace('/\\s+/', ' ', $this->getComponentHTML('main/issue_transition_error'))));
                 }
             }
             return $this->renderJSON(array('transition' => 'ok', 'issue' => $this->getComponentHTML('agile/whiteboardissue', array('issue' => $issue, 'column' => $column, 'swimlane' => $swimlane))));
         } else {
             $milestone = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $request['milestone_id']);
             return $this->renderJSON(array('component' => $this->getComponentHTML('agile/whiteboardcontent', array('board' => $this->board, 'milestone' => $milestone)), 'swimlanes' => $this->board->usesSwimlanes() ? 1 : 0));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Example #4
0
 /**
  * Add a build (AJAX call)
  *
  * @param framework\Request $request The request object
  */
 public function runProjectBuild(framework\Request $request)
 {
     $i18n = framework\Context::getI18n();
     if ($this->getUser()->canManageProjectReleases($this->selected_project)) {
         try {
             if (framework\Context::getUser()->canManageProjectReleases($this->selected_project)) {
                 if (($b_name = $request['build_name']) && trim($b_name) != '') {
                     $build = new entities\Build($request['build_id']);
                     $build->setName($b_name);
                     $build->setVersion($request->getParameter('ver_mj', 0), $request->getParameter('ver_mn', 0), $request->getParameter('ver_rev', 0));
                     $build->setReleased((bool) $request['isreleased']);
                     $build->setLocked((bool) $request['locked']);
                     if ($request['milestone'] && ($milestone = entities\Milestone::getB2DBTable()->selectById($request['milestone']))) {
                         $build->setMilestone($milestone);
                     } else {
                         $build->clearMilestone();
                     }
                     if ($request['edition'] && ($edition = entities\Edition::getB2DBTable()->selectById($request['edition']))) {
                         $build->setEdition($edition);
                     } else {
                         $build->clearEdition();
                     }
                     $release_date = null;
                     if ($request['has_release_date']) {
                         $release_date = mktime($request['release_hour'], $request['release_minute'], 1, $request['release_month'], $request['release_day'], $request['release_year']);
                     }
                     $build->setReleaseDate($release_date);
                     switch ($request->getParameter('download', 'leave_file')) {
                         case '0':
                             $build->clearFile();
                             $build->setFileURL('');
                             break;
                         case 'upload_file':
                             if ($build->hasFile()) {
                                 $build->getFile()->delete();
                                 $build->clearFile();
                             }
                             $file = framework\Context::getRequest()->handleUpload('upload_file');
                             $build->setFile($file);
                             $build->setFileURL('');
                             break;
                         case 'url':
                             $build->clearFile();
                             $build->setFileURL($request['file_url']);
                             break;
                     }
                     if (!$build->getID()) {
                         $build->setProject($this->selected_project);
                     }
                     $build->save();
                 } else {
                     throw new \Exception($i18n->__('You need to specify a name for the release'));
                 }
             } else {
                 throw new \Exception($i18n->__('You do not have access to this project'));
             }
         } catch (\Exception $e) {
             framework\Context::setMessage('build_error', $e->getMessage());
         }
         $this->forward(framework\Context::getRouting()->generate('project_release_center', array('project_key' => $this->selected_project->getKey())));
     }
     return $this->forward403($i18n->__("You don't have access to add releases"));
 }
         echo __("Issuetype changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_CATEGORY:
     echo image_tag('icon_category.png');
     if ($item->hasChangeDetails()) {
         $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getName()) : __('Unknown') : __('Not determined');
         $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getName()) : __('Unknown') : __('Not determined');
         echo __("Category changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_MILESTONE:
     echo image_tag('icon_milestone.png');
     if ($item->hasChangeDetails()) {
         $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getName()) : __('Unknown') : __('Not determined');
         $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getName()) : __('Unknown') : __('Not determined');
         echo __("Milestone changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_OWNED:
     echo image_tag('icon_user.png');
     if ($item->hasChangeDetails()) {
         echo __("Owned by changed to %user", array('%user' => '<strong>' . $item->getText() . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_POSTED:
     echo image_tag('icon_user.png');
     if ($item->hasChangeDetails()) {
         $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         echo __("Posted by changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
Example #6
0
 public function toJSON()
 {
     $return_values = array('id' => $this->getID(), 'issue_no' => $this->getFormattedIssueNo(), 'state' => $this->getState(), 'created_at' => $this->getPosted(), 'updated_at' => $this->getLastUpdatedTime(), 'title' => $this->getRawTitle(), 'posted_by' => $this->getPostedBy() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getPostedBy()->toJSON() : null, 'assignee' => $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->toJSON() : null, 'status' => $this->getStatus() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getStatus()->toJSON() : null);
     $fields = $this->getProject()->getVisibleFieldsArray($this->getIssueType());
     foreach ($fields as $field => $details) {
         $identifiable = true;
         switch ($field) {
             case 'shortname':
             case 'description':
             case 'votes':
                 $identifiable = false;
             case 'resolution':
             case 'priority':
             case 'severity':
             case 'category':
             case 'reproducability':
                 $method = 'get' . ucfirst($field);
                 $value = $this->{$method}();
                 break;
             case 'milestone':
                 $method = 'get' . ucfirst($field);
                 $value = $this->{$method}();
                 if (is_numeric($value) && $value == 0) {
                     $value = new Milestone();
                     $value->setID(0);
                 }
                 break;
             case 'owner':
                 $value = $this->getOwner();
                 break;
             case 'assignee':
                 $value = $this->getAssignee();
                 break;
             case 'percent_complete':
                 $value = $this->getPercentCompleted();
                 $identifiable = false;
                 break;
             case 'user_pain':
                 $value = $this->getUserPain();
                 $identifiable = false;
                 break;
             case 'reproduction_steps':
                 $value = $this->getReproductionSteps();
                 $identifiable = false;
                 break;
             case 'estimated_time':
                 $value = $this->getEstimatedTime();
                 $identifiable = false;
                 break;
             case 'spent_time':
                 $value = $this->getSpentTime();
                 $identifiable = false;
                 break;
             case 'build':
             case 'edition':
             case 'component':
                 break;
             default:
                 $value = $this->getCustomField($field);
                 $identifiable = false;
                 break;
         }
         if (isset($value)) {
             if ($identifiable) {
                 $return_values[$field] = $value instanceof \thebuggenie\core\entities\common\Identifiable ? $value->toJSON() : null;
             } else {
                 $return_values[$field] = $value;
             }
         }
     }
     $comments = array();
     foreach ($this->getComments() as $comment) {
         $comments[$comment->getCommentNumber()] = $comment->toJSON();
     }
     $return_values['comments'] = $comments;
     $return_values['visible_fields'] = $fields;
     return $return_values;
 }
 public function getRuleOptions()
 {
     if ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_STATUS_VALID) {
         $options = \thebuggenie\core\entities\Status::getAll();
     } elseif ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_PRIORITY_VALID) {
         $options = \thebuggenie\core\entities\Priority::getAll();
     } elseif ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID) {
         $options = \thebuggenie\core\entities\Resolution::getAll();
     } elseif ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID) {
         $options = \thebuggenie\core\entities\Reproducability::getAll();
     } elseif ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID) {
         $options = \thebuggenie\core\entities\Team::getAll();
     } elseif ($this->getRule() == \thebuggenie\core\entities\WorkflowTransitionValidationRule::RULE_ISSUE_IN_MILESTONE_VALID) {
         $options = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectAll();
     } elseif ($this->isCustom()) {
         $options = $this->getCustomField()->getOptions();
     }
     return $options;
 }
Example #8
0
 protected function _getMilestoneFromRequest($request)
 {
     if ($request->hasParameter('milestone_id')) {
         try {
             $milestone = entities\Milestone::getB2DBTable()->selectById((int) $request['milestone_id']);
             if ($milestone instanceof entities\Milestone && !$milestone->hasAccess()) {
                 $milestone = null;
             }
             return $milestone;
         } catch (\Exception $e) {
         }
     }
 }
Example #9
0
 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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_user_pain':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . '% &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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 . ' &rArr; ' . $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;
 }
Example #10
0
                </tr>
                <tr>
                    <td><label for="milestone_percentage_type_<?php 
echo $milestone->getID();
?>
"><?php 
echo __('Percentage type');
?>
</label></td>
                    <td>
                        <select name="percentage_type" id="milestone_percentage_type_<?php 
echo $milestone->getID();
?>
">
                            <?php 
foreach (Milestone::getPercentageTypes() as $percentage_type_key => $percentage_type_text) {
    ?>
                                <option value="<?php 
    echo $percentage_type_key;
    ?>
"<?php 
    if ($milestone->getPercentageType() == $percentage_type_key) {
        ?>
 selected<?php 
    }
    ?>
><?php 
    echo $percentage_type_text;
    ?>
</option>
                            <?php 
Example #11
0
 public function runBulkUpdateIssues(framework\Request $request)
 {
     $issue_ids = $request['issue_ids'];
     $options = array('issue_ids' => array_values($issue_ids));
     framework\Context::loadLibrary('common');
     $options['last_updated'] = tbg_formatTime(time(), 20);
     if (!empty($issue_ids)) {
         $options['bulk_action'] = $request['bulk_action'];
         switch ($request['bulk_action']) {
             case 'assign_milestone':
                 $milestone = null;
                 if ($request['milestone'] == 'new') {
                     $milestone = new entities\Milestone();
                     $milestone->setProject(framework\Context::getCurrentProject());
                     $milestone->setName($request['milestone_name']);
                     $milestone->save();
                     $options['milestone_url'] = framework\Context::getRouting()->generate('agile_milestone', array('project_key' => $milestone->getProject()->getKey(), 'milestone_id' => $milestone->getID()));
                 } elseif ($request['milestone']) {
                     $milestone = new entities\Milestone($request['milestone']);
                 }
                 $milestone_id = $milestone instanceof entities\Milestone ? $milestone->getID() : null;
                 foreach (array_keys($issue_ids) as $issue_id) {
                     if (is_numeric($issue_id)) {
                         $issue = new entities\Issue($issue_id);
                         $issue->setMilestone($milestone_id);
                         $issue->save();
                     }
                 }
                 $options['milestone_id'] = $milestone_id;
                 $options['milestone_name'] = $milestone_id ? $milestone->getName() : '-';
                 break;
             case 'set_status':
                 if (is_numeric($request['status'])) {
                     $status = new entities\Status($request['status']);
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $issue->setStatus($status->getID());
                             $issue->save();
                         }
                     }
                     $options['status'] = array('color' => $status->getColor(), 'name' => $status->getName(), 'id' => $status->getID());
                 }
                 break;
             case 'set_severity':
                 if (is_numeric($request['severity'])) {
                     $severity = $request['severity'] ? new entities\Severity($request['severity']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $severity_id = $severity instanceof entities\Severity ? $severity->getID() : 0;
                             $issue->setSeverity($severity_id);
                             $issue->save();
                         }
                     }
                     $options['severity'] = array('name' => $severity instanceof entities\Severity ? $severity->getName() : '-', 'id' => $severity instanceof entities\Severity ? $severity->getID() : 0);
                 }
                 break;
             case 'set_resolution':
                 if (is_numeric($request['resolution'])) {
                     $resolution = $request['resolution'] ? new entities\Resolution($request['resolution']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $resolution_id = $resolution instanceof entities\Resolution ? $resolution->getID() : 0;
                             $issue->setResolution($resolution_id);
                             $issue->save();
                         }
                     }
                     $options['resolution'] = array('name' => $resolution instanceof entities\Resolution ? $resolution->getName() : '-', 'id' => $resolution instanceof entities\Resolution ? $resolution->getID() : 0);
                 }
                 break;
             case 'set_priority':
                 if (is_numeric($request['priority'])) {
                     $priority = $request['priority'] ? new entities\Priority($request['priority']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $priority_id = $priority instanceof entities\Priority ? $priority->getID() : 0;
                             $issue->setPriority($priority_id);
                             $issue->save();
                         }
                     }
                     $options['priority'] = array('name' => $priority instanceof entities\Priority ? $priority->getName() : '-', 'id' => $priority instanceof entities\Priority ? $priority->getID() : 0);
                 }
                 break;
             case 'set_category':
                 if (is_numeric($request['category'])) {
                     $category = $request['category'] ? new entities\Category($request['category']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $category_id = $category instanceof entities\Category ? $category->getID() : 0;
                             $issue->setCategory($category_id);
                             $issue->save();
                         }
                     }
                     $options['category'] = array('name' => $category instanceof entities\Category ? $category->getName() : '-', 'id' => $category instanceof entities\Category ? $category->getID() : 0);
                 }
                 break;
         }
     }
     return $this->renderJSON($options);
 }
Example #12
0
 protected function _getMilestoneFromRequest($request)
 {
     if ($request->hasParameter('milestone_id')) {
         try {
             $milestone = entities\Milestone::getB2DBTable()->selectById((int) $request['milestone_id']);
             return $milestone;
         } catch (\Exception $e) {
         }
     }
 }
Example #13
0
 public function runDoImportCSV(framework\Request $request)
 {
     try {
         if ($request['csv_data'] == '') {
             throw new \Exception($this->getI18n()->__('No data supplied to import'));
         }
         $csv = str_replace("\r\n", "\n", $request['csv_data']);
         $csv = html_entity_decode($csv);
         $headerrow = null;
         $data = array();
         $errors = array();
         // Parse CSV
         $handle = fopen("php://memory", 'r+');
         fputs($handle, $csv);
         rewind($handle);
         $i = 0;
         while (($row = fgetcsv($handle, 1000)) !== false) {
             if (!$headerrow) {
                 $headerrow = $row;
             } else {
                 if (count($headerrow) == count($row)) {
                     $data[] = array_combine($headerrow, $row);
                 } else {
                     $errors[] = $this->getI18n()->__('Row %row does not have the same number of elements as the header row', array('%row' => $i));
                 }
             }
             $i++;
         }
         fclose($handle);
         if (empty($data)) {
             throw new \Exception($this->getI18n()->__('Insufficient data to import'));
         }
         // Verify required columns are present based on type
         $requiredcols = array(self::CSV_TYPE_CLIENTS => array(self::CSV_CLIENT_NAME), self::CSV_TYPE_PROJECTS => array(self::CSV_PROJECT_NAME), self::CSV_TYPE_ISSUES => array(self::CSV_ISSUE_TITLE, self::CSV_ISSUE_PROJECT, self::CSV_ISSUE_ISSUE_TYPE));
         if (!isset($requiredcols[$request['type']])) {
             throw new \Exception('Sorry, this type is unimplemented');
         }
         foreach ($requiredcols[$request['type']] as $col) {
             if (!in_array($col, $headerrow)) {
                 $errors[] = $this->getI18n()->__('Required column \'%col\' not found in header row', array('%col' => $col));
             }
         }
         // Check if rows are long enough and fields are not empty
         for ($i = 0; $i != count($data); $i++) {
             $activerow = $data[$i];
             // Check if fields are empty
             foreach ($activerow as $col => $val) {
                 if (strlen($val) == 0) {
                     $errors[] = $this->getI18n()->__('Row %row column %col has no value', array('%col' => $col, '%row' => $i + 1));
                 }
             }
         }
         if (count($errors) == 0) {
             // Check if fields are valid
             switch ($request['type']) {
                 case self::CSV_TYPE_PROJECTS:
                     for ($i = 0; $i != count($data); $i++) {
                         $activerow = $data[$i];
                         // Check if project exists
                         $key = str_replace(' ', '', $activerow[self::CSV_PROJECT_NAME]);
                         $key = mb_strtolower($key);
                         $tmp = entities\Project::getByKey($key);
                         if ($tmp !== null) {
                             $errors[] = $this->getI18n()->__('Row %row: A project with this name already exists', array('%row' => $i + 1));
                         }
                         // First off are booleans
                         $boolitems = array(self::CSV_PROJECT_SCRUM, self::CSV_PROJECT_ALLOW_REPORTING, self::CSV_PROJECT_AUTOASSIGN, self::CSV_PROJECT_FREELANCE, self::CSV_PROJECT_EN_BUILDS, self::CSV_PROJECT_EN_COMPS, self::CSV_PROJECT_EN_EDITIONS, self::CSV_PROJECT_SHOW_SUMMARY);
                         foreach ($boolitems as $boolitem) {
                             if (array_key_exists($boolitem, $activerow) && isset($activerow[$boolitem]) && $activerow[$boolitem] != 1 && $activerow[$boolitem] != 0) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1/0)', array('%col' => $boolitem, '%row' => $i + 1));
                             }
                         }
                         // Now identifiables
                         $identifiableitems = array(array(self::CSV_PROJECT_QA, self::CSV_PROJECT_QA_TYPE), array(self::CSV_PROJECT_LEAD, self::CSV_PROJECT_LEAD_TYPE), array(self::CSV_PROJECT_OWNER, self::CSV_PROJECT_OWNER_TYPE));
                         foreach ($identifiableitems as $identifiableitem) {
                             if (!array_key_exists($identifiableitem[1], $activerow) && array_key_exists($identifiableitem[0], $activerow) || array_key_exists($identifiableitem[1], $activerow) && !array_key_exists($identifiableitem[0], $activerow)) {
                                 $errors[] = $this->getI18n()->__('Row %row: Both the type and item ID must be supplied for owner/lead/qa fields', array('%row' => $i + 1));
                                 continue;
                             }
                             if (array_key_exists($identifiableitem[1], $activerow) && isset($activerow[$identifiableitem[1]]) !== null && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_USER && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_TEAM) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1 for a user or 2 for a team)', array('%col' => $identifiableitem[1], '%row' => $i + 1));
                             }
                             if (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && !is_numeric($activerow[$identifiableitem[0]])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                             } elseif (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && is_numeric($activerow[$identifiableitem[0]])) {
                                 // check if they exist
                                 switch ($activerow[$identifiableitem[1]]) {
                                     case self::CSV_IDENTIFIER_TYPE_USER:
                                         try {
                                             entities\User::getB2DBTable()->selectByID($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: user does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
                                         break;
                                     case self::CSV_IDENTIFIER_TYPE_TEAM:
                                         try {
                                             entities\Team::getB2DBTable()->selectById($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: team does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
                                         break;
                                 }
                             }
                         }
                         // Now check client exists
                         if (array_key_exists(self::CSV_PROJECT_CLIENT, $activerow) && isset($activerow[self::CSV_PROJECT_CLIENT])) {
                             if (!is_numeric($activerow[self::CSV_PROJECT_CLIENT])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_PROJECT_CLIENT, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Client::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_CLIENT]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: client does not exist', array('%col' => self::CSV_PROJECT_CLIENT, '%row' => $i + 1));
                                 }
                             }
                         }
                         // Now check if workflow exists
                         if (array_key_exists(self::CSV_PROJECT_WORKFLOW_ID, $activerow) && isset($activerow[self::CSV_PROJECT_WORKFLOW_ID])) {
                             if (!is_numeric($activerow[self::CSV_PROJECT_WORKFLOW_ID])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_PROJECT_WORKFLOW_ID, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\WorkflowScheme::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_WORKFLOW_ID]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: workflow scheme does not exist', array('%col' => self::CSV_PROJECT_WORKFLOW_ID, '%row' => $i + 1));
                                 }
                             }
                         }
                         // Now check if issuetype scheme
                         if (array_key_exists(self::CSV_PROJECT_ISSUETYPE_SCHEME, $activerow) && isset($activerow[self::CSV_PROJECT_ISSUETYPE_SCHEME])) {
                             if (!is_numeric($activerow[self::CSV_PROJECT_ISSUETYPE_SCHEME])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_PROJECT_ISSUETYPE_SCHEME, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\IssuetypeScheme::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_ISSUETYPE_SCHEME]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: issuetype scheme does not exist', array('%col' => self::CSV_PROJECT_ISSUETYPE_SCHEME, '%row' => $i + 1));
                                 }
                             }
                         }
                         // Finally check if the summary type is valid. At this point, your error list has probably become so big it has eaten up all your available RAM...
                         if (array_key_exists(self::CSV_PROJECT_SUMMARY_TYPE, $activerow) && isset($activerow[self::CSV_PROJECT_SUMMARY_TYPE])) {
                             if ($activerow[self::CSV_PROJECT_SUMMARY_TYPE] != 'issuetypes' && $activerow[self::CSV_PROJECT_SHOW_SUMMARY] != 'milestones') {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be \'issuetypes\' or \'milestones\')', array('%col' => self::CSV_PROJECT_SUMMARY_TYPE, '%row' => $i + 1));
                             }
                         }
                     }
                     break;
                 case self::CSV_TYPE_ISSUES:
                     for ($i = 0; $i != count($data); $i++) {
                         $activerow = $data[$i];
                         // Check if project exists
                         try {
                             $prjtmp = entities\Project::getB2DBTable()->selectByID($activerow[self::CSV_ISSUE_PROJECT]);
                         } catch (\Exception $e) {
                             $errors[] = $this->getI18n()->__('Row %row column %col: Project does not exist', array('%col' => self::CSV_ISSUE_PROJECT, '%row' => $i + 1));
                             break;
                         }
                         // First off are booleans
                         $boolitems = array(self::CSV_ISSUE_STATE, self::CSV_ISSUE_BLOCKING);
                         foreach ($boolitems as $boolitem) {
                             if (array_key_exists($boolitem, $activerow) && isset($activerow[$boolitem]) && $activerow[$boolitem] != 1 && $activerow[$boolitem] != 0) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1/0)', array('%col' => $boolitem, '%row' => $i + 1));
                             }
                         }
                         // Now numerics
                         $numericitems = array(self::CSV_ISSUE_VOTES, self::CSV_ISSUE_PERCENTAGE, self::CSV_ISSUE_ISSUENO);
                         foreach ($numericitems as $numericitem) {
                             if (array_key_exists($numericitem, $activerow) && isset($activerow[$numericitem]) && !is_numeric($activerow[$numericitem])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => $numericitem, '%row' => $i + 1));
                             }
                         }
                         // Percentage must be 0-100
                         if (array_key_exists(self::CSV_ISSUE_PERCENTAGE, $activerow) && isset($activerow[self::CSV_ISSUE_PERCENTAGE]) && ($activerow[self::CSV_ISSUE_PERCENTAGE] < 0 || $activerow[self::CSV_ISSUE_PERCENTAGE] > 100)) {
                             $errors[] = $this->getI18n()->__('Row %row column %col: Percentage must be from 0 to 100 inclusive', array('%col' => self::CSV_ISSUE_PERCENTAGE, '%row' => $i + 1));
                         }
                         // Now identifiables
                         $identifiableitems = array(array(self::CSV_ISSUE_OWNER, self::CSV_ISSUE_OWNER_TYPE), array(self::CSV_ISSUE_ASSIGNED, self::CSV_ISSUE_ASSIGNED_TYPE));
                         foreach ($identifiableitems as $identifiableitem) {
                             if (!array_key_exists($identifiableitem[1], $activerow) && array_key_exists($identifiableitem[0], $activerow) || array_key_exists($identifiableitem[1], $activerow) && !array_key_exists($identifiableitem[0], $activerow)) {
                                 $errors[] = $this->getI18n()->__('Row %row: Both the type and item ID must be supplied for owner/lead/qa fields', array('%row' => $i + 1));
                                 continue;
                             }
                             if (array_key_exists($identifiableitem[1], $activerow) && isset($activerow[$identifiableitem[1]]) && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_USER && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_TEAM) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1 for a user or 2 for a team)', array('%col' => $identifiableitem[1], '%row' => $i + 1));
                             }
                             if (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && !is_numeric($activerow[$identifiableitem[0]])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                             } elseif (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && is_numeric($activerow[$identifiableitem[0]])) {
                                 // check if they exist
                                 switch ($activerow[$identifiableitem[1]]) {
                                     case self::CSV_IDENTIFIER_TYPE_USER:
                                         try {
                                             entities\User::getB2DBTable()->selectByID($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: user does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
                                         break;
                                     case self::CSV_IDENTIFIER_TYPE_TEAM:
                                         try {
                                             entities\Team::getB2DBTable()->selectById($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: team does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
                                         break;
                                 }
                             }
                         }
                         // Now timestamps
                         if (array_key_exists(self::CSV_ISSUE_POSTED, $activerow) && isset($activerow[self::CSV_ISSUE_POSTED]) && (string) (int) $activerow[self::CSV_ISSUE_POSTED] !== $activerow[self::CSV_ISSUE_POSTED] && $activerow[self::CSV_ISSUE_POSTED] >= PHP_INT_MAX && $activerow[self::CSV_ISSUE_POSTED] <= ~PHP_INT_MAX) {
                             $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a Unix timestamp)', array('%col' => self::CSV_ISSUE_POSTED, '%row' => $i + 1));
                         }
                         // Now check user exists for postedby
                         if (array_key_exists(self::CSV_ISSUE_POSTED_BY, $activerow) && isset($activerow[self::CSV_ISSUE_POSTED_BY])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_POSTED_BY])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_POSTED_BY, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\User::getB2DBTable()->selectByID($activerow[self::CSV_ISSUE_POSTED_BY]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: user does not exist', array('%col' => self::CSV_ISSUE_POSTED_BY, '%row' => $i + 1));
                                 }
                             }
                         }
                         // Now check milestone exists and is valid
                         if (array_key_exists(self::CSV_ISSUE_MILESTONE, $activerow) && isset($activerow[self::CSV_ISSUE_MILESTONE])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_MILESTONE])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_MILESTONE, '%row' => $i + 1));
                             } else {
                                 try {
                                     $milestonetmp = entities\Milestone::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_MILESTONE]);
                                     if ($milestonetmp->getProject()->getID() != $activerow[self::CSV_ISSUE_PROJECT]) {
                                         $errors[] = $this->getI18n()->__('Row %row column %col: milestone does not apply to the specified project', array('%col' => self::CSV_ISSUE_MILESTONE, '%row' => $i + 1));
                                     }
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: milestone does not exist', array('%col' => self::CSV_ISSUE_MILESTONE, '%row' => $i + 1));
                                 }
                             }
                         }
                         // status
                         if (array_key_exists(self::CSV_ISSUE_STATUS, $activerow) && isset($activerow[self::CSV_ISSUE_STATUS])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_STATUS])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_STATUS, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Status::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_STATUS]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: status does not exist', array('%col' => self::CSV_ISSUE_STATUS, '%row' => $i + 1));
                                 }
                             }
                         }
                         // resolution
                         if (array_key_exists(self::CSV_ISSUE_RESOLUTION, $activerow) && isset($activerow[self::CSV_ISSUE_RESOLUTION])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_RESOLUTION])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_RESOLUTION, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Resolution::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_RESOLUTION]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: resolution does not exist', array('%col' => self::CSV_ISSUE_RESOLUTION, '%row' => $i + 1));
                                 }
                             }
                         }
                         // priority
                         if (array_key_exists(self::CSV_ISSUE_PRIORITY, $activerow) && isset($activerow[self::CSV_ISSUE_PRIORITY])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_PRIORITY])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_PRIORITY, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Priority::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_PRIORITY]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: priority does not exist', array('%col' => self::CSV_ISSUE_PRIORITY, '%row' => $i + 1));
                                 }
                             }
                         }
                         // category
                         if (array_key_exists(self::CSV_ISSUE_CATEGORY, $activerow) && isset($activerow[self::CSV_ISSUE_CATEGORY])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_CATEGORY])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_CATEGORY, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Category::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_CATEGORY]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: category does not exist', array('%col' => self::CSV_ISSUE_CATEGORY, '%row' => $i + 1));
                                 }
                             }
                         }
                         // severity
                         if (array_key_exists(self::CSV_ISSUE_SEVERITY, $activerow) && isset($activerow[self::CSV_ISSUE_SEVERITY])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_SEVERITY])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_SEVERITY, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Severity::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_SEVERITY]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: severity does not exist', array('%col' => self::CSV_ISSUE_SEVERITY, '%row' => $i + 1));
                                 }
                             }
                         }
                         // reproducability
                         if (array_key_exists(self::CSV_ISSUE_REPRODUCIBILITY, $activerow) && isset($activerow[self::CSV_ISSUE_REPRODUCIBILITY])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_REPRODUCIBILITY])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_REPRODUCIBILITY, '%row' => $i + 1));
                             } else {
                                 try {
                                     entities\Reproducability::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_REPRODUCIBILITY]);
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: reproducability does not exist', array('%col' => self::CSV_ISSUE_REPRODUCIBILITY, '%row' => $i + 1));
                                 }
                             }
                         }
                         // type
                         if (array_key_exists(self::CSV_ISSUE_ISSUE_TYPE, $activerow) && isset($activerow[self::CSV_ISSUE_ISSUE_TYPE])) {
                             if (!is_numeric($activerow[self::CSV_ISSUE_ISSUE_TYPE])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => self::CSV_ISSUE_ISSUE_TYPE, '%row' => $i + 1));
                             } else {
                                 try {
                                     $typetmp = entities\Issuetype::getB2DBTable()->selectById($activerow[self::CSV_ISSUE_ISSUE_TYPE]);
                                     if (!$prjtmp->getIssuetypeScheme()->isSchemeAssociatedWithIssuetype($typetmp)) {
                                         $errors[] = $this->getI18n()->__('Row %row column %col: this project does not support issues of this type (%type)', array('%type' => $typetmp->getName(), '%col' => self::CSV_ISSUE_ISSUE_TYPE, '%row' => $i + 1));
                                     }
                                 } catch (\Exception $e) {
                                     $errors[] = $this->getI18n()->__('Row %row column %col: issue type does not exist', array('%col' => self::CSV_ISSUE_ISSUE_TYPE, '%row' => $i + 1));
                                 }
                             }
                         }
                     }
                     break;
             }
         }
         // Handle errors
         if (count($errors) != 0) {
             $errordiv = '<ul>';
             foreach ($errors as $error) {
                 $errordiv .= '<li>' . $error . '</li>';
             }
             $errordiv .= '</ul>';
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('errordetail' => $errordiv, 'error' => $this->getI18n()->__('Errors occured while importing, see the error list in the import screen for further details')));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('errordetail' => $e->getMessage(), 'error' => $e->getMessage()));
     }
     if ($request['csv_dry_run']) {
         return $this->renderJSON(array('message' => $this->getI18n()->__('Dry-run successful, you can now uncheck the dry-run box and import your data.')));
     } else {
         switch ($request['type']) {
             case self::CSV_TYPE_CLIENTS:
                 for ($i = 0; $i != count($data); $i++) {
                     try {
                         $activerow = $data[$i];
                         $client = new entities\Client();
                         $client->setName($activerow[self::CSV_CLIENT_NAME]);
                         if (isset($activerow[self::CSV_CLIENT_EMAIL])) {
                             $client->setEmail($activerow[self::CSV_CLIENT_EMAIL]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_WEBSITE])) {
                             $client->setWebsite($activerow[self::CSV_CLIENT_WEBSITE]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_FAX])) {
                             $client->setFax($activerow[self::CSV_CLIENT_FAX]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_TELEPHONE])) {
                             $client->setTelephone($activerow[self::CSV_CLIENT_TELEPHONE]);
                         }
                         $client->save();
                     } catch (\Exception $e) {
                         $errors[] = $this->getI18n()->__('Row %row failed: %err', array('%row' => $i + 1, '%err' => $e->getMessage()));
                     }
                 }
                 break;
             case self::CSV_TYPE_PROJECTS:
                 for ($i = 0; $i != count($data); $i++) {
                     try {
                         $activerow = $data[$i];
                         $project = new entities\Project();
                         $project->setName($activerow[self::CSV_PROJECT_NAME]);
                         $project->save();
                         if (isset($activerow[self::CSV_PROJECT_PREFIX])) {
                             $project->setPrefix($activerow[self::CSV_PROJECT_PREFIX]);
                             $project->setUsePrefix(true);
                         }
                         if (isset($activerow[self::CSV_PROJECT_SCRUM])) {
                             if ($activerow[self::CSV_PROJECT_SCRUM] == '1') {
                                 $project->setUsesScrum(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_OWNER]) && isset($activerow[self::CSV_PROJECT_OWNER_TYPE])) {
                             switch ($activerow[self::CSV_PROJECT_OWNER_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_PROJECT_OWNER]);
                                     $project->setOwner($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_PROJECT_OWNER]);
                                     $project->setOwner($team);
                                     break;
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_LEAD]) && isset($activerow[self::CSV_PROJECT_LEAD_TYPE])) {
                             switch ($activerow[self::CSV_PROJECT_LEAD_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_PROJECT_LEAD]);
                                     $project->setLeader($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_PROJECT_LEAD]);
                                     $project->setLeader($team);
                                     break;
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_QA]) && isset($activerow[self::CSV_PROJECT_QA_TYPE])) {
                             switch ($activerow[self::CSV_PROJECT_QA_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_PROJECT_QA]);
                                     $project->setQaResponsible($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_PROJECT_QA]);
                                     $project->setQaResponsible($team);
                                     break;
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_DESCR])) {
                             $project->setDescription($activerow[self::CSV_PROJECT_DESCR]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_DOC_URL])) {
                             $project->setDocumentationUrl($activerow[self::CSV_PROJECT_DOC_URL]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_WIKI_URL])) {
                             $project->setWikiUrl($activerow[self::CSV_PROJECT_WIKI_URL]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_FREELANCE])) {
                             if ($activerow[self::CSV_PROJECT_FREELANCE] == '1') {
                                 $project->setChangeIssuesWithoutWorkingOnThem(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_EN_BUILDS])) {
                             if ($activerow[self::CSV_PROJECT_EN_BUILDS] == '1') {
                                 $project->setBuildsEnabled(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_EN_COMPS])) {
                             if ($activerow[self::CSV_PROJECT_EN_COMPS] == '1') {
                                 $project->setComponentsEnabled(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_EN_EDITIONS])) {
                             if ($activerow[self::CSV_PROJECT_EN_EDITIONS] == '1') {
                                 $project->setEditionsEnabled(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_CLIENT])) {
                             $project->setClient(entities\Client::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_CLIENT]));
                         }
                         if (isset($activerow[self::CSV_PROJECT_SHOW_SUMMARY])) {
                             if ($activerow[self::CSV_PROJECT_SHOW_SUMMARY] == '1') {
                                 $project->setFrontpageSummaryVisibility(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_SUMMARY_TYPE])) {
                             $project->setFrontpageSummaryType($activerow[self::CSV_PROJECT_SUMMARY_TYPE]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_ALLOW_REPORTING])) {
                             $project->setLocked($activerow[self::CSV_PROJECT_ALLOW_REPORTING]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_AUTOASSIGN])) {
                             $project->setAutoassign($activerow[self::CSV_PROJECT_AUTOASSIGN]);
                         }
                         if (isset($activerow[self::CSV_PROJECT_ISSUETYPE_SCHEME])) {
                             $project->setIssuetypeScheme(entities\IssuetypeScheme::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_ISSUETYPE_SCHEME]));
                         }
                         if (isset($activerow[self::CSV_PROJECT_WORKFLOW_ID])) {
                         }
                         $project->setWorkflowScheme(entities\WorkflowScheme::getB2DBTable()->selectById($activerow[self::CSV_PROJECT_WORKFLOW_ID]));
                         $project->save();
                     } catch (\Exception $e) {
                         $errors[] = $this->getI18n()->__('Row %row failed: %err', array('%row' => $i + 1, '%err' => $e->getMessage()));
                     }
                 }
                 break;
             case self::CSV_TYPE_ISSUES:
                 for ($i = 0; $i != count($data); $i++) {
                     try {
                         $activerow = $data[$i];
                         $issue = new entities\Issue();
                         $issue->setTitle($activerow[self::CSV_ISSUE_TITLE]);
                         $issue->setProject($activerow[self::CSV_ISSUE_PROJECT]);
                         $issue->setIssuetype($activerow[self::CSV_ISSUE_ISSUE_TYPE]);
                         $issue->save();
                         if (isset($activerow[self::CSV_ISSUE_DESCR])) {
                             $issue->setDescription($activerow[self::CSV_ISSUE_DESCR]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_REPRO])) {
                             $issue->setReproductionSteps($activerow[self::CSV_ISSUE_REPRO]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_STATE])) {
                             $issue->setState($activerow[self::CSV_ISSUE_STATE]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_STATUS])) {
                             $issue->setStatus($activerow[self::CSV_ISSUE_STATUS]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_POSTED_BY])) {
                             $issue->setPostedBy(entities\User::getB2DBTable()->selectByID($activerow[self::CSV_ISSUE_POSTED_BY]));
                         }
                         if (isset($activerow[self::CSV_ISSUE_OWNER]) && isset($activerow[self::CSV_ISSUE_OWNER_TYPE])) {
                             switch ($activerow[self::CSV_ISSUE_OWNER_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_ISSUE_OWNER]);
                                     $issue->setOwner($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_ISSUE_OWNER]);
                                     $issue->setOwner($team);
                                     break;
                             }
                         }
                         if (isset($activerow[self::CSV_ISSUE_ASSIGNED]) && isset($activerow[self::CSV_ISSUE_ASSIGNED_TYPE])) {
                             switch ($activerow[self::CSV_ISSUE_ASSIGNED_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_ISSUE_ASSIGNED]);
                                     $issue->setAssignee($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_ISSUE_ASSIGNED]);
                                     $issue->setAssignee($team);
                                     break;
                             }
                         }
                         if (isset($activerow[self::CSV_ISSUE_RESOLUTION])) {
                             $issue->setResolution($activerow[self::CSV_ISSUE_RESOLUTION]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_PRIORITY])) {
                             $issue->setPriority($activerow[self::CSV_ISSUE_PRIORITY]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_CATEGORY])) {
                             $issue->setCategory($activerow[self::CSV_ISSUE_CATEGORY]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_BLOCKING])) {
                             $issue->setBlocking($activerow[self::CSV_ISSUE_BLOCKING]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_SEVERITY])) {
                             $issue->setSeverity($activerow[self::CSV_ISSUE_SEVERITY]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_REPRODUCIBILITY])) {
                             $issue->setReproducability($activerow[self::CSV_ISSUE_REPRODUCIBILITY]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_VOTES])) {
                             $issue->setVotes($activerow[self::CSV_ISSUE_VOTES]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_PERCENTAGE])) {
                             $issue->setPercentCompleted($activerow[self::CSV_ISSUE_PERCENTAGE]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_ISSUENO])) {
                             $issue->setIssueNo((int) $activerow[self::CSV_ISSUE_ISSUENO]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_MILESTONE])) {
                             $issue->setMilestone($activerow[self::CSV_ISSUE_MILESTONE]);
                         }
                         if (isset($activerow[self::CSV_ISSUE_POSTED])) {
                             $issue->setPosted((int) $activerow[self::CSV_ISSUE_POSTED]);
                         }
                         $issue->save();
                     } catch (\Exception $e) {
                         $errors[] = $this->getI18n()->__('Row %row failed: %err', array('%row' => $i + 1, '%err' => $e->getMessage()));
                     }
                 }
                 break;
         }
         // Handle errors
         if (count($errors) != 0) {
             $errordiv = '<ul>';
             foreach ($errors as $error) {
                 $errordiv .= '<li>' . $error . '</li>';
             }
             $errordiv .= '</ul>';
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('errordetail' => $errordiv, 'error' => $this->getI18n()->__('Errors occured while importing, see the error list in the import screen for further details')));
         } else {
             return $this->renderJSON(array('message' => $this->getI18n()->__('Successfully imported %num rows!', array('%num' => count($data)))));
         }
     }
 }
Example #14
0
 /**
  * The project board whiteboard page
  *
  * @Route(url="/boards/:board_id/whiteboard/issues/*")
  * @CsrfProtected
  *
  * @param framework\Request $request
  */
 public function runWhiteboardIssues(framework\Request $request)
 {
     $this->forward403unless($this->_checkProjectPageAccess('agile_board'));
     $this->board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
     $this->forward403unless($this->board instanceof entities\AgileBoard);
     try {
         if ($request->isPost()) {
             $issue = \thebuggenie\core\entities\tables\Issues::getTable()->selectById((int) $request['issue_id']);
             $column = entities\BoardColumn::getB2DBTable()->selectById((int) $request['column_id']);
             $milestone = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById((int) $request['milestone_id']);
             $swimlane = null;
             if ($request['swimlane_identifier']) {
                 foreach ($column->getBoard()->getMilestoneSwimlanes($milestone) as $swimlane) {
                     if ($swimlane->getIdentifier() == $request['swimlane_identifier']) {
                         break;
                     }
                 }
             }
             if ($request->hasParameter('transition_id')) {
                 $transitions = array(\thebuggenie\core\entities\tables\WorkflowTransitions::getTable()->selectById((int) $request['transition_id']));
             } else {
                 list($status_ids, $transitions) = $issue->getAvailableWorkflowStatusIDsAndTransitions();
                 $available_statuses = array_intersect($status_ids, $column->getStatusIds());
                 if (empty($available_statuses)) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => $this->getI18n()->__('There are no valid transitions to any states in this column')));
                 }
                 if (count($available_statuses) > 1) {
                     return $this->renderJSON(array('component' => $this->getComponentHTML('agile/whiteboardtransitionselector', array('issue' => $issue, 'transitions' => $transitions, 'statuses' => $available_statuses, 'new_column' => $column, 'board' => $column->getBoard(), 'swimlane_identifier' => $request['swimlane_identifier']))));
                 }
             }
             current($transitions)->transitionIssueToOutgoingStepWithoutRequest($issue);
             return $this->renderJSON(array('transition' => 'ok', 'issue' => $this->getComponentHTML('agile/whiteboardissue', array('issue' => $issue, 'column' => $column, 'swimlane' => $swimlane))));
         } else {
             $milestone = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $request['milestone_id']);
             return $this->renderJSON(array('component' => $this->getComponentHTML('agile/whiteboardcontent', array('board' => $this->board, 'milestone' => $milestone))));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }