Ejemplo n.º 1
0
// Add the view to the list of titles
if (isset($view)) {
    addView($title, $view);
}
if (isset($type)) {
    $title[] = $type;
    if (isset($uid)) {
        if ($type == SOCIAL_TYPE_USER) {
            $alias = getUserAlias($uid);
        }
        if ($type == SOCIAL_TYPE_GROUP) {
            $alias = getGroupAlias($uid);
        }
        if ($type == SOCIAL_TYPE_EVENT) {
            $alias = getEventAlias($uid);
        }
        $title[] = $alias;
        shRemoveFromGETVarsList('uid');
    }
    shRemoveFromGETVarsList('type');
}
// For photos, we need to get the beautiful title
if (isset($id)) {
    $id = (int) $id;
    $album = ES::table('Album');
    $album->load($id);
    $albumTitle = $album->core ? JText::_($album->title) : $album->title;
    $title[] = JFilterOutput::stringURLSafe($albumTitle);
    shRemoveFromGETVarsList('id');
    shRemoveFromGETVarsList('layout');
}
Ejemplo n.º 2
0
 /**
  * Updates a user profile
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function updateUserProfile($uid, $profileId)
 {
     $map = ES::table('ProfileMap');
     $exists = $map->load(array('user_id' => $uid));
     if (!$exists) {
         $map->user_id = $uid;
         $map->state = SOCIAL_STATE_PUBLISHED;
     }
     $map->profile_id = $profileId;
     $state = $map->store();
     if (!$state) {
         $this->setError($map->getError());
         return $state;
     }
     $db = ES::db();
     $sql = $db->sql();
     $sql->update('#__social_fields_data', 'a');
     $sql->leftjoin('#__social_fields', 'b');
     $sql->on('a.field_id', 'b.id');
     $sql->leftjoin('#__social_fields', 'c');
     $sql->on('b.unique_key', 'c.unique_key');
     $sql->leftjoin('#__social_fields_steps', 'd');
     $sql->on('c.step_id', 'd.id');
     $sql->set('a.field_id', 'c.id', false);
     $sql->where('a.uid', $uid);
     $sql->where('a.type', 'user');
     $sql->where('d.type', 'profiles');
     $sql->where('d.uid', $profileId);
     $db->setQuery($sql);
     $state = $db->query();
     if ($state) {
         // Update fields privacy according to the new profile
         $sql = $db->sql();
         // update `jos_social_privacy_items as a
         //  left join jos_social_fields as b
         //  	on a.uid = bid and a.type = 'field'
         //  left join jos_social_fields as c
         //  	on b.unique_key = c.unique_key
         //  left join jos_social_fields_steps as d
         //  	on c.step_id = d.id
         //  set a.uid = c.id
         //  where a.user_id = $uid
         //  and a.type = 'field'
         //  and d.type = 'profiles'
         //  and d.uid = $profileId;
         $sql->update('#__social_privacy_items', 'a');
         $sql->leftjoin('#__social_fields', 'b');
         $sql->on('a.uid', 'b.id');
         $sql->leftjoin('#__social_fields', 'c');
         $sql->on('b.unique_key', 'c.unique_key');
         $sql->leftjoin('#__social_fields_steps', 'd');
         $sql->on('c.step_id', 'd.id');
         $sql->set('a.uid', 'c.id', false);
         $sql->where('a.user_id', $uid);
         $sql->where('(');
         $sql->where('a.type', 'field');
         $sql->where('a.type', 'year', '=', 'OR');
         $sql->where(')');
         $sql->where('d.type', 'profiles');
         $sql->where('d.uid', $profileId);
         $db->setQuery($sql);
         $state = $db->query();
     }
     return $state;
 }
Ejemplo n.º 3
0
 /**
  * Saves a new or existing profile.
  *
  * @since   1.0
  * @access  public
  * @param   null
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function store()
 {
     // Check for request forgeries!
     ES::checkToken();
     $pid = $this->input->get('id', 0, 'int');
     $cid = $this->input->get('cid', 0, 'int');
     $post = $this->input->getArray('post');
     // Determines if this is a new profile type
     $isNew = !$pid ? true : false;
     // Get the current task
     $task = $this->getTask();
     $isCopy = $task == 'savecopy' ? true : false;
     // Load the profile type.
     $profile = ES::table('Profile');
     if ($cid && $isCopy) {
         $profile->load($cid);
         //reset the pid
         $post['id'] = $cid;
     } else {
         $profile->load($pid);
     }
     // Bind the posted data.
     $profile->bind($post);
     // Get the current task since we need to know what to do after the storing is successful.
     $this->view->task = $task;
     // Bind the user group's that are associated with the profile.
     $gid = $this->input->get('gid', '', 'default');
     // This is a minimum requirement to create a profile.
     if (!$gid) {
         $this->view->setMessage('COM_EASYSOCIAL_PROFILES_FORM_ERROR_SELECT_GROUP', SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__, $profile);
     }
     // Bind user groups for this profile.
     $profile->bindUserGroups($gid);
     // Validate the profile field.
     $valid = $profile->validate();
     // If there's errors, just show the error.
     if ($valid !== true) {
         $this->view->setMessage($profile->getError(), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__, $profile);
     }
     // Try to store the profile.
     if (!$profile->store()) {
         $this->view->setMessage($profile->getError(), SOCIAL_MSG_ERROR);
         return $this->view->store($profile);
     }
     // Bind the access
     $profile->bindAccess($post['access']);
     // If this profile is default, we need to ensure that the rest of the profiles are not default any longer.
     if ($profile->default) {
         $profile->makeDefault();
     }
     // Store the avatar for this profile.
     $file = $this->input->files->get('avatar', '');
     // Try to upload the profile's avatar if required
     if (!empty($file['tmp_name'])) {
         $profile->uploadAvatar($file);
     }
     // Get fields data separately as we need allowraw here
     $postfields = JRequest::getVar('fields', $default = null, $hash = 'POST', $type = 'none', $mask = JREQUEST_ALLOWRAW);
     // Set the fields for this profile type.
     if (!empty($postfields)) {
         $fieldsData = FD::json()->decode($postfields);
         $fieldsLib = FD::fields();
         $fieldsLib->saveFields($profile->id, SOCIAL_TYPE_PROFILES, $fieldsData, array('copy' => $task === 'savecopy'));
         // After saving fields, we have to reset all the user's completed fields count in this profile
         FD::model('Users')->resetCompletedFieldsByProfileId($profile->id);
     }
     // Set the privacy for this profile type
     if (isset($post['privacy'])) {
         $privacyLib = FD::privacy();
         $resetMap = $privacyLib->getResetMap('all');
         $privacy = $post['privacy'];
         $ids = $post['privacyID'];
         $requireReset = isset($post['privacyReset']) ? true : false;
         $data = array();
         if (count($privacy)) {
             foreach ($privacy as $group => $items) {
                 foreach ($items as $rule => $val) {
                     $id = $ids[$group][$rule];
                     $id = explode('_', $id);
                     $obj = new stdClass();
                     $obj->id = $id[0];
                     $obj->mapid = $id[1];
                     $obj->value = $val;
                     $obj->reset = false;
                     //check if require to reset or not.
                     $gr = strtolower($group . '.' . $rule);
                     if ($gr != 'field.joomla_username' && $gr != 'field.joomla_email' && $gr != 'field.joomla_timezone' && $gr != 'field.joomla_fullname') {
                         $gr = str_replace('_', '.', $gr);
                     }
                     if ($requireReset && in_array($gr, $resetMap)) {
                         $obj->reset = true;
                     }
                     $data[] = $obj;
                 }
             }
         }
         $privacyModel = FD::model('Privacy');
         $privacyModel->updatePrivacy($profile->id, $data, SOCIAL_PRIVACY_TYPE_PROFILES);
     }
     // If this is a save as copy
     if ($isCopy && $pid) {
         $profile->copyAvatar($pid);
     }
     $message = 'COM_EASYSOCIAL_PROFILES_PROFILE_CREATED_SUCCESSFULLY';
     if (!$isNew) {
         $message = 'COM_EASYSOCIAL_PROFILES_PROFILE_UPDATED_SUCCESSFULLY';
     }
     if ($isCopy) {
         $message = 'COM_EASYSOCIAL_PROFILES_PROFILE_COPIED_SUCCESSFULLY';
     }
     // Set message.
     $this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $this->view->call(__FUNCTION__, $profile);
 }
Ejemplo n.º 4
0
 /**
  * Edit privacy form
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function editPrivacy()
 {
     // User needs to be logged in
     FD::requireLogin();
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Get user's privacy
     $privacyLib = FD::privacy($this->my->id);
     $result = $privacyLib->getData();
     // Set page title
     $this->page->title('COM_EASYSOCIAL_PAGE_TITLE_PRIVACY_SETTINGS');
     // Set the page breadcrumb
     $this->page->breadcrumb('COM_EASYSOCIAL_PAGE_TITLE_PROFILE', FRoute::profile());
     $this->page->breadcrumb('COM_EASYSOCIAL_PAGE_TITLE_PRIVACY_SETTINGS');
     $privacy = array();
     // Update the privacy data with proper properties.
     foreach ($result as $group => $items) {
         // We do not want to show field privacy rules here because it does not make sense for user to set a default value
         // Most of the fields only have 1 and it is set in Edit Profile page
         if ($group === 'field') {
             continue;
         }
         // Only display such privacy rules if photos is enabled
         if (($group == 'albums' || $group == 'photos') && !$this->config->get('photos.enabled')) {
             continue;
         }
         // Do not display badges / achievements in privacy if badges is disabled
         if ($group == 'achievements' && !$this->config->get('badges.enabled')) {
             continue;
         }
         // Do not display followers privacy item
         if ($group == 'followers' && !$this->config->get('followers.enabled')) {
             continue;
         }
         foreach ($items as &$item) {
             // Conversations rule should only appear if it is enabled.
             if ($group == 'profiles' && $item->rule == 'post.message' && !$this->config->get('conversations.enabled')) {
                 unset($item);
             }
             $rule = JString::str_ireplace('.', '_', $item->rule);
             $rule = strtoupper($rule);
             $groupKey = strtoupper($group);
             // Determines if this has custom
             $item->hasCustom = $item->custom ? true : false;
             // If the rule is a custom rule, we need to set the ids
             $item->customIds = array();
             $item->customUsers = array();
             if ($item->hasCustom) {
                 foreach ($item->custom as $friend) {
                     $item->customIds[] = $friend->user_id;
                     $user = FD::user($friend->user_id);
                     $item->customUsers[] = $user;
                 }
             }
             // Try to find an app element that is related to the privacy type
             $app = ES::table('App');
             $appExists = $app->load(array('element' => $item->type));
             if ($appExists) {
                 $app->loadLanguage();
             }
             // Go through each options to get the selected item
             $item->selected = '';
             foreach ($item->options as $option => $value) {
                 if ($value) {
                     $item->selected = $option;
                 }
                 // We need to remove "Everyone" if the site lockdown is enabled
                 if ($this->config->get('general.site.lockdown.enabled') && $option == SOCIAL_PRIVACY_0) {
                     unset($item->options[$option]);
                 }
             }
             $item->groupKey = $groupKey;
             $item->label = JText::_('COM_EASYSOCIAL_PRIVACY_LABEL_' . $groupKey . '_' . $rule);
             $item->tips = JText::_('COM_EASYSOCIAL_PRIVACY_TIPS_' . $groupKey . '_' . $rule);
         }
         $privacy[$group] = $items;
     }
     // Get a list of blocked users for this user
     $blockModel = FD::model('Blocks');
     $blocked = $blockModel->getBlockedUsers($this->my->id);
     $this->set('blocked', $blocked);
     $this->set('privacy', $privacy);
     parent::display('site/profile/default.edit.privacy');
 }
Ejemplo n.º 5
0
 /**
  * Displays the join group dialog
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function joinGroup()
 {
     // Only logged in users are allowed here.
     FD::requireLogin();
     // Get the group id from request
     $id = $this->input->get('id', 0, 'int');
     // Determines if this is an api request
     $api = $this->input->get('api', false, 'bool');
     // Load up the group
     $group = ES::group($id);
     if (!$id || !$group) {
         return $this->ajax->reject();
     }
     // Try to load the member object
     $member = ES::table('GroupMember');
     $member->load(array('uid' => $this->my->id, 'type' => SOCIAL_TYPE_USER, 'cluster_id' => $group->id));
     // Determines which namespace we should be using
     $namespace = 'site/groups/dialog.join.open';
     // Check if the group is open or closed
     if ($group->isClosed()) {
         if ($member->state == SOCIAL_GROUPS_MEMBER_PUBLISHED) {
             $namespace = 'site/groups/dialog.join.invited';
         } else {
             $namespace = 'site/groups/dialog.join.closed';
         }
     }
     $theme = ES::themes();
     $theme->set('group', $group);
     $contents = $theme->output($namespace);
     return $this->ajax->resolve($contents);
 }