| Current Path : /var/www/html/administrator/components/com_jchat/Controller/ |
| Current File : /var/www/html/administrator/components/com_jchat/Controller/UsersController.php |
<?php
namespace JExtstore\Component\JChat\Administrator\Controller;
/**
*
* @package JCHAT::USERS::administrator::components::com_jchat
* @subpackage controllers
* @author Joomla! Extensions Store
* @copyright (C) 2024 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use JExtstore\Component\JChat\Administrator\Framework\Controller as JChatController;
/**
* Users concrete implementation
*
* @package JCHAT::USERS::administrator::components::com_jchat
* @subpackage controllers
* @since 1.6
*/
class UsersController extends JChatController {
/**
* Setta il model state a partire dallo userstate di sessione
* @access protected
* @param string $scope
* @param boolean $ordering
* @return object
*/
protected function setModelState($scope = 'default', $ordering = true): object {
$option = $this->option;
$ban_status = $this->getUserStateFromRequest( "$option.users.banstatus", 'banstatus', '');
$filter_order = $this->getUserStateFromRequest("$option.users.filter_order", 'filter_order', 'a.id', 'cmd');
$filter_order_Dir = $this->getUserStateFromRequest("$option.users.filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
$defaultModel = parent::setModelState('users');
// Set model state
$defaultModel->setState('banstatus', $ban_status);
$defaultModel->setState('order', $filter_order);
$defaultModel->setState('order_dir', $filter_order_Dir);
return $defaultModel;
}
/**
* Default listEntities
*
* @access public
* @return void
*/
public function display($cachable = false, $urlparams = false) {
// Set model state
$this->setModelState('users');
// Parent construction and view display
parent::display($cachable);
}
/**
* Delete a db table entity
*
* @access public
* @return void
*/
public function banEntity() {
$cids = $this->app->getInput()->get ( 'cid', array (), 'array' );
$option = $this->option;
// Load della model e checkin before exit
$model = $this->getModel ();
$result = $model->banEntity ($cids, $this->task);
if (! $result) {
// Model set exceptions for something gone wrong, so enqueue exceptions and levels on application object then set redirect and exit
$modelException = $model->getException ( null, false );
$this->app->enqueueMessage ( $modelException->getMessage (), $modelException->getExceptionLevel () );
$this->setRedirect ( "index.php?option=$option&task=users.display", Text::_ ( 'COM_JCHAT_ERROR_BANSTATUS' ) );
return false;
}
$this->setRedirect ( "index.php?option=$option&task=users.display", Text::_ ( 'COM_JCHAT_SUCCESS_BANSTATUS' ) );
}
/**
* Constructor.
*
* @access protected
* @param
* array An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task',
* 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @since 1.5
*/
public function __construct($config = array(), ?MVCFactoryInterface $factory = null, $app = null, $input = null) {
parent::__construct($config, $factory, $app, $input);
$this->registerTask('unbanEntity', 'banEntity');
}
}