コード例 #1
0
 public function postConfigSettings(TBGRequest $request)
 {
     $settings = array('use_web_interface', 'vcs_passkey');
     foreach ($settings as $setting) {
         if ($request->hasParameter($setting)) {
             $this->saveSetting($setting, $request->getParameter($setting));
         }
     }
     foreach (TBGProject::getAll() as $aProduct) {
         if ($request->hasParameter('web_path_' . $aProduct->getID())) {
             // github is always at github.com
             if ($request->hasParameter('web_type_' . $aProduct->getID()) && $request->getParameter('web_type_' . $aProduct->getID()) == 'github') {
                 $this->saveSetting('web_path_' . $aProduct->getID(), 'http://github.com');
             } else {
                 $this->saveSetting('web_path_' . $aProduct->getID(), $request->getParameter('web_path_' . $aProduct->getID()));
             }
         }
         if ($request->hasParameter('web_type_' . $aProduct->getID())) {
             $this->saveSetting('web_type_' . $aProduct->getID(), $request->getParameter('web_type_' . $aProduct->getID()));
         }
         if ($request->hasParameter('web_repo_' . $aProduct->getID())) {
             $this->saveSetting('web_repo_' . $aProduct->getID(), $request->getParameter('web_repo_' . $aProduct->getID()));
         }
     }
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runListProjects(TBGRequest $request)
 {
     $projects = TBGProject::getAll();
     $return_array = array();
     foreach ($projects as $project) {
         $return_array[$project->getKey()] = $project->getName();
     }
     $this->projects = $return_array;
 }
コード例 #3
0
 /**
  * Configure projects
  * 
  * @param TBGRequest $request The request object
  */
 public function runConfigureProjects(TBGRequest $request)
 {
     $this->allProjects = TBGProject::getAll();
 }
コード例 #4
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runFilterGetDynamicChoices(TBGRequest $request)
 {
     $subproject_ids = explode(',', $request['subprojects']);
     $existing_ids = $request['existing_ids'];
     $results = array();
     $projects = $request['project_id'] != '' ? TBGProject::getAllByIDs(explode(',', $request['project_id'])) : TBGProject::getAll();
     $items = array('build' => array(), 'edition' => array(), 'component' => array(), 'milestone' => array());
     foreach ($projects as $project) {
         foreach ($project->getBuilds() as $build) {
             $items['build'][$build->getID()] = $build;
         }
         foreach ($project->getEditions() as $edition) {
             $items['edition'][$edition->getID()] = $edition;
         }
         foreach ($project->getComponents() as $component) {
             $items['component'][$component->getID()] = $component;
         }
         foreach ($project->getMilestones() as $milestone) {
             $items['milestone'][$milestone->getID()] = $milestone;
         }
     }
     $filters = array();
     $filters['build'] = TBGSearchFilter::createFilter('build');
     $filters['edition'] = TBGSearchFilter::createFilter('edition');
     $filters['component'] = TBGSearchFilter::createFilter('component');
     $filters['milestone'] = TBGSearchFilter::createFilter('milestone');
     if (isset($existing_ids['build'])) {
         foreach (TBGBuildsTable::getTable()->getByIDs($existing_ids['build']) as $build) {
             $items['build'][$build->getID()] = $build;
         }
         $filters['build']->setValue(join(',', $existing_ids['build']));
     }
     if (isset($existing_ids['edition'])) {
         foreach (TBGEditionsTable::getTable()->getByIDs($existing_ids['edition']) as $edition) {
             $items['edition'][$edition->getID()] = $edition;
         }
         $filters['edition']->setValue(join(',', $existing_ids['edition']));
     }
     if (isset($existing_ids['component'])) {
         foreach (TBGComponentsTable::getTable()->getByIDs($existing_ids['component']) as $component) {
             $items['component'][$component->getID()] = $component;
         }
         $filters['component']->setValue(join(',', $existing_ids['component']));
     }
     if (isset($existing_ids['milestone'])) {
         foreach (TBGMilestonesTable::getTable()->getByIDs($existing_ids['milestone']) as $milestone) {
             $items['milestone'][$milestone->getID()] = $milestone;
         }
         $filters['milestone']->setValue(join(',', $existing_ids['milestone']));
     }
     foreach (array('build', 'edition', 'component', 'milestone') as $k) {
         $results[$k] = $this->getTemplateHTML('search/interactivefilterdynamicchoicelist', array('filter' => $filters[$k], 'items' => $items[$k]));
     }
     return $this->renderJSON(compact('results'));
 }
コード例 #5
0
		</ul>
	</div>
	<div id="<?php 
echo $base_id;
?>
_tab_projects_pane" class="tab_pane" style="display: none;">
		<p><?php 
echo __('These permissions control what you can do, and which pages you can access in The Bug Genie - on a project-specific basis. Some of these permissions are also available as site-wide permissions, from the "%general_permissions%" tab.', array('%general_permissions%' => '<i>' . __('General permissions') . '</i>'));
?>
</p>
		<?php 
if (count(TBGProject::getAll()) > 0) {
    ?>
			<ul>
				<?php 
    foreach (TBGProject::getAll() as $project) {
        ?>
					<li>
						<a href="javascript:void(0);" onclick="$('project_permission_details_<?php 
        echo $project->getID();
        ?>
').toggle();"><?php 
        echo image_tag('icon_project_permissions.png', array('style' => 'float: right;'));
        echo $project->getName();
        ?>
 <span class="faded_out smaller"><?php 
        echo $project->getKey();
        ?>
</span></a>
						<ul style="display: none;" id="project_permission_details_<?php 
        echo $project->getID();
コード例 #6
0
 public function runAddFilter(TBGRequest $request)
 {
     if ($request->getParameter('filter_name') == 'project_id' && count(TBGProject::getAll()) == 0) {
         return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('No projects exist so this filter can not be added')));
     } elseif (in_array($request->getParameter('filter_name'), TBGIssuesTable::getValidSearchFilters()) || TBGCustomDatatype::doesKeyExist($request->getParameter('filter_name'))) {
         return $this->renderJSON(array('failed' => false, 'content' => $this->getComponentHTML('search/filter', array('filter' => $request->getParameter('filter_name'), 'key' => $request->getParameter('key', 0)))));
     } else {
         return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('This is not a valid search field')));
     }
 }
コード例 #7
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();
                 }
             }
     }
 }
コード例 #8
0
</th>
									<th><?php 
echo __('ID');
?>
</th>
								</tr>
							</thead>
							<tbody>
						<?php 
foreach (TBGIssuetypeScheme::getAll() as $item) {
    echo '<tr><td>' . __('Issue type scheme') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGWorkflowScheme::getAll() as $item) {
    echo '<tr><td>' . __('Workflow scheme') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
}
foreach (TBGProject::getAll() as $item) {
    echo '<tr><td>' . __('Project') . '</td><td>' . $item->getName() . '</td><td>' . $item->getID() . '</td></tr>';
    foreach (TBGMilestone::getAllByProjectID($item->getID()) as $item2) {
        echo '<tr><td>' . __('Milestone for project') . ' ' . $item->getID() . '</td><td>' . $item2->getName() . '</td><td>' . $item2->getID() . '</td></tr>';
    }
}
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) {
コード例 #9
0
 /**
  * Set the currently selected project
  * 
  * @param TBGProject $project The project, or null if none
  */
 public static function setCurrentProject($project)
 {
     self::getResponse()->setBreadcrumb(null);
     self::$_selected_project = $project;
     if ($project instanceof TBGProject) {
         $projectsubmenulinks = null;
         $clientsubmenulinks = null;
         if (count(TBGProject::getAll()) > 1) {
             $projectsubmenulinks = array();
             foreach (TBGProject::getAll() as $existing_project) {
                 if (!$project->hasClient() || $existing_project->hasClient() && $project->getClient()->getID() == $existing_project->getClient()->getID()) {
                     $projectsubmenulinks[] = array('url' => self::getRouting()->generate('project_dashboard', array('project_key' => $existing_project->getKey())), 'title' => $existing_project->getName());
                 }
             }
         }
         if (self::$_selected_project->hasClient()) {
             $clientsubmenulinks = array();
             foreach (TBGClient::getAll() as $client) {
                 if ($client->hasAccess()) {
                     $clientsubmenulinks[] = array('url' => self::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName());
                 }
             }
             self::setCurrentClient(self::$_selected_project->getClient());
         }
         if (strtolower(TBGSettings::getTBGname()) != strtolower($project->getName()) || self::isClientContext()) {
             self::getResponse()->addBreadcrumb(TBGSettings::getTBGName(), self::getRouting()->generate('home'));
             if (self::isClientContext()) {
                 self::getResponse()->addBreadcrumb(self::getCurrentClient()->getName(), self::getRouting()->generate('client_dashboard', array('client_id' => self::getCurrentClient()->getID())), $clientsubmenulinks);
             }
         }
         self::getResponse()->addBreadcrumb($project->getName(), self::getRouting()->generate('project_dashboard', array('project_key' => TBGContext::getCurrentProject()->getKey())), $projectsubmenulinks, 'selected_project');
     } else {
         self::getResponse()->addBreadcrumb(TBGSettings::getTBGName(), self::getRouting()->generate('home'));
     }
 }
コード例 #10
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 protected function _upgradeFrom3dot1()
 {
     // Add classpath for existing old tables used for upgrade
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.1');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes' . DS . 'B2DB');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes');
     // Create new tables
     TBGDashboardViewsTable::getTable()->create();
     TBGOpenIdAccountsTable::getTable()->create();
     TBGProjectAssignedUsersTable::getTable()->create();
     TBGProjectAssignedTeamsTable::getTable()->create();
     TBGEditionAssignedUsersTable::getTable()->create();
     TBGEditionAssignedTeamsTable::getTable()->create();
     TBGComponentAssignedUsersTable::getTable()->create();
     TBGComponentAssignedTeamsTable::getTable()->create();
     TBGRolePermissionsTable::getTable()->create();
     TBGUserScopesTable::getTable()->create();
     // Upgrade existing tables
     TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot1::getTable());
     TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot1::getTable());
     TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot1::getTable());
     TBGIssueTypesTable::getTable()->upgrade(TBGIssueTypesTable3dot1::getTable());
     TBGListTypesTable::getTable()->upgrade(TBGListTypesTable3dot1::getTable());
     TBGEditionsTable::getTable()->upgrade(TBGEditionsTable3dot1::getTable());
     TBGBuildsTable::getTable()->upgrade(TBGBuildsTable3dot1::getTable());
     TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot1::getTable());
     TBGComponentsTable::getTable()->upgrade(TBGComponentsTable3dot1::getTable());
     TBGCustomFieldsTable::getTable()->upgrade(TBGCustomFieldsTable3dot1::getTable());
     TBGCustomFieldOptionsTable::getTable()->upgrade(TBGCustomFieldOptionsTable3dot1::getTable());
     TBGIssueCustomFieldsTable::getTable()->upgrade(TBGIssueCustomFieldsTable3dot1::getTable());
     // Create new module tables
     TBGIncomingEmailAccountTable::getTable()->create();
     // Add new indexes
     TBGArticlesTable::getTable()->createIndexes();
     TBGCommentsTable::getTable()->createIndexes();
     TBGIssueAffectsBuildTable::getTable()->createIndexes();
     TBGIssueAffectsComponentTable::getTable()->createIndexes();
     TBGIssueAffectsEditionTable::getTable()->createIndexes();
     TBGIssueFieldsTable::getTable()->createIndexes();
     TBGIssueFilesTable::getTable()->createIndexes();
     TBGIssuesTable::getTable()->createIndexes();
     TBGIssuetypeSchemesTable::getTable()->createIndexes();
     TBGPermissionsTable::getTable()->createIndexes();
     TBGProjectsTable::getTable()->createIndexes();
     TBGSettingsTable::getTable()->createIndexes();
     TBGTeamMembersTable::getTable()->createIndexes();
     TBGUserIssuesTable::getTable()->createIndexes();
     TBGUsersTable::getTable()->createIndexes();
     TBGUserScopesTable::getTable()->createIndexes();
     if (TBGContext::getRequest()->getParameter('fix_my_timestamps', false)) {
         $this->_fixTimestamps();
     }
     foreach (TBGScope::getAll() as $scope) {
         TBGRole::loadFixtures($scope);
         foreach (TBGDatatype::getTypes() as $type => $class) {
             TBGContext::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID());
         }
         TBGContext::setPermission('page_confirm_scope_access', 0, 'core', 0, 0, 0, true, $scope->getID());
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOW, 'core', $scope->getID())) {
             $workflow_id = TBGWorkflowsTable::getTable()->getFirstIdByScope($scope->getID());
             if ($workflow_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOW, $workflow_id, 'core', $scope->getID());
             } else {
                 TBGWorkflow::loadFixtures($scope);
             }
         }
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, 'core', $scope->getID())) {
             $workflow_scheme_id = TBGWorkflowSchemesTable::getTable()->getFirstIdByScope($scope->getID());
             if ($workflow_scheme_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, $workflow_scheme_id, 'core', $scope->getID());
             } else {
                 TBGWorkflowScheme::loadFixtures($scope);
             }
         }
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, 'core', $scope->getID())) {
             $issuetype_scheme_id = TBGIssuetypeSchemesTable::getTable()->getFirstIdByScope($scope->getID());
             if ($issuetype_scheme_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, $issuetype_scheme_id, 'core', $scope->getID());
             } else {
                 TBGIssuetypeScheme::loadFixtures($scope);
             }
         }
         TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_ID, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_TYPE, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_ID, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_TYPE, 0, 'core', $scope->getID());
     }
     $linkstable = TBGLinksTable::getTable();
     $crit = $linkstable->getCriteria();
     $crit->addUpdate(TBGLinksTable::URL, 'http://issues.thebuggenie.com');
     $crit->addWhere(TBGLinksTable::URL, 'http://thebuggenie.com/thebuggenie');
     $crit->addOr(TBGLinksTable::URL, 'http://www.thebuggenie.com/thebuggenie');
     $linkstable->doUpdate($crit);
     $listtypestable = TBGListTypesTable::getTable();
     $crit = $listtypestable->getCriteria();
     $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'role');
     $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'projectrole');
     $listtypestable->doUpdate($crit);
     $crit = $listtypestable->getCriteria();
     $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'priority');
     $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'b2_prioritytypes');
     $listtypestable->doUpdate($crit);
     TBGWorkflowTransitionsTable::getTable()->upgradeFrom3dot1();
     TBGSettings::saveSetting(TBGSettings::SETTING_ICONSET, TBGSettings::get(TBGSettings::SETTING_THEME_NAME));
     TBGContext::setPermission('readarticle', 0, 'publish', 0, 0, 0, true);
     foreach (TBGProject::getAll() as $project) {
         TBGDashboardViewsTable::getTable()->setDefaultViews($project->getID(), TBGDashboardViewsTable::TYPE_PROJECT);
         if (!$project->getKey()) {
             $project->setName($project->getName());
         }
     }
     $this->upgrade_complete = true;
 }
コード例 #11
0
?>
><?php 
echo __('No, use regular index page');
?>
</option>
			</select>
		</td>
	</tr>
	<tr>
		<td class="config_explanation" colspan="2">
			<?php 
echo __('In single project tracker mode, The Bug Genie will display the homepage for the first project as the main page instead of the regular index page');
?>
<br>
			<?php 
if (count(TBGProject::getAll()) > 1) {
    ?>
				<br>
				<b class="more_than_one_project_warning"><?php 
    echo __('More than one project exists. When in "single project" mode, accessing other projects than the first will become harder.');
    ?>
</b>
			<?php 
}
?>
		</td>
	</tr>
	<tr>
		<td><label for="showprojectsoverview"><?php 
echo __('Show project list on frontpage');
?>
コード例 #12
0
 protected function _upgrade()
 {
     switch ($this->_version) {
         case "1.0":
             // Upgrade tables
             \b2db\Core::getTable('TBGVCSIntegrationCommitsTable')->create();
             \b2db\Core::getTable('TBGVCSIntegrationFilesTable')->create();
             \b2db\Core::getTable('TBGVCSIntegrationIssueLinksTable')->create();
             TBGVCSIntegrationCommitsTable::getTable()->createIndexes();
             TBGVCSIntegrationFilesTable::getTable()->createIndexes();
             TBGVCSIntegrationIssueLinksTable::getTable()->createIndexes();
             // Migrate data from old table to new tables
             $crit = new \b2db\Criteria();
             $crit->addOrderBy(TBGVCSIntegrationTable::DATE, \b2db\Criteria::SORT_DESC);
             $results = TBGVCSIntegrationTable::getTable()->doSelect($crit);
             if ($results instanceof \b2db\Resultset && $results->count() > 0) {
                 $commits = array();
                 while ($row = $results->getNextRow()) {
                     $rev = $row->get(TBGVCSIntegrationTable::NEW_REV);
                     if (array_key_exists($rev, $commits)) {
                         // Add a new file or issue to the commit data
                         $commits[$rev]['files'][$row->get(TBGVCSIntegrationTable::FILE_NAME)] = array('file_name' => $row->get(TBGVCSIntegrationTable::FILE_NAME), 'action' => $row->get(TBGVCSIntegrationTable::ACTION));
                         $commits[$rev]['issues'][$row->get(TBGVCSIntegrationTable::ISSUE_NO)] = $row->get(TBGVCSIntegrationTable::ISSUE_NO);
                     } else {
                         // All issues will be of the same project, so use one issue
                         $issue = TBGContext::factory()->TBGIssue($results->get(TBGVCSIntegrationTable::ISSUE_NO));
                         // Add details of a new commit
                         $commits[$rev] = array('commit' => array(), 'files' => array(), 'issues' => array());
                         $commits[$rev]['commit'] = array('new_rev' => $rev, 'old_rev' => $row->get(TBGVCSIntegrationTable::OLD_REV), 'author' => $row->get(TBGVCSIntegrationTable::AUTHOR), 'date' => $row->get(TBGVCSIntegrationTable::DATE), 'log' => $row->get(TBGVCSIntegrationTable::LOG), 'scope' => $row->get(TBGVCSIntegrationTable::SCOPE), 'project' => $issue->getProject());
                         $commits[$rev]['files'][$row->get(TBGVCSIntegrationTable::FILE_NAME)] = array('file_name' => $row->get(TBGVCSIntegrationTable::FILE_NAME), 'action' => $row->get(TBGVCSIntegrationTable::ACTION));
                         $commits[$rev]['issues'][$row->get(TBGVCSIntegrationTable::ISSUE_NO)] = $row->get(TBGVCSIntegrationTable::ISSUE_NO);
                     }
                 }
                 foreach ($commits as $commit) {
                     $files = array();
                     $issues = array();
                     $scope = TBGContext::factory()->TBGScope($commit['commit']['scope']);
                     try {
                         $author = TBGContext::factory()->TBGUser($commit['commit']['author']);
                     } catch (Exception $e) {
                         $author = TBGContext::factory()->TBGUser(TBGSettings::getDefaultUserID());
                     }
                     if (!$author instanceof TBGUser) {
                         $author = TBGContext::factory()->TBGUser(TBGSettings::getDefaultUserID());
                     }
                     // Add the commit
                     $inst = new TBGVCSIntegrationCommit();
                     $inst->setAuthor($author);
                     $inst->setDate($commit['commit']['date']);
                     $inst->setLog($commit['commit']['log']);
                     $inst->setPreviousRevision($commit['commit']['old_rev']);
                     $inst->setRevision($commit['commit']['new_rev']);
                     $inst->setProject($commit['commit']['project']);
                     $inst->setScope($scope);
                     $inst->save();
                     // Process issue list, remove duplicates
                     $issues = $commit['issues'];
                     $files = $commit['files'];
                     $commit = $inst;
                     foreach ($files as $file) {
                         // Add affected files
                         $inst = new TBGVCSIntegrationFile();
                         $inst->setCommit($commit);
                         $inst->setFile($file['file_name']);
                         $inst->setAction($file['action']);
                         $inst->setScope($scope);
                         $inst->save();
                     }
                     foreach ($issues as $issue) {
                         // Add affected issues
                         $issue = TBGContext::factory()->TBGIssue($issue);
                         $inst = new TBGVCSIntegrationIssueLink();
                         $inst->setIssue($issue);
                         $inst->setCommit($commit);
                         $inst->setScope($scope);
                         $inst->save();
                     }
                 }
             }
             // Migrate settings to new format
             $access_method = $this->getSetting('use_web_interface');
             $passkey = $this->getSetting('vcs_passkey');
             foreach (TBGProject::getAll() as $project) {
                 $projectId = $project->getID();
                 $web_path = $this->getSetting('web_path_' . $projectId);
                 $web_repo = $this->getSetting('web_repo_' . $projectId);
                 // Check if enabled
                 if ($web_path == '') {
                     continue;
                 }
                 switch ($this->getSetting('web_type_' . $projectId)) {
                     case 'viewvc':
                         $base_url = $web_path . '/' . '?root=' . $web_repo;
                         $link_rev = '&amp;view=rev&amp;revision=%revno';
                         $link_file = '&amp;view=log';
                         $link_diff = '&amp;r1=%revno&amp;r2=%oldrev';
                         $link_view = '&amp;revision=%revno&amp;view=markup';
                         break;
                     case 'viewvc_repo':
                         $base_url = $web_path;
                         $link_rev = '/?view=rev&amp;revision=%revno';
                         $link_file = '/%file?view=log';
                         $link_diff = '/%file?r1=%revno&amp;r2=%oldrev';
                         $link_view = '/%file?revision=%revno&amp;view=markup';
                         break;
                     case 'websvn':
                         $base_url = $web_path;
                         $link_rev = '/revision.php?repname=' . $web_repo . '&amp;isdir=1&amp;rev=%revno';
                         $link_file = '/log.php?repname=' . $web_repo . '&amp;path=/$%file';
                         $link_diff = '/comp.php?repname=' . $web_repo . '&amp;compare[]=/%file@%revno&amp;compare[]=/%file@%oldrev';
                         $link_view = '/filedetails.php?repname=' . $web_repo . '&path=/%file&amp;rev=%revno';
                         break;
                     case 'websvn_mv':
                         $base_url = $web_path;
                         $link_rev = '/' . '?repname=' . $web_repo . '&amp;op=log&isdir=1&amp;rev=%revno';
                         $link_file = '/%file?repname=' . $web_repo;
                         $link_diff = '/%file?repname=' . $web_repo . '&amp;compare[]=/%file@%revno&amp;compare[]=/%file@%oldrev';
                         $link_view = '/%file?repname=' . $web_repo . '&amp;rev=%revno';
                         break;
                     case 'loggerhead':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/revision/%revno';
                         $link_file = '/changes';
                         $link_diff = '/revision/%revno?compare_revid=%oldrev';
                         $link_view = '/annotate/head:/%file';
                         break;
                     case 'gitweb':
                         $base_url = $web_path . '/' . '?p=' . $web_repo;
                         $link_rev = ';a=commitdiff;h=%revno';
                         $link_file = ';a=history;f=%file;hb=HEAD';
                         $link_diff = ';a=blobdiff;f=%file;hb=%revno;hpb=%oldrev';
                         $link_view = ';a=blob;f=%file;hb=%revno';
                         break;
                     case 'cgit':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/commit/?id=%revno';
                         $link_file = '/log';
                         $link_diff = '/diff/%file?id=%revno?id2=%oldrev';
                         $link_view = '/tree/%file?id=%revno';
                         break;
                     case 'hgweb':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/rev/%revno';
                         $link_file = '/log/tip/%file';
                         $link_diff = '/diff/%revno/%file';
                         $link_view = '/file/%revno/%file';
                         break;
                     case 'github':
                         $base_url = 'http://github.com/' . $web_repo;
                         $link_rev = '/commit/%revno';
                         $link_file = '/commits/master/%file';
                         $link_diff = '/commit/%revno';
                         $link_view = '/blob/%revno/%file';
                         break;
                     case 'gitlab':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/commit/%revno';
                         $link_file = '/commits/%branch/%file';
                         $link_diff = '/commit/%revno';
                         $link_view = '/blob/%revno/%file';
                         break;
                     case 'bitbucket':
                         $base_url = 'https://bitbucket.org/' . $web_repo;
                         $link_rev = '/changeset/%revno';
                         $link_file = '/history/%file';
                         $link_diff = '/changeset/%revno#chg-%file';
                         $link_view = '/src/%revno/%file';
                         break;
                     case 'gitorious':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/commit/%revno';
                         $link_file = '/blobs/history/master/%file';
                         $link_diff = '/commit/%revno';
                         $link_view = '/blobs/%revno/%file';
                         break;
                     case 'rhodecode':
                         $base_url = $web_path . '/' . $web_repo;
                         $link_rev = '/changeset/%revno';
                         $link_file = '/changelog/%revno/%file';
                         $link_diff = '/diff/%file?diff2=%revno&amp;diff1=%oldrev&amp;fulldiff=1&amp;diff=diff';
                         $link_view = '/files/%revno/%file';
                         break;
                 }
                 $this->saveSetting('browser_url_' . $projectId, $base_url);
                 $this->saveSetting('log_url_' . $projectId, $link_file);
                 $this->saveSetting('blob_url_' . $projectId, $link_diff);
                 $this->saveSetting('diff_url_' . $projectId, $link_view);
                 $this->saveSetting('commit_url_' . $projectId, $link_rev);
                 // Access method
                 $this->saveSetting('access_method_' . $projectId, $access_method);
                 if ($access_method == self::ACCESS_HTTP) {
                     $this->saveSetting('access_passkey_' . $projectId, $passkey);
                 }
                 // Enable VCS Integration
                 $this->saveSetting('vcs_mode_' . $projectId, self::MODE_ISSUECOMMITS);
                 // Remove old settings
                 $this->deleteSetting('web_type_' . $projectId);
                 $this->deleteSetting('web_path_' . $projectId);
                 $this->deleteSetting('web_repo_' . $projectId);
             }
             // Remove old settings
             $this->deleteSetting('use_web_interface');
             $this->deleteSetting('vcs_passkey');
             // Upgrade module version
             $this->_version = $this->_module_version;
             $this->save();
             break;
     }
 }
コード例 #13
0
 public function componentSettings()
 {
     $this->allProjects = TBGProject::getAll();
 }