当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::setCurrentProject方法代码示例

本文整理汇总了PHP中thebuggenie\core\framework\Context::setCurrentProject方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::setCurrentProject方法的具体用法?PHP Context::setCurrentProject怎么用?PHP Context::setCurrentProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thebuggenie\core\framework\Context的用法示例。


在下文中一共展示了Context::setCurrentProject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preExecute

 /**
  * Pre-execute function for search functions
  *
  * @param framework\Request $request
  */
 public function preExecute(framework\Request $request, $action)
 {
     $this->forward403unless(framework\Context::getUser()->hasPageAccess('search') && framework\Context::getUser()->canSearchForIssues());
     if ($project_key = $request['project_key']) {
         $project = entities\Project::getByKey($project_key);
     } elseif (is_numeric($request['project_id']) && ($project_id = (int) $request['project_id'])) {
         $project = tables\Projects::getTable()->selectById($project_id);
     } else {
         $project = false;
     }
     if ($project instanceof entities\Project) {
         $this->forward403unless(framework\Context::getUser()->hasProjectPageAccess('project_issues', $project));
         framework\Context::getResponse()->setPage('project_issues');
         framework\Context::setCurrentProject($project);
     }
     $this->search_object = entities\SavedSearch::getFromRequest($request);
     $this->issavedsearch = $this->search_object instanceof entities\SavedSearch && $this->search_object->getB2DBID();
     $this->show_results = $this->issavedsearch || $request->hasParameter('quicksearch') || $request->hasParameter('fs') || $request->getParameter('search', false) ? true : false;
     $this->searchterm = $this->search_object instanceof entities\SavedSearch ? $this->search_object->getSearchterm() : '';
     $this->searchtitle = $this->search_object instanceof entities\SavedSearch ? $this->search_object->getTitle() : '';
     if ($this->issavedsearch) {
         if (!($this->search_object instanceof entities\SavedSearch && framework\Context::getUser()->canAccessSavedSearch($this->search_object))) {
             framework\Context::setMessage('search_error', framework\Context::getI18n()->__("You don't have access to this saved search"));
         }
     }
 }
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:31,代码来源:Actions.php

示例2: runProjectCommitsMore

 public function runProjectCommitsMore(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     $this->selected_project = Project::getByKey($request['project_key']);
     framework\Context::setCurrentProject($this->selected_project);
     if (framework\Context::getModule('vcs_integration')->getSetting('vcs_mode_' . framework\Context::getCurrentProject()->getID()) == Vcs_integration::MODE_DISABLED) {
         return $this->return404(framework\Context::getI18n()->__('VCS Integration has been disabled for this project'));
     }
     $offset = $request->getParameter('offset', 0);
     $this->commits = Commit::getByProject($this->selected_project->getID(), 40, $offset, $request->getParameter('branchname'), $request->getParameter('gitlab_repos_nss'));
     return $this->renderJSON(array('content' => $this->getComponentHTML('vcs_integration/projectcommits', array('commits' => $this->commits, 'selected_project' => $this->selected_project)), 'offset' => $offset + 40));
 }
开发者ID:JonathanRH,项目名称:thebuggenie,代码行数:12,代码来源:Main.php

示例3: preExecute

 /**
  * The currently selected project in actions where there is one
  *
  * @access protected
  * @property entities\Project $selected_project
  */
 public function preExecute(framework\Request $request, $action)
 {
     try {
         if ($project_key = $request['project_key']) {
             $this->selected_project = entities\Project::getByKey($project_key);
         } elseif ($project_id = (int) $request['project_id']) {
             $this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id);
         }
         if ($this->selected_project instanceof entities\Project) {
             framework\Context::setCurrentProject($this->selected_project);
         }
     } catch (\Exception $e) {
     }
 }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:20,代码来源:Main.php

示例4: preExecute

 /**
  * Pre-execute function
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function preExecute(framework\Request $request, $action)
 {
     $this->article = null;
     $this->article_name = $request->getRawParameter('article_name');
     $this->article_id = (int) $request['article_id'];
     $this->special = false;
     if (!is_null($this->article_name) && mb_strpos($this->article_name, ':') !== false) {
         $this->article_name = $this->_getArticleNameDetails($this->article_name);
     } else {
         try {
             if ($project_key = $request['project_key']) {
                 $this->selected_project = \thebuggenie\core\entities\Project::getByKey($project_key);
             } elseif ($project_id = (int) $request['project_id']) {
                 $this->selected_project = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($project_id);
             }
         } catch (\Exception $e) {
         }
     }
     if (!$this->special) {
         if ($this->article_id) {
             $this->article = Articles::getTable()->selectById($this->article_id);
         } elseif ($this->article_name) {
             $this->article = Articles::getTable()->getArticleByName($this->article_name);
         }
         if (!$this->article instanceof Article) {
             $this->article = new Article();
             if ($this->article_name) {
                 $this->article->setName($this->article_name);
             } elseif ($request->hasParameter('parent_article_name')) {
                 $parent_article_name = $request->getRawParameter('parent_article_name');
                 $this->article->setParentArticle(Articles::getTable()->getArticleByName($parent_article_name));
                 $this->_getArticleNameDetails($parent_article_name);
                 if ($this->article->getParentArticle() instanceof Article) {
                     if ($this->article->getParentArticle()->getArticleType() == Article::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 \thebuggenie\core\entities\Project) {
         if (!$this->selected_project->hasAccess()) {
             $this->forward403();
         } else {
             framework\Context::setCurrentProject($this->selected_project);
         }
     }
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:55,代码来源:Main.php

示例5: preExecute

 /**
  * Pre-execute function
  *
  * @param framework\Request $request
  * @param string $action
  */
 public function preExecute(framework\Request $request, $action)
 {
     try {
         if ($project_id = $request['project_id']) {
             $this->selected_project = entities\Project::getB2DBTable()->selectById($project_id);
         } elseif ($project_key = $request['project_key']) {
             $this->selected_project = entities\Project::getByKey($project_key);
         }
     } catch (\Exception $e) {
     }
     if (!$this->selected_project instanceof entities\Project) {
         return $this->return404(framework\Context::getI18n()->__('This project does not exist'));
     }
     framework\Context::setCurrentProject($this->selected_project);
     $this->project_key = $this->selected_project->getKey();
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:22,代码来源:ProjectActions.php

示例6: preExecute

 /**
  * The currently selected project in actions where there is one
  *
  * @access protected
  * @property entities\Project $selected_project
  */
 public function preExecute(framework\Request $request, $action)
 {
     try {
         // Default to JSON if nothing is specified.
         $newFormat = $request->getParameter('format', 'json');
         $this->getResponse()->setTemplate(mb_strtolower($action) . '.' . $newFormat . '.php');
         $this->getResponse()->setupResponseContentType($newFormat);
         if ($project_key = $request['project_key']) {
             $this->selected_project = entities\Project::getByKey($project_key);
         } elseif ($project_id = (int) $request['project_id']) {
             $this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id);
         }
         if ($this->selected_project instanceof entities\Project) {
             framework\Context::setCurrentProject($this->selected_project);
         }
         $this->render_detail = !isset($request['nodetail']);
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(500);
         return $this->renderJSON(array('error' => 'An exception occurred: ' . $e));
     }
 }
开发者ID:thebuggenie,项目名称:module-api,代码行数:27,代码来源:Main.php

示例7: processCommit

 public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::MODE_DISABLED) {
         $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n";
         return $output;
     }
     // Parse the commit message, and obtain the issues and transitions for issues.
     $parsed_commit = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // Build list of affected files
     $file_lines = preg_split('/[\\n\\r]+/', $changed);
     $files = array();
     foreach ($file_lines as $aline) {
         $action = mb_substr($aline, 0, 1);
         if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
             $theline = trim(mb_substr($aline, 1));
             $files[] = array($action, $theline);
         }
     }
     // Find author of commit, fallback is guest
     /*
      * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
      * Joe Bloggs <me@example.com>, instead of a classic username. Therefore a user will be found via 4 queries:
      * a) First we extract the email if there is one, and find a user with that email
      * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
      * c) the username or full name is checked against the friendly name field
      * d) and if we still havent found one, then we check against the username
      * e) and if we STILL havent found one, we use the guest user
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::cacheAllPermissions();
     $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n";
     if ($date == null) {
         $date = NOW;
     }
     // Create the commit data
     $commit = new Commit();
     $commit->setAuthor($user);
     $commit->setDate($date);
     $commit->setLog($commit_msg);
     $commit->setPreviousRevision($old_rev);
     $commit->setRevision($new_rev);
     $commit->setProject($project);
     if ($branch !== null) {
         $data = 'branch:' . $branch;
         $commit->setMiscData($data);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $commit->save();
     $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n";
     // Iterate over affected issues and update them.
     foreach ($issues as $issue) {
         $inst = new IssueLink();
         $inst->setIssue($issue);
//.........这里部分代码省略.........
开发者ID:AzerothShard,项目名称:thebuggenie,代码行数:101,代码来源:Vcs_integration.php

示例8: runProjectIssueCommitsMore

 public function runProjectIssueCommitsMore(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     $this->selected_project = Project::getByKey($request['project_key']);
     framework\Context::setCurrentProject($this->selected_project);
     if (framework\Context::getModule('vcs_integration')->getSetting('vcs_mode_' . framework\Context::getCurrentProject()->getID()) == Vcs_integration::MODE_DISABLED) {
         return $this->return404(framework\Context::getI18n()->__('VCS Integration has been disabled for this project'));
     }
     $issue = Issues::getTable()->getByProjectIDAndIssueNo($this->selected_project->getID(), $request['issue_no']);
     $links = IssueLink::getCommitsByIssue($issue, $request->getParameter('limit', 0), $request->getParameter('offset', 0));
     return $this->renderJSON(array('content' => $this->getComponentHTML('vcs_integration/issuecommits', array("projectId" => $this->selected_project->getID(), "links" => $links))));
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:12,代码来源:Main.php

示例9: runDashboardView

 public function runDashboardView(framework\Request $request)
 {
     $view = entities\DashboardView::getB2DBTable()->selectById($request['view_id']);
     if (!$view instanceof entities\DashboardView) {
         return $this->renderJSON(array('content' => 'invalid view'));
     }
     if ($view->getTargetType() == entities\DashboardView::TYPE_PROJECT) {
         framework\Context::setCurrentProject($view->getDashboard()->getProject());
     }
     return $this->renderJSON(array('content' => $this->returnComponentHTML($view->getTemplate(), array('view' => $view))));
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:11,代码来源:Main.php


注:本文中的thebuggenie\core\framework\Context::setCurrentProject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。