Ejemplo n.º 1
0
 /**
  * Triggered before comments notify subscribers
  *
  * @since	1.0
  * @access	public
  * @param	SocialTableComments	The comment object
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     $allowed = array('files.user.create');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     // For likes on albums when user uploads multiple photos within an album
     if ($comment->element == 'files.user.create') {
         // Since the uid is tied to the album we can get the album object
         $stream = FD::table('Stream');
         $stream->load($comment->uid);
         // Get the actor of the likes
         $actor = FD::user($comment->created_by);
         $owner = FD::user($stream->actor_id);
         // Set the email options
         $emailOptions = array('title' => 'APP_USER_FILES_EMAILS_COMMENT_STREAM_SUBJECT', 'template' => 'apps/user/files/comment.status.item', 'permalink' => $stream->getPermalink(true, true), 'comment' => $comment->comment, 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'target' => $owner->getName(), 'targetLink' => $owner->getPermalink(true, true));
         $systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->id, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner of the photo first
         if ($stream->actor_id != $comment->created_by) {
             FD::notify('comments.item', array($stream->actor_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, 'files', 'user', 'create', array(), array($stream->actor_id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_FILES_EMAILS_COMMENT_STREAM_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/files/comment.status.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
 }
Ejemplo n.º 2
0
 /**
  * After a person replies a topic
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterReply($message)
 {
     $length = JString::strlen($message->message);
     // Assign points for replying a thread
     if ($length > $this->params->get('activity_points_limit', 0)) {
         $this->assignPoints('thread.reply');
     }
     // Assign badge for replying to a thread
     if ($length > $this->params->get('activity_badge_limit', 0)) {
         $this->assignBadge('thread.reply', JText::_('PLG_KUNENA_EASYSOCIAL_BADGE_REPLY_TITLE'));
     }
     $stream = FD::stream();
     $tmpl = $stream->getTemplate();
     $tmpl->setActor($message->userid, SOCIAL_TYPE_USER);
     $tmpl->setContext($message->id, 'kunena');
     $tmpl->setVerb('reply');
     $tmpl->setAccess('core.view');
     // Add into stream
     $stream->add($tmpl);
     // Get a list of subscribers
     $recipients = $this->getSubscribers($message);
     if (!$recipients) {
         return;
     }
     $permalink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null);
     $options = array('uid' => $message->id, 'actor_id' => $message->userid, 'title' => '', 'type' => 'post', 'url' => $permalink, 'image' => '');
     // Add notifications in EasySocial
     FD::notify('post.reply', $recipients, array(), $options);
 }
Ejemplo n.º 3
0
 public function onAfterLikeSave($likes)
 {
     if ($likes->type != 'relationship.user.approve') {
         return;
     }
     $table = $this->getTableObject($likes->uid);
     if (!$table) {
         return;
     }
     $recipients = $this->getStreamNotificationTargets($likes->uid, 'relationship', 'user', 'approve', array($table->actor, $table->target), array($likes->created_by));
     $streamItem = FD::table('streamitem');
     $streamItem->load(array('context_type' => 'relationship', 'context_id' => $likes->uid, 'verb' => 'approve'));
     FD::notify('likes.item', $recipients, array('link' => $streamItem->getPermalink(true, true)), array('type' => 'likes', 'uid' => $likes->uid, 'context_type' => $likes->type, 'url' => $streamItem->getPermalink(false, false, false)));
 }
Ejemplo n.º 4
0
 /**
  * Processes after someone likes an announcement
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterLikeSave(&$likes)
 {
     $allowed = array('news.group.create');
     if (!in_array($likes->type, $allowed)) {
         return;
     }
     if ($likes->type == 'news.group.create') {
         // Get the stream object
         $news = FD::table('ClusterNews');
         $news->load($likes->uid);
         // Get the likes actor
         $actor = FD::user($likes->created_by);
         $emailOptions = array('title' => 'APP_GROUP_NEWS_EMAILS_LIKE_ITEM_SUBJECT', 'template' => 'apps/group/news/like.news.item', 'permalink' => $news->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
         $systemOptions = array('context_type' => $likes->type, 'context_ids' => $news->cluster_id, 'url' => $news->getPermalink(false, false, false), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
         // Notify the owner first
         if ($news->created_by != $likes->created_by) {
             FD::notify('likes.item', array($news->created_by), $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, 'news', 'group', 'create', array(), array($news->created_by, $likes->created_by));
         $emailOptions['title'] = 'APP_GROUP_NEWS_EMAILS_LIKE_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/group/news/like.news.involved';
         // Notify other participating users
         FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
 }
Ejemplo n.º 5
0
 /**
  * Processes when someone likes the stream of a milestone
  *
  * @since    1.2
  * @access    public
  * @param    string
  * @return
  */
 public function onAfterLikeSave(&$likes)
 {
     $allowed = array('tasks.event.createMilestone', 'tasks.event.createTask');
     if (!in_array($likes->type, $allowed)) {
         return;
     }
     // Get the verb
     list($element, $group, $verb) = explode('.', $likes->type);
     $identifier = $verb == 'createMilestone' ? 'milestone' : 'task';
     // Get the milestone/task table
     $table = FD::table($identifier);
     $table->load($likes->uid);
     // Get the actor
     $actor = FD::user($likes->created_by);
     // Get the owner
     $owner = FD::user($table->owner_id);
     // Get the event
     $event = FD::event($table->uid);
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     // APP_EVENT_TASKS_EMAILS_LIKE_YOUR_MILESTONE_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_YOUR_TASK_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_A_MILESTONE_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_A_TASK_SUBJECT
     // apps/event/tasks/like.milestone
     // apps/event/tasks/like.task
     // apps/event/tasks/like.milestone.involved
     // apps/event/tasks/like.task.involved
     $emailOptions = array('title' => 'APP_EVENT_TASKS_EMAILS_LIKE_YOUR_' . strtoupper($identifier) . '_SUBJECT', 'template' => 'apps/event/tasks/like.' . $identifier, 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
     $systemOptions = array('context_type' => $likes->type, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'sef' => false)), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     // Notify the owner first
     if ($likes->created_by != $owner->id) {
         FD::notify('likes.item', array($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, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     $emailOptions['title'] = 'APP_EVENT_TASKS_EMAILS_LIKE_A_' . strtoupper($identifier) . '_SUBJECT';
     $emailOptions['template'] = 'apps/event/tasks/like.' . $identifier . '.involved';
     // Notify other participating users
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 6
0
 /**
  * Allows a user to follow another user.
  *
  * @since	1.0
  * @access	public
  */
 public function follow()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user needs to be logged in.
     FD::requireLogin();
     // Get the current view.
     $view = $this->getCurrentView();
     // Get the object identifier.
     $id = JRequest::getInt('id');
     // Get the user that is being followed
     $user = FD::user($id);
     $type = JRequest::getVar('type');
     $group = JRequest::getVar('group', SOCIAL_APPS_GROUP_USER);
     // Get the current logged in user.
     $my = FD::user();
     // Load subscription table.
     $subscription = FD::table('Subscription');
     // Get subscription library
     $subscriptionLib = FD::get('Subscriptions');
     // User should never be allowed to follow themselves.
     if ($my->id == $id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_FOLLOWERS_NOT_ALLOWED_TO_FOLLOW_SELF'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $subscription);
     }
     // Determine if the current user is already a follower
     $isFollowing = $subscriptionLib->isFollowing($id, $type, $group, $my->id);
     // If it's already following, throw proper message
     if ($isFollowing) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_SUBSCRIPTIONS_ERROR_ALREADY_FOLLOWING_USER'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $subscription);
     }
     // If the user isn't alreayd following, create a new subscription record.
     $subscription->uid = $id;
     $subscription->type = $type . '.' . $group;
     $subscription->user_id = $my->id;
     $state = $subscription->store();
     if (!$state) {
         $view->setMessage($subscription->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $subscription);
     }
     // @badge: followers.follow
     $badge = FD::badges();
     $badge->log('com_easysocial', 'followers.follow', $my->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWING_USER'));
     // @badge: followers.followed
     $badge->log('com_easysocial', 'followers.followed', $user->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWED'));
     // @points: profile.follow
     // Assign points when user follows another person
     $points = FD::points();
     $points->assign('profile.follow', 'com_easysocial', $my->id);
     // @points: profile.followed
     // Assign points when user is being followed by another person
     $points->assign('profile.followed', 'com_easysocial', $user->id);
     // check if admin want to add stream on following a user or not.
     $config = FD::config();
     if ($config->get('users.stream.following')) {
         // Share this on the stream.
         $stream = FD::stream();
         $streamTemplate = $stream->getTemplate();
         // Set the actor.
         $streamTemplate->setActor($my->id, SOCIAL_TYPE_USER);
         // Set the context.
         $streamTemplate->setContext($subscription->id, SOCIAL_TYPE_FOLLOWERS);
         // Set the verb.
         $streamTemplate->setVerb('follow');
         $streamTemplate->setAccess('followers.view');
         // Create the stream data.
         $stream->add($streamTemplate);
     }
     // Set the email options
     $emailOptions = array('title' => 'COM_EASYSOCIAL_EMAILS_NEW_FOLLOWER_SUBJECT', 'template' => 'site/followers/new.followers', 'actor' => $my->getName(), 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $my->getPermalink(true, true), 'target' => $user->getName(), 'targetLink' => $user->getPermalink(true, true), 'totalFriends' => $my->getTotalFriends(), 'totalFollowing' => $my->getTotalFollowing(), 'totalFollowers' => $my->getTotalFollowers());
     $state = FD::notify('profile.followed', array($user->id), $emailOptions, array('url' => $my->getPermalink(false, false, false), 'actor_id' => $my->id, 'uid' => $id));
     return $view->call(__FUNCTION__, $subscription);
 }
Ejemplo n.º 7
0
 /**
  * Notifies the owner when user likes their feed
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     // @legacy
     // photos.user.add should just be photos.user.upload since they are pretty much the same
     $allowed = array('feeds.user.create');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     // For new feed items
     if ($comment->element == 'feeds.user.create') {
         // Get the RSS feed
         $feed = $this->getTable('Feed');
         $feed->load($comment->uid);
         // Get the stream since we want to link it to the stream
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         // Get the actor of the likes
         $actor = FD::user($comment->created_by);
         // Get the owner of the item
         $owner = FD::user($feed->user_id);
         // Set the email options
         $emailOptions = array('title' => 'APP_USER_FEEDS_EMAILS_COMMENT_RSS_FEED_ITEM_SUBJECT', 'template' => 'apps/user/feeds/comment.feed.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'target' => $owner->getName(), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'context_ids' => $stream->id, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner of the photo first
         if ($feed->user_id != $comment->created_by) {
             FD::notify('comments.item', array($feed->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, 'feeds', 'user', 'create', array(), array($feed->user_id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_FEEDS_EMAILS_COMMENT_RSS_FEED_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/feeds/comment.feed.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
 }
Ejemplo n.º 8
0
 /**
  * Shorthand function to send notification for various actions.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.2
  * @access private
  * @param  string    $verb   The action string.
  * @param  integer   $actor  The acting user id.
  * @param  integer   $target The targeted user id.
  */
 private function notify($verb, $actor, $target)
 {
     $actor = FD::user($actor);
     $target = FD::user($target);
     $emailOptions = array('title' => 'PLG_FIELDS_RELATIONSHIP_EMAIL_TITLE_' . strtoupper($verb), 'template' => 'fields/user/relationship/' . $verb, 'actor' => $actor->getName(), 'posterName' => $actor->getName(), 'posterAvatar' => $actor->getAvatar(), 'posterLink' => $actor->getPermalink(true, true), 'recipientName' => $target->getName(), 'type' => $this->type, 'link' => FRoute::profile(array('layout' => 'edit', 'external' => true), true));
     $systemOptions = array('uid' => $this->id, 'actor_id' => $actor->id, 'type' => 'relationship', 'title' => 'APP_USER_RELATIONSHIP_NOTIFICATION_TITLE_' . strtoupper($verb), 'url' => FRoute::profile(array('layout' => 'edit', 'sef' => false)), 'image' => $actor->getAvatar(SOCIAL_AVATAR_LARGE), 'context_type' => 'apps.user.relationship.' . $verb);
     // relationship.request
     // relationship.approve
     // relationship.reject
     FD::notify('relationship.' . $verb, array($target->id), $emailOptions, $systemOptions);
 }
Ejemplo n.º 9
0
 /**
  * Responsible to send notification to the user when they achieved a badge
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function sendNotification(SocialTableBadge $badge, $userId)
 {
     // Load the language file from the front end too since badge titles are loaded from the back end language
     FD::language()->loadAdmin();
     // We need the language file from the front end
     FD::language()->loadSite();
     // We want to send a notification to the user who earned the badge
     $recipient = array($userId);
     // Add notification to the requester that the user accepted his friend request.
     $systemOptions = array('uid' => $badge->id, 'type' => SOCIAL_TYPE_BADGES, 'url' => FRoute::badges(array('id' => $badge->getAlias(), 'layout' => 'item', 'sef' => false)), 'image' => $badge->getAvatar());
     $params = array('badgeTitle' => $badge->get('title'), 'badgePermalink' => $badge->getPermalink(false, true), 'badgeAvatar' => $badge->getAvatar(), 'badgeDescription' => $badge->get('description'));
     // Email template
     $emailOptions = array('title' => 'COM_EASYSOCIAL_EMAILS_UNLOCKED_NEW_BADGE_SUBJECT', 'badge' => $badge->get('title'), 'template' => 'site/badges/unlocked', 'params' => $params);
     // Send notifications to the receivers when they unlock the badge
     FD::notify('badges.unlocked', $recipient, $emailOptions, $systemOptions);
 }
Ejemplo n.º 10
0
 /**
  * Invites a user to the event and does the appropriate follow actions.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3
  * @access public
  * @param  integer    $target The invited user id.
  * @param  integer    $actor  The actor user id.
  * @return boolean            True if successful.
  */
 public function invite($target, $actor = null)
 {
     $actor = FD::user($actor);
     $target = FD::user($target);
     $guest = FD::table('EventGuest');
     $guest->cluster_id = $this->id;
     $guest->uid = $target->id;
     $guest->type = SOCIAL_TYPE_USER;
     $guest->state = SOCIAL_EVENT_GUEST_INVITED;
     $guest->invited_by = $actor->id;
     $guest->store();
     FD::points()->assign('events.guest.invite', 'com_easysocial', $actor->id);
     $emailOptions = (object) array('title' => 'COM_EASYSOCIAL_EMAILS_EVENT_GUEST_INVITED_SUBJECT', 'template' => 'site/event/guest.invited', 'event' => $this->getName(), 'eventName' => $this->getName(), 'eventAvatar' => $this->getAvatar(), 'eventLink' => $this->getPermalink(false, true), 'invitorName' => $actor->getName(), 'invitorLink' => $actor->getPermalink(false, true), 'invitorAvatar' => $actor->getAvatar());
     $systemOptions = (object) array('uid' => $this->id, 'actor_id' => $actor->id, 'target_id' => $target->id, 'context_type' => 'events', 'type' => 'events', 'url' => $this->getPermalink(true, false, 'item', false), 'eventId' => $this->id);
     FD::notify('events.guest.invited', array($target->id), $emailOptions, $systemOptions);
     return true;
 }
Ejemplo n.º 11
0
 /**
  * Allows caller to make a friend request from source to target
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function request($sourceId, $targetId, $state = SOCIAL_FRIENDS_STATE_PENDING)
 {
     // Do not allow user to create a friend request to himself
     if ($sourceId == $targetId) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_UNABLE_TO_ADD_YOURSELF'));
         return false;
     }
     // If they are already friends, ignore this.
     if ($this->isFriends($sourceId, $targetId)) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_ERROR_ALREADY_FRIENDS'));
         return false;
     }
     // Check if user has already previously requested this.
     if ($this->isFriends($sourceId, $targetId, SOCIAL_FRIENDS_STATE_PENDING)) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_ERROR_ALREADY_REQUESTED'));
         return false;
     }
     // If everything is okay, we proceed to add this request to the friend table.
     $table = FD::table('Friend');
     $table->setActorId($sourceId);
     $table->setTargetId($targetId);
     $table->setState($state);
     // Save the request
     $state = $table->store();
     $my = FD::user($sourceId);
     $user = FD::user($targetId);
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$table, $my, $user);
     // @trigger: onFriendRequest
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onFriendRequest', $args);
     // Send notification to the target when a user requests to be his / her friend.
     $params = array('requesterId' => $my->id, 'requesterAvatar' => $my->getAvatar(SOCIAL_AVATAR_LARGE), 'requesterName' => $my->getName(), 'requesterLink' => $my->getPermalink(true, true), 'requestDate' => FD::date()->toMySQL(), 'totalFriends' => $my->getTotalFriends(), 'totalMutualFriends' => $my->getTotalMutualFriends($user->id));
     // Email template
     $emailOptions = array('actor' => $my->getName(), 'title' => 'COM_EASYSOCIAL_EMAILS_FRIENDS_NEW_REQUEST_SUBJECT', 'template' => 'site/friends/request', 'params' => $params);
     FD::notify('friends.request', array($user->id), $emailOptions, false);
     // @badge: friends.create
     // Assign badge for the person that initiated the friend request.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'friends.create', $my->id, JText::_('COM_EASYSOCIAL_FRIENDS_BADGE_REQUEST_TO_BE_FRIEND'));
     return $table;
 }
Ejemplo n.º 12
0
 /**
  * Processes notifications
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterLikeSave($likes)
 {
     $allowed = array('notes.user.create', 'notes.user.update');
     if (!in_array($likes->type, $allowed)) {
         return;
     }
     // Get the verb
     $segments = explode('.', $likes->type);
     $verb = $segments[2];
     // Get the note object
     $note = $this->getTable('Note');
     $note->load($likes->uid);
     $emailOptions = array('title' => JText::_('APP_USER_NOTES_EMAILS_LIKE_ITEM_TITLE'), 'template' => 'apps/user/notes/like.item', 'permalink' => $note->getPermalink(true, true));
     $systemOptions = array('title' => '', 'context_type' => $likes->type, 'url' => $note->getPermalink(false, false, false), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     // Notify the owner first if the liker is not the note owner
     if ($likes->created_by != $note->user_id) {
         FD::notify('likes.item', array($note->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($likes->uid, 'notes', 'user', $verb, array(), array($note->user_id, $likes->created_by));
     $emailOptions['title'] = 'APP_USER_NOTES_EMAILS_LIKE_INVOLVED_TITLE';
     $emailOptions['template'] = 'apps/user/notes/like.involved';
     // Notify other participating users
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 13
0
 /**
  * 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);
     }
 }
Ejemplo n.º 14
0
 public function onAfterLikeSave($likes)
 {
     $segments = explode('.', $likes->type);
     if (count($segments) !== 3 || $segments[1] !== SOCIAL_TYPE_EVENT) {
         return;
     }
     list($element, $group, $verb) = explode('.', $likes->type);
     if ($element !== 'events') {
         return;
     }
     // Get the actor
     $actor = FD::user($likes->created_by);
     // Verbs
     // feature
     // create
     // update
     $event = FD::event($likes->uid);
     $stream = FD::table('Stream');
     $stream->load($likes->stream_id);
     $owner = FD::user($stream->actor_id);
     // APP_USER_EVENTS_EMAILS_FEATURE_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_EMAILS_CREATE_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_EMAILS_UPDATE_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_EMAILS_FEATURE_LIKE_INVOLVED_SUBJECT
     // APP_USER_EVENTS_EMAILS_CREATE_LIKE_INVOLVED_SUBJECT
     // APP_USER_EVENTS_EMAILS_UPDATE_LIKE_INVOLVED_SUBJECT
     // apps/user/events/feature.like.item
     // apps/user/events/create.like.item
     // apps/user/events/update.like.item
     // apps/user/events/feature.like.involved
     // apps/user/events/create.like.involved
     // apps/user/events/update.like.involved
     $emailOptions = array('title' => 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_LIKE_ITEM_SUBJECT', 'template' => 'apps/user/events/' . $verb . '.like.item', 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
     $systemOptions = array('context_type' => $likes->type, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'sef' => false)), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     // Notify the owner first
     if ($likes->created_by != $owner->id) {
         FD::notify('likes.item', array($owner->id), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item
     // We exclude the guest and the actor of the like here
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     $emailOptions['title'] = 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_LIKE_INVOLVED_SUBJECT';
     $emailOptions['template'] = 'apps/user/events/' . $verb . '.like.involved';
     // Notify other participating users
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 15
0
 public function promoteMembers()
 {
     FD::checkToken();
     $view = $this->getCurrentView();
     $groupid = JRequest::getInt('id');
     $cids = JRequest::getVar('cid');
     if (empty($cids)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_PROMOTE_MEMBERS_FAILED'), SOCIAL_MSG_ERROR);
         $view->call(__FUNCTION__);
     }
     FD::language()->loadSite();
     $my = FD::user();
     $group = FD::group($groupid);
     $user = FD::table('GroupMember');
     $user->load(array('cluster_id' => $group->id, 'uid' => $my->id, 'type' => SOCIAL_TYPE_USER));
     if (!$my->isSiteAdmin() && !$user->isAdmin() && !$user->isOwner()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_PROMOTE_MEMBERS_FAILED'), SOCIAL_MSG_ERROR);
         $view->call(__FUNCTION__);
     }
     $count = 0;
     foreach ($cids as $id) {
         $member = FD::table('GroupMember');
         $member->load($id);
         $member->makeAdmin();
         $group->createStream($member->uid, 'makeadmin');
         // Notify the person that they are now a group admin
         $emailOptions = array('title' => 'COM_EASYSOCIAL_GROUPS_EMAILS_PROMOTED_AS_GROUP_ADMIN_SUBJECT', 'template' => 'site/group/promoted', 'permalink' => $group->getPermalink(true, true), 'actor' => $my->getName(), 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $my->getPermalink(true, true), 'group' => $group->getName(), 'groupLink' => $group->getPermalink(true, true));
         $systemOptions = array('context_type' => 'groups.group.promoted', 'url' => $group->getPermalink(false, false, 'item', false), 'actor_id' => $my->id, 'uid' => $group->id);
         // Notify the owner first
         FD::notify('groups.promoted', array($member->uid), $emailOptions, $systemOptions);
         $count++;
     }
     if ($count > 0) {
         $view->setMessage(JText::sprintf('COM_EASYSOCIAL_GROUPS_PROMOTE_MEMBERS_SUCCESS', $count), SOCIAL_MSG_SUCCESS);
     }
     $view->call(__FUNCTION__);
 }
Ejemplo n.º 16
0
 /**
  * Processes notifications when a comment is stored on the site
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     // We need to split it because the type now stores as badges.user.unlocked.[9999]
     $namespace = explode('.', $comment->element);
     array_shift($namespace);
     $context = implode('.', $namespace);
     if (count($namespace) < 4 || $context != 'badges.user.unlocked') {
         return;
     }
     list($element, $group, $verb, $owner) = $namespace;
     // Get the permalink of the achievement item which is the stream item
     $streamItem = FD::table('StreamItem');
     $state = $streamItem->load(array('context_type' => $element, 'verb' => $verb, 'actor_id' => $owner, 'actor_type' => $group));
     if (!$state) {
         return;
     }
     $emailOptions = array('title' => 'APP_USER_BADGES_EMAILS_COMMENT_ITEM_TITLE', 'template' => 'apps/user/badges/comment.item', 'permalink' => $streamItem->getPermalink(true, true));
     $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $streamItem->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
     if ($comment->created_by != $owner) {
         FD::notify('comments.item', array($owner), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item.
     $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb . '.' . $owner, array(), array($owner, $comment->created_by));
     $emailOptions['title'] = 'APP_USER_BADGES_EMAILS_COMMENT_INVOLVED_TITLE';
     $emailOptions['template'] = 'apps/user/badges/comment.involved';
     FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 17
0
 /**
  * Processes a saved story so that we can notify users who are tagged in the system
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterStorySave(&$stream, $streamItem, $streamTemplate)
 {
     // If there's no "with" data, skip this.
     if (!$streamTemplate->with) {
         return;
     }
     // Get list of users that are tagged in this post.
     $taggedUsers = $streamTemplate->with;
     // Get the creator of this update
     $poster = FD::user($streamTemplate->actor_id);
     // Get the content of the stream item.
     $content = $streamTemplate->content;
     if (!$taggedUsers) {
         return;
     }
     foreach ($taggedUsers as $id) {
         $taggedUser = FD::user($id);
         // Set the email options
         $emailOptions = array('title' => 'APP_USER_FRIENDS_EMAILS_USER_TAGGED_YOU_IN_POST_SUBJECT', 'template' => 'apps/user/friends/post.tagged', 'permalink' => $streamItem->getPermalink(true, true), 'actor' => $poster->getName(), 'actorAvatar' => $poster->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $poster->getPermalink(true, true), 'message' => $content);
         $systemOptions = array('uid' => $streamItem->id, 'context_type' => 'tagged', 'type' => 'stream', 'url' => $streamItem->getPermalink(false, false, false), 'actor_id' => $poster->id, 'aggregate' => false);
         // Add new notification item
         FD::notify('stream.tagged', array($taggedUser->id), $emailOptions, $systemOptions);
     }
     return true;
 }
Ejemplo n.º 18
0
 /**
  * event onLiked on shared link
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onAfterLikeSave(&$likes)
 {
     $allowed = array('groups.user.create', 'groups.user.join', 'groups.user.leave', 'groups.user.makeadmin', 'groups.user.update');
     if (!in_array($likes->type, $allowed)) {
         return;
     }
     $stream = FD::table('Stream');
     $stream->load($likes->uid);
     // Get a list of recipients from the stream
     $recipients = $this->getStreamNotificationTargets($likes->uid, 'userprofile', 'user', 'update', array($stream->actor_id), array($likes->created_by));
     // Prepare the command
     $command = 'likes.item';
     $systemOptions = array('title' => '', 'context_type' => $likes->type, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $likes->created_by, 'uid' => $likes->uid);
     FD::notify($command, $recipients, false, $systemOptions);
 }
Ejemplo n.º 19
0
 /**
  * We need to notify group members when someone posts a new story in the group
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function onAfterStorySave(SocialStream &$stream, SocialTableStreamItem &$streamItem, SocialStreamTemplate &$template)
 {
     // Determine if this is for a group
     if (!$template->cluster_id) {
         return;
     }
     // Now we only want to allow specific context
     $context = $template->context_type . '.' . $template->verb;
     $allowed = array('story.create', 'links.create', 'photos.share');
     if (!in_array($context, $allowed)) {
         return;
     }
     // When a user posts a new story in a group, we need to notify the group members
     $group = FD::group($template->cluster_id);
     // Get the actor
     $actor = FD::user($streamItem->actor_id);
     // Get a list of group members
     $model = FD::model('Groups');
     $targets = $model->getMembers($group->id, array('exclude' => $actor->id, 'state' => SOCIAL_STATE_PUBLISHED));
     // If there's nothing to send skip this altogether.
     if (!$targets) {
         return;
     }
     // Get the item's permalink
     $permalink = FRoute::stream(array('id' => $streamItem->uid, 'layout' => 'item', 'external' => true), true);
     // Prepare the email params
     $mailParams = array();
     $mailParams['actor'] = $actor->getName();
     $mailParams['posterAvatar'] = $actor->getAvatar(SOCIAL_AVATAR_SQUARE);
     $mailParams['posterLink'] = $actor->getPermalink(true, true);
     $mailParams['message'] = $template->content;
     $mailParams['group'] = $group->getName();
     $mailParams['groupLink'] = $group->getPermalink(true, true);
     $mailParams['permalink'] = FRoute::stream(array('id' => $streamItem->uid, 'layout' => 'item', 'external' => true), true);
     $mailParams['title'] = 'APP_GROUP_STORY_EMAILS_NEW_POST_IN_GROUP';
     $mailParams['template'] = 'apps/group/story/new.post';
     // Prepare the system notification params
     $systemParams = array();
     $systemParams['context_type'] = $template->context_type . '.group.' . $template->verb;
     $systemParams['url'] = FRoute::stream(array('id' => $streamItem->uid, 'layout' => 'item', 'sef' => false));
     $systemParams['actor_id'] = $actor->id;
     $systemParams['uid'] = $streamItem->uid;
     $systemParams['context_ids'] = $group->id;
     $systemParams['content'] = $template->content;
     // Try to send the notification
     $state = FD::notify('groups.updates', $targets, $mailParams, $systemParams);
 }
Ejemplo n.º 20
0
 public function onAfterCommentSave($comment)
 {
     $segments = explode('.', $comment->element);
     if (count($segments) !== 3 || $segments[1] !== SOCIAL_TYPE_EVENT) {
         return;
     }
     list($element, $group, $verb) = explode('.', $comment->element);
     // Get the actor
     $actor = FD::user($comment->created_by);
     if ($element === 'events') {
         $event = FD::event($comment->uid);
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         $owner = FD::user($stream->actor_id);
         // APP_USER_EVENTS_EMAILS_FEATURE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_CREATE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_UPDATE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_FEATURE_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_EMAILS_CREATE_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_EMAILS_UPDATE_COMMENT_INVOLVED_SUBJECT
         // apps/user/events/feature.comment.item
         // apps/user/events/create.comment.item
         // apps/user/events/update.comment.item
         // apps/user/events/feature.comment.involved
         // apps/user/events/create.comment.involved
         // apps/user/events/update.comment.involved
         $emailOptions = array('title' => 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/user/events/' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/events/' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'guests') {
         $guest = FD::table('EventGuest');
         $guest->load($comment->uid);
         $event = FD::event($guest->cluster_id);
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         $owner = FD::user($stream->actor_id);
         // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_INVOLVED_SUBJECT
         // apps/user/events/guest.makeadmin.comment.item
         // apps/user/events/guest.going.comment.item
         // apps/user/events/guest.notgoing.comment.item
         // apps/user/events/guest.makeadmin.comment.involved
         // apps/user/events/guest.going.comment.involved
         // apps/user/events/guest.notgoing.comment.involved
         $emailOptions = array('title' => 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/user/events/guest.' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/events/guest.' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'discussions') {
         // Uses app/event/discussions onAfterCommentSave logic and language strings since it is the same
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         // Get the discussion object since it's tied to the stream
         $discussion = FD::table('Discussion');
         $discussion->load($comment->uid);
         // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_ITEM_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_INVOLVED_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_ITEM_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_INVOLVED_SUBJECT
         // apps/event/discussions/create.comment.item
         // apps/event/discussions/create.comment.involved
         // apps/event/discussions/reply.comment.item
         // apps/event/discussions/reply.comment.involved
         $emailOptions = array('title' => 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/event/discussions/' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $discussion->created_by) {
             FD::notify('comments.item', array($discussion->created_by), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($discussion->created_by, $comment->created_by));
         $emailOptions['title'] = 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/event/discussions/' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'tasks') {
         // Uses app/event/tasks onAfterCommentSave logic and language strings since it is the same
         $identifier = $verb == 'createMilestone' ? 'milestone' : 'task';
         // Get the milestone/task table
         $table = FD::table($identifier);
         $table->load($comment->uid);
         // Get the owner
         $owner = FD::user($table->owner_id);
         // Get the event
         $event = FD::event($table->uid);
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_MILESTONE_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_TASK_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_MILESTONE_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_TASK_SUBJECT
         // apps/event/tasks/comment.milestone
         // apps/event/tasks/comment.task
         // apps/event/tasks/comment.milestone.involved
         // apps/event/tasks/comment.task.involved
         $emailOptions = array('title' => 'APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_' . strtoupper($identifier) . '_SUBJECT', 'template' => 'apps/event/tasks/comment.' . $identifier, 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $comment->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->element, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $comment->stream_id, 'sef' => false)), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($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($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_' . strtoupper($identifier) . '_SUBJECT';
         $emailOptions['template'] = 'apps/event/tasks/comment.' . $identifier . '.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
 }
Ejemplo n.º 21
0
 /**
  * Triggered when a comment save occurs
  *
  * @since   1.0
  * @access  public
  * @param   SocialTableComments    The comment object
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     $allowed = array('photos.event.upload', 'albums.event.create', 'stream.event.upload', 'photos.event.add', 'photos.event.uploadAvatar', 'photos.event.updateCover');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     // For likes on albums when user uploads multiple photos within an album
     if ($comment->element == 'albums.event.create') {
         // Since the uid is tied to the album we can get the album object
         $album = FD::table('Album');
         $album->load($comment->uid);
         // Get the actor of the likes
         $actor = FD::user($comment->created_by);
         // Set the email options
         $emailOptions = array('title' => 'APP_EVENT_PHOTOS_EMAILS_COMMENT_ALBUM_ITEM_SUBJECT', 'template' => 'apps/event/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) {
             FD::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', 'event', 'create', array(), array($album->user_id, $comment->created_by));
         $emailOptions['title'] = 'APP_EVENT_PHOTOS_EMAILS_COMMENT_ALBUM_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/event/photos/comment.album.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
     // For comments made on photos
     $allowed = array('photos.event.upload', 'stream.event.upload', 'photos.event.add', 'photos.event.uploadAvatar', 'photos.event.updateCover');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     // Get the actor of the likes
     $actor = FD::user($comment->created_by);
     // Set the email options
     $emailOptions = array('template' => 'apps/event/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_EVENT_PHOTOS_EMAILS_COMMENT_PHOTO_ITEM_SUBJECT';
     $involvedTitle = 'APP_EVENT_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.event.upload') {
         // Since this item is tied to the stream, we need to load the stream object
         $stream = FD::table('Stream');
         $stream->load($comment->uid);
         // Get the photo object from the context id of the stream
         $model = FD::model('Stream');
         $origin = $model->getContextItem($comment->uid);
         $photo = FD::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.event.upload' || $comment->element == 'photos.event.add' || $comment->element == 'photos.event.uploadAvatar' || $comment->element == 'photos.event.updateCover') {
         // Get the photo object
         $photo = FD::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.event.uploadAvatar') {
         $verb = 'uploadAvatar';
         $ownerTitle = 'APP_EVENT_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_ITEM_SUBJECT';
         $involvedTitle = 'APP_EVENT_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_INVOLVED_SUBJECT';
     }
     if ($comment->element == 'photos.event.updateCover') {
         $verb = 'updateCover';
         $ownerTitle = 'APP_EVENT_PHOTOS_EMAILS_COMMENT_PROFILE_COVER_ITEM_SUBJECT';
         $involvedTitle = 'APP_EVENT_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) {
         FD::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, 'event', $verb, $additionalRecipients, array($photo->user_id, $comment->created_by));
     $emailOptions['title'] = $involvedTitle;
     $emailOptions['template'] = 'apps/event/photos/comment.photo.involved';
     // Notify other participating users
     FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     return;
 }
Ejemplo n.º 22
0
 /**
  * Adds a user into an existing conversation.
  *
  * @since	1.0
  * @access	public
  */
 public function addParticipant()
 {
     // Check for request forgeries.
     FD::checkToken();
     // We know for the fact that guests can never access conversations.
     FD::requireLogin();
     // Get the conversation id.
     $id = JRequest::getInt('id');
     // Load the current conversation
     $conversation = FD::table('Conversation');
     $state = $conversation->load($id);
     // Get current logged in user.
     $my = FD::user();
     // Get current view
     $view = $this->getCurrentView();
     // Get config
     $config = FD::config();
     // Check if multiple conversations is enabled
     if (!$config->get('conversations.multiple')) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_GROUP_CONVERSATIONS_DISABLED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $conversation);
     }
     // Check that there are recipients.
     if (!$state || !$id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_INVALID_CONVERSATION_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $conversation);
     }
     // Check if the user is allowed to add people to the conversation
     if (!$conversation->isParticipant()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_NOT_ALLOWED_ACCESS_TO_CONVERSATION'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $conversation);
     }
     // Get the new recipients.
     $recipients = JRequest::getVar('uid');
     // Ensure that the recipients is in an array form.
     $recipients = FD::makeArray($recipients);
     // Check that there are recipients.
     if (!$recipients || empty($recipients)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_INVALID_RECIPIENTS_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $conversation);
     }
     // Get the current logged in user.
     $my = FD::user();
     // Let's go through the list of recipients and add them to the conversation.
     foreach ($recipients as &$id) {
         // Run cleanup on the node id to make sure that they are all typecasted to integer.
         $id = (int) $id;
         $state = $conversation->addParticipant($my->id, $id);
         if (!$state) {
             $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_ADDING_PARTICIPANT'), SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__, $conversation);
         }
     }
     // We need to update the conversation type to multiple
     $conversation->type = SOCIAL_CONVERSATION_MULTIPLE;
     $conversation->store();
     // Send notification email to recipients that got invited to the conversation
     foreach ($recipients as $recipientId) {
         $recipient = FD::user($recipientId);
         // Add new notification item
         $mailParams = FD::registry();
         $mailParams->set('actor', $my->getName());
         $mailParams->set('name', $recipient->getName());
         $mailParams->set('authorName', $my->getName());
         $mailParams->set('authorAvatar', $my->getAvatar());
         $mailParams->set('authorLink', $my->getPermalink(true, true));
         $mailParams->set('conversationLink', $conversation->getPermalink(true, true));
         $title = 'COM_EASYSOCIAL_EMAILS_YOU_ARE_INVITED_TO_A_CONVERSATION_SUBJECT';
         // Send a notification for all participants in this thread.
         $state = FD::notify('conversations.invite', array($recipientId), array('title' => $title, 'params' => $mailParams), false);
     }
     // // Now we need to send notification to existing participants
     // $participants 	= $conversation->getParticipants( array( $my->id ) );
     // if( $participants )
     // {
     // 	foreach( $participants as $participant )
     // 	{
     // 		// Add new notification item
     // 		$mailParams 	= FD::registry();
     // 		$mailParams->set( 'total'			, count( $recipients ) );
     // 		$mailParams->set('actor', $my->getName());
     // 		$mailParams->set( 'name'			, $participant->getName() );
     // 		$mailParams->set( 'authorName'		, $my->getName() );
     // 		$mailParams->set( 'authorAvatar'	, $my->getAvatar() );
     // 		$mailParams->set( 'authorLink'		, $my->getPermalink( true, true ) );
     // 		$mailParams->set( 'conversationLink', $conversation->getPermalink( true, true ) );
     // 		$title 	= 'COM_EASYSOCIAL_EMAILS_ACTOR_INVITED_USER_INTO_CONVERSATION_SUBJECT';
     // 		// Send a notification for all participants in this thread.
     // 		$state 	= FD::notify( 'conversations.invited' , false , array( 'title' => $title, 'params' => $mailParams ) );
     // 	}
     // }
     $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_MESSAGE_SENT'), SOCIAL_MSG_SUCCESS);
     // Set a success message.
     $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ADDED_RECIPIENTS'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $conversation);
 }
Ejemplo n.º 23
0
 /**
  * Notifies a user when someone posted something on their timeline
  *
  * @since	1.0
  * @access	public
  * @param	int				The target user id.
  * @param	SocialStream	The stream table
  * @return
  */
 public function notify($id, $stream, $content, $contextIds, $contextType, $notificationType)
 {
     $recipient = FD::user($id);
     $actor = FD::user($stream->actor_id);
     $systemOptions = array('uid' => $stream->id, 'content' => $content, 'actor_id' => $actor->id, 'target_id' => $recipient->id, 'context_ids' => FD::json()->encode($contextIds), 'context_type' => 'post.user.timeline', 'type' => $notificationType, 'url' => $stream->getPermalink(false, false, false));
     $emailOptions = array('title' => 'COM_EASYSOCIAL_EMAILS_USER_POSTED_ON_YOUR_TIMELINE_SUBJECT', 'template' => 'site/profile/post.story', 'params' => array('actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(), 'actorLink' => $actor->getPermalink(true, true), 'permalink' => $stream->getPermalink(false, true), 'content' => $content));
     $state = FD::notify('profile.story', array($recipient->id), $emailOptions, $systemOptions);
     return $state;
 }
Ejemplo n.º 24
0
 /**
  * Notify the owner of the stream
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function onAfterStreamSave(SocialStreamTemplate &$streamTemplate)
 {
     // We only want to process shares
     if ($streamTemplate->context_type != SOCIAL_TYPE_SHARE || !$streamTemplate->cluster_type) {
         return;
     }
     $allowed = array('add.stream');
     if (!in_array($streamTemplate->verb, $allowed)) {
         return;
     }
     // Because the verb is segmented with a ., we need to split this up
     $namespace = explode('.', $streamTemplate->verb);
     $verb = $namespace[0];
     $type = $namespace[1];
     // Add a notification to the owner of the stream
     $stream = FD::table('Stream');
     $stream->load($streamTemplate->target_id);
     // If the person that is reposting this is the same as the actor of the stream, skip this altogether.
     if ($streamTemplate->actor_id == $stream->actor_id) {
         return;
     }
     // Get the group
     $group = FD::group($streamTemplate->cluster_id);
     // Get the actor
     $actor = FD::user($streamTemplate->actor_id);
     // Get the share object
     $share = FD::table('Share');
     $share->load($streamTemplate->context_id);
     // Prepare the email params
     $mailParams = array();
     $mailParams['actor'] = $actor->getName();
     $mailParams['actorLink'] = $actor->getPermalink(true, true);
     $mailParams['actorAvatar'] = $actor->getAvatar(SOCIAL_AVATAR_SQUARE);
     $mailParams['group'] = $group->getName();
     $mailParams['groupLink'] = $group->getPermalink(true, true);
     $mailParams['permalink'] = FRoute::stream(array('layout' => 'item', 'id' => $share->uid, 'external' => true), true);
     $mailParams['title'] = 'APP_GROUP_SHARES_EMAILS_USER_REPOSTED_YOUR_POST_SUBJECT';
     $mailParams['template'] = 'apps/group/shares/stream.repost';
     // Prepare the system notification params
     $systemParams = array();
     $systemParams['context_type'] = $streamTemplate->verb;
     $systemParams['url'] = FRoute::stream(array('layout' => 'item', 'id' => $share->uid, 'sef' => false));
     $systemParams['actor_id'] = $actor->id;
     $systemParams['uid'] = $group->id;
     $systemParams['context_ids'] = $share->id;
     FD::notify('repost.item', array($stream->actor_id), $mailParams, $systemParams);
 }
Ejemplo n.º 25
0
 /**
  * Processes notifications when a comment is saved
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     $allowed = array('userprofile.user.update');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     $stream = FD::table('Stream');
     $state = $stream->load($comment->uid);
     if (!$state) {
         return;
     }
     $owner = $stream->actor_id;
     $emailOptions = array('title' => 'APPS_USER_PROFILES_EMAILS_COMMENT_ITEM_TITLE', 'template' => 'apps/user/profiles/comment.item', 'permalink' => $stream->getPermalink(true, true));
     $systemOptions = array('title' => '', 'context_type' => $comment->element, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
     if ($comment->created_by != $owner) {
         FD::notify('comments.item', array($owner), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item.
     $recipients = $this->getStreamNotificationTargets($comment->uid, 'userprofile', 'user', 'update', array(), array($owner, $comment->created_by));
     $emailOptions['title'] = 'APP_USER_PROFILES_EMAILS_COMMENT_INVOLVED_TITLE';
     $emailOptions['template'] = 'apps/user/profiles/comment.involved';
     FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 26
0
 /**
  * Processes when user comments on a file
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     $allowed = array('files.group.uploaded');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     if ($comment->element == 'files.group.uploaded') {
         // Get the stream object
         $stream = FD::table('Stream');
         $stream->load($comment->uid);
         $segments = explode('.', $comment->element);
         $element = $segments[0];
         $verb = $segments[2];
         // Load up the stream object
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         // Get the group object
         $group = FD::group($stream->cluster_id);
         // Get the comment actor
         $actor = FD::user($comment->created_by);
         $emailOptions = array('title' => 'APP_GROUP_FILES_EMAILS_COMMENT_ITEM_SUBJECT', 'template' => 'apps/group/files/comment.file.item', 'comment' => $comment->comment, 'group' => $group->getName(), 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
         $systemOptions = array('content' => $comment->comment, 'context_type' => $comment->element, 'context_ids' => $stream->cluster_id, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the note owner
         if ($comment->created_by != $stream->actor_id) {
             FD::notify('comments.item', array($stream->actor_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, $element, 'group', $verb, array(), array($stream->actor_id, $comment->created_by));
         $emailOptions['title'] = 'APP_GROUP_FILES_EMAILS_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/group/files/comment.file.involved';
         // Notify participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
 }
Ejemplo n.º 27
0
 public function onAfterCommentSave($comment)
 {
     $segments = explode('.', $comment->element);
     if (count($segments) !== 3 || $segments[1] !== SOCIAL_TYPE_EVENT) {
         return;
     }
     list($element, $group, $verb) = explode('.', $comment->element);
     if ($element !== 'guests') {
         return;
     }
     // Get the actor
     $actor = FD::user($comment->created_by);
     $guest = FD::table('EventGuest');
     $guest->load($comment->uid);
     $event = FD::event($guest->cluster_id);
     $stream = FD::table('Stream');
     $stream->load($comment->stream_id);
     $owner = FD::user($stream->actor_id);
     // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_INVOLVED_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_INVOLVED_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_INVOLVED_SUBJECT
     // apps/user/events/guest.makeadmin.comment.item
     // apps/user/events/guest.going.comment.item
     // apps/user/events/guest.notgoing.comment.item
     // apps/user/events/guest.makeadmin.comment.involved
     // apps/user/events/guest.going.comment.involved
     // apps/user/events/guest.notgoing.comment.involved
     $emailOptions = array('title' => 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/user/events/guest.' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
     $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
     // Notify the owner first
     if ($comment->created_by != $owner->id) {
         FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item
     // We exclude the owner of the discussion and the actor of the comment here
     $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
     $emailOptions['title'] = 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
     $emailOptions['template'] = 'apps/user/events/guest.' . $verb . '.comment.involved';
     // Notify other participating users
     FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 28
0
 public function onAfterLikeSave($like)
 {
     $allowed = array('k2.user.create', 'k2.user.update', 'k2.user.read');
     if (!in_array($like->type, $allowed)) {
         return;
     }
     $segments = $like->type;
     list($element, $group, $verb) = explode('.', $segments);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $likes->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     $emailOptions = array('title' => 'APP_USER_K2_EMAILS_LIKE_ITEM_TITLE', 'template' => 'apps/user/k2/like.item', 'permalink' => $streamItem->getPermalink(true, true));
     $systemOptions = array('title' => '', 'context_type' => $likes->type, 'url' => $streamItem->getPermalink(false, false, false), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     if ($likes->created_by != $owner) {
         FD::notify('likes.item', array($owner), $emailOptions, $systemOptions);
     }
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner, $likes->created_by));
     $emailOptions['title'] = 'APP_USER_K2_EMAILS_LIKE_INVOLVED_TITLE';
     $emailOptions['template'] = 'apps/user/k2/like.involved';
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 29
0
 public function onAfterCommentSave($comment)
 {
     $allowed = array('discussions.event.create', 'discussions.event.reply');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     $stream = FD::table('Stream');
     $stream->load($comment->stream_id);
     $streamItems = $stream->getItems();
     // Since we have the stream, we can get the event id
     $event = FD::event($stream->cluster_id);
     // Get the actor
     $actor = FD::user($comment->created_by);
     // Get the discussion object since it's tied to the stream
     $discussion = FD::table('Discussion');
     $discussion->load($streamItems[0]->context_id);
     list($element, $group, $verb) = explode('.', $comment->element);
     // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_ITEM_SUBJECT
     // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_INVOLVED_SUBJECT
     // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_ITEM_SUBJECT
     // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_INVOLVED_SUBJECT
     // apps/event/discussions/create.comment.item
     // apps/event/discussions/create.comment.involved
     // apps/event/discussions/reply.comment.item
     // apps/event/discussions/reply.comment.involved
     $emailOptions = array('title' => 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/event/discussions/' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'event' => $event->getName(), 'comment' => $comment->comment);
     $systemOptions = array('context_type' => $comment->element, 'context_ids' => $discussion->id, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
     // Notify the owner first
     if ($comment->created_by != $discussion->created_by) {
         FD::notify('comments.item', array($discussion->created_by), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item
     // We exclude the owner of the discussion and the actor of the comment here
     $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($discussion->created_by, $comment->created_by));
     $emailOptions['title'] = 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
     $emailOptions['template'] = 'apps/event/discussions/' . $verb . '.comment.involved';
     // Notify other participating users
     FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
 }
Ejemplo n.º 30
0
 /**
  * Make a user an admin of a group
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function makeAdmin()
 {
     // Check for request forgeries
     FD::checkToken();
     // Require the user to be logged in
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     // Get the current user
     $my = FD::user();
     // Get the group
     $id = JRequest::getInt('id');
     $group = FD::group($id);
     if (!$group->isOwner() && !$group->isAdmin() && !$my->isSiteAdmin()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NO_ACCESS'));
         return $view->call(__FUNCTION__);
     }
     // Get the target user
     $userId = JRequest::getInt('userId');
     $member = FD::table('GroupMember');
     $member->load(array('uid' => $userId, 'cluster_id' => $group->id));
     // Make the user as the admin
     $member->makeAdmin();
     // Create a stream for this
     $group->createStream($userId, 'makeadmin');
     $permalink = $group->getPermalink(false, true);
     // Notify the person that they are now a group admin
     $emailOptions = array('title' => 'COM_EASYSOCIAL_GROUPS_EMAILS_PROMOTED_AS_GROUP_ADMIN_SUBJECT', 'template' => 'site/group/promoted', 'permalink' => $group->getPermalink(true, true), 'actor' => $my->getName(), 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $my->getPermalink(true, true), 'group' => $group->getName(), 'groupLink' => $group->getPermalink(true, true));
     $systemOptions = array('context_type' => 'groups.group.promoted', 'url' => $group->getPermalink(false, false, false), 'actor_id' => $my->id, 'uid' => $group->id);
     // Notify the owner first
     $state = FD::notify('groups.promoted', array($userId), $emailOptions, $systemOptions);
     return $view->call(__FUNCTION__);
 }