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


PHP Activity\IManager类代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $app = $this->getUniqueID('MailQueueHandlerTest');
     $this->userManager = $this->getMock('OCP\\IUserManager');
     $connection = \OC::$server->getDatabaseConnection();
     $query = $connection->prepare('INSERT INTO `*PREFIX*activity_mq` ' . ' (`amq_appid`, `amq_subject`, `amq_subjectparams`, `amq_affecteduser`, `amq_timestamp`, `amq_type`, `amq_latest_send`) ' . ' VALUES(?, ?, ?, ?, ?, ?, ?)');
     $query->execute(array($app, 'Test data', 'Param1', 'user1', 150, 'phpunit', 152));
     $query->execute(array($app, 'Test data', 'Param1', 'user1', 150, 'phpunit', 153));
     $query->execute(array($app, 'Test data', 'Param1', 'user2', 150, 'phpunit', 150));
     $query->execute(array($app, 'Test data', 'Param1', 'user2', 150, 'phpunit', 151));
     $query->execute(array($app, 'Test data', 'Param1', 'user3', 150, 'phpunit', 154));
     $query->execute(array($app, 'Test data', 'Param1', 'user3', 150, 'phpunit', 155));
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('setApp')->willReturnSelf();
     $event->expects($this->any())->method('setType')->willReturnSelf();
     $event->expects($this->any())->method('setAffectedUser')->willReturnSelf();
     $event->expects($this->any())->method('setTimestamp')->willReturnSelf();
     $event->expects($this->any())->method('setSubject')->willReturnSelf();
     $this->activityManager = $this->getMockBuilder('OCP\\Activity\\IManager')->disableOriginalConstructor()->getMock();
     $this->activityManager->expects($this->any())->method('generateEvent')->willReturn($event);
     $this->dataHelper = $this->getMockBuilder('OCA\\Activity\\DataHelper')->disableOriginalConstructor()->getMock();
     $this->dataHelper->expects($this->any())->method('getParameters')->willReturn([]);
     $this->message = $this->getMockBuilder('OC\\Mail\\Message')->disableOriginalConstructor()->getMock();
     $this->mailer = $this->getMock('OCP\\Mail\\IMailer');
     $this->mailer->expects($this->any())->method('createMessage')->willReturn($this->message);
     $this->mailQueueHandler = new MailQueueHandler($this->getMock('\\OCP\\IDateTimeFormatter'), $connection, $this->dataHelper, $this->mailer, $this->getMockBuilder('\\OCP\\IURLGenerator')->disableOriginalConstructor()->getMock(), $this->userManager, $this->activityManager);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:28,代码来源:mailqueuehandlertest.php

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

示例3: testAppActivity

 public function testAppActivity()
 {
     $this->activityManager->expects($this->once())->method('registerExtension')->willReturnCallback(function ($closure) {
         $this->assertInstanceOf('\\Closure', $closure);
         $navigation = $closure();
         $this->assertInstanceOf('\\OCA\\AnnouncementCenter\\ActivityExtension', $navigation);
     });
     include __DIR__ . '/../../appinfo/app.php';
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:9,代码来源:AppTest.php

示例4: getLinkList

 /**
  * Get all items for the users we want to send an email to
  *
  * @return array Notification data (user => array of rows from the table)
  */
 public function getLinkList()
 {
     $topEntries = [['id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')]];
     if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) {
         $topEntries[] = ['id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))];
         $topEntries[] = ['id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))];
     }
     $additionalEntries = $this->activityManager->getNavigation();
     $topEntries = array_merge($topEntries, $additionalEntries['top']);
     return array('top' => $topEntries, 'apps' => $additionalEntries['apps']);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:16,代码来源:navigation.php

示例5: translate

 public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode)
 {
     if ($app !== 'activity_ext') {
         return false;
     }
     $l = $this->getL10N($languageCode);
     if ($this->activityManager->isFormattingFilteredObject()) {
         $translation = $this->translateShort($text, $l, $params);
         if ($translation !== false) {
             return $translation;
         }
     }
     return $this->translateLong($text, $l, $params);
 }
开发者ID:inwinstack,项目名称:owncloud-activity_ext,代码行数:14,代码来源:activity.php

示例6: translation

 /**
  * @brief Translate an event string with the translations from the app where it was send from
  * @param string $app The app where this event comes from
  * @param string $text The text including placeholders
  * @param array $params The parameter for the placeholder
  * @param bool $stripPath Shall we strip the path from file names?
  * @param bool $highlightParams Shall we highlight the parameters in the string?
  *             They will be highlighted with `<strong>`, all data will be passed through
  *             \OCP\Util::sanitizeHTML() before, so no XSS is possible.
  * @return string translated
  */
 public function translation($app, $text, $params, $stripPath = false, $highlightParams = false)
 {
     if (!$text) {
         return '';
     }
     $preparedParams = $this->parameterHelper->prepareParameters($params, $this->parameterHelper->getSpecialParameterList($app, $text), $stripPath, $highlightParams);
     // Allow apps to correctly translate their activities
     $translation = $this->activityManager->translate($app, $text, $preparedParams, $stripPath, $highlightParams, $this->l->getLanguageCode());
     if ($translation !== false) {
         return $translation;
     }
     $l = Util::getL10N($app, $this->l->getLanguageCode());
     return $l->t($text, $preparedParams);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:25,代码来源:datahelper.php

示例7: getDefaultTypes

 /**
  * Get the default selection of types for a method
  *
  * @param string $method Should be one of 'stream' or 'email'
  * @return array Array of strings
  */
 public function getDefaultTypes($method)
 {
     $settings = array();
     if ($method === 'stream') {
         $settings[] = Data::TYPE_SHARE_CREATED;
         $settings[] = Data::TYPE_SHARE_CHANGED;
         $settings[] = Data::TYPE_SHARE_DELETED;
         //			$settings[] = Data::TYPE_SHARE_RESHARED;
         $settings[] = Data::TYPE_SHARE_RESTORED;
         //			$settings[] = Data::TYPE_SHARE_DOWNLOADED;
     }
     if ($method === 'stream' || $method === 'email') {
         $settings[] = Data::TYPE_SHARED;
         //			$settings[] = Data::TYPE_SHARE_EXPIRED;
         //			$settings[] = Data::TYPE_SHARE_UNSHARED;
         //
         //			$settings[] = Data::TYPE_SHARE_UPLOADED;
         //
         //			$settings[] = Data::TYPE_STORAGE_QUOTA_90;
         //			$settings[] = Data::TYPE_STORAGE_FAILURE;
     }
     // Allow other apps to add notification types to the default setting
     $additionalSettings = $this->manager->getDefaultTypes($method);
     $settings = array_merge($settings, $additionalSettings);
     return $settings;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:32,代码来源:usersettings.php

示例8: sendEmailToUser

 /**
  * Send a notification to one user
  *
  * @param string $userName Username of the recipient
  * @param string $email Email address of the recipient
  * @param string $lang Selected language of the recipient
  * @param string $timezone Selected timezone of the recipient
  * @param int $maxTime
  */
 public function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime)
 {
     $user = $this->userManager->get($userName);
     if (!$user instanceof IUser) {
         return;
     }
     list($mailData, $skippedCount) = $this->getItemsForUser($userName, $maxTime);
     $l = $this->getLanguage($lang);
     $parser = new PlainTextParser($l);
     $this->dataHelper->setUser($userName);
     $this->dataHelper->setL10n($l);
     $this->activityManager->setCurrentUserId($userName);
     $activityList = array();
     foreach ($mailData as $activity) {
         $event = $this->activityManager->generateEvent();
         $event->setApp($activity['amq_appid'])->setType($activity['amq_type'])->setTimestamp($activity['amq_timestamp'])->setSubject($activity['amq_subject'], []);
         $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($activity['amq_timestamp'], 'long', 'medium', new \DateTimeZone($timezone), $l);
         $activityList[] = array($parser->parseMessage($this->dataHelper->translation($activity['amq_appid'], $activity['amq_subject'], $this->dataHelper->getParameters($event, 'subject', $activity['amq_subjectparams']))), $relativeDateTime);
     }
     $alttext = new Template('activity', 'email.notification', '', false);
     $alttext->assign('username', $user->getDisplayName());
     $alttext->assign('activities', $activityList);
     $alttext->assign('skippedCount', $skippedCount);
     $alttext->assign('owncloud_installation', $this->urlGenerator->getAbsoluteURL('/'));
     $alttext->assign('overwriteL10N', $l);
     $emailText = $alttext->fetchPage();
     $message = $this->mailer->createMessage();
     $message->setTo([$email => $user->getDisplayName()]);
     $message->setSubject((string) $l->t('Activity notification'));
     $message->setPlainBody($emailText);
     $message->setFrom([$this->getSenderData('email') => $this->getSenderData('name')]);
     $this->mailer->send($message);
     $this->activityManager->setCurrentUserId(null);
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:43,代码来源:MailQueueHandler.php

示例9: mapperEvent

 /**
  * @param MapperEvent $event
  */
 public function mapperEvent(MapperEvent $event)
 {
     $tagIds = $event->getTags();
     if ($event->getObjectType() !== 'files' || empty($tagIds) || !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN]) || !$this->appManager->isInstalled('activity')) {
         // System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy)
         return;
     }
     try {
         $tags = $this->tagManager->getTagsByIds($tagIds);
     } catch (TagNotFoundException $e) {
         // User assigned/unassigned a non-existing tag, ignore...
         return;
     }
     if (empty($tags)) {
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getObjectId());
         if (!empty($nodes)) {
             /** @var Node $node */
             $node = array_shift($nodes);
             $path = $node->getPath();
             if (strpos($path, '/' . $owner . '/files/') === 0) {
                 $path = substr($path, strlen('/' . $owner . '/files'));
             }
             // Get all users that have access to the mount point
             $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
         }
     }
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor)->setObject($event->getObjectType(), $event->getObjectId());
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         foreach ($tags as $tag) {
             if ($event->getEvent() === MapperEvent::EVENT_ASSIGN) {
                 $activity->setSubject(Extension::ASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
             } else {
                 if ($event->getEvent() === MapperEvent::EVENT_UNASSIGN) {
                     $activity->setSubject(Extension::UNASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
                 }
             }
             $this->activityManager->publish($activity);
         }
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:63,代码来源:listener.php

示例10: testCreatePublicity

 public function testCreatePublicity()
 {
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setType')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setAuthor')->with('author')->willReturnSelf();
     $event->expects($this->once())->method('setTimestamp')->with(1337)->willReturnSelf();
     $event->expects($this->once())->method('setSubject')->with('announcementsubject#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setMessage')->with('announcementmessage#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $event->expects($this->exactly(5))->method('setAffectedUser')->willReturnSelf();
     $notification = $this->getMockBuilder('OC\\Notification\\INotification')->disableOriginalConstructor()->getMock();
     $notification->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $dateTime = new \DateTime();
     $dateTime->setTimestamp(1337);
     $notification->expects($this->once())->method('setDateTime')->with($dateTime)->willReturnSelf();
     $notification->expects($this->once())->method('setSubject')->with('announced', ['author'])->willReturnSelf();
     $notification->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $notification->expects($this->once())->method('setLink')->willReturnSelf();
     $notification->expects($this->exactly(4))->method('setUser')->willReturnSelf();
     $controller = $this->getController();
     $this->activityManager->expects($this->once())->method('generateEvent')->willReturn($event);
     $this->notificationManager->expects($this->once())->method('createNotification')->willReturn($notification);
     $this->userManager->expects($this->once())->method('search')->with('')->willReturn([$this->getUserMock('author', 'User One'), $this->getUserMock('u2', 'User Two'), $this->getUserMock('u3', 'User Three'), $this->getUserMock('u4', 'User Four'), $this->getUserMock('u5', 'User Five')]);
     $this->activityManager->expects($this->exactly(5))->method('publish');
     $this->notificationManager->expects($this->exactly(4))->method('notify');
     $this->invokePrivate($controller, 'createPublicity', [10, 'author', 1337]);
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:28,代码来源:PageControllerTest.php

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

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

示例13: mockUserSession

 protected function mockUserSession($user)
 {
     $mockUser = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
     $mockUser->expects($this->any())->method('getUID')->willReturn($user);
     $this->session->expects($this->any())->method('isLoggedIn')->willReturn(true);
     $this->session->expects($this->any())->method('getUser')->willReturn($mockUser);
     $this->manager->expects($this->any())->method('getCurrentUserId')->willReturn($user);
 }
开发者ID:ynott,项目名称:activity,代码行数:8,代码来源:feedtest.php

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

示例15: getSpecialParameterList

 /**
  * List with special parameters for the message
  *
  * @param string $app
  * @param string $text
  * @return array
  */
 public function getSpecialParameterList($app, $text)
 {
     $specialParameters = $this->activityManager->getSpecialParameterList($app, $text);
     if ($specialParameters !== false) {
         return $specialParameters;
     }
     return array();
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:15,代码来源:parameterhelper.php


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