本文整理汇总了PHP中Foundry::notify方法的典型用法代码示例。如果您正苦于以下问题:PHP Foundry::notify方法的具体用法?PHP Foundry::notify怎么用?PHP Foundry::notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundry
的用法示例。
在下文中一共展示了Foundry::notify方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifySubscribers
/**
* Notify site subscribers whenever a new blog post is created
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function notifySubscribers(EasyBlogTableBlog $blog, $action, $comment = null)
{
// We don't want to notify via e-mail
$emailOptions = false;
$recipients = array();
$rule = '';
if ($action == 'new.post') {
$recipients = $blog->getRegisteredSubscribers('new', array($blog->created_by));
$permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
$image = '';
if ($blog->getImage()) {
$image = $blog->getImage()->getSource('frontpage');
}
$options = array('uid' => $blog->id, 'actor_id' => $blog->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image);
$rule = 'blog.create';
}
if ($action == 'new.comment') {
$recipients = $comment->getSubscribers($blog, array($comment->created_by));
$recipients = array_merge($recipients, array($blog->created_by));
$permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
$image = '';
if ($blog->getImage()) {
$image = $blog->getImage()->getSource('frontpage');
}
$content = JString::substr(strip_tags($comment->comment), 0, 50);
$options = array('uid' => $blog->id, 'actor_id' => $comment->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_COMMENT_ON_THE_BLOG_POST', $content, $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image, 'actor_id' => $comment->created_by);
$rule = 'blog.comment';
}
if ($action == 'ratings.add') {
// Get blog post owner
$recipients = array($blog->created_by);
$permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
$image = '';
if ($blog->getImage()) {
$image = $blog->getImage()->getSource('frontpage');
}
$my = Foundry::user();
$options = array('uid' => $blog->id, 'actor_id' => $my->id, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_RATINGS_FOR_YOUR_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image, 'actor_id' => $my->id);
$rule = 'blog.ratings';
}
if (empty($rule)) {
return false;
}
// Send notifications to the receivers when they unlock the badge
Foundry::notify($rule, $recipients, $emailOptions, $options);
}
示例2: notifyBroadcast
/**
* Notify a broadcast a message to a set of profiles on the site.
*
* @since 1.3
* @access public
* @param int The profile id to target. 0 for all
* @param string The message to be broadcasted
* @return
*/
public function notifyBroadcast($id, $title, $content, $link, $createdBy)
{
$db = FD::db();
$sql = $db->sql();
$query = array();
$query[] = 'SELECT';
$query[] = '`user_id`';
$query[] = 'FROM ' . $db->quoteName('#__social_profiles_maps');
$query[] = 'WHERE 1';
if (!empty($id)) {
$query[] = 'AND ' . $db->quoteName('profile_id') . '=' . $db->Quote($id);
}
// Exclude the broadcaster because it would be pretty insane if I am spamming myself
$my = FD::user();
$query[] = 'AND `user_id` !=' . $db->Quote($my->id);
$query = implode(' ', $query);
$sql->raw($query);
$db->setQuery($sql);
$results = $db->loadObjectList();
$recipients = array();
foreach ($results as $result) {
$recipients[] = FD::user($result);
}
$options = array('uid' => $my->id, 'actor_id' => $my->id, 'title' => $title, 'content' => $content, 'type' => 'broadcast');
$state = Foundry::notify('broadcast.notify', $recipients, false, $options);
if ($state) {
// Create an empty broadcast record for stream item
$query = array();
// Get the creation date
$date = FD::date();
$query[] = 'INSERT INTO ' . $db->quoteName('#__social_broadcasts');
$query[] = '(`target_id`,`target_type`,`title`,`content`,`link`,`state`,`created`,`created_by`) VALUES';
$query[] = '(' . $db->Quote('') . ',' . $db->Quote('') . ',' . $db->Quote($title) . ',' . $db->Quote($content) . ',' . $db->Quote($link) . ',1,' . $db->Quote($date->toSql()) . ',' . $db->Quote($createdBy) . ')';
$query = implode(' ', $query);
$sql->raw($query);
$db->setQuery($sql);
$state = $db->Query();
if (!$state) {
return $state;
}
// Get the id of the new broadcasted item
$id = $db->insertid();
return $id;
}
return $state;
}
示例3: sendNotification
public function sendNotification(JUser $sender, JUser $receiver, $content = "ES Notification", $systemOptions = array())
{
$recipient[] = $receiver->id;
// If you do not want to send email, $emailOptions should be set to false
// $emailOptions - An array of options to define in the mail
// Email template
$emailOptions = false;
// If you do not want to send system notifications, set this to false.
// $systemOptions - The internal system notifications
// System notification template
$myUser = Foundry::user($receiver->id);
$cmd = $systemOptions['cmd'];
unset($systemOptions['cmd']);
$systemOptions['url'] = JRoute::_($myUser->getPermalink());
$resp = Foundry::notify($cmd, $recipient, $emailOptions, $systemOptions);
}
示例4: onAfterLikeSave
/**
* Processes when someone likes the stream of a milestone
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function onAfterLikeSave(&$likes)
{
$allowed = array('tasks.group.createMilestone');
if (!in_array($likes->type, $allowed)) {
return;
}
// Get the verb
$segments = explode('.', $likes->type);
$verb = $segments[2];
if ($likes->type == 'tasks.group.createMilestone') {
// Get the milestone
$milestone = FD::table('Milestone');
$milestone->load($likes->uid);
// Get the group
$group = FD::group($milestone->uid);
// Get a list of recipients
$recipients = $this->getStreamNotificationTargets($likes->uid, 'tasks', 'group', $verb, array(), array($milestone->owner_id, $likes->created_by));
// okay since likes on group task can be made to 'task.group.createmilestones' and can only be liked via stream item,
// also, currently milestone page do not display any likes, thus the link have to go to stream item page to see the likes.
// @2014-07-02, Sam
$emailOptions = array('title' => 'APP_GROUP_TASKS_EMAILS_LIKE_YOUR_MILESTONE_TITLE', 'template' => 'apps/group/tasks/like.milestone', 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'external' => true, 'xhtml' => true)));
$systemOptions = array('title' => '', 'context_type' => $likes->type, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id)), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
// Notify the owner first
if ($likes->created_by != $milestone->owner_id) {
Foundry::notify('likes.item', array($milestone->owner_id), $emailOptions, $systemOptions);
}
// Get a list of recipients to be notified for this stream item
// We exclude the owner of the note and the actor of the like here
$recipients = $this->getStreamNotificationTargets($likes->uid, 'tasks', 'group', $verb, array(), array($milestone->owner_id, $likes->created_by));
$emailOptions['title'] = 'APP_GROUP_TASKS_EMAILS_LIKE_USERS_MILESTONE_TITLE';
$emailOptions['template'] = 'apps/group/tasks/like.milestone.involved';
// Notify other participating users
FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
}
}
示例5: onAfterCommentSave
/**
* Triggered when a comment save occurs
*
* @since 1.0
* @access public
* @param SocialTableComments The comment object
* @return
*/
public function onAfterCommentSave(&$comment)
{
$allowed = array('photos.user.upload', 'albums.user.create', 'stream.user.upload', 'photos.user.add', 'photos.user.uploadAvatar', 'photos.user.updateCover');
if (!in_array($comment->element, $allowed)) {
return;
}
// For likes on albums when user uploads multiple photos within an album
if ($comment->element == 'albums.user.create') {
// Since the uid is tied to the album we can get the album object
$album = Foundry::table('Album');
$album->load($comment->uid);
// Get the actor of the likes
$actor = Foundry::user($comment->created_by);
// Set the email options
$emailOptions = array('title' => 'APP_USER_PHOTOS_EMAILS_COMMENT_ALBUM_ITEM_SUBJECT', 'template' => 'apps/user/photos/comment.album.item', 'permalink' => $album->getPermalink(true, true), 'comment' => $comment->comment, 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
$systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->uid, 'url' => $album->getPermalink(false, false, 'item', false), 'actor_id' => $comment->created_by, 'uid' => $comment->id, 'aggregate' => true);
// Notify the owner of the photo first
if ($comment->created_by != $album->user_id) {
Foundry::notify('comments.item', array($album->user_id), $emailOptions, $systemOptions);
}
// Get a list of recipients to be notified for this stream item
// We exclude the owner of the note and the actor of the like here
$recipients = $this->getStreamNotificationTargets($comment->uid, 'albums', 'user', 'create', array(), array($album->user_id, $comment->created_by));
$emailOptions['title'] = 'APP_USER_PHOTOS_EMAILS_COMMENT_ALBUM_INVOLVED_SUBJECT';
$emailOptions['template'] = 'apps/user/photos/comment.album.involved';
// Notify other participating users
Foundry::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
return;
}
// For comments made on photos
$allowed = array('photos.user.upload', 'stream.user.upload', 'photos.user.add', 'photos.user.uploadAvatar', 'photos.user.updateCover');
if (in_array($comment->element, $allowed)) {
// Get the actor of the likes
$actor = Foundry::user($comment->created_by);
// Set the email options
$emailOptions = array('template' => 'apps/user/photos/comment.photo.item', 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
$systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->uid, 'actor_id' => $comment->created_by, 'uid' => $comment->id, 'aggregate' => true);
// Standard email subject
$ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PHOTO_ITEM_SUBJECT';
$involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PHOTO_INVOLVED_SUBJECT';
// If this item is multiple share on the stream, we need to get the photo id here.
if ($comment->element == 'stream.user.upload') {
// Since this item is tied to the stream, we need to load the stream object
$stream = Foundry::table('Stream');
$stream->load($comment->uid);
// Get the photo object from the context id of the stream
$model = Foundry::model('Stream');
$origin = $model->getContextItem($comment->uid);
$photo = Foundry::table('Photo');
$photo->load($origin->context_id);
// Get the permalink to the photo
$emailOptions['permalink'] = $stream->getPermalink(true, true);
$systemOptions['url'] = $stream->getPermalink(false, false, false);
$element = 'stream';
$verb = 'upload';
}
// For single photo items on the stream
if ($comment->element == 'photos.user.upload' || $comment->element == 'photos.user.add' || $comment->element == 'photos.user.uploadAvatar' || $comment->element == 'photos.user.updateCover') {
// Get the photo object
$photo = Foundry::table('Photo');
$photo->load($comment->uid);
// Get the permalink to the photo
$emailOptions['permalink'] = $photo->getPermalink(true, true);
$systemOptions['url'] = $photo->getPermalink(false, false, 'item', false);
$element = 'photos';
$verb = 'upload';
}
if ($comment->element == 'photos.user.uploadAvatar') {
$verb = 'uploadAvatar';
$ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_ITEM_SUBJECT';
$involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_INVOLVED_SUBJECT';
}
if ($comment->element == 'photos.user.updateCover') {
$verb = 'updateCover';
$ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_COVER_ITEM_SUBJECT';
$involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_COVER_INVOLVED_SUBJECT';
}
$emailOptions['title'] = $ownerTitle;
// @points: photos.like
// Assign points for the author for liking this item
$photo->assignPoints('photos.comment.add', $comment->created_by);
// Notify the owner of the photo first
if ($photo->user_id != $comment->created_by) {
Foundry::notify('comments.item', array($photo->user_id), $emailOptions, $systemOptions);
}
// Get additional recipients since photos has tag
$additionalRecipients = array();
$this->getTagRecipients($additionalRecipients, $photo);
// Get a list of recipients to be notified for this stream item
// We exclude the owner of the note and the actor of the like here
$recipients = $this->getStreamNotificationTargets($comment->uid, $element, 'user', $verb, $additionalRecipients, array($photo->user_id, $comment->created_by));
$emailOptions['title'] = $involvedTitle;
//.........这里部分代码省略.........
示例6: sendNotification
public function sendNotification(JUser $sender, JUser $receiver, $content = "JS Notification", $options = array())
{
$recipient[] = $receiver->id;
// If you do not want to send email, $emailOptions should be set to false
// $emailOptions - An array of options to define in the mail
// Email template
$emailOptions = false;
// If you do not want to send system notifications, set this to false.
// $systemOptions - The internal system notifications
// System notification template
$myUser = Foundry::user($receiver->id);
$systemOptions['url'] = JRoute::_($myUser->getPermalink());
$title = $myUser->getName() . " " . $notification_msg;
Foundry::notify('notify_invite.create', $recipient, $emailOptions, $systemOptions);
}
示例7: notify
/**
* Notify site subscribers whenever a new blog post is created
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function notify($action, $post, $question = null, $comment = null, $actor = null)
{
if (!$this->exists()) {
return;
}
// We don't want to notify via e-mail
$emailOptions = false;
$recipients = array();
$rule = '';
$recipients = $this->getRecipients($action, $post);
if ($action == 'new.discussion') {
if (!$this->config->get('integration_easysocial_notify_create')) {
return;
}
if (!$recipients) {
return;
}
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id);
$image = '';
$options = array('actor_id' => $post->user_id, 'uid' => $post->id, 'title' => JText::sprintf('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_NEW_POST', $post->title), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.create';
}
if ($action == 'new.reply') {
if (!$this->config->get('integration_easysocial_notify_reply')) {
return;
}
if (!$recipients) {
return;
}
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $question->id);
$options = array('actor_id' => $post->user_id, 'uid' => $post->id, 'title' => JText::sprintf('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_REPLY', $question->title), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.reply';
}
if ($action == 'new.comment') {
if (!$this->config->get('integration_easysocial_notify_comment')) {
return;
}
// The recipient should only be the post owner
$recipients = array($post->user_id);
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $question->id) . '#' . JText::_('COM_EASYDISCUSS_REPLY_PERMALINK') . '-' . $post->id;
$content = JString::substr($comment->comment, 0, 25) . '...';
$options = array('actor_id' => $comment->user_id, 'uid' => $comment->id, 'title' => JText::sprintf('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_COMMENT', $content), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.comment';
}
if ($action == 'accepted.answer') {
if (!$this->config->get('integration_easysocial_notify_accepted')) {
return;
}
// The recipient should only be the post owner
$recipients = array($post->user_id);
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $question->id) . '#answer';
$options = array('actor_id' => $actor, 'uid' => $post->id, 'title' => JText::sprintf('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_ACCEPTED_ANSWER', $question->title), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.accepted';
}
if ($action == 'accepted.answer.owner') {
if (!$this->config->get('integration_easysocial_notify_accepted')) {
return;
}
// The recipient should only be the post owner
$recipients = array($question->user_id);
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $question->id) . '#answer';
$options = array('actor_id' => $actor, 'uid' => $post->id, 'title' => JText::sprintf('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_ACCEPTED_ANSWER_OWNER', $question->title), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.accepted.owner';
}
if ($action == 'new.likes') {
if (!$this->config->get('integration_easysocial_notify_likes')) {
return;
}
// The recipient should only be the post owner
$recipients = array($post->user_id);
$permalink = DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $question->id) . '#' . JText::_('COM_EASYDISCUSS_REPLY_PERMALINK') . '-' . $post->id;
$options = array('actor_id' => JFactory::getUser()->id, 'uid' => $post->id, 'title' => JText::_('COM_EASYDISCUSS_EASYSOCIAL_NOTIFICATION_LIKES'), 'type' => 'discuss', 'url' => $permalink);
$rule = 'discuss.likes';
}
if (empty($rule)) {
return false;
}
// Send notifications to the receivers when they unlock the badge
Foundry::notify($rule, $recipients, $emailOptions, $options);
}
示例8: notify
public function notify( $action, $comment )
{
if( !$this->exists() )
{
return false;
}
$targets = array();
switch( $action )
{
case 'comment':
$targets = array( 'author', 'usergroup', 'participant' );
break;
case 'reply':
$targets = array( 'parent', 'author', 'usergroup', 'participant' );
break;
case 'like':
$targets = array( 'owner', 'usergroup' );
break;
default:
return false;
break;
}
$actor = Foundry::user();
$application = Komento::loadApplication( $comment->component )->load( $comment->cid );
$pagelink = $application->getContentPermalink();
$permalink = $pagelink . '#kmt-' . $comment->id;
$title = $application->getContentTitle();
$systemOptions = array(
'uid' => $comment->id,
'actor_id' => $actor->id,
'type' => 'komento',
'url' => $permalink,
'image' => $actor->getAvatar( SOCIAL_AVATAR_LARGE ),
'contentTitle' => $title,
'owner' => $comment->created_by
);
$socialApp = $this->getApp();
if( $socialApp )
{
$systemOptions['app_id'] = $socialApp->id;
}
$notified = array();
// We always do not want action user to get notified
$notified[] = $actor->id;
foreach( $targets as $target )
{
$users = array_diff( $this->getNotificationTarget( $target, $action, $comment ), $notified );
if( !empty( $users ) )
{
$systemOptions['target'] = $target;
Foundry::notify( 'komento.' . $action, $users, false, $systemOptions );
}
$notified = array_merge( $notified, $users );
}
}