Exemple #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;
 }
 public static function loadFixtures(TBGScope $scope)
 {
     $scheme = new TBGIssuetypeScheme();
     $scheme->setScope($scope->getID());
     $scheme->setName("Default issuetype scheme");
     $scheme->setDescription("This is the default issuetype scheme. It is used by all projects with no specific issuetype scheme selected. This scheme cannot be edited or removed.");
     $scheme->save();
     foreach (TBGIssuetype::getAll() as $issuetype) {
         $scheme->setIssuetypeEnabled($issuetype);
         if ($issuetype->getIcon() == 'developer_report') {
             $scheme->setIssuetypeRedirectedAfterReporting($issuetype, false);
         }
         if (in_array($issuetype->getIcon(), array('task', 'developer_report', 'idea'))) {
             $scheme->setIssuetypeReportable($issuetype, false);
         }
     }
     return $scheme;
 }
 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');
         }
     }
 }
 /**
  * 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));
             }
         }
     }
 }
 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;
 }
 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();
                 }
             }
     }
 }
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');
 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;
 }
    ?>
</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 
 /** 
  * 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;
 }
 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;
 }