public static function loadFixtures(TBGScope $scope, TBGWorkflow $workflow) { $steps = array(); $steps['new'] = array('name' => 'New', 'description' => 'A new issue, not yet handled', 'status_id' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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 TBGWorkflowStep(); $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 = TBGWorkflowTransition::loadFixtures($scope, $workflow, $steps); foreach ($steps as $step) { foreach ($step['transitions'] as $transition) { $step['step']->addOutgoingTransition($transitions[$transition]); } } }
public static function loadFixtures(TBGScope $scope) { TBGCategory::loadFixtures($scope); TBGPriority::loadFixtures($scope); TBGReproducability::loadFixtures($scope); TBGResolution::loadFixtures($scope); TBGSeverity::loadFixtures($scope); TBGStatus::loadFixtures($scope); TBGProjectRole::loadFixtures($scope); }
/** * Returns all statuses available * * @return array */ public static function getAll() { if (self::$_items === null) { self::$_items = array(); if ($items = TBGListTypesTable::getTable()->getAllByItemType(self::STATUS)) { foreach ($items as $row_id => $row) { self::$_items[$row_id] = TBGContext::factory()->TBGStatus($row_id, $row); } } } return self::$_items; }
public static function loadFixtures(TBGScope $scope) { TBGCategory::loadFixtures($scope); TBGPriority::loadFixtures($scope); TBGReproducability::loadFixtures($scope); TBGResolution::loadFixtures($scope); TBGSeverity::loadFixtures($scope); TBGStatus::loadFixtures($scope); TBGRole::loadFixtures($scope); TBGActivityType::loadFixtures($scope); foreach (self::getTypes() as $type => $class) { TBGContext::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID()); } }
public static function loadFixtures(TBGScope $scope) { $statuses = array(); $statuses['New'] = '#FFF'; $statuses['Investigating'] = '#C2F533'; $statuses['Confirmed'] = '#FF55AA'; $statuses['Not a bug'] = '#44FC1D'; $statuses['Being worked on'] = '#5C5'; $statuses['Near completion'] = '#7D3'; $statuses['Ready for testing / QA'] = '#55C'; $statuses['Testing / QA'] = '#77C'; $statuses['Closed'] = '#C2F588'; $statuses['Postponed'] = '#FA5'; $statuses['Done'] = '#7D3'; $statuses['Fixed'] = '#5C5'; foreach ($statuses as $name => $itemdata) { $status = new TBGStatus(); $status->setName($name); $status->setItemdata($itemdata); $status->setScope($scope); $status->save(); } }
public function componentFilter() { $i18n = TBGContext::getI18n(); $this->selected_value = isset($this->selected_value) ? $this->selected_value : 0; $this->selected_operator = isset($this->selected_operator) ? $this->selected_operator : '='; $filters = array(); $filters['status'] = array('description' => $i18n->__('Status'), 'options' => TBGStatus::getAll()); $filters['category'] = array('description' => $i18n->__('Category'), 'options' => TBGCategory::getAll()); $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => TBGPriority::getAll()); $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => TBGSeverity::getAll()); $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => TBGReproducability::getAll()); $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => TBGResolution::getAll()); $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => TBGIssuetype::getAll()); $this->filters = $filters; }
public function loadFixtures(TBGScope $scope) { $steps = array(); $steps[] = array('name' => 'New', 'description' => 'A new issue, not yet handled', 'status_id' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('investigating')->getID(), 'editable' => true, 'is_closed' => false); $steps[] = array('name' => 'Confirmed', 'description' => 'An issue that has been confirmed', 'status_id' => TBGStatus::getStatusByKeyish('confirmed')->getID(), 'editable' => false, 'is_closed' => false); $steps[] = array('name' => 'In progress', 'description' => 'An issue that is being adressed', 'status_id' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('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' => TBGStatus::getStatusByKeyish('testing/qa')->getID(), 'editable' => false, 'is_closed' => false); $steps[] = array('name' => 'Rejected', 'description' => 'A closed issue that has been rejected', 'status_id' => TBGStatus::getStatusByKeyish('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); } }
public function componentProjectSettings() { $this->statustypes = TBGStatus::getAll(); }
public function getAvailableValues($filters = array()) { switch ($this->getFilterKey()) { case 'issuetype': return TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getIssuetypeScheme()->getIssuetypes() : TBGIssuetype::getAll(); case 'status': return TBGStatus::getAll(); case 'category': return TBGCategory::getAll(); case 'priority': return TBGPriority::getAll(); case 'severity': return TBGSeverity::getAll(); case 'reproducability': return TBGReproducability::getAll(); case 'resolution': return TBGResolution::getAll(); case 'project_id': return TBGProject::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 = TBGProject::getIncludingAllSubprojectsAsArray(TBGContext::getCurrentProject()); foreach ($projects as $project) { if ($project->getID() == TBGContext::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 = TBGCustomDatatype::getByKey($this->getFilterKey()); if ($customdatatype instanceof TBGCustomDatatype && $customdatatype->hasCustomOptions()) { return $customdatatype->getOptions(); } else { switch ($this->getFilterType()) { case TBGCustomDatatype::COMPONENTS_CHOICE: return $this->_getAvailableComponentChoices(); case TBGCustomDatatype::RELEASES_CHOICE: return $this->_getAvailableBuildChoices(); case TBGCustomDatatype::EDITIONS_CHOICE: return $this->_getAvailableEditionChoices(); case TBGCustomDatatype::MILESTONE_CHOICE: return $this->_getAvailableMilestoneChoices(); case TBGCustomDatatype::USER_CHOICE: return $this->_getAvailableUserChoices(); case TBGCustomDatatype::TEAM_CHOICE: return $this->_getAvailableTeamChoices(); case TBGCustomDatatype::STATUS_CHOICE: return TBGStatus::getAll(); default: return array(); } } } }
<br> <?php $editions = array(); $components = array(); $builds = array(); $statuses = array(); if ($issue->getProject()->isEditionsEnabled()) { $editions = $issue->getEditions(); } if ($issue->getProject()->isComponentsEnabled()) { $components = $issue->getComponents(); } if ($issue->getProject()->isBuildsEnabled()) { $builds = $issue->getBuilds(); } $statuses = TBGStatus::getAll(); $count = count($editions) + count($components) + count($builds); ?> <table style="width: 100%;" cellpadding="0" cellspacing="0" class="issue_affects" id="affected_list"> <tr> <th style="width: 16px; text-align: right; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 3px;"></th><th><?php echo __('Name'); ?> </th><th><?php echo __('Status'); ?> </th><th style="width: 90px; text-align: right; padding-top: 0px; padding-right: 3px; padding-bottom: 0px; padding-left: 0px;"><?php echo __('Confirmed'); ?>
/** * Configuration import page * * @param TBGRequest $request */ public function runImport(TBGRequest $request) { if ($request->isMethod(TBGRequest::POST)) { if ($request->getParameter('import_sample_data')) { $users = array(); $user1 = new TBGUser(); $user1->setUsername('john'); $user1->setPassword('john'); $user1->setBuddyname('John'); $user1->setRealname('John'); $user1->setActivated(); $user1->setEnabled(); $user1->save(); $users[] = $user1; $user2 = new TBGUser(); $user2->setUsername('jane'); $user2->setPassword('jane'); $user2->setBuddyname('Jane'); $user2->setRealname('Jane'); $user2->setActivated(); $user2->setEnabled(); $user2->save(); $users[] = $user2; $user3 = new TBGUser(); $user3->setUsername('jackdaniels'); $user3->setPassword('jackdaniels'); $user3->setBuddyname('Jack'); $user3->setRealname('Jack Daniels'); $user3->setActivated(); $user3->setEnabled(); $user3->save(); $users[] = $user3; $project1 = new TBGProject(); $project1->setName('Sample project 1'); $project1->setOwner($users[rand(0, 2)]); $project1->setLeader($users[rand(0, 2)]); $project1->setQaResponsible($users[rand(0, 2)]); $project1->setDescription('This is a sample project that is awesome. Try it out!'); $project1->setHomepage('http://www.google.com'); $project1->save(); $project2 = new TBGProject(); $project2->setName('Sample project 2'); $project2->setOwner($users[rand(0, 2)]); $project2->setLeader($users[rand(0, 2)]); $project2->setQaResponsible($users[rand(0, 2)]); $project2->setDescription('This is the second sample project. Not as awesome as the first one, but still worth a try!'); $project2->setHomepage('http://www.bing.com'); $project2->save(); foreach (array($project1, $project2) as $project) { for ($cc = 1; $cc <= 5; $cc++) { $milestone = new TBGMilestone(); $milestone->setName("Milestone {$cc}"); $milestone->setProject($project); $milestone->setType(TBGMilestone::TYPE_REGULAR); if ((bool) rand(0, 1)) { $milestone->setScheduledDate(NOW + 100000 * (20 * $cc)); } $milestone->save(); } } $p1_milestones = $project1->getMilestones(); $p2_milestones = $project2->getMilestones(); $issues = array(); $priorities = TBGPriority::getAll(); $categories = TBGCategory::getAll(); $severities = TBGSeverity::getAll(); $statuses = TBGStatus::getAll(); $reproducabilities = TBGReproducability::getAll(); $lorem_ipsum = TBGArticlesTable::getTable()->getArticleByName('LoremIpsum'); $lorem_ipsum = PublishFactory::article($lorem_ipsum->get(TBGArticlesTable::ID), $lorem_ipsum); $lorem_words = explode(' ', $lorem_ipsum->getContent()); foreach (array('bugreport', 'featurerequest', 'enhancement', 'idea') as $issuetype) { $issuetype = TBGIssuetype::getIssuetypeByKeyish($issuetype); for ($cc = 1; $cc <= 10; $cc++) { $issue1 = new TBGIssue(); $issue1->setProject($project1); $issue1->setPostedBy($users[rand(0, 2)]); $issue1->setPosted(NOW - 86400 * rand(1, 30)); $title_string = ''; $description_string = ''; $rand_length = rand(4, 15); $ucnext = true; for ($ll = 1; $ll <= $rand_length; $ll++) { $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]); $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : strtolower($word); $title_string .= $word; $ucnext = false; if ($ll == $rand_length || rand(1, 15) == 5) { $title_string .= '.'; $ucnext = true; } $title_string .= ' '; } $rand_length = rand(40, 500); $ucnext = true; for ($ll = 1; $ll <= $rand_length; $ll++) { $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]); $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : strtolower($word); $description_string .= $word; $ucnext = false; if ($ll == $rand_length || rand(1, 15) == 5) { $description_string .= '.'; $ucnext = true; $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' '; } else { $description_string .= ' '; } } $issue1->setTitle(ucfirst($title_string)); $issue1->setDescription($description_string); $issue1->setIssuetype($issuetype); $issue1->setMilestone($p1_milestones[array_rand($p1_milestones)]); $issue1->setPriority($priorities[array_rand($priorities)]); $issue1->setCategory($categories[array_rand($categories)]); $issue1->setSeverity($severities[array_rand($severities)]); $issue1->setReproducability($reproducabilities[array_rand($reproducabilities)]); $issue1->setPercentCompleted(rand(0, 100)); $issue1->save(); $issue1->setStatus($statuses[array_rand($statuses)]); if (rand(0, 1)) { $issue1->setAssignee($users[array_rand($users)]); } $issue1->save(); $issues[] = $issue1; $issue2 = new TBGIssue(); $issue2->setProject($project2); $issue2->setPostedBy($users[rand(0, 2)]); $issue2->setPosted(NOW - 86400 * rand(1, 30)); $title_string = ''; $description_string = ''; $rand_length = rand(4, 15); $ucnext = true; for ($ll = 1; $ll <= $rand_length; $ll++) { $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]); $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : strtolower($word); $title_string .= $word; $ucnext = false; if ($ll == $rand_length || rand(1, 15) == 5) { $title_string .= '.'; $ucnext = true; } $title_string .= ' '; } $rand_length = rand(40, 500); $ucnext = true; for ($ll = 1; $ll <= $rand_length; $ll++) { $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]); $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : strtolower($word); $description_string .= $word; $ucnext = false; if ($ll == $rand_length || rand(1, 15) == 5) { $description_string .= '.'; $ucnext = true; $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' '; } else { $description_string .= ' '; } } $issue2->setTitle(ucfirst($title_string)); $issue2->setDescription($description_string); $issue2->setIssuetype($issuetype); $issue2->setMilestone($p2_milestones[array_rand($p2_milestones)]); $issue2->setPriority($priorities[array_rand($priorities)]); $issue2->setCategory($categories[array_rand($categories)]); $issue2->setSeverity($severities[array_rand($severities)]); $issue2->setReproducability($reproducabilities[array_rand($reproducabilities)]); $issue2->setPercentCompleted(rand(0, 100)); if (rand(0, 1)) { $issue1->setAssignee($users[array_rand($users)]); } $issue2->save(); $issue2->setStatus($statuses[array_rand($statuses)]); $issue2->save(); $issues[] = $issue2; } } $rand_issues_to_close = rand(8, 40); $resolutions = TBGResolution::getAll(); for ($cc = 1; $cc <= $rand_issues_to_close; $cc++) { $issue = array_slice($issues, array_rand($issues), 1); $issue = $issue[0]; $issue->setResolution($resolutions[array_rand($resolutions)]); $issue->close(); $issue->save(); } $this->imported_data = true; $developer = TBGProjectAssigneesTable::getByType(TBGProjectAssigneesTable::TYPE_DEVELOPER); foreach (array($project1, $project2) as $project) { foreach ($users as $user) { $project->addAssignee($user, $developer->getID()); } } } } $project1 = TBGProject::getByKey('sampleproject1'); $project2 = TBGProject::getByKey('sampleproject2'); $this->canimport = !$project1 instanceof TBGProject && !$project2 instanceof TBGProject; }
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') ? TBGUser::doesIDExist($target_details[1]) : TBGTeam::doesIDExist($target_details[1]); break; case self::ACTION_SET_PERCENT: return (bool) ($this->_target_value > -1); break; case self::ACTION_SET_MILESTONE: return (bool) TBGMilestone::doesIDExist($this->_target_value); break; case self::ACTION_SET_PRIORITY: return (bool) TBGPriority::has($this->_target_value); break; case self::ACTION_SET_STATUS: return (bool) TBGStatus::has($this->_target_value); break; case self::ACTION_SET_REPRODUCABILITY: return (bool) TBGReproducability::has($this->_target_value); break; case self::ACTION_SET_RESOLUTION: return (bool) TBGResolution::has($this->_target_value); break; default: return true; } }
} ?> </select> <?php break; case TBGCustomDatatype::STATUS_CHOICE: ?> <select name="<?php echo $customdatatype->getKey(); ?> _id" id="<?php echo $customdatatype->getKey(); ?> _id_additional"> <?php foreach (TBGStatus::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
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 (TBGStatus::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 }
protected function setupVariables() { $i18n = TBGContext::getI18n(); $this->statuses = TBGStatus::getAll(); $this->issuetypes = $this->issue->getProject()->getIssuetypeScheme()->getIssuetypes(); $fields_list = array(); $fields_list['category'] = array('title' => $i18n->__('Category'), 'visible' => $this->issue->isCategoryVisible(), 'changed' => $this->issue->isCategoryChanged(), 'merged' => $this->issue->isCategoryMerged(), 'name' => $this->issue->getCategory() instanceof TBGCategory ? $this->issue->getCategory()->getName() : '', 'name_visible' => (bool) ($this->issue->getCategory() instanceof TBGCategory), 'noname_visible' => (bool) (!$this->issue->getCategory() instanceof TBGCategory), 'icon' => false, 'change_tip' => $i18n->__('Click to change category'), 'change_header' => $i18n->__('Change category'), 'clear' => $i18n->__('Clear the category'), 'select' => $i18n->__('%clear_the_category% or click to select a new category', array('%clear_the_category%' => ''))); if ($this->issue->isEditable() && $this->issue->canEditCategory()) { $fields_list['category']['choices'] = TBGCategory::getAll(); } $fields_list['resolution'] = array('title' => $i18n->__('Resolution'), 'visible' => $this->issue->isResolutionVisible(), 'changed' => $this->issue->isResolutionChanged(), 'merged' => $this->issue->isResolutionMerged(), 'name' => $this->issue->getResolution() instanceof TBGResolution ? $this->issue->getResolution()->getName() : '', 'name_visible' => (bool) ($this->issue->getResolution() instanceof TBGResolution), 'noname_visible' => (bool) (!$this->issue->getResolution() instanceof TBGResolution), 'icon' => false, 'change_tip' => $i18n->__('Click to change resolution'), 'change_header' => $i18n->__('Change resolution'), 'clear' => $i18n->__('Clear the resolution'), 'select' => $i18n->__('%clear_the_resolution% or click to select a new resolution', array('%clear_the_resolution%' => ''))); if ($this->issue->isUpdateable() && $this->issue->canEditResolution()) { $fields_list['resolution']['choices'] = TBGResolution::getAll(); } $fields_list['priority'] = array('title' => $i18n->__('Priority'), 'visible' => $this->issue->isPriorityVisible(), 'changed' => $this->issue->isPriorityChanged(), 'merged' => $this->issue->isPriorityMerged(), 'name' => $this->issue->getPriority() instanceof TBGPriority ? $this->issue->getPriority()->getName() : '', 'name_visible' => (bool) ($this->issue->getPriority() instanceof TBGPriority), 'noname_visible' => (bool) (!$this->issue->getPriority() instanceof TBGPriority), 'icon' => false, 'change_tip' => $i18n->__('Click to change priority'), 'change_header' => $i18n->__('Change priority'), 'clear' => $i18n->__('Clear the priority'), 'select' => $i18n->__('%clear_the_priority% or click to select a new priority', array('%clear_the_priority%' => ''))); if ($this->issue->isUpdateable() && $this->issue->canEditPriority()) { $fields_list['priority']['choices'] = TBGPriority::getAll(); } $fields_list['reproducability'] = array('title' => $i18n->__('Reproducability'), 'visible' => $this->issue->isReproducabilityVisible(), 'changed' => $this->issue->isReproducabilityChanged(), 'merged' => $this->issue->isReproducabilityMerged(), 'name' => $this->issue->getReproducability() instanceof TBGReproducability ? $this->issue->getReproducability()->getName() : '', 'name_visible' => (bool) ($this->issue->getReproducability() instanceof TBGReproducability), 'noname_visible' => (bool) (!$this->issue->getReproducability() instanceof TBGReproducability), 'icon' => false, 'change_tip' => $i18n->__('Click to change reproducability'), 'change_header' => $i18n->__('Change reproducability'), 'clear' => $i18n->__('Clear the reproducability'), 'select' => $i18n->__('%clear_the_reproducability% or click to select a new reproducability', array('%clear_the_reproducability%' => ''))); if ($this->issue->isEditable() && $this->issue->canEditReproducability()) { $fields_list['reproducability']['choices'] = TBGReproducability::getAll(); } $fields_list['severity'] = array('title' => $i18n->__('Severity'), 'visible' => $this->issue->isSeverityVisible(), 'changed' => $this->issue->isSeverityChanged(), 'merged' => $this->issue->isSeverityMerged(), 'name' => $this->issue->getSeverity() instanceof TBGSeverity ? $this->issue->getSeverity()->getName() : '', 'name_visible' => (bool) ($this->issue->getSeverity() instanceof TBGSeverity), 'noname_visible' => (bool) (!$this->issue->getSeverity() instanceof TBGSeverity), 'icon' => false, 'change_tip' => $i18n->__('Click to change severity'), 'change_header' => $i18n->__('Change severity'), 'clear' => $i18n->__('Clear the severity'), 'select' => $i18n->__('%clear_the_severity% or click to select a new severity', array('%clear_the_severity%' => ''))); if ($this->issue->isUpdateable() && $this->issue->canEditSeverity()) { $fields_list['severity']['choices'] = TBGSeverity::getAll(); } $fields_list['milestone'] = array('title' => $i18n->__('Targetted for'), 'visible' => $this->issue->isMilestoneVisible(), 'changed' => $this->issue->isMilestoneChanged(), 'merged' => $this->issue->isMilestoneMerged(), 'name' => $this->issue->getMilestone() instanceof TBGMilestone ? $this->issue->getMilestone()->getName() : '', 'name_visible' => (bool) ($this->issue->getMilestone() instanceof TBGMilestone), 'noname_visible' => (bool) (!$this->issue->getMilestone() instanceof TBGMilestone), 'icon' => true, 'icon_name' => 'icon_milestones.png', 'change_tip' => $i18n->__('Click to change which milestone this issue is targetted for'), 'change_header' => $i18n->__('Set issue target / milestone'), 'clear' => $i18n->__('Set as not targetted'), 'select' => $i18n->__('%set_as_not_targetted% or click to set a new target milestone', array('%set_as_not_targetted%' => ''))); if ($this->issue->isUpdateable() && $this->issue->canEditMilestone()) { $fields_list['milestone']['choices'] = $this->issue->getProject()->getAllMilestones(); } $customfields_list = array(); foreach (TBGCustomDatatype::getAll() as $key => $customdatatype) { $changed_methodname = "isCustomfield{$key}Changed"; $merged_methodname = "isCustomfield{$key}Merged"; $customfields_list[$key] = array('type' => $customdatatype->getType(), 'title' => $i18n->__($customdatatype->getDescription()), 'visible' => $this->issue->isFieldVisible($key), 'changed' => $this->issue->{$changed_methodname}(), 'merged' => $this->issue->{$merged_methodname}(), 'change_tip' => $i18n->__($customdatatype->getInstructions()), 'change_header' => $i18n->__($customdatatype->getDescription()), 'clear' => $i18n->__('Clear this field'), 'select' => $i18n->__('%clear_this_field% or click to set a new value', array('%clear_this_field%' => ''))); if ($customdatatype->hasCustomOptions()) { $customfields_list[$key]['name'] = $this->issue->getCustomField($key) instanceof TBGCustomDatatypeOption ? $this->issue->getCustomField($key)->getName() : ''; $customfields_list[$key]['name_visible'] = (bool) ($this->issue->getCustomField($key) instanceof TBGCustomDatatypeOption); $customfields_list[$key]['noname_visible'] = (bool) (!$this->issue->getCustomField($key) instanceof TBGCustomDatatypeOption); $customfields_list[$key]['choices'] = $customdatatype->getOptions(); } else { $customfields_list[$key]['name'] = $this->issue->getCustomField($key); $customfields_list[$key]['name_visible'] = (bool) ($this->issue->getCustomField($key) != ''); $customfields_list[$key]['noname_visible'] = (bool) ($this->issue->getCustomField($key) == ''); } } $this->fields_list = $fields_list; $this->customfields_list = $customfields_list; if (isset($this->transition) && $this->transition->hasAction(TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE)) { $available_assignees = array(); foreach (TBGContext::getUser()->getTeams() as $team) { foreach ($team->getMembers() as $user) { $available_assignees[$user->getID()] = $user->getNameWithUsername(); } } foreach (TBGContext::getUser()->getFriends() as $user) { $available_assignees[$user->getID()] = $user->getNameWithUsername(); } $this->available_assignees = $available_assignees; } }
public function componentFilter() { $pkey = TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : null; $i18n = TBGContext::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' => TBGStatus::getAll()); $filters['category'] = array('description' => $i18n->__('Category'), 'options' => TBGCategory::getAll()); $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => TBGPriority::getAll()); $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => TBGSeverity::getAll()); $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => TBGReproducability::getAll()); $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => TBGResolution::getAll()); $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => TBGIssuetype::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 (TBGContext::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 = TBGProject::getIncludingAllSubprojectsAsArray(TBGContext::getCurrentProject()); foreach ($projects as $project) { if ($project->getID() == TBGContext::getCurrentProject()->getID()) { continue; } $filters['subprojects']['options'][$project->getID()] = "{$project->getName()} ({$project->getKey()})"; } } else { $projects = array(); foreach (TBGProject::getAllRootProjects() as $project) { TBGProject::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; }
protected function _populateStatusCount() { if ($this->_statuscount === null) { $this->_statuscount = array(); $this->_statuscount[0] = array('open' => 0, 'closed' => 0, 'percentage' => 0); foreach (TBGStatus::getAll() as $status_id => $status) { $this->_statuscount[$status_id] = array('open' => 0, 'closed' => 0, 'percentage' => 0); } foreach (TBGIssuesTable::getTable()->getStatusCountByProjectID($this->getID()) as $status_id => $status_count) { $this->_statuscount[$status_id] = $status_count; } } }
<?php echo __('Resolution must be any of these values'); ?> <?php } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID) { ?> <?php echo __('Reproducability must be any of these values'); ?> <?php } ?> </label> <?php if ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_STATUS_VALID) { $options = TBGStatus::getAll(); } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_PRIORITY_VALID) { $options = TBGPriority::getAll(); } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID) { $options = TBGResolution::getAll(); } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID) { $options = TBGReproducability::getAll(); } elseif ($rule->getRule() == TBGWorkflowTransitionValidationRule::ACTION_ASSIGN_ISSUE) { $options = $available_assignees; } ?> <?php foreach ($options as $option) { ?> <br><input type="checkbox" style="margin-left: 25px;" name="rule_value[<?php echo $option->getID();
public static function processCommit(TBGProject $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null) { $output = ''; TBGContext::setCurrentProject($project); if ($project->isArchived()) { return; } try { TBGContext::getI18n(); } catch (Exception $e) { TBGContext::reinitializeI18n(null); } // Is VCS Integration enabled? if (TBGSettings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == TBGVCSIntegration::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 = TBGIssue::getIssuesFromTextByRegex($commit_msg); $issues = $parsed_commit["issues"]; $transitions = $parsed_commit["transitions"]; // If no issues exist, we may not be able to continue // if (count($issues) == 0) // { // $output .= '[VCS '.$project->getKey().'] This project only accepts commits which affect issues' . "\n"; // return $output; // } // 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 */ if (preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) { $email = $matches[0]; // a) $user = TBGUsersTable::getTable()->getByEmail($email); if (!$user instanceof TBGUser) { // Not found by email preg_match("/(?<=^)(.*)(?= <)/", $author, $matches); $author = $matches[0]; } } // b) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByRealname($author); } // c) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByBuddyname($author); } // d) if (!$user instanceof TBGUser) { $user = TBGUsersTable::getTable()->getByUsername($author); } // e) if (!$user instanceof TBGUser) { $user = TBGSettings::getDefaultUser(); } TBGContext::setUser($user); TBGSettings::forceSettingsReload(); TBGContext::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 TBGVCSIntegrationCommit(); $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); } $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 TBGVCSIntegrationIssueLink(); $inst->setIssue($issue); $inst->setCommit($commit); $inst->save(); // Process all commit-message transitions for an issue. foreach ($transitions[$issue->getFormattedIssueNo()] as $transition) { if (TBGSettings::get('vcs_workflow_' . $project->getID(), 'vcs_integration') == TBGVCSIntegration::WORKFLOW_ENABLED) { TBGContext::setUser($user); TBGSettings::forceSettingsReload(); TBGContext::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 = TBGResolution::getResolutionByKeyish($value)) instanceof TBGResolution) { TBGContext::getRequest()->setParameter('resolution_id', $resolution->getID()); } break; case 'status': if (($status = TBGStatus::getStatusByKeyish($value)) instanceof TBGStatus) { TBGContext::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(TBGContext::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 TBGVCSIntegrationFile(); $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"; } TBGEvent::createNew('vcs_integration', 'new_commit')->trigger(array('commit' => $commit)); return $output; }
public static function loadFixtures(TBGScope $scope, TBGWorkflow $workflow, $steps) { $rejected_resolutions = array(); $rejected_resolutions[] = TBGResolution::getResolutionByKeyish('notanissue')->getID(); $rejected_resolutions[] = TBGResolution::getResolutionByKeyish('wontfix')->getID(); $rejected_resolutions[] = TBGResolution::getResolutionByKeyish('cantfix')->getID(); $rejected_resolutions[] = TBGResolution::getResolutionByKeyish('cantreproduce')->getID(); $rejected_resolutions[] = TBGResolution::getResolutionByKeyish('duplicate')->getID(); $resolved_resolutions = array(); $resolved_resolutions[] = TBGResolution::getResolutionByKeyish('resolved')->getID(); $resolved_resolutions[] = TBGResolution::getResolutionByKeyish('wontfix')->getID(); $resolved_resolutions[] = TBGResolution::getResolutionByKeyish('postponed')->getID(); $resolved_resolutions[] = TBGResolution::getResolutionByKeyish('duplicate')->getID(); $closed_statuses = array(); $closed_statuses[] = TBGStatus::getStatusByKeyish('closed')->getID(); $closed_statuses[] = TBGStatus::getStatusByKeyish('postponed')->getID(); $closed_statuses[] = TBGStatus::getStatusByKeyish('done')->getID(); $closed_statuses[] = TBGStatus::getStatusByKeyish('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(TBGWorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES => 5), 'actions' => array(TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0)); $transitions['confirmissue'] = array('name' => 'Confirm issue', 'description' => 'Confirm that the issue is valid', 'outgoing_step' => 'confirmed', 'template' => null, 'actions' => array(TBGWorkflowTransitionAction::ACTION_SET_PERCENT => 10, TBGWorkflowTransitionAction::ACTION_SET_PRIORITY)); $transitions['rejectissue'] = array('name' => 'Reject issue', 'description' => 'Reject the issue as invalid', 'outgoing_step' => 'rejected', 'template' => 'main/updateissueproperties', 'post_validations' => array(TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID => join(',', $rejected_resolutions)), 'actions' => array(TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, TBGWorkflowTransitionAction::ACTION_SET_PERCENT => 100, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES => 5), 'actions' => array(TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE_SELF => 0, TBGWorkflowTransitionAction::ACTION_USER_START_WORKING => 0)); $transitions['reopenissue'] = array('name' => 'Reopen issue', 'description' => 'Reopen the issue', 'outgoing_step' => 'new', 'template' => null, 'actions' => array(TBGWorkflowTransitionAction::ACTION_CLEAR_RESOLUTION => 0, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE => 0, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, TBGWorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0)); $transitions['resolveissue'] = array('name' => 'Resolve issue', 'description' => 'Resolve the issue', 'outgoing_step' => 'closed', 'template' => 'main/updateissueproperties', 'post_validations' => array(TBGWorkflowTransitionValidationRule::RULE_STATUS_VALID => join(',', $closed_statuses), TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID => join(',', $resolved_resolutions)), 'actions' => array(TBGWorkflowTransitionAction::ACTION_SET_STATUS => 0, TBGWorkflowTransitionAction::ACTION_SET_PERCENT => 100, TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_ASSIGN_ISSUE_SELF => 0, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, TBGWorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, TBGWorkflowTransitionAction::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(TBGWorkflowTransitionAction::ACTION_SET_RESOLUTION => 0, TBGWorkflowTransitionAction::ACTION_CLEAR_ASSIGNEE => 0, TBGWorkflowTransitionAction::ACTION_USER_STOP_WORKING => 0)); foreach ($transitions as $key => $transition) { $transition_object = new TBGWorkflowTransition(); $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 TBGWorkflowTransitionValidationRule(); $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 TBGWorkflowTransitionValidationRule(); $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 TBGWorkflowTransitionAction(); $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; }
<table class="cleantable"> <thead> <tr> <th><?php echo __('Name'); ?> </th> <th><?php echo __('ID'); ?> </th> </tr> </thead> <tbody> <?php foreach (TBGStatus::getAll() as $item) { ?> <tr><td><?php echo $item->getName(); ?> </td><td><?php echo $item->getID(); ?> </td></tr> <?php } ?> </tbody> </table> </div> <br class="clear" />
public function runBulkUpdateIssues(TBGRequest $request) { $issue_ids = $request['issue_ids']; $options = array('issue_ids' => array_values($issue_ids)); TBGContext::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 TBGMilestone(); $milestone->setProject(TBGContext::getCurrentProject()); $milestone->setName($request['milestone_name']); $milestone->save(); $options['milestone_url'] = TBGContext::getRouting()->generate('project_planning_milestone', array('project_key' => $milestone->getProject()->getKey(), 'milestone_id' => $milestone->getID())); } elseif ($request['milestone']) { $milestone = new TBGMilestone($request['milestone']); } $milestone_id = $milestone instanceof TBGMilestone ? $milestone->getID() : null; foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($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 TBGStatus($request['status']); foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($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 TBGSeverity($request['severity']) : null; foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($issue_id); $severity_id = $severity instanceof TBGSeverity ? $severity->getID() : 0; $issue->setSeverity($severity_id); $issue->save(); } } $options['severity'] = array('name' => $severity instanceof TBGSeverity ? $severity->getName() : '-', 'id' => $severity instanceof TBGSeverity ? $severity->getID() : 0); } break; case 'set_resolution': if (is_numeric($request['resolution'])) { $resolution = $request['resolution'] ? new TBGResolution($request['resolution']) : null; foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($issue_id); $resolution_id = $resolution instanceof TBGResolution ? $resolution->getID() : 0; $issue->setResolution($resolution_id); $issue->save(); } } $options['resolution'] = array('name' => $resolution instanceof TBGResolution ? $resolution->getName() : '-', 'id' => $resolution instanceof TBGResolution ? $resolution->getID() : 0); } break; case 'set_priority': if (is_numeric($request['priority'])) { $priority = $request['priority'] ? new TBGPriority($request['priority']) : null; foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($issue_id); $priority_id = $priority instanceof TBGPriority ? $priority->getID() : 0; $issue->setPriority($priority_id); $issue->save(); } } $options['priority'] = array('name' => $priority instanceof TBGPriority ? $priority->getName() : '-', 'id' => $priority instanceof TBGPriority ? $priority->getID() : 0); } break; case 'set_category': if (is_numeric($request['category'])) { $category = $request['category'] ? new TBGCategory($request['category']) : null; foreach (array_keys($issue_ids) as $issue_id) { if (is_numeric($issue_id)) { $issue = new TBGIssue($issue_id); $category_id = $category instanceof TBGCategory ? $category->getID() : 0; $issue->setCategory($category_id); $issue->save(); } } $options['category'] = array('name' => $category instanceof TBGCategory ? $category->getName() : '-', 'id' => $category instanceof TBGCategory ? $category->getID() : 0); } break; } } return $this->renderJSON($options); }
protected function _setupReportIssueProperties() { $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 (TBGCustomDatatype::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 = TBGCategory::getAll(); $this->severities = TBGSeverity::getAll(); $this->priorities = TBGPriority::getAll(); $this->reproducabilities = TBGReproducability::getAll(); $this->resolutions = TBGResolution::getAll(); $this->statuses = TBGStatus::getAll(); $this->milestones = TBGContext::getCurrentProject()->getMilestonesForIssues(); }
/** * Return an array specifying visibility, requirement and choices for fields in issues * * @param integer $issue_type * @param boolean $reportable[optional] Whether to only include fields that can be reported * * @return array */ protected function _getFieldsArray($issue_type, $reportable = true) { $issue_type = is_object($issue_type) ? $issue_type->getID() : $issue_type; if (!isset($this->_fieldsarrays[$issue_type][(int) $reportable])) { $retval = array(); $res = B2DB::getTable('TBGIssueFieldsTable')->getBySchemeIDandIssuetypeID($this->getIssuetypeScheme()->getID(), $issue_type); if ($res) { $builtin_types = TBGDatatype::getAvailableFields(true); while ($row = $res->getNextRow()) { if (!$reportable || (bool) $row->get(TBGIssueFieldsTable::REPORTABLE) == true) { if ($reportable) { if (in_array($row->get(TBGIssueFieldsTable::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(TBGIssueFieldsTable::FIELD_KEY), $reportable) && !($row->get(TBGIssueFieldsTable::REQUIRED) && $reportable))) { continue; } elseif (!in_array($row->get(TBGIssueFieldsTable::FIELD_KEY), $builtin_types) && (!$this->fieldPermissionCheck($row->get(TBGIssueFieldsTable::FIELD_KEY), $reportable, true) && !($row->get(TBGIssueFieldsTable::REQUIRED) && $reportable))) { continue; } } $field_key = $row->get(TBGIssueFieldsTable::FIELD_KEY); $retval[$field_key] = array('required' => (bool) $row->get(TBGIssueFieldsTable::REQUIRED), 'additional' => (bool) $row->get(TBGIssueFieldsTable::ADDITIONAL)); if (!in_array($field_key, $builtin_types)) { $retval[$field_key]['custom'] = true; $custom_type = TBGCustomDatatype::getByKey($field_key); if ($custom_type instanceof TBGCustomDatatype) { $retval[$field_key]['custom_type'] = $custom_type->getType(); } else { unset($retval[$field_key]); } } } } if (array_key_exists('user_pain', $retval)) { $retval['pain_bug_type'] = array('required' => $retval['user_pain']['required']); $retval['pain_likelihood'] = array('required' => $retval['user_pain']['required']); $retval['pain_effect'] = array('required' => $retval['user_pain']['required']); } if ($reportable) { foreach ($retval as $key => $return_details) { if ($key == 'edition' || array_key_exists('custom', $return_details) && $return_details['custom'] && in_array($return_details['custom_type'], array(TBGCustomDatatype::EDITIONS_LIST, TBGCustomDatatype::EDITIONS_CHOICE))) { $retval[$key]['values'] = array(); $retval[$key]['values'][''] = TBGContext::getI18n()->__('None'); foreach ($this->getEditions() as $edition) { $retval[$key]['values'][$edition->getID()] = $edition->getName(); } if (!$this->isEditionsEnabled() || empty($retval[$key]['values'])) { if (!$retval[$key]['required']) { unset($retval[$key]); } else { unset($retval[$key]['values']); } } if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) { asort($retval[$key]['values'], SORT_STRING); } } elseif ($key == 'status' || array_key_exists('custom', $return_details) && $return_details['custom'] && in_array($return_details['custom_type'], array(TBGCustomDatatype::EDITIONS_LIST, TBGCustomDatatype::STATUS_CHOICE))) { $retval[$key]['values'] = array(); foreach (TBGStatus::getAll() as $status) { $retval[$key]['values'][$status->getID()] = $status->getName(); } if (empty($retval[$key]['values'])) { if (!$retval[$key]['required']) { unset($retval[$key]); } else { unset($retval[$key]['values']); } } if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) { asort($retval[$key]['values'], SORT_STRING); } } elseif ($key == 'component' || array_key_exists('custom', $return_details) && $return_details['custom'] && in_array($return_details['custom_type'], array(TBGCustomDatatype::COMPONENTS_LIST, TBGCustomDatatype::COMPONENTS_CHOICE))) { $retval[$key]['values'] = array(); $retval[$key]['values'][''] = TBGContext::getI18n()->__('None'); foreach ($this->getComponents() as $component) { $retval[$key]['values'][$component->getID()] = $component->getName(); } if (!$this->isComponentsEnabled() || empty($retval[$key]['values'])) { if (!$retval[$key]['required']) { unset($retval[$key]); } else { unset($retval[$key]['values']); } } if (array_key_exists($key, $retval) && array_key_exists('values', $retval[$key])) { asort($retval[$key]['values'], SORT_STRING); } } elseif ($key == 'build' || array_key_exists('custom', $return_details) && $return_details['custom'] && in_array($return_details['custom_type'], array(TBGCustomDatatype::RELEASES_LIST, TBGCustomDatatype::RELEASES_CHOICE))) { $retval[$key]['values'] = array(); $retval[$key]['values'][''] = TBGContext::getI18n()->__('None'); foreach ($this->getBuilds() as $build) { $retval[$key]['values'][$build->getID()] = $build->getName() . ' (' . $build->getVersion() . ')'; } if (!$this->isBuildsEnabled() || empty($retval[$key]['values'])) { if (!$retval[$key]['required']) { unset($retval[$key]); } else { unset($retval[$key]['values']); } } } } } } $this->_fieldsarrays[$issue_type][(int) $reportable] = $retval; } return $this->_fieldsarrays[$issue_type][(int) $reportable]; }
public function runAddAffected(TBGRequest $request) { TBGContext::loadLibrary('ui'); try { $issue = TBGContext::factory()->TBGIssue($request['issue_id']); $statuses = TBGStatus::getAll(); switch ($request['item_type']) { case 'edition': if (!$issue->getProject()->isEditionsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('Editions are disabled'))); } elseif (!$issue->canEditAffectedEditions()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('You are not allowed to do this'))); } $edition = TBGContext::factory()->TBGEdition($request['which_item_edition']); if (TBGIssueAffectsEditionTable::getTable()->getByIssueIDandEditionID($issue->getID(), $edition->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('%item is already affected by this issue', array('%item' => $edition->getName())))); } $edition = $issue->addAffectedEdition($edition); $item = $edition; $itemtype = 'edition'; $itemtypename = TBGContext::getI18n()->__('Edition'); $content = get_template_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); $message = TBGContext::getI18n()->__('Edition <b>%edition</b> is now affected by this issue', array('%edition' => $edition['edition']->getName())); break; case 'component': if (!$issue->getProject()->isComponentsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('Components are disabled'))); } elseif (!$issue->canEditAffectedComponents()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('You are not allowed to do this'))); } $component = TBGContext::factory()->TBGComponent($request['which_item_component']); if (TBGIssueAffectsComponentTable::getTable()->getByIssueIDandComponentID($issue->getID(), $component->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('%item is already affected by this issue', array('%item' => $component->getName())))); } $component = $issue->addAffectedComponent($component); $item = $component; $itemtype = 'component'; $itemtypename = TBGContext::getI18n()->__('Component'); $content = get_template_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); $message = TBGContext::getI18n()->__('Component <b>%component</b> is now affected by this issue', array('%component' => $component['component']->getName())); break; case 'build': if (!$issue->getProject()->isBuildsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('Releases are disabled'))); } elseif (!$issue->canEditAffectedBuilds()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('You are not allowed to do this'))); } $build = TBGContext::factory()->TBGBuild($request['which_item_build']); if (TBGIssueAffectsBuildTable::getTable()->getByIssueIDandBuildID($issue->getID(), $build->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('%item is already affected by this issue', array('%item' => $build->getName())))); } $build = $issue->addAffectedBuild($build); $item = $build; $itemtype = 'build'; $itemtypename = TBGContext::getI18n()->__('Release'); $content = get_template_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); $message = TBGContext::getI18n()->__('Release <b>%build</b> is now affected by this issue', array('%build' => $build['build']->getName())); break; default: throw new Exception('Internal error'); break; } $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())); } }
?> style="display: none;"<?php } ?> > <?php echo __('Not determined'); ?> </span><?php break; case TBGCustomDatatype::STATUS_CHOICE: $status = null; $value = null; $color = '#FFF'; try { $status = new TBGStatus($info['name']); $value = $status->getName(); $color = $status->getColor(); } catch (Exception $e) { } ?> <span id="<?php echo $field; ?> _name"<?php if (!$info['name_visible']) { ?> style="display: none;"<?php } ?> ><div class="status_badge" style="background-color: <?php
public function processIncomingEmailCommand($content, TBGIssue $issue, TBGUser $user) { 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 = TBGResolution::getResolutionByKeyish($val)) instanceof TBGResolution) { TBGContext::getRequest()->setParameter('resolution_id', $resolution->getID()); } break; case 'status': if (($status = TBGStatus::getStatusByKeyish($val)) instanceof TBGStatus) { TBGContext::getRequest()->setParameter('status_id', $status->getID()); } break; } } } TBGContext::getRequest()->setParameter('comment_body', join("\n", $lines)); return $transition->transitionIssueToOutgoingStepWithoutRequest($issue); } } }