mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +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
95 lines
2.9 KiB
PHP
95 lines
2.9 KiB
PHP
<?php
|
|
|
|
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/**
|
|
* This controller operates between (interface) the JS (GUI) and the UDFLib (back-end)
|
|
* Provides data to the ajax get calls about the UDF widget
|
|
* Accepts ajax post calls to save UDFs
|
|
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
|
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the UDFWidget has its
|
|
* own permissions check
|
|
*/
|
|
class UDF extends FHC_Controller
|
|
{
|
|
const UDF_UNIQUE_ID = 'udfUniqueId'; // Name of the udf widget unique id
|
|
|
|
/**
|
|
* Calls the parent's constructor and loads the UDFLib
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
// Loads authentication library and starts authentication
|
|
$this->load->library('AuthLib');
|
|
|
|
// Loads the UDFLib with HTTP GET/POST parameters
|
|
$this->_loadUDFLib();
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
// Public methods
|
|
|
|
/**
|
|
* Save data about the current UDFs and the result will be written on the output in JSON format
|
|
*/
|
|
public function saveUDFs()
|
|
{
|
|
$udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID);
|
|
$udfs = $this->input->post(UDFLib::UDFS_ARG_NAME);
|
|
|
|
if (!isEmptyString($udfs))
|
|
{
|
|
$jsonDecodedUDF = json_decode($udfs);
|
|
if ($jsonDecodedUDF != null)
|
|
{
|
|
$this->outputJson($this->udflib->saveUDFs($udfUniqueId, $jsonDecodedUDF));
|
|
}
|
|
else
|
|
{
|
|
$this->outputJsonError('No valid JSON format for UDF values');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$this->outputJsonError('UDFUniqueId, schema, table name, primary key name and primary key value are mandatory paramenters');
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
// Private methods
|
|
|
|
/**
|
|
* Loads the UDFLib with the UDF_UNIQUE_ID parameter
|
|
* If the parameter UDF_UNIQUE_ID is not given then the execution of the controller is terminated and
|
|
* an error message is printed
|
|
*/
|
|
private function _loadUDFLib()
|
|
{
|
|
// If the parameter UDF_UNIQUE_ID is present in the HTTP GET or POST
|
|
if (isset($_GET[self::UDF_UNIQUE_ID]) || isset($_POST[self::UDF_UNIQUE_ID]))
|
|
{
|
|
// If it is present in the HTTP GET
|
|
if (isset($_GET[self::UDF_UNIQUE_ID]))
|
|
{
|
|
$udfUniqueId = $this->input->get(self::UDF_UNIQUE_ID); // is retrieved from the HTTP GET
|
|
}
|
|
elseif (isset($_POST[self::UDF_UNIQUE_ID])) // Else if it is present in the HTTP POST
|
|
{
|
|
$udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID); // is retrieved from the HTTP POST
|
|
}
|
|
|
|
// Loads the UDFLib that contains all the used logic
|
|
$this->load->library('UDFLib');
|
|
|
|
$this->udflib->setUDFUniqueId($udfUniqueId);
|
|
}
|
|
else // Otherwise an error will be written in the output
|
|
{
|
|
$this->terminateWithJsonError('Parameter "'.self::UDF_UNIQUE_ID.'" not provided!');
|
|
}
|
|
}
|
|
}
|
|
|