public function do_execute() { /* Prepare variables */ try { $project_id = $this->getProvidedArgument('projectid'); $project_row = TBGProjectsTable::getTable()->getById($project_id, false); TBGContext::setScope(new TBGScope($project_row[TBGProjectsTable::SCOPE])); $project = new TBGProject($project_id, $project_row); } catch (Exception $e) { throw $e; $this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold'); exit; } $author = $this->getProvidedArgument('author'); $new_rev = $this->getProvidedArgument('revno'); $commit_msg = $this->getProvidedArgument('log'); $changed = $this->getProvidedArgument('changed'); $old_rev = $this->getProvidedArgument('oldrev', null); $date = $this->getProvidedArgument('date', null); $branch = $this->getProvidedArgument('branch', null); if (TBGSettings::get('access_method_' . $project->getKey()) == TBGVCSIntegration::ACCESS_HTTP) { $this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold'); exit; } if ($old_rev === null && !is_integer($new_rev)) { $this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number)."); } else { if ($old_rev === null) { $old_rev = $new_rev - 1; } } $output = TBGVCSIntegration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch); $this->cliEcho($output); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::ISSUETYPE_ID, TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::ISSUETYPE_ID, TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::MILESTONE_ID, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::MILESTONE_ID, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable()); parent::_addForeignKeyColumn(self::ROLE_ID, TBGListTypesTable::getTable()); parent::_addForeignKeyColumn(self::TEAM_ID, TBGTeamsTable::getTable()); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable()); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addInteger(self::TARGET_TYPE, 5); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::TID, B2DB::getTable('TBGTeamsTable'), TBGTeamsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addText(self::DESCRIPTION, false); parent::_addInteger(self::REACHED, 10); parent::_addInteger(self::MILESTONE_TYPE, 2); parent::_addInteger(self::STARTING, 10); parent::_addInteger(self::SCHEDULED, 10); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addInteger(self::VERSION_MAJOR, 3); parent::_addInteger(self::VERSION_MINOR, 3); parent::_addInteger(self::VERSION_REVISION, 5); parent::_addInteger(self::LEAD_BY, 10); parent::_addInteger(self::LEAD_TYPE, 3); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addInteger(self::VERSION_MAJOR, 3); parent::_addInteger(self::VERSION_MINOR, 3); parent::_addInteger(self::VERSION_REVISION, 5); parent::_addInteger(self::LEAD_BY, 10); parent::_addInteger(self::LEAD_TYPE, 3); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addInteger(self::VERSION_MAJOR, 3); parent::_addInteger(self::VERSION_MINOR, 3); parent::_addInteger(self::VERSION_REVISION, 5); parent::_addInteger(self::RELEASE_DATE, 10); parent::_addBoolean(self::RELEASED); parent::_addBoolean(self::LOCKED); parent::_addForeignKeyColumn(self::EDITION, TBGEditionsTable::getTable(), TBGEditionsTable::ID); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addInteger(self::VERSION_MAJOR, 3); parent::_addInteger(self::VERSION_MINOR, 3); parent::_addInteger(self::VERSION_REVISION, 5); parent::_addInteger(self::RELEASE_DATE, 10); parent::_addBoolean(self::RELEASED); parent::_addBoolean(self::LOCKED); parent::_addForeignKeyColumn(self::EDITION, B2DB::getTable('TBGEditionsTable'), TBGEditionsTable::ID); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addInteger(self::ISSUE_NO, 10); parent::_addVarchar(self::TITLE, 200); parent::_addInteger(self::POSTED, 10); parent::_addInteger(self::LAST_UPDATED, 10); parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addText(self::DESCRIPTION, false); parent::_addBoolean(self::STATE); parent::_addForeignKeyColumn(self::POSTED_BY, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addInteger(self::OWNER, 10); parent::_addInteger(self::OWNER_TYPE, 2); parent::_addFloat(self::USER_PAIN, 3); parent::_addInteger(self::PAIN_BUG_TYPE, 3); parent::_addInteger(self::PAIN_EFFECT, 3); parent::_addInteger(self::PAIN_LIKELIHOOD, 3); parent::_addInteger(self::ASSIGNED_TO, 10); parent::_addText(self::REPRODUCTION_STEPS, false); parent::_addForeignKeyColumn(self::RESOLUTION, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::ISSUE_TYPE, TBGIssueTypesTable::getTable(), TBGIssueTypesTable::ID); parent::_addForeignKeyColumn(self::STATUS, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::PRIORITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::CATEGORY, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::SEVERITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addForeignKeyColumn(self::REPRODUCABILITY, TBGListTypesTable::getTable(), TBGListTypesTable::ID); parent::_addVarchar(self::SCRUMCOLOR, 7, '#FFFFFF'); parent::_addInteger(self::ESTIMATED_MONTHS, 10); parent::_addInteger(self::ESTIMATED_WEEKS, 10); parent::_addInteger(self::ESTIMATED_DAYS, 10); parent::_addInteger(self::ESTIMATED_HOURS, 10); parent::_addInteger(self::ESTIMATED_POINTS); parent::_addInteger(self::SPENT_MONTHS, 10); parent::_addInteger(self::SPENT_WEEKS, 10); parent::_addInteger(self::SPENT_DAYS, 10); parent::_addInteger(self::SPENT_HOURS, 10); parent::_addInteger(self::VOTES_TOTAL, 10); parent::_addInteger(self::SPENT_POINTS); parent::_addInteger(self::PERCENT_COMPLETE, 2); parent::_addInteger(self::ASSIGNED_TYPE, 2); parent::_addInteger(self::DUPLICATE_OF, 10); parent::_addBoolean(self::DELETED); parent::_addBoolean(self::BLOCKING); parent::_addBoolean(self::LOCKED); parent::_addForeignKeyColumn(self::BEING_WORKED_ON_BY_USER, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addInteger(self::BEING_WORKED_ON_BY_USER_SINCE, 10); parent::_addForeignKeyColumn(self::MILESTONE, TBGMilestonesTable::getTable(), TBGMilestonesTable::ID); parent::_addForeignKeyColumn(self::WORKFLOW_STEP_ID, TBGWorkflowStepsTable::getTable(), TBGWorkflowStepsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
/** * Pre-execute function * * @param TBGRequest $request */ public function preExecute(TBGRequest $request, $action) { $this->article = null; $this->article_name = $request['article_name']; $this->article_id = (int) $request['article_id']; $this->special = false; if ($request->hasParameter('article_name') && mb_strpos($request['article_name'], ':') !== false) { $this->article_name = $this->_getArticleNameDetails($request['article_name']); } else { try { if ($project_key = $request['project_key']) { $this->selected_project = TBGProject::getByKey($project_key); } elseif ($project_id = (int) $request['project_id']) { $this->selected_project = TBGProjectsTable::getTable()->selectById($project_id); } } catch (Exception $e) { } } if (!$this->special) { if ($this->article_id) { $this->article = TBGArticlesTable::getTable()->selectById($this->article_id); } elseif ($this->article_name) { $this->article = TBGArticlesTable::getTable()->getArticleByName($this->article_name); } if (!$this->article instanceof TBGWikiArticle) { $this->article = new TBGWikiArticle(); if ($this->article_name) { $this->article->setName($this->article_name); } elseif ($request->hasParameter('parent_article_name')) { $this->article->setParentArticle(TBGArticlesTable::getTable()->getArticleByName($request['parent_article_name'])); $this->_getArticleNameDetails($request['parent_article_name']); if ($this->article->getParentArticle() instanceof TBGWikiArticle) { if ($this->article->getParentArticle()->getArticleType() == TBGWikiArticle::TYPE_WIKI) { $this->article->setName($this->article->getParentArticle()->getName() . ':'); } $this->article->setArticleType($this->article->getParentArticle()->getArticleType()); } } $this->article->setContentSyntax($this->getUser()->getPreferredWikiSyntax(true)); } } if ($this->selected_project instanceof TBGProject) { if (!$this->selected_project->hasAccess()) { $this->forward403(); } else { TBGContext::setCurrentProject($this->selected_project); } } }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 200); parent::_addText(self::DESCRIPTION, false); parent::_addBoolean(self::IS_PUBLIC); parent::_addVarchar(self::TEMPLATE_NAME, 200); parent::_addVarchar(self::TEMPLATE_PARAMETER, 200); parent::_addInteger(self::ISSUES_PER_PAGE, 10); parent::_addVarchar(self::GROUPBY, 100); parent::_addVarchar(self::GROUPORDER, 5); parent::_addForeignKeyColumn(self::APPLIES_TO_PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 200); parent::_addVarchar(self::DESCRIPTION, 255, ''); parent::_addBoolean(self::IS_PUBLIC); parent::_addVarchar(self::TEMPLATE_NAME, 200); parent::_addVarchar(self::TEMPLATE_PARAMETER, 200); parent::_addInteger(self::ISSUES_PER_PAGE, 10); parent::_addVarchar(self::GROUPBY, 100); parent::_addVarchar(self::GROUPORDER, 5); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); parent::_addForeignKeyColumn(self::APPLIES_TO_PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 200); parent::_addVarchar(self::SERVER, 200); parent::_addInteger(self::PORT, 3); parent::_addInteger(self::SERVER_TYPE, 10); parent::_addBoolean(self::SSL); parent::_addBoolean(self::KEEP_EMAIL); parent::_addVarchar(self::USERNAME, 200); parent::_addVarchar(self::PASSWORD, 200); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addInteger(self::ISSUETYPE, 10); parent::_addInteger(self::NUM_LAST_FETCHED, 10); parent::_addInteger(self::TIME_LAST_FETCHED, 10); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
/** * Pre-execute function * * @param TBGRequest $request */ public function preExecute(TBGRequest $request, $action) { $this->getResponse()->setPage('wiki'); $i18n = TBGContext::getI18n(); $this->article = null; $this->article_name = $request->getParameter('article_name'); if ($request->hasParameter('article_name') && strpos($request->getParameter('article_name'), ':') !== false) { $namespace = substr($this->article_name, 0, strpos($this->article_name, ':')); $article_name = substr($this->article_name, strpos($this->article_name, ':') + 1); if ($namespace == 'Category') { $namespace = substr($article_name, 0, strpos($article_name, ':')); $article_name = substr($article_name, strpos($article_name, ':') + 1); } if ($namespace != '') { $key = strtolower($namespace); $row = TBGProjectsTable::getTable()->getByKey($key); if ($row instanceof B2DBRow) { $project = TBGContext::factory()->TBGProject($row->get(TBGProjectsTable::ID), $row); if ($project instanceof TBGProject) { $this->forward403unless($project->hasAccess()); } TBGContext::setCurrentProject($project); } } } else { try { if ($project_key = $request->getParameter('project_key')) { $row = TBGProjectsTable::getTable()->getByKey($project_key); $this->selected_project = TBGContext::factory()->TBGProject($row->get(TBGProjectsTable::ID), $row); } elseif ($project_id = (int) $request->getParameter('project_id')) { $this->selected_project = TBGContext::factory()->TBGProject($project_id); } if ($this->selected_project instanceof TBGProject) { $this->forward403unless($this->selected_project->hasAccess()); } TBGContext::setCurrentProject($this->selected_project); } catch (Exception $e) { } } if ($row = TBGArticlesTable::getTable()->getArticleByName($this->article_name)) { $this->article = PublishFactory::article($row->get(TBGArticlesTable::ID), $row); } }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::NAME, 100); parent::_addText(self::DESCRIPTION, false); parent::_addInteger(self::LEAD_BY, 10); parent::_addInteger(self::LEAD_TYPE, 3); parent::_addInteger(self::OWNED_BY, 10); parent::_addInteger(self::OWNED_TYPE, 3); parent::_addVarchar(self::DOC_URL, 200, ''); parent::_addInteger(self::QA, 10); parent::_addInteger(self::QA_TYPE, 3); parent::_addInteger(self::RELEASE_DATE, 10); parent::_addBoolean(self::RELEASED); parent::_addBoolean(self::PLANNED_RELEASED); parent::_addBoolean(self::LOCKED); parent::_addForeignKeyColumn(self::PROJECT, TBGProjectsTable::getTable(), TBGProjectsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
/** * Performs quicksearch * * @param TBGRequest $request The request object */ public function runQuickSearch(TBGRequest $request) { if ($this->getUser()->canAccessConfigurationPage(TBGSettings::CONFIGURATION_SECTION_USERS)) { $this->found_users = TBGUsersTable::getTable()->findInConfig($this->searchterm, 10, false); $this->found_teams = TBGTeamsTable::getTable()->quickfind($this->searchterm); $this->found_clients = TBGClientsTable::getTable()->quickfind($this->searchterm); $this->num_users = count($this->found_users); $this->num_teams = count($this->found_teams); $this->num_clients = count($this->found_clients); } $found_projects = TBGProjectsTable::getTable()->quickfind($this->searchterm); $projects = array(); foreach ($found_projects as $project) { if ($project->hasAccess()) { $projects[$project->getID()] = $project; } } $this->found_projects = $projects; $this->num_projects = count($projects); }
public function runUserdata(TBGRequest $request) { if ($this->getUser()->isGuest()) { return $this->renderJSON(array()); } else { $data = array(); if ($request->isPost()) { switch ($request['say']) { case 'notificationstatus': $notification = TBGNotificationsTable::getTable()->selectById($request['notification_id']); if ($notification instanceof TBGNotification) { $notification->setIsRead(!$notification->isRead()); $notification->save(); $data['notification_id'] = $notification->getID(); $data['is_read'] = (int) $notification->isRead(); } break; case 'notificationsread': $this->getUser()->markAllNotificationsRead(); $data['all'] = 'read'; break; } } else { switch ($request['say']) { case 'get_mentionables': switch ($request['target_type']) { case 'issue': $target = TBGIssuesTable::getTable()->selectById($request['target_id']); break; case 'article': $target = TBGArticlesTable::getTable()->selectById($request['target_id']); break; case 'project': $target = TBGProjectsTable::getTable()->selectById($request['target_id']); break; } $mentionables = array(); if (isset($target) && $target instanceof TBGMentionableProvider) { foreach ($target->getMentionableUsers() as $user) { if ($user->isOpenIdLocked()) { continue; } $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL()); } } foreach ($this->getUser()->getFriends() as $user) { if ($user->isOpenIdLocked()) { continue; } $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL()); } foreach ($this->getUser()->getTeams() as $team) { foreach ($team->getMembers() as $user) { if ($user->isOpenIdLocked()) { continue; } $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL()); } } foreach ($this->getUser()->getClients() as $client) { foreach ($client->getMembers() as $user) { if ($user->isOpenIdLocked()) { continue; } $mentionables[$user->getID()] = array('username' => $user->getUsername(), 'name' => $user->getName(), 'image' => $user->getAvatarURL()); } } $data['mentionables'] = array_values($mentionables); break; default: $data['unread_notifications'] = $this->getUser()->getNumberOfUnreadNotifications(); } } return $this->renderJSON($data); } }
public function hasAccess() { $namespaces = $this->getNamespaces(); if (count($namespaces) > 0) { $key = $namespaces[0]; $row = TBGProjectsTable::getTable()->getByKey($key); if ($row instanceof B2DBRow) { $project = TBGContext::factory()->TBGProject($row->get(TBGProjectsTable::ID), $row); if ($project instanceof TBGProject) { if (!$project->hasAccess()) { return false; } } } } return true; }
/** * Return list of issue reported by an user * * @param int $user_id user ID * @param int $limit number of issues to retrieve [optional] * @param Criteria $sort sort order [optional] * * @return B2DBResultset */ public function getIssuesPostedByUser($user_id, $limit = null, $sort = Criteria::SORT_DESC) { $crit = $this->getCriteria(); $crit->addWhere(self::DELETED, false); $crit->addJoin(TBGProjectsTable::getTable(), TBGProjectsTable::ID, self::PROJECT_ID); $crit->addWhere(self::POSTED_BY, $user_id); $crit->addOrderBy(self::POSTED, $sort); if ($limit !== null) { $crit->setLimit($limit); } return $this->doSelect($crit); }
protected function _populateChildren() { if ($this->_children === null) { $this->_children = TBGProjectsTable::getTable()->getByParentID($this->getID()); } return $this->_children; }
/** * Returns the project for a specified prefix * * @return TBGProject */ static function getByPrefix($prefix) { if ($row = TBGProjectsTable::getTable()->getByPrefix($prefix)) { return TBGContext::factory()->TBGProject($row->get(TBGProjectsTable::ID), $row); } return null; }
protected function _getAllInNamespace($namespace, TBGProject $project = null) { $crit = $this->getCriteria(); if ($project instanceof TBGProject) { $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . ":%", Criteria::DB_LIKE); } else { $crit->addWhere(self::NAME, "{$namespace}:%", Criteria::DB_LIKE); foreach (TBGProjectsTable::getTable()->getAllIncludingDeleted() as $project) { if (trim($project->getKey()) == '') { continue; } $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . "%", Criteria::DB_NOT_LIKE); $crit->addWhere(self::NAME, ucfirst($project->getKey()) . ":%", Criteria::DB_NOT_LIKE); } } $crit->addWhere(self::SCOPE, TBGContext::getScope()->getID()); return $this->select($crit); }
private function _fixTimestamps() { // Unlimited execution time set_time_limit(0); foreach (TBGScope::getAll() as $scope) { TBGContext::setScope($scope); // The first job is to work out the offsets that need applying $offsets = array('system', 'users'); $offsets['users'] = array(); $offsets['system'] = (int) TBGSettings::getGMToffset() * 3600; $settingstable = TBGSettingsTable::getTable(); $crit = $settingstable->getCriteria(); $crit->addWhere(TBGSettingsTable::NAME, 'timezone'); $crit->addWhere(TBGSettingsTable::MODULE, 'core'); $crit->addWhere(TBGSettingsTable::UID, 0, \b2db\Criteria::DB_NOT_EQUALS); $crit->addWhere(TBGSettingsTable::VALUE, 0, \b2db\Criteria::DB_NOT_EQUALS); $crit->addWhere(TBGSettingsTable::VALUE, 'sys', \b2db\Criteria::DB_NOT_EQUALS); $crit->addWhere(TBGSettingsTable::SCOPE, $scope->getID()); $res = $settingstable->doSelect($crit); if ($res instanceof \b2db\Resultset) { while ($user = $res->getNextRow()) { $offsets['users']['uid_' . $user->get(TBGSettingsTable::UID)] = (int) $user->get(TBGSettingsTable::VALUE) * 3600; } } // Now go through every thing which requires updating TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes'); // ARTICLE HISTORY $this->_fixUserDependentTimezone($offsets, TBGArticleHistoryTable::getTable(), TBGArticleHistoryTable::AUTHOR, TBGArticleHistoryTable::DATE, $scope); // ARTICLES $this->_fixUserDependentTimezone($offsets, TBGArticlesTable::getTable(), TBGArticlesTable::AUTHOR, TBGArticlesTable::DATE, $scope); // BUILDS $this->_fixNonUserDependentTimezone($offsets, TBGBuildsTable::getTable(), TBGBuildsTable::RELEASE_DATE, $scope, TBGBuildsTable::RELEASED); // COMMENTS $this->_fixUserDependentTimezone($offsets, TBGCommentsTable::getTable(), array('a' => TBGCommentsTable::POSTED_BY, 'b' => TBGCommentsTable::UPDATED_BY), array('a' => TBGCommentsTable::POSTED, 'b' => TBGCommentsTable::UPDATED), $scope); // EDITIONS $this->_fixNonUserDependentTimezone($offsets, TBGEditionsTable::getTable(), TBGEditionsTable::RELEASE_DATE, $scope, TBGEditionsTable::RELEASED); // ISSUES // This is a bit more complex so do this manually - we have to poke around with the issue log $table = TBGIssuesTable::getTable(); $crit = $table->getCriteria(); $crit->addWhere(TBGIssuesTable::SCOPE, $scope->getID()); $crit->addWhere(TBGIssuesTable::DELETED, false); $res = $table->doSelect($crit); if ($res) { while ($row = $res->getNextRow()) { $crit = TBGLogTable::getTable()->getCriteria(); $crit->addSelectionColumn(TBGLogTable::UID); $crit->addWhere(TBGLogTable::CHANGE_TYPE, TBGLogTable::LOG_ISSUE_ASSIGNED); $crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID)); $crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE); $crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC); $crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC); if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) { $assigned_by = $row2->get(TBGLogTable::UID); } $crit = TBGLogTable::getTable()->getCriteria(); $crit->addSelectionColumn(TBGLogTable::UID); $crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID)); $crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE); $crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC); $crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC); if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) { $updated_by = $row2->get(TBGLogTable::UID); } unset($crit); unset($row2); if (array_key_exists('uid_' . $row->get(TBGIssuesTable::POSTED_BY), $offsets['users'])) { $offset = $offsets['users']['uid_' . $row->get(TBGIssuesTable::POSTED_BY)]; } else { $offset = $offsets['system']; } if (isset($updated_by) && array_key_exists('uid_' . $updated_by, $offsets['users'])) { $offset2 = $offsets['users']['uid_' . $updated_by]; } elseif (isset($updated_by)) { $offset2 = $offsets['system']; } if (isset($assigned_by) && array_key_exists('uid_' . $assigned_by, $offsets['users'])) { $offset3 = $offsets['users']['uid_' . $assigned_by]; } elseif (isset($assigned_by)) { $offset3 = $offsets['system']; } $crit2 = $table->getCriteria(); $crit2->addUpdate(TBGIssuesTable::POSTED, (int) $row->get(TBGIssuesTable::POSTED) + $offset); if (isset($offset2)) { $crit2->addUpdate(TBGIssuesTable::LAST_UPDATED, (int) $row->get(TBGIssuesTable::LAST_UPDATED) + $offset2); unset($offset2); } if (isset($offset3)) { $crit2->addUpdate(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE, (int) $row->get(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE) + $offset3); unset($offset3); } $crit2->addWhere(TBGIssuesTable::ID, $row->get(TBGIssuesTable::ID)); $table->doUpdate($crit2); } } // LOG $this->_fixUserDependentTimezone($offsets, TBGLogTable::getTable(), TBGLogTable::UID, TBGLogTable::TIME, $scope); // MILESTONES // The conditions are a bit different here so do it manually $table = TBGMilestonesTable::getTable(); $crit = $table->getCriteria(); $crit->addWhere(TBGMilestonesTable::SCOPE, $scope->getID()); $res = $table->doSelect($crit); if ($res) { while ($row = $res->getNextRow()) { $offset = $offsets['system']; $crit2 = $table->getCriteria(); $added = 0; if ($row->get(TBGMilestonesTable::REACHED) > 0) { $crit2->addUpdate(TBGMilestonesTable::REACHED, (int) $row->get(TBGMilestonesTable::REACHED) + $offset); $added = 1; } if ($row->get(TBGMilestonesTable::SCHEDULED) > 0) { $crit2->addUpdate(TBGMilestonesTable::SCHEDULED, (int) $row->get(TBGMilestonesTable::SCHEDULED) + $offset); $added = 1; } if ($row->get(TBGMilestonesTable::STARTING) > 0) { $crit2->addUpdate(TBGMilestonesTable::STARTING, (int) $row->get(TBGMilestonesTable::STARTING) + $offset); $added = 1; } // Only do something if at least one call to addUpdate is done if ($added == 1) { $crit2->addWhere(TBGMilestonesTable::ID, $row->get(TBGMilestonesTable::ID)); $table->doUpdate($crit2); } } } // PROJECTS $this->_fixNonUserDependentTimezone($offsets, TBGProjectsTable::getTable(), TBGProjectsTable::RELEASE_DATE, $scope, TBGProjectsTable::RELEASED); // VCS INTEGRATION // check if module is loaded $modules = TBGModulesTable::getTable()->getModulesForScope($scope->getID()); if ($modules['vcs_integration'] == true) { TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'vcs_integration' . DS . 'classes' . DS . 'B2DB'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'vcs_integration' . DS . 'classes'); $this->_fixUserDependentTimezone($offsets, TBGVCSIntegrationTable::getTable(), TBGVCSIntegrationTable::AUTHOR, TBGVCSIntegrationTable::DATE, $scope); } } }
public function isInUse() { if ($this->_number_of_projects === null) { $this->_number_of_projects = TBGProjectsTable::getTable()->countByIssuetypeSchemeID($this->getID()); } return (bool) $this->_number_of_projects; }
/** * Get all the projects a user is associated with * * @return array */ public function getAssociatedProjects() { if ($this->_associated_projects === null) { $this->_associated_projects = array(); $projects = TBGProjectAssignedUsersTable::getTable()->getProjectsByUserID($this->getID()); $lo_projects = TBGProjectsTable::getTable()->getByUserID($this->getID()); $project_ids = array_merge(array_keys($projects), array_keys($lo_projects)); foreach ($this->getTeams() as $team) { $project_ids += array_keys($team->getAssociatedProjects()); } $project_ids = array_unique($project_ids); foreach ($project_ids as $project_id) { try { $this->_associated_projects[$project_id] = TBGContext::factory()->TBGProject($project_id); } catch (Exception $e) { } } } return $this->_associated_projects; }