mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
9c84558f5f
- Removed the private method _isAllowed from application/controllers/widgets/UDF.php - Removed required permissions from views application/views/system/fas_udf.php and application/views/system/infocenter/zgvpruefungen.php - Widget views application/views/widgets/checkbox, dropdown, textarea and textfield now they print the attribute disabled - Added constant DISABLED to application/widgets/html/HTMLWidget.php - Removed private property _requiredPermissions from application/widgets/udf/UDFWidget.php - application/widgets/udf/UDFWidget.php does not check permissions anymore and does not store them anymore - Added constants PERMISSION_TYPE_READ and PERMISSION_TYPE_WRITE to application/libraries/UDFLib.php - Removed constant PERMISSION_TYPE from application/libraries/UDFLib.php - Removed public method isAllowed from application/libraries/UDFLib.php - Added private methods _readAllowed, _writeAllowed, _setRequiredPermissions and _setReadOnly to application/libraries/UDFLib.php - UDFLib->displayUDFWidget now checks if permissions are declared in the UDF JSON and if the user is allowed to read and write such UDF - UDFLib->saveUDFs now checks if the user has the permissions to write such UDF - Now the UDFs are even displayed in read only mode
137 lines
3.5 KiB
PHP
137 lines
3.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Represents a generic UDF element
|
|
* It's used to render the HTML of a UDF element using widgets
|
|
*/
|
|
class UDFWidget extends HTMLWidget
|
|
{
|
|
private $_schema; // Schema name
|
|
private $_table; // Table name
|
|
private $_primaryKeyName; // Primary key name
|
|
private $_primaryKeyValue; // Primary key value
|
|
|
|
/**
|
|
* Initialize the UDFWidget and starts the execution of the logic
|
|
*/
|
|
public function __construct($name, $args = array())
|
|
{
|
|
parent::__construct($name, $args); // calls the parent's constructor
|
|
|
|
$this->load->library('UDFLib'); // Loads the UDFLib that contains all the used logic
|
|
|
|
$this->udflib->setUDFUniqueIdByParams($args); // sets the unique id for this UDF
|
|
|
|
$this->_initUDFWidget($args); // checks parameters and initialize properties
|
|
|
|
$this->_startUDFWidget($args[UDFLib::UDF_UNIQUE_ID]);
|
|
}
|
|
|
|
/**
|
|
* Called by the WidgetLib, it renders the HTML of the UDF
|
|
*/
|
|
public function display($widgetData)
|
|
{
|
|
$this->_ci->udflib->displayUDFWidget($widgetData);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
// Private methods
|
|
|
|
/**
|
|
* Checks parameters and initialize all the properties of this UDFWidget
|
|
*/
|
|
private function _initUDFWidget($args)
|
|
{
|
|
$this->_checkParameters($args);
|
|
|
|
// If here then everything is ok
|
|
|
|
// Initialize class properties
|
|
$this->_schema = null;
|
|
$this->_table = null;
|
|
$this->_primaryKeyName = null;
|
|
$this->_primaryKeyValue = null;
|
|
|
|
// Retrieved the
|
|
if (isset($args[UDFLib::SCHEMA_ARG_NAME]))
|
|
{
|
|
$this->_schema = $args[UDFLib::SCHEMA_ARG_NAME];
|
|
}
|
|
|
|
// Retrieved the
|
|
if (isset($args[UDFLib::TABLE_ARG_NAME]))
|
|
{
|
|
$this->_table = $args[UDFLib::TABLE_ARG_NAME];
|
|
}
|
|
|
|
// Retrieved the
|
|
if (isset($args[UDFLib::PRIMARY_KEY_NAME]))
|
|
{
|
|
$this->_primaryKeyName = $args[UDFLib::PRIMARY_KEY_NAME];
|
|
}
|
|
|
|
// Retrieved the
|
|
if (isset($args[UDFLib::PRIMARY_KEY_VALUE]))
|
|
{
|
|
$this->_primaryKeyValue = $args[UDFLib::PRIMARY_KEY_VALUE];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks the required parameters used to call this UDFWidget
|
|
*/
|
|
private function _checkParameters($args)
|
|
{
|
|
if (!is_array($args) || (is_array($args) && count($args) == 0))
|
|
{
|
|
show_error('Second parameter of the widget call must be a NOT empty associative array');
|
|
}
|
|
else
|
|
{
|
|
if (!isset($args[UDFLib::UDF_UNIQUE_ID]))
|
|
{
|
|
show_error('The parameter "'.UDFLib::UDF_UNIQUE_ID.'" must be specified');
|
|
}
|
|
|
|
if (!isset($args[UDFLib::SCHEMA_ARG_NAME]))
|
|
{
|
|
show_error('The parameter "'.UDFLib::SCHEMA_ARG_NAME.'" must be specified');
|
|
}
|
|
|
|
if (!isset($args[UDFLib::TABLE_ARG_NAME]))
|
|
{
|
|
show_error('The parameter "'.UDFLib::TABLE_ARG_NAME.'" must be specified');
|
|
}
|
|
|
|
if (!isset($args[UDFLib::PRIMARY_KEY_NAME]))
|
|
{
|
|
show_error('The parameter "'.UDFLib::PRIMARY_KEY_NAME.'" must be specified');
|
|
}
|
|
|
|
if (!isset($args[UDFLib::PRIMARY_KEY_VALUE]))
|
|
{
|
|
show_error('The parameter "'.UDFLib::PRIMARY_KEY_VALUE.'" must be specified');
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Contains all the logic used to load all the data needed to the UDFWidget
|
|
*/
|
|
private function _startUDFWidget($udfUniqueId)
|
|
{
|
|
// Stores an array that contains all the data useful for
|
|
$this->udflib->setSession(
|
|
array(
|
|
UDFLib::UDF_UNIQUE_ID => $udfUniqueId, // table unique id
|
|
UDFLib::SCHEMA_ARG_NAME => $this->_schema, //
|
|
UDFLib::TABLE_ARG_NAME => $this->_table, //
|
|
UDFLib::PRIMARY_KEY_NAME => $this->_primaryKeyName, //
|
|
UDFLib::PRIMARY_KEY_VALUE => $this->_primaryKeyValue //
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|