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


PHP IManager::getCurrentUserId方法代码示例

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


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

示例1: show

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function show()
 {
     try {
         $user = $this->activityManager->getCurrentUserId();
         $userLang = $this->config->getUserValue($user, 'core', 'lang');
         // Overwrite user and language in the helper
         $l = Util::getL10N('activity', $userLang);
         $l->forceLanguage($userLang);
         $this->helper->setL10n($l);
         $this->helper->setUser($user);
         $description = (string) $l->t('Personal activity feed for %s', $user);
         $activities = $this->data->read($this->helper, $this->settings, 0, self::DEFAULT_PAGE_SIZE, 'all', $user);
     } catch (\UnexpectedValueException $e) {
         $l = Util::getL10N('activity');
         $description = (string) $l->t('Your feed URL is invalid');
         $activities = [['activity_id' => -1, 'timestamp' => time(), 'subject' => true, 'subjectformatted' => ['full' => $description]]];
     }
     $response = new TemplateResponse('activity', 'rss', ['rssLang' => $l->getLanguageCode(), 'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'), 'rssPubDate' => date('r'), 'description' => $description, 'activities' => $activities], '');
     if ($this->request->getHeader('accept') !== null && stristr($this->request->getHeader('accept'), 'application/rss+xml')) {
         $response->addHeader('Content-Type', 'application/rss+xml');
     } else {
         $response->addHeader('Content-Type', 'text/xml; charset=UTF-8');
     }
     return $response;
 }
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:feed.php

示例2: translate

 /**
  * The extension can translate a given message to the requested languages.
  * If no translation is available false is to be returned.
  *
  * @param string $app
  * @param string $text
  * @param array $params
  * @param boolean $stripPath
  * @param boolean $highlightParams
  * @param string $languageCode
  * @return string|false
  */
 public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode)
 {
     if ($app === 'announcementcenter') {
         $l = $this->languageFactory->get('announcementcenter', $languageCode);
         list(, $id) = explode('#', $text);
         try {
             $announcement = $this->manager->getAnnouncement($id, $highlightParams);
         } catch (\InvalidArgumentException $e) {
             return (string) $l->t('Announcement does not exist anymore', $params);
         }
         if (strpos($text, 'announcementmessage#') === 0) {
             return $announcement['message'];
         }
         if ($highlightParams) {
             $params[] = '<strong>' . $announcement['subject'] . '</strong>';
         } else {
             $params[] = $announcement['subject'];
         }
         if ($announcement['author'] === $this->activityManager->getCurrentUserId()) {
             array_shift($params);
             return (string) $l->t('You announced %s', $params);
         }
         return (string) $l->t('%s announced %s', $params);
     }
     return false;
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:38,代码来源:activityextension.php

示例3: show

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function show()
 {
     try {
         $user = $this->activityManager->getCurrentUserId();
         $userLang = $this->config->getUserValue($user, 'core', 'lang');
         // Overwrite user and language in the helper
         $this->l = $this->l10nFactory->get('activity', $userLang);
         $parser = new PlainTextParser($this->l);
         $this->helper->setL10n($this->l);
         $this->helper->setUser($user);
         $description = (string) $this->l->t('Personal activity feed for %s', $user);
         $response = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all');
         $data = $response['data'];
         $activities = [];
         foreach ($data as $activity) {
             $activity['subject_prepared'] = $parser->parseMessage($activity['subject_prepared']);
             $activity['message_prepared'] = $parser->parseMessage($activity['message_prepared']);
             $activities[] = $activity;
         }
     } catch (\UnexpectedValueException $e) {
         $this->l = $this->l10nFactory->get('activity');
         $description = (string) $this->l->t('Your feed URL is invalid');
         $activities = [['activity_id' => -1, 'timestamp' => time(), 'subject' => true, 'subject_prepared' => $description]];
     }
     $response = new TemplateResponse('activity', 'rss', ['rssLang' => $this->l->getLanguageCode(), 'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'), 'rssPubDate' => date('r'), 'description' => $description, 'activities' => $activities], '');
     if ($this->request->getHeader('accept') !== null && stristr($this->request->getHeader('accept'), 'application/rss+xml')) {
         $response->addHeader('Content-Type', 'application/rss+xml');
     } else {
         $response->addHeader('Content-Type', 'text/xml; charset=UTF-8');
     }
     return $response;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:38,代码来源:Feed.php

示例4: actorIsCurrentUser

 /**
  * Check if the author is the current user
  *
  * @param string $user Parameter e.g. `<user display-name="admin">admin</user>`
  * @return bool
  */
 protected function actorIsCurrentUser($user)
 {
     try {
         return strip_tags($user) === $this->activityManager->getCurrentUserId();
     } catch (\UnexpectedValueException $e) {
         return false;
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:Extension.php

示例5: authorIsCurrentUser

 /**
  * Check if the author is the current user
  *
  * @param string $user Parameter e.g. `<user display-name="admin">admin</user>`
  * @return bool
  */
 protected function authorIsCurrentUser($user)
 {
     try {
         return strip_tags($user) === $this->activityManager->getCurrentUserId();
     } catch (\UnexpectedValueException $e) {
         // FIXME this is awkward, but we have no access to the current user in emails
         return false;
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:15,代码来源:Extension.php

示例6: getQueryForFilter

 /**
  * For a given filter the extension can specify the sql query conditions including parameters for that query.
  * In case the extension does not know the filter false is to be returned.
  * The query condition and the parameters are to be returned as array with two elements.
  * E.g. return array('`app` = ? and `message` like ?', array('mail', 'ownCloud%'));
  *
  * @param string $filter
  * @return array|false
  */
 public function getQueryForFilter($filter)
 {
     $user = $this->activityManager->getCurrentUserId();
     // Display actions from all files
     if ($filter === self::FILTER_FILES) {
         return ['`app` = ?', [self::APP_FILES]];
     }
     if (!$user) {
         // Remaining filters only work with a user/token
         return false;
     }
     // Display actions from favorites only
     if ($filter === self::FILTER_FAVORITES || in_array($filter, ['all', 'by', 'self']) && $this->userSettingFavoritesOnly($user)) {
         try {
             $favorites = $this->helper->getFavoriteFilePaths($user);
         } catch (\RuntimeException $e) {
             // Too many favorites, can not put them into one query anymore...
             return ['`app` = ?', [self::APP_FILES]];
         }
         /*
          * Display activities only, when they are not `type` create/change
          * or `file` is a favorite or in a favorite folder
          */
         $parameters = $fileQueryList = [];
         $parameters[] = self::APP_FILES;
         $parameters[] = self::APP_FILES;
         $fileQueryList[] = '(`type` <> ? AND `type` <> ?)';
         $parameters[] = self::TYPE_SHARE_CREATED;
         $parameters[] = self::TYPE_SHARE_CHANGED;
         foreach ($favorites['items'] as $favorite) {
             $fileQueryList[] = '`file` = ?';
             $parameters[] = $favorite;
         }
         foreach ($favorites['folders'] as $favorite) {
             $fileQueryList[] = '`file` LIKE ?';
             $parameters[] = $this->connection->escapeLikeParameter($favorite) . '/%';
         }
         return [' CASE ' . 'WHEN `app` <> ? THEN 1 ' . 'WHEN `app` = ? AND (' . implode(' OR ', $fileQueryList) . ') THEN 1 ' . 'ELSE 0 ' . 'END = 1 ', $parameters];
     }
     return false;
 }
开发者ID:evanjt,项目名称:core,代码行数:50,代码来源:activity.php


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