Exemple #1
0
 public function prepareCreateMilestoneStream(SocialStreamItem $streamItem, $includePrivacy = true)
 {
     $params = FD::registry($streamItem->params);
     $milestone = FD::table('Milestone');
     $milestone->bind($params->get('milestone'));
     // Get the group data
     FD::load('event');
     $event = new SocialEvent();
     $event->bind($params->get('event'));
     // Get the actor
     $actor = $streamItem->actor;
     $app = $this->getApp();
     $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id));
     $this->set('permalink', $permalink);
     $this->set('milestone', $milestone);
     $this->set('actor', $actor);
     $this->set('event', $event);
     $streamItem->title = parent::display('streams/create.milestone.title');
     $streamItem->content = parent::display('streams/create.milestone.content');
     $streamItem->opengraph->addDescription(JText::sprintf('APP_EVENT_TASKS_STREAM_OPENGRAPH_CREATE_MILESTONE', $streamItem->actor->getName(), $event->getName()));
 }
Exemple #2
0
 public function createRecurring()
 {
     FD::checkToken();
     $eventId = $this->input->getInt('eventId');
     $schedule = $this->input->getString('datetime');
     $parentEvent = FD::event($eventId);
     $duration = $parentEvent->hasEventEnd() ? $parentEvent->getEventEnd()->toUnix() - $parentEvent->getEventStart()->toUnix() : false;
     $data = $this->input->getVar('postdata');
     // Because this comes form a form, the $data['id'] might be an existing id especially if the create recurring comes from "edit"
     unset($data['id']);
     // Because this comes from a form, $data['applyRecurring'] might be 1 for applying purposes, but for creation, we do not this flag
     unset($data['applyRecurring']);
     // Mark the data as createRecurring
     $data['createRecurring'] = true;
     // Manually change the start end time
     $data['startDatetime'] = FD::date($schedule)->toSql();
     if ($duration) {
         $data['endDatetime'] = FD::date($schedule + $duration)->toSql();
     } else {
         unset($data['endDatetime']);
     }
     $my = FD::user();
     $fieldsLib = FD::fields();
     $options = array();
     $options['uid'] = $parentEvent->category_id;
     $options['group'] = SOCIAL_FIELDS_GROUP_EVENT;
     $fields = FD::model('fields')->getCustomFields($options);
     $event = new SocialEvent();
     $event->category_id = $parentEvent->category_id;
     $event->creator_uid = $parentEvent->creator_uid;
     $event->creator_type = SOCIAL_TYPE_USER;
     $event->state = SOCIAL_STATE_PUBLISHED;
     $event->key = md5(FD::date()->toSql() . $my->password . uniqid());
     $event->parent_id = $parentEvent->id;
     $event->parent_type = SOCIAL_TYPE_EVENT;
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bind($data);
     $event->save();
     // Duplicate nodes from parent
     FD::model('Events')->duplicateGuests($parentEvent->id, $event->id);
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bindCustomFields($data);
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     return $this->view->call(__FUNCTION__);
 }
Exemple #3
0
 /**
  * Processes mentions in a stream object
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function formatMentions(SocialStreamItem &$stream)
 {
     // Get the current view
     $view = JRequest::getCmd('view', '');
     // Get the stream's content
     $content = $stream->content;
     // Get tags for the stream
     $tags = isset($stream->tags) ? $stream->tags : array();
     // If there is no tags, just skip this and escape the content
     if (!$tags) {
         return FD::string()->escape($content);
     }
     // We need to store the changes in an array and replace it accordingly based on the counter.
     $items = array();
     // We need to merge the mentions and hashtags since we are based on the offset.
     $i = 0;
     foreach ($tags as $tag) {
         if ($tag->type == 'user') {
             $replace = '<a href="' . $tag->user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $tag->user->id . '" class="mentions-user">' . $tag->user->getName() . '</a>';
         }
         if ($tag->type == 'hashtag') {
             // $alias = JFilterOutput::stringURLSafe($tag->title);
             $alias = $tag->title;
             $url = '';
             if ($view == 'groups') {
                 $clusterReg = FD::registry($stream->params);
                 $object = $clusterReg->get($stream->cluster_type);
                 switch ($stream->cluster_type) {
                     case SOCIAL_TYPE_GROUP:
                         // for now we assume all is group type.
                         $group = new SocialGroup();
                         $group->bind($object);
                         $url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'tag' => $alias));
                         break;
                     case SOCIAL_TYPE_EVENT:
                         $event = new SocialEvent();
                         $event->bind($object);
                         $url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'tag' => $alias));
                         break;
                     default:
                         FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias));
                         break;
                 }
             } else {
                 $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias));
             }
             $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>';
         }
         $links[$i] = $replace;
         $replace = '[si:mentions]' . $i . '[/si:mentions]';
         $content = JString::substr_replace($content, $replace, $tag->offset, $tag->length);
         $i++;
     }
     // Once we have the content, escape it
     $content = FD::string()->escape($content);
     if ($links) {
         for ($x = 0; $x < count($links); $x++) {
             $content = str_ireplace('[si:mentions]' . $x . '[/si:mentions]', $links[$x], $content);
         }
     }
     return $content;
 }
Exemple #4
0
 /**
  * Prepares the upload avatar stream for a event
  *
  * @since	1.3
  * @access	public
  */
 public function prepareEventUploadAvatarStream(&$item, $privacy, $includePrivacy = true)
 {
     $element = $item->context;
     $uid = $item->contextId;
     // Load the photo
     $photo = $this->getPhotoFromParams($item);
     // Get the data of the group
     $registry = Foundry::registry($item->params);
     $event = new SocialEvent();
     $event->bind($registry->get($item->cluster_type));
     $this->set('event', $event);
     $this->set('photo', $photo);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/event/upload.avatar.title');
     $item->content = parent::display('streams/event/upload.avatar.content');
     if ($includePrivacy) {
         $item->privacy = $privacy->form($uid, $element, $item->actor->id, 'core.view', false, $item->uid);
     }
 }