Exemplo n.º 1
0
 public static function loadFixtures(\thebuggenie\core\entities\Scope $scope)
 {
     Category::loadFixtures($scope);
     Priority::loadFixtures($scope);
     Reproducability::loadFixtures($scope);
     Resolution::loadFixtures($scope);
     Severity::loadFixtures($scope);
     Status::loadFixtures($scope);
     Role::loadFixtures($scope);
     ActivityType::loadFixtures($scope);
     foreach (self::getTypes() as $type => $class) {
         framework\Context::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID());
     }
 }
Exemplo n.º 2
0
 public static function loadFixtures(\thebuggenie\core\entities\Scope $scope, \thebuggenie\core\entities\Workflow $workflow)
 {
     $steps = array();
     $steps['new'] = array('name' => 'New', 'description' => 'A new issue, not yet handled', 'status_id' => Status::getByKeyish('new')->getID(), 'transitions' => array('investigateissue', 'confirmissue', 'rejectissue', 'acceptissue', 'resolveissue'), 'editable' => true, 'is_closed' => false);
     $steps['investigating'] = array('name' => 'Investigating', 'description' => 'An issue that is being investigated, looked into or is by other means between new and unconfirmed state', 'status_id' => Status::getByKeyish('investigating')->getID(), 'transitions' => array('requestmoreinformation', 'confirmissue', 'rejectissue', 'acceptissue'), 'editable' => true, 'is_closed' => false);
     $steps['confirmed'] = array('name' => 'Confirmed', 'description' => 'An issue that has been confirmed', 'status_id' => Status::getByKeyish('confirmed')->getID(), 'transitions' => array('acceptissue', 'assignissue', 'resolveissue'), 'editable' => false, 'is_closed' => false);
     $steps['inprogress'] = array('name' => 'In progress', 'description' => 'An issue that is being adressed', 'status_id' => Status::getByKeyish('beingworkedon')->getID(), 'transitions' => array('rejectissue', 'markreadyfortesting', 'resolveissue'), 'editable' => false, 'is_closed' => false);
     $steps['readyfortesting'] = array('name' => 'Ready for testing', 'description' => 'An issue that has been marked fixed and is ready for testing', 'status_id' => Status::getByKeyish('readyfortesting/qa')->getID(), 'transitions' => array('resolveissue', 'testissuesolution'), 'editable' => false, 'is_closed' => false);
     $steps['testing'] = array('name' => 'Testing', 'description' => 'An issue where the proposed or implemented solution is currently being tested or approved', 'status_id' => Status::getByKeyish('testing/qa')->getID(), 'transitions' => array('acceptissuesolution', 'rejectissuesolution'), 'editable' => false, 'is_closed' => false);
     $steps['rejected'] = array('name' => 'Rejected', 'description' => 'A closed issue that has been rejected', 'status_id' => Status::getByKeyish('notabug')->getID(), 'transitions' => array('reopenissue'), 'editable' => false, 'is_closed' => true);
     $steps['closed'] = array('name' => 'Closed', 'description' => 'A closed issue', 'status_id' => null, 'transitions' => array('reopenissue'), 'editable' => false, 'is_closed' => true);
     foreach ($steps as $key => $step) {
         $step_object = new \thebuggenie\core\entities\WorkflowStep();
         $step_object->setWorkflow($workflow);
         $step_object->setName($step['name']);
         $step_object->setDescription($step['description']);
         $step_object->setLinkedStatusID($step['status_id']);
         $step_object->setIsClosed($step['is_closed']);
         $step_object->setIsEditable($step['editable']);
         $step_object->save();
         $steps[$key]['step'] = $step_object;
     }
     $transitions = WorkflowTransition::loadFixtures($scope, $workflow, $steps);
     $transition = new \thebuggenie\core\entities\WorkflowTransition();
     $step = $steps['new']['step'];
     $transition->setOutgoingStep($step);
     $transition->setName('Issue created');
     $transition->setWorkflow($workflow);
     $transition->setDescription('This is the initial transition for issues using this workflow');
     $transition->save();
     $workflow->setInitialTransition($transition);
     $workflow->save();
     foreach ($steps as $step) {
         foreach ($step['transitions'] as $transition) {
             $step['step']->addOutgoingTransition($transitions[$transition]);
         }
     }
 }
Exemplo n.º 3
0
 public function loadFixtures(\thebuggenie\core\entities\Scope $scope)
 {
     $steps = array();
     $steps[] = array('name' => 'New', 'description' => 'A new issue, not yet handled', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('new')->getID(), 'editable' => true, 'is_closed' => false);
     $steps[] = array('name' => 'Investigating', 'description' => 'An issue that is being investigated, looked into or is by other means between new and unconfirmed state', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('investigating')->getID(), 'editable' => true, 'is_closed' => false);
     $steps[] = array('name' => 'Confirmed', 'description' => 'An issue that has been confirmed', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('confirmed')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'In progress', 'description' => 'An issue that is being adressed', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('beingworkedon')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Ready for testing', 'description' => 'An issue that has been marked fixed and is ready for testing', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('readyfortesting/qa')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Testing', 'description' => 'An issue where the proposed or implemented solution is currently being tested or approved', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('testing/qa')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Rejected', 'description' => 'A closed issue that has been rejected', 'status_id' => \thebuggenie\core\entities\Status::getByKeyish('notabug')->getID(), 'editable' => false, 'is_closed' => true);
     $steps[] = array('name' => 'Closed', 'description' => 'A closed issue', 'status_id' => null, 'editable' => false, 'is_closed' => true);
     foreach ($steps as $step) {
         $crit = $this->getCriteria();
         $crit->addInsert(self::WORKFLOW_ID, 1);
         $crit->addInsert(self::SCOPE, $scope->getID());
         $crit->addInsert(self::NAME, $step['name']);
         $crit->addInsert(self::DESCRIPTION, $step['description']);
         $crit->addInsert(self::STATUS_ID, $step['status_id']);
         $crit->addInsert(self::CLOSED, $step['is_closed']);
         $crit->addInsert(self::EDITABLE, $step['editable']);
         $this->doInsert($crit);
     }
 }
Exemplo n.º 4
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)))));
         }
     }
 }
        echo __('Connected status');
        ?>
</label></dt>
                                    <dd>
                                        <select name="status_id" id="step_status">
                                            <option value="0"<?php 
        if (!$step->hasLinkedStatus()) {
            echo " selected";
        }
        ?>
><?php 
        echo __('Not connected to a status');
        ?>
</option>
                                            <?php 
        foreach (\thebuggenie\core\entities\Status::getAll() as $status) {
            ?>
                                            <option value="<?php 
            echo $status->getID();
            ?>
"<?php 
            if ($step->hasLinkedStatus() && $step->getLinkedStatus()->getID() == $status->getID()) {
                echo " selected";
            }
            ?>
><?php 
            echo $status->getName();
            ?>
</option>
                                            <?php 
        }
Exemplo n.º 6
0
 public function componentBoardColumnheader()
 {
     $this->statuses = \thebuggenie\core\entities\Status::getAll();
 }
Exemplo n.º 7
0
 protected function _populateStatusCount()
 {
     if ($this->_statuscount === null) {
         $this->_statuscount = array();
         $this->_statuscount[0] = array('open' => 0, 'closed' => 0, 'percentage' => 0);
         foreach (Status::getAll() as $status_id => $status) {
             $this->_statuscount[$status_id] = array('open' => 0, 'closed' => 0, 'percentage' => 0);
         }
         foreach (tables\Issues::getTable()->getStatusCountByProjectID($this->getID()) as $status_id => $status_count) {
             $this->_statuscount[$status_id] = $status_count;
         }
     }
 }
Exemplo n.º 8
0
 public function getAvailableValues()
 {
     switch ($this->getFilterKey()) {
         case 'issuetype':
             return framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getIssuetypeScheme()->getIssuetypes() : Issuetype::getAll();
         case 'status':
             return Status::getAll();
         case 'category':
             return Category::getAll();
         case 'priority':
             return Priority::getAll();
         case 'severity':
             return Severity::getAll();
         case 'reproducability':
             return Reproducability::getAll();
         case 'resolution':
             return Resolution::getAll();
         case 'project_id':
             return \thebuggenie\core\entities\Project::getAll();
         case 'build':
             return $this->_getAvailableBuildChoices();
         case 'component':
             return $this->_getAvailableComponentChoices();
         case 'edition':
             return $this->_getAvailableEditionChoices();
         case 'milestone':
             return $this->_getAvailableMilestoneChoices();
         case 'subprojects':
             $filters = array();
             $projects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject());
             foreach ($projects as $project) {
                 if ($project->getID() == framework\Context::getCurrentProject()->getID()) {
                     continue;
                 }
                 $filters[$project->getID()] = $project;
             }
             return $filters;
         case 'owner_user':
         case 'assignee_user':
         case 'posted_by':
             return $this->_getAvailableUserChoices();
         case 'owner_team':
         case 'assignee_team':
             return $this->_getAvailableTeamChoices();
         default:
             $customdatatype = CustomDatatype::getByKey($this->getFilterKey());
             if ($customdatatype instanceof \thebuggenie\core\entities\CustomDatatype && $customdatatype->hasCustomOptions()) {
                 return $customdatatype->getOptions();
             } else {
                 switch ($this->getFilterType()) {
                     case CustomDatatype::COMPONENTS_CHOICE:
                         return $this->_getAvailableComponentChoices();
                     case CustomDatatype::RELEASES_CHOICE:
                         return $this->_getAvailableBuildChoices();
                     case CustomDatatype::EDITIONS_CHOICE:
                         return $this->_getAvailableEditionChoices();
                     case CustomDatatype::MILESTONE_CHOICE:
                         return $this->_getAvailableMilestoneChoices();
                     case CustomDatatype::USER_CHOICE:
                         return $this->_getAvailableUserChoices();
                     case CustomDatatype::TEAM_CHOICE:
                         return $this->_getAvailableTeamChoices();
                     case CustomDatatype::CLIENT_CHOICE:
                         return $this->_getAvailableClientChoices();
                     case CustomDatatype::STATUS_CHOICE:
                         return Status::getAll();
                     default:
                         return array();
                 }
             }
     }
 }
Exemplo n.º 9
0
         }
     } catch (\Exception $e) {
     }
     try {
         switch ($customdatatype->getType()) {
             case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Edition::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Component::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE:
                 $new_object = \thebuggenie\core\entities\Build::getB2DBTable()->selectById($new_value);
                 break;
             case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                 $new_object = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($new_value);
                 break;
         }
     } catch (\Exception $e) {
     }
     $old_value = is_object($old_object) ? $old_object->getName() : \thebuggenie\core\framework\Context::getI18n()->__('Unknown');
     $new_value = is_object($new_object) ? $new_object->getName() : \thebuggenie\core\framework\Context::getI18n()->__('Unknown');
     break;
 default:
     $old_item = null;
     $new_item = null;
     try {
         $old_item = $old_value ? new \thebuggenie\core\entities\CustomDatatypeOption($old_value) : null;
     } catch (\Exception $e) {
     }
     try {
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
 public function componentProjectSettings()
 {
     $this->statustypes = entities\Status::getAll();
 }
                        ?>
"<?php 
                        if ($issue instanceof \thebuggenie\core\entities\Issue && $issue->getCustomField($field) instanceof \thebuggenie\core\entities\Milestone && $issue->getCustomField($field)->getID() == $choice->getID()) {
                            ?>
 selected<?php 
                        }
                        ?>
><?php 
                        echo __($choice->getName());
                        ?>
</option>
                                                <?php 
                    }
                    break;
                case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                    foreach (\thebuggenie\core\entities\Status::getAll() as $choice) {
                        ?>
                                                    <option value="<?php 
                        echo $choice->getID();
                        ?>
"<?php 
                        if ($issue instanceof \thebuggenie\core\entities\Issue && $issue->getCustomField($field) instanceof \thebuggenie\core\entities\Edition && $issue->getCustomField($field)->getID() == $choice->getID()) {
                            ?>
 selected<?php 
                        }
                        ?>
><?php 
                        echo __($choice->getName());
                        ?>
</option>
                                                <?php 
Exemplo n.º 13
0
 public function runAddAffected(framework\Request $request)
 {
     framework\Context::loadLibrary('ui');
     try {
         $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
         $statuses = entities\Status::getAll();
         switch ($request['item_type']) {
             case 'edition':
                 if (!$issue->getProject()->isEditionsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Editions are disabled')));
                 } elseif (!$issue->canEditAffectedEditions()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $edition = entities\Edition::getB2DBTable()->selectById($request['which_item_edition']);
                 if (tables\IssueAffectsEdition::getTable()->getByIssueIDandEditionID($issue->getID(), $edition->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $edition->getName()))));
                 }
                 $result = $issue->addAffectedEdition($edition);
                 if ($result !== false) {
                     $itemtype = 'edition';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Edition');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Edition <b>%edition</b> is now affected by this issue', array('%edition' => $edition->getName()), true);
                 break;
             case 'component':
                 if (!$issue->getProject()->isComponentsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Components are disabled')));
                 } elseif (!$issue->canEditAffectedComponents()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $component = entities\Component::getB2DBTable()->selectById($request['which_item_component']);
                 if (tables\IssueAffectsComponent::getTable()->getByIssueIDandComponentID($issue->getID(), $component->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $component->getName()))));
                 }
                 $result = $issue->addAffectedComponent($component);
                 if ($result !== false) {
                     $itemtype = 'component';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Component');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Component <b>%component</b> is now affected by this issue', array('%component' => $component->getName()), true);
                 break;
             case 'build':
                 if (!$issue->getProject()->isBuildsEnabled()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Releases are disabled')));
                 } elseif (!$issue->canEditAffectedBuilds()) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this')));
                 }
                 $build = entities\Build::getB2DBTable()->selectById($request['which_item_build']);
                 if (tables\IssueAffectsBuild::getTable()->getByIssueIDandBuildID($issue->getID(), $build->getID())) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $build->getName()))));
                 }
                 $result = $issue->addAffectedBuild($build);
                 if ($result !== false) {
                     $itemtype = 'build';
                     $item = $result;
                     $itemtypename = framework\Context::getI18n()->__('Release');
                     $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses));
                 }
                 $message = framework\Context::getI18n()->__('Release <b>%build</b> is now affected by this issue', array('%build' => $build->getName()), true);
                 break;
             default:
                 throw new \Exception('Internal error');
         }
         $editions = array();
         $components = array();
         $builds = array();
         if ($issue->getProject()->isEditionsEnabled()) {
             $editions = $issue->getEditions();
         }
         if ($issue->getProject()->isComponentsEnabled()) {
             $components = $issue->getComponents();
         }
         if ($issue->getProject()->isBuildsEnabled()) {
             $builds = $issue->getBuilds();
         }
         $count = count($editions) + count($components) + count($builds);
         return $this->renderJSON(array('content' => $content, 'message' => $message, 'itemcount' => $count));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Exemplo n.º 14
0
 /**
  * Return this steps linked status if any
  * 
  * @return \thebuggenie\core\entities\Status
  */
 public function getLinkedStatus()
 {
     if (is_numeric($this->_status_id)) {
         try {
             $this->_status_id = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($this->_status_id);
         } catch (\Exception $e) {
             $this->_status_id = null;
         }
     }
     return $this->_status_id;
 }
Exemplo n.º 15
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);
 }
Exemplo n.º 16
0
 protected function _calculateImageDetails($counts)
 {
     $i18n = framework\Context::getI18n();
     $labels = array();
     $values = array();
     $colors = array();
     foreach ($counts as $item_id => $details) {
         if ($this->image_number == 1) {
             $value = $details['open'] + $details['closed'];
         }
         if ($this->image_number == 2) {
             $value = $details['open'];
         }
         if ($this->image_number == 3) {
             $value = $details['closed'];
         }
         if (isset($value) && $value > 0) {
             if ($item_id != 0 || $this->key == 'issues_per_state') {
                 switch ($this->key) {
                     case 'issues_per_status':
                         $item = entities\Status::getB2DBTable()->selectById($item_id);
                         break;
                     case 'issues_per_priority':
                         $item = entities\Priority::getB2DBTable()->selectById($item_id);
                         break;
                     case 'issues_per_category':
                         $item = entities\Category::getB2DBTable()->selectById($item_id);
                         break;
                     case 'issues_per_resolution':
                         $item = entities\Resolution::getB2DBTable()->selectById($item_id);
                         break;
                     case 'issues_per_reproducability':
                         $item = entities\Reproducability::getB2DBTable()->selectById($item_id);
                         break;
                     case 'issues_per_state':
                         $item = $item_id == entities\Issue::STATE_OPEN ? $i18n->__('Open', array(), true) : $i18n->__('Closed', array(), true);
                         break;
                     default:
                         $item = null;
                 }
                 if ($this->key != 'issues_per_state') {
                     $labels[] = $item instanceof entities\Datatype ? html_entity_decode($item->getName()) : $i18n->__('Unknown', array(), true);
                     framework\Context::loadLibrary('common');
                     if ($item instanceof entities\common\Colorizable) {
                         $colors[] = tbg_hex_to_rgb($item->getColor());
                     }
                 } else {
                     $labels[] = $item;
                 }
             } else {
                 $labels[] = $i18n->__('Not determined', array(), true);
             }
             $values[] = $value;
         }
     }
     return array($values, $labels, $colors);
 }
                         <?php 
     echo __('Assign issue to %user', array('%user' => ''));
     ?>
                     <?php 
 } elseif ($action->isCustomSetAction()) {
     ?>
                         <?php 
     echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => ''));
     ?>
                     <?php 
 }
 ?>
                 </label>
                 <?php 
 if ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_STATUS) {
     $options = \thebuggenie\core\entities\Status::getAll();
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_PRIORITY) {
     $options = \thebuggenie\core\entities\Priority::getAll();
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_PERCENT) {
     $options = range(1, 100);
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_RESOLUTION) {
     $options = \thebuggenie\core\entities\Resolution::getAll();
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_REPRODUCABILITY) {
     $options = \thebuggenie\core\entities\Reproducability::getAll();
 } elseif ($action->isCustomAction()) {
     $customfield = \thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType());
     if ($customfield->getType() == \thebuggenie\core\entities\CustomDatatype::CALCULATED_FIELD) {
         $options = array();
     } else {
         $options = $customfield->getOptions();
     }
Exemplo n.º 18
0
 public function componentFilter()
 {
     $pkey = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getID() : null;
     $i18n = framework\Context::getI18n();
     $this->selected_operator = isset($this->selected_operator) ? $this->selected_operator : '=';
     $this->key = isset($this->key) ? $this->key : null;
     $this->filter = isset($this->filter) ? $this->filter : null;
     if (in_array($this->filter, array('posted', 'last_updated'))) {
         $this->selected_value = $this->selected_value ? $this->selected_value : NOW;
     } else {
         $this->selected_value = isset($this->selected_value) ? $this->selected_value : 0;
     }
     $this->filter_info = isset($this->filter_info) ? $this->filter_info : null;
     $filters = array();
     $filters['status'] = array('description' => $i18n->__('Status'), 'options' => entities\Status::getAll());
     $filters['category'] = array('description' => $i18n->__('Category'), 'options' => entities\Category::getAll());
     $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => entities\Priority::getAll());
     $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => entities\Severity::getAll());
     $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => entities\Reproducability::getAll());
     $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => entities\Resolution::getAll());
     $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => entities\Issuetype::getAll());
     $filters['component'] = array('description' => $i18n->__('Component'), 'options' => array());
     $filters['build'] = array('description' => $i18n->__('Build'), 'options' => array());
     $filters['edition'] = array('description' => $i18n->__('Edition'), 'options' => array());
     $filters['milestone'] = array('description' => $i18n->__('Milestone'), 'options' => array());
     if (framework\Context::isProjectContext()) {
         $filters['subprojects'] = array('description' => $i18n->__('Include subproject(s)'), 'options' => array('all' => $this->getI18n()->__('All subprojects'), 'none' => $this->getI18n()->__("Don't include subprojects (default, unless specified otherwise)")));
         $projects = entities\Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject());
         foreach ($projects as $project) {
             if ($project->getID() == framework\Context::getCurrentProject()->getID()) {
                 continue;
             }
             $filters['subprojects']['options'][$project->getID()] = "{$project->getName()} ({$project->getKey()})";
         }
     } else {
         $projects = array();
         foreach (entities\Project::getAllRootProjects() as $project) {
             entities\Project::getSubprojectsArray($project, $projects);
         }
     }
     if (count($projects) > 0) {
         foreach ($projects as $project) {
             foreach ($project->getComponents() as $component) {
                 $filters['component']['options'][] = $component;
             }
             foreach ($project->getBuilds() as $build) {
                 $filters['build']['options'][] = $build;
             }
             foreach ($project->getEditions() as $edition) {
                 $filters['edition']['options'][] = $edition;
             }
             foreach ($project->getMilestones() as $milestone) {
                 $filters['milestone']['options'][] = $milestone;
             }
         }
     }
     $filters['posted_by'] = array('description' => $i18n->__('Posted by'));
     $filters['assignee_user'] = array('description' => $i18n->__('Assigned to user'));
     $filters['assignee_team'] = array('description' => $i18n->__('Assigned to team'));
     $filters['owner_user'] = array('description' => $i18n->__('Owned by user'));
     $filters['owner_team'] = array('description' => $i18n->__('Owned by team'));
     $filters['posted'] = array('description' => $i18n->__('Date reported'));
     $filters['last_updated'] = array('description' => $i18n->__('Date last updated'));
     $this->filters = $filters;
 }
 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;
     }
 }
Exemplo n.º 20
0
 protected function _setupReportIssueProperties()
 {
     $this->locked_issuetype = $this->locked_issuetype ?: null;
     $this->selected_issuetype = $this->selected_issuetype ?: null;
     $this->selected_edition = $this->selected_edition ?: null;
     $this->selected_build = $this->selected_build ?: null;
     $this->selected_milestone = $this->selected_milestone ?: null;
     $this->parent_issue = $this->parent_issue ?: null;
     $this->selected_component = $this->selected_component ?: null;
     $this->selected_category = $this->selected_category ?: null;
     $this->selected_status = $this->selected_status ?: null;
     $this->selected_resolution = $this->selected_resolution ?: null;
     $this->selected_priority = $this->selected_priority ?: null;
     $this->selected_reproducability = $this->selected_reproducability ?: null;
     $this->selected_severity = $this->selected_severity ?: null;
     $this->selected_estimated_time = $this->selected_estimated_time ?: null;
     $this->selected_spent_time = $this->selected_spent_time ?: null;
     $this->selected_percent_complete = $this->selected_percent_complete ?: null;
     $this->selected_pain_bug_type = $this->selected_pain_bug_type ?: null;
     $this->selected_pain_likelihood = $this->selected_pain_likelihood ?: null;
     $this->selected_pain_effect = $this->selected_pain_effect ?: null;
     $selected_customdatatype = $this->selected_customdatatype ?: array();
     foreach (entities\CustomDatatype::getAll() as $customdatatype) {
         $selected_customdatatype[$customdatatype->getKey()] = isset($selected_customdatatype[$customdatatype->getKey()]) ? $selected_customdatatype[$customdatatype->getKey()] : null;
     }
     $this->selected_customdatatype = $selected_customdatatype;
     $this->issuetype_id = $this->issuetype_id ?: null;
     $this->issue = $this->issue ?: null;
     $this->categories = entities\Category::getAll();
     $this->severities = entities\Severity::getAll();
     $this->priorities = entities\Priority::getAll();
     $this->reproducabilities = entities\Reproducability::getAll();
     $this->resolutions = entities\Resolution::getAll();
     $this->statuses = entities\Status::getAll();
     $this->milestones = framework\Context::getCurrentProject()->getMilestonesForIssues();
     $this->al_items = array();
 }
Exemplo n.º 21
0
                }
                ?>
                                            </select>
                                            <?php 
                break;
            case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE:
                ?>
                                            <select name="<?php 
                echo $customdatatype->getKey();
                ?>
_id" id="<?php 
                echo $customdatatype->getKey();
                ?>
_id_additional">
                                                <?php 
                foreach (\thebuggenie\core\entities\Status::getAll() as $option) {
                    ?>
                                                <option value="<?php 
                    echo $option->getID();
                    ?>
"<?php 
                    if ($selected_customdatatype[$customdatatype->getKey()] == $option->getID()) {
                        ?>
 selected<?php 
                    }
                    ?>
><?php 
                    echo $option->getName();
                    ?>
</option>
                                                <?php 
 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;
 }
Exemplo n.º 23
0
 public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::MODE_DISABLED) {
         $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n";
         return $output;
     }
     // Parse the commit message, and obtain the issues and transitions for issues.
     $parsed_commit = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // Build list of affected files
     $file_lines = preg_split('/[\\n\\r]+/', $changed);
     $files = array();
     foreach ($file_lines as $aline) {
         $action = mb_substr($aline, 0, 1);
         if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
             $theline = trim(mb_substr($aline, 1));
             $files[] = array($action, $theline);
         }
     }
     // Find author of commit, fallback is guest
     /*
      * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
      * Joe Bloggs <*****@*****.**>, instead of a classic username. Therefore a user will be found via 4 queries:
      * a) First we extract the email if there is one, and find a user with that email
      * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
      * c) the username or full name is checked against the friendly name field
      * d) and if we still havent found one, then we check against the username
      * e) and if we STILL havent found one, we use the guest user
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::cacheAllPermissions();
     $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n";
     if ($date == null) {
         $date = NOW;
     }
     // Create the commit data
     $commit = new Commit();
     $commit->setAuthor($user);
     $commit->setDate($date);
     $commit->setLog($commit_msg);
     $commit->setPreviousRevision($old_rev);
     $commit->setRevision($new_rev);
     $commit->setProject($project);
     if ($branch !== null) {
         $data = 'branch:' . $branch;
         $commit->setMiscData($data);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $commit->save();
     $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n";
     // Iterate over affected issues and update them.
     foreach ($issues as $issue) {
         $inst = new IssueLink();
         $inst->setIssue($issue);
         $inst->setCommit($commit);
         $inst->save();
         // Process all commit-message transitions for an issue.
         foreach ($transitions[$issue->getFormattedIssueNo()] as $transition) {
             if (framework\Settings::get('vcs_workflow_' . $project->getID(), 'vcs_integration') == self::WORKFLOW_ENABLED) {
                 framework\Context::setUser($user);
                 framework\Settings::forceSettingsReload();
                 framework\Context::cacheAllPermissions();
                 if ($issue->isWorkflowTransitionsAvailable()) {
                     // Go through the list of possible transitions for an issue. Only
                     // process transitions that are applicable to issue's workflow.
                     foreach ($issue->getAvailableWorkflowTransitions() as $possible_transition) {
                         if (mb_strtolower($possible_transition->getName()) == mb_strtolower($transition[0])) {
                             $output .= '[VCS ' . $project->getKey() . '] Running transition ' . $transition[0] . ' on issue ' . $issue->getFormattedIssueNo() . "\n";
                             // String representation of parameters. Used for log message.
                             $parameters_string = "";
                             // Iterate over the list of this transition's parameters, and
                             // set them.
                             foreach ($transition[1] as $parameter => $value) {
                                 $parameters_string .= "{$parameter}={$value} ";
                                 switch ($parameter) {
                                     case 'resolution':
                                         if (($resolution = \thebuggenie\core\entities\Resolution::getByKeyish($value)) instanceof \thebuggenie\core\entities\Resolution) {
                                             framework\Context::getRequest()->setParameter('resolution_id', $resolution->getID());
                                         }
                                         break;
                                     case 'status':
                                         if (($status = \thebuggenie\core\entities\Status::getByKeyish($value)) instanceof \thebuggenie\core\entities\Status) {
                                             framework\Context::getRequest()->setParameter('status_id', $status->getID());
                                         }
                                         break;
                                 }
                             }
                             // Run the transition.
                             $possible_transition->transitionIssueToOutgoingStepWithoutRequest($issue);
                             // Log an informative message about the transition.
                             $output .= '[VCS ' . $project->getKey() . '] Ran transition ' . $possible_transition->getName() . ' with parameters \'' . $parameters_string . '\' on issue ' . $issue->getFormattedIssueNo() . "\n";
                         }
                     }
                 }
             }
         }
         $issue->addSystemComment(framework\Context::getI18n()->__('This issue has been updated with the latest changes from the code repository.<source>%commit_msg</source>', array('%commit_msg' => $commit_msg)), $user->getID());
         $output .= '[VCS ' . $project->getKey() . '] Updated issue ' . $issue->getFormattedIssueNo() . "\n";
     }
     // Create file links
     foreach ($files as $afile) {
         // index 0 is action, index 1 is file
         $inst = new File();
         $inst->setAction($afile[0]);
         $inst->setFile($afile[1]);
         $inst->setCommit($commit);
         $inst->save();
         $output .= '[VCS ' . $project->getKey() . '] Added with action ' . $afile[0] . ' file ' . $afile[1] . "\n";
     }
     framework\Event::createNew('vcs_integration', 'new_commit')->trigger(array('commit' => $commit));
     return $output;
 }
 public function isValid($input)
 {
     switch ($this->_name) {
         case self::RULE_MAX_ASSIGNED_ISSUES:
             $num_issues = (int) $this->getRuleValue();
             return $num_issues ? (bool) (count(framework\Context::getUser()->getUserAssignedIssues()) < $num_issues) : true;
             break;
         case self::RULE_TEAM_MEMBERSHIP_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $teams = \thebuggenie\core\entities\Team::getAll();
             if ($this->isPost()) {
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $assignee = $input->getAssignee();
                 }
             }
             if (!isset($assignee)) {
                 $assignee = framework\Context::getUser();
             }
             if ($assignee instanceof \thebuggenie\core\entities\User) {
                 if (count($valid_items) == 1 && reset($valid_items) == '') {
                     return true;
                 }
                 foreach ($valid_items as $team_id) {
                     if ($assignee->isMemberOfTeam($teams[$team_id])) {
                         return true;
                     }
                 }
             } elseif ($assignee instanceof \thebuggenie\core\entities\Team) {
                 foreach ($valid_items as $team_id) {
                     if ($assignee->getID() == $team_id) {
                         return true;
                     }
                 }
             }
             return false;
         case self::RULE_ISSUE_IN_MILESTONE_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             if ($input instanceof \thebuggenie\core\entities\Issue) {
                 $issue = $input;
             } else {
                 if ($input->hasParameter('issue_id')) {
                     $issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectByID((int) $input->getParameter('issue_id'));
                 }
             }
             if (isset($issue) && $issue instanceof \thebuggenie\core\entities\Issue) {
                 if (!$issue->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
                     return false;
                 }
                 if (count($valid_items) == 1 && reset($valid_items) == '') {
                     return true;
                 }
                 return in_array($issue->getMilestone()->getID(), $valid_items);
             }
             return false;
         case self::RULE_STATUS_VALID:
         case self::RULE_PRIORITY_VALID:
         case self::RULE_RESOLUTION_VALID:
         case self::RULE_REPRODUCABILITY_VALID:
             $valid_items = explode(',', $this->getRuleValue());
             $valid = false;
             if ($this->_name == self::RULE_STATUS_VALID) {
                 $fieldname = 'Status';
                 $fieldname_small = 'status';
             } elseif ($this->_name == self::RULE_RESOLUTION_VALID) {
                 $fieldname = 'Resolution';
                 $fieldname_small = 'resolution';
             } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) {
                 $fieldname = 'Reproducability';
                 $fieldname_small = 'reproducability';
             } elseif ($this->_name == self::RULE_PRIORITY_VALID) {
                 $fieldname = 'Priority';
                 $fieldname_small = 'priority';
             } else {
                 throw new framework\exceptions\ConfigurationException(framework\Context::getI18n()->__('Invalid workflow validation rule: %rule_name', array('%rule_name' => $this->_name)));
             }
             if (!$this->getRuleValue()) {
                 if ($input instanceof \thebuggenie\core\entities\Issue) {
                     $getter = "get{$fieldname}";
                     if (is_object($input->{$getter}())) {
                         $valid = true;
                     }
                 } elseif ($input instanceof framework\Request) {
                     if ($input->getParameter("{$fieldname_small}_id") && Status::has($input->getParameter("{$fieldname_small}_id"))) {
                         $valid = true;
                     }
                 }
             } else {
                 foreach ($valid_items as $item) {
                     if ($input instanceof \thebuggenie\core\entities\Issue) {
                         $type = "\\thebuggenie\\core\\entities\\{$fieldname}";
                         $getter = "get{$fieldname}";
                         if (is_object($input->{$getter}()) && $type::getB2DBTable()->selectByID((int) $item)->getID() == $input->{$getter}()->getID()) {
                             $valid = true;
                             break;
                         }
                     } elseif ($input instanceof framework\Request) {
                         if ($input->getParameter("{$fieldname_small}_id") == $item) {
                             $valid = true;
                             break;
                         }
                     }
                 }
             }
             return $valid;
             break;
         default:
             if ($this->isCustom()) {
                 switch ($this->getCustomType()) {
                     case CustomDatatype::RADIO_CHOICE:
                     case CustomDatatype::DROPDOWN_CHOICE_TEXT:
                     case CustomDatatype::TEAM_CHOICE:
                     case CustomDatatype::STATUS_CHOICE:
                     case CustomDatatype::MILESTONE_CHOICE:
                     case CustomDatatype::CLIENT_CHOICE:
                     case CustomDatatype::COMPONENTS_CHOICE:
                     case CustomDatatype::EDITIONS_CHOICE:
                     case CustomDatatype::RELEASES_CHOICE:
                         $valid_items = explode(',', $this->getRuleValue());
                         if ($input instanceof \thebuggenie\core\entities\Issue) {
                             $value = $input->getCustomField($this->getCustomFieldname());
                         } elseif ($input instanceof framework\Request) {
                             $value = $input->getParameter($this->getCustomFieldname() . "_id");
                         }
                         $valid = false;
                         if (!$this->getRuleValue()) {
                             foreach ($this->getCustomField()->getOptions() as $item) {
                                 if ($item->getID() == $value) {
                                     $valid = true;
                                     break;
                                 }
                             }
                         } else {
                             foreach ($valid_items as $item) {
                                 if ($value instanceof Identifiable && $value->getID() == $item) {
                                     $valid = true;
                                     break;
                                 } elseif (is_numeric($value) && $value == $item) {
                                     $valid = true;
                                     break;
                                 }
                             }
                         }
                         return $valid;
                         break;
                 }
             } else {
                 $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::isValid', $this);
                 $event->setReturnValue(false);
                 $event->triggerUntilProcessed(array('input' => $input));
                 return $event->getReturnValue();
             }
     }
 }
Exemplo n.º 25
0
 public function processIncomingEmailCommand($content, Issue $issue)
 {
     if (!$issue->isWorkflowTransitionsAvailable()) {
         return false;
     }
     $lines = preg_split("/(\r?\n)/", $content);
     $first_line = array_shift($lines);
     $commands = explode(" ", trim($first_line));
     $command = array_shift($commands);
     foreach ($issue->getAvailableWorkflowTransitions() as $transition) {
         if (strpos(str_replace(array(' ', '/'), array('', ''), mb_strtolower($transition->getName())), str_replace(array(' ', '/'), array('', ''), mb_strtolower($command))) !== false) {
             foreach ($commands as $single_command) {
                 if (mb_strpos($single_command, '=')) {
                     list($key, $val) = explode('=', $single_command);
                     switch ($key) {
                         case 'resolution':
                             if (($resolution = Resolution::getByKeyish($val)) instanceof Resolution) {
                                 framework\Context::getRequest()->setParameter('resolution_id', $resolution->getID());
                             }
                             break;
                         case 'status':
                             if (($status = Status::getByKeyish($val)) instanceof Status) {
                                 framework\Context::getRequest()->setParameter('status_id', $status->getID());
                             }
                             break;
                     }
                 }
             }
             framework\Context::getRequest()->setParameter('comment_body', join("\n", $lines));
             return $transition->transitionIssueToOutgoingStepWithoutRequest($issue);
         }
     }
 }
Exemplo n.º 26
0
 protected function _populateOptions()
 {
     if ($this->_options === null) {
         if ($this->hasCustomOptions()) {
             $this->_b2dbLazyload('_options');
         } else {
             switch ($this->getType()) {
                 case self::RELEASES_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getBuilds() : \thebuggenie\core\entities\tables\Builds::getTable()->selectAll();
                     break;
                 case self::COMPONENTS_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getComponents() : \thebuggenie\core\entities\tables\Components::getTable()->selectAll();
                     break;
                 case self::EDITIONS_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getEditions() : \thebuggenie\core\entities\tables\Editions::getTable()->selectAll();
                     break;
                 case self::MILESTONE_CHOICE:
                     $this->_options = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getMilestonesForIssues() : \thebuggenie\core\entities\tables\Milestones::getTable()->selectAll();
                     break;
                 case self::STATUS_CHOICE:
                     $this->_options = \thebuggenie\core\entities\Status::getAll();
                     break;
             }
         }
     }
 }
Exemplo n.º 27
0
 public static function loadFixtures(\thebuggenie\core\entities\Scope $scope, \thebuggenie\core\entities\Workflow $workflow, $steps)
 {
     $rejected_resolutions = array();
     $rejected_resolutions[] = Resolution::getByKeyish('notanissue')->getID();
     $rejected_resolutions[] = Resolution::getByKeyish('wontfix')->getID();
     $rejected_resolutions[] = Resolution::getByKeyish('cantfix')->getID();
     $rejected_resolutions[] = Resolution::getByKeyish('cantreproduce')->getID();
     $rejected_resolutions[] = Resolution::getByKeyish('duplicate')->getID();
     $resolved_resolutions = array();
     $resolved_resolutions[] = Resolution::getByKeyish('resolved')->getID();
     $resolved_resolutions[] = Resolution::getByKeyish('wontfix')->getID();
     $resolved_resolutions[] = Resolution::getByKeyish('postponed')->getID();
     $resolved_resolutions[] = Resolution::getByKeyish('duplicate')->getID();
     $closed_statuses = array();
     $closed_statuses[] = Status::getByKeyish('closed')->getID();
     $closed_statuses[] = Status::getByKeyish('postponed')->getID();
     $closed_statuses[] = Status::getByKeyish('done')->getID();
     $closed_statuses[] = Status::getByKeyish('fixed')->getID();
     $transitions = array();
     $transitions['investigateissue'] = array('name' => 'Investigate issue', 'description' => 'Assign the issue to yourself and start investigating it', 'outgoing_step' => 'investigating', 'template' => null, 'pre_validations' => array(WorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES => 5), 'actions' => array(WorkflowTransitionAction::ACTION_ASSIGN_ISSUE_SELF => 0));
     $transitions['requestmoreinformation'] = array('name' => 'Request more information', 'description' => 'Move issue back to new state for more details', 'outgoing_step' => 'new', 'template' => 'main/updateissueproperties', 'actions' => array(WorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0));
     $transitions['confirmissue'] = array('name' => 'Confirm issue', 'description' => 'Confirm that the issue is valid', 'outgoing_step' => 'confirmed', 'template' => null, 'actions' => array(WorkflowTransitionAction::ACTION_SET_PERCENT => 10));
     $transitions['rejectissue'] = array('name' => 'Reject issue', 'description' => 'Reject the issue as invalid', 'outgoing_step' => 'rejected', 'template' => 'main/updateissueproperties', 'post_validations' => array(WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID => join(',', $rejected_resolutions)), 'actions' => array(WorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, WorkflowTransitionAction::ACTION_SET_DUPLICATE => 0, WorkflowTransitionAction::ACTION_SET_PERCENT => 100, WorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0));
     $transitions['acceptissue'] = array('name' => 'Accept issue', 'description' => 'Accept the issue and assign it to yourself', 'outgoing_step' => 'inprogress', 'template' => null, 'pre_validations' => array(WorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES => 5), 'actions' => array(WorkflowTransitionAction::ACTION_ASSIGN_ISSUE_SELF => 0, WorkflowTransitionAction::ACTION_USER_START_WORKING => 0));
     $transitions['reopenissue'] = array('name' => 'Reopen issue', 'description' => 'Reopen the issue', 'outgoing_step' => 'new', 'template' => null, 'actions' => array(WorkflowTransitionAction::ACTION_CLEAR_RESOLUTION => 0, WorkflowTransitionAction::ACTION_CLEAR_DUPLICATE => 0, WorkflowTransitionAction::ACTION_CLEAR_PERCENT => 0));
     $transitions['assignissue'] = array('name' => 'Assign issue', 'description' => 'Accept the issue and assign it to someone', 'outgoing_step' => 'inprogress', 'template' => 'main/updateissueproperties', 'actions' => array(WorkflowTransitionAction::ACTION_ASSIGN_ISSUE => 0, WorkflowTransitionAction::ACTION_USER_START_WORKING => 0));
     $transitions['markreadyfortesting'] = array('name' => 'Mark ready for testing', 'description' => 'Mark the issue as ready to be tested', 'outgoing_step' => 'readyfortesting', 'template' => null, 'actions' => array(WorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, WorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0));
     $transitions['resolveissue'] = array('name' => 'Resolve issue', 'description' => 'Resolve the issue', 'outgoing_step' => 'closed', 'template' => 'main/updateissueproperties', 'post_validations' => array(WorkflowTransitionValidationRule::RULE_STATUS_VALID => join(',', $closed_statuses), WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID => join(',', $resolved_resolutions)), 'actions' => array(WorkflowTransitionAction::ACTION_SET_STATUS => 0, WorkflowTransitionAction::ACTION_SET_PERCENT => 100, WorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, WorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0));
     $transitions['testissuesolution'] = array('name' => 'Test issue solution', 'description' => 'Check whether the solution is valid', 'outgoing_step' => 'testing', 'template' => null, 'actions' => array(WorkflowTransitionAction::ACTION_ASSIGN_ISSUE_SELF => 0, WorkflowTransitionAction::ACTION_USER_START_WORKING => 0));
     $transitions['acceptissuesolution'] = array('name' => 'Accept issue solution', 'description' => 'Mark the issue as resolved', 'outgoing_step' => 'closed', 'template' => 'main/updateissueproperties', 'actions' => array(WorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, WorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, WorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0));
     $transitions['rejectissuesolution'] = array('name' => 'Reject issue solution', 'description' => 'Reject the proposed solution and mark the issue as in progress', 'outgoing_step' => 'inprogress', 'template' => null, 'actions' => array(WorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, WorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, WorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0));
     foreach ($transitions as $key => $transition) {
         $transition_object = new \thebuggenie\core\entities\WorkflowTransition();
         $transition_object->setName($transition['name']);
         $transition_object->setDescription($transition['description']);
         $transition_object->setOutgoingStep($steps[$transition['outgoing_step']]['step']);
         $transition_object->setTemplate($transition['template']);
         $transition_object->setWorkflow($workflow);
         $transition_object->save();
         $transitions[$key] = $transition_object;
         if (array_key_exists('pre_validations', $transition) && is_array($transition['pre_validations'])) {
             foreach ($transition['pre_validations'] as $type => $validation) {
                 $rule = new \thebuggenie\core\entities\WorkflowTransitionValidationRule();
                 $rule->setTransition($transition_object);
                 $rule->setPre();
                 $rule->setRule($type);
                 $rule->setRuleValue($validation);
                 $rule->setWorkflow($workflow);
                 $rule->save();
             }
         }
         if (array_key_exists('post_validations', $transition) && is_array($transition['post_validations'])) {
             foreach ($transition['post_validations'] as $type => $validation) {
                 $rule = new \thebuggenie\core\entities\WorkflowTransitionValidationRule();
                 $rule->setTransition($transition_object);
                 $rule->setPost();
                 $rule->setRule($type);
                 $rule->setRuleValue($validation);
                 $rule->setWorkflow($workflow);
                 $rule->save();
             }
         }
         if (array_key_exists('actions', $transition) && is_array($transition['actions'])) {
             foreach ($transition['actions'] as $type => $action) {
                 $action_object = new \thebuggenie\core\entities\WorkflowTransitionAction();
                 $action_object->setActionType($type);
                 $action_object->setTransition($transition_object);
                 $action_object->setWorkflow($workflow);
                 if (!is_null($action)) {
                     $action_object->setTargetValue($action);
                 }
                 $action_object->save();
             }
         }
     }
     return $transitions;
 }
 public function isValid(\thebuggenie\core\framework\Request $request)
 {
     if ($this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             return (bool) $request['assignee_type'] && $request['assignee_id'];
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) $request->hasParameter('milestone_id');
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) $request->hasParameter('priority_id');
             break;
         case self::ACTION_SET_STATUS:
             return (bool) $request->hasParameter('status_id') && ($status = Status::getB2DBTable()->selectById((int) $request->getParameter('status_id'))) instanceof Status && $status->canUserSet(framework\Context::getUser());
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) $request->hasParameter('reproducability_id');
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) $request->hasParameter('resolution_id');
             break;
         default:
             return true;
     }
 }