| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/administrator/components/com_kunena/src/Model/ |
Upload File : |
<?php
/**
* Kunena Component
*
* @package Kunena.Administrator
* @subpackage Models
*
* @copyright Copyright (C) 2008 - 2025 Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
namespace Kunena\Forum\Administrator\Model;
\defined('_JEXEC') or die();
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Database\QueryInterface;
/**
* Ranks Model for Kunena
*
* @since 3.0
*/
class RanksModel extends ListModel
{
/**
* @param array $config config
*
* @throws Exception
* @since Kunena 6.0
*/
public function __construct($config = [])
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = [
'rankId',
'rankTitle',
'rankMin',
'rankSpecial',
'rankImage',
];
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering ordering
* @param string $direction direction
*
* @return void
*
* @throws Exception
* @since Kunena 6.0
*/
protected function populateState($ordering = 'rankId', $direction = 'asc')
{
// For some reason kunena sets option to com_m instead of com_kunena.
// That is why the workaround to set the context manually
$this->context = 'com_kunena.admin.ranks';
$app = Factory::getApplication();
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout');
$this->context = 'com_kunena.admin.ranks';
if ($layout) {
$this->context .= '.' . $layout;
}
$this->setState('filter.rankTitle', $this->getUserStateFromRequest($this->context . 'filter.rankTitle', 'filter_rankTitle', null, 'string'));
$this->setState('filter.rankSpecial', $this->getUserStateFromRequest($this->context . 'filter.rankSpecial', 'filter_rankSpecial', null, 'string'));
$this->setState('filter.rankMin', $this->getUserStateFromRequest($this->context . 'filter.rankMin', 'filter_rankMin', null, 'int'));
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . 'filter.search', 'filter_search', null, 'string'));
parent::populateState($ordering, $direction);
}
/**
* @param string $id id
*
* @return string
*
* @since Kunena 6.0
*/
protected function getStoreId($id = ''): string
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.rankSpecial');
$id .= ':' . $this->getState('filter.rankMin');
return parent::getStoreId($id);
}
/**
* @return QueryInterface
*
* @since Kunena 6.0
*/
protected function getListQuery(): QueryInterface
{
$db = $this->getDatabase();
$query = $db->createQuery();
$query->select(
$this->getState(
'list.select',
'a.rankId, a.rankTitle, a.rankMin, a.rankSpecial, a.rankImage'
)
);
$query->from($db->quoteName('#__kunena_ranks', 'a'));
// Filter by access level.
$filter = $this->getState('filter.search');
if (!empty($filter)) {
// Searching on title down't work as expected because title is stored as language string
$title = $db->quote('%' . $db->escape($filter, true) . '%');
$query->where('(a.rankTitle LIKE ' . $title . ')');
}
$filter = $this->getState('filter.rankSpecial');
if (is_numeric($filter)) {
$query->where('a.rankSpecial = ' . (int) $filter);
}
$filter = $this->getState('filter.rankMin');
if (is_numeric($filter)) {
$query->where('a.rankMin > ' . (int) $filter);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'rankId');
$orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol && $orderDirn) {
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
return $query;
}
}