/**
  *
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function execute($item)
 {
     // Get the owner of the stream item since we need to notify the person
     $stream = FD::table('Stream');
     $stream->load($item->uid);
     // Get comment participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : 'SINGULAR';
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_PROFILES_USER_LIKES_YOUR_PROFILE_UPDATES' . $plurality, $names);
         return $item;
     }
     if ($stream->actor_id == $item->actor_id && count($users)) {
         $item->title = JText::sprintf('APP_USER_PROFILES_OWNER_LIKES_PROFILE_UPDATE' . FD::user($stream->actor_id)->getGenderLang(), $names);
     }
     // This is for 3rd party viewers
     $item->title = JText::sprintf('APP_USER_PROFILES_USER_LIKES_USER_PROFILE_UPDATES' . $plurality, $names, FD::user($stream->actor_id)->getName());
     return $item;
 }
 public function execute($item)
 {
     // Get comment participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     list($element, $group, $verb) = explode('.', $item->context_type);
     $event = FD::event($item->uid);
     $owner = FD::user($item->getParams()->get('owner_id'));
     // Verbs
     // makeadmin
     // going
     // notgoing
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_NOTGOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_NOTGOING_PLURAL
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner->id) {
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_' . strtoupper($verb), count($users)), $names);
         return $item;
     }
     $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_' . strtoupper($verb), count($users)), $names, $owner->getName());
     return $item;
 }
 /**
  *
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function execute($item)
 {
     // Get the badge
     $badge = FD::table('Badge');
     $badge->load($item->uid);
     // Break the namespace
     list($element, $group, $verb, $owner) = explode('.', $item->context_type);
     // Get the permalink of the achievement item which is the stream item
     $streamItem = FD::table('StreamItem');
     $streamItem->load(array('context_type' => $element, 'verb' => $verb, 'actor_type' => $group, 'actor_id' => $owner));
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // Get the badge image
     $item->image = $badge->getAvatar();
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($owner == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_BADGES_USER_COMMENTED_ON_YOUR_ACHIEVEMENT' . $plurality, $names, $badge->get('title'));
         return $item;
     }
     if ($owner == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_BADGES_OWNER_COMMENTED_ON_ACHIEVEMENT' . FD::user($owner)->getGenderLang(), $names, $badge->get('title'));
         return $item;
     }
     // This is for 3rd party viewers
     $item->title = JText::sprintf('APP_USER_BADGES_USER_COMMENTED_ON_USERS_ACHIEVEMENT' . $plurality, $names, FD::user($stream->actor_id)->getName(), $badge->get('title'));
     return $item;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a event
     if ($item->context_type == 'news.event.create') {
         // We do not want to display any content if the person likes a event announcement
         $item->content = '';
         // Get the news object
         $news = FD::table('EventNews');
         $news->load($item->uid);
         // Get the event from the stream
         $event = FD::event($news->cluster_id);
         // Set the content
         if ($event) {
             $item->image = $event->getAvatar();
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($news->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_EVENT_NEWS_USER_LIKES_YOUR_ANNOUNCEMENT', count($users));
             $item->title = JText::sprintf($langString, $names, $event->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_EVENT_NEWS_USER_LIKES_USER_ANNOUNCEMENT', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($news->created_by)->getName(), $event->getName());
         return;
     }
     return;
 }
 public function execute($item)
 {
     $contexts = explode('.', $item->context_type);
     $streamItem = FD::table('StreamItem');
     $streamItem->load(array('context_id' => $item->uid, 'context_type' => $contexts[0], 'verb' => $contexts[2]));
     $stream = FD::table('Stream');
     $stream->load($streamItem->uid);
     // Get likes participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the notification actor
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_RELATIONSHIP_USER_COMMENTED_ON_YOUR_RELATIONSHIP_STATUS' . $plurality, $names);
         return $item;
     }
     if ($stream->actor_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_RELATIONSHIP_OWNER_COMMENTED_ON_RELATIONSHIP_STATUS' . FD::user($stream->actor_id)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_RELATIONSHIP_USER_COMMENTED_ON_USER_RELATIONSHIP_STATUS' . $plurality, $names, FD::user($stream->actor_id)->getName());
     return $item;
 }
 public function execute($item)
 {
     $model = FD::model('comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     $content = '';
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     list($element, $group, $verb) = explode('.', $item->context_type);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_YOUR_ITEM' . $plurality, $names);
         return $item;
     }
     if ($item->actor_id == $owner && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_COMMENTED_ON_ITEM' . FD::user($owner)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
     return $item;
 }
 public function execute(&$item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a event
     if ($item->context_type == 'files.event.uploaded') {
         $file = FD::table('File');
         $file->load($item->uid);
         // Get the event
         $event = FD::event($file->uid);
         // Set the content
         if ($file->hasPreview()) {
             $item->image = $file->getPreviewURI();
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($file->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_FILES_USER_COMMENTED_ON_YOUR_FILE', count($users)), $names);
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_FILES_USER_COMMENTED_ON_USERS_FILE', count($users)), $names, FD::user($file->user_id)->getName());
         return;
     }
     return;
 }
 public function execute($item)
 {
     $model = FD::model('likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     list($element, $group, $verb) = explode('.', $item->context_type);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_YOUR_ITEM' . $plurality, $names);
         return $item;
     }
     if ($item->actor_id == $owner && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_LIKES_ITEM' . FD::user($owner)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
     return $item;
 }
 public function execute($item, $calendar)
 {
     $model = FD::model('comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the notification actor
     $users[] = $item->actor_id;
     // Exclude the current user
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     $content = '';
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     if ($calendar->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_YOUR_EVENT' . $plurality, $names);
         return $item;
     }
     if ($calendar->user_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_OWNER_COMMENTED_ON_EVENT' . FD::user($calendar->user_id)->getGendarLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_USER_EVENT' . $plurality, $names, FD::user($calendar->user_id)->getName());
     return $item;
 }
Example #10
0
 public function formatContent($content)
 {
     if (empty($this->item->tags)) {
         return $content;
     }
     $content = FD::string()->processTags($this->item->tags, $content);
     return $content;
 }
Example #11
0
 /**
  * Alias to JText::_
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return	
  */
 public static function _($string, $escape = false)
 {
     $string = JText::_($string);
     if ($escape) {
         $string = FD::string()->escape($string);
     }
     return $string;
 }
Example #12
0
 /**
  * Sends a new share to a user.
  *
  * @since	1.0
  * @access	public
  */
 public function send()
 {
     FD::checkToken();
     $token = JRequest::getString('token', '');
     $recipients = JRequest::getVar('recipients', array());
     $content = JRequest::getVar('content', '');
     // Get the current view.
     $view = $this->getCurrentView();
     // Cleaning
     if (is_string($recipients)) {
         $recipients = explode(',', FD::string()->escape($recipients));
     }
     if (is_array($recipients)) {
         foreach ($recipients as &$recipient) {
             $recipient = FD::string()->escape($recipient);
             if (!JMailHelper::isEmailAddress($recipient)) {
                 return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_RECIPIENT'));
             }
         }
     }
     $content = FD::string()->escape($content);
     // Check for valid data
     if (empty($recipients)) {
         return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_NO_RECIPIENTS'));
     }
     if (empty($token)) {
         return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_TOKEN'));
     }
     $session = JFactory::getSession();
     $config = FD::config();
     $limit = $config->get('sharing.email.limit', 0);
     $now = FD::date()->toUnix();
     $time = $session->get('easysocial.sharing.email.time');
     $count = $session->get('easysocial.sharing.email.count');
     if (is_null($time)) {
         $session->set('easysocial.sharing.email.time', $now);
         $time = $now;
     }
     if (is_null($count)) {
         $session->set('easysocial.sharing.email.count', 0);
     }
     $diff = $now - $time;
     if ($diff <= 3600) {
         if ($limit > 0 && $count >= $limit) {
             return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_SHARING_LIMIT_MAXED'));
         }
         $count++;
         $session->set('easysocial.sharing.email.count', $count);
     } else {
         $session->set('easysocial.sharing.email.time', $now);
         $session->set('easysocial.sharing.email.count', 1);
     }
     $library = FD::get('Sharing');
     $library->sendLink($recipients, $token, $content);
     $view->call(__FUNCTION__, true);
 }
Example #13
0
 /**
  * Formats the content of a note
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getContent()
 {
     // Apply e-mail replacements
     $content = FD::string()->replaceEmails($this->content);
     // Apply hyperlinks
     $content = FD::string()->replaceHyperlinks($content);
     // Apply bbcode
     $content = FD::string()->parseBBCode($content, array('code' => true, 'escape' => false));
     return $content;
 }
Example #14
0
 private function render($text)
 {
     $string = FD::string();
     if ($this->params->get('bbcode')) {
         // Don't allow html codes here
         $text = strip_tags($text);
         $text = $string->parseBBCode($text);
     } else {
         $text = $string->escape($text);
     }
     $this->set('text', $text);
     return $this->display();
 }
Example #15
0
 public function execute($item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // By default content is always empty;
     $content = '';
     // Only show the content when there is only 1 item
     if (count($users) == 1) {
         // Legacy fix for prior to 1.2 as there is no content stored.
         if (!empty($item->content)) {
             $content = JString::substr(strip_tags($item->content), 0, 30);
             if (JString::strlen($item->content) > 30) {
                 $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
             }
         }
     }
     $item->content = $content;
     list($element, $group, $verb) = explode('.', $item->context_type);
     if ($verb == 'createMilestone') {
         // Load the milestone
         $milestone = FD::table('Milestone');
         $milestone->load($item->uid);
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($milestone->owner_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_COMMENTED_ON_YOUR_MILESTONE', count($users)), $names);
             $item->content = $milestone->get('title');
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_COMMENTED_ON_USERS_MILESTONE', count($users)), $names, FD::user($milestone->owner_id)->getName());
         $item->content = $milestone->get('title');
     }
     if ($verb == 'createTask') {
         // Load the task
         $task = FD::table('Task');
         $task->load($item->uid);
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($task->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_COMMENTED_ON_YOUR_TASK', count($users)), $names);
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_COMMENTED_ON_USERS_TASK', count($users)), $names, FD::user($task->user_id)->getName());
     }
     return $item;
 }
 public function execute($item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // By default content is always empty;
     $content = '';
     // Only show the content when there is only 1 item
     if (count($users) == 1) {
         // Legacy fix for prior to 1.2 as there is no content stored.
         if (!empty($item->content)) {
             $content = JString::substr(strip_tags($item->content), 0, 30);
             if (JString::strlen($item->content) > 30) {
                 $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
             }
         }
     }
     list($element, $group, $verb) = explode('.', $item->context_type);
     $item->content = $content;
     $guest = FD::table('EventGuest');
     $guest->load($item->uid);
     $event = FD::event($guest->cluster_id);
     $owner = FD::user($item->getParams()->get('owner_id'));
     // Verbs
     // makeadmin
     // going
     // notgoing
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_NOTGOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_NOTGOING_PLURAL
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner->id) {
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_YOUR_UPDATE_' . strtoupper($verb), count($users)), $names);
         return $item;
     }
     $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_COMMENTED_ON_USERS_UPDATE_' . strtoupper($verb), count($users)), $names, $owner->getName());
     return $item;
 }
Example #17
0
 public function getTitle()
 {
     $actors = $this->item->actors;
     $names = FD::string()->namesToStream($actors);
     $sourceId = $this->share->uid;
     $photo = FD::table('Photo');
     $photo->load($sourceId);
     $photoCreator = FD::user($photo->uid);
     $theme = FD::get('Themes');
     $theme->set('names', $names);
     $theme->set('photo', $photo);
     $theme->set('creator', $photoCreator);
     $title = $theme->output('apps/event/shares/streams/photos/title');
     return $title;
 }
Example #18
0
 public function getTitle()
 {
     $actors = $this->item->actors;
     $names = FD::string()->namesToStream($actors, true, 3);
     // Load the album
     $album = FD::table('Album');
     $album->load($this->share->uid);
     $albumCreator = FD::user($album->uid);
     $theme = FD::get('Themes');
     $theme->set('names', $names);
     $theme->set('album', $album);
     $theme->set('creator', $albumCreator);
     $html = $theme->output('apps/user/shares/streams/albums/title');
     return $html;
 }
Example #19
0
 public function execute(&$item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // $item->uid is coming from comment->uid
     // $item->uid is also the stream id
     $stream = FD::table('Stream');
     $stream->load($item->uid);
     $streamItems = $stream->getItems();
     $discussion = FD::table('Discussion');
     $discussion->load($streamItems[0]->context_id);
     $event = FD::event($discussion->uid);
     // By default content is always empty;
     $content = '';
     // Only show the content when there is only 1 user
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     $isOwner = $discussion->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER;
     if ($item->context_type === 'discussions.event.create') {
         if ($isOwner) {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_COMMENTED_ON_YOUR_DISCUSSION', count($users));
             $item->title = JText::sprintf($string, $names, $event->getName());
         } else {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_COMMENTED_ON_USERS_DISCUSSION', count($users));
             $item->title = JText::sprintf($string, $names, FD::user($discussion->created_by)->getName(), $event->getName());
         }
     }
     if ($item->context_type === 'discussions.event.reply') {
         if ($isOwner) {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_COMMENTED_ON_YOUR_REPLY', count($users));
             $item->title = JText::sprintf($string, $names, $event->getName());
         } else {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_COMMENTED_ON_USERS_REPLY', count($users));
             $item->title = JText::sprintf($string, $names, FD::user($discussion->created_by)->getName(), $event->getName());
         }
     }
 }
 /**
  * Processes comment notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(SocialTableNotification &$item)
 {
     // Get the owner of the stream item since we need to notify the person
     $stream = FD::table('Stream');
     $stream->load($item->uid);
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // By default content is always empty;
     $content = '';
     // Only show the content when there is only 1 item
     if (count($users) == 1) {
         // Legacy fix for prior to 1.2 as there is no content stored.
         if (!empty($item->content)) {
             $content = JString::substr(strip_tags($item->content), 0, 30);
             if (JString::strlen($item->content) > 30) {
                 $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
             }
         }
     }
     // Set the content to the stream
     $item->content = $content;
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $langString = FD::string()->computeNoun('APP_USER_LINKS_USER_POSTED_COMMENT_ON_YOUR_LINK', count($users));
         $item->title = JText::sprintf($langString, $names);
         return $item;
     }
     // This is for 3rd party viewers
     $langString = FD::string()->computeNoun('APP_USER_LINKS_USER_POSTED_COMMENT_ON_USERS_LINK', count($users));
     $item->title = JText::sprintf($langString, $names, FD::user($stream->actor_id)->getName());
     return $item;
 }
Example #21
0
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // Load the stream object
     $stream = FD::table('Stream');
     $stream->load($item->uid);
     // Get the link assets
     $assets = $stream->getAssets(SOCIAL_TYPE_LINKS);
     if (!empty($assets)) {
         $asset = $assets[0];
         $link = FD::makeObject($asset->data);
         if ($link) {
             if ($link->link) {
                 $item->content = $link->link;
             }
             if ($link->image) {
                 $item->image = $link->image;
             }
         }
     }
     // We need to determine if the user is the owner
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $langString = FD::string()->computeNoun('APP_USER_LINKS_NOTIFICATIONS_USER_LIKES_YOUR_LINK_UPDATE', count($users));
         $item->title = JText::sprintf($langString, $names);
         return;
     }
     // For other users, we just post a generic message
     $langString = FD::string()->computeNoun('APP_USER_LINKS_NOTIFICATIONS_USER_LIKES_USERS_LINK_UPDATE', count($users));
     $item->title = JText::sprintf($langString, $names, FD::user($stream->actor_id)->getName());
     return;
 }
Example #22
0
 /**
  *
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function execute($item, $note)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // By default content is always empty;
     $content = '';
     // Only show the content when there is only 1 item
     if (count($users) == 1) {
         // Legacy fix for prior to 1.2 as there is no content stored.
         if (!empty($item->content)) {
             $content = JString::substr(strip_tags($item->content), 0, 30);
             if (JString::strlen($item->content) > 30) {
                 $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
             }
         }
     }
     $item->content = $content;
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($note->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_NOTES_USER_COMMENTED_ON_YOUR_NOTE' . $plurality, $names);
         return $item;
     }
     if ($note->user_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_NOTES_OWNER_COMMENTED_ON_NOTE' . FD::user($note->user_id)->getGenderLang(), $names);
         return $item;
     }
     // This is for 3rd party viewers
     $item->title = JText::sprintf('APP_USER_NOTES_USER_COMMENTED_ON_USERS_NOTE' . $plurality, $names, FD::user($note->user_id)->getName());
     return $item;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'files.group.uploaded') {
         $file = FD::table('File');
         $file->load($item->uid);
         // Get the group from the stream
         $group = FD::group($file->uid);
         // Set the content
         if ($file->hasPreview()) {
             $item->image = $file->getPreviewURI();
         }
         // We need to get the comment that is tied to this stream
         if (count($users) == 1) {
             $comment = FD::table('Comments');
             $comment->load(array('element' => 'files.group.uploaded', 'uid' => $item->uid));
             $item->content = $comment->comment;
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($file->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf('APP_GROUP_FILES_USER_COMMENTED_ON_YOUR_FILE', $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf('APP_GROUP_FILES_USER_COMMENTED_ON_USERS_FILE', $names, FD::user($file->user_id)->getName(), $group->getName());
         return;
     }
     return;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // Load the comment object since we have the context_ids
     $comment = FD::table('Comments');
     $comment->load($item->context_ids);
     // When user likes on an album or a group of photos from an album on the stream
     if ($item->context_type == 'story.user.create') {
         $stream = FD::table('Stream');
         $stream->load($item->uid);
         if (count($users) == 1) {
             $item->content = $comment->comment;
         }
         // We need to determine if the user is the owner
         if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_USER_STORY_NOTIFICATIONS_USER_POSTED_COMMENT_ON_YOUR_STATUS_UPDATE', count($users));
             $item->title = JText::sprintf($langString, $names);
             return;
         }
         if ($item->actor_id == $stream->actor_id && count($users) == 1) {
             $item->title = JText::sprintf('APP_USER_STORY_NOTIFICATIONS_USER_POSTED_COMMENT_ON_USERS_UPDATE' . FD::user($item->actor_id)->getGenderLang(), FD::user($stream->actor_id)->getName());
             return;
         }
         // For other users, we just post a generic message
         $langString = FD::string()->computeNoun('APP_USER_STORY_NOTIFICATIONS_USER_POSTED_COMMENT_ON_YOUR_USERS_UPDATE', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($stream->actor_id)->getName());
         return;
     }
     return;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'news.group.create') {
         // We do not want to display any content if the person likes a group announcement
         $item->content = '';
         // Get the news object
         $news = FD::table('ClusterNews');
         $news->load($item->uid);
         // Get the group from the stream
         $group = FD::group($news->cluster_id);
         // Set the content
         if ($group) {
             $item->image = $group->getAvatar();
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($news->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_GROUP_NEWS_USER_LIKES_YOUR_ANNOUNCEMENT', count($users));
             $item->title = JText::sprintf($langString, $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_GROUP_NEWS_USER_LIKES_USER_ANNOUNCEMENT', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($news->created_by)->getName(), $group->getName());
         return;
     }
     return;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     if ($item->context_ids) {
         $discussion = FD::table('Discussion');
         $discussion->load($item->context_ids);
         $item->content = JString::substr(strip_tags($discussion->content), 0, 30) . JText::_('COM_EASYSOCIAL_ELLIPSES');
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'discussions.group.create') {
         $discussion = FD::table('Discussion');
         $discussion->load($item->context_ids);
         // Get the group from the stream
         $group = FD::group($discussion->uid);
         // Set the content to the discussion title.
         $item->content = $discussion->title;
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($discussion->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_GROUP_DISCUSSIONS_USER_LIKES_YOUR_DISCUSSION', count($users));
             $item->title = JText::sprintf($langString, $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_GROUP_DISCUSSIONS_USER_LIKES_USERS_DISCUSSION', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($discussion->created_by)->getName(), $group->getName());
         return;
     }
     return;
 }
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     $discussion = FD::table('Discussion');
     $discussion->load($item->context_ids);
     $event = FD::event($discussion->uid);
     $isOwner = $discussion->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER;
     // Set the content to the discussion title.
     $item->content = $discussion->title;
     if ($item->context_type == 'discussions.event.create') {
         if ($isOwner) {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_YOUR_DISCUSSION', count($users));
             $item->title = JText::sprintf($string, $names, $event->getName());
         } else {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_USERS_DISCUSSION', count($users));
             $item->title = JText::sprintf($string, $names, FD::user($discussion->created_by)->getName(), $event->getName());
         }
     }
     if ($item->context_type == 'discussions.event.reply') {
         if ($isOwner) {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_YOUR_REPLY', count($users));
             $item->title = JText::sprintf($string, $names, $event->getName());
         } else {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_USERS_REPLY', count($users));
             $item->title = JText::sprintf($string, $names, FD::user($discussion->created_by)->getName(), $event->getName());
         }
     }
     if ($item->context_type == 'discussions.event.answered') {
         if ($isOwner) {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_YOUR_ACCEPTED_ANSWER', count($users));
             $item->title = JText::sprintf($string, $names, $event->getName());
         } else {
             $string = FD::string()->computeNoun('APP_EVENT_DISCUSSIONS_USER_LIKES_USERS_ACCEPTED_ANSWER', count($users));
             $item->title = JText::sprintf($string, $names, FD::user($discussion->created_by)->getName(), $event->getName());
         }
     }
 }
 public function execute($item)
 {
     // Get comment participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     list($element, $group, $verb) = explode('.', $item->context_type);
     if ($verb == 'createMilestone') {
         // Load the milestone
         $milestone = FD::table('Milestone');
         $milestone->load($item->uid);
         // Set the milestone title as the content
         $item->content = $milestone->title;
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($milestone->owner_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_LIKES_YOUR_MILESTONE', count($users)), $names);
             $item->content = $milestone->get('title');
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_LIKES_USERS_MILESTONE', count($users)), $names, FD::user($milestone->owner_id)->getName());
         $item->content = $milestone->get('title');
     }
     if ($verb == 'createTask') {
         // Load the task
         $task = FD::table('Task');
         $task->load($item->uid);
         // Set the milestone title as the content
         $item->content = $task->title;
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($task->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_LIKES_YOUR_TASK', count($users)), $names);
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_EVENT_TASKS_USER_LIKES_USERS_TASK', count($users)), $names, FD::user($task->user_id)->getName());
     }
     return $item;
 }
Example #29
0
 /**
  * Returns the lapsed time since NOW
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	string	The lapsed time.
  */
 public function toLapsed()
 {
     // Load front end language strings as well since this lib requires it.
     FD::language()->loadSite();
     $now = FD::date();
     $time = $now->date->toUnix(true) - $this->date->toUnix(true);
     $tokens = array(31536000 => 'COM_EASYSOCIAL_LAPSED_YEARS_COUNT', 2592000 => 'COM_EASYSOCIAL_LAPSED_MONTHS_COUNT', 604800 => 'COM_EASYSOCIAL_LAPSED_WEEKS_COUNT', 86400 => 'COM_EASYSOCIAL_LAPSED_DAYS_COUNT', 3600 => 'COM_EASYSOCIAL_LAPSED_HOURS_COUNT', 60 => 'COM_EASYSOCIAL_LAPSED_MINUTES_COUNT', 1 => 'COM_EASYSOCIAL_LAPSED_SECONDS_COUNT');
     if ($time == 0) {
         return JText::_('COM_EASYSOCIAL_LAPSED_NOW');
     }
     foreach ($tokens as $unit => $key) {
         if ($time < $unit) {
             continue;
         }
         $units = floor($time / $unit);
         $text = FD::string()->computeNoun($key, $units);
         $text = JText::sprintf($text, $units);
         return $text;
     }
 }
 public function execute($item, $calendar)
 {
     $model = FD::model('likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the notification actor
     $users[] = $item->actor_id;
     // Exclude the current user
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     if ($calendar->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_USER_LIKES_YOUR_EVENT' . $plurality, $names);
         return $item;
     }
     if ($calendar->user_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_OWNER_LIKES_EVENT' . FD::user($calendar->user_id)->getGendarLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_CALENDAR_USER_LIKES_USER_EVENT' . $plurality, $names, FD::user($calendar->user_id)->getName());
     return $item;
 }