예제 #1
0
 public function runListIssuetypes(TBGRequest $request)
 {
     $issuetypes = TBGIssuetype::getAll();
     $return_array = array();
     foreach ($issuetypes as $issuetype) {
         $return_array[] = $issuetype->getName();
     }
     $this->issuetypes = $return_array;
 }
 public static function getIssueRegex()
 {
     if (!($regex = TBGCache::get(TBGCache::KEY_TEXTPARSER_ISSUE_REGEX))) {
         $issue_strings = array('bug', 'issue', 'ticket', 'story');
         foreach (TBGIssuetype::getAll() as $issuetype) {
             $issue_strings[] = $issuetype->getName();
         }
         $issue_string = join('|', $issue_strings);
         $issue_string = html_entity_decode($issue_string, ENT_QUOTES);
         $issue_string = str_replace(array(' ', "'"), array('\\s{1,1}', "\\'"), $issue_string);
         $regex = '#( |^)(?<!\\!)((' . $issue_string . ')\\s\\#?(([A-Z0-9]+\\-)?\\d+))#i';
         TBGCache::add(TBGCache::KEY_TEXTPARSER_ISSUE_REGEX, $regex);
     }
     return $regex;
 }
 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;
 }
예제 #4
0
 public function loadFixtures()
 {
     // Load initial settings
     TBGSettingsTable::getTable()->loadFixtures($this);
     TBGSettings::loadSettings();
     // Load group, users and permissions fixtures
     TBGGroup::loadFixtures($this);
     // Load initial teams
     TBGTeam::loadFixtures($this);
     // Set up user states, like "available", "away", etc
     TBGUserstate::loadFixtures($this);
     // Set up data types
     list($b_id, $f_id, $e_id, $t_id, $u_id, $i_id) = TBGIssuetype::loadFixtures($this);
     $scheme = TBGIssuetypeScheme::loadFixtures($this);
     TBGIssueFieldsTable::getTable()->loadFixtures($this, $scheme, $b_id, $f_id, $e_id, $t_id, $u_id, $i_id);
     TBGDatatype::loadFixtures($this);
     // Set up workflows
     TBGWorkflow::loadFixtures($this);
     TBGWorkflowSchemesTable::getTable()->loadFixtures($this);
     TBGWorkflowIssuetypeTable::getTable()->loadFixtures($this);
     // Set up left menu links
     TBGLinksTable::getTable()->loadFixtures($this);
 }
 public function setFieldAvailableForIssuetype(TBGIssuetype $issuetype, $key, $details = array())
 {
     TBGIssueFieldsTable::getTable()->addFieldAndDetailsBySchemeIDandIssuetypeID($this->getID(), $issuetype->getID(), $key, $details);
 }
예제 #6
0
 protected function _upgradeFrom3dot0()
 {
     // Add new tables
     TBGScopeHostnamesTable::getTable()->create();
     // Add classpath for existing old tables used for upgrade
     TBGContext::addClasspath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.0');
     // Upgrade old tables
     TBGScopesTable::getTable()->upgrade(TBGScopesTable3dot0::getTable());
     TBGIssueFieldsTable::getTable()->upgrade(TBGIssueFieldsTable3dot0::getTable());
     // Upgrade all modules
     foreach (TBGContext::getModules() as $module) {
         if (method_exists($module, 'upgradeFrom3dot0')) {
             $module->upgradeFrom3dot0();
         }
     }
     // Start a transaction to preserve the upgrade path
     $transaction = B2DB::startTransaction();
     // Add votes to feature requests for default issue type scheme
     $its = new TBGIssuetypeScheme(1);
     foreach (TBGIssuetype::getAll() as $fr) {
         if ($fr instanceof TBGIssuetype) {
             if (in_array($fr->getKey(), array('featurerequest', 'bugreport', 'enhancement'))) {
                 $its->setFieldAvailableForIssuetype($fr, 'votes');
             }
         }
     }
     $ut = TBGUsersTable::getTable();
     $crit = $ut->getCriteria();
     $crit->addUpdate(TBGUsersTable::PRIVATE_EMAIL, true);
     $ut->doUpdate($crit);
     // Add default gravatar setting
     TBGSettings::saveSetting(TBGSettings::SETTING_ENABLE_GRAVATARS, 1);
     $trans_crit = TBGWorkflowTransitionsTable::getTable()->getCriteria();
     $trans_crit->addWhere(TBGWorkflowTransitionsTable::NAME, 'Request more information');
     $trans_crit->addWhere(TBGWorkflowTransitionsTable::WORKFLOW_ID, 1);
     $trans_row = TBGWorkflowTransitionsTable::getTable()->doSelectOne($trans_crit);
     if ($trans_row) {
         $transition = new TBGWorkflowTransition($trans_row->get(TBGWorkflowTransitionsTable::ID), $trans_row);
         $transition->setTemplate('main/updateissueproperties');
         $transition->save();
     }
     // End transaction and finalize upgrade
     $transaction->commitAndEnd();
     $this->upgrade_complete = true;
 }
예제 #7
0
 /**
  * Move issues from one step to another for a given issue type and conversions
  * @param TBGProject $project
  * @param TBGIssuetype $type
  * @param array $conversions
  * 
  * $conversions should be an array containing arrays:
  * array (
  * 		array(oldstep, newstep)
  * 		...
  * )
  */
 public function convertIssueStepByIssuetype(TBGProject $project, TBGIssuetype $type, array $conversions)
 {
     foreach ($conversions as $conversion) {
         $crit = $this->getCriteria();
         $crit->addWhere(self::PROJECT_ID, $project->getID());
         $crit->addWhere(self::ISSUE_TYPE, $type->getID());
         $crit->addWhere(self::WORKFLOW_STEP_ID, $conversion[0]);
         $crit->addUpdate(self::WORKFLOW_STEP_ID, $conversion[1]);
         $this->doUpdate($crit);
     }
 }
예제 #8
0
 public static function getAvailableViews($target_type)
 {
     switch ($target_type) {
         case TBGDashboardView::TYPE_USER:
             $searches = array();
             $searches[self::VIEW_PREDEFINED_SEARCH] = array(TBGContext::PREDEFINED_SEARCH_MY_REPORTED_ISSUES => TBGContext::getI18n()->__('Issues reported by me'), TBGContext::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues assigned to me'), TBGContext::PREDEFINED_SEARCH_MY_OWNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues owned by me'), TBGContext::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues assigned to my teams'));
             $searches[self::VIEW_LOGGED_ACTIONS] = array(0 => TBGContext::getI18n()->__("What you've done recently"));
             if (TBGContext::getUser()->canViewComments()) {
                 $searches[self::VIEW_RECENT_COMMENTS] = array(0 => TBGContext::getI18n()->__('Recent comments'));
             }
             $searches[self::VIEW_SAVED_SEARCH] = array();
             $allsavedsearches = TBGSavedSearchesTable::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID());
             foreach ($allsavedsearches as $savedsearches) {
                 foreach ($savedsearches as $a_savedsearch) {
                     $searches[self::VIEW_SAVED_SEARCH][$a_savedsearch->getID()] = $a_savedsearch->getName();
                 }
             }
             break;
         case TBGDashboardView::TYPE_PROJECT:
             $issuetype_icons = array();
             foreach (TBGIssuetype::getAll() as $id => $issuetype) {
                 $issuetype_icons[$id] = TBGContext::getI18n()->__('Recent issues: %issuetype', array('%issuetype' => $issuetype->getName()));
             }
             $searches = array();
             $searches[self::VIEW_PROJECT_INFO] = array(0 => TBGContext::getI18n()->__('About this project'));
             $searches[self::VIEW_PROJECT_TEAM] = array(0 => TBGContext::getI18n()->__('Project team'));
             $searches[self::VIEW_PROJECT_CLIENT] = array(0 => TBGContext::getI18n()->__('Project client'));
             $searches[self::VIEW_PROJECT_SUBPROJECTS] = array(0 => TBGContext::getI18n()->__('Subprojects'));
             $searches[self::VIEW_PROJECT_STATISTICS_LAST15] = array(0 => TBGContext::getI18n()->__('Graph of closed vs open issues, past 15 days'));
             $searches[self::VIEW_PROJECT_STATISTICS_PRIORITY] = array(0 => TBGContext::getI18n()->__('Statistics by priority'));
             $searches[self::VIEW_PROJECT_STATISTICS_SEVERITY] = array(0 => TBGContext::getI18n()->__('Statistics by severity'));
             $searches[self::VIEW_PROJECT_STATISTICS_CATEGORY] = array(0 => TBGContext::getI18n()->__('Statistics by category'));
             $searches[self::VIEW_PROJECT_STATISTICS_STATUS] = array(0 => TBGContext::getI18n()->__('Statistics by status'));
             $searches[self::VIEW_PROJECT_STATISTICS_RESOLUTION] = array(0 => TBGContext::getI18n()->__('Statistics by resolution'));
             $searches[self::VIEW_PROJECT_STATISTICS_WORKFLOW_STEP] = array(0 => TBGContext::getI18n()->__('Statistics by workflow step'));
             $searches[self::VIEW_PROJECT_RECENT_ISSUES] = $issuetype_icons;
             $searches[self::VIEW_PROJECT_RECENT_ACTIVITIES] = array(0 => TBGContext::getI18n()->__('Recent activities'));
             $searches[self::VIEW_PROJECT_UPCOMING] = array(0 => TBGContext::getI18n()->__('Upcoming milestones and deadlines'));
             $searches[self::VIEW_PROJECT_DOWNLOADS] = array(0 => TBGContext::getI18n()->__('Latest downloads'));
             break;
     }
     return $searches;
 }
 /**
  * Get all steps in this workflow
  *
  * @return array An array of TBGWorkflowStep objects
  */
 public function getWorkflowForIssuetype(TBGIssuetype $issuetype)
 {
     $this->_populateAssociatedWorkflows();
     if (array_key_exists($issuetype->getID(), $this->_issuetype_workflows)) {
         return $this->_issuetype_workflows[$issuetype->getID()];
     } else {
         return TBGSettings::getCoreWorkflow();
     }
 }
예제 #10
0
 /**
  * Returns an array of issue types
  *
  * @param integer $scope_id  The ID number of the scope to load issue types from
  * @return array
  */
 public static function getAll()
 {
     if (self::$_issuetypes === null) {
         self::$_issuetypes = TBGIssueTypesTable::getTable()->getAll();
     }
     return self::$_issuetypes;
 }
예제 #11
0
 public function componentIssueType()
 {
     $this->icons = TBGIssuetype::getIcons();
 }
예제 #12
0
    ?>
</label></td>
						<td style="width: auto;">
							<select name="issuetype" id="build_<?php 
    echo $b_id;
    ?>
_issuetype">
								<option value="" selected><?php 
    echo __('All issue types');
    ?>
</option>
								<?php 
    if ($build->getProject() instanceof TBGProject) {
        ?>
									<?php 
        foreach (TBGIssuetype::getAll($build->getProject()->getID()) as $anIssuetype) {
            ?>
										<option value=<?php 
            echo $anIssuetype->getID();
            ?>
><?php 
            echo $anIssuetype->getName();
            ?>
</option>
									<?php 
        }
        ?>
								<?php 
    } else {
        ?>
									<?php 
예제 #13
0
 /** 
  * Returns an array of regular expressions that should be used for matching
  * the issue numbers and workflow transitions in a VCS commit.
  *
  * Each element of an array is a single regular expression that will be
  * applied against the incoming commit message. Each regular expression
  * should have two named patterns - one denoting the issue number (should
  * include prefix if used in project), and one denoting workflow
  * transitions.
  *
  * Simple example would be:
  *
  * '#fixes issue #(?P<issues>([A-Z0-9]+\-)?\d+) (?P<transitions> \(.*?\))?#i'
  * 
  * @return array
  */
 public static function getIssueRegex()
 {
     // Try getting the regexes from cache first.
     if (!($regex = TBGCache::get(TBGCache::KEY_TEXTPARSER_ISSUE_REGEX))) {
         // List of keywords that are expected to prefix the issue number in a
         // commit message (these are _not_ project prefixes).
         $issue_strings = array('bug', 'issue', 'ticket', 'fix', 'fixes', 'fixed', 'fixing', 'applies to', 'closes', 'references', 'ref', 'addresses', 're', 'see', 'according to', 'also see', 'story');
         // Add the issue types as prefixes as well.
         foreach (TBGIssuetype::getAll() as $issuetype) {
             $issue_strings[] = $issuetype->getName();
         }
         // Construct the OR'ed (|) regex out of issue prefixes.
         $issue_string = join('|', $issue_strings);
         $issue_string = html_entity_decode($issue_string, ENT_QUOTES);
         $issue_string = str_replace(array(' ', "'"), array('\\s{1,1}', "\\'"), $issue_string);
         // Store all regular expressions for mathces in an array.
         $regex = array();
         // This regex will match messages that contain template like "KEYWORD
         // (#)ISSUE_NUMBER (TRANSITIONS)" (parenthesis means optional). For
         // example:
         // "Resolves issue #2 (Resolve issue)"
         $regex[] = '#( |^)(?<!\\!)((' . $issue_string . ')\\s\\#?(?P<issues>([A-Z0-9]+\\-)?\\d+))( \\((?P<transitions>.*?)\\))?#i';
         // This regex will match messages that contain template at the beginning
         // of message in format "ISSUE_NUMBER: (TRANSITIONS)".
         $regex[] = '#^(?<!\\!)((?P<issues>([A-Z0-9]+\\-)?\\d+)):( \\((?P<transitions>.*?)\\))?#i';
         // Add the constructed regexes to cache.
         TBGCache::add(TBGCache::KEY_TEXTPARSER_ISSUE_REGEX, $regex);
     }
     // Return the regular expressions.
     return $regex;
 }
예제 #14
0
 public function runListIssuefields(TBGRequest $request)
 {
     try {
         $issuetype = TBGIssuetype::getIssuetypeByKeyish($request->getParameter('issuetype'));
         $issuefields = $this->selected_project->getVisibleFieldsArray($issuetype->getID());
     } catch (Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => 'An exception occurred: ' . $e));
     }
     $this->issuefields = array_keys($issuefields);
 }
 /**
  * Returns an array of issue types
  *
  * @param integer $scope_id  The ID number of the scope to load issue types from
  * @return array
  */
 public static function getAll($scope_id = null)
 {
     if (self::$_issuetypes === null) {
         self::$_issuetypes = array();
         $crit = TBGIssueTypesTable::getTable()->getCriteria();
         if ($scope_id === null) {
             $crit->addWhere(TBGIssueTypesTable::SCOPE, TBGContext::getScope()->getID());
         } else {
             $crit->addWhere(TBGIssueTypesTable::SCOPE, $scope_id);
         }
         $issuetypes = array();
         if ($res = TBGIssueTypesTable::getTable()->doSelect($crit, 'none')) {
             while ($row = $res->getNextRow()) {
                 $issuetypes[$row->get(TBGIssueTypesTable::ID)] = TBGContext::factory()->TBGIssuetype($res->get(TBGIssueTypesTable::ID), $row);
             }
         } else {
             TBGLogging::log('There are no issue types', 'main', TBGLogging::LEVEL_NOTICE);
         }
         self::$_issuetypes = $issuetypes;
     }
     return self::$_issuetypes;
 }
예제 #16
0
 public function runListIssues(TBGRequest $request)
 {
     $filters = array('project_id' => array('operator' => '=', 'value' => $this->selected_project->getID()));
     $filter_state = $request->getParameter('state', 'all');
     $filter_issuetype = $request->getParameter('issuetype', 'all');
     $filter_assigned_to = $request->getParameter('assigned_to', 'all');
     if (mb_strtolower($filter_state) != 'all') {
         $filters['state'] = array('operator' => '=', 'value' => '');
         if (mb_strtolower($filter_state) == 'open') {
             $filters['state']['value'] = TBGIssue::STATE_OPEN;
         } elseif (mb_strtolower($filter_state) == 'closed') {
             $filters['state']['value'] = TBGIssue::STATE_CLOSED;
         }
     }
     if (mb_strtolower($filter_issuetype) != 'all') {
         $issuetype = TBGIssuetype::getIssuetypeByKeyish($filter_issuetype);
         if ($issuetype instanceof TBGIssuetype) {
             $filters['issuetype'] = array('operator' => '=', 'value' => $issuetype->getID());
         }
     }
     if (mb_strtolower($filter_assigned_to) != 'all') {
         $user_id = 0;
         switch (mb_strtolower($filter_assigned_to)) {
             case 'me':
                 $user_id = TBGContext::getUser()->getID();
                 break;
             case 'none':
                 $user_id = 0;
                 break;
             default:
                 try {
                     $user = TBGUser::findUser(mb_strtolower($filter_assigned_to));
                     if ($user instanceof TBGUser) {
                         $user_id = $user->getID();
                     }
                 } catch (Exception $e) {
                 }
                 break;
         }
         $filters['assignee_user'] = array('operator' => '=', 'value' => $user_id);
     }
     list($this->issues, $this->count) = TBGIssue::findIssues($filters, 0);
     $this->return_issues = array();
 }
예제 #17
0
foreach (TBGReproducability::getAll() as $item) {
    echo '<tr><td>' . __('Reproducability') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGSeverity::getAll() as $item) {
    echo '<tr><td>' . __('Severity') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGCategory::getAll() as $item) {
    echo '<tr><td>' . __('Category') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGPriority::getAll() as $item) {
    echo '<tr><td>' . __('Priority') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGResolution::getAll() as $item) {
    echo '<tr><td>' . __('Resolution') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGIssuetype::getAll() as $item) {
    echo '<tr><td>' . __('Issue type') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
?>
							</tbody>
						</table>
						</div>
					</div>
				</div>
				<div id="tab_tbg_pane" style="padding-top: 0; width: 750px; display: none;">
					<div class="tab_content"><?php 
echo __('You can import data from previous version of The Bug Genie into your version 3 installation.');
?>
</div>
					<div class="tab_header"><?php 
echo __('BUGS 1.x');
예제 #18
0
 /**
  * Populates the internal array with unassigned user stories for the scrum page
  */
 protected function _populateUnassignedStories()
 {
     if ($this->_unassignedstories === null) {
         $this->_unassignedstories = array();
         $issuetypes = array();
         foreach (TBGIssuetype::getAll() as $issuetype) {
             if ($issuetype->getIcon() == 'developer_report') {
                 $issuetypes[] = $issuetype->getID();
             }
         }
         if ($res = TBGIssuesTable::getTable()->getByProjectIDandNoMilestoneandTypesAndState($this->getID(), $issuetypes, TBGIssue::STATE_OPEN)) {
             while ($row = $res->getNextRow()) {
                 $this->_unassignedstories[$row->get(TBGIssuesTable::ID)] = TBGContext::factory()->TBGIssue($row->get(TBGIssuesTable::ID));
             }
         }
     }
 }
예제 #19
0
 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();
                 }
             }
     }
 }
예제 #20
0
 public function runConfigureWorkflowScheme(TBGRequest $request)
 {
     $this->workflow_scheme = null;
     $this->mode = $request->getParameter('mode', 'list');
     try {
         $this->workflow_scheme = TBGContext::factory()->TBGWorkflowScheme($request->getParameter('scheme_id'));
         $this->issuetypes = TBGIssuetype::getAll();
         if (TBGContext::getScope()->isCustomWorkflowsEnabled() && $this->mode == 'copy_scheme') {
             if ($new_name = $request->getParameter('new_name')) {
                 $new_scheme = new TBGWorkflowScheme();
                 $new_scheme->setName($new_name);
                 $new_scheme->save();
                 foreach ($this->issuetypes as $issuetype) {
                     if ($this->workflow_scheme->hasWorkflowAssociatedWithIssuetype($issuetype)) {
                         $new_scheme->associateIssuetypeWithWorkflow($issuetype, $this->workflow_scheme->getWorkflowForIssuetype($issuetype));
                     }
                 }
                 return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflowscheme', array('scheme' => $new_scheme))));
             } else {
                 $this->error = TBGContext::getI18n()->__('Please enter a valid name');
             }
         } elseif (TBGContext::getScope()->isCustomWorkflowsEnabled() && $this->mode == 'delete_scheme') {
             $this->workflow_scheme->delete();
             return $this->renderJSON(array('success' => true, 'message' => TBGContext::getI18n()->__('The workflow scheme was deleted')));
         } elseif (TBGContext::getScope()->isCustomWorkflowsEnabled() && $request->isMethod(TBGRequest::POST)) {
             foreach ($request->getParameter('workflow_id', array()) as $issuetype_id => $workflow_id) {
                 $issuetype = TBGContext::factory()->TBGIssuetype($issuetype_id);
                 if ($workflow_id) {
                     $workflow = TBGContext::factory()->TBGWorkflow($workflow_id);
                     $this->workflow_scheme->associateIssuetypeWithWorkflow($issuetype, $workflow);
                 } else {
                     $this->workflow_scheme->unassociateIssuetype($issuetype);
                 }
             }
             return $this->renderJSON(array('success' => true, 'message' => TBGContext::getI18n()->__('Workflow associations were updated')));
         }
     } catch (Exception $e) {
         if ($request->getRequestedFormat() == 'json') {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('success' => false, 'message' => TBGContext::getI18n()->__('An error occured'), 'error' => $e->getMessage()));
         } else {
             $this->error = TBGContext::getI18n()->__('This workflow scheme does not exist');
         }
     }
 }
예제 #21
0
 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;
 }