| 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/aix/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 Kunena\Forum\Libraries\Forum\Category\KunenaCategory;
use Kunena\Forum\Libraries\Forum\Category\KunenaCategoryHelper;
use RuntimeException;
/**
* Category Model for Kunena
*
* @since 6.0
*/
class CategoryModel extends CategoriesModel
{
/**
* @var KunenaCategory
* @since Kunena 6.0
*/
protected $internalAdminCategory = false;
/**
* @return boolean|KunenaCategory|void
*
* @since Kunena 6.0
*
* @throws Exception
*/
public function getAdminCategory()
{
$category = KunenaCategoryHelper::get($this->getState($this->getName() . '.id'));
if (!$this->me->isAdmin($category)) {
return false;
}
if ($this->internalAdminCategory === false) {
if ($category->exists()) {
if (!$category->isCheckedOut($this->me->userid)) {
$category->checkout($this->me->userid);
}
} else {
// New category is by default child of the first section -- this will help new users to do it right
$db = $this->getDatabase();
$query = $db->createQuery()
->select('a.id, a.name')
->from("{$db->quoteName('#__kunena_categories')} AS a")
->where($db->quoteName('parentid') . '=' . $db->quote('0'))
->where($db->quoteName('id') . '!=' . $db->quote($category->id))
->order('ordering');
$db->setQuery($query);
try {
$this->sections = $db->loadObjectList();
} catch (RuntimeException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return;
}
$category->parentid = $this->getState('item.parent_id');
$category->published = 0;
$category->ordering = 9999;
$category->pubRecurse = 1;
$category->adminRecurse = 1;
$category->accesstype = 'joomla.level';
$category->access = 1;
$category->pubAccess = 1;
$category->adminAccess = 8;
}
$this->internalAdminCategory = $category;
}
return $this->internalAdminCategory;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param null $ordering ordering
* @param null $direction direction
*
* @return void
*
* @since Kunena 6.0
*
* @throws Exception
*/
protected function populateState($ordering = null, $direction = null)
{
$this->context = 'com_kunena.admin.category';
$app = Factory::getApplication();
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout');
$this->context = 'com_kunena.admin.category';
if ($layout) {
$this->context .= '.' . $layout;
}
$value = Factory::getApplication()->input->getInt('catid');
$this->setState($this->getName() . '.id', $value);
}
}