Esempio n. 1
0
 /**
  * Displays the application output in the canvas.
  *
  * @since   1.3
  * @access  public
  * @param   integer $uid    The event id.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     // Check if the viewer is allowed here.
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get app params
     $params = $this->app->getParams();
     // Load the milestone
     $id = JRequest::getInt('milestoneId');
     $milestone = FD::table('Milestone');
     $milestone->load($id);
     if (!empty($milestone->id)) {
         FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_EDITING_MILESTONE'));
     } else {
         FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_CREATE_MILESTONE'));
     }
     // Get a list of members from the group
     $members = FD::model('Events')->getMembers($event->id);
     $this->set('members', $members);
     $this->set('milestone', $milestone);
     $this->set('params', $params);
     $this->set('event', $event);
     echo parent::display('views/form');
 }
 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;
 }
Esempio n. 3
0
 /**
  * Validates the permalink.
  *
  * @author  Jason Rey <*****@*****.**>
  * @since   1.3
  * @access  public
  * @return  JSON    A jsong encoded string.
  */
 public function isValid()
 {
     // Render the ajax lib.
     $ajax = FD::ajax();
     // Get the cluster id.
     $clusterId = JRequest::getInt('clusterid', 0);
     // Init the current alias.
     $current = '';
     if (!empty($clusterId)) {
         $event = FD::event($clusterId);
         $current = $event->alias;
     }
     // Get the provided permalink
     $permalink = JRequest::getVar('permalink', '');
     // Check if the field is required
     if (!$this->field->isRequired() && empty($permalink)) {
         return true;
     }
     // Check if the permalink provided is valid
     if (!SocialFieldsEventPermalinkHelper::valid($permalink, $this->params)) {
         return $ajax->reject(JText::_('FIELDS_EVENT_PERMALINK_INVALID_PERMALINK'));
     }
     // Test if permalink exists
     if (SocialFieldsEventPermalinkHelper::exists($permalink) && $permalink != $current) {
         return $ajax->reject(JText::_('FIELDS_EVENT_PERMALINK_NOT_AVAILABLE'));
     }
     $text = JText::_('FIELDS_EVENT_PERMALINK_AVAILABLE');
     return $ajax->resolve($text);
 }
Esempio n. 4
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.3
  * @access   public
  * @param    int        The event id
  */
 public function display($id = null, $docType = null)
 {
     // Load up the event
     $event = FD::event($id);
     // Check if the viewer is really allowed to view news
     if ($event->isInviteOnly() && $event->isClosed() && !$event->getGuest()->isGuest() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($event->getPermalink(false));
     }
     $params = $this->app->getParams();
     // Set the max length of the item
     $options = array('limit' => (int) $params->get('total', 10));
     $model = FD::model('Clusters');
     $items = $model->getNews($event->id, $options);
     $pagination = $model->getPagination();
     // Format the item's content.
     $this->format($items, $params);
     $pagination->setVar('option', 'com_easysocial');
     $pagination->setVar('view', 'events');
     $pagination->setVar('layout', 'item');
     $pagination->setVar('id', $event->getAlias());
     $pagination->setVar('appId', $this->app->getAlias());
     $this->set('params', $params);
     $this->set('pagination', $pagination);
     $this->set('event', $event);
     $this->set('items', $items);
     echo parent::display('canvas/default');
 }
 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;
 }
Esempio n. 6
0
 public function createStream($verb)
 {
     // Create a new stream item for this discussion
     $stream = FD::stream();
     // Get the stream template
     $tpl = $stream->getTemplate();
     // Someone just joined the event
     $tpl->setActor($this->created_by, SOCIAL_TYPE_USER);
     // Set the params to cache the event data
     $registry = FD::registry();
     $registry->set('news', $this);
     // Set the context
     $tpl->setContext($this->id, 'news');
     $event = FD::event($this->cluster_id);
     // Set the cluster
     $tpl->setCluster($this->cluster_id, SOCIAL_TYPE_EVENT, $event->type);
     // Set the verb
     $tpl->setVerb($verb);
     // Set the params
     $tpl->setParams($registry);
     if ($this->_stream_date) {
         $tpl->setDate($this->_stream_date);
     }
     $tpl->setAccess('core.view');
     // Add the stream
     $stream->add($tpl);
 }
Esempio n. 7
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($eventId = null, $docType = null)
 {
     $event = FD::event($eventId);
     // Check if the viewer is allowed here.
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get app params
     $params = $this->app->getParams();
     $model = FD::model('Discussions');
     $options = array('limit' => $params->get('total', 10));
     $discussions = $model->getDiscussions($event->id, SOCIAL_TYPE_EVENT, $options);
     $pagination = $model->getPagination();
     $pagination->setVar('option', 'com_easysocial');
     $pagination->setVar('view', 'events');
     $pagination->setVar('layout', 'item');
     $pagination->setVar('id', $event->getAlias());
     $pagination->setVar('appId', $this->app->getAlias());
     $this->set('app', $this->app);
     $this->set('params', $params);
     $this->set('pagination', $pagination);
     $this->set('event', $event);
     $this->set('discussions', $discussions);
     echo parent::display('events/default');
 }
Esempio n. 8
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     $editor = JFactory::getEditor();
     $guest = $event->getGuest();
     // Only allow group admin to create or edit news
     if (!$guest->isAdmin() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($event->getPermalink(false));
     }
     // Determines if this item is being edited
     $id = $this->input->get('newsId', 0, 'int');
     $news = FD::table('EventNews');
     $news->load($id);
     FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_UPDATE_PAGE_TITLE'));
     // Determine if this is a new record or not
     if (!$id) {
         $news->comments = true;
         FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_CREATE_PAGE_TITLE'));
     }
     // Get app params
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('news', $news);
     $this->set('editor', $editor);
     $this->set('event', $event);
     echo parent::display('canvas/form');
 }
 /**
  * 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;
 }
Esempio n. 10
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     // Get the article item
     $news = FD::table('EventNews');
     $news->load($this->input->get('newsId', 0, 'int'));
     // Check if the user is really allowed to view this item
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get the author of the article
     $author = FD::user($news->created_by);
     // Get the url for the article
     $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
     // Apply comments for the article
     $comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url));
     // Apply likes for the article
     $likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT);
     // Set the page title
     FD::page()->title($news->get('title'));
     // Retrieve the params
     $params = $this->app->getParams();
     $this->set('app', $this->app);
     $this->set('params', $params);
     $this->set('event', $event);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('author', $author);
     $this->set('news', $news);
     echo parent::display('canvas/item');
 }
Esempio n. 11
0
 public function invite()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $result = new stdClass();
     $event_id = $app->input->get('event_id', 0, 'INT');
     $target_users = $app->input->get('target_users', null, 'ARRAY');
     $user = FD::user($log_user->id);
     $event = FD::event($event_id);
     $guest = $event->getGuest($log_user);
     if (empty($event) || empty($event->id)) {
         $result->message = "Event not found";
         $result->status = $state;
         return $result;
     }
     if ($event_id) {
         foreach ($target_users as $id) {
             $guest = $event->getGuest($id);
             if (!$guest->isGuest()) {
                 //invite friend to  event
                 $state = $event->invite($id, $log_user->id);
                 $result->message = "Invited";
                 $result->status = $state;
             } else {
                 $result->message = "Guests can not be invited";
                 $result->status = $state;
             }
         }
     }
     return $result;
 }
Esempio n. 12
0
 public function __construct($id, $type)
 {
     parent::__construct($id, 'event');
     if (!EB::easysocial()->exists()) {
         return;
     }
     $this->event = FD::event($id);
 }
Esempio n. 13
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     $editor = JFactory::getEditor();
     $this->set('editor', $editor);
     $this->set('event', $event);
     echo parent::display('canvas/form');
 }
Esempio n. 14
0
 /**
  * Generates the stream title of event.
  *
  * @since    1.0
  * @access    public
  * @param    object    $params        A standard object with key / value binding.
  *
  * @return    none
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'links') {
         return;
     }
     // event access checking
     $event = FD::event($stream->cluster_id);
     if (!$event || !$event->canViewItem()) {
         return;
     }
     //get links object, in this case, is the stream_item
     $uid = $stream->uid;
     $stream->color = '#5580BE';
     $stream->fonticon = 'ies-link';
     $stream->label = FD::_('APP_EVENT_LINKS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $stream->repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_EVENT);
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
         return;
     }
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $assets = $stream->getAssets();
     if (empty($assets)) {
         return;
     }
     $assets = $assets[0];
     $videoHtml = '';
     // Retrieve the link that is stored.
     $hash = md5($assets->get('link'));
     $link = FD::table('Link');
     $link->load(array('hash' => $hash));
     $linkObj = FD::json()->decode($link->data);
     // Determine if there's any embedded object
     $oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
     // Get app params
     $params = $this->getParams();
     $this->set('event', $event);
     $this->set('params', $params);
     $this->set('oembed', $oembed);
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $stream->title = parent::display('streams/title.' . $stream->verb);
     $stream->preview = parent::display('streams/preview.' . $stream->verb);
     return true;
 }
Esempio n. 15
0
 /**
  * Support for generic getFieldValue('TITLE')
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3.9
  * @access public
  * @return SocialFieldValue    The value container
  */
 public function getValue()
 {
     $container = $this->getValueContainer();
     if ($this->field->type == SOCIAL_TYPE_EVENT && !empty($this->field->uid)) {
         $event = FD::event($this->field->uid);
         $container->value = $event->getName();
         $container->data = $event->title;
     }
     return $container;
 }
Esempio n. 16
0
 /**
  * Display user photos on the side bar
  *
  * @since   1.2
  * @access  public
  * @return
  */
 public function sidebarBottom($eventId, $event)
 {
     $event = FD::event($eventId);
     $category = $event->getCategory();
     if (!$category->getAcl()->get('photos.enabled', true) || !$event->getParams()->get('photo.albums', true)) {
         return;
     }
     // Get recent albums
     $albumsHTML = $this->getAlbums($event);
     echo $albumsHTML;
 }
Esempio n. 17
0
 /**
  * Displays the attendees in mini header
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function miniEventStatsEnd($eventId)
 {
     $theme = FD::themes();
     // Get the event object
     $event = FD::event($eventId);
     $permalink = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'appId' => $this->app->getAlias()));
     $theme->set('miniheader', true);
     $theme->set('permalink', $permalink);
     $theme->set('event', $event);
     echo $theme->output('themes:/apps/event/guests/widgets/widget.header');
 }
Esempio n. 18
0
 public function get_event()
 {
     $app = JFactory::getApplication();
     $log_user = $this->plugin->get('user')->id;
     $event_id = $app->input->get('event_id', 0, 'INT');
     $mapp = new EasySocialApiMappingHelper();
     //getting all detail of particular event.
     $data = null;
     if ($event_id) {
         $event[] = FD::event($event_id);
         $data = $mapp->mapItem($event, 'event', $log_user);
     }
     return $data;
 }
 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;
 }
Esempio n. 20
0
 /**
  * Renders the event link
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public static function event($obj, $popbox = false, $popboxPosition = 'top-left')
 {
     if (!is_object($obj)) {
         $event = FD::event($obj);
     }
     if ($obj instanceof SocialEvent) {
         $event = $obj;
     }
     $theme = FD::themes();
     $theme->set('popbox', $popbox);
     $theme->set('position', $popboxPosition);
     $theme->set('event', $event);
     $output = $theme->output('admin/html/html.event');
     return $output;
 }
Esempio n. 21
0
 public function sidebarBottom($eventId)
 {
     $params = $this->app->getParams();
     if (!$params->get('widget')) {
         return;
     }
     $event = FD::event($eventId);
     $theme = FD::themes();
     $limit = $params->get('widget_total', 5);
     $model = FD::model('Files');
     $options = array('limit' => $limit);
     $files = $model->getFiles($event->id, SOCIAL_TYPE_EVENT, $options);
     $theme->set('files', $files);
     echo $theme->output('themes:/apps/event/files/widgets/widget.files');
 }
Esempio n. 22
0
 /**
  * Notify the owner of the stream
  *
  * @since   1.2
  * @access  public
  */
 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 event
     $event = FD::event($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['event'] = $event->getName();
     $mailParams['eventLink'] = $event->getPermalink(true, true);
     $mailParams['permalink'] = FRoute::stream(array('layout' => 'item', 'id' => $share->uid, 'external' => true), true);
     $mailParams['title'] = 'APP_EVENT_SHARES_EMAILS_USER_REPOSTED_YOUR_POST_SUBJECT';
     $mailParams['template'] = 'apps/event/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'] = $event->id;
     $systemParams['context_ids'] = $share->id;
     FD::notify('repost.item', array($stream->actor_id), $mailParams, $systemParams);
 }
Esempio n. 23
0
 /**
  * Filters the output of members
  *
  * @since    1.3
  * @access    public
  * @return
  */
 public function filterGuests()
 {
     // Check for request forgeriess
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get the event object
     $id = $this->input->get('id', 0, 'int');
     $event = FD::event($id);
     if (!$event || !$id) {
         return $this->ajax->reject();
     }
     // Check whether the viewer can really view the contents
     if (!$event->canViewItem()) {
         return $this->ajax->reject();
     }
     // Get the current filter
     $filter = $this->input->get('filter', '', 'word');
     $options = array();
     if ($filter == 'admin') {
         $options['admin'] = true;
     }
     if ($filter == 'going') {
         $options['state'] = SOCIAL_EVENT_GUEST_GOING;
     }
     if ($filter == 'maybe') {
         $options['state'] = SOCIAL_EVENT_GUEST_MAYBE;
     }
     if ($filter == 'notgoing') {
         $options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING;
     }
     if ($filter == 'pending') {
         $options['state'] = SOCIAL_EVENT_GUEST_PENDING;
     }
     $model = FD::model('Events');
     $guests = $model->getGuests($event->id, $options);
     $pagination = $model->getPagination();
     $myGuest = $event->getGuest();
     // Load the contents
     $theme = FD::themes();
     $theme->set('pagination', $pagination);
     $theme->set('event', $event);
     $theme->set('guests', $guests);
     $theme->set('myGuest', $myGuest);
     $contents = $theme->output('apps/event/guests/events/default.list');
     return $this->ajax->resolve($contents, count($guests));
 }
Esempio n. 24
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());
         }
     }
 }
Esempio n. 25
0
 /**
  * Processes comment notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(SocialTableNotification &$item)
 {
     // Get the group item
     $event = FD::event($item->uid);
     // Get the actor
     $actor = FD::user($item->actor_id);
     // Set the title of the notification
     $item->title = JText::sprintf('APP_EVENT_NEWS_USER_POSTED_NEW_NEWS', $actor->getName(), $event->getName());
     if (!$item->context_ids) {
         return;
     }
     // Set the news item
     $news = FD::table('EventNews');
     $news->load($item->context_ids);
     $item->content = $news->title;
     return $item;
 }
Esempio n. 26
0
 private function loadAccess($id = null, $type = SOCIAL_TYPE_USER)
 {
     // This is to prevent unnecessary multiple loading per user id
     static $loadedAccess = array();
     $uid = null;
     // Perform data standardization
     // If type is profile, then we just directly use it as profile id
     if ($type === SOCIAL_TYPE_PROFILES) {
         $uid = $id;
     }
     // If type is user then we deduce the profile id from the user
     if ($type === SOCIAL_TYPE_USER) {
         // Get the user object
         $my = FD::user($id);
         $uid = $my->profile_id;
         $type = SOCIAL_TYPE_PROFILES;
     }
     // clusters is the profiles equivalent
     // If type is groups category, then use the id directly
     if ($type === SOCIAL_TYPE_CLUSTERS) {
         $uid = $id;
     }
     // If the type is group, then get the group category id from the group
     if ($type === SOCIAL_TYPE_GROUP) {
         // @TODO: Get the group category id
         $group = FD::group($id);
         $uid = $group->category_id;
         $type = SOCIAL_TYPE_CLUSTERS;
     }
     if ($type === SOCIAL_TYPE_EVENT) {
         $event = FD::event($id);
         $uid = $event->category_id;
         $type = SOCIAL_TYPE_CLUSTERS;
     }
     $this->getDefaultValues($type);
     if (empty($loadedAccess[$type][$uid])) {
         // Load up the access based on the profile
         $model = FD::model('Access');
         $storedAccess = $model->getParams($uid, $type);
         // Merge all the group registries first.
         $registry = FD::registry($storedAccess);
         $loadedAccess[$type][$uid] = $registry;
     }
     $this->access = $loadedAccess[$type][$uid];
     return $this;
 }
Esempio n. 27
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     FD::requireLogin();
     $event = FD::event($uid);
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Load up the app params
     $params = $this->app->getParams();
     // Get the discussion item
     $id = $this->input->get('discussionId', 0, 'int');
     $discussion = FD::table('Discussion');
     $discussion->load($id);
     // Get the author of the article
     $author = FD::user($discussion->created_by);
     // Get the url for the article
     $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'discussionId' => $discussion->id), false);
     // Set the page title
     FD::page()->title($discussion->get('title'));
     // Increment the hits for this discussion item
     $discussion->addHit();
     // Get a list of other news
     $model = FD::model('Discussions');
     $replies = $model->getReplies($discussion->id, array('ordering' => 'created'));
     $participants = $model->getParticipants($discussion->id);
     // Get the answer
     $answer = false;
     if ($discussion->answer_id) {
         $answer = FD::table('Discussion');
         $answer->load($discussion->answer_id);
         $answer->author = FD::user($answer->created_by);
     }
     // Determines if we should allow file sharing
     $access = $event->getAccess();
     $files = $access->get('files.enabled', true);
     $this->set('app', $this->app);
     $this->set('files', $files);
     $this->set('params', $params);
     $this->set('answer', $answer);
     $this->set('participants', $participants);
     $this->set('discussion', $discussion);
     $this->set('event', $event);
     $this->set('replies', $replies);
     $this->set('author', $author);
     echo parent::display('canvas/item');
 }
Esempio n. 28
0
 /**
  * Allows caller to export event items into downloadable ics file
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function export()
 {
     // Get the event object
     $event = FD::event($this->input->get('id', 0, 'int'));
     $theme = FD::themes();
     $theme->set('event', $event);
     $output = $theme->output('site/events/ical');
     $ts = substr(md5(rand(0, 100)), 0, 5);
     $fileName = 'calendar_' . $ts . '.ics';
     // Allow caller to download the file
     header('Content-type: text/calendar; charset=utf-8');
     header('Content-Disposition: inline; filename=' . $fileName);
     echo $output;
     // Debug
     // echo nl2br($output);
     exit;
 }
Esempio n. 29
0
 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());
         }
     }
 }
Esempio n. 30
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($eventId = null, $docType = null)
 {
     // Load up the event
     $event = FD::event($eventId);
     // Get the event params
     $params = $event->getParams();
     // Load up the events model
     $model = FD::model('Events');
     $type = FD::input()->getString('type', 'going');
     $options = array();
     if ($type === 'going') {
         $options['state'] = SOCIAL_EVENT_GUEST_GOING;
     }
     if ($params->get('allowmaybe') && $type === 'maybe') {
         $options['state'] = SOCIAL_EVENT_GUEST_MAYBE;
     }
     if ($params->get('allownotgoingguest') && $type === 'notgoing') {
         $options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING;
     }
     if ($event->isClosed() && $type === 'pending') {
         $options['state'] = SOCIAL_EVENT_GUEST_PENDING;
     }
     if ($type === 'admin') {
         $options['admin'] = 1;
     }
     $this->set('type', $type);
     $guests = $model->getGuests($event->id, $options);
     $pagination = $model->getPagination();
     $this->set('event', $event);
     $this->set('guests', $guests);
     $eventAlias = $event->getAlias();
     $appAlias = $this->app->getAlias();
     $permalinks = array('going' => '', 'notgoing' => '', 'maybe' => '', 'admin' => '', 'pending' => '');
     // Avoid using $filter because it is a FRoute reserved word
     foreach ($permalinks as $key => &$value) {
         $value = FRoute::events(array('layout' => 'item', 'id' => $eventAlias, 'appId' => $appAlias, 'type' => $key));
     }
     $this->set('permalinks', $permalinks);
     $myGuest = $event->getGuest();
     $this->set('myGuest', $myGuest);
     echo parent::display('events/default');
 }