本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}