public function getProfileURL($userid, $task = '', $xhtml = true) { if ($userid) { $user = ES::user($userid); // When simple urls are enabled, we just hardcode the url $config = ES::config(); $jConfig = ES::jConfig(); if (!ES::isSh404Installed() && $config->get('users.simpleUrl') && $jConfig->getValue('sef')) { $url = rtrim(JURI::root(), '/') . '/' . $user->getAlias(false); return $url; } // If it's not configured for simple urls, just set the alias $alias = $user->getAlias(); } else { $alias = $userid; } $options = array('id' => $alias); if ($task) { $options['layout'] = $task; } $url = FRoute::profile($options, $xhtml); return $url; }
/** * 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; }
<?php include '../include/head.inc.php'; /* Define diretorio da aplicação */ $raizDir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR; // zera variaveis $return = ''; //$data = ''; /* Carrega biblioteca eleitor */ include $raizDir . 'lib' . DIRECTORY_SEPARATOR . 'estatistica.class.php'; //instancia classe $estatistica = new ES(); ?> <!-- Bootstrap core CSS --> <link href="../css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="../css/justified-nav.css" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="../assets/js/ie-emulation-modes-warning.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="../assets/js/ie10-viewport-bug-workaround.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]-->
/** * Delete stream items given the app type. * * @since 1.0 * @access public * @param */ public function delete($contextId, $contextType, $actorId = '', $verb = '') { // Load dispatcher. $dispatcher = ES::dispatcher(); $args = array($contextId, $contextType, $verb); // Trigger onBeforeStreamDelete $dispatcher->trigger(SOCIAL_APPS_GROUP_USER, 'onBeforeStreamDelete', $args); $dispatcher->trigger(SOCIAL_APPS_GROUP_GROUP, 'onBeforeStreamDelete', $args); $dispatcher->trigger(SOCIAL_APPS_GROUP_EVENT, 'onBeforeStreamDelete', $args); $model = FD::model('Stream'); $model->delete($contextId, $contextType, $actorId, $verb); // Trigger onAfterStreamDelete $dispatcher->trigger(SOCIAL_APPS_GROUP_USER, 'onAfterStreamDelete', $args); $dispatcher->trigger(SOCIAL_APPS_GROUP_GROUP, 'onAfterStreamDelete', $args); $dispatcher->trigger(SOCIAL_APPS_GROUP_EVENT, 'onAfterStreamDelete', $args); }
/** * Remove older javascript files * * @since 1.3 * @access public */ public static function purgeOldVersionScripts() { // Get the current installed version $version = ES::getLocalVersion(); // Ignored files $ignored = array('.svn', 'CVS', '.DS_Store', '__MACOSX'); $ignored[] = 'easysocial-' . $version . '.static.min.js'; $ignored[] = 'easysocial-' . $version . '.static.js'; $ignored[] = 'easysocial-' . $version . '.optimized.min.js'; $ignored[] = 'easysocial-' . $version . '.optimized.js'; $files = JFolder::files(JPATH_ROOT . '/media/com_easysocial/scripts', 'easysocial-', false, true, $ignored); if ($files) { foreach ($files as $file) { JFile::delete($file); } } return true; }
$file = JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php'; jimport('joomla.filesystem.file'); if (!JFile::exists($file)) { return; } // Include the engine file. require_once $file; FD::language()->loadSite(); // Check if Foundry exists if (!FD::exists()) { echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING'); return; } // Load up helper file require_once dirname(__FILE__) . '/helper.php'; $events = EasySocialModEventsHelper::getEvents($params); if (empty($events)) { return; } $my = ES::user(); // Load up the module engine $modules = FD::modules('mod_easysocial_events'); // We need foundryjs here $modules->loadComponentScripts(); $modules->loadComponentStylesheets(); // We need these packages $modules->addDependency('css', 'javascript'); // Get the layout to use. $layout = $params->get('layout', 'default'); $suffix = $params->get('suffix', ''); require JModuleHelper::getLayoutPath('mod_easysocial_events', $layout);
// 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'); }
/** * Retrieves the group template * * @since 1.3 * @access public * @param string * @return */ public function getGroupTemplate() { $ids = $this->input->get('groups', array(), 'array'); if (!$ids) { return $this->ajax->reject(); } $groups = array(); foreach ($ids as $id) { $group = ES::group($id); $groups[] = $group; } $theme = ES::themes(); $theme->set('groups', $groups); $html = $theme->output('admin/profiles/form.groups.item'); return $this->ajax->resolve($html); }
/** * Displays a the profile form when someone creates a new profile type or edits an existing profile. * * @since 1.0 * @access public * @param SocialTableProfile The profile object (Optional) * @return null * * @author Mark Lee <*****@*****.**> */ public function form($profile = '') { // Get the profile id from the request. $id = $this->input->get('id', 0, 'int'); // Add Joomla buttons here. $this->addButtons(__FUNCTION__); // Test if id is provided by the query string if (!$profile) { $profile = FD::table('Profile'); if ($id) { $state = $profile->load($id); if (!$state) { $this->info->set($this->getMessage()); return $this->redirect('index.php?option=com_easysocial&view=profiles'); } } } // Set the structure heading here. $this->setHeading('COM_EASYSOCIAL_TOOLBAR_TITLE_NEW_PROFILE_TYPE'); // If this is an edited profile, display the profile title. if (!empty($id)) { $this->setHeading($profile->get('title')); } $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_PROFILES_FORM'); // Default Values $defaultAvatars = array(); // load frontend language so that the custom fields languages display properly. FD::language()->loadSite(); // Only process the rest of the blocks of this is not a new item. if ($id) { // Get a list of users in this profile. $profilesModel = ES::model('Profiles'); // Get default avatars for this profile type. $avatarsModel = ES::model('Avatars'); $defaultAvatars = $avatarsModel->getDefaultAvatars($profile->id); // Get a list of available field apps $appsModel = ES::model('Apps'); $defaultApps = $appsModel->getApps(array('type' => SOCIAL_APPS_TYPE_FIELDS, 'group' => SOCIAL_FIELDS_GROUP_USER, 'state' => SOCIAL_STATE_PUBLISHED)); // Get a list of workflows for this profile type. $stepsModel = ES::model('Steps'); $steps = $stepsModel->getSteps($profile->id, SOCIAL_TYPE_PROFILES); // Get a list of fields based on the id $fieldsModel = ES::model('Fields'); $fields = $fieldsModel->getCustomFields(array('profile_id' => $profile->id, 'state' => 'all')); $data = array(); // @field.triggers: onSample $lib = FD::fields(); $lib->trigger('onSample', SOCIAL_FIELDS_GROUP_USER, $fields, $data, array($lib->getHandler(), 'getOutput')); // Create a temporary storage $tmpFields = array(); // Group the fields to each workflow properly if ($steps) { foreach ($steps as $step) { $step->fields = array(); if (!empty($fields)) { foreach ($fields as $field) { if ($field->step_id == $step->id) { $step->fields[] = $field; } $tmpFields[$field->app_id] = $field; } } } } // We need to know the amount of core apps and used core apps // 1.3 Update, we split out unique apps as well $coreAppsCount = 0; $usedCoreAppsCount = 0; $uniqueAppsCount = 0; $usedUniqueAppsCount = 0; // hide the apps if it is a core app and it is used in the field if ($defaultApps) { foreach ($defaultApps as $app) { $app->hidden = false; // If app is core, increase the coreAppsCount counter if ($app->core) { $coreAppsCount++; } // If app is NOT core and unique, increase the coreAppsCount counter // This is because core apps are definitely unique, so we do not want to include core apps here if (!$app->core && $app->unique) { $uniqueAppsCount++; } // Test if this app has already been assigned to the $tmpFields if (isset($tmpFields[$app->id]) && $app->core) { $usedCoreAppsCount++; $app->hidden = true; } // Test if this app is NOT core and unique and has already been assigned // This is because core apps are definitely unique, so we do not want to include core apps here if (isset($tmpFields[$app->id]) && !$app->core && $app->unique) { $usedUniqueAppsCount++; $app->hidden = true; } } } unset($tmpFields); // We need to know if there are any core apps remain $coreAppsRemain = $usedCoreAppsCount < $coreAppsCount; // We need to know if there are any unique apps remain $uniqueAppsRemain = $usedUniqueAppsCount < $uniqueAppsCount; // Render the access form. $accessModel = FD::model('Access'); $accessForm = $accessModel->getForm($id, SOCIAL_TYPE_PROFILES, 'access', '', false); $this->set('accessForm', $accessForm); // Set the flag of coreAppsRemain $this->set('coreAppsRemain', $coreAppsRemain); // Set the flag of uniqueAppsRemain $this->set('uniqueAppsRemain', $uniqueAppsRemain); // Set the default apps to the template. $this->set('defaultApps', $defaultApps); // Set the steps for the template. $this->set('steps', $steps); // Set the fields to the template $this->set('fields', $fields); // Set the field group to the template $this->set('fieldGroup', SOCIAL_FIELDS_GROUP_USER); // Get the total number of users in the current profile. $membersCount = $profile->getMembersCount(); // Set member's count to the template. $this->set('membersCount', $membersCount); } // Get a list of themes. $themesModel = FD::model('Themes'); $themes = $themesModel->getThemes(); // Get profile parameters $params = $profile->getParams(); // Get default privacy $privacy = FD::get('Privacy', $profile->id, SOCIAL_PRIVACY_TYPE_PROFILES); // We need to hide the guest user group that is defined in com_users options. // Public group should also be hidden. $userOptions = JComponentHelper::getComponent('com_users')->params; $defaultRegistrationGroup = $userOptions->get('new_usertype'); $guestGroup = array(1, $userOptions->get('guest_usergroup')); // Set the default registration group for new items if (!$id) { $profile->gid = $defaultRegistrationGroup; } // Get the active tab $activeTab = $this->input->get('activeTab', 'settings', 'word'); // Get a list of default groups $defaultGroups = $profile->getDefaultGroups(); // Exclude groups from being suggested $excludeGroups = array(); if ($defaultGroups) { foreach ($defaultGroups as $group) { $excludeGroups[] = (int) $group->id; } } $this->set('excludeGroups', $excludeGroups); $this->set('defaultGroups', $defaultGroups); $this->set('activeTab', $activeTab); $this->set('defaultAvatars', $defaultAvatars); $this->set('guestGroup', $guestGroup); $this->set('id', $id); $this->set('themes', $themes); $this->set('param', $params); $this->set('profile', $profile); $this->set('privacy', $privacy); echo parent::display('admin/profiles/default.form'); }
/** * Determines if the app should appear in the app listing * * @since 1.0 * @access public * @param string * @return */ public function appListing($view, $uid = '', $type = '') { $apps = ES::apps(); $hasListing = $apps->hasAppListing($this, $view, $uid, $type); return $hasListing; }
/** * Checks for new friend requests * * @since 1.0 * @access public */ public function getSystemCounter() { // Check for request forgeries. FD::checkToken(); // Ensure that user is logged in FD::requireLogin(); $model = ES::model('Notifications'); $options = array('unread' => true, 'target' => array('id' => $this->my->id, 'type' => SOCIAL_TYPE_USER)); $total = $model->getCount($options); return $this->view->call(__FUNCTION__, $total); }
/** * 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); }
public function updateScriptVersion() { $version = $this->getInstalledVersion(); // Update the version in the database to the latest now $config = FD::table('Config'); $exists = $config->load(array('type' => 'scriptversion')); $config->type = 'scriptversion'; $config->value = $version; $config->store(); $result = $this->getResultObj(JText::_('COM_EASYSOCIAL_INSTALLATION_MAINTENANCE_UPDATED_MAINTENANCE_VERSION'), 1, JText::_('COM_EASYSOCIAL_INSTALLATION_STEP_SUCCESS')); // Purge all old version files ES::purgeOldVersionScripts(); // Purge javascript resources FD::purgeJavascriptResources(); // Remove installation temporary file JFile::delete(JPATH_ROOT . '/tmp/easysocial.installation'); return $this->output($result); }
/** * 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); }
/** * Suggests a list of groups for a user. * * @since 1.3 * @access public * @param string * @return */ public function suggest() { // Check for request forgeries ES::checkToken(); ES::requireLogin(); // Get the search query $search = $this->input->get('search', '', 'word'); // Get exclusion list $exclusion = $this->input->get('exclusion', array(), 'array'); // Determines if the user is an admin $options = array('unpublished' => false, 'exclusion' => $exclusion); if ($this->my->isSiteAdmin()) { $options['unpublished'] = true; } // Load up the groups model $model = ES::model('Groups'); $groups = $model->search($search, $options); return $this->view->call(__FUNCTION__, $groups); }
" class="group-category"> <i class="ies-database"></i> <?php echo $modules->html('string.escape', $group->getCategory()->get('title')); ?> </a> </span> <?php } ?> <?php if ($params->get('display_member_counter', true)) { ?> <span class="hit-counter"> <i class="ies-users"></i> <?php echo JText::sprintf(ES::string()->computeNoun('MOD_EASYSOCIAL_GROUPS_MEMBERS_COUNT', $group->getTotalMembers()), $group->getTotalMembers()); ?> </span> <?php } ?> </div> <?php if ($params->get('display_actions', true) && !$group->isMember()) { ?> <div class="es-group-actions"> <a href="javascript:void(0);" class="btn btn-es-primary btn-sm" data-es-groups-join data-id="<?php echo $group->id; ?> "><?php
/** * 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); }
/** * Displays all albums from the site. * * @since 1.2 * @access public * @param string * @return */ public function all($tpl = null) { // Check for user profile completeness FD::checkCompleteProfile(); // Check if photos is enabled $this->checkFeature(); // Set the page title $this->page->title(JText::_('COM_EASYSOCIAL_ALBUMS_ALL_ALBUMS')); // Set the breadcrumbs $this->page->breadcrumb(JText::_('COM_EASYSOCIAL_ALBUMS_ALL_ALBUMS')); // Get albums model $model = ES::model('Albums'); $model->initStates(); // Get the start limit from the request $startlimit = $this->input->get('limitstart', 0, 'int'); // By default albums should be sorted by creation date. $sorting = $this->input->get('sort', 'created'); if (!$startlimit) { $model->setState('limitstart', 0); } // Get a list of normal albums $options = array('pagination' => true, 'order' => 'a.assigned_date', 'direction' => 'DESC', 'core' => false); if ($sorting == 'alphabetical') { $options['order'] = 'a.title'; $options['direction'] = 'ASC'; } if ($sorting == 'popular') { $options['order'] = 'a.hits'; $options['direction'] = 'DESC'; } // Get the albums $albums = $model->getAlbums('', SOCIAL_TYPE_USER, $options); // Get the album pagination $pagination = $model->getPagination(); $lib = FD::albums(FD::user()->id, SOCIAL_TYPE_USER); $this->set('sorting', $sorting); $this->set('lib', $lib); $this->set('albums', $albums); $this->set('pagination', $pagination); // Wrap it with the albums wrapper. echo parent::display('site/albums/all'); }
/** * 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'); }
/** * Searches for groups * * @since 1.3 * @access public * @param string * @return */ public function search($keyword, $options = array()) { $db = ES::db(); $sql = $db->sql(); $sql->select('#__social_clusters'); $sql->where('cluster_type', SOCIAL_TYPE_GROUP); $sql->where('title', '%' . $keyword . '%', 'LIKE'); // Determines if we should search for unpublished groups as well $unpublished = isset($options['unpublished']) && $options['unpublished'] ? true : false; if (!$unpublished) { $sql->where('state', SOCIAL_STATE_PUBLISHED); } // Determines if we should exclude specific group ids $exclusion = isset($options['exclusion']) && $options['exclusion'] ? $options['exclusion'] : false; if ($exclusion) { $exclusion = ES::makeArray($exclusion); $sql->where('id', $exclusion, 'NOT IN'); } $db->setQuery($sql); $result = $db->loadObjectList(); $groups = array(); if (!$result) { return $groups; } foreach ($result as $row) { $group = FD::group(); $group->bind($row); $groups[] = $group; } return $groups; }
/** * Helper method to retrieve the toolbar's HTML code. * * @since 1.0 * @access public * @param null * @return null */ public function getToolbar() { // The current logged in user. $toolbar = ES::toolbar(); return $toolbar->render(); }
/** * Processes the install by uploading * * @since 1.0 * @access public * @param null * @return null * * @author Mark Lee <*****@*****.**> **/ public function installFromUpload() { // Check for request forgeries. FD::checkToken(); $package = $this->input->files->get('package'); // Test for empty packages. if (!isset($package['tmp_name']) || !$package['tmp_name']) { $this->view->setMessage('COM_EASYSOCIAL_APPS_PLEASE_UPLOAD_INSTALLER', SOCIAL_MSG_ERROR); return $this->view->install(); } $source = $package['tmp_name']; $jConfig = ES::config('joomla'); // Construct the destination path $destination = $jConfig->getValue('tmp_path') . '/' . $package['name']; // Get the installer library $installer = ES::get('Installer'); // Now try to upload the installer $state = $installer->upload($source, $destination); if (!$state) { $this->view->setMessage('COM_EASYSOCIAL_APPS_UNABLE_TO_COPY_UPLOADED_FILE', SOCIAL_MSG_ERROR); return $this->view->install(); } // Unpack the archive. $path = $installer->extract($destination); // When something went wrong with the installation, just display the error if ($path === false) { $error = ES::get('Errors')->getErrors('installer.extract'); $this->info->set($error, SOCIAL_MSG_ERROR); $this->app->redirect('index.php?option=com_easysocial&view=applications&layout=error'); return $this->app->close(); } return $this->installFromDirectory($path); }
/** * Determines if the provided user id is a member of this group * * @since 1.0 * @access public * @param int The user's id to check against. * @return bool True if he / she is a member already. */ public function isMember($userId = null) { $userId = ES::user($userId)->id; if (isset($this->members[$userId])) { return true; } return false; }
/** * Allows caller to pass in an array of gid to be binded to the object property. * * @since 1.0 * @access public * @param Array An array of group id's. * @return boolean True on success false otherwise. */ public function bindUserGroups($gids = array()) { $gids = ES::makeArray($gids); if (is_array($gids) && !empty($gids)) { $this->gid = json_encode($gids); return true; } return false; }
/** * Retrieves a list of notification items. * * @since 1.0 * @access public * @param bool To aggregate the notification items or not. * @return Array An array of @SocialTableNotification */ public function getItems($options = array()) { $model = ES::model('Notifications'); $items = $model->getItems($options); if (!$items) { return false; } // Retrieve applications and trigger onNotificationLoad $dispatcher = ES::dispatcher(); $result = array(); // Trigger apps foreach ($items as $item) { // Add a `since` column to the result so that user's could use the `since` time format. $item->since = FD::date($item->created)->toLapsed(); $args = array(&$item); // @trigger onNotificationLoad $dispatcher->trigger(SOCIAL_APPS_GROUP_USER, 'onNotificationLoad', $args); // @trigger onNotificationLoad $dispatcher->trigger(SOCIAL_APPS_GROUP_GROUP, 'onNotificationLoad', $args); // @trigger onNotificationLoad $dispatcher->trigger(SOCIAL_APPS_GROUP_EVENT, 'onNotificationLoad', $args); // If an app lets us know that they want to exclude the stream, we should exclude it. if (isset($item->exclude) && $item->exclude) { continue; } // Let's format the item title. $this->formatItem($item); $result[] = $item; } // Group up items. if (isset($options['group']) && $options['group'] == SOCIAL_NOTIFICATION_GROUP_ITEMS) { $result = $this->group($result); } return $result; }
// Include the engine file. require_once $file; // Check if Foundry exists if (!FD::exists()) { FD::language()->loadSite(); echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING'); return; } // Include EasyBlog's library require_once JPATH_ROOT . '/administrator/components/com_easyblog/includes/easyblog.php'; $my = ES::user(); // Load up the module engine $modules = ES::modules('mod_easysocial_easyblog_posts'); $model = EB::model('Blog'); // Get the module options $total = (int) $params->get('total', 5); $sorting = $params->get('sorting', 'latest'); // Let's load the list of posts now $posts = $model->getBlogsBy('latest', '', $sorting, $total); // We need to format the blog post accordingly. $posts = EB::formatter('list', $posts, false); // Get the author of the blog posts foreach ($posts as $post) { $post->user = ES::user($post->created_by); } // We need these packages $modules->addDependency('css', 'javascript'); // Get the layout to use. $layout = $params->get('layout', 'default'); $suffix = $params->get('suffix', ''); require JModuleHelper::getLayoutPath('mod_easysocial_easyblog_posts', $layout);
/** * Displays the switch profile form * * @since 1.0 * @access public * @param string * @return */ public function switchProfileForm() { // Get the id's of the user that we are trying to modify $ids = $this->input->get('ids', array(), 'array'); $ids = ES::makeArray($ids); $theme = ES::themes(); $theme->set('ids', $ids); $output = $theme->output('admin/users/dialog.switch.profile'); return $this->ajax->resolve($output); }