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


PHP Project::getByKey方法代码示例

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


在下文中一共展示了Project::getByKey方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: runSaveIncomingAccount

 /**
  * Save incoming email account
  *
  * @Route(url="/mailing/:project_key/incoming_account/*", name="save_incoming_account")
  * @param \thebuggenie\core\framework\Request $request
  * @return type
  */
 public function runSaveIncomingAccount(framework\Request $request)
 {
     $project = null;
     if ($project_key = $request['project_key']) {
         try {
             $project = \thebuggenie\core\entities\Project::getByKey($project_key);
         } catch (\Exception $e) {
         }
     }
     if ($project instanceof \thebuggenie\core\entities\Project) {
         try {
             $account_id = $request['account_id'];
             $account = $account_id ? new \thebuggenie\modules\mailing\entities\IncomingEmailAccount($account_id) : new \thebuggenie\modules\mailing\entities\IncomingEmailAccount();
             $account->setIssuetype((int) $request['issuetype']);
             $account->setProject($project);
             $account->setPort((int) $request['port']);
             $account->setName($request['name']);
             $account->setFoldername($request['folder']);
             $account->setKeepEmails($request['keepemail']);
             $account->setServer($request['servername']);
             $account->setUsername($request['username']);
             $account->setPassword($request['password']);
             $account->setSSL((bool) $request['ssl']);
             $account->setIgnoreCertificateValidation((bool) $request['ignore_certificate_validation']);
             $account->setUsePlaintextAuthentication((bool) $request['plaintext_authentication']);
             $account->setServerType((int) $request['account_type']);
             $account->save();
             if (!$account_id) {
                 return $this->renderComponent('mailing/incomingemailaccount', array('project' => $project, 'account' => $account));
             } else {
                 return $this->renderJSON(array('name' => $account->getName()));
             }
         } catch (\Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid mailing account')));
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid project')));
     }
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:48,代码来源:Main.php

示例7: 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

示例8: getProject

 public function getProject()
 {
     $namespaces = $this->getNamespaces();
     if (count($namespaces) > 0) {
         $key = $namespaces[0];
         $project = Project::getByKey($key);
         return $project;
     }
 }
开发者ID:JonathanRH,项目名称:thebuggenie,代码行数:9,代码来源:Article.php

示例9: 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

示例10: _loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction

 protected function _loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction(framework\Request $request)
 {
     try {
         if ($project_key = $request['project_key']) {
             $this->selected_project = entities\Project::getByKey($project_key);
         } elseif ($project_id = $request['project_id']) {
             $this->selected_project = entities\Project::getB2DBTable()->selectById($project_id);
         }
     } catch (\Exception $e) {
     }
     if ($this->selected_project instanceof entities\Project) {
         framework\Context::setCurrentProject($this->selected_project);
     }
     if ($this->selected_project instanceof entities\Project) {
         $this->issuetypes = $this->selected_project->getIssuetypeScheme()->getIssuetypes();
     } else {
         $this->issuetypes = entities\Issuetype::getAll();
     }
     $this->selected_issuetype = null;
     if ($request->hasParameter('issuetype')) {
         $this->selected_issuetype = entities\Issuetype::getByKeyish($request['issuetype']);
     }
     $this->locked_issuetype = (bool) $request['lock_issuetype'];
     if (!$this->selected_issuetype instanceof entities\Issuetype) {
         $this->issuetype_id = $request['issuetype_id'];
         if ($this->issuetype_id) {
             try {
                 $this->selected_issuetype = entities\Issuetype::getB2DBTable()->selectById($this->issuetype_id);
             } catch (\Exception $e) {
             }
         }
     } else {
         $this->issuetype_id = $this->selected_issuetype->getID();
     }
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:35,代码来源:Main.php

示例11: runDoImportCSV

 public function runDoImportCSV(framework\Request $request)
 {
     try {
         if ($request['csv_data'] == '') {
             throw new \Exception($this->getI18n()->__('No data supplied to import'));
         }
         $csv = str_replace("\r\n", "\n", $request['csv_data']);
         $csv = html_entity_decode($csv);
         $headerrow = null;
         $data = array();
         $errors = array();
         // Parse CSV
         $handle = fopen("php://memory", 'r+');
         fputs($handle, $csv);
         rewind($handle);
         $i = 0;
         while (($row = fgetcsv($handle, 1000)) !== false) {
             if (!$headerrow) {
                 $headerrow = $row;
             } else {
                 if (count($headerrow) == count($row)) {
                     $data[] = array_combine($headerrow, $row);
                 } else {
                     $errors[] = $this->getI18n()->__('Row %row does not have the same number of elements as the header row', array('%row' => $i));
                 }
             }
             $i++;
         }
         fclose($handle);
         if (empty($data)) {
             throw new \Exception($this->getI18n()->__('Insufficient data to import'));
         }
         // Verify required columns are present based on type
         $requiredcols = array(self::CSV_TYPE_CLIENTS => array(self::CSV_CLIENT_NAME), self::CSV_TYPE_PROJECTS => array(self::CSV_PROJECT_NAME), self::CSV_TYPE_ISSUES => array(self::CSV_ISSUE_TITLE, self::CSV_ISSUE_PROJECT, self::CSV_ISSUE_ISSUE_TYPE));
         if (!isset($requiredcols[$request['type']])) {
             throw new \Exception('Sorry, this type is unimplemented');
         }
         foreach ($requiredcols[$request['type']] as $col) {
             if (!in_array($col, $headerrow)) {
                 $errors[] = $this->getI18n()->__('Required column \'%col\' not found in header row', array('%col' => $col));
             }
         }
         // Check if rows are long enough and fields are not empty
         for ($i = 0; $i != count($data); $i++) {
             $activerow = $data[$i];
             // Check if fields are empty
             foreach ($activerow as $col => $val) {
                 if (strlen($val) == 0) {
                     $errors[] = $this->getI18n()->__('Row %row column %col has no value', array('%col' => $col, '%row' => $i + 1));
                 }
             }
         }
         if (count($errors) == 0) {
             // Check if fields are valid
             switch ($request['type']) {
                 case self::CSV_TYPE_PROJECTS:
                     for ($i = 0; $i != count($data); $i++) {
                         $activerow = $data[$i];
                         // Check if project exists
                         $key = str_replace(' ', '', $activerow[self::CSV_PROJECT_NAME]);
                         $key = mb_strtolower($key);
                         $tmp = entities\Project::getByKey($key);
                         if ($tmp !== null) {
                             $errors[] = $this->getI18n()->__('Row %row: A project with this name already exists', array('%row' => $i + 1));
                         }
                         // First off are booleans
                         $boolitems = array(self::CSV_PROJECT_SCRUM, self::CSV_PROJECT_ALLOW_REPORTING, self::CSV_PROJECT_AUTOASSIGN, self::CSV_PROJECT_FREELANCE, self::CSV_PROJECT_EN_BUILDS, self::CSV_PROJECT_EN_COMPS, self::CSV_PROJECT_EN_EDITIONS, self::CSV_PROJECT_SHOW_SUMMARY);
                         foreach ($boolitems as $boolitem) {
                             if (array_key_exists($boolitem, $activerow) && isset($activerow[$boolitem]) && $activerow[$boolitem] != 1 && $activerow[$boolitem] != 0) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1/0)', array('%col' => $boolitem, '%row' => $i + 1));
                             }
                         }
                         // Now identifiables
                         $identifiableitems = array(array(self::CSV_PROJECT_QA, self::CSV_PROJECT_QA_TYPE), array(self::CSV_PROJECT_LEAD, self::CSV_PROJECT_LEAD_TYPE), array(self::CSV_PROJECT_OWNER, self::CSV_PROJECT_OWNER_TYPE));
                         foreach ($identifiableitems as $identifiableitem) {
                             if (!array_key_exists($identifiableitem[1], $activerow) && array_key_exists($identifiableitem[0], $activerow) || array_key_exists($identifiableitem[1], $activerow) && !array_key_exists($identifiableitem[0], $activerow)) {
                                 $errors[] = $this->getI18n()->__('Row %row: Both the type and item ID must be supplied for owner/lead/qa fields', array('%row' => $i + 1));
                                 continue;
                             }
                             if (array_key_exists($identifiableitem[1], $activerow) && isset($activerow[$identifiableitem[1]]) !== null && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_USER && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_TEAM) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1 for a user or 2 for a team)', array('%col' => $identifiableitem[1], '%row' => $i + 1));
                             }
                             if (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && !is_numeric($activerow[$identifiableitem[0]])) {
                                 $errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                             } elseif (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && is_numeric($activerow[$identifiableitem[0]])) {
                                 // check if they exist
                                 switch ($activerow[$identifiableitem[1]]) {
                                     case self::CSV_IDENTIFIER_TYPE_USER:
                                         try {
                                             entities\User::getB2DBTable()->selectByID($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: user does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
                                         break;
                                     case self::CSV_IDENTIFIER_TYPE_TEAM:
                                         try {
                                             entities\Team::getB2DBTable()->selectById($activerow[$identifiableitem[0]]);
                                         } catch (\Exception $e) {
                                             $errors[] = $this->getI18n()->__('Row %row column %col: team does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
                                         }
//.........这里部分代码省略.........
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:101,代码来源:Main.php


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