first commit
This commit is contained in:
77
administrator/src/Helper/CircolariHelper.php
Normal file
77
administrator/src/Helper/CircolariHelper.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @version CVS: 1.0.0
|
||||
* @package Com_Circolari
|
||||
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
|
||||
* @copyright 2025 Tommaso Cippitelli
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Pcrt\Component\Circolari\Administrator\Helper;
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use \Joomla\CMS\Factory;
|
||||
use \Joomla\CMS\Language\Text;
|
||||
use \Joomla\CMS\Object\CMSObject;
|
||||
|
||||
/**
|
||||
* Circolari helper.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class CircolariHelper
|
||||
{
|
||||
/**
|
||||
* Gets the files attached to an item
|
||||
*
|
||||
* @param int $pk The item's id
|
||||
*
|
||||
* @param string $table The table's name
|
||||
*
|
||||
* @param string $field The field's name
|
||||
*
|
||||
* @return array The files
|
||||
*/
|
||||
public static function getFiles($pk, $table, $field)
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query
|
||||
->select($field)
|
||||
->from($table)
|
||||
->where('id = ' . (int) $pk);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return explode(',', $db->loadResult());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @return CMSObject
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getActions()
|
||||
{
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
$result = new CMSObject;
|
||||
|
||||
$assetName = 'com_circolari';
|
||||
|
||||
$actions = array(
|
||||
'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete'
|
||||
);
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($action, $user->authorise($action, $assetName));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user