本文整理汇总了PHP中thebuggenie\core\framework\Context::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getUser方法的具体用法?PHP Context::getUser怎么用?PHP Context::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\framework\Context
的用法示例。
在下文中一共展示了Context::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preExecute
/**
* Pre-execute function
*
* @param framework\Request $request
* @param string $action
*/
public function preExecute(framework\Request $request, $action)
{
// forward 403 if you're not allowed here
if ($request->isAjaxCall() == false) {
$this->forward403unless(framework\Context::getUser()->canAccessConfigurationPage());
}
$this->access_level = $this->getAccessLevel(framework\Settings::CONFIGURATION_SECTION_IMPORT, 'core');
if (!$request->isAjaxCall()) {
$this->getResponse()->setPage('config');
framework\Context::loadLibrary('ui');
$this->getResponse()->addBreadcrumb(framework\Context::getI18n()->__('Configure %thebuggenie_name', array('%thebuggenie_name' => framework\Settings::getSiteHeaderName())), framework\Context::getRouting()->generate('configure'), $this->getResponse()->getPredefinedBreadcrumbLinks('configure'));
}
}
示例2: saveEstimate
public function saveEstimate($issue_id, $months, $weeks, $days, $hours, $points)
{
$crit = $this->getCriteria();
$crit->addInsert(self::ESTIMATED_MONTHS, $months);
$crit->addInsert(self::ESTIMATED_WEEKS, $weeks);
$crit->addInsert(self::ESTIMATED_DAYS, $days);
$crit->addInsert(self::ESTIMATED_HOURS, $hours);
$crit->addInsert(self::ESTIMATED_POINTS, $points);
$crit->addInsert(self::ISSUE_ID, $issue_id);
$crit->addInsert(self::EDITED_AT, NOW);
$crit->addInsert(self::EDITED_BY, framework\Context::getUser()->getID());
$crit->addInsert(self::SCOPE, framework\Context::getScope()->getID());
$this->doInsert($crit);
}
示例3: componentEditAgileBoard
public function componentEditAgileBoard()
{
$i18n = framework\Context::getI18n();
$this->autosearches = array(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES => $i18n->__('Project open issues (recommended)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project open issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES => $i18n->__('Project closed issues'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project closed issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_REPORTED_THIS_MONTH => $i18n->__('Project issues reported last month'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_WISHLIST => $i18n->__('Project wishlist'));
$this->savedsearches = \thebuggenie\core\entities\tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), $this->board->getProject()->getID());
$this->issuetypes = $this->board->getProject()->getIssuetypeScheme()->getIssuetypes();
$this->swimlane_groups = array('priority' => $i18n->__('Issue priority'), 'severity' => $i18n->__('Issue severity'), 'category' => $i18n->__('Issue category'));
$this->priorities = \thebuggenie\core\entities\Priority::getAll();
$this->severities = \thebuggenie\core\entities\Severity::getAll();
$this->categories = \thebuggenie\core\entities\Category::getAll();
$fakecolumn = new entities\BoardColumn();
$fakecolumn->setBoard($this->board);
$this->fakecolumn = $fakecolumn;
}
示例4: saveFile
public function saveFile($real_filename, $original_filename, $content_type, $description = null, $content = null)
{
$crit = $this->getCriteria();
$crit->addInsert(self::UID, framework\Context::getUser()->getID());
$crit->addInsert(self::REAL_FILENAME, $real_filename);
$crit->addInsert(self::UPLOADED_AT, NOW);
$crit->addInsert(self::ORIGINAL_FILENAME, $original_filename);
$crit->addInsert(self::CONTENT_TYPE, $content_type);
$crit->addInsert(self::SCOPE, framework\Context::getScope()->getID());
if ($description !== null) {
$crit->addInsert(self::DESCRIPTION, $description);
}
if ($content !== null) {
$crit->addInsert(self::CONTENT, $content, 'blob');
}
$res = $this->doInsert($crit);
return $res->getInsertID();
}
示例5: addLink
public function addLink($target_type, $target_id = 0, $url = null, $description = null, $link_order = null, $scope = null)
{
$scope = $scope === null ? framework\Context::getScope()->getID() : $scope;
if ($link_order === null) {
$crit = $this->getCriteria();
$crit->addSelectionColumn(self::LINK_ORDER, 'max_order', Criteria::DB_MAX, '', '+1');
$crit->addWhere(self::TARGET_TYPE, $target_type);
$crit->addWhere(self::TARGET_ID, $target_id);
$crit->addWhere(self::SCOPE, $scope);
$row = $this->doSelectOne($crit);
$link_order = $row->get('max_order') ? $row->get('max_order') : 1;
}
$crit = $this->getCriteria();
$crit->addInsert(self::TARGET_TYPE, $target_type);
$crit->addInsert(self::TARGET_ID, $target_id);
$crit->addInsert(self::URL, $url);
$crit->addInsert(self::DESCRIPTION, $description);
$crit->addInsert(self::LINK_ORDER, $link_order);
$crit->addInsert(self::UID, framework\Context::getUser() instanceof \thebuggenie\core\entities\User ? framework\Context::getUser()->getID() : 0);
$crit->addInsert(self::SCOPE, $scope);
$res = $this->doInsert($crit);
framework\Context::getCache()->clearCacheKeys(array(framework\Cache::KEY_MAIN_MENU_LINKS));
return $res->getInsertID();
}
示例6: getAvailableViews
public static function getAvailableViews($target_type)
{
$i18n = framework\Context::getI18n();
$searches = array('info' => array(), 'searches' => array());
switch ($target_type) {
case self::TYPE_USER:
$searches['info'][self::VIEW_LOGGED_ACTIONS] = array(0 => array('title' => $i18n->__("What you've done recently"), 'description' => $i18n->__('A widget that shows your most recent actions, such as issue edits, wiki edits and more')));
if (framework\Context::getUser()->canViewComments()) {
$searches['info'][self::VIEW_RECENT_COMMENTS] = array(0 => array('title' => $i18n->__('Recent comments'), 'description' => $i18n->__('Shows a list of your most recent comments')));
}
$searches['searches'][self::VIEW_PREDEFINED_SEARCH] = array(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_MY_REPORTED_ISSUES => array('title' => $i18n->__('Issues reported by me'), 'description' => $i18n->__('Shows a list of all issues you have reported, across all projects')), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES => array('title' => $i18n->__('Open issues assigned to me'), 'description' => $i18n->__('Shows a list of all issues assigned to you')), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_MY_OWNED_OPEN_ISSUES => array('title' => $i18n->__('Open issues owned by me'), 'description' => $i18n->__('Shows a list of all issues owned by you')), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES => array('title' => $i18n->__('Open issues assigned to my teams'), 'description' => $i18n->__('Shows all issues assigned to any of your teams')));
$searches['info'][self::VIEW_PROJECTS] = array(0 => array('title' => $i18n->__("Your projects"), 'description' => $i18n->__('A widget that shows projects you are involved in')));
$searches['info'][self::VIEW_MILESTONES] = array(0 => array('title' => $i18n->__("Upcoming milestones / sprints"), 'description' => $i18n->__('A widget that shows all upcoming milestones or sprints for any projects you are involved in')));
break;
case self::TYPE_PROJECT:
$searches['statistics'] = array();
$issuetype_icons = array();
foreach (Issuetype::getAll() as $id => $issuetype) {
$issuetype_icons[$id] = array('title' => $i18n->__('Recent issues: %issuetype', array('%issuetype' => $issuetype->getName())), 'description' => $i18n->__('Show recent issues of type %issuetype', array('%issuetype' => $issuetype->getName())));
}
$searches['info'][self::VIEW_PROJECT_INFO] = array(0 => array('title' => $i18n->__('About this project'), 'description' => $i18n->__('Basic project information widget, showing project name, important people and links')));
$searches['info'][self::VIEW_PROJECT_TEAM] = array(0 => array('title' => $i18n->__('Project team'), 'description' => $i18n->__('A widget with information about project developers and the project team and their respective project roles')));
$searches['info'][self::VIEW_PROJECT_CLIENT] = array(0 => array('title' => $i18n->__('Project client'), 'description' => $i18n->__('Shows information about the associated project client (if any)')));
$searches['info'][self::VIEW_PROJECT_SUBPROJECTS] = array(0 => array('title' => $i18n->__('Subprojects'), 'description' => $i18n->__('Lists all subprojects of this project, with quick links to report an issue, open the project wiki and more')));
$searches['info'][self::VIEW_PROJECT_RECENT_ACTIVITIES] = array(0 => array('title' => $i18n->__('Recent activities'), 'description' => $i18n->__('Displays project timeline')));
$searches['info'][self::VIEW_PROJECT_UPCOMING] = array(0 => array('title' => $i18n->__('Upcoming milestones and deadlines'), 'description' => $i18n->__('A widget showing a list of upcoming milestones and deadlines for the next three weeks')));
$searches['info'][self::VIEW_PROJECT_DOWNLOADS] = array(0 => array('title' => $i18n->__('Latest downloads'), 'description' => $i18n->__('Lists recent downloads released in the release center')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_LAST15] = array(0 => array('title' => $i18n->__('Graph of closed vs open issues'), 'description' => $i18n->__('Shows a line graph comparing closed vs open issues for the past 15 days')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_PRIORITY] = array(0 => array('title' => $i18n->__('Statistics by priority'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by priority')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_SEVERITY] = array(0 => array('title' => $i18n->__('Statistics by severity'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by severity')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_CATEGORY] = array(0 => array('title' => $i18n->__('Statistics by category'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by category')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_STATUS] = array(0 => array('title' => $i18n->__('Statistics by status'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by status')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_RESOLUTION] = array(0 => array('title' => $i18n->__('Statistics by resolution'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by resolution')));
$searches['statistics'][self::VIEW_PROJECT_STATISTICS_WORKFLOW_STEP] = array(0 => array('title' => $i18n->__('Statistics by workflow step'), 'description' => $i18n->__('Displays a bar graph of open and closed issues grouped by current workflow step')));
$searches['searches'][self::VIEW_PROJECT_RECENT_ISSUES] = $issuetype_icons;
break;
}
return $searches;
}
示例7: componentSidebar
public function componentSidebar()
{
$savedsearches = tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getID() : 0);
foreach ($savedsearches['user'] as $a_savedsearch) {
$this->getResponse()->addFeed(make_url('search', array('saved_search' => $a_savedsearch->getID(), 'search' => true, 'format' => 'rss')), __($a_savedsearch->getName()));
}
foreach ($savedsearches['public'] as $a_savedsearch) {
$this->getResponse()->addFeed(make_url('search', array('saved_search' => $a_savedsearch->getID(), 'search' => true, 'format' => 'rss')), __($a_savedsearch->getName()));
}
$this->savedsearches = $savedsearches;
}
示例8: transitionIssueToOutgoingStepFromRequest
/**
* Transition an issue to the outgoing step, based on request data if available
*
* @param \thebuggenie\core\entities\Issue $issue
* @param \thebuggenie\core\framework\Request $request
*/
public function transitionIssueToOutgoingStepFromRequest(\thebuggenie\core\entities\Issue $issue, $request = null)
{
$request = $request !== null ? $request : $this->_request;
$this->getOutgoingStep()->applyToIssue($issue);
if (!empty($this->_validation_errors)) {
return false;
}
foreach ($this->getActions() as $action) {
$action->perform($issue, $request);
}
foreach ($this->getPostValidationRules() as $rule) {
if (!$rule->isValid($request)) {
$this->_validation_errors[$rule->getRule()] = true;
}
}
if (!empty($this->_validation_errors)) {
return false;
}
if ($request->hasParameter('comment_body') && trim($request['comment_body'] != '')) {
$comment = new \thebuggenie\core\entities\Comment();
$comment->setContent($request->getParameter('comment_body', null, false));
$comment->setPostedBy(framework\Context::getUser()->getID());
$comment->setTargetID($issue->getID());
$comment->setTargetType(Comment::TYPE_ISSUE);
$comment->setModuleName('core');
$comment->setIsPublic(true);
$comment->setSystemComment(false);
$comment->save();
$issue->setSaveComment($comment);
}
$issue->save();
}
示例9: processIncomingEmailAccount
public function processIncomingEmailAccount(IncomingEmailAccount $account)
{
$count = 0;
if ($emails = $account->getUnprocessedEmails()) {
try {
$current_user = framework\Context::getUser();
foreach ($emails as $email) {
$user = $this->getOrCreateUserFromEmailString($email->from);
if ($user instanceof User) {
if (framework\Context::getUser()->getID() != $user->getID()) {
framework\Context::switchUserContext($user);
}
$message = $account->getMessage($email);
$data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML());
if ($data) {
if (mb_detect_encoding($data, 'UTF-8', true) === false) {
$data = utf8_encode($data);
}
$new_data = '';
foreach (explode("\n", $data) as $line) {
$line = trim($line);
if ($line) {
$line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line);
$new_data .= $line . "\n";
} else {
$new_data .= "\n";
}
}
$data = nl2br($new_data, false);
}
// Parse the subject, and obtain the issues.
$parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject));
$issues = $parsed_commit["issues"];
// If any issues were found, add new comment to each issue.
if ($issues) {
foreach ($issues as $issue) {
$text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data);
$text = trim($text);
if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) {
$comment = new Comment();
$comment->setContent($text);
$comment->setPostedBy($user);
$comment->setTargetID($issue->getID());
$comment->setTargetType(Comment::TYPE_ISSUE);
$comment->save();
}
}
} else {
if ($user->canReportIssues($account->getProject())) {
$issue = new Issue();
$issue->setProject($account->getProject());
$issue->setTitle(mb_decode_mimeheader($email->subject));
$issue->setDescription($data);
$issue->setPostedBy($user);
$issue->setIssuetype($account->getIssuetype());
$issue->save();
// Append the new issue to the list of affected issues. This
// is necessary in order to process the attachments properly.
$issues[] = $issue;
}
}
// If there was at least a single affected issue, and mail
// contains attachments, add those attachments to related issues.
if ($issues && $message->hasAttachments()) {
foreach ($message->getAttachments() as $attachment_no => $attachment) {
echo 'saving attachment ' . $attachment_no;
$name = $attachment['filename'];
$new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name);
if (framework\Settings::getUploadStorage() == 'files') {
$files_dir = framework\Settings::getUploadsLocalpath();
$filename = $files_dir . $new_filename;
} else {
$filename = $name;
}
Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no);
echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no;
$content_type = $attachment['type'] . '/' . $attachment['subtype'];
$file = new File();
$file->setRealFilename($new_filename);
$file->setOriginalFilename(basename($name));
$file->setContentType($content_type);
$file->setDescription($name);
$file->setUploadedBy(framework\Context::getUser());
if (framework\Settings::getUploadStorage() == 'database') {
$file->setContent($attachment['data']);
} else {
Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no);
file_put_contents($new_filename, $attachment['data']);
}
$file->save();
// Attach file to each related issue.
foreach ($issues as $issue) {
$issue->attachFile($file);
}
}
}
$count++;
}
}
} catch (\Exception $e) {
//.........这里部分代码省略.........
示例10: getToggle
public static function getToggle($toggle)
{
return (bool) self::get(self::TOGGLE_PREFIX . $toggle, 'core', Context::getScope()->getID(), Context::getUser()->getID());
}
示例11: _checkProjectPageAccess
protected function _checkProjectPageAccess($page)
{
return framework\Context::getUser()->hasProjectPageAccess($page, $this->selected_project);
}
示例12: toJSON
public function toJSON($detailed = true)
{
$returnJSON = array('id' => $this->getID(), 'name' => $this->getName(), 'username' => $this->getUsername(), 'type' => 'user');
if ($detailed) {
$returnJSON['display_name'] = $this->getDisplayName();
$returnJSON['realname'] = $this->getRealname();
$returnJSON['buddyname'] = $this->getBuddyname();
// Only return email if it is public or we are looking at the currently logged-in user
if ($this->isEmailPublic() || framework\Context::getUser()->getID() == $this->getID()) {
$returnJSON['email'] = $this->getEmail();
}
$returnJSON['avatar'] = $this->getAvatar();
$returnJSON['avatar_url'] = $this->getAvatarURL(false);
$returnJSON['avatar_url_small'] = $this->getAvatarURL(true);
$returnJSON['url_homepage'] = $this->getHomepage();
$returnJSON['date_joined'] = $this->getJoinedDate();
$returnJSON['last_seen'] = $this->getLastSeen();
$returnJSON['timezone'] = $this->getTimezoneIdentifier();
$returnJSON['language'] = $this->getLanguage();
$returnJSON['state'] = $this->getState()->toJSON();
/*
* TODO...
*/
// $this->getClients();
// $this->getDashboards();
// $this->getDefaultDashboard();
// $this->getFriends();
// $this->getGroup();
// $this->getTeams();
/*
* TODO: Return these?
*/
// $this->isActivated();
// $this->isDeleted();
// $this->isEnabled();
}
return $returnJSON;
}
示例13: componentAddDashboardView
public function componentAddDashboardView()
{
$request = framework\Context::getRequest();
$this->dashboard = entities\Dashboard::getB2DBTable()->selectById($request['dashboard_id']);
$this->column = $request['column'];
$this->views = entities\DashboardView::getAvailableViews($this->dashboard->getType());
$this->savedsearches = tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), $this->dashboard->getProject() instanceof entities\Project ? $this->dashboard->getProject()->getID() : 0);
}
示例14: doSave
public function doSave($options = array(), $reason = null)
{
if (tables\Articles::getTable()->doesNameConflictExist($this->_name, $this->_id, framework\Context::getScope()->getID())) {
if (!array_key_exists('overwrite', $options) || !$options['overwrite']) {
throw new \Exception(framework\Context::getI18n()->__('Another article with this name already exists'));
}
}
$user_id = framework\Context::getUser() instanceof User ? framework\Context::getUser()->getID() : 0;
if (!isset($options['revert']) || !$options['revert']) {
$revision = tables\ArticleHistory::getTable()->addArticleHistory($this->_name, $this->_old_content, $this->_content, $user_id, $reason);
} else {
$revision = null;
}
tables\ArticleLinks::getTable()->deleteLinksByArticle($this->_name);
ArticleCategories::getTable()->deleteCategoriesByArticle($this->_name);
$this->save();
$this->_old_content = $this->_content;
if (mb_substr($this->getContent(), 0, 10) == "#REDIRECT ") {
$content = explode("\n", $this->getContent());
preg_match('/(\\[\\[([^\\]]*?)\\]\\])$/im', mb_substr(array_shift($content), 10), $matches);
if (count($matches) == 3) {
return;
}
}
list($links, $categories) = $this->_retrieveLinksAndCategoriesFromContent($options);
foreach ($links as $link => $occurrences) {
tables\ArticleLinks::getTable()->addArticleLink($this->_name, $link);
}
foreach ($categories as $category => $occurrences) {
ArticleCategories::getTable()->addArticleCategory($this->_name, $category, $this->isCategory());
}
$this->_history = null;
\thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\modules\\publish\\entities\\Article::doSave', $this, compact('reason', 'revision', 'user_id'))->trigger();
return true;
}
示例15: listen_project_links
public function listen_project_links(framework\Event $event)
{
if (framework\Context::getUser()->hasProjectPageAccess('project_commits', framework\Context::getCurrentProject())) {
$event->addToReturnList(array('url' => framework\Context::getRouting()->generate('vcs_commitspage', array('project_key' => framework\Context::getCurrentProject()->getKey())), 'title' => framework\Context::getI18n()->__('Commits')));
}
}