From cc015e2161a5ab1866acbe7f8c3153919883b106 Mon Sep 17 00:00:00 2001 From: Pratiksha khandagale Date: Sat, 9 Dec 2017 14:41:24 +0530 Subject: [PATCH 1/3] Task #114679 refactor: [User Plugin] - Resolved Phpcs error and code updated --- users/users.xml | 3 +- users/users/config.php | 305 +++++++++++++++++++---------- users/users/login.php | 174 ++++++++++------- users/users/users.php | 425 ++++++++++++++--------------------------- 4 files changed, 456 insertions(+), 451 deletions(-) diff --git a/users/users.xml b/users/users.xml index 5cfaa6a..29e9c90 100644 --- a/users/users.xml +++ b/users/users.xml @@ -1,7 +1,7 @@ PLG_API_USERS - 1.8.7 + 2.0.0 10/11/2014 Techjoomla extensions@techjoomla.com @@ -25,6 +25,7 @@ + diff --git a/users/users/config.php b/users/users/config.php index 4614c7f..9e7b6c8 100644 --- a/users/users/config.php +++ b/users/users/config.php @@ -1,11 +1,14 @@ - * @link http://www.techjoomla.com -*/ - + * @package Com_Api + * @subpackage Com_api-plugins + * + * @copyright Copyright (C) 2009-2017 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. + * @license GNU GPLv2 + * @link http://techjoomla.com + * Work derived from the original RESTful API by Techjoomla (https://github.com/techjoomla/Joomla-REST-API) + * and the com_api extension by Brian Edgerton (http://www.edgewebworks.com) + */ defined('_JEXEC') or die( 'Restricted access' ); jimport('joomla.plugin.plugin'); @@ -16,154 +19,264 @@ jimport('joomla.user.user'); jimport('joomla.application.component.helper'); -JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models'); -require_once JPATH_SITE.'/components/com_api/libraries/authentication/user.php'; -require_once JPATH_SITE.'/components/com_api/libraries/authentication/login.php'; +JModelLegacy::addIncludePath(JPATH_SITE . 'components/com_api/models'); +require_once JPATH_SITE . '/components/com_api/libraries/authentication/user.php'; +require_once JPATH_SITE . '/components/com_api/libraries/authentication/login.php'; +/** + * API class UsersApiResourceConfig + * + * @since 1.0 + */ class UsersApiResourceConfig extends ApiResource { + /** + * Method get + * + * @return mixed + * + * @since 1.0 + */ public function get() { $obj = new stdClass; - //get joomla,easyblog and easysocial configuration - //get version of easysocial and easyblog - $easyblog = JPATH_ADMINISTRATOR .'/components/com_easyblog/easyblog.php'; - $easysocial = JPATH_ADMINISTRATOR .'/components/com_easysocial/easysocial.php'; - //eb version - if( JFile::exists( $easyblog ) ) + $result = new stdClass; + + $app = JFactory::getApplication(); + $acl = $app->input->get('acl', false, boolean); + $userId = $app->input->get('userId', 0, 'INT'); + + if ($acl && $userId != 0) { - $obj->easyblog = $this->getCompParams('com_easyblog','easyblog'); + $this->getProfileACL($userId); } - //es version - if( JFile::exists( $easysocial ) ) + else + { + // Get joomla,easyblog and easysocial configuration + // Get version of easysocial and easyblog + + $easyblog = JPATH_ADMINISTRATOR . '/components/com_easyblog/easyblog.php'; + $easysocial = JPATH_ADMINISTRATOR . '/components/com_easysocial/easysocial.php'; + + // Eb version + if (JFile::exists($easyblog)) + { + $obj->easyblog = $this->getCompParams('com_easyblog', 'easyblog'); + } + + // Es version + if (JFile::exists($easysocial)) { - /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easysocial/easyblog.xml'); - $obj->easysocial_version = (string)$xml->version;*/ - $obj->easysocial = $this->getCompParams( 'com_easysocial','easysocial' ); + $obj->easysocial = $this->getCompParams('com_easysocial', 'easysocial'); } $obj->global_config = $this->getJoomlaConfig(); $obj->plugin_config = $this->getpluginConfig(); - - $this->plugin->setResponse($obj); + $installed_languages = JLanguageHelper::getLanguages(); + $languages = array(); + + foreach ($installed_languages as $lang) + { + $languages[] = substr($lang->lang_code, 0, 2); + } + + $obj->languages = $languages; + + // $getACL = EB::acl($log_user); + // $obj->ACL = $getACL; + + $xml = JFactory::getXML(JPATH_SITE . '/plugins/api/users/users.xml'); + $obj->plugin_version = (string) $xml->version; + + $result->result = $obj; + + $this->plugin->setResponse($result); + } } + /** + * Method post + * + * @return mixed + * + * @since 1.0 + */ public function post() { - $this->plugin->setResponse( JText::_( 'PLG_API_USERS_UNSUPPORTED_METHOD_POST' )); + $this->plugin->setResponse(JText::_('PLG_API_USERS_UNSUPPORTED_METHOD_POST')); } - - //get component params + /** + * Method to update auth keys + * + * @param number $cname The table + * @param number $name The table + * + * @return ApiPlugin response object + * + * @since 2.0 + */ public function getCompParams($cname=null,$name=null) { jimport('joomla.application.component.helper'); $app = JFactory::getApplication(); $cdata = array(); - - $xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/'.$cname.'/'.$name.'.xml'); - $cdata['version'] = (string)$xml->version; + + $xml = JFactory::getXML(JPATH_ADMINISTRATOR . '/components/' . $cname . '/' . $name . '.xml'); + $cdata['version'] = (string) $xml->version; $jconfig = JFactory::getConfig(); - - if( $cname == 'com_easyblog' ) + + if ($cname == 'com_easyblog') { - /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easyblog/easyblog.xml'); - $version = (string)$xml->version;*/ - - if($cdata['version']<5) - { - require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' ); - $eb_params = EasyBlogHelper::getConfig(); - } - else - { - require_once JPATH_ADMINISTRATOR.'/components/com_easyblog/includes/easyblog.php'; - $eb_params = EB::config(); - } - - $cdata['main_max_relatedpost'] = $eb_params->get('main_max_relatedpost'); - $cdata['layout_pagination_bloggers'] = $eb_params->get('layout_pagination_bloggers'); - $cdata['layout_pagination_categories'] = $eb_params->get('layout_pagination_categories'); - $cdata['layout_pagination_categories_per_page'] = $eb_params->get('layout_pagination_categories_per_page'); - $cdata['layout_pagination_bloggers_per_page'] = $eb_params->get('layout_pagination_bloggers_per_page'); - $cdata['layout_pagination_archive'] = $eb_params->get('layout_pagination_archive'); - $cdata['layout_pagination_teamblogs'] = $eb_params->get('layout_pagination_teamblogs'); - + if ($cdata['version'] < 5) + { + require_once JPATH_ROOT . '/components/com_easyblog/helpers/helper.php'; + $eb_params = EasyBlogHelper::getConfig(); + } + else + { + require_once JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php'; + $eb_params = EB::config(); + } + + $cdata['main_max_relatedpost'] = $eb_params->get('main_max_relatedpost'); + $cdata['layout_pagination_bloggers'] = $eb_params->get('layout_pagination_bloggers'); + $cdata['layout_pagination_categories'] = $eb_params->get('layout_pagination_categories'); + $cdata['layout_pagination_categories_per_page'] = $eb_params->get('layout_pagination_categories_per_page'); + $cdata['layout_pagination_bloggers_per_page'] = $eb_params->get('layout_pagination_bloggers_per_page'); + $cdata['layout_pagination_archive'] = $eb_params->get('layout_pagination_archive'); + $cdata['layout_pagination_teamblogs'] = $eb_params->get('layout_pagination_teamblogs'); } else { - require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php'; + require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $es_params = FD::config(); - $profiles = FD::model( 'profiles' ); - - //$cdata['conversations_limit'] = $es_params->get('conversations')->limit; - $cdata['activity_limit'] = $es_params->get('activity')->pagination; - $cdata['lists_limit'] = $es_params->get('lists')->display->limit; - $cdata['comments_limit'] = $es_params->get('comments')->limit; - $cdata['stream_pagination_limit'] = $es_params->get('stream')->pagination->pagelimit; - $cdata['photos_pagination_limit'] = $es_params->get('photos')->pagination->photo; - $cdata['album_pagination_limit'] = $es_params->get('photos')->pagination->album; - $cdata['emailasusername'] = $es_params->get('registrations')->emailasusername; - $cdata['displayName'] = $es_params->get('users')->displayName; - $cdata['groups']['enabled'] = $es_params->get('groups')->enabled; - $profiles_data = $profiles->getAllProfiles(); + $profiles = FD::model('profiles'); + + // $cdata['conversations_limit'] = $es_params->get('conversations')->limit; + $cdata['activity_limit'] = $es_params->get('activity')->pagination; + $cdata['lists_limit'] = $es_params->get('lists')->display->limit; + $cdata['comments_limit'] = $es_params->get('comments')->limit; + $cdata['stream_pagination_limit'] = $es_params->get('stream')->pagination->pagelimit; + $cdata['photos_pagination_limit'] = $es_params->get('photos')->pagination->photo; + $cdata['album_pagination_limit'] = $es_params->get('photos')->pagination->album; + $cdata['emailasusername'] = $es_params->get('registrations')->emailasusername; + $cdata['displayName'] = $es_params->get('users')->displayName; + $cdata['groups']['enabled'] = $es_params->get('groups')->enabled; + $profiles_data = $profiles->getAllProfiles(); /* Check for profile_type is allowed for Registration by vivek*/ $allowed_profile_types = array(); - foreach ($profiles_data as $key ) { - if($key->registration == '1'){ + + foreach ($profiles_data as $key) + { + if ($key->registration == '1' && $key->state == '1') + { array_push($allowed_profile_types, $key); } } + $cdata['profile_types'] = $allowed_profile_types; } + return $cdata; } - - // get fb plugin config + + /** + * Method get fb plugin config + * + * @return mixed + * + * @since 1.0 + */ public function getpluginConfig() { $data = array(); $plugin = JPluginHelper::getPlugin('api', 'users'); $pluginParams = new JRegistry($plugin->params); - //code for future use - /*$plugin_es = JPluginHelper::getPlugin('api', 'easysocial'); - $pluginParams_es = new JRegistry($plugin_es->params);*/ - + + // Code for future use + + /* $plugin_es = JPluginHelper::getPlugin('api', 'easysocial'); + $pluginParams_es = new JRegistry($plugin_es->params); */ + $data['fb_login'] = $pluginParams->get('fb_login'); $data['fb_app_id'] = $pluginParams->get('fb_app_id'); - $data['quick2art'] = $pluginParams->get('quick2art'); - + $data['google_client_id'] = $pluginParams->get('google_client_id'); + return $data; } - - //get joomla config changes + /** + * Method get joomla config changes + * + * @return mixed + * + * @since 1.0 + */ public function getJoomlaConfig() { - $jconfig = JFactory::getConfig(); - $jarray = array(); - $jarray['global_list_limit'] = $jconfig->get('list_limit'); - $jarray['offset'] = $jconfig->get('offset'); - $jarray['offset_user'] = $jconfig->get('offset_user'); - + $jconfig = JFactory::getConfig(); + $jarray = array(); + $jarray['global_list_limit'] = $jconfig->get('list_limit'); + $jarray['offset'] = $jconfig->get('offset'); + $jarray['offset_user'] = $jconfig->get('offset_user'); + return $jarray; - } - - /* - * function to update Easyblog auth keys + } + + /** + * Method to update Easyblog auth keys + * + * @param string $user The table + * @param string $key The table + * + * @return ApiPlugin response object + * + * @since 2.0 */ public function updateEauth($user=null,$key=null) { - require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php'; - $model = FD::model('Users'); - $id = $model->getUserId('username', $user->username); - $user = FD::user($id); - $user->alias = $user->username; - $user->auth = $key; + require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; + $model = FD::model('Users'); + $id = $model->getUserId('username', $user->username); + $user = FD::user($id); + $user->alias = $user->username; + $user->auth = $key; $user->store(); - + return $id; } + + /** + * Method use to get ACL config + * + * @param string $userId The table + * + * @return ApiPlugin response object + * + * @since 1.0 + */ + public function getProfileACL($userId) + { + $access = ES::access($userId, SOCIAL_TYPE_USER); + $res = new stdClass; + + $res->result->comments = $access->get('comments'); + $res->result->conversations = $access->get('conversations'); + $res->result->events = $access->get('events'); + $res->result->files = $access->get('files'); + $res->result->friends = $access->get('friends'); + $res->result->groups = $access->get('groups'); + $res->result->albums = $access->get('albums'); + $res->result->photos = $access->get('photos'); + $res->result->polls = $access->get('polls'); + $res->result->reports = $access->get('reports'); + $res->result->story = $access->get('story'); + $res->result->stream = $access->get('stream'); + $res->result->videos = $access->get('videos'); + + $this->plugin->setResponse($res); + } } diff --git a/users/users/login.php b/users/users/login.php index 568f36f..dd8e374 100644 --- a/users/users/login.php +++ b/users/users/login.php @@ -1,124 +1,154 @@ - * @link http://www.techjoomla.com + * @package Com_Api + * @subpackage Com_api-plugins + * + * @copyright Copyright (C) 2009-2017 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. + * @license GNU GPLv2 + * @link http://techjoomla.com + * Work derived from the original RESTful API by Techjoomla (https://github.com/techjoomla/Joomla-REST-API) + * and the com_api extension by Brian Edgerton (http://www.edgewebworks.com) */ defined('_JEXEC') or die( 'Restricted access' ); - -jimport('joomla.plugin.plugin'); -jimport('joomla.html.html'); -jimport('joomla.application.component.controller'); -jimport('joomla.application.component.model'); -jimport('joomla.user.helper'); -jimport('joomla.user.user'); -jimport('joomla.application.component.helper'); - JModelLegacy::addIncludePath(JPATH_SITE . 'components/com_api/models'); require_once JPATH_SITE . '/components/com_api/libraries/authentication/user.php'; require_once JPATH_SITE . '/components/com_api/libraries/authentication/login.php'; require_once JPATH_SITE . '/components/com_api/models/key.php'; require_once JPATH_SITE . '/components/com_api/models/keys.php'; +/** + * API class UsersApiResourceConfig + * + * @since 1.0 + */ class UsersApiResourceLogin extends ApiResource { + /** + * Method get + * + * @return mixed + * + * @since 1.0 + */ public function get() { - $this->plugin->setResponse( JText::_('PLG_API_USERS_GET_METHOD_NOT_ALLOWED_MESSAGE')); + $this->plugin->err_code = 405; + $this->plugin->err_message = JText::_('PLG_API_USERS_GET_METHOD_NOT_ALLOWED_MESSAGE'); + $this->plugin->setResponse(null); } + /** + * Method post + * + * @return auth, id + * + * @since 1.0 + */ public function post() { $this->plugin->setResponse($this->keygen()); } + /** + * Method description + * + * @return key + * + * @since 1.0 + */ public function keygen() { - //init variable - $obj = new stdclass; - $umodel = new JUser; - $user = $umodel->getInstance(); - - $app = JFactory::getApplication(); - $username = $app->input->get('username', 0, 'STRING'); + // Init variable + $obj = new stdclass; + $umodel = new JUser; + $user = $umodel->getInstance(); + $app = JFactory::getApplication(); + $username = $app->input->get('username', 0, 'STRING'); + $user = JFactory::getUser(); + $id = JUserHelper::getUserId($username); - $user = JFactory::getUser(); - $id = JUserHelper::getUserId($username); - - if($id == null) + if ($id == null) { $model = FD::model('Users'); - $id = $model->getUserId('email', $username); + $id = $model->getUserId('email', $username); } - $kmodel = new ApiModelKey; - $model = new ApiModelKeys; - $key = null; + $result = new stdClass; + $kmodel = new ApiModelKey; + $model = new ApiModelKeys; + $key = null; + // Get login user hash - //$kmodel->setState('user_id', $user->id); + // $kmodel->setState('user_id', $user->id); $kmodel->setState('user_id', $id); $log_hash = $kmodel->getList(); $log_hash = (!empty($log_hash))?$log_hash[count($log_hash) - count($log_hash)]:$log_hash; - if( !empty($log_hash) ) + if (!empty($log_hash)) { $key = $log_hash->hash; } - elseif( $key == null || empty($key) ) + elseif($key == null || empty($key)) { - // Create new key for user - $data = array( - 'userid' => $user->id, - 'domain' => '' , - 'state' => 1, - 'id' => '', - 'task' => 'save', - 'c' => 'key', - 'ret' => 'index.php?option=com_api&view=keys', - 'option' => 'com_api', - JSession::getFormToken() => 1 - ); + // Create new key for user + $data = array( + 'userid' => $user->id, + 'domain' => '' , + 'state' => 1, + 'id' => '', + 'task' => 'save', + 'c' => 'key', + 'ret' => 'index.php?option=com_api&view=keys', + 'option' => 'com_api', + JSession::getFormToken() => 1 + ); + + $result = $kmodel->save($data); + $key = $result->hash; + + // Add new key in easysocial table + $easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php'; - $result = $kmodel->save($data); - $key = $result->hash; - - //add new key in easysocial table - $easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php'; - if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true)) - { - $this->updateEauth( $user , $key ); - } + if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true)) + { + $this->updateEauth($user, $key); + } } - - if( !empty($key) ) + + if (!empty($key)) { - $obj->auth = $key; - $obj->code = '200'; - //$obj->id = $user->id; - $obj->id = $id; + $result->result = new stdClass; + $result->result->token = $key; + $result->result->id = $id; } else { - $obj->code = 403; - $obj->message = JText::_('PLG_API_USERS_BAD_REQUEST_MESSAGE'); + $this->plugin->err_code = 403; + $this->plugin->err_message = JText::_('PLG_API_USERS_BAD_REQUEST_MESSAGE'); } - return( $obj ); - + + return $result; } - - /* - * function to update Easyblog auth keys + + /** + * Method updateEauth + * + * @param array $user my + * @param array $key group object + * + * @return string + * + * @since 1.0 */ public function updateEauth($user=null,$key=null) { - require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php'; - $model = FD::model('Users'); - $id = $model->getUserId('username', $user->username); - $user = FD::user($id); - $user->alias = $user->username; - $user->auth = $key; + require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; + $model = FD::model('Users'); + $id = $model->getUserId('username', $user->username); + $user = FD::user($id); + $user->alias = $user->username; + $user->auth = $key; $user->store(); return $id; diff --git a/users/users/users.php b/users/users/users.php index 9ed8a02..260db2f 100644 --- a/users/users/users.php +++ b/users/users/users.php @@ -1,9 +1,9 @@ load('com_users'); -$language->load('com_users', JPATH_SITE, 'en-GB', true); -$language->load('com_users', JPATH_ADMINISTRATOR, 'en-GB', true); require_once JPATH_SITE . '/libraries/joomla/filesystem/folder.php'; require_once JPATH_ROOT . '/administrator/components/com_users/models/users.php'; @@ -41,158 +36,14 @@ class UsersApiResourceUsers extends ApiResource */ public function delete() { - $app = JFactory::getApplication(); - $db = JFactory::getDbo(); - $data = array(); - $eobj = new stdClass; - $eobj->status = false; - $eobj->id = 0; - - // Get values paased by put in the url - $data = $app->input->getArray(array()); - - // Check username or user_id to edit the details of user - if (isset($data['username']) || isset($data['user_id'])) - { - if (!$data['user_id'] && $data['username']) - { - // Get user_id with the help of username - $query = $db->getQuery(true); - $query->select('id'); - $query->from('#__users'); - $query->where($db->quoteName('username') . '=' . $db->quote($data['username'])); - $db->setQuery($query); - $user_id = $db->loadResult(); - $data['user_id'] = $user_id; - } - - $user = JUser::getInstance($data['user_id']); - - if ($user->id && $user->delete()) - { - $eobj->status = true; - $eobj->id = $data['user_id']; - $eobj->code = '200'; - $eobj->message = JText::_('COM_USERS_USERS_N_ITEMS_DELETED_1'); - $this->plugin->setResponse($eobj); - - return; - } - else - { - $eobj->code = '400'; - $eobj->message = JText::_('COM_USERS_USER_NOT_FOUND'); - $this->plugin->setResponse($eobj); - - return; - } - } - else - { - // Not given username or user_id to edit the details of user - $eobj->code = '400'; - $eobj->message = JText::_('PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE'); - $this->plugin->setResponse($eobj); - - return; - } - } - - /** - * Function for edit user record. - * - * @return void - */ - public function put() - { - $app = JFactory::getApplication(); - $db = JFactory::getDbo(); - $data = array(); - $eobj = new stdClass; - $eobj->status = false; - $eobj->id = 0; - - // Get values paased by put in the url - $data = $app->input->getArray(array()); - - // Check username or user_id to edit the details of user - if (isset($data['username']) || isset($data['user_id'])) - { - if (!$data['user_id'] && isset($data['username'])) - { - // Get user_id with the help of username - $query = $db->getQuery(true); - $query->select('id'); - $query->from('#__users'); - $query->where($db->quoteName('username') . '=' . $db->quote($data['username'])); - $db->setQuery($query); - $user_id = $db->loadResult(); - $data['user_id'] = $user_id; - } - - // Given username or user_id not exist - if (!$data['user_id']) - { - $eobj->code = '400'; - $eobj->message = JText::_('COM_USERS_USER_NOT_FOUND'); - $this->plugin->setResponse($eobj); - - return; - } - - $user = JFactory::getUser($data['user_id']); - - // Bind the data. - if (!$user->bind($data)) - { - // User deatils are not updated - $message = $user->getError(); - $eobj->code = '400'; - $eobj->message = $message; - $this->plugin->setResponse($eobj); - - return; - } - - // Save the user data - if (!$user->save()) - { - // User deatils are not updated - $message = $user->getError(); - $eobj->code = '400'; - $eobj->message = $message; - $this->plugin->setResponse($eobj); - - return; - } - else - { - // Updated records updated successsfully - $eobj->status = true; - $eobj->id = $data['user_id']; - $eobj->code = '200'; - $eobj->message = JText::_('PLG_API_USERS_ACCOUNT_EDITED_SUCCESSFULLY_MESSAGE'); - $this->plugin->setResponse($eobj); - - return; - } - } - else - { - // Not given username or user_id to edit the details of user - $eobj->code = '400'; - $eobj->message = JText::_('PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE'); - $this->plugin->setResponse($eobj); - - return; - } + $this->plugin->setResponse(JText::_('PLG_API_USERS_IN_DELETE_FUNCTION_MESSAGE')); } /** - * Function for edit user record. - * - * @return void - */ + * Function post for create user record. + * + * @return void + */ public function post() { $error_messages = array(); @@ -202,30 +53,29 @@ public function post() $userid = null; $data = array(); - $app = JFactory::getApplication(); - $data['username'] = $app->input->get('username', '', 'STRING'); - $data['password'] = $app->input->get('password', '', 'STRING'); - $data['name'] = $app->input->get('name', '', 'STRING'); - $data['email'] = $app->input->get('email', '', 'STRING'); - $data['enabled'] = $app->input->get('enabled', 1, 'INT'); + $app = JFactory::getApplication(); + $data['username'] = $app->input->get('username', '', 'STRING'); + $data['password'] = $app->input->get('password', '', 'STRING'); + $data['name'] = $app->input->get('name', '', 'STRING'); + $data['email'] = $app->input->get('email', '', 'STRING'); + $data['enabled'] = $app->input->get('enabled', 1, 'INT'); + $data['activation'] = $app->input->get('activation', 0, 'INT'); + $data['app'] = $app->input->get('app_name', 'Easysocial App', 'STRING'); + $data['profile_id'] = $app->input->get('profile_id', 1, 'INT'); - $data['activation'] = $app->input->get('activation', 0, 'INT'); - $data['app'] = $app->input->get('app_name', 'Easysocial App', 'STRING'); - $data['profile_id'] = $app->input->get('profile_id', 1, 'INT'); global $message; - $eobj = new stdClass(); + $eobj = new stdClass; - if( $data['username']=='' || $data['password'] =='' || $data['name'] == '' || $data['email']== '') + if ($data['username'] == '' || $data['password'] == '' || $data['name'] == '' || $data['email'] == '') { $eobj->status = false; $eobj->id = 0; $eobj->code = '403'; - $eobj->message = JText::_( 'PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE' ); - + $eobj->message = JText::_('PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE'); $this->plugin->setResponse($eobj); - return; + return; } jimport('joomla.user.helper'); @@ -266,76 +116,58 @@ public function post() // True on success, false otherwise if (!$user->save()) { - //$message = "not created because of " . $user->getError(); + // $message = "not created because of " . $user->getError(); $message = $user->getError(); - $eobj->status = false; - $eobj->id = 0; - $eobj->code = '403'; - $eobj->message = $message; + $eobj->status = false; + $eobj->id = 0; + $eobj->code = '403'; + $eobj->message = $message; $this->plugin->setResponse($eobj); - return; } else { - - /* - // Auto registration - if( $data['activation'] == 0) - { - $emailSubject = 'Email Subject for registration successfully'; - $emailBody = 'Email body for registration successfully'; - $return = JFactory::getMailer()->sendMail('sender email', 'sender name', $user->email, $emailSubject, $emailBody); - - } - else if( $data['activation'] == 1) - { - $emailSubject = 'Email Subject for activate the account'; - $emailBody = 'Email body for for activate the account'; - $user_activation_url = JURI::base().JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $user->activation, false); // Append this URL in your email body - $return = JFactory::getMailer()->sendMail('sender email', 'sender name', $user->email, $emailSubject, $emailBody); - - } - */ /* Update profile type */ - $profiles = FD::model( 'profiles' ); + $profiles = FD::model('profiles'); $all_profiles = $profiles->getAllProfiles(); - foreach ($all_profiles as $key) { - if($key->id == $data['profile_id']){ - $profiles->updateUserProfile($user->id,$data['profile_id']); + foreach ($all_profiles as $key) + { + if ($key->id == $data['profile_id']) + { + $profiles->updateUserProfile($user->id, $data['profile_id']); } } $mail_sent = $this->sendRegisterEmail($data); - $easysocial = JPATH_ADMINISTRATOR .'/components/com_easysocial/easysocial.php'; - //eb version - if( JFile::exists( $easysocial ) ) + $easysocial = JPATH_ADMINISTRATOR . '/components/com_easysocial/easysocial.php'; + + // Eb version + if (JFile::exists($easysocial)) { $pobj = $this->createEsprofile($user->id); - //$message = "created of username-" . $user->username .",send mail of details please check"; $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE'); } else - $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE'); + { + $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE'); + } // Assign badge for the person. $badge = FD::badges(); - $badge->log( 'com_easysocial' , 'registration.create' , $user->id , JText::_( 'COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED' ) ); - + $badge->log('com_easysocial', 'registration.create', $user->id, JText::_('COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED')); } + $userid = $user->id; - // Result message - //$result = array('user id ' => $userid, 'message' => $message); - //$result = ($userid) ? $result : $message; $eobj->status = true; $eobj->id = $userid; $eobj->code = '200'; $eobj->message = $message; $this->plugin->setResponse($eobj); + return; } @@ -346,19 +178,20 @@ public function post() */ public function get() { - $input = JFactory::getApplication()->input; // If we have an id try to fetch the user if ($id = $input->get('id')) { $user = JUser::getInstance($id); + if (!$user->id) { - $this->plugin->setResponse($this->getErrorResponse(JText::_( 'PLG_API_USERS_USER_NOT_FOUND_MESSAGE' ))); + $this->plugin->setResponse($this->getErrorResponse(JText::_('PLG_API_USERS_USER_NOT_FOUND_MESSAGE'))); return; } + $this->plugin->setResponse($user); } else @@ -376,13 +209,17 @@ public function get() } /** - * Function create easysocial profile. + * Method create profile * - * @return user obj + * @param array $log_user log_user + * + * @return string + * + * @since 1.0 */ public function createEsprofile($log_user) { - $obj = new stdClass(); + $obj = new stdClass; if (JComponentHelper::isEnabled('com_easysocial', true)) { @@ -390,7 +227,7 @@ public function createEsprofile($log_user) $epost = $app->input->get('fields', '', 'ARRAY'); - require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php'; + require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; // Get all published fields apps that are available in the current form to perform validations $fieldsModel = FD::model('Fields'); @@ -399,11 +236,18 @@ public function createEsprofile($log_user) $my = FD::user($log_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 ); + $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); - $epost = $this->create_field_arr($fields,$epost); + $epost = $this->create_field_arr($fields, $epost); // Load json library. $json = FD::json(); @@ -412,15 +256,16 @@ public function createEsprofile($log_user) $registry = FD::registry(); // Get disallowed keys so we wont get wrong values. - $disallowed = array( FD::token() , 'option' , 'task' , 'controller' ); + $disallowed = array(FD::token(), 'option', 'task', 'controller'); // Process $_POST vars - foreach ($epost as $key => $value) { - - if (!in_array($key, $disallowed)) { - - if (is_array($value) && $key != 'es-fields-11') { - $value = $json->encode( $value ); + foreach ($epost as $key => $value) + { + if (!in_array($key, $disallowed)) + { + if (is_array($value) && $key != 'es-fields-11') + { + $value = $json->encode($value); } $registry->set($key, $value); @@ -432,17 +277,13 @@ public function createEsprofile($log_user) // Perform field validations here. Validation should only trigger apps that are loaded on the form // @trigger onRegisterValidate - $fieldsLib = FD::fields(); + $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' ) ); + $args = array( $data, &$my ); // Bind the my object with appropriate data. $my->bind($data); @@ -451,10 +292,11 @@ public function createEsprofile($log_user) $sval = $my->save(); // Reconstruct args - $args = array(&$data, &$my); + $args = array(&$data, &$my); // @trigger onEditAfterSave - $fieldsLib->trigger( 'onRegisterAfterSave' , SOCIAL_FIELDS_GROUP_USER , $fields , $args ); + // $fieldsLib->trigger( 'onEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields , $args ); + $fieldsLib->trigger('onRegisterAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args); // Bind custom fields for the user. $my->bindCustomFields($data); @@ -463,9 +305,9 @@ public function createEsprofile($log_user) $args = array(&$data, &$my); // @trigger onEditAfterSaveFields - $fieldsLib->trigger( 'onEditAfterSaveFields' , SOCIAL_FIELDS_GROUP_USER , $fields , $args ); + $fieldsLib->trigger('onEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args); - if($sval) + if ($sval) { $obj->success = 1; $obj->message = JText::_('PLG_API_USERS_PROFILE_CREATED_SUCCESSFULLY_MESSAGE'); @@ -473,79 +315,98 @@ public function createEsprofile($log_user) else { $obj->success = 0; - $obj->message = JText::_( 'PLG_API_USERS_UNABLE_CREATE_PROFILE_MESSAGE' ); + $obj->message = JText::_('PLG_API_USERS_UNABLE_CREATE_PROFILE_MESSAGE'); } - } else { $obj->success = 0; - $obj->message = JText::_( 'PLG_API_USERS_EASYSOCIAL_NOT_INSTALL_MESSAGE'); + $obj->message = JText::_('PLG_API_USERS_EASYSOCIAL_NOT_INSTALL_MESSAGE'); } return $obj; - } - //create field array as per easysocial - public function create_field_arr($fields,$post) + /** + * Method create field array as per easysocial + * + * @param array $fields fields + * @param array $post Post + * + * @return string + * + * @since 1.0 + */ + public function create_field_arr($fields, $post) { $fld_data = array(); $app = JFactory::getApplication(); - require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php'; - //for upload photo - if(!empty($_FILES['avatar']['name'])) - { - $upload_obj = new EasySocialApiUploadHelper(); + require_once JPATH_SITE . '/plugins/api/easysocial/libraries/uploadHelper.php'; - $phto_obj = $upload_obj->ajax_avatar($_FILES['avatar']); - $avtar_pth = $phto_obj['temp_path']; - $avtar_scr = $phto_obj['temp_uri']; - $avtar_typ = 'upload'; - $avatar_file_name = $_FILES['avatar']['name']; - } + // For upload photo + if (!empty($_FILES['avatar']['name'])) + { + $upload_obj = new EasySocialApiUploadHelper; + $phto_obj = $upload_obj->ajax_avatar($_FILES['avatar']); + $avtar_pth = $phto_obj['temp_path']; + $avtar_scr = $phto_obj['temp_uri']; + $avtar_typ = 'upload'; + $avatar_file_name = $_FILES['avatar']['name']; + } - foreach($fields as $field) + foreach ($fields as $field) { - $fobj = new stdClass(); + $fobj = new stdClass; $fullname = $app->input->get('name', '', 'STRING'); $fld_data['first_name'] = $app->input->get('name', '', 'STRING'); - - $fobj->first = $fld_data['first_name']; - $fobj->middle = ''; - $fobj->last = ''; - $fobj->name = $fullname; - switch($field->unique_key) - { - case 'HEADER': break; + $fobj->first = $fld_data['first_name']; + $fobj->middle = ''; + $fobj->last = ''; + $fobj->name = $fullname; - case 'JOOMLA_FULLNAME': $fld_data['es-fields-'.$field->id] = $fobj; - break; - case 'JOOMLA_USERNAME': $fld_data['es-fields-'.$field->id] = $app->input->get('username', '', 'STRING'); + switch ($field->unique_key) + { + case 'HEADER': + break; + case 'JOOMLA_FULLNAME': $fld_data['es-fields-' . $field->id] = $fobj; break; - case 'JOOMLA_PASSWORD': $fld_data['es-fields-'.$field->id] = $app->input->get('password', '', 'STRING'); + case 'JOOMLA_USERNAME': $fld_data['es-fields-' . $field->id] = $app->input->get('username', '', 'STRING'); break; - case 'JOOMLA_EMAIL': $fld_data['es-fields-'.$field->id] = $app->input->get('email', '', 'STRING'); + case 'JOOMLA_PASSWORD': $fld_data['es-fields-' . $field->id] = $app->input->get('password', '', 'STRING'); break; - case 'AVATAR': if(isset($avtar_scr)){ - $fld_data['es-fields-'.$field->id] = Array - ( - 'source' =>$avtar_scr, - 'path' =>$avtar_pth, - 'data' => '', - 'type' => $avtar_typ, - 'name' => $avatar_file_name - ); - } + case 'JOOMLA_EMAIL': $fld_data['es-fields-' . $field->id] = $app->input->get('email', '', 'STRING'); break; + case 'AVATAR': + if (isset($avtar_scr)) + { + $fld_data['es-fields-' . $field->id] = Array + ( + 'source' => $avtar_scr, + 'path' => $avtar_pth, + 'data' => '', + 'type' => $avtar_typ, + 'name' => $avatar_file_name + ); + } + + break; } } + return $fld_data; } - //send registration mail + /** + * Method use to get RegisterEmail + * + * @param string $base_dt The table + * + * @return ApiPlugin response object + * + * @since 1.0 + */ public function sendRegisterEmail($base_dt) { $config = JFactory::getConfig(); @@ -558,7 +419,7 @@ public function sendRegisterEmail($base_dt) $data['fromname'] = $config->get('fromname'); $data['mailfrom'] = $config->get('mailfrom'); $data['sitename'] = $config->get('sitename'); - $data['siteurl'] = JUri::root(); + $data['siteurl'] = JUri::root(); $data['activation'] = $base_dt['activation']; // Handle account activation/confirmation emails. @@ -574,11 +435,12 @@ public function sendRegisterEmail($base_dt) $base_dt['name'], $data['sitename'] ); + $emailBody = ''; if ($sendpassword) { $emailBody = JText::sprintf( - 'Hello %s,\n\nThank you for registering at %s. Your account is created and activated. + 'Hello %s,\n\nThank you for registering at %s. Your account is created and activated. \nYou can login to %s using the following username and password:\n\nUsername: %s\nPassword: %s', $base_dt['name'], $data['sitename'], @@ -587,7 +449,6 @@ public function sendRegisterEmail($base_dt) $base_dt['password'] ); } - } elseif ($data['activation'] == 1) { @@ -617,7 +478,7 @@ public function sendRegisterEmail($base_dt) } // Send the registration email. $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $base_dt['email'], $emailSubject, $emailBody); - return $return; + return $return; } } From 434be5619db1613c21eac852ffc1248acbeed66b Mon Sep 17 00:00:00 2001 From: Pratiksha khandagale Date: Wed, 13 Dec 2017 17:13:57 +0530 Subject: [PATCH 2/3] Update users.xml --- users/users.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/users.xml b/users/users.xml index 29e9c90..ec98c24 100644 --- a/users/users.xml +++ b/users/users.xml @@ -2,7 +2,7 @@ PLG_API_USERS 2.0.0 - 10/11/2014 + 15/12/2017 Techjoomla extensions@techjoomla.com www.techjoomla.com From 9843a291d96ceb7abfc0e40ae0fb0f388eab0f13 Mon Sep 17 00:00:00 2001 From: Pratiksha khandagale Date: Wed, 13 Dec 2017 19:58:16 +0530 Subject: [PATCH 3/3] Task #114679 refactor: Remove Conflicts --- users/users/config.php | 179 +++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 116 deletions(-) diff --git a/users/users/config.php b/users/users/config.php index 9e7b6c8..50238a0 100644 --- a/users/users/config.php +++ b/users/users/config.php @@ -9,17 +9,19 @@ * Work derived from the original RESTful API by Techjoomla (https://github.com/techjoomla/Joomla-REST-API) * and the com_api extension by Brian Edgerton (http://www.edgewebworks.com) */ + defined('_JEXEC') or die( 'Restricted access' ); -jimport('joomla.plugin.plugin'); jimport('joomla.html.html'); -jimport('joomla.application.component.controller'); -jimport('joomla.application.component.model'); +jimport('joomla.plugin.plugin'); jimport('joomla.user.helper'); jimport('joomla.user.user'); +jimport('joomla.application.component.controller'); jimport('joomla.application.component.helper'); +jimport('joomla.application.component.model'); JModelLegacy::addIncludePath(JPATH_SITE . 'components/com_api/models'); + require_once JPATH_SITE . '/components/com_api/libraries/authentication/user.php'; require_once JPATH_SITE . '/components/com_api/libraries/authentication/login.php'; @@ -40,22 +42,10 @@ class UsersApiResourceConfig extends ApiResource public function get() { $obj = new stdClass; - $result = new stdClass; - - $app = JFactory::getApplication(); - $acl = $app->input->get('acl', false, boolean); - $userId = $app->input->get('userId', 0, 'INT'); - if ($acl && $userId != 0) - { - $this->getProfileACL($userId); - } - else - { // Get joomla,easyblog and easysocial configuration // Get version of easysocial and easyblog - - $easyblog = JPATH_ADMINISTRATOR . '/components/com_easyblog/easyblog.php'; + $easyblog = JPATH_ADMINISTRATOR . '/components/com_easyblog/easyblog.php'; $easysocial = JPATH_ADMINISTRATOR . '/components/com_easysocial/easysocial.php'; // Eb version @@ -67,40 +57,23 @@ public function get() // Es version if (JFile::exists($easysocial)) { + /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easysocial/easyblog.xml'); + $obj->easysocial_version = (string)$xml->version;*/ $obj->easysocial = $this->getCompParams('com_easysocial', 'easysocial'); } $obj->global_config = $this->getJoomlaConfig(); $obj->plugin_config = $this->getpluginConfig(); - $installed_languages = JLanguageHelper::getLanguages(); - $languages = array(); - - foreach ($installed_languages as $lang) - { - $languages[] = substr($lang->lang_code, 0, 2); - } - - $obj->languages = $languages; - - // $getACL = EB::acl($log_user); - // $obj->ACL = $getACL; - - $xml = JFactory::getXML(JPATH_SITE . '/plugins/api/users/users.xml'); - $obj->plugin_version = (string) $xml->version; - - $result->result = $obj; - - $this->plugin->setResponse($result); - } + $this->plugin->setResponse($obj); } /** - * Method post + * Method to get groups list * - * @return mixed + * @return ApiPlugin response object * - * @since 1.0 + * @since 2.0 */ public function post() { @@ -108,11 +81,11 @@ public function post() } /** - * Method to update auth keys + * Method to update Easyblog auth keys * * @param number $cname The table * @param number $name The table - * + * * @return ApiPlugin response object * * @since 2.0 @@ -120,15 +93,19 @@ public function post() public function getCompParams($cname=null,$name=null) { jimport('joomla.application.component.helper'); - $app = JFactory::getApplication(); + + $app = JFactory::getApplication(); $cdata = array(); - $xml = JFactory::getXML(JPATH_ADMINISTRATOR . '/components/' . $cname . '/' . $name . '.xml'); + $xml = JFactory::getXML(JPATH_ADMINISTRATOR . '/components/' . $cname . '/' . $name . '.xml'); $cdata['version'] = (string) $xml->version; - $jconfig = JFactory::getConfig(); + $jconfig = JFactory::getConfig(); if ($cname == 'com_easyblog') { + /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easyblog/easyblog.xml'); + $version = (string)$xml->version;*/ + if ($cdata['version'] < 5) { require_once JPATH_ROOT . '/components/com_easyblog/helpers/helper.php'; @@ -140,13 +117,13 @@ public function getCompParams($cname=null,$name=null) $eb_params = EB::config(); } - $cdata['main_max_relatedpost'] = $eb_params->get('main_max_relatedpost'); - $cdata['layout_pagination_bloggers'] = $eb_params->get('layout_pagination_bloggers'); - $cdata['layout_pagination_categories'] = $eb_params->get('layout_pagination_categories'); - $cdata['layout_pagination_categories_per_page'] = $eb_params->get('layout_pagination_categories_per_page'); - $cdata['layout_pagination_bloggers_per_page'] = $eb_params->get('layout_pagination_bloggers_per_page'); - $cdata['layout_pagination_archive'] = $eb_params->get('layout_pagination_archive'); - $cdata['layout_pagination_teamblogs'] = $eb_params->get('layout_pagination_teamblogs'); + $cdata['main_max_relatedpost'] = $eb_params->get('main_max_relatedpost'); + $cdata['layout_pagination_bloggers'] = $eb_params->get('layout_pagination_bloggers'); + $cdata['layout_pagination_categories'] = $eb_params->get('layout_pagination_categories'); + $cdata['layout_pagination_categories_per_page'] = $eb_params->get('layout_pagination_categories_per_page'); + $cdata['layout_pagination_bloggers_per_page'] = $eb_params->get('layout_pagination_bloggers_per_page'); + $cdata['layout_pagination_archive'] = $eb_params->get('layout_pagination_archive'); + $cdata['layout_pagination_teamblogs'] = $eb_params->get('layout_pagination_teamblogs'); } else { @@ -154,24 +131,25 @@ public function getCompParams($cname=null,$name=null) $es_params = FD::config(); $profiles = FD::model('profiles'); - // $cdata['conversations_limit'] = $es_params->get('conversations')->limit; - $cdata['activity_limit'] = $es_params->get('activity')->pagination; - $cdata['lists_limit'] = $es_params->get('lists')->display->limit; - $cdata['comments_limit'] = $es_params->get('comments')->limit; - $cdata['stream_pagination_limit'] = $es_params->get('stream')->pagination->pagelimit; - $cdata['photos_pagination_limit'] = $es_params->get('photos')->pagination->photo; - $cdata['album_pagination_limit'] = $es_params->get('photos')->pagination->album; - $cdata['emailasusername'] = $es_params->get('registrations')->emailasusername; - $cdata['displayName'] = $es_params->get('users')->displayName; - $cdata['groups']['enabled'] = $es_params->get('groups')->enabled; - $profiles_data = $profiles->getAllProfiles(); + // $cdata['conversations_limit'] = $es_params->get('conversations')->limit; + $cdata['activity_limit'] = $es_params->get('activity')->pagination; + $cdata['lists_limit'] = $es_params->get('lists')->display->limit; + $cdata['comments_limit'] = $es_params->get('comments')->limit; + $cdata['stream_pagination_limit'] = $es_params->get('stream')->pagination->pagelimit; + $cdata['photos_pagination_limit'] = $es_params->get('photos')->pagination->photo; + $cdata['album_pagination_limit'] = $es_params->get('photos')->pagination->album; + $cdata['emailasusername'] = $es_params->get('registrations')->emailasusername; + $cdata['displayName'] = $es_params->get('users')->displayName; + $cdata['groups']['enabled'] = $es_params->get('groups')->enabled; + + $profiles_data = $profiles->getAllProfiles(); /* Check for profile_type is allowed for Registration by vivek*/ $allowed_profile_types = array(); - foreach ($profiles_data as $key) + foreach ($profiles_data as $key ) { - if ($key->registration == '1' && $key->state == '1') + if ($key->registration == '1') { array_push($allowed_profile_types, $key); } @@ -184,16 +162,16 @@ public function getCompParams($cname=null,$name=null) } /** - * Method get fb plugin config + * Method to Get fb plugin config * - * @return mixed + * @return ApiPlugin response object * - * @since 1.0 + * @since 2.0 */ public function getpluginConfig() { - $data = array(); - $plugin = JPluginHelper::getPlugin('api', 'users'); + $data = array(); + $plugin = JPluginHelper::getPlugin('api', 'users'); $pluginParams = new JRegistry($plugin->params); // Code for future use @@ -201,27 +179,27 @@ public function getpluginConfig() /* $plugin_es = JPluginHelper::getPlugin('api', 'easysocial'); $pluginParams_es = new JRegistry($plugin_es->params); */ - $data['fb_login'] = $pluginParams->get('fb_login'); + $data['fb_login'] = $pluginParams->get('fb_login'); $data['fb_app_id'] = $pluginParams->get('fb_app_id'); - $data['google_client_id'] = $pluginParams->get('google_client_id'); + $data['quick2art'] = $pluginParams->get('quick2art'); return $data; } /** - * Method get joomla config changes + * Method to Get joomla config changes * - * @return mixed + * @return ApiPlugin response object * - * @since 1.0 + * @since 2.0 */ public function getJoomlaConfig() { - $jconfig = JFactory::getConfig(); - $jarray = array(); - $jarray['global_list_limit'] = $jconfig->get('list_limit'); - $jarray['offset'] = $jconfig->get('offset'); - $jarray['offset_user'] = $jconfig->get('offset_user'); + $jconfig = JFactory::getConfig(); + $jarray = array(); + $jarray['global_list_limit'] = $jconfig->get('list_limit'); + $jarray['offset'] = $jconfig->get('offset'); + $jarray['offset_user'] = $jconfig->get('offset_user'); return $jarray; } @@ -231,7 +209,7 @@ public function getJoomlaConfig() * * @param string $user The table * @param string $key The table - * + * * @return ApiPlugin response object * * @since 2.0 @@ -239,44 +217,13 @@ public function getJoomlaConfig() public function updateEauth($user=null,$key=null) { require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; - $model = FD::model('Users'); - $id = $model->getUserId('username', $user->username); - $user = FD::user($id); - $user->alias = $user->username; - $user->auth = $key; + $model = FD::model('Users'); + $id = $model->getUserId('username', $user->username); + $user = FD::user($id); + $user->alias = $user->username; + $user->auth = $key; $user->store(); return $id; } - - /** - * Method use to get ACL config - * - * @param string $userId The table - * - * @return ApiPlugin response object - * - * @since 1.0 - */ - public function getProfileACL($userId) - { - $access = ES::access($userId, SOCIAL_TYPE_USER); - $res = new stdClass; - - $res->result->comments = $access->get('comments'); - $res->result->conversations = $access->get('conversations'); - $res->result->events = $access->get('events'); - $res->result->files = $access->get('files'); - $res->result->friends = $access->get('friends'); - $res->result->groups = $access->get('groups'); - $res->result->albums = $access->get('albums'); - $res->result->photos = $access->get('photos'); - $res->result->polls = $access->get('polls'); - $res->result->reports = $access->get('reports'); - $res->result->story = $access->get('story'); - $res->result->stream = $access->get('stream'); - $res->result->videos = $access->get('videos'); - - $this->plugin->setResponse($res); - } }