mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
Merge branch 'master' into feature-15029/Docsbox
This commit is contained in:
@@ -89,6 +89,7 @@ class AnrechnungLib
|
||||
$antrag_data->vorname = $person->vorname;
|
||||
$antrag_data->nachname = $person->nachname;
|
||||
$antrag_data->matrikelnr = $student->matrikelnr;
|
||||
$antrag_data->studiengang_kz = $studiengang->studiengang_kz;
|
||||
$antrag_data->stg_bezeichnung = $studiengang->bezeichnung;
|
||||
$antrag_data->lektoren = $lv_lektoren_arr;
|
||||
$antrag_data->zgv = $latest_zgv_bezeichnung;
|
||||
|
||||
@@ -203,7 +203,7 @@ class FilterWidgetLib
|
||||
// Loops in the session for all the filter widgets
|
||||
foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData)
|
||||
{
|
||||
// If this filter widget is not the currrent used filter widget and the it is expired...
|
||||
// If this filter widget is not the current used filter widget and the it is expired...
|
||||
if ($this->_filterUniqueId != $filterWidget && $filterWidgetData[self::SESSION_TIMEOUT] <= time())
|
||||
{
|
||||
cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it
|
||||
@@ -232,7 +232,7 @@ class FilterWidgetLib
|
||||
if ($filterId != null && is_numeric($filterId) && $filterId > 0)
|
||||
{
|
||||
$whereParameters = array(
|
||||
'filter_id' => $filterId
|
||||
self::FILTER_ID => $filterId
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -279,6 +279,18 @@ class FilterWidgetLib
|
||||
if ($definition == null && $whereParameters != null)
|
||||
{
|
||||
$definition = $this->_ci->FiltersModel->loadWhere($whereParameters);
|
||||
|
||||
// Last chance!!!
|
||||
if (!hasData($definition)) // If no data have been found until now the tries the most desperate query
|
||||
{
|
||||
$this->_ci->FiltersModel->addOrder('filter_id', 'ASC'); // sort on column filter_id to get the oldest
|
||||
$whereParameters = array(
|
||||
'app' => $app,
|
||||
'dataset_name' => $datasetName
|
||||
);
|
||||
|
||||
$definition = $this->_ci->FiltersModel->loadWhere($whereParameters);
|
||||
}
|
||||
}
|
||||
|
||||
return $definition;
|
||||
@@ -712,8 +724,11 @@ class FilterWidgetLib
|
||||
{
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel'); // to remove the filter definitions from DB
|
||||
|
||||
// delete it!
|
||||
$this->_ci->FiltersModel->delete(array('filter_id' => $filterId));
|
||||
// Delete it from database
|
||||
$this->_ci->FiltersModel->delete(array(self::FILTER_ID => $filterId));
|
||||
|
||||
// Delete it from session
|
||||
$this->_dropFromSessionFilterWidgetById($filterId);
|
||||
|
||||
$removeCustomFilter = true;
|
||||
}
|
||||
@@ -735,7 +750,7 @@ class FilterWidgetLib
|
||||
$session = $this->getSession(); // The filter currently stored in session (the one that is currently used)
|
||||
if ($session != null)
|
||||
{
|
||||
// Loads the Fitlers model
|
||||
// Loads the Filters model
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Loads all the filters related to this page (same dataset_name and same app name)
|
||||
@@ -761,7 +776,7 @@ class FilterWidgetLib
|
||||
'%s?%s=%s',
|
||||
site_url($navigationPage),
|
||||
self::FILTER_ID,
|
||||
$filter->filter_id
|
||||
$filter->{self::FILTER_ID}
|
||||
) // link
|
||||
);
|
||||
|
||||
@@ -774,7 +789,7 @@ class FilterWidgetLib
|
||||
{
|
||||
$menuEntry['subscriptDescription'] = 'Remove';
|
||||
$menuEntry['subscriptLinkClass'] = 'remove-custom-filter';
|
||||
$menuEntry['subscriptLinkValue'] = $filter->filter_id;
|
||||
$menuEntry['subscriptLinkValue'] = $filter->{self::FILTER_ID};
|
||||
$childrenPersonalArray[] = $menuEntry; // adds to personal filters menu array
|
||||
}
|
||||
}
|
||||
@@ -974,5 +989,29 @@ class FilterWidgetLib
|
||||
|
||||
return $pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove from the session the given filter widget
|
||||
*/
|
||||
private function _dropFromSessionFilterWidgetById($filterId)
|
||||
{
|
||||
// Loads the session for all the filter widgets
|
||||
$filterWidgetsSession = getSession(self::SESSION_NAME);
|
||||
|
||||
// If something is present in session
|
||||
if ($filterWidgetsSession != null)
|
||||
{
|
||||
// Loops in the session for all the filter widgets
|
||||
foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData)
|
||||
{
|
||||
// If this filter widget is not the one that we are looking for
|
||||
if ($filterWidgetData[self::FILTER_ID] == $filterId)
|
||||
{
|
||||
cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it
|
||||
break; // stop to search
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Library for writing and reading issues (problems in fhcomplete system which need resolving)
|
||||
*/
|
||||
class IssuesLib
|
||||
{
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
const APP_INDEX = 'app';
|
||||
const INSERTVON_INDEX = 'insertvon';
|
||||
const FALLBACK_FEHLERCODE_INDEX = 'fallbackFehlercode';
|
||||
|
||||
const STATUS_NEU = 'new';
|
||||
const STATUS_IN_BEARBEITUNG = 'inProgress';
|
||||
const STATUS_BEHOBEN = 'resolved';
|
||||
|
||||
const ERRORTYPE_CODE = 'error';
|
||||
const WARNINGTYPE_CODE = 'warning';
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Properties default values
|
||||
$this->_app = 'core';
|
||||
$this->_insertvon = 'system';
|
||||
$this->_fallbackFehlercode = 'UNKNOWN_ERROR';
|
||||
|
||||
// If parameters are given then overwrite the default values
|
||||
if (!isEmptyArray($params)) $this->setConfigs($params);
|
||||
|
||||
// load models
|
||||
$this->_ci->load->model('system/Issue_model', 'IssueModel');
|
||||
$this->_ci->load->model('system/Fehler_model', 'FehlerModel');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Store configuration parameters for this lib
|
||||
*/
|
||||
public function setConfigs($params)
|
||||
{
|
||||
// If parameters are given then overwrite the default values
|
||||
if (!isEmptyArray($params))
|
||||
{
|
||||
if (isset($params[self::APP_INDEX])) $this->_app = $params[self::APP_INDEX];
|
||||
if (isset($params[self::INSERTVON_INDEX])) $this->_insertvon = $params[self::INSERTVON_INDEX];
|
||||
if (isset($params[self::FALLBACK_FEHLERCODE_INDEX])) $this->_fallbackFehlercode = $params[self::FALLBACK_FEHLERCODE_INDEX];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an Fhc issue, i.e. an internal, self-defined issue.
|
||||
* @param string $fehler_kurzbz short unique text name of the issue
|
||||
* @param int $person_id
|
||||
* @param string $oe_kurzbz
|
||||
* @param array $fehlertext_params params for sprint replace of error text in system.tbl_fehler
|
||||
* @return object success or error
|
||||
*/
|
||||
public function addFhcIssue($fehler_kurzbz, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $resolution_params = null)
|
||||
{
|
||||
$fehlerRes = $this->_ci->FehlerModel->loadWhere(array('fehler_kurzbz' => $fehler_kurzbz));
|
||||
|
||||
if (hasData($fehlerRes))
|
||||
{
|
||||
$fehlercode = getData($fehlerRes)[0]->fehlercode;
|
||||
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
}
|
||||
else
|
||||
return error("Error $fehler_kurzbz not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an external issue, already defined externally by another system.
|
||||
* @param string $fehlercode_extern the error code in the external system
|
||||
* @param string $inhalt_extern error text in external system
|
||||
* @param int $person_id
|
||||
* @param int $oe_kurzbz
|
||||
* @param array $fehlertext_params params for replacement of parts of error text
|
||||
* @param bool $force_predefined if true, only predefined (with entry in fehler table) external issues are added
|
||||
* @return object success or error
|
||||
*/
|
||||
public function addExternalIssue($fehlercode_extern, $inhalt_extern, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null)
|
||||
{
|
||||
if (isEmptyString($fehlercode_extern))
|
||||
return error("fehlercode_extern missing");
|
||||
|
||||
// get external fehlercode (unique for each app)
|
||||
$this->_ci->FehlerModel->addSelect('fehlercode');
|
||||
$fehlerRes = $this->_ci->FehlerModel->loadWhere(
|
||||
array(
|
||||
'fehlercode_extern' => $fehlercode_extern,
|
||||
'app' => $this->_app
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($fehlerRes))
|
||||
return $fehlerRes;
|
||||
|
||||
// check if there is a predefined custom error for the external issue
|
||||
if (hasData($fehlerRes))
|
||||
{
|
||||
$fehlerData = getData($fehlerRes)[0];
|
||||
// if found, use the code
|
||||
$fehlercode = $fehlerData->fehlercode;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if predefined error is not found, insert with fallback code
|
||||
$fehlercode = $this->_fallbackFehlercode;
|
||||
}
|
||||
|
||||
// add external issue
|
||||
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, null, $fehlercode_extern, $inhalt_extern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set issue to resolved.
|
||||
* @param int $issue_id
|
||||
* @param string $user uid of issue resolver
|
||||
* @return object success or error
|
||||
*/
|
||||
public function setBehoben($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_BEHOBEN,
|
||||
'verarbeitetvon' => $user,
|
||||
'verarbeitetamum' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set issue to in progress.
|
||||
* @param int $issue_id
|
||||
* @param string $user uid of issue resovler
|
||||
* @return object success or error
|
||||
*/
|
||||
public function setInBearbeitung($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_IN_BEARBEITUNG,
|
||||
'verarbeitetvon' => $user
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set issue to new.
|
||||
* @param int $issue_id
|
||||
* @param string $user uid of issue resolver
|
||||
* @return object success or error
|
||||
*/
|
||||
public function setNeu($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_NEU,
|
||||
'verarbeitetvon' => null,
|
||||
'verarbeitetamum' => null
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes status of an issue.
|
||||
* @param int $issue_id
|
||||
* @param array $sdata the data to save, including status
|
||||
* @param string $user uid of person changing the status (needed for in Bearbeitung and behoben)
|
||||
* @return success or error
|
||||
*/
|
||||
private function _changeIssueStatus($issue_id, $data, $user)
|
||||
{
|
||||
if (!isset($issue_id) || !is_numeric($issue_id))
|
||||
return error("Issue Id must be set correctly.");
|
||||
|
||||
// check if given status is same as existing
|
||||
$this->_ci->IssueModel->addSelect('status_kurzbz');
|
||||
$currStatus = $this->_ci->IssueModel->load($issue_id);
|
||||
|
||||
if (hasData($currStatus))
|
||||
{
|
||||
if (getData($currStatus)[0]->status_kurzbz == $data['status_kurzbz'])
|
||||
return success("Same status already set");
|
||||
}
|
||||
else
|
||||
return error("Error when getting status");
|
||||
|
||||
$data['updatevon'] = $user;
|
||||
$data['updateamum'] = date('Y-m-d H:i:s');
|
||||
|
||||
return $this->_ci->IssueModel->update(
|
||||
array(
|
||||
'issue_id' => $issue_id
|
||||
),
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an issue.
|
||||
* @param $fehlercode
|
||||
* @param int $person_id
|
||||
* @param string $oe_kurzbz
|
||||
* @param array $fehlertext_params
|
||||
* @param string $resolution_params
|
||||
* @param string $fehlercode_extern
|
||||
* @param string $inhalt_extern
|
||||
* @return object success or error
|
||||
*/
|
||||
private function _addIssue($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $resolution_params = null, $fehlercode_extern = null, $inhalt_extern = null)
|
||||
{
|
||||
if (isEmptyString($person_id) && isEmptyString($oe_kurzbz))
|
||||
return error("Person_id or oe_kurzbz must be set.");
|
||||
|
||||
// get fehlertextVorlage and replace it with params
|
||||
$fehlerRes = $this->_ci->FehlerModel->load($fehlercode);
|
||||
|
||||
if (hasData($fehlerRes))
|
||||
{
|
||||
$fehlertextVorlage = getData($fehlerRes)[0]->fehlertext;
|
||||
$fehlertext = isEmptyArray($fehlertext_params) ? $fehlertextVorlage : vsprintf($fehlertextVorlage, $fehlertext_params);
|
||||
|
||||
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);
|
||||
|
||||
if (hasData($openIssuesCountRes))
|
||||
{
|
||||
// don't insert if issue is already open
|
||||
// already open - status new with same fehlercode or same fehlercode-extern (if set)
|
||||
$openIssueCount = getData($openIssuesCountRes)[0]->anzahl_open_issues;
|
||||
|
||||
if ($openIssueCount == 0)
|
||||
{
|
||||
if (isset($resolution_params))
|
||||
{
|
||||
if (is_array($resolution_params))
|
||||
{
|
||||
foreach ($resolution_params as $resolution_key => $resolution_param)
|
||||
{
|
||||
if (!is_string($resolution_key))
|
||||
return error("Invalid parameter for resolution, must be an associative array");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Invalid parameters for resolution");
|
||||
}
|
||||
|
||||
return $this->_ci->IssueModel->insert(
|
||||
array(
|
||||
'fehlercode' => $fehlercode,
|
||||
'fehlercode_extern' => $fehlercode_extern,
|
||||
'inhalt' => $fehlertext,
|
||||
'inhalt_extern' => $inhalt_extern,
|
||||
'person_id' => $person_id,
|
||||
'oe_kurzbz' => $oe_kurzbz,
|
||||
'datum' => date('Y-m-d H:i:s'),
|
||||
'status_kurzbz' => self::STATUS_NEU,
|
||||
'behebung_parameter' => isset($resolution_params) ? json_encode($resolution_params) : null,
|
||||
'insertvon' => $this->_insertvon
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
return success($openIssueCount);
|
||||
}
|
||||
else
|
||||
return error("Number of open issues could not be determined");
|
||||
}
|
||||
else
|
||||
return error("Error $fehlercode could not be found");
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,18 @@ class JobsQueueLib
|
||||
return $this->_ci->JobsQueueModel->loadWhere(array('status' => self::STATUS_NEW, 'type' => $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* To get all the jobs specified by the given parameters
|
||||
*/
|
||||
public function getJobsByTypeStatus($type, $status)
|
||||
{
|
||||
$this->_ci->JobsQueueModel->resetQuery();
|
||||
|
||||
$this->_ci->JobsQueueModel->addOrder('creationtime', 'DESC');
|
||||
|
||||
return $this->_ci->JobsQueueModel->loadWhere(array('status' => $status, 'type' => $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* To get all the jobs specified by the given parameters
|
||||
*/
|
||||
|
||||
+295
-126
@@ -30,13 +30,14 @@ class UDFLib
|
||||
// ...to specify permissions that are needed to use this TableWidget
|
||||
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
|
||||
|
||||
const PERMISSION_TABLE_METHOD = 'UDFWidget'; // Name for fake method to be checked by the PermissionLib
|
||||
const PERMISSION_TYPE_READ = 'r';
|
||||
const PERMISSION_TYPE_WRITE = 'w';
|
||||
|
||||
// ...to specify the primary key name and value
|
||||
const PRIMARY_KEY_NAME = 'primaryKeyName';
|
||||
const PRIMARY_KEY_VALUE = 'primaryKeyValue';
|
||||
|
||||
const PERMISSION_TABLE_METHOD = 'UDFWidget'; // Name for fake method to be checked by the PermissionLib
|
||||
const PERMISSION_TYPE = 'rw';
|
||||
|
||||
// HTML components
|
||||
const LABEL = 'title';
|
||||
const TITLE = 'description';
|
||||
@@ -76,10 +77,10 @@ class UDFLib
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* UDFWidget
|
||||
*/
|
||||
public function UDFWidget($args, $htmlArgs = array())
|
||||
{
|
||||
* UDFWidget
|
||||
*/
|
||||
public function UDFWidget($args, $htmlArgs = array())
|
||||
{
|
||||
if ((isset($args[self::SCHEMA_ARG_NAME]) && !isEmptyString($args[self::SCHEMA_ARG_NAME]))
|
||||
&& (isset($args[self::TABLE_ARG_NAME]) && !isEmptyString($args[self::TABLE_ARG_NAME])))
|
||||
{
|
||||
@@ -112,16 +113,17 @@ class UDFLib
|
||||
show_error(self::TABLE_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* It renders the HTML of the UDF
|
||||
*
|
||||
* NOTE: When this method is called $widgetData contains different data from
|
||||
* parameter $args in the constructor
|
||||
*/
|
||||
public function displayUDFWidget(&$widgetData)
|
||||
public function displayUDFWidget(&$widgetData)
|
||||
{
|
||||
$field = null;
|
||||
$schema = $widgetData[self::SCHEMA_ARG_NAME]; // schema attribute
|
||||
$table = $widgetData[self::TABLE_ARG_NAME]; // table attribute
|
||||
|
||||
@@ -133,7 +135,7 @@ class UDFLib
|
||||
$udfResults = $this->_loadUDF($schema, $table); // loads UDF definition
|
||||
if (hasData($udfResults))
|
||||
{
|
||||
$udf = $udfResults->retval[0]; // only one record is loaded
|
||||
$udf = getData($udfResults)[0]; // only one record is loaded
|
||||
if (isset($udf->jsons))
|
||||
{
|
||||
$jsonSchemas = json_decode($udf->jsons); // decode the json schema
|
||||
@@ -155,7 +157,7 @@ class UDFLib
|
||||
$found = false; // used to check if the field is found or not in the json schema
|
||||
|
||||
$this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property
|
||||
|
||||
|
||||
// Loops through json schemas
|
||||
foreach ($jsonSchemasArray as $jsonSchema)
|
||||
{
|
||||
@@ -169,21 +171,37 @@ class UDFLib
|
||||
{
|
||||
show_error(sprintf('%s.%s: Attribute "name" not present in the json schema', $schema, $table));
|
||||
}
|
||||
// If the requiredPermissions property is not present then show an error
|
||||
if (!isset($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
{
|
||||
show_error(sprintf('%s.%s: Attribute "requiredPermissions" not present in the json schema', $schema, $table));
|
||||
}
|
||||
|
||||
// Set the required permissions for this UDF
|
||||
$this->_setRequiredPermissions($jsonSchema->{self::NAME}, $jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER});
|
||||
|
||||
// If a UDF is specified and is present in the json schemas list or no UDF is specified
|
||||
if ((isset($field) && $field == $jsonSchema->{self::NAME}) || !isset($field))
|
||||
{
|
||||
// Set attributes using phrases
|
||||
$this->_setAttributesWithPhrases($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
// If the user has the permissions to read this field
|
||||
if ($this->_readAllowed($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
{
|
||||
// Set attributes using phrases
|
||||
$this->_setAttributesWithPhrases($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
|
||||
// Set validation attributes
|
||||
$this->_setValidationAttributes($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
// Set validation attributes
|
||||
$this->_setValidationAttributes($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
|
||||
// Set name and id attributes
|
||||
$this->_setNameAndId($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
// Set name and id attributes
|
||||
$this->_setNameAndId($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
|
||||
// Render the HTML for this UDF
|
||||
$this->_render($jsonSchema, $widgetData);
|
||||
// Set if the field is in read only mode
|
||||
$this->_setReadOnly($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
|
||||
|
||||
// Render the HTML for this UDF
|
||||
$this->_render($jsonSchema, $widgetData);
|
||||
}
|
||||
// otherwise the UDF is not displayed
|
||||
|
||||
// If a UDf is specified and it was found then stop looking through this list
|
||||
if (isset($field) && $field == $jsonSchema->{self::NAME})
|
||||
@@ -213,12 +231,97 @@ class UDFLib
|
||||
show_error(sprintf('%s.%s: Does not contain "jsons" field', $schema, $table));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage UDFs
|
||||
* UDFs permissions check and convertion to read them from database
|
||||
*/
|
||||
public function manageUDFs(&$data, $schemaAndTable, $udfValues = null)
|
||||
public function prepareUDFsRead(&$data, $schemaAndTable, $udfValues = null)
|
||||
{
|
||||
$this->_ci->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
// Retrieves UDFs definitions for this table
|
||||
$resultUDFsDefinitions = $this->_ci->UDFModel->getUDFsDefinitions($schemaAndTable);
|
||||
|
||||
// If an error occurred while reading from database
|
||||
if (isError($resultUDFsDefinitions))
|
||||
{
|
||||
$data = array(); // then set data as an empty array
|
||||
return; // and exit from this method
|
||||
}
|
||||
|
||||
// If there are no UDFs defined for this table the return
|
||||
if (!hasData($resultUDFsDefinitions)) return;
|
||||
|
||||
// If not an error and has data, decodes json that define the UDFs for this table
|
||||
$decodedUDFDefinitions = json_decode(
|
||||
getData($resultUDFsDefinitions)[0]->{self::COLUMN_JSON_DESCRIPTION}
|
||||
);
|
||||
|
||||
// Looping on results, resultElement is an object that represent a database record
|
||||
foreach ($data as $resultElement)
|
||||
{
|
||||
// Decode the JSON column udf_values
|
||||
$udfColumn = json_decode($resultElement->{self::COLUMN_NAME});
|
||||
|
||||
// If this is not a valid JSON then skip to the next database record
|
||||
if ($udfColumn == null) continue;
|
||||
|
||||
// For each UDF column of this database record
|
||||
foreach (get_object_vars($udfColumn) as $columnName => $columnValue)
|
||||
{
|
||||
$udfColumnToBeRemoved = $columnName; // let's try to remove it
|
||||
|
||||
// Loops through the UDFs definitions
|
||||
foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
|
||||
{
|
||||
// If the column exists in the UDF definition
|
||||
if ($columnName == $decodedUDFDefinition->{self::NAME})
|
||||
{
|
||||
$udfColumnToBeRemoved = null; // then keep it
|
||||
}
|
||||
}
|
||||
|
||||
// If in this record have been found a _not_ defined UDF then remove it
|
||||
if (!isEmptyString($udfColumnToBeRemoved)) unset($udfColumn->{$udfColumnToBeRemoved});
|
||||
}
|
||||
|
||||
// Loops through the UDFs definitions
|
||||
foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
|
||||
{
|
||||
// Checks if the requiredPermissions is available and it is a valid array or a valid string
|
||||
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
{
|
||||
// Then check if the user has the permissions to read such UDF
|
||||
if (!$this->_readAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
{
|
||||
// If not then remove the UDF from the result set
|
||||
unset($udfColumn->{$decodedUDFDefinition->{self::NAME}});
|
||||
}
|
||||
}
|
||||
else // If not then remove the UDF from the result set
|
||||
{
|
||||
unset($udfColumn->{$decodedUDFDefinition->{self::NAME}});
|
||||
}
|
||||
}
|
||||
|
||||
// Add the defined and permitted UDF columns to the record set
|
||||
foreach (get_object_vars($udfColumn) as $columnName => $columnValue)
|
||||
{
|
||||
$resultElement->{$columnName} = $columnValue;
|
||||
}
|
||||
|
||||
// And finally remove the UDFs column
|
||||
unset($resultElement->{self::COLUMN_NAME});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UDFs validation and permissions check to write them into database
|
||||
*/
|
||||
public function prepareUDFsWrite(&$data, $schemaAndTable, $udfValues = null)
|
||||
{
|
||||
$validate = success(true); // returned value
|
||||
// Contains a list of validation errors for the UDFs that have not passed the validation
|
||||
@@ -241,18 +344,34 @@ class UDFLib
|
||||
|
||||
// Decodes json that define the UDFs for this table
|
||||
$decodedUDFDefinitions = json_decode(
|
||||
$resultUDFsDefinitions->retval[0]->{self::COLUMN_JSON_DESCRIPTION}
|
||||
getData($resultUDFsDefinitions)[0]->{self::COLUMN_JSON_DESCRIPTION}
|
||||
);
|
||||
|
||||
// Loops through the UDFs definitions
|
||||
for ($i = 0; $i < count($decodedUDFDefinitions); $i++)
|
||||
foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
|
||||
{
|
||||
$decodedUDFDefinition = $decodedUDFDefinitions[$i]; // Definition of a single UDF
|
||||
// Checks if the requiredPermissions is available and it is a valid array or a valid string
|
||||
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|
||||
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|
||||
{
|
||||
// Then check if the user has the permissions to write such UDF
|
||||
if (!$this->_writeAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
{
|
||||
// If the logged user has no permissions then remove the UDF
|
||||
unset($udfsParameters[$decodedUDFDefinition->{self::NAME}]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no permissions have been defined for this UDF then remove it
|
||||
unset($udfsParameters[$decodedUDFDefinition->{self::NAME}]);
|
||||
}
|
||||
|
||||
// Loops through the UDFs values that should be stored
|
||||
foreach ($udfsParameters as $key => $val)
|
||||
{
|
||||
$tmpValidate = success(true); // temporary variable used to store the returned value from _validateUDFs
|
||||
$tmpValidateArray = array(); // temporary variable used to store the returned value from _validateUDFs
|
||||
|
||||
// If this is the definition of this UDF
|
||||
if ($decodedUDFDefinition->{self::NAME} == $key)
|
||||
@@ -314,7 +433,7 @@ class UDFLib
|
||||
|
||||
if ($toBeValidated === true) // Checks if validation should be performed
|
||||
{
|
||||
$tmpValidate = $this->_validateUDFs(
|
||||
$tmpValidateArray = $this->_validateUDFs(
|
||||
$decodedUDFDefinition->{self::VALIDATION},
|
||||
$decodedUDFDefinition->{self::NAME},
|
||||
$val
|
||||
@@ -324,13 +443,13 @@ class UDFLib
|
||||
}
|
||||
|
||||
// If validation is ok copy the value that is to be stored into $toBeStoredUDFsArray
|
||||
if (isSuccess($tmpValidate))
|
||||
if (isEmptyArray($tmpValidateArray))
|
||||
{
|
||||
$toBeStoredUDFsArray[$key] = $val;
|
||||
}
|
||||
else // otherwise store the validation error in $notValidUDFsArray
|
||||
else // otherwise store the validation errors in $notValidUDFsArray
|
||||
{
|
||||
$notValidUDFsArray[] = $tmpValidate;
|
||||
$notValidUDFsArray = array_merge($notValidUDFsArray, $tmpValidateArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,11 +463,11 @@ class UDFLib
|
||||
}
|
||||
|
||||
// If the validation of all the supplied UDFs is ok
|
||||
if (count($notValidUDFsArray) == 0)
|
||||
if (isEmptyArray($notValidUDFsArray))
|
||||
{
|
||||
// An update is performed, then in this case it preserves the values
|
||||
// of the UDF that are not updated
|
||||
if (is_array($udfValues) && count($udfValues) > 0)
|
||||
if (!isEmptyArray($udfValues))
|
||||
{
|
||||
foreach ($udfValues as $fieldName => $fieldValue)
|
||||
{
|
||||
@@ -379,7 +498,7 @@ class UDFLib
|
||||
/**
|
||||
* isUDFColumn
|
||||
*/
|
||||
public function isUDFColumn($columnName, $columnType)
|
||||
public function isUDFColumn($columnName, $columnType = self::COLUMN_TYPE)
|
||||
{
|
||||
$isUDFColumn = false;
|
||||
|
||||
@@ -466,7 +585,7 @@ class UDFLib
|
||||
/**
|
||||
* Save UDFs
|
||||
*/
|
||||
public function saveUDFs($udfUniqueId, $udfs)
|
||||
public function saveUDFs($udfs)
|
||||
{
|
||||
// Read the all session for this udf widget
|
||||
$session = $this->getSession();
|
||||
@@ -490,30 +609,80 @@ class UDFLib
|
||||
// Returns the result of the database update operation to save UDFs
|
||||
return $dbModel->update(
|
||||
array($session[self::PRIMARY_KEY_NAME] => $session[self::PRIMARY_KEY_VALUE]),
|
||||
(array)$udfs
|
||||
get_object_vars($udfs)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if at least one of the permissions given as parameter (requiredPermissions) belongs
|
||||
* to the authenticated user, if confirmed then is allowed to use this UDFWidget.
|
||||
* If the parameter requiredPermissions is NOT given or is not present in the session,
|
||||
* then NO one is allow to use this UDFWidget
|
||||
* Wrapper method to permissionlib->hasAtLeastOne
|
||||
*/
|
||||
public function isAllowed($requiredPermissions = null)
|
||||
{
|
||||
$this->_ci->load->library('PermissionLib'); // Load permission library
|
||||
|
||||
// Gets the required permissions from the session if they are not provided as parameter
|
||||
$rq = $requiredPermissions;
|
||||
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
|
||||
|
||||
return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
//
|
||||
|
||||
/**
|
||||
* Checks if at least one of the permissions given as parameter belongs to the authenticated user in read mode
|
||||
* Wrapper method to permissionlib->hasAtLeastOne
|
||||
*/
|
||||
private function _readAllowed($requiredPermissions)
|
||||
{
|
||||
$readAllowed = false;
|
||||
|
||||
// If the user is logged then it is possible to check the permissions
|
||||
if (isLogged())
|
||||
{
|
||||
$this->_ci->load->library('PermissionLib'); // Load permission library
|
||||
|
||||
$readAllowed = $this->_ci->permissionlib->hasAtLeastOne(
|
||||
$requiredPermissions,
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_READ
|
||||
);
|
||||
} // otherwise it is not possible to check the permissions
|
||||
|
||||
return $readAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if at least one of the permissions given as parameter belongs to the authenticated user in write mode
|
||||
* Wrapper method to permissionlib->hasAtLeastOne
|
||||
*/
|
||||
private function _writeAllowed($requiredPermissions)
|
||||
{
|
||||
$writeAllowed = false;
|
||||
|
||||
// If the user is logged then it is possible to check the permissions
|
||||
if (isLogged())
|
||||
{
|
||||
$this->_ci->load->library('PermissionLib'); // Load permission library
|
||||
|
||||
$writeAllowed = $this->_ci->permissionlib->hasAtLeastOne(
|
||||
$requiredPermissions,
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_WRITE
|
||||
);
|
||||
} // otherwise it is not possible to check the permissions
|
||||
|
||||
return $writeAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an array of required permissions for a UDF into the session
|
||||
*/
|
||||
private function _setRequiredPermissions($udfName, $permissions)
|
||||
{
|
||||
// Get the session for this UDFWidget
|
||||
$session = $this->getSession();
|
||||
|
||||
// If does _not_ exist yet in the session
|
||||
if (!isset($session[self::REQUIRED_PERMISSIONS_PARAMETER]))
|
||||
{
|
||||
$session[self::REQUIRED_PERMISSIONS_PARAMETER] = array();
|
||||
}
|
||||
|
||||
// Set the required permission in the session for this UDFWidget
|
||||
$session[self::REQUIRED_PERMISSIONS_PARAMETER][$udfName] = $permissions;
|
||||
|
||||
// Write into the session
|
||||
$this->setSession($session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the block for UDFs
|
||||
@@ -544,12 +713,12 @@ class UDFLib
|
||||
{
|
||||
$udfsParameters = array();
|
||||
|
||||
foreach ($data as $key => $val)
|
||||
foreach ($data as $columnName => $columnValue)
|
||||
{
|
||||
if (substr($key, 0, 4) == self::COLUMN_PREFIX)
|
||||
if ($this->isUDFColumn($columnName))
|
||||
{
|
||||
$udfsParameters[$key] = $val; // stores UDF value into property UDFs
|
||||
unset($data[$key]); // remove from data
|
||||
$udfsParameters[$columnName] = $columnValue; // stores UDF value into property UDFs
|
||||
unset($data[$columnName]); // remove from data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,29 +814,39 @@ class UDFLib
|
||||
}
|
||||
}
|
||||
|
||||
// If no UDF validation errors were raised, it's a success!!
|
||||
if (count($returnArrayValidation) == 0)
|
||||
{
|
||||
$returnArrayValidation = success(true);
|
||||
}
|
||||
|
||||
return $returnArrayValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name and id attribute of the HTML element
|
||||
*/
|
||||
private function _setNameAndId($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
/**
|
||||
* Disable the HTML element if in read only mode
|
||||
*/
|
||||
private function _setReadOnly($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
// If write permissions _not_ exist then set the field as disabled
|
||||
if (!$this->_writeAllowed($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
|
||||
{
|
||||
$htmlParameters[HTMLWidget::DISABLED] = HTMLWidget::DISABLED; // any values is fine
|
||||
}
|
||||
else // otherwise restore to default
|
||||
{
|
||||
if (isset($htmlParameters[HTMLWidget::DISABLED])) unset($htmlParameters[HTMLWidget::DISABLED]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name and id attribute of the HTML element
|
||||
*/
|
||||
private function _setNameAndId($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
|
||||
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list of UDF by sort property
|
||||
*/
|
||||
private function _sortJsonSchemas(&$jsonSchemasArray)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list of UDF by sort property
|
||||
*/
|
||||
private function _sortJsonSchemas(&$jsonSchemasArray)
|
||||
{
|
||||
usort($jsonSchemasArray, function ($a, $b) {
|
||||
if (!isset($a->{self::SORT}))
|
||||
{
|
||||
@@ -684,13 +863,13 @@ class UDFLib
|
||||
|
||||
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the UDF description by the given schema and table
|
||||
*/
|
||||
private function _loadUDF($schema, $table)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the UDF description by the given schema and table
|
||||
*/
|
||||
private function _loadUDF($schema, $table)
|
||||
{
|
||||
// Loads UDF model
|
||||
$this->_ci->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
@@ -703,18 +882,7 @@ class UDFLib
|
||||
|
||||
if (isError($udfResults))
|
||||
{
|
||||
if (is_object($udfResults) && isset($udfResults->retval))
|
||||
{
|
||||
show_error(getError($udfResults));
|
||||
}
|
||||
elseif (is_string($udfResults))
|
||||
{
|
||||
show_error($udfResults);
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('UDFWidget: generic error occurred');
|
||||
}
|
||||
show_error(getError($udfResults));
|
||||
}
|
||||
elseif (!hasData($udfResults))
|
||||
{
|
||||
@@ -722,13 +890,13 @@ class UDFLib
|
||||
}
|
||||
|
||||
return $udfResults;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the HTML for the UDF
|
||||
*/
|
||||
private function _render($jsonSchema, &$widgetData)
|
||||
{
|
||||
/**
|
||||
* Render the HTML for the UDF
|
||||
*/
|
||||
private function _render($jsonSchema, &$widgetData)
|
||||
{
|
||||
// Checkbox
|
||||
if ($jsonSchema->{self::TYPE} == 'checkbox')
|
||||
{
|
||||
@@ -759,11 +927,11 @@ class UDFLib
|
||||
{
|
||||
$this->_renderDropdown($jsonSchema, $widgetData, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a dropdown element
|
||||
*/
|
||||
/**
|
||||
* Renders a dropdown element
|
||||
*/
|
||||
private function _renderDropdown($jsonSchema, &$widgetData, $multiple = false)
|
||||
{
|
||||
// Selected element/s
|
||||
@@ -792,7 +960,7 @@ class UDFLib
|
||||
$queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{self::LIST_VALUES}->sql);
|
||||
if (hasData($queryResult))
|
||||
{
|
||||
$parameters = $queryResult->retval;
|
||||
$parameters = getData($queryResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,8 +973,8 @@ class UDFLib
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a textarea element
|
||||
*/
|
||||
* Renders a textarea element
|
||||
*/
|
||||
private function _renderTextarea($jsonSchema, &$widgetData)
|
||||
{
|
||||
$text = null; // text value
|
||||
@@ -823,8 +991,8 @@ class UDFLib
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an input text element
|
||||
*/
|
||||
* Renders an input text element
|
||||
*/
|
||||
private function _renderTextfield($jsonSchema, &$widgetData)
|
||||
{
|
||||
$text = null; // text value
|
||||
@@ -841,8 +1009,8 @@ class UDFLib
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a checkbox element
|
||||
*/
|
||||
* Renders a checkbox element
|
||||
*/
|
||||
private function _renderCheckbox($jsonSchema, &$widgetData)
|
||||
{
|
||||
// Set checkbox value if present in the DB
|
||||
@@ -861,11 +1029,11 @@ class UDFLib
|
||||
$checkboxWidgetUDF->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attributes of the HTML element using the phrases system
|
||||
*/
|
||||
private function _setAttributesWithPhrases($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
/**
|
||||
* Sets the attributes of the HTML element using the phrases system
|
||||
*/
|
||||
private function _setAttributesWithPhrases($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
// By default set to null all the attributes
|
||||
$htmlParameters[HTMLWidget::LABEL] = null;
|
||||
$htmlParameters[HTMLWidget::TITLE] = null;
|
||||
@@ -893,7 +1061,7 @@ class UDFLib
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$htmlParameters[HTMLWidget::LABEL] = $tmpResult->retval[0]->text;
|
||||
$htmlParameters[HTMLWidget::LABEL] = getData($tmpResult)[0]->text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,7 +1079,7 @@ class UDFLib
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$htmlParameters[HTMLWidget::TITLE] = $tmpResult->retval[0]->text;
|
||||
$htmlParameters[HTMLWidget::TITLE] = getData($tmpResult)[0]->text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -929,17 +1097,17 @@ class UDFLib
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$htmlParameters[HTMLWidget::PLACEHOLDER] = $tmpResult->retval[0]->text;
|
||||
$htmlParameters[HTMLWidget::PLACEHOLDER] = getData($tmpResult)[0]->text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the validation attributes of the HTML element using the configuration inside the json schema
|
||||
*/
|
||||
private function _setValidationAttributes($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
/**
|
||||
* Sets the validation attributes of the HTML element using the configuration inside the json schema
|
||||
*/
|
||||
private function _setValidationAttributes($jsonSchema, &$htmlParameters)
|
||||
{
|
||||
// Validation attributes set by default to null
|
||||
$htmlParameters[HTMLWidget::REGEX] = null;
|
||||
$htmlParameters[HTMLWidget::REQUIRED] = null;
|
||||
@@ -998,3 +1166,4 @@ class UDFLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ class VorlageLib
|
||||
if (!hasData($vorlage))
|
||||
{
|
||||
// Builds where clause
|
||||
$where = $this->_where($vorlage_kurzbz, $orgform_kurzbz, $sprache);
|
||||
$where = $this->_where($vorlage_kurzbz);
|
||||
|
||||
$vorlage = $this->ci->organisationseinheitlib->treeSearch(
|
||||
'public',
|
||||
@@ -134,20 +134,11 @@ class VorlageLib
|
||||
/**
|
||||
* _where
|
||||
*/
|
||||
private function _where($vorlage_kurzbz, $orgform_kurzbz, $sprache)
|
||||
private function _where($vorlage_kurzbz)
|
||||
{
|
||||
// Builds where clause
|
||||
$where = "vorlage_kurzbz = ".$this->ci->VorlageModel->escape($vorlage_kurzbz);
|
||||
|
||||
if (is_null($sprache))
|
||||
{
|
||||
$where .= " AND sprache IS NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
$where .= " AND sprache = ".$this->ci->VorlageModel->escape($sprache);
|
||||
}
|
||||
|
||||
$where .= " AND aktiv = true";
|
||||
|
||||
return $where;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Bisio Zweck does not exist
|
||||
*/
|
||||
class CORE_INOUT_0001 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
|
||||
|
||||
// get all bisio Zwecke
|
||||
$this->_ci->BisiozweckModel->addSelect('1');
|
||||
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisiozweckRes))
|
||||
return $bisiozweckRes;
|
||||
|
||||
if (hasData($bisiozweckRes))
|
||||
return success(true); // resolved if bisio Zweck exists
|
||||
else
|
||||
return success(false); // not resolved if no bisio zweck
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* More than one Zweck for incoming
|
||||
*/
|
||||
class CORE_INOUT_0002 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
|
||||
|
||||
// get all bisio Zwecke
|
||||
$this->_ci->BisiozweckModel->addSelect('1');
|
||||
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisiozweckRes))
|
||||
return $bisiozweckRes;
|
||||
|
||||
if (hasData($bisiozweckRes))
|
||||
{
|
||||
if (count(getData($bisiozweckRes)) <= 1) // resolved if one bisio Zweck
|
||||
return success(true);
|
||||
else
|
||||
return success(false); // otherwise not resolved
|
||||
}
|
||||
else
|
||||
return success(true); // resolved if no bisio zweck
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Invalid Zweck for incoming
|
||||
*/
|
||||
class CORE_INOUT_0003 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
|
||||
|
||||
// get all Zwecke
|
||||
$this->_ci->BisiozweckModel->addSelect('zweck_code');
|
||||
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisiozweckRes))
|
||||
return $bisiozweckRes;
|
||||
|
||||
if (hasData($bisiozweckRes))
|
||||
{
|
||||
$bisiozweckData = getData($bisiozweckRes);
|
||||
|
||||
// resolved if Zweck is 1, 2 or 3
|
||||
if (count($bisiozweckData) == 1 && !in_array($bisiozweckData[0]->zweck_code, array(1, 2, 3)))
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Aufenthaltsförderung must exist if certain length of outgoing stay is exceeded
|
||||
*/
|
||||
class CORE_INOUT_0004 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Aufenthaltfoerderung_model', 'AufenthaltfoerderungModel');
|
||||
|
||||
// get all Zwecke
|
||||
$this->_ci->AufenthaltfoerderungModel->addSelect('tbl_aufenthaltfoerderung.aufenthaltfoerderung_code');
|
||||
$this->_ci->AufenthaltfoerderungModel->addJoin('bis.tbl_bisio_aufenthaltfoerderung', 'aufenthaltfoerderung_code');
|
||||
$this->_ci->AufenthaltfoerderungModel->addOrder('tbl_aufenthaltfoerderung.aufenthaltfoerderung_code');
|
||||
$bisioFoerderungRes = $this->_ci->AufenthaltfoerderungModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisioFoerderungRes))
|
||||
return $bisioFoerderungRes;
|
||||
|
||||
if (hasData($bisioFoerderungRes))
|
||||
{
|
||||
// resolved if Aufenthaltsfoerderung exists
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
|
||||
|
||||
// get Bisio Aufenthaltsdauer
|
||||
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
|
||||
|
||||
if (isError($aufenthaltsdauerRes))
|
||||
return $aufenthaltsdauerRes;
|
||||
|
||||
if (hasData($aufenthaltsdauerRes))
|
||||
{
|
||||
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
|
||||
|
||||
// check if stay >= 29 days. If yes and no Aufenthaltsfoerderung - not resolved
|
||||
if ($aufenthaltsdauer >= 29)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else // no Aufenthaltsdauer - not resolved
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ECTS angerechnet must exist for outgoing if longer stay
|
||||
*/
|
||||
class CORE_INOUT_0005 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
|
||||
|
||||
// get all Zwecke
|
||||
$this->_ci->BisioModel->addSelect('ects_angerechnet');
|
||||
$bisioRes = $this->_ci->BisioModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisioRes))
|
||||
return $bisioRes;
|
||||
|
||||
if (hasData($bisioRes) && !isEmptyString(getData($bisioRes)[0]->ects_angerechnet))
|
||||
{
|
||||
// resolved if ects exists
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get Bisio Aufenthaltsdauer
|
||||
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
|
||||
|
||||
if (isError($aufenthaltsdauerRes))
|
||||
return $aufenthaltsdauerRes;
|
||||
|
||||
if (hasData($aufenthaltsdauerRes))
|
||||
{
|
||||
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
|
||||
|
||||
// check if stay >= 29 days. If yes and no ects - not resolved
|
||||
if ($aufenthaltsdauer >= 29)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else // no Aufenthaltsdauer - not resolved
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ECTS erworben must exist for outgoing if longer stay
|
||||
*/
|
||||
class CORE_INOUT_0006 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
|
||||
return error('Bisio Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
|
||||
//$this->_ci->load->model('codex/Aufenthaltfoerderung_model', 'AufenthaltfoerderungModel');
|
||||
|
||||
// get all Zwecke
|
||||
$this->_ci->BisioModel->addSelect('ects_erworben');
|
||||
$bisioRes = $this->_ci->BisioModel->loadWhere(array('bisio_id' => $params['bisio_id']));
|
||||
|
||||
if (isError($bisioRes))
|
||||
return $bisioRes;
|
||||
|
||||
if (hasData($bisioRes) && !isEmptyString(getData($bisioRes)[0]->ects_erworben))
|
||||
{
|
||||
// resolved if ects exists
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get Bisio Aufenthaltsdauer
|
||||
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
|
||||
|
||||
if (isError($aufenthaltsdauerRes))
|
||||
return $aufenthaltsdauerRes;
|
||||
|
||||
if (hasData($aufenthaltsdauerRes))
|
||||
{
|
||||
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
|
||||
|
||||
// check if stay >= 29 days. If yes and no ects - not resolved
|
||||
if ($aufenthaltsdauer >= 29)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else // no Aufenthaltsdauer - not resolved
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ZGV Datum in future
|
||||
*/
|
||||
class CORE_ZGV_0001 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// get zgvdatum of prestudent
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->_ci->PrestudentModel->addSelect('zgvdatum');
|
||||
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
|
||||
|
||||
if (isError($prestudentRes))
|
||||
return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$zgvdatum = getData($prestudentRes)[0]->zgvdatum;
|
||||
|
||||
if (isEmptyString($zgvdatum))
|
||||
return success(false);
|
||||
|
||||
// check if zgvdatum comes after today
|
||||
if ($zgvdatum > date('Y-m-d'))
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ZGV Datum must be after Geburtsdatum
|
||||
*/
|
||||
class CORE_ZGV_0002 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// get zgvdatum of prestudent
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->_ci->PrestudentModel->addSelect('zgvdatum, gebdatum');
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
|
||||
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
|
||||
|
||||
if (isError($prestudentRes))
|
||||
return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudentData = getData($prestudentRes)[0];
|
||||
|
||||
$zgvdatum = $prestudentData->zgvdatum;
|
||||
|
||||
if (isEmptyString($zgvdatum))
|
||||
return success(false);
|
||||
|
||||
$gebdatum = $prestudentData->gebdatum;
|
||||
|
||||
if (isEmptyString($gebdatum))
|
||||
return success(false);
|
||||
|
||||
// check if zgvdatum comes before geburtsdatum
|
||||
if ($zgvdatum < $gebdatum)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ZGV master Datum in future
|
||||
*/
|
||||
class CORE_ZGV_0003 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// get zgvdatum of prestudent
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->_ci->PrestudentModel->addSelect('zgvmadatum');
|
||||
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
|
||||
|
||||
if (isError($prestudentRes))
|
||||
return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$zgvdatum = getData($prestudentRes)[0]->zgvmadatum;
|
||||
|
||||
if (isEmptyString($zgvdatum))
|
||||
return success(false);
|
||||
|
||||
// check if zgvdatum comes after today
|
||||
if ($zgvdatum > date('Y-m-d'))
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ZGV Datum should not be after ZGV master Datum
|
||||
*/
|
||||
class CORE_ZGV_0004 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// get zgvdatum of prestudent
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->_ci->PrestudentModel->addSelect('zgvdatum, zgvmadatum');
|
||||
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
|
||||
|
||||
if (isError($prestudentRes))
|
||||
return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudentData = getData($prestudentRes)[0];
|
||||
|
||||
// get and compare zgvdatum and zgvmadatum
|
||||
$zgvdatum = $prestudentData->zgvdatum;
|
||||
|
||||
if (isEmptyString($zgvdatum))
|
||||
return success(false);
|
||||
|
||||
$zgvmadatum = $prestudentData->zgvmadatum;
|
||||
|
||||
if (isEmptyString($zgvmadatum))
|
||||
return success(false);
|
||||
|
||||
// check if zgvmadatum comes after zgvdatum
|
||||
if ($zgvmadatum < $zgvdatum)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* ZGV master Datum before Geburtsdatum
|
||||
*/
|
||||
class CORE_ZGV_0005 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// get zgvdatum and geburtsdatum of prestudent
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->_ci->PrestudentModel->addSelect('zgvmadatum, gebdatum');
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
|
||||
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
|
||||
|
||||
if (isError($prestudentRes))
|
||||
return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudentData = getData($prestudentRes)[0];
|
||||
|
||||
$zgvdatum = $prestudentData->zgvmadatum;
|
||||
|
||||
if (isEmptyString($zgvdatum))
|
||||
return success(false);
|
||||
|
||||
$gebdatum = $prestudentData->gebdatum;
|
||||
|
||||
if (isEmptyString($gebdatum))
|
||||
return success(false);
|
||||
|
||||
// check if zgvdatum comes before geburtsdatum
|
||||
if ($zgvdatum < $gebdatum)
|
||||
return success(false);
|
||||
else
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user