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


PHP IManager::generateEvent方法代码示例

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


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

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

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

示例3: createPublicity

 /**
  * @param int $id
  * @param string $authorId
  * @param int $timeStamp
  */
 protected function createPublicity($id, $authorId, $timeStamp)
 {
     $users = $this->userManager->search('');
     $event = $this->activityManager->generateEvent();
     $event->setApp('announcementcenter')->setType('announcementcenter')->setAuthor($authorId)->setTimestamp($timeStamp)->setSubject('announcementsubject#' . $id, [$authorId])->setMessage('announcementmessage#' . $id, [$authorId])->setObject('announcement', $id);
     $dateTime = new \DateTime();
     $dateTime->setTimestamp($timeStamp);
     $notification = $this->notificationManager->createNotification();
     $notification->setApp('announcementcenter')->setDateTime($dateTime)->setObject('announcement', $id)->setSubject('announced', [$authorId])->setLink($this->urlGenerator->linkToRoute('announcementcenter.page.index'));
     foreach ($users as $user) {
         $event->setAffectedUser($user->getUID());
         $this->activityManager->publish($event);
         if ($authorId !== $user->getUID()) {
             $notification->setUser($user->getUID());
             $this->notificationManager->notify($notification);
         }
     }
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:23,代码来源:pagecontroller.php

示例4: commentEvent

 /**
  * @param CommentsEvent $event
  */
 public function commentEvent(CommentsEvent $event)
 {
     if ($event->getComment()->getObjectType() !== 'files' || !in_array($event->getEvent(), [CommentsEvent::EVENT_ADD]) || !$this->appManager->isInstalled('activity')) {
         // Comment not for file, not adding a comment or no activity-app enabled (save the energy)
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getComment()->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->getComment()->getObjectType(), $event->getComment()->getObjectId())->setMessage(Extension::ADD_COMMENT_MESSAGE, [$event->getComment()->getId()]);
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         $activity->setSubject(Extension::ADD_COMMENT_SUBJECT, [$actor, $path]);
         $this->activityManager->publish($activity);
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:45,代码来源:Listener.php

示例5: addNotificationsForUser

 /**
  * Adds the activity and email for a user when the settings require it
  *
  * @param string $user
  * @param string $subject
  * @param array $subjectParams
  * @param int $fileId
  * @param string $path
  * @param bool $isFile If the item is a file, we link to the parent directory
  * @param bool $streamSetting
  * @param int $emailSetting
  * @param string $type
  */
 protected function addNotificationsForUser($user, $subject, $subjectParams, $fileId, $path, $isFile, $streamSetting, $emailSetting, $type = Files_Sharing::TYPE_SHARED)
 {
     if (!$streamSetting && !$emailSetting) {
         return;
     }
     $selfAction = $user === $this->currentUser;
     $app = $type === Files_Sharing::TYPE_SHARED ? 'files_sharing' : 'files';
     $link = Util::linkToAbsolute('files', 'index.php', array('dir' => $isFile ? dirname($path) : $path));
     $objectType = $fileId ? 'files' : '';
     $event = $this->manager->generateEvent();
     $event->setApp($app)->setType($type)->setAffectedUser($user)->setAuthor($this->currentUser)->setTimestamp(time())->setSubject($subject, $subjectParams)->setObject($objectType, $fileId, $path)->setLink($link);
     // Add activity to stream
     if ($streamSetting && (!$selfAction || $this->userSettings->getUserSetting($this->currentUser, 'setting', 'self'))) {
         $this->activityData->send($event);
     }
     // Add activity to mail queue
     if ($emailSetting && (!$selfAction || $this->userSettings->getUserSetting($this->currentUser, 'setting', 'selfemail'))) {
         $latestSend = time() + $emailSetting;
         $this->activityData->storeMail($event, $latestSend);
     }
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:34,代码来源:fileshooks.php

示例6: downloadShare

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @param string $token
  * @param string $files
  * @param string $path
  * @param string $downloadStartSecret
  * @return void|RedirectResponse
  */
 public function downloadShare($token, $files = null, $path = '', $downloadStartSecret = '')
 {
     \OC_User::setIncognitoMode(true);
     $share = $this->shareManager->getShareByToken($token);
     // Share is password protected - check whether the user is permitted to access the share
     if ($share->getPassword() !== null && !$this->linkShareAuth($share)) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', ['token' => $token]));
     }
     $files_list = null;
     if (!is_null($files)) {
         // download selected files
         $files_list = json_decode($files);
         // in case we get only a single file
         if ($files_list === null) {
             $files_list = [$files];
         }
     }
     $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID());
     $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
     // Single file share
     if ($share->getNode() instanceof \OCP\Files\File) {
         // Single file download
         $event = $this->activityManager->generateEvent();
         $event->setApp('files_sharing')->setType(Activity::TYPE_PUBLIC_LINKS)->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($share->getNode()->getPath())])->setAffectedUser($share->getShareOwner()->getUID())->setObject('files', $share->getNode()->getId(), $userFolder->getRelativePath($share->getNode()->getPath()));
         $this->activityManager->publish($event);
     } else {
         /** @var \OCP\Files\Folder $node */
         $node = $share->getNode();
         // Try to get the path
         if ($path !== '') {
             try {
                 $node = $node->get($path);
             } catch (NotFoundException $e) {
                 return new NotFoundResponse();
             }
         }
         $originalSharePath = $userFolder->getRelativePath($node->getPath());
         if ($node instanceof \OCP\Files\File) {
             // Single file download
             $event = $this->activityManager->generateEvent();
             $event->setApp('files_sharing')->setType(Activity::TYPE_PUBLIC_LINKS)->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])->setAffectedUser($share->getShareOwner()->getUID())->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
             $this->activityManager->publish($event);
         } else {
             if (!empty($files_list)) {
                 /** @var \OCP\Files\Folder $node */
                 // Subset of files is downloaded
                 foreach ($files_list as $file) {
                     $subNode = $node->get($file);
                     $event = $this->activityManager->generateEvent();
                     $event->setApp('files_sharing')->setType(Activity::TYPE_PUBLIC_LINKS)->setAffectedUser($share->getShareOwner()->getUID())->setObject('files', $subNode->getId(), $userFolder->getRelativePath($subNode->getPath()));
                     if ($subNode instanceof \OCP\Files\File) {
                         $event->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($subNode->getPath())]);
                     } else {
                         $event->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED, [$userFolder->getRelativePath($subNode->getPath())]);
                     }
                     $this->activityManager->publish($event);
                 }
             } else {
                 // The folder is downloaded
                 $event = $this->activityManager->generateEvent();
                 $event->setApp('files_sharing')->setType(Activity::TYPE_PUBLIC_LINKS)->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])->setAffectedUser($share->getShareOwner()->getUID())->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
                 $this->activityManager->publish($event);
             }
         }
     }
     /* FIXME: We should do this all nicely in OCP */
     OC_Util::tearDownFS();
     OC_Util::setupFS($share->getShareOwner()->getUID());
     /**
      * this sets a cookie to be able to recognize the start of the download
      * the content must not be longer than 32 characters and must only contain
      * alphanumeric characters
      */
     if (!empty($downloadStartSecret) && !isset($downloadStartSecret[32]) && preg_match('!^[a-zA-Z0-9]+$!', $downloadStartSecret) === 1) {
         // FIXME: set on the response once we use an actual app framework response
         setcookie('ocDownloadStarted', $downloadStartSecret, time() + 20, '/');
     }
     // download selected files
     if (!is_null($files)) {
         // FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
         // after dispatching the request which results in a "Cannot modify header information" notice.
         OC_Files::get($originalSharePath, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD');
         exit;
     } else {
         // FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
         // after dispatching the request which results in a "Cannot modify header information" notice.
         OC_Files::get(dirname($originalSharePath), basename($originalSharePath), $_SERVER['REQUEST_METHOD'] == 'HEAD');
         exit;
     }
 }
开发者ID:Pookay,项目名称:core,代码行数:100,代码来源:sharecontroller.php

示例7: getEventFromArray

 /**
  * @param array $activity
  * @return IEvent
  */
 public function getEventFromArray(array $activity)
 {
     $event = $this->activityManager->generateEvent();
     $event->setApp($activity['app'])->setType($activity['type'])->setAffectedUser($activity['affecteduser'])->setAuthor($activity['user'])->setTimestamp($activity['timestamp'])->setSubject($activity['subject'], $activity['subjectparams'])->setMessage($activity['message'], $activity['messageparams'])->setObject($activity['object_type'], $activity['object_id'], $activity['object_name'])->setLink($activity['link']);
     return $event;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:10,代码来源:GroupHelper.php


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