コード例 #1
0
 /**
  * Main method to display the privacy view.
  *
  * @since	1.0
  * @access	public
  * @return	null
  *
  * @author	Sam <*****@*****.**>
  */
 public function display($tpl = null)
 {
     $this->setHeading('COM_EASYSOCIAL_HEADING_PRIVACY');
     $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_PRIVACY');
     $state = JRequest::getInt('state', 1);
     JToolbarHelper::divider();
     JToolbarHelper::publishList('publish');
     JToolbarHelper::unpublishList('unpublish');
     JToolbarHelper::divider();
     JToolbarHelper::deleteList('', 'delete', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_DELETE'));
     $model = FD::model('Privacy', array('initState' => true));
     $limit = $model->getState('limit');
     $ordering = $model->getState('ordering');
     $direction = $model->getState('direction');
     $search = $model->getState('search');
     $privacy = $model->getList();
     // Get pagination
     $pagination = $model->getPagination();
     $this->set('ordering', $ordering);
     $this->set('direction', $direction);
     $this->set('limit', $limit);
     $this->set('search', $search);
     $this->set('pagination', $pagination);
     $this->set('privacy', $privacy);
     $this->set('state', $state);
     FD::language()->loadSite();
     FD::apps()->loadAllLanguages();
     echo parent::display('admin/privacy/default');
 }
コード例 #2
0
ファイル: view.ajax.php プロジェクト: knigherrant/decopatio
 /**
  * Responsible to output the application contents.
  *
  * @since	1.0
  * @access	public
  * @param	SocialAppTable	The application ORM.
  */
 public function getAppContents($app)
 {
     // If there's an error throw it back to the caller.
     if ($this->hasErrors()) {
         return $this->ajax->reject($this->getMessage());
     }
     // Load the library.
     $lib = FD::apps();
     $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'dashboard', $app, array('userId' => $this->my->id));
     // Return the contents
     return $this->ajax->resolve($contents);
 }
コード例 #3
0
ファイル: points.php プロジェクト: ppantilla/bbninja
 /**
  * Updates the cache copy of the user's points.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user's id.
  * @param	int		The total number of points
  * @return	bool	True if success false otherwise.
  */
 public function updateUserPoints($userId, $points)
 {
     // Load user's app
     FD::apps()->load(SOCIAL_TYPE_USER);
     // Load the user
     $user = FD::user($userId);
     // Get the dispatcher
     $dispatcher = FD::dispatcher();
     // Construct the arguments to pass to the apps
     $args = array(&$user, &$points);
     // @trigger onBeforeAssignPoints
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onBeforeAssignPoints', $args);
     $user->addPoints($points);
     // @trigger onAfterAssignPoints
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onAfterAssignPoints', $args);
     return true;
 }
コード例 #4
0
 /**
  * Single method to run specific triggers. Caller can specify callbacks which can be
  * executed by the caller.
  *
  * @param   string  $group       The addon group
  * @param	string  $element    The element name.
  * @param   string  $method     The method to be called.
  * @param   array   $data       An array of data to be passed on to the addon.
  * @param   array   $callbacks  An array of callback methods with key/value pairs
  * @return  mixed
  */
 public function trigger($group, $eventName, $args, $elements = null, $callbacks = array())
 {
     // Hot load this so that trigger caller doesn't need to load the apps
     FD::apps()->load($group);
     // Check if there's anything to load at all.
     if (!isset($this->observers[$group])) {
         return false;
     }
     // Get the list of observers
     $observers = $this->observers[$group];
     // If elements is an array, this means that
     // we only want to trigger those specific group of apps,
     // in that specific ordering as in that array.
     if (is_array($elements)) {
         $observers = array();
         foreach ($elements as $element) {
             if (isset($this->observers[$group][$element])) {
                 $observers[] = $this->observers[$group][$element];
             }
         }
     }
     $result = array();
     // Arguments must always be an array.
     $args = FD::makeArray($args);
     foreach ($observers as $observer) {
         // If the observer is not an instance of SocialAppItem, we just skip this.
         if (!$observer instanceof SocialAppItem) {
             continue;
         }
         // Execute any callback methods.
         if (!empty($callbacks)) {
             foreach ($callbacks as $callback => $value) {
                 if (method_exists($observer, $callback)) {
                     call_user_func_array(array($observer, $callback), array($value));
                 }
             }
         }
         // Run the initial execution.
         $result[] = $observer->update($eventName, $args);
     }
     return $result;
 }
コード例 #5
0
ファイル: comments.php プロジェクト: knigherrant/decopatio
 public function store($updateNulls = false)
 {
     if (!$this->params instanceof SocialRegistry) {
         $this->params = FD::registry($this->params);
     }
     $this->params = $this->params->toString();
     $isNew = false;
     if (empty($this->id)) {
         $isNew = true;
     }
     // Get the necessary group
     $namespace = explode('.', $this->element);
     $group = isset($namespace[1]) ? $namespace[1] : SOCIAL_APPS_GROUP_USER;
     FD::apps()->load($group);
     if ($isNew && $this->_trigger) {
         if (!empty($this->parent)) {
             $parent = $this->getParent();
             if ($parent) {
                 $this->depth = $parent->depth + 1;
                 $parent->addChildCount();
             }
         }
         $this->setBoundary();
         // Get the dispatcher object
         $dispatcher = FD::dispatcher();
         $args = array(&$this);
         // @trigger: onBeforeCommentSave
         $dispatcher->trigger($group, 'onBeforeCommentSave', $args);
     }
     $state = parent::store();
     if (!$state) {
         FD::logError(__FILE__, __LINE__, $this->getError());
         return false;
     }
     if ($isNew && $this->_trigger) {
         // @trigger: onAfterCommentSave
         $dispatcher->trigger($group, 'onAfterCommentSave', $args);
     }
     return $state;
 }
コード例 #6
0
ファイル: cron.php プロジェクト: ppantilla/bbninja
 /**
  * Triggers the cron service
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     $config = FD::config();
     // Check if we need a secure phrase.
     $requirePhrase = $config->get('general.cron.secure');
     $storedPhrase = $config->get('general.cron.key');
     $phrase = JRequest::getVar('phrase', '');
     if ($requirePhrase && empty($phrase) || $requirePhrase && $storedPhrase != $phrase) {
         $this->setStatus('failed');
         $this->output(JText::_('COM_EASYSOCIAL_CRONJOB_PASSPHRASE_INVALID'));
         return $this->render();
     }
     // Data to be passed to the triggers.
     $data = array();
     // Array of states
     $states = array();
     // @trigger: fields.onBeforeCronExecute
     // Retrieve custom fields for the current step
     $fieldsModel = FD::model('Fields');
     $customFields = $fieldsModel->getCustomFields(array('appgroup' => SOCIAL_TYPE_USER));
     $fields = FD::fields();
     $fields->trigger('onCronExecute', SOCIAL_TYPE_USER, $customFields, $data);
     // @trigger: apps.onBeforeCronExecute
     $apps = FD::apps();
     $dispatcher = FD::dispatcher();
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onCronExecute', $data);
     // Load up files in hooks
     $this->hook($states);
     if (!empty($states)) {
         foreach ($states as $state) {
             $this->output($state);
         }
     }
     // Perform maintenance
     $maintenance = FD::get('Maintenance');
     $maintenance->cleanup();
     $this->render();
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: ppantilla/bbninja
 /**
  * Displays a user profile to a 3rd person perspective.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  **/
 public function display($tpl = null)
 {
     // Get the user's id.
     $id = $this->input->get('id', 0, 'int');
     // The current logged in user might be viewing their own profile.
     if ($id == 0) {
         $id = FD::user()->id;
     }
     // When the user tries to view his own profile but if he isn't logged in, throw a login page.
     if ($id == 0) {
         return FD::requireLogin();
     }
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Get the user's object.
     $user = FD::user($id);
     // If the user still don't exist, throw a 404
     if (!$user->id) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
     }
     if (Foundry::user()->id != $user->id) {
         if (FD::user()->isBlockedBy($user->id)) {
             return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
         }
     }
     if ($user->isBlock()) {
         FD::info()->set(JText::sprintf('COM_EASYSOCIAL_PROFILE_USER_NOT_EXIST', $user->getName()), SOCIAL_MSG_ERROR);
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Set the page title
     FD::page()->title(FD::string()->escape($user->getName()));
     // Set the page breadcrumb
     FD::page()->breadcrumb(FD::string()->escape($user->getName()));
     // Apply opengraph tags.
     FD::opengraph()->addProfile($user);
     // Get the current logged in user's object.
     $my = FD::user();
     // Do not assign badge if i view myself.
     if ($user->id != $my->id && $my->id) {
         // @badge: profile.view
         $badge = FD::badges();
         $badge->log('com_easysocial', 'profile.view', $my->id, JText::_('COM_EASYSOCIAL_PROFILE_VIEWED_A_PROFILE'));
     }
     $startlimit = JRequest::getInt('limitstart', 0);
     // Determine if the current request is to load an app
     $appId = JRequest::getInt('appId');
     // Get site configuration
     $config = FD::config();
     // Get the apps library.
     $appsLib = FD::apps();
     $contents = '';
     if ($appId) {
         // Load the app
         $app = FD::table('App');
         $app->load($appId);
         // Check if the user has access to this app
         if (!$app->accessible($user->id)) {
             FD::info()->set(null, JText::_('COM_EASYSOCIAL_PROFILE_APP_IS_NOT_INSTALLED_BY_USER'), SOCIAL_MSG_ERROR);
             return $this->redirect(FRoute::profile(array('id' => $user->getAlias()), false));
         }
         // Set the page title
         FD::page()->title(FD::string()->escape($user->getName()) . ' - ' . $app->get('title'));
         $contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id));
     }
     $layout = JRequest::getCmd('layout');
     // @since 1.3.7
     // If layout is empty, means we want to get the default view
     // Previously timeline is always the default
     if (empty($appId) && empty($layout)) {
         $defaultDisplay = FD::config()->get('users.profile.display', 'timeline');
         $layout = $defaultDisplay;
     }
     if ($layout === 'about') {
         FD::language()->loadAdmin();
         $currentStep = JRequest::getInt('step', 1);
         $steps = FD::model('Steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY);
         $fieldsLib = FD::fields();
         $fieldsModel = FD::model('Fields');
         $index = 1;
         foreach ($steps as $step) {
             $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
             if (!empty($step->fields)) {
                 $args = array($user);
                 $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_USER, $step->fields, $args);
             }
             $step->hide = true;
             foreach ($step->fields as $field) {
                 // As long as one of the field in the step has an output, then this step shouldn't be hidden
                 // If step has been marked false, then no point marking it as false again
                 // We don't break from the loop here because there is other checking going on
                 if (!empty($field->output) && $step->hide === true) {
                     $step->hide = false;
                 }
             }
             if ($index === 1) {
                 $step->url = FRoute::profile(array('id' => $user->getAlias(), 'layout' => 'about'), false);
             } else {
                 $step->url = FRoute::profile(array('id' => $user->getAlias(), 'layout' => 'about', 'step' => $index), false);
             }
             $step->title = $step->get('title');
             $step->active = !$step->hide && $currentStep == $index;
             if ($step->active) {
                 $theme = FD::themes();
                 $theme->set('fields', $step->fields);
                 $contents = $theme->output('site/events/item.info');
             }
             $step->index = $index;
             $index++;
         }
         $this->set('infoSteps', $steps);
     }
     // If contents is still empty at this point, then we just get the stream items as the content
     if (empty($contents)) {
         // Mark timeline item as the active one
         $this->set('timeline', true);
         // Retrieve user's stream
         $theme = FD::themes();
         // Get story
         $story = FD::get('Story', SOCIAL_TYPE_USER);
         $story->target = $user->id;
         $stream = FD::stream();
         $stream->get(array('userId' => $user->id, 'startlimit' => $startlimit));
         if (FD::user()->id) {
             // only logged in user can submit story.
             $stream->story = $story;
         }
         // Set stream to theme
         $theme->set('stream', $stream);
         $contents = $theme->output('site/profile/default.stream');
     }
     $this->set('contents', $contents);
     $privacy = $my->getPrivacy();
     // Let's test if the current viewer is allowed to view this profile.
     if ($my->id != $user->id) {
         if (!$privacy->validate('profiles.view', $user->id, SOCIAL_TYPE_USER)) {
             $this->set('user', $user);
             parent::display('site/profile/restricted');
             return;
         }
     }
     // Get user's cover object
     $cover = $user->getCoverData();
     $this->set('cover', $cover);
     // If we're setting a cover
     $coverId = JRequest::getInt('cover_id', null);
     if ($coverId) {
         // Load cover photo
         $newCover = FD::table('Photo');
         $newCover->load($coverId);
         // If the cover photo belongs to the user
         if ($newCover->isMine()) {
             // Then allow replacement of cover
             $this->set('newCover', $newCover);
         }
     }
     $photosModel = FD::model('Photos');
     $photos = array();
     // $photos 		= $photosModel->getPhotos( array( 'uid' => $user->id ) ); // not using? it seems like no one is referencing this photos.
     $totalPhotos = 0;
     // Retrieve list of apps for this user
     $appsModel = FD::model('Apps');
     $options = array('view' => 'profile', 'uid' => $user->id, 'key' => SOCIAL_TYPE_USER);
     $apps = $appsModel->getApps($options);
     // Set the apps lib
     $this->set('appsLib', $appsLib);
     $this->set('totalPhotos', $totalPhotos);
     $this->set('photos', $photos);
     $this->set('apps', $apps);
     $this->set('activeApp', $appId);
     $this->set('privacy', $privacy);
     $this->set('user', $user);
     // Load the output of the profile.
     echo parent::display('site/profile/default');
 }
コード例 #8
0
ファイル: accessrules.php プロジェクト: knigherrant/decopatio
 private function loadLanguage($extension = 'com_easysocial')
 {
     static $loaded = array();
     if (!in_array($extension, $loaded)) {
         $loaded[] = $extension;
         if ($extension === 'com_easysocial') {
             FD::apps()->loadAllLanguages();
         }
         JFactory::getLanguage()->load($extension, JPATH_ROOT . '/administrator');
         JFactory::getLanguage()->load($extension, JPATH_ROOT);
     }
     return true;
 }
コード例 #9
0
ファイル: events.php プロジェクト: ppantilla/bbninja
 /**
  * Creates a new event based on the session.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3
  * @access public
  * @param  SocialTableStepSession $session The step session.
  * @return SocialEvent                     The SocialEvent object.
  */
 public function createEvent(SocialTableStepSession $session)
 {
     FD::import('admin:/includes/event/event');
     $event = new SocialEvent();
     $event->creator_uid = FD::user()->id;
     $event->creator_type = SOCIAL_TYPE_USER;
     $event->category_id = $session->uid;
     $event->cluster_type = SOCIAL_TYPE_EVENT;
     $event->created = FD::date()->toSql();
     $event->key = md5(JFactory::getDate()->toSql() . FD::user()->password . uniqid());
     $params = FD::registry($session->values);
     // Support for group event
     if ($params->exists('group_id')) {
         $group = FD::group($params->get('group_id'));
         $event->setMeta('group_id', $group->id);
     }
     $data = $params->toArray();
     $customFields = FD::model('Fields')->getCustomFields(array('visible' => SOCIAL_EVENT_VIEW_REGISTRATION, 'group' => SOCIAL_TYPE_EVENT, 'uid' => $session->uid));
     $fieldsLib = FD::fields();
     $args = array(&$data, &$event);
     $callback = array($fieldsLib->getHandler(), 'beforeSave');
     $errors = $fieldsLib->trigger('onRegisterBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args, $callback);
     if (!empty($errors)) {
         $this->setError($errors);
         return false;
     }
     // Get the current user.
     $my = FD::user();
     $event->state = SOCIAL_CLUSTER_PENDING;
     // If the event is created by site admin or user doesn't need to be moderated, publish event immediately.
     if ($my->isSiteAdmin() || !$my->getAccess()->get('events.moderate')) {
         $event->state = SOCIAL_CLUSTER_PUBLISHED;
     }
     // Trigger apps
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $triggerArgs = array(&$event, &$my, true);
     // @trigger: onEventBeforeSave
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventBeforeSave', $triggerArgs);
     $state = $event->save();
     if (!$state) {
         $this->setError($event->getError());
         return false;
     }
     // Notifies admin when a new event is created
     if ($event->state === SOCIAL_CLUSTER_PENDING || !$my->isSiteAdmin()) {
         $this->notifyAdmins($event);
     }
     // Recreate the event object
     SocialEvent::$instances[$event->id] = null;
     $event = FD::event($event->id);
     // Create a new owner object
     $event->createOwner($my->id);
     // Support for group event
     if ($event->isGroupEvent()) {
         // Check for transfer flag to insert group member as event guest
         $transferMode = isset($data['member_transfer']) ? $data['member_transfer'] : 'invite';
         if (!empty($transferMode) && $transferMode != 'none') {
             $nodeState = SOCIAL_EVENT_GUEST_INVITED;
             if ($transferMode == 'attend') {
                 $nodeState = SOCIAL_EVENT_GUEST_GOING;
             }
             /*
             insert into jos_social_clusters_nodes (cluster_id, uid, type, created, state, owner, admin, invited_by)
                             select $eventId as cluster_id, uid, type, $now as created, $nodeState as state, 0 as owner, admin, $userId as invited_by from jos_social_clusters_nodes
                             where cluster_id = $groupId
                             and state = 1
                             and type = 'user'
                             and uid not in (select uid from jos_social_clusters_nodes where cluster_id = $eventId and type = 'user')
             */
             $eventId = $event->id;
             $groupId = $event->getMeta('group_id');
             $userId = $my->id;
             $now = FD::date()->toSql();
             $query = "INSERT INTO `#__social_clusters_nodes` (`cluster_id`, `uid`, `type`, `created`, `state`, `owner`, `admin`, `invited_by`) SELECT '{$eventId}' AS `cluster_id`, `uid`, `type`, '{$now}' AS `created`, '{$nodeState}' AS `state`, '0' AS `owner`, `admin`, '{$userId}' AS `invited_by` FROM `#__social_clusters_nodes` WHERE `cluster_id` = '{$groupId}' AND `state` = '" . SOCIAL_GROUPS_MEMBER_PUBLISHED . "' AND `type` = '" . SOCIAL_TYPE_USER . "' AND `uid` NOT IN (SELECT `uid` FROM `#__social_clusters_nodes` WHERE `cluster_id` = '{$eventId}' AND `type` = '" . SOCIAL_TYPE_USER . "')";
             $db = FD::db();
             $sql = $db->sql();
             $sql->raw($query);
             $db->setQuery($sql);
             $db->query();
         }
     }
     // Trigger the fields again
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onRegisterAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args);
     $event->bindCustomFields($data);
     $fieldsLib->trigger('onRegisterAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args);
     if (empty($event->alias)) {
         $event->alias = $this->getUniqueAlias($event->getName());
         $event->save();
     }
     // @trigger: onEventAfterSave
     $triggerArgs = array(&$event, &$my, true);
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventAfterSave', $triggerArgs);
     return $event;
 }
コード例 #10
0
ファイル: story.php プロジェクト: ppantilla/bbninja
 /**
  * Trigger to prepare the story item before being output.
  *
  * @since	1.0
  * @access	public
  */
 public function prepare()
 {
     // Load up the necessary apps
     FD::apps()->load($this->type);
     // Pass arguments by reference.
     $args = array(&$this);
     // Only go through dispatcher when there is some apps loaded, otherwise it's pointless.
     $dispatcher = FD::dispatcher();
     // StoryAttachment service
     $panels = $dispatcher->trigger($this->type, 'onPrepareStoryPanel', $args);
     if ($panels) {
         foreach ($panels as $panel) {
             if ($panel instanceof SocialStoryPanel) {
                 $this->panels[] = $panel;
                 $this->plugins[] = $panel;
             }
         }
     }
     return true;
 }
コード例 #11
0
ファイル: avatar.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Creates the necessary images to be used as an avatar.
  *
  * @since	1.0
  * @access	public
  * @param	SocialTablePhoto	The photo table
  * @param 	array 				options - createStream
  * @return
  */
 public function store(SocialTablePhoto &$photo, $options = array())
 {
     // setup the options.
     $createStream = isset($options['addstream']) ? $options['addstream'] : true;
     // default to true.
     // Check if there's a profile photos album that already exists.
     $model = FD::model('Albums');
     // Create default album if necessary
     $album = $model->getDefaultAlbum($this->uid, $this->type, SOCIAL_ALBUM_PROFILE_PHOTOS);
     // Load avatar table
     $avatarTable = FD::table('Avatar');
     $exists = $avatarTable->load(array('uid' => $this->uid, 'type' => $this->type));
     // Cleanup previous avatars only if they exist.
     if ($exists) {
         $this->cleanup($avatarTable);
     }
     // Create the images
     $this->create($avatarTable, $options);
     // Set the avatar composite indices.
     $avatarTable->uid = $this->uid;
     $avatarTable->type = $this->type;
     // Link the avatar to the photo
     $avatarTable->photo_id = $photo->id;
     // Unlink the avatar from gallery item
     $avatarTable->avatar_id = 0;
     // Set the last modified time to now.
     $avatarTable->modified = FD::date()->toMySQL();
     // We need to always reset the avatar back to "joomla"
     $avatarTable->storage = SOCIAL_STORAGE_JOOMLA;
     // Store the avatar now
     $avatarTable->store();
     // @points: profile.avatar.update
     // Assign points to the current user for uploading their avatar
     $photo->assignPoints('profile.avatar.update', $this->uid);
     // @Add stream item when a new profile avatar is uploaded
     if ($createStream) {
         $photo->addPhotosStream('uploadAvatar');
     }
     // Once the photo is finalized as the profile picture we need to update the state
     $photo->state = SOCIAL_STATE_PUBLISHED;
     // If album doesn't have a cover, set the current photo as the cover.
     if (!$album->hasCover()) {
         $album->cover_id = $photo->id;
         // Store the album
         $album->store();
     }
     // Prepare the dispatcher
     FD::apps()->load($this->type);
     if ($this->type == SOCIAL_TYPE_USER) {
         $node = FD::user($this->uid);
     } else {
         $node = FD::group($this->uid);
     }
     $args = array(&$photo, $node);
     $dispatcher = FD::dispatcher();
     // @trigger: onUserAvatarUpdate
     $dispatcher->trigger($this->type, 'onAvatarBeforeSave', $args);
     // Once it is created, store the photo as we need to update
     $state = $photo->store();
     // @trigger: onUserAvatarUpdate
     $dispatcher->trigger($this->type, 'onAvatarAfterSave', $args);
     return $state;
 }
コード例 #12
0
ファイル: events.php プロジェクト: BetterBetterBetter/B3App
 public function onBeforeStorySave(&$template, &$stream, &$content)
 {
     $params = $this->getParams();
     // Determine if we should attach ourselves here.
     if (!$params->get('story_event', true)) {
         return;
     }
     $in = FD::input();
     $title = $in->getString('event_title');
     $description = $in->getString('event_description');
     $categoryid = $in->getInt('event_category');
     $start = $in->getString('event_start');
     $end = $in->getString('event_end');
     $timezone = $in->getString('event_timezone');
     // If no category id, then we don't proceed
     if (empty($categoryid)) {
         return;
     }
     // Perhaps in the future we use FD::model('Event')->createEvent() instead.
     // For now just hardcode it here to prevent field triggering and figuring out how to punch data into the respective field data because the form is not rendered through field trigger.
     $my = FD::user();
     $event = FD::event();
     $event->title = $title;
     $event->description = $description;
     // Set a default params for this event first
     $event->params = '{"photo":{"albums":true},"news":true,"discussions":true,"allownotgoingguest":false,"allowmaybe":true,"guestlimit":0}';
     $event->type = SOCIAL_EVENT_TYPE_PUBLIC;
     $event->creator_uid = $my->id;
     $event->creator_type = SOCIAL_TYPE_USER;
     $event->category_id = $categoryid;
     $event->cluster_type = SOCIAL_TYPE_EVENT;
     $event->alias = FD::model('Events')->getUniqueAlias($title);
     $event->created = FD::date()->toSql();
     $event->key = md5($event->created . $my->password . uniqid());
     $event->state = SOCIAL_CLUSTER_PENDING;
     if ($my->isSiteAdmin() || !$my->getAccess()->get('events.moderate')) {
         $event->state = SOCIAL_CLUSTER_PUBLISHED;
     }
     // Trigger apps
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $triggerArgs = array(&$event, &$my, true);
     // @trigger: onEventBeforeSave
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventBeforeSave', $triggerArgs);
     $state = $event->save();
     // Notifies admin when a new event is created
     if ($event->state === SOCIAL_CLUSTER_PENDING || !$my->isSiteAdmin()) {
         FD::model('Events')->notifyAdmins($event);
     }
     // Set the meta for start end timezone
     $meta = $event->meta;
     $meta->cluster_id = $event->id;
     $meta->start = FD::date($start)->toSql();
     $meta->end = FD::date($end)->toSql();
     $meta->timezone = $timezone;
     $meta->store();
     // Recreate the event object
     $event = FD::event($event->id);
     // Create a new owner object
     $event->createOwner($my->id);
     // @trigger: onEventAfterSave
     $triggerArgs = array(&$event, &$my, true);
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventAfterSave', $triggerArgs);
     // Due to inconsistency, we don't use SOCIAL_TYPE_EVENT.
     // Instead we use "events" because app elements are named with 's', namely users, groups, events.
     $template->context_type = 'events';
     $template->context_id = $event->id;
     $template->cluster_access = $event->type;
     $template->cluster_type = $event->cluster_type;
     $template->cluster_id = $event->id;
     $params = array('event' => $event);
     $template->setParams(FD::json()->encode($params));
 }
コード例 #13
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Displays a user profile to a 3rd person perspective.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  **/
 public function display($tpl = null)
 {
     // Get the user's id.
     $id = $this->input->get('id', 0, 'int');
     // Check if there is any stream filtering or not.
     $filter = $this->input->get('type', '', 'word');
     // The current logged in user might be viewing their own profile.
     if ($id == 0) {
         $id = FD::user()->id;
     }
     // When the user tries to view his own profile but if he isn't logged in, throw a login page.
     if ($id == 0) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
     }
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Get the user's object.
     $user = FD::user($id);
     // If the user doesn't exist throw an error
     if (!$user->id) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
     }
     // If the user is blocked or the user doesn't have community access
     if ($this->my->id != $user->id && $this->my->isBlockedBy($user->id) || !$user->hasCommunityAccess()) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
     }
     // If the user is blocked, they should not be accessible
     if ($user->isBlock()) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
     }
     // Set the page properties
     $this->page->title($this->string->escape($user->getName()));
     $this->page->breadcrumb($this->string->escape($user->getName()));
     // Get the current user's privacy object
     $privacy = $this->my->getPrivacy();
     // Let's test if the current viewer is allowed to view this profile.
     if ($this->my->id != $user->id && !$privacy->validate('profiles.view', $user->id, SOCIAL_TYPE_USER)) {
         $this->set('user', $user);
         return parent::display('site/profile/restricted');
     }
     // Apply opengraph tags.
     FD::opengraph()->addProfile($user);
     // Do not assign badge if i view myself.
     if ($user->id != $this->my->id && $this->my->id) {
         // @badge: profile.view
         $badge = FD::badges();
         $badge->log('com_easysocial', 'profile.view', $this->my->id, JText::_('COM_EASYSOCIAL_PROFILE_VIEWED_A_PROFILE'));
     }
     // Get the limit start
     $startLimit = $this->input->get('limitstart', 0, 'int');
     // Determine if the current request is to load an app
     $appId = $this->input->get('appId', 0, 'int');
     // Get the apps library.
     $appsLib = FD::apps();
     // Default contents
     $contents = '';
     // Load the app when necessary
     if ($appId) {
         $app = FD::table('App');
         $app->load($appId);
         // Check if the user has access to this app
         if (!$app->accessible($user->id)) {
             FD::info()->set(false, JText::_('COM_EASYSOCIAL_PROFILE_APP_IS_NOT_INSTALLED_BY_USER'), SOCIAL_MSG_ERROR);
             $redirect = FRoute::profile(array('id' => $user->getAlias()), false);
             return $this->redirect($redirect);
         }
         // Set the page title
         $this->page->title(FD::string()->escape($user->getName()) . ' - ' . $app->get('title'));
         // Render the app contents
         $contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id));
     }
     // Get the layout
     $layout = $this->input->get('layout', '', 'cmd');
     // @since 1.3.7
     // If layout is empty, means we want to get the default view
     // Previously timeline is always the default
     if (empty($appId) && empty($layout) && $filter != 'appFilter') {
         $defaultDisplay = $this->config->get('users.profile.display', 'timeline');
         $layout = $defaultDisplay;
     }
     // Default variables
     $timeline = null;
     $newCover = false;
     // Viewing info of a user.
     if ($layout === 'about') {
         $showTimeline = false;
         $usersModel = FD::model('Users');
         $steps = $usersModel->getAbout($user);
         // We should generate a canonical link if user is viewing the about section and the default page is about
         if ($this->config->get('users.profile.display') == 'about') {
             $this->page->canonical($user->getPermalink(false, true));
         }
         if ($steps) {
             foreach ($steps as $step) {
                 if ($step->active) {
                     $theme = FD::themes();
                     $theme->set('fields', $step->fields);
                     $contents = $theme->output('site/events/item.info');
                 }
             }
         }
         $this->set('infoSteps', $steps);
     }
     // Should we filter stream items by specific app types
     $appType = $this->input->get('filterid', '', 'string');
     // If contents is still empty at this point, then we just get the stream items as the content
     if (empty($contents) || $filter == 'appFilter') {
         // Should the timeline be active
         $timeline = true;
         // Retrieve user's stream
         $theme = FD::themes();
         // Get story
         $story = FD::story(SOCIAL_TYPE_USER);
         $story->target = $user->id;
         // Get the stream
         $stream = FD::stream();
         //lets get the sticky posts 1st
         $stickies = $stream->getStickies(array('userId' => $user->id, 'limit' => 0));
         if ($stickies) {
             $stream->stickies = $stickies;
         }
         $streamOptions = array('userId' => $user->id, 'nosticky' => true, 'startlimit' => $startLimit);
         if ($filter == 'appFilter') {
             $timeline = false;
             $streamOptions['actorId'] = $user->id;
         }
         if ($appType) {
             $streamOptions['context'] = $appType;
             // Should this be set now or later
             $stream->filter = 'custom';
         }
         $stream->get($streamOptions);
         // Only registered users can access the story form
         if (!$this->my->guest) {
             $stream->story = $story;
         }
         // Set stream to theme
         $theme->set('stream', $stream);
         $contents = $theme->output('site/profile/default.stream');
     }
     // Get user's cover object
     $cover = $user->getCoverData();
     // If we're setting a cover
     $coverId = $this->input->get('cover_id', 0, 'int');
     // Load cover photo
     if ($coverId) {
         $coverTable = FD::table('Photo');
         $coverTable->load($coverId);
         // If the cover photo belongs to the user
         if ($coverTable->isMine()) {
             $newCover = $coverTable;
         }
     }
     $streamModel = FD::model('Stream');
     // Get a list of application filters
     $appFilters = $streamModel->getAppFilters(SOCIAL_TYPE_USER);
     // Retrieve list of apps for this user
     $appsModel = FD::model('Apps');
     $options = array('view' => 'profile', 'uid' => $user->id, 'key' => SOCIAL_TYPE_USER);
     $apps = $appsModel->getApps($options);
     $this->set('appFilters', $appFilters);
     $this->set('filterId', $appType);
     $this->set('timeline', $timeline);
     $this->set('newCover', $newCover);
     $this->set('cover', $cover);
     $this->set('contents', $contents);
     $this->set('appsLib', $appsLib);
     $this->set('apps', $apps);
     $this->set('activeApp', $appId);
     $this->set('privacy', $privacy);
     $this->set('user', $user);
     // Load the output of the profile.
     return parent::display('site/profile/default');
 }
コード例 #14
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Displays the application in a main canvas layout which is the full width of the component.
  * Example:
  * 		index.php?option=com_easysocial&view=apps&layout=canvas&id=[id]&appView=[appView]
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  *
  */
 public function canvas()
 {
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Get the unique id of the item that is being viewed
     $uid = $this->input->get('uid', null, 'int');
     $type = $this->input->get('type', SOCIAL_TYPE_USER, 'word');
     // Determines if the type is accessible
     if (!$this->allowed($uid, $type)) {
         return;
     }
     // Get the current app id.
     $id = $this->input->get('id', 0, 'int');
     // Get the current app.
     $app = FD::table('App');
     $state = $app->load($id);
     // Default redirection url
     $redirect = FRoute::dashboard(array(), false);
     // Check if the user has access to this app
     if (!$app->accessible($uid, $type) && $type == SOCIAL_TYPE_USER) {
         $this->info->set(null, JText::_('COM_EASYSOCIAL_APPS_CANVAS_APP_IS_NOT_INSTALLED'), SOCIAL_MSG_ERROR);
         return $this->redirect($redirect);
     }
     // If id is not provided, we need to throw some errors here.
     if (!$id || !$state) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_APPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         $info->set($this->getMessage());
         return $this->redirect($redirect);
     }
     // Try to load the app's css.
     $app->loadCss();
     // Check if the app provides any custom view
     $appView = $this->input->get('customView', 'canvas', 'default');
     // We need to set the breadcrumb for the cluster type
     if ($type == 'group') {
         $group = FD::group($uid);
         $this->page->breadcrumb($group->getName());
     }
     // Set the breadcrumbs with the app's title
     $this->page->breadcrumb($app->get('title'));
     // Load the library.
     $lib = FD::apps();
     $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_CANVAS, $appView, $app, array('uid' => $uid));
     $this->set('uid', $uid);
     $this->set('contents', $contents);
     $template = 'site/apps/default.canvas.' . strtolower($type);
     echo parent::display($template);
 }
コード例 #15
0
ファイル: comments.php プロジェクト: knigherrant/decopatio
 public function delete()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Only registered users are allowed here.
     FD::requireLogin();
     // Get the view
     $view = FD::view('comments', false);
     // Check for permission first
     $access = FD::access();
     // Get the comment id
     $id = JRequest::getInt('id', 0);
     // Get the current logged in user
     $my = FD::user();
     // Load the comment object
     $table = FD::table('comments');
     $state = $table->load($id);
     if (!$state) {
         $view->setMessage($table->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // There are cases where the app may need to allow the user to delete the comments.
     $apps = FD::apps();
     $apps->load(SOCIAL_TYPE_USER);
     $args = array(&$table, &$my);
     $dispatcher = FD::dispatcher();
     $allowed = $dispatcher->trigger(SOCIAL_TYPE_USER, 'canDeleteComment', $args);
     if ($my->isSiteAdmin() || $access->allowed('comments.delete') || $table->isAuthor() && $access->allowed('comments.deleteown') || in_array(true, $allowed)) {
         $state = $table->delete();
         if (!$state) {
             $view->setMessage($table->getError(), SOCIAL_MSG_ERROR);
         }
     } else {
         $view->setMessage(JText::_('COM_EASYSOCIAL_COMMENTS_NOT_ALLOWED_TO_DELETE'), SOCIAL_MSG_ERROR);
     }
     return $view->call(__FUNCTION__);
 }
コード例 #16
0
ファイル: users.php プロジェクト: knigherrant/decopatio
 /**
  * Stores the user object
  *
  * @since	1.0
  * @access	public
  */
 public function store()
 {
     // Check for request forgeries
     FD::checkToken();
     // Load front end's language file
     FD::language()->loadSite();
     // Get the current task
     $task = $this->getTask();
     // Determine if this is an edited user.
     $id = $this->input->get('id', 0, 'int');
     $id = !$id ? null : $id;
     // Get the posted data
     $post = $this->input->getArray('post');
     // this should come from backend user management page only.
     $autoApproval = isset($post['autoapproval']) ? $post['autoapproval'] : 0;
     // Create an options array for custom fields
     $options = array();
     if (!$id) {
         $user = new SocialUser();
         // Get the profile id
         $profileId = $this->input->get('profileId');
     } else {
         // Here we assume that the user record already exists.
         $user = FD::user($id);
         // Get the profile id from the user
         $profileId = $user->getProfile()->id;
         $options['data'] = true;
         $options['dataId'] = $id;
         $options['dataType'] = SOCIAL_TYPE_USER;
     }
     // Set the profile id
     $options['profile_id'] = $profileId;
     // Set the group
     $options['group'] = SOCIAL_FIELDS_GROUP_USER;
     // Load the profile
     $profile = FD::table('Profile');
     $profile->load($profileId);
     // Set the visibility
     // since this is at backend so we assume admin is editing someone else.
     if (!$id) {
         $options['visible'] = SOCIAL_PROFILES_VIEW_REGISTRATION;
     }
     // Get fields model
     $fieldsModel = ES::model('Fields');
     // Get the custom fields
     $fields = $fieldsModel->getCustomFields($options);
     // Initialize default registry
     $registry = ES::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(ES::token(), 'option', 'task', 'controller', 'autoapproval');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Test to see if the points has changed.
     $points = $this->input->get('points', 0, 'int');
     // Lets get the difference of the points
     $userPoints = $user->getPoints();
     // If there is a difference, the admin may have altered the user points
     if ($userPoints != $points) {
         // Insert a new points record for this new adjustments.
         if ($points > $userPoints) {
             // If the result points is larger, we always need to subtract and get the balance.
             $totalPoints = $points - $userPoints;
         } else {
             // If the result points is smaller, we always need to subtract.
             $totalPoints = -($userPoints - $points);
         }
         $pointsLib = FD::points();
         $pointsLib->assignCustom($user->id, $totalPoints, JText::_('COM_EASYSOCIAL_POINTS_ADJUSTMENTS'));
         $user->points = $points;
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Get the fields lib
     $fieldsLib = FD::fields();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$user);
     // @trigger onAdminEditValidate
     $errors = $fieldsLib->trigger('onAdminEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $this->view->call('form', $errors);
     }
     // @trigger onAdminEditBeforeSave
     $errors = $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     if (is_array($errors) && count($errors) > 0) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $this->view->call('form', $errors);
     }
     // Update the user's gid
     $gid = $this->input->get('gid', array(), 'array');
     $data['gid'] = $gid;
     // Bind the user object with the form data.
     $user->bind($data);
     // Create a new user record if the id don't exist yet.
     if (!$id) {
         $model = ES::model('Users');
         $user = $model->create($data, $user, $profile);
         if (!$user) {
             $this->view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
             // We need to set the data into the post again because onEditValidate might have changed the data structure
             JRequest::set($data, 'post');
             return $this->view->call('form');
         }
         // If admin selected auto approval, automatically approve this user.
         if ($autoApproval) {
             $user->approve(false);
         }
         $message = $autoApproval ? JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY_AND_APPROVED') : JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY');
     } else {
         // If this was an edited user, save the user object.
         $user->save();
         $message = JText::_('COM_EASYSOCIAL_USERS_USER_UPDATED_SUCCESSFULLY');
     }
     // Reconstruct args
     $args = array(&$data, &$user);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Bind the custom fields for the user.
     $user->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$user);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$user, &$fields, &$data);
     // @trigger: onUserProfileUpdate
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserProfileUpdate', $args);
     // Process notifications
     if (isset($post['notifications']) && !empty($post['notifications'])) {
         $systemNotifications = $post['notifications']['system'];
         $emailNotifications = $post['notifications']['email'];
         // Store the notification settings for this user.
         $model = ES::model('Notifications');
         $model->saveNotifications($systemNotifications, $emailNotifications, $user);
     }
     // Process privacy items
     if (isset($post['privacy']) && !empty($post['privacy'])) {
         $resetPrivacy = isset($post['privacyReset']) ? true : false;
         $user->bindPrivacy($post['privacy'], $post['privacyID'], $post['privacyCustom'], $post['privacyOld'], $resetPrivacy);
     }
     $this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $this->view->call(__FUNCTION__, $task, $user);
 }
コード例 #17
0
ファイル: group.php プロジェクト: knigherrant/decopatio
 /**
  * Approves the user application
  *
  * @since	1.2
  * @access	public
  * @param	int		The user id
  * @return
  */
 public function approveUser($userId)
 {
     $member = FD::table('GroupMember');
     $member->load(array('cluster_id' => $this->id, 'uid' => $userId));
     $member->state = SOCIAL_GROUPS_MEMBER_PUBLISHED;
     $state = $member->store();
     // Additional triggers to be processed when the page starts.
     FD::apps()->load(SOCIAL_TYPE_GROUP);
     $dispatcher = FD::dispatcher();
     // Trigger: onComponentStart
     $dispatcher->trigger('user', 'onJoinGroup', array($userId, $this));
     // @points: groups.join
     // Add points when user joins a group
     $points = FD::points();
     $points->assign('groups.join', 'com_easysocial', $userId);
     // Publish on the stream
     if ($state) {
         // Add stream item so the world knows that the user joined the group
         $this->createStream($userId, 'join');
     }
     // Notify the user that his request to join the group has been approved
     $this->notifyMembers('approved', array('targets' => array($userId)));
     // Send notifications to group members when a new member joined the group
     $this->notifyMembers('join', array('userId' => $userId));
     return $state;
 }
コード例 #18
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Responsible to output the dashboard layout for the current logged in user.
  *
  * @since	1.0
  * @access	public
  * @param	string	The name of the template file to parse; automatically searches through the template paths.
  * @return	null
  * @author	Mark Lee <*****@*****.**>
  */
 public function display($tpl = null)
 {
     // If the user is not logged in, display the dashboard's unity layout.
     if ($this->my->guest) {
         return $this->displayGuest();
     }
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Default page title
     $title = $this->my->getName() . ' - ' . JText::_('COM_EASYSOCIAL_PAGE_TITLE_DASHBOARD');
     // Set the page breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_DASHBOARD'));
     // Get list of apps
     $model = FD::model('Apps');
     $options = array('view' => 'dashboard', 'uid' => $this->my->id, 'key' => SOCIAL_TYPE_USER);
     $apps = $model->getApps($options);
     // Load css for apps
     $model->loadAppCss($options);
     // Check if there is an app id in the current request as we need to show the app's content.
     $appId = $this->input->get('appId', 0, 'default');
     $contents = '';
     $isAppView = false;
     // If the user is viewing output from a particular app
     if ($appId) {
         $appId = (int) $appId;
         if (!$appId) {
             return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PAGE_IS_NOT_AVAILABLE'));
         }
         // Load the application.
         $app = FD::table('App');
         $app->load($appId);
         if (!$app->id) {
             return JError::raiseError(404, JText::_('COM_EASYSOCIAL_APP_NOT_FOUND'));
         }
         // Check if the user has access to this app
         if (!$app->accessible($this->my->id)) {
             FD::info()->set(null, JText::_('COM_EASYSOCIAL_DASHBOARD_APP_IS_NOT_INSTALLED'), SOCIAL_MSG_ERROR);
             return $this->redirect(FRoute::dashboard(array(), false));
         }
         $app->loadCss();
         // Generate the page title
         $title = $this->my->getName() . ' - ' . $app->get('title');
         // Load the library.
         $lib = FD::apps();
         $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'dashboard', $app, array('userId' => $this->my->id));
         $isAppView = true;
     }
     // Get the limit start
     $startlimit = $this->input->get('limitstart', 0, 'int');
     // Determine the start page for the user.
     $start = $this->config->get('users.dashboard.start');
     // Check if there is any stream filtering or not.
     $filter = $this->input->get('type', $start, 'word');
     if (!$filter) {
         $filter = $start;
     }
     // The filter 'all' is taken from the menu item the setting. all == user & friend, which mean in this case, is the 'me' filter.
     if ($filter == 'all') {
         $filter = 'me';
     }
     $listId = $this->input->get('listId', 0, 'int');
     $fid = '';
     // Used in conjunction with type=appFilter
     $filterId = '';
     // Determine if the current request is for "tags"
     $hashtag = $this->input->get('tag', '', 'default');
     $hashtagAlias = $hashtag;
     if (!empty($hashtag)) {
         $filter = 'hashtag';
     }
     // Retrieve user's groups
     $groupModel = FD::model('Groups');
     $groups = $groupModel->getUserGroups($this->my->id);
     // Retrieve user's events
     $eventModel = FD::model('Events');
     $events = $eventModel->getEvents(array('creator_uid' => $this->my->id, 'creator_type' => SOCIAL_TYPE_USER, 'ongoing' => true, 'upcoming' => true, 'ordering' => 'start', 'limit' => 5));
     // Retrieve user's status
     $story = FD::get('Story', SOCIAL_TYPE_USER);
     $story->setTarget($this->my->id);
     // Retrieve user's stream
     $stream = FD::stream();
     $stream->story = $story;
     // Determines if we should be rendering the group streams
     $groupId = false;
     $eventId = false;
     $tags = array();
     // Filter by specific list item
     if ($filter == 'list' && !empty($listId)) {
         $list = FD::table('List');
         $list->load($listId);
         $title = $this->my->getName() . ' - ' . $list->get('title');
         // Get list of users from this list.
         $friends = $list->getMembers();
         if ($friends) {
             $stream->get(array('listId' => $listId, 'startlimit' => $startlimit));
         } else {
             $stream->filter = 'list';
         }
     }
     // Filter by specific #hashtag
     if ($filter == 'hashtag') {
         $tag = $this->input->get('tag', '', 'default');
         $hashtag = $tag;
         $title = $this->my->getName() . ' - #' . $tag;
         $stream->get(array('tag' => $tag, 'startlimit' => $startlimit));
         $tags = array($tag);
     }
     // Filter by everyone
     if ($filter == 'everyone') {
         $stream->get(array('guest' => true, 'ignoreUser' => true, 'startlimit' => $startlimit));
     }
     // Filter by following
     if ($filter == 'following') {
         // Set the page title
         $title = $this->my->getName() . ' - ' . JText::_('COM_EASYSOCIAL_DASHBOARD_FEED_FOLLLOW');
         $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => 'follow', 'startlimit' => $startlimit));
     }
     // Filter by bookmarks
     if ($filter == 'bookmarks') {
         // Set the page title
         $title = $this->my->getName() . ' - ' . JText::_('COM_EASYSOCIAL_DASHBOARD_FEED_DASHBOARD_BOOKMARKS');
         $stream->get(array('guest' => true, 'type' => 'bookmarks', 'startlimit' => $startlimit));
     }
     // Filter by sticky
     if ($filter == 'sticky') {
         // Set the page title
         $title = $this->my->getName() . ' - ' . JText::_('COM_EASYSOCIAL_DASHBOARD_FEED_DASHBOARD_STICKY');
         $stream->get(array('userId' => $this->my->id, 'type' => 'sticky', 'startlimit' => $startlimit));
     }
     // Filter by apps
     if ($filter == 'appFilter') {
         $appType = $this->input->get('filterid', '', 'string');
         $filterId = $appType;
         $stream->get(array('context' => $appType, 'startlimit' => $startlimit));
         $stream->filter = 'custom';
     }
     // Filter by custom filters
     if ($filter == 'filter') {
         $fid = $this->input->get('filterid', 0, 'int');
         $sfilter = FD::table('StreamFilter');
         $sfilter->load($fid);
         // Set the page title
         $title = $this->my->getName() . ' - ' . $sfilter->title;
         if ($sfilter->id) {
             $hashtags = $sfilter->getHashTag();
             $tags = explode(',', $hashtags);
             if ($tags) {
                 $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'tag' => $tags, 'startlimit' => $startlimit));
             }
         }
         $stream->filter = 'custom';
     }
     // Stream filter form
     if ($filter == 'filterForm') {
         // Set the page title
         $title = $this->my->getName() . ' - ' . JText::_('COM_EASYSOCIAL_PAGE_TITLE_FILTER_FORM');
         $id = $this->input->get('id', 0, 'int');
         // Load up the theme lib so we can output the contents
         $theme = FD::themes();
         $filter = FD::table('StreamFilter');
         $filter->load($id);
         $theme->set('filter', $filter);
         $contents = $theme->output('site/stream/form.edit');
     }
     // Filter by groups
     if ($filter == 'group') {
         $id = $this->input->get('groupId', 0, 'int');
         $group = FD::group($id);
         $groupId = $group->id;
         // Check if the user is a member of the group
         if (!$group->isMember()) {
             $this->setMessage(JText::_('COM_EASYSOCIAL_STREAM_GROUPS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR);
             FD::info()->set($this->getMessage());
             return $this->redirect(FRoute::dashboard(array(), false));
         }
         // When posting stories into the stream, it should be made to the group
         $story = FD::get('Story', SOCIAL_TYPE_GROUP);
         $story->setCluster($group->id, SOCIAL_TYPE_GROUP);
         $story->showPrivacy(false);
         $stream->story = $story;
         //lets get the sticky posts 1st
         $stickies = $stream->getStickies(array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'limit' => 0));
         if ($stickies) {
             $stream->stickies = $stickies;
         }
         $stream->get(array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'nosticky' => true, 'startlimit' => $startlimit));
     }
     if ($filter == 'event') {
         $id = $this->input->get('eventId', 0, 'int');
         $event = FD::event($id);
         $eventId = $event->id;
         // Check if the user is a member of the group
         if (!$event->getGuest()->isGuest()) {
             $this->setMessage(JText::_('COM_EASYSOCIAL_STREAM_GROUPS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR);
             $this->info->set($this->getMessage());
             return $this->redirect(FRoute::dashboard(array(), false));
         }
         // When posting stories into the stream, it should be made to the group
         $story = FD::get('Story', SOCIAL_TYPE_EVENT);
         $story->setCluster($event->id, SOCIAL_TYPE_EVENT);
         $story->showPrivacy(false);
         $stream->story = $story;
         //lets get the sticky posts 1st
         $stickies = $stream->getStickies(array('clusterId' => $event->id, 'clusterType' => SOCIAL_TYPE_EVENT, 'limit' => 0));
         if ($stickies) {
             $stream->stickies = $stickies;
         }
         $stream->get(array('clusterId' => $event->id, 'clusterType' => SOCIAL_TYPE_EVENT, 'nosticky' => true, 'startlimit' => $startlimit));
     }
     if ($filter == 'me') {
         $stream->get(array('startlimit' => $startlimit));
     }
     // Set the page title.
     FD::page()->title($title);
     // Set hashtags
     $story->setHashtags($tags);
     // Retrieve lists model
     $listsModel = FD::model('Lists');
     // Only fetch x amount of list to be shown by default.
     $limit = $this->config->get('lists.display.limit');
     // Get the friend's list.
     $lists = $listsModel->setLimit($limit)->getLists(array('user_id' => $this->my->id, 'showEmpty' => $this->config->get('friends.list.showEmpty')));
     // Get stream filter list
     $model = FD::model('Stream');
     $filterList = $model->getFilters($this->my->id);
     // Add RSS feed for dashboard
     $feedOptions = array('filter' => $filter);
     if ($hashtag) {
         $feedOptions['tag'] = $hashtag;
     } else {
         if ($filter == 'filter') {
             $feedOptions['filterid'] = $fid . ':' . $sfilter->alias;
         } else {
             if ($filter == 'list') {
                 $feedOptions['listId'] = $listId;
             } else {
                 $id = $this->input->get('id', 0, 'int');
                 if ($id) {
                     $feedOptions['id'] = $id;
                 }
             }
         }
     }
     if ($this->config->get('stream.rss.enabled')) {
         $this->addRss(FRoute::dashboard($feedOptions, false));
     }
     // Get a list of application filters
     $appFilters = $model->getAppFilters(SOCIAL_TYPE_USER);
     $this->set('rssLink', $this->rssLink);
     $this->set('title', $title);
     $this->set('eventId', $eventId);
     $this->set('events', $events);
     $this->set('filterId', $filterId);
     $this->set('appFilters', $appFilters);
     $this->set('groupId', $groupId);
     $this->set('groups', $groups);
     $this->set('hashtag', $hashtag);
     $this->set('hashtagAlias', $hashtagAlias);
     $this->set('listId', $listId);
     $this->set('filter', $filter);
     $this->set('isAppView', $isAppView);
     $this->set('apps', $apps);
     $this->set('lists', $lists);
     $this->set('appId', $appId);
     $this->set('contents', $contents);
     $this->set('user', $this->my);
     $this->set('stream', $stream);
     $this->set('filterList', $filterList);
     $this->set('fid', $fid);
     echo parent::display('site/dashboard/default');
 }
コード例 #19
0
ファイル: app.php プロジェクト: ppantilla/bbninja
 /**
  * Render's application parameters form.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	string	HTML codes.
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function renderForm($type = 'form', $params = null, $prefix = '', $tabs = false)
 {
     // Get the manifest path.
     $file = $this->getManifestPath($type);
     if ($file === false) {
         return false;
     }
     $registry = FD::makeObject($file);
     // Check for custom callbacks
     foreach ($registry as &$section) {
         foreach ($section->fields as &$field) {
             if (isset($field->callback)) {
                 $callable = FD::apps()->getCallable($field->callback);
                 if (!$callable) {
                     continue;
                 }
                 $field->options = call_user_func_array($callable, array($this));
             }
         }
     }
     // Get the parameter object.
     $form = FD::get('Form');
     $form->load($registry);
     if ($params) {
         $form->bind($params);
     } else {
         // Bind the stored data with the params.
         $form->bind($this->params);
     }
     // Get the HTML output.
     return $form->render($tabs, false, '', $prefix);
 }
コード例 #20
0
 /**
  * Renders widget output on a theme file.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function renderWidgets($group, $view, $position)
 {
     $apps = FD::apps();
     $args = func_get_args();
     $args = isset($args[3]) ? $args[3] : array();
     return $apps->renderWidgets($group, $view, $position, $args);
 }
コード例 #21
0
ファイル: view.ajax.php プロジェクト: knigherrant/decopatio
 /**
  * Retrieves the app contents
  *
  * @since	1.0
  * @access	public
  */
 public function getAppContents($app, $userId)
 {
     $ajax = FD::ajax();
     // If there's an error throw it back to the caller.
     if ($this->hasErrors()) {
         return $ajax->reject($this->getMessage());
     }
     // Get the current logged in user.
     $user = FD::user($userId);
     // Load the library.
     $lib = FD::apps();
     $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id));
     // Return the contents
     return $ajax->resolve($contents);
 }
コード例 #22
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Default method to display the group entry page.
  *
  * @since	1.2
  * @access	public
  * @author	Mark Lee <*****@*****.**>
  */
 public function item($tpl = null)
 {
     // Check if this feature is enabled.
     $this->checkFeature();
     // Check for user profile completeness
     FD::checkCompleteProfile();
     $id = $this->input->get('id', 0, 'int');
     $group = FD::group($id);
     // Check if the group is valid
     if (!$id || !$group->id) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND'));
     }
     // Ensure that the group is published
     if (!$group->isPublished()) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_UNAVAILABLE'), SOCIAL_MSG_ERROR);
         FD::info()->set($this->getMessage());
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Check if the group is accessible
     if ($group->isInviteOnly() && !$group->isMember() && !$group->isInvited() && !$this->my->isSiteAdmin()) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
         FD::info()->set($this->getMessage());
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // If the user is not the owner and the user has been blocked by the group creator
     if ($this->my->id != $group->creator_uid && $this->my->isBlockedBy($group->creator_uid)) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND'));
     }
     // Set the page title.
     $this->page->title($group->getName());
     // Set the breadcrumbs for the group
     $this->page->breadcrumb(JText::_('COM_EASYSOCIAL_GROUPS_PAGE_TITLE'), FRoute::groups());
     $this->page->breadcrumb($group->getName());
     $this->set('group', $group);
     if (($group->isInviteOnly() || $group->isClosed()) && !$group->isMember() && !$this->my->isSiteAdmin()) {
         // Display private group contents;
         return parent::display('site/groups/restricted');
     }
     // Update the hit counter
     $group->hit();
     // Get the start limit
     $startlimit = $this->input->get('limitstart', 0, 'int');
     // Get the context
     $context = $this->input->get('app', '', 'cmd');
     // Get group's filter for this logged in user.
     $filters = $group->getFilters($this->my->id);
     // Get a list of application filters
     $streamModel = FD::model('Stream');
     $appFilters = $streamModel->getAppFilters(SOCIAL_TYPE_GROUP);
     $this->set('context', $context);
     $this->set('filters', $filters);
     $this->set('appFilters', $appFilters);
     // Load list of apps for this group
     $model = FD::model('Apps');
     // Retrieve apps
     $apps = $model->getGroupApps($group->id);
     // We need to load the app's own css file.
     foreach ($apps as $app) {
         $app->loadCss();
     }
     $this->set('apps', $apps);
     $appId = $this->input->get('appId', 0, 'int');
     $contents = '';
     $isAppView = false;
     if ($appId) {
         // Load the application.
         $app = FD::table('App');
         $app->load($appId);
         $app->loadCss();
         FD::page()->title($group->getName() . ' - ' . $app->get('title'));
         FD::page()->breadcrumb($app->get('title'));
         // Load the library.
         $lib = FD::apps();
         $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'groups', $app, array('groupId' => $group->id));
         $isAppView = true;
     }
     $this->set('appId', $appId);
     // Determines if we should display the custom content based on type.
     $type = $this->input->get('type', '', 'cmd');
     if (!$isAppView && empty($type)) {
         $type = FD::config()->get('groups.item.display', 'timeline');
     }
     $filterId = $this->input->get('filterId', 0, 'int');
     if ($type == 'filterForm') {
         $theme = FD::themes();
         $streamFilter = FD::table('StreamFilter');
         if ($filterId) {
             $streamFilter->load($filterId);
         }
         $theme->set('controller', 'groups');
         $theme->set('filter', $streamFilter);
         $theme->set('uid', $group->id);
         $contents = $theme->output('site/stream/form.edit');
     }
     if ($type == 'info') {
         FD::language()->loadAdmin();
         $currentStep = JRequest::getInt('step', 1);
         $steps = FD::model('Steps')->getSteps($group->category_id, SOCIAL_TYPE_CLUSTERS, SOCIAL_GROUPS_VIEW_DISPLAY);
         $fieldsLib = FD::fields();
         $fieldsLib->init(array('privacy' => false));
         $fieldsModel = FD::model('Fields');
         $index = 1;
         foreach ($steps as $step) {
             $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP, 'visible' => SOCIAL_GROUPS_VIEW_DISPLAY));
             if (!empty($step->fields)) {
                 $args = array($group);
                 $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_GROUP, $step->fields, $args);
             }
             $step->hide = true;
             foreach ($step->fields as $field) {
                 // As long as one of the field in the step has an output, then this step shouldn't be hidden
                 // If step has been marked false, then no point marking it as false again
                 // We don't break from the loop here because there is other checking going on
                 if (!empty($field->output) && $step->hide === true) {
                     $step->hide = false;
                 }
             }
             if ($index === 1) {
                 $step->url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'type' => 'info'), false);
             } else {
                 $step->url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'type' => 'info', 'infostep' => $index), false);
             }
             $step->title = $step->get('title');
             $step->active = !$step->hide && $currentStep == $index;
             if ($step->active) {
                 $theme = FD::themes();
                 $theme->set('fields', $step->fields);
                 $contents = $theme->output('site/groups/item.info');
             }
             $step->index = $index;
             $index++;
         }
         $this->set('infoSteps', $steps);
     }
     $this->set('type', $type);
     $this->set('filterId', $filterId);
     $this->set('contents', $contents);
     if (!empty($contents)) {
         return parent::display('site/groups/item');
     }
     // If no content, only we get the stream. No point getting stream and contents at the same time.
     // Retrieve group's stream
     $stream = FD::stream();
     // Determine if the current request is for "tags"
     $hashtag = $this->input->get('tag', 0);
     $hashtagAlias = $this->input->get('tag');
     // If there's a hash tag, try to get the actual title to display on the site
     if ($hashtag) {
         $tag = $stream->getHashTag($hashtag);
         $hashtag = $tag->title;
     }
     // Retrieve story form for group
     $story = FD::get('Story', SOCIAL_TYPE_GROUP);
     $story->setCluster($group->id, SOCIAL_TYPE_GROUP);
     $story->showPrivacy(false);
     if ($hashtag) {
         $story->setHashtags(array($hashtag));
     }
     // Only group members allowed to post story updates on group page.
     if ($group->isMember() || $this->my->isSiteAdmin()) {
         // Set the story data on the stream
         $stream->story = $story;
         // Get the group params
         $params = $group->getParams();
         // Ensure that the user has permissions to see the story form
         $permissions = $params->get('stream_permissions', null);
         // If permissions has been configured before.
         if (!is_null($permissions)) {
             // If the user is not an admin, ensure that permissions has member
             if (!$group->isAdmin() && !in_array('member', $permissions)) {
                 unset($stream->story);
             }
             // If the user is an admin, ensure that permissions has admin
             if ($group->isAdmin() && !in_array('admin', $permissions) && !$group->isOwner()) {
                 unset($stream->story);
             }
         }
     }
     //lets get the sticky posts 1st
     $stickies = $stream->getStickies(array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'limit' => 0));
     if ($stickies) {
         $stream->stickies = $stickies;
     }
     // lets get stream items for this group
     $options = array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'nosticky' => true);
     // stream filter id
     $filterId = $this->input->get('filterId', 0, 'int');
     if ($filterId) {
         $sfilter = FD::table('StreamFilter');
         $sfilter->load($filterId);
         $hashtags = $sfilter->getHashTag();
         $tags = explode(',', $hashtags);
         if ($tags) {
             $options['tag'] = $tags;
         }
     }
     // we only wan streams thats has this hashtag associated.
     if ($hashtag) {
         $options['tag'] = array($hashtag);
     }
     $options['startlimit'] = $startlimit;
     // Filter stream item by specific context type
     if ($context) {
         $options['context'] = $context;
     }
     if ($type == 'moderation') {
         $options['onlyModerated'] = true;
         unset($stream->story);
     }
     $stream->get($options);
     // Apply opengraph tags for the group.
     FD::opengraph()->addGroup($group);
     $this->set('context', $context);
     $this->set('stream', $stream);
     $this->set('hashtag', $hashtag);
     $this->set('hashtagAlias', $hashtagAlias);
     parent::display('site/groups/item');
 }
コード例 #23
0
ファイル: apps.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Allows apps to process a controller
  *
  * @since	1.2
  * @access	public
  */
 public function controller()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get the app
     $id = $this->input->get('appId', 0, 'int');
     $app = FD::table('App');
     $app->load($id);
     // Allow app to specify their own controller and task
     $controller = $this->input->get('appController', '', 'cmd');
     $task = $this->input->get('appTask', '', 'cmd');
     // Process the app's controller
     $lib = FD::apps();
     $lib->renderController($controller, $task, $app);
 }
コード例 #24
0
ファイル: user.php プロジェクト: ppantilla/bbninja
 /**
  * Allows caller to remove the user's avatar
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function removeAvatar()
 {
     $avatar = FD::table('Avatar');
     $state = $avatar->load(array('uid' => $this->id, 'type' => SOCIAL_TYPE_USER));
     if ($state) {
         $state = $avatar->delete();
         // Prepare the dispatcher
         FD::apps()->load(SOCIAL_TYPE_USER);
         $dispatcher = FD::dispatcher();
         $args = array(&$this, &$avatar);
         // @trigger: onUserAvatarRemove
         $dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserAvatarRemove', $args);
     }
     return $state;
 }
コード例 #25
0
 public function createAvatar($value, $uid, $createStream = true, $deleteImage = true)
 {
     $value = FD::makeObject($value);
     if (!empty($value->data)) {
         $value->data = FD::makeObject($value->data);
     }
     if ($value->type === 'remove') {
         $table = FD::table('avatar');
         $state = $table->load(array('uid' => $uid, 'type' => $this->group));
         if ($state) {
             $table->delete();
             if ($this->group == SOCIAL_TYPE_USER) {
                 $user = FD::user($uid);
                 // Prepare the dispatcher
                 FD::apps()->load(SOCIAL_TYPE_USER);
                 $dispatcher = FD::dispatcher();
                 $args = array(&$user, &$table);
                 // @trigger: onUserAvatarRemove
                 $dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserAvatarRemove', $args);
             }
         }
         return true;
     }
     if ($value->type === 'gallery') {
         $table = FD::table('avatar');
         $state = $table->load(array('uid' => $uid, 'type' => $this->group));
         if (!$state) {
             $table->uid = $uid;
             $table->type = $this->group;
         }
         $table->avatar_id = $value->source;
         $table->store();
         return true;
     }
     if ($value->type === 'upload') {
         $data = new stdClass();
         if (!empty($value->path)) {
             $image = FD::image();
             $image->load($value->path);
             $avatar = FD::avatar($image, $uid, $this->group);
             // Check if there's a profile photos album that already exists.
             $albumModel = FD::model('Albums');
             // Retrieve the user's default album
             $album = $albumModel->getDefaultAlbum($uid, $this->group, SOCIAL_ALBUM_PROFILE_PHOTOS);
             $photo = FD::table('Photo');
             $photo->uid = $uid;
             $photo->type = $this->group;
             $photo->user_id = $this->group == SOCIAL_TYPE_USER ? $uid : FD::user()->id;
             $photo->album_id = $album->id;
             $photo->title = $value->name;
             $photo->caption = '';
             $photo->ordering = 0;
             // We need to set the photo state to "SOCIAL_PHOTOS_STATE_TMP"
             $photo->state = SOCIAL_PHOTOS_STATE_TMP;
             // Try to store the photo first
             $state = $photo->store();
             if (!$state) {
                 $this->setError(JText::_('PLG_FIELDS_AVATAR_ERROR_CREATING_PHOTO_OBJECT'));
                 return false;
             }
             // Push all the ordering of the photo down
             $photosModel = FD::model('photos');
             $photosModel->pushPhotosOrdering($album->id, $photo->id);
             // If album doesn't have a cover, set the current photo as the cover.
             if (!$album->hasCover()) {
                 $album->cover_id = $photo->id;
                 // Store the album
                 $album->store();
             }
             // Get the photos library
             $photoLib = FD::get('Photos', $image);
             $storage = $photoLib->getStoragePath($album->id, $photo->id);
             $paths = $photoLib->create($storage);
             // Create metadata about the photos
             foreach ($paths as $type => $fileName) {
                 $meta = FD::table('PhotoMeta');
                 $meta->photo_id = $photo->id;
                 $meta->group = SOCIAL_PHOTOS_META_PATH;
                 $meta->property = $type;
                 $meta->value = $storage . '/' . $fileName;
                 $meta->store();
             }
             // Synchronize Indexer
             $indexer = FD::get('Indexer');
             $template = $indexer->getTemplate();
             $template->setContent($photo->title, $photo->caption);
             //$url 	= FRoute::photos(array('layout' => 'item', 'id' => $photo->getAlias()));
             $url = $photo->getPermalink();
             $url = '/' . ltrim($url, '/');
             $url = str_replace('/administrator/', '/', $url);
             $template->setSource($photo->id, SOCIAL_INDEXER_TYPE_PHOTOS, $photo->uid, $url);
             $template->setThumbnail($photo->getSource('thumbnail'));
             $indexer->index($template);
             // Crop the image to follow the avatar format. Get the dimensions from the request.
             if (!empty($value->data) && is_object($value->data)) {
                 $width = $value->data->width;
                 $height = $value->data->height;
                 $top = $value->data->top;
                 $left = $value->data->left;
                 $avatar->crop($top, $left, $width, $height);
             }
             $options = array();
             // Create the avatars now
             if (!$createStream) {
                 $options = array('addstream' => false);
             }
             $options['deleteimage'] = false;
             $avatar->store($photo, $options);
         }
         return true;
     }
 }
コード例 #26
0
ファイル: friends.php プロジェクト: ppantilla/bbninja
 /**
  * Allows caller to make a friend request from source to target
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function request($sourceId, $targetId, $state = SOCIAL_FRIENDS_STATE_PENDING)
 {
     // Do not allow user to create a friend request to himself
     if ($sourceId == $targetId) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_UNABLE_TO_ADD_YOURSELF'));
         return false;
     }
     // If they are already friends, ignore this.
     if ($this->isFriends($sourceId, $targetId)) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_ERROR_ALREADY_FRIENDS'));
         return false;
     }
     // Check if user has already previously requested this.
     if ($this->isFriends($sourceId, $targetId, SOCIAL_FRIENDS_STATE_PENDING)) {
         $this->setError(JText::_('COM_EASYSOCIAL_FRIENDS_ERROR_ALREADY_REQUESTED'));
         return false;
     }
     // If everything is okay, we proceed to add this request to the friend table.
     $table = FD::table('Friend');
     $table->setActorId($sourceId);
     $table->setTargetId($targetId);
     $table->setState($state);
     // Save the request
     $state = $table->store();
     $my = FD::user($sourceId);
     $user = FD::user($targetId);
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$table, $my, $user);
     // @trigger: onFriendRequest
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onFriendRequest', $args);
     // Send notification to the target when a user requests to be his / her friend.
     $params = array('requesterId' => $my->id, 'requesterAvatar' => $my->getAvatar(SOCIAL_AVATAR_LARGE), 'requesterName' => $my->getName(), 'requesterLink' => $my->getPermalink(true, true), 'requestDate' => FD::date()->toMySQL(), 'totalFriends' => $my->getTotalFriends(), 'totalMutualFriends' => $my->getTotalMutualFriends($user->id));
     // Email template
     $emailOptions = array('actor' => $my->getName(), 'title' => 'COM_EASYSOCIAL_EMAILS_FRIENDS_NEW_REQUEST_SUBJECT', 'template' => 'site/friends/request', 'params' => $params);
     FD::notify('friends.request', array($user->id), $emailOptions, false);
     // @badge: friends.create
     // Assign badge for the person that initiated the friend request.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'friends.create', $my->id, JText::_('COM_EASYSOCIAL_FRIENDS_BADGE_REQUEST_TO_BE_FRIEND'));
     return $table;
 }
コード例 #27
0
ファイル: profile.php プロジェクト: ppantilla/bbninja
 /**
  * Save user's information.
  *
  * @since	1.0
  * @access	public
  */
 public function save()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is registered
     FD::requireLogin();
     // Clear previous session
     $session = JFactory::getSession();
     $session->clear('easysocial.profile.errors', SOCIAL_SESSION_NAMESPACE);
     // Get post data.
     $post = JRequest::get('POST');
     // Get the current view.
     $view = $this->getCurrentView();
     // Get all published fields apps that are available in the current form to perform validations
     $fieldsModel = FD::model('Fields');
     // Get current user.
     $my = FD::user();
     // Only fetch relevant fields for this user.
     $options = array('profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER);
     $fields = $fieldsModel->getCustomFields($options);
     // Load json library.
     $json = FD::json();
     // Initialize default registry
     $registry = FD::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = $json->encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Perform field validations here. Validation should only trigger apps that are loaded on the form
     // @trigger onRegisterValidate
     $fieldsLib = FD::fields();
     // Get the general field trigger handler
     $handler = $fieldsLib->getHandler();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$my);
     // Ensure that there is no errors.
     // @trigger onEditValidate
     $errors = $fieldsLib->trigger('onEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args, array($handler, 'validate'));
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'profile', 'POST');
         JRequest::setVar('layout', 'edit', 'POST');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors, $data);
     }
     // @trigger onEditBeforeSave
     $errors = $fieldsLib->trigger('onEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args, array($handler, 'beforeSave'));
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'profile');
         JRequest::setVar('layout', 'edit');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors);
     }
     // Bind the my object with appropriate data.
     $my->bind($data);
     // Save the user object.
     $my->save();
     // Reconstruct args
     $args = array(&$data, &$my);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Bind custom fields for the user.
     $my->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$my);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Now we update the Facebook details if it is available
     $associatedFacebook = $this->input->get('associatedFacebook', 0, 'int');
     if (!empty($associatedFacebook)) {
         $facebookPull = $this->input->get('oauth_facebook_pull', null, 'default');
         $facebookPush = $this->input->get('oauth_facebook_push', null, 'default');
         $my = FD::user();
         $facebookTable = $my->getOAuth(SOCIAL_TYPE_FACEBOOK);
         if ($facebookTable) {
             $facebookTable->pull = $facebookPull;
             $facebookTable->push = $facebookPush;
             $facebookTable->store();
         }
     }
     // Add stream item to notify the world that this user updated their profile.
     $my->addStream('updateProfile');
     // Update indexer
     $my->syncIndex();
     // @points: profile.update
     // Assign points to the user when their profile is updated
     $points = FD::points();
     $points->assign('profile.update', 'com_easysocial', $my->id);
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$user, &$fields, &$data);
     // @trigger: onUserProfileUpdate
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserProfileUpdate', $args);
     // @trigger onProfileCompleteCheck
     // This should return an array of booleans to state which field is filled in.
     // We count the returned result since it will be an array of trues that marks the field that have data for profile completeness checking.
     // We do this after all the data has been saved, and we reget the fields from the model again.
     // We also need to reset the cached field data
     SocialTableField::$_fielddata = array();
     $fields = $fieldsModel->getCustomFields(array('profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER));
     $args = array(&$my);
     $completedFields = $fieldsLib->trigger('onProfileCompleteCheck', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     $table = FD::table('Users');
     $table->load(array('user_id' => $my->id));
     $table->completed_fields = count($completedFields);
     $table->store();
     $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ACCOUNT_UPDATED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $my);
 }
コード例 #28
0
 /**
  * Removes a friend
  *
  * @since	1.0
  * @access	public
  */
 public function unfriend()
 {
     // Check for request forgeries
     FD::checkToken();
     // User needs to be logged in.
     FD::requireLogin();
     // Get the current view.
     $view = $this->getCurrentView();
     // Get the target user that will be removed.
     $id = JRequest::getInt('id');
     // Get the current user.
     $my = FD::user();
     // Try to load up the friend table
     $friend = FD::table('Friend');
     $state = $friend->load($id);
     if (!$state || !$id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_FRIENDS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Need to ensure that the target or source of the friend belongs to the current user.
     if ($friend->actor_id != $my->id && $friend->target_id != $my->id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_FRIENDS_ERROR_NOT_YOUR_FRIEND'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Throw errors when there's a problem removing the friends
     if (!$friend->unfriend($my->id)) {
         $view->setMessage($friend->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$friend);
     // @trigger: onFriendRemoved
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onFriendRemoved', $args);
     return $view->call(__FUNCTION__);
 }
コード例 #29
0
ファイル: story.php プロジェクト: knigherrant/decopatio
 /**
  * Prepares the activity log for user's actions
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareActivityLog(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'story') {
         return;
     }
     // Stories wouldn't be aggregated
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_MINI;
     // @triggers: onPrepareStoryContent
     // Processes any apps to process the content.
     FD::apps()->load(SOCIAL_TYPE_USER);
     $args = array(&$story, &$stream);
     $dispatcher = FD::dispatcher();
     $result = $dispatcher->trigger(SOCIAL_TYPE_USER, 'onPrepareStoryContent', $args);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $this->set('result', $result);
     $stream->title = parent::display('logs/title.' . $stream->verb);
     $stream->content = parent::display('logs/content.' . $stream->verb);
     if ($includePrivacy) {
         $my = FD::user();
         // only activiy log can use stream->uid directly bcos now the uid is holding id from social_stream_item.id;
         $stream->privacy = FD::privacy($my->id)->form($stream->uid, SOCIAL_TYPE_STORY, $stream->actor->id, 'story.view', false, $stream->aggregatedItems[0]->uid);
     }
     return true;
 }
コード例 #30
0
ファイル: view.html.php プロジェクト: ppantilla/bbninja
 /**
  * Displays the event item page.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3
  * @access public
  */
 public function item()
 {
     // Check if events is enabled.
     $this->checkFeature();
     // Check for profile completeness
     FD::checkCompleteProfile();
     // Get the event id
     $id = $this->input->get('id', 0, 'int');
     // Load up the event
     $event = FD::event($id);
     // Set the default redirect url
     $defaultRedirect = FRoute::events(array(), false);
     if (empty($event) || empty($event->id)) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_INVALID_EVENT_ID'), SOCIAL_MSG_ERROR);
         return $this->redirect($defaultRedirect);
     }
     if (!$event->isPublished()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_EVENT_UNAVAILABLE'), SOCIAL_MSG_ERROR);
         return $this->redirect($defaultRedirect);
     }
     // Determines if the current user is a guest of this event
     $guest = $event->getGuest($this->my->id);
     if (!$this->my->isSiteAdmin() && $event->isInviteOnly() && !$guest->isParticipant()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_NO_ACCESS_TO_EVENT'), SOCIAL_MSG_ERROR);
         return $this->redirect($defaultRedirect);
     }
     // check if the current logged in user blocked by the event creator or not.
     if ($this->my->id != $event->creator_uid) {
         if (FD::user()->isBlockedBy($event->creator_uid)) {
             return JError::raiseError(404, JText::_('COM_EASYSOCIAL_EVENTS_EVENT_UNAVAILABLE'));
         }
     }
     // Support for group event
     // If user is not a group member, then redirect to group page
     if ($event->isGroupEvent()) {
         $group = FD::group($event->getMeta('group_id'));
         if (!$this->my->isSiteAdmin() && !$group->isMember()) {
             FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_EVENTS_NO_PERMISSION_TO_VIEW_EVENT'), SOCIAL_MSG_ERROR);
             return $this->redirect($group->getPermailnk());
         }
         $this->set('group', $group);
     }
     // Set the page title
     FD::page()->title($event->getName());
     // Set the breadcrumbs
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_EVENTS'), FRoute::events());
     FD::page()->breadcrumb($event->getName());
     $this->set('guest', $guest);
     $this->set('event', $event);
     if (!$this->my->isSiteAdmin() && !$event->isOpen() && !$guest->isGuest()) {
         return parent::display('site/events/restricted');
     }
     // Increment the hit counter
     $event->hit();
     // stream pagination
     $startlimit = JRequest::getInt('limitstart', 0);
     // Filter stream item by specific context type
     $context = $this->input->get('app', '', 'cmd');
     $this->set('context', $context);
     // Get a list of filters
     $filters = $event->getFilters($this->my->id);
     $this->set('filters', $filters);
     // Load up the stream model
     $streamModel = FD::model('Stream');
     $appFilters = $streamModel->getAppFilters(SOCIAL_TYPE_EVENT);
     $this->set('appFilters', $appFilters);
     // Get all apps for the event
     $appsModel = FD::model('Apps');
     $apps = $appsModel->getEventApps($event->id);
     // Load css files for the apps
     foreach ($apps as $app) {
         $app->loadCss();
     }
     $contents = '';
     $isAppView = false;
     // Determines if the current page is loading a specific app item
     $appId = $this->input->get('appId', 0, 'int');
     if ($appId) {
         $app = FD::table('App');
         $app->load($appId);
         $app->loadCss();
         FD::page()->title($event->getName() . ' - ' . $app->get('title'));
         $appsLib = FD::apps();
         $contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'events', $app, array('eventId' => $event->id));
         $isAppView = true;
     }
     // Type can be info or timeline
     // If type is info, then we load the info tab first instead of showing timleine first
     $type = $this->input->get('type', '', 'cmd');
     // @since 1.3.7
     // If type is empty, means we want to get the default view
     // Previously timeline is always the default
     if (!$isAppView && empty($type)) {
         $type = FD::config()->get('events.item.display', 'timeline');
     }
     // Determines if the current request is to filter specific items
     $filterId = $this->input->get('filterId', 0, 'int');
     // Load Stream filter table
     $streamFilter = FD::table('StreamFilter');
     if ($filterId) {
         $streamFilter->load($filterId);
     }
     $this->set('filterId', $filterId);
     // If the current view is to display filters form
     if ($type == 'filterForm' && $guest->isGuest()) {
         $theme = FD::themes();
         $theme->set('controller', 'events');
         $theme->set('filter', $streamFilter);
         $theme->set('uid', $event->id);
         $contents = $theme->output('site/stream/form.edit');
     }
     if ($type == 'info') {
         FD::language()->loadAdmin();
         $currentStep = JRequest::getInt('step', 1);
         $steps = FD::model('Steps')->getSteps($event->category_id, SOCIAL_TYPE_CLUSTERS, SOCIAL_EVENT_VIEW_DISPLAY);
         $fieldsLib = FD::fields();
         $fieldsLib->init(array('privacy' => false));
         $fieldsModel = FD::model('Fields');
         $index = 1;
         foreach ($steps as $step) {
             $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $event->id, 'dataType' => SOCIAL_TYPE_EVENT, 'visible' => SOCIAL_EVENT_VIEW_DISPLAY));
             if (!empty($step->fields)) {
                 $args = array($event);
                 $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_EVENT, $step->fields, $args);
             }
             $step->hide = true;
             foreach ($step->fields as $field) {
                 // As long as one of the field in the step has an output, then this step shouldn't be hidden
                 // If step has been marked false, then no point marking it as false again
                 // We don't break from the loop here because there is other checking going on
                 if (!empty($field->output) && $step->hide === true) {
                     $step->hide = false;
                 }
             }
             if ($index === 1) {
                 $step->url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'type' => 'info'), false);
             } else {
                 $step->url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'type' => 'info', 'infostep' => $index), false);
             }
             $step->title = $step->get('title');
             $step->active = !$step->hide && $currentStep == $index;
             if ($step->active) {
                 $theme = FD::themes();
                 $theme->set('fields', $step->fields);
                 $contents = $theme->output('site/events/item.info');
             }
             $step->index = $index;
             $index++;
         }
         $this->set('infoSteps', $steps);
     }
     $this->set('appId', $appId);
     $this->set('apps', $apps);
     $this->set('type', $type);
     $this->set('contents', $contents);
     if (!empty($contents)) {
         return parent::display('site/events/item');
     }
     // If no content then only we proceed to get the stream
     $stream = FD::stream();
     $streamOptions = array('clusterId' => $event->id, 'clusterType' => $event->cluster_type);
     // Load the story
     $story = FD::story($event->cluster_type);
     $story->setCluster($event->id, $event->cluster_type);
     $story->showPrivacy(false);
     // Determines if this is a hashtag
     $hashtag = $this->input->get('tag', 0, 'int');
     $hashtagAlias = $this->input->get('tag', '', 'default');
     if (!empty($hashtag)) {
         $tag = $stream->getHashTag($hashtag);
         if (!empty($tag->id)) {
             $this->set('hashtag', $tag->title);
             $this->set('hashtagAlias', $hashtagAlias);
             $story->setHashtags(array($tag->title));
             $streamOptions['tag'] = array($tag->title);
         }
     }
     if (!empty($streamFilter->id)) {
         $tags = $streamFilter->getHashtag();
         $tags = explode(',', $tags);
         $streamOptions['tag'] = $tags;
     }
     if ($guest->isGuest()) {
         $stream->story = $story;
     }
     $streamOptions['startlimit'] = $startlimit;
     if ($context) {
         $streamOptions['context'] = $context;
     }
     $stream->get($streamOptions);
     $this->set('stream', $stream);
     parent::display('site/events/item');
 }