Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #114679 refactor: [User Plugin] - Resolved Phpcs error and code … #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions users/users.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0.0" type="plugin" group="api" method="upgrade">
<name>PLG_API_USERS</name>
<version>1.8.7</version>
<creationDate>10/11/2014</creationDate>
<version>2.0.0</version>
<creationDate>15/12/2017</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.techjoomla.com</authorUrl>
Expand All @@ -25,6 +25,7 @@
<option value="1">Yes</option>
</field>
<field name="fb_app_id" type="text" default="" label="Facebook Application ID" description="Facebook Application ID" />
<field name="google_client_id" type="text" default="" label="Google Client ID" description="Google Client ID" />
</fieldset>
</fields>
</config>
Expand Down
246 changes: 153 additions & 93 deletions users/users/config.php
Original file line number Diff line number Diff line change
@@ -1,169 +1,229 @@
<?php
/**
* @package API plugins
* @copyright Copyright (C) 2009 2014 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @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 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @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.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');

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/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 ) )

// 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');
$obj->easyblog = $this->getCompParams('com_easyblog', 'easyblog');
}
//es version
if( JFile::exists( $easysocial ) )

// 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);
$this->plugin->setResponse($obj);
}

/**
* Method to get groups list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update desc.

*
* @return ApiPlugin response object
*
* @since 2.0
*/
public function post()
{
$this->plugin->setResponse( JText::_( 'PLG_API_USERS_UNSUPPORTED_METHOD_POST' ));
$this->plugin->setResponse(JText::_('PLG_API_USERS_UNSUPPORTED_METHOD_POST'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you do it like

$this->plugin->err_code		= 405;
$this->plugin->err_message	= JText::_('PLG_API_USERS_GET_METHOD_NOT_ALLOWED_MESSAGE');
$this->plugin->setResponse(null);```

}


//get component params
/**
* Method to update Easyblog 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();

$app = JFactory::getApplication();
$cdata = array();
$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/'.$cname.'/'.$name.'.xml');
$cdata['version'] = (string)$xml->version;
$jconfig = JFactory::getConfig();
if( $cname == 'com_easyblog' )

$xml = JFactory::getXML(JPATH_ADMINISTRATOR . '/components/' . $cname . '/' . $name . '.xml');
$cdata['version'] = (string) $xml->version;
$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' );
$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');
/*$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');

$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' );
$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['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;
$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')
{
array_push($allowed_profile_types, $key);
}
}

$cdata['profile_types'] = $allowed_profile_types;
}

return $cdata;
}

// get fb plugin config

/**
* Method to Get fb plugin config
*
* @return ApiPlugin response object
*
* @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
/*$plugin_es = JPluginHelper::getPlugin('api', 'easysocial');
$pluginParams_es = new JRegistry($plugin_es->params);*/

$data['fb_login'] = $pluginParams->get('fb_login');

// 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');

return $data;
}


//get joomla config changes
/**
* Method to Get joomla config changes
*
* @return ApiPlugin response object
*
* @since 2.0
*/
public function getJoomlaConfig()
{
$jconfig = JFactory::getConfig();
$jarray = array();
$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');
$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);
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->auth = $key;
$user->store();

return $id;
}
}
Loading