本文整理汇总了PHP中OCP\Activity\IManager::setCurrentUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP IManager::setCurrentUserId方法的具体用法?PHP IManager::setCurrentUserId怎么用?PHP IManager::setCurrentUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Activity\IManager
的用法示例。
在下文中一共展示了IManager::setCurrentUserId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}