Merge branch 'feature-5491/UDFWidget_add_new_features'

This commit is contained in:
Andreas Österreicher
2020-04-23 12:24:21 +02:00
18 changed files with 904 additions and 605 deletions
+8 -83
View File
@@ -7,60 +7,34 @@ class FAS_UDF extends Auth_Controller
const FAS_UDF_SESSION_NAME = 'fasUdfSessionName';
public function __construct()
{
parent::__construct(
{
parent::__construct(
array(
'index' => 'basis/person:r',
'saveUDF' => 'basis/person:rw'
)
);
$this->load->model('person/Person_model', 'PersonModel');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
}
}
/**
*
*/
public function index()
{
$fasUdfSession = getSession(self::FAS_UDF_SESSION_NAME);
$person_id = $this->input->get('person_id');
if (isset($fasUdfSession['person_id']))
{
if (!isset($person_id))
{
$person_id = $fasUdfSession['person_id'];
}
unset($fasUdfSession['person_id']);
}
$prestudent_id = $this->input->get('prestudent_id');
if (isset($fasUdfSession['prestudent_id']))
{
if (!isset($prestudent_id))
{
$prestudent_id = $fasUdfSession['prestudent_id'];
}
unset($fasUdfSession['prestudent_id']);
}
$result = null;
if (isset($fasUdfSession['result']))
{
$result = clone $fasUdfSession['result'];
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', null);
}
$data = array('result' => $result);
$data = array();
if (isset($person_id) && is_numeric($person_id))
{
if ($this->PersonModel->hasUDF())
{
$personUdfs = $this->PersonModel->getUDFs($person_id);
$personUdfs['person_id'] = $person_id;
$data['person_id'] = $person_id;
$data['personUdfs'] = $personUdfs;
}
}
@@ -70,61 +44,12 @@ class FAS_UDF extends Auth_Controller
if ($this->PrestudentModel->hasUDF())
{
$prestudentUdfs = $this->PrestudentModel->getUDFs($prestudent_id);
$prestudentUdfs['prestudent_id'] = $prestudent_id;
$data['prestudent_id'] = $prestudent_id;
$data['prestudentUdfs'] = $prestudentUdfs;
}
}
$this->load->view('system/fas_udf', $data);
}
/**
*
*/
public function saveUDF()
{
$udfs = $this->input->post();
$validation = $this->_validate($udfs);
$userdata = array(
'person_id' => $this->input->post('person_id'),
'prestudent_id' => $this->input->post('prestudent_id')
);
if (isSuccess($validation))
{
// Load model UDF_model
$this->load->model('system/FAS_UDF_model', 'FASUDFModel');
$result = $this->FASUDFModel->saveUDFs($udfs);
$userdata['result'] = $result;
}
else
{
$userdata['result'] = $validation;
}
setSessionElement(self::FAS_UDF_SESSION_NAME, 'person_id', $userdata['person_id']);
setSessionElement(self::FAS_UDF_SESSION_NAME, 'prestudent_id', $userdata['prestudent_id']);
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', $userdata['result']);
redirect('system/FAS_UDF');
}
/**
*
*/
private function _validate($udfs)
{
$validation = error('person_id or prestudent_id is missing');
if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != ''))
|| (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != '')))
{
$validation = success(true);
}
return $validation;
}
}
@@ -1337,7 +1337,7 @@ class InfoCenter extends Auth_Controller
show_error(getError($prestudentWithZgv));
}
$zgvpruefung = $prestudentWithZgv->retval[0];
$zgvpruefung = getData($prestudentWithZgv);
if (isset($zgvpruefung->prestudentstatus))
{
@@ -1362,11 +1362,15 @@ class InfoCenter extends Auth_Controller
$zgvpruefung->isRtFreigegeben = false;
$zgvpruefung->isStgFreigegeben = false;
$zgvpruefung->sendStgFreigabeMsg = true;//wether Stgudiengangfreigabemessage can be sent (for "exceptions", Studiengänge with no message sending)
$this->PrestudentstatusModel->addSelect('bestaetigtam, statusgrund_id, tbl_status_grund.bezeichnung_mehrsprachig AS bezeichnung_statusgrund');
$this->PrestudentstatusModel->addJoin('public.tbl_status_grund', 'statusgrund_id', 'LEFT');
$isFreigegeben = $this->PrestudentstatusModel->loadWhere(array('studiensemester_kurzbz' => $zgvpruefung->prestudentstatus->studiensemester_kurzbz,
'tbl_prestudentstatus.status_kurzbz' => self::INTERESSENTSTATUS, 'prestudent_id' => $prestudent->prestudent_id));
$isFreigegeben = null;
if (isset($zgvpruefung->prestudentstatus->studiensemester_kurzbz))
{
$this->PrestudentstatusModel->addSelect('bestaetigtam, statusgrund_id, tbl_status_grund.bezeichnung_mehrsprachig AS bezeichnung_statusgrund');
$this->PrestudentstatusModel->addJoin('public.tbl_status_grund', 'statusgrund_id', 'LEFT');
$isFreigegeben = $this->PrestudentstatusModel->loadWhere(array('studiensemester_kurzbz' => $zgvpruefung->prestudentstatus->studiensemester_kurzbz,
'tbl_prestudentstatus.status_kurzbz' => self::INTERESSENTSTATUS, 'prestudent_id' => $prestudent->prestudent_id));
}
if (hasData($isFreigegeben))
{
@@ -1537,9 +1541,10 @@ class InfoCenter extends Auth_Controller
show_error(getError($prestudent));
}
$person_id = $prestudent->retval[0]->person_id;
$studiengang_kurzbz = $prestudent->retval[0]->studiengang;
$studiengang_bezeichnung = $prestudent->retval[0]->studiengangbezeichnung;
$prestudentdata = getData($prestudent);
$person_id = $prestudentdata->person_id;
$studiengang_kurzbz = $prestudentdata->studiengang;
$studiengang_bezeichnung = $prestudentdata->studiengangbezeichnung;
return array('person_id' => $person_id, 'studiengang_kurzbz' => $studiengang_kurzbz, 'studiengang_bezeichnung' => $studiengang_bezeichnung);
}
@@ -1582,7 +1587,8 @@ class InfoCenter extends Auth_Controller
private function _sendFreigabeMail($prestudent_id)
{
//get data
$prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id)->retval[0];
$prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id);
$prestudent = getData($prestudent);
$prestudentstatus = $prestudent->prestudentstatus;
$person_id = $prestudent->person_id;
$person = $this->PersonModel->getPersonStammdaten($person_id, true)->retval;
+2 -2
View File
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the FilterWidgetLib (back-end)
* Provides data to the ajax get calls about the filter
* Provides data to the ajax get calls about the filter widget
* Accepts ajax post calls to change the filter data
* 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 FilterWidget has its
@@ -12,7 +12,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class Filters extends FHC_Controller
{
const FILTER_UNIQUE_ID = 'filterUniqueId';
const FILTER_UNIQUE_ID = 'filterUniqueId'; // Name of the filter widget unique id
/**
* Calls the parent's constructor and loads the FilterWidgetLib
+2 -2
View File
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the tablewidgetlib (back-end)
* Provides data to the ajax get calls about the filter
* Provides data to the ajax get calls about the table widget
* Accepts ajax post calls to change the filter data
* 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 TableWidget has its
@@ -12,7 +12,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class Tables extends FHC_Controller
{
const TABLE_UNIQUE_ID = 'tableUniqueId';
const TABLE_UNIQUE_ID = 'tableUniqueId'; // Name of the table widget unique id
/**
* Calls the parent's constructor and loads the tablewidgetlib
+107
View File
@@ -0,0 +1,107 @@
<?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();
// Checks if the caller is allow to use this UDF widget
$this->_isAllowed();
}
//------------------------------------------------------------------------------------------------------------------
// 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
/**
* Checks if the user is allowed to use this UDFWidget
*/
private function _isAllowed()
{
if (!$this->udflib->isAllowed())
{
$this->terminateWithJsonError('You are not allowed to access to this content');
}
}
/**
* 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!');
}
}
}
+17 -3
View File
@@ -60,6 +60,20 @@ class DB_Model extends CI_Model
// ------------------------------------------------------------------------------------------
// Public methods
/**
* This method provides a way to setup a database model without declaring one that extends this class
*/
public function setup($schema, $table, $primaryKey, $hasSequence = true)
{
//
if (!isEmptyString($schema) && !isEmptyString($table) && !isEmptyString($primaryKey) && is_bool($hasSequence))
{
$this->dbTable = $schema.'.'.$table;
$this->pk = $primaryKey;
$this->hasSequence = $hasSequence;
}
}
/**
* Insert Data into DB-Table
*
@@ -690,7 +704,7 @@ class DB_Model extends CI_Model
*/
public function hasUDF()
{
if($this->fieldExists(UDFLib::COLUMN_NAME))
if ($this->fieldExists(UDFLib::COLUMN_NAME))
{
$resultUDFsDefinitions = $this->UDFModel->getUDFsDefinitions($this->dbTable);
if (hasData($resultUDFsDefinitions))
@@ -727,8 +741,8 @@ class DB_Model extends CI_Model
$cleanedQuery = trim(preg_replace('/\t|\n|\r|;/', '', $query)); //
//
if (stripos($cleanedQuery, 'SELECT') == 0
&& (stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
if (
(stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
&& (stripos($cleanedQuery, 'UPDATE') > 0 || stripos($cleanedQuery, 'UPDATE') == false)
&& (stripos($cleanedQuery, 'CREATE') > 0 || stripos($cleanedQuery, 'CREATE') == false)
&& (stripos($cleanedQuery, 'DELETE') > 0 || stripos($cleanedQuery, 'DELETE') == false)
+284 -119
View File
@@ -3,15 +3,20 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Library to manage UDF
* Library to manage UDFs
*/
class UDFLib
{
const WIDGET_NAME = 'UDFWidget';
const SCHEMA_ARG_NAME = 'schema';
const TABLE_ARG_NAME = 'table';
const FIELD_ARG_NAME = 'field';
const UDFS_ARG_NAME = 'udfs';
const UDF_UNIQUE_ID = 'udfUniqueId'; // Name of the UDF widget unique id
const SESSION_NAME = 'FHC_UDF_WIDGET'; // Name of the session area used for UDFs
// Parameters names
const WIDGET_NAME = 'UDFWidget'; // UDFWidget name
const SCHEMA_ARG_NAME = 'schema'; // Schema parameter name
const TABLE_ARG_NAME = 'table'; // Table parameter name
const FIELD_ARG_NAME = 'field'; // Field parameter name
const UDFS_ARG_NAME = 'udfs'; // UDFs parameter name
// UDF json schema attributes
const NAME = 'name'; // UDF name attribute
@@ -22,6 +27,16 @@ class UDFLib
const FE_REGEX_LANGUAGE = 'js'; // UDF javascript regex language attribute (front end)
const BE_REGEX_LANGUAGE = 'php'; // UDF php regex language attribute (back end)
// ...to specify permissions that are needed to use this TableWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
// ...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';
@@ -47,8 +62,10 @@ class UDFLib
private $_ci; // Code igniter instance
private $_udfUniqueId; // Property that contains the UDF widget unique id
/**
* Loads fhc helper
* Gets CI instance
*/
public function __construct()
{
@@ -63,8 +80,8 @@ class UDFLib
*/
public function UDFWidget($args, $htmlArgs = array())
{
if ((isset($args[UDFLib::SCHEMA_ARG_NAME]) && !isEmptyString($args[UDFLib::SCHEMA_ARG_NAME]))
&& (isset($args[UDFLib::TABLE_ARG_NAME]) && !isEmptyString($args[UDFLib::TABLE_ARG_NAME])))
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])))
{
// Loads the widget library
$this->_ci->load->library('WidgetLib');
@@ -73,26 +90,26 @@ class UDFLib
loadResource(APPPATH.'widgets/udf');
// Default external block is true
if (!isset($args[UDFLib::FIELD_ARG_NAME]) && !isset($htmlArgs[HTMLWidget::EXTERNAL_BLOCK]))
if (!isset($args[self::FIELD_ARG_NAME]) && !isset($htmlArgs[HTMLWidget::EXTERNAL_BLOCK]))
{
$htmlArgs[HTMLWidget::EXTERNAL_BLOCK] = true;
}
return $this->_ci->widgetlib->widget(
UDFLib::WIDGET_NAME,
self::WIDGET_NAME,
$args,
$htmlArgs
);
}
else
{
if (!isset($args[UDFLib::SCHEMA_ARG_NAME]) || isEmptyString($args[UDFLib::SCHEMA_ARG_NAME]))
if (!isset($args[self::SCHEMA_ARG_NAME]) || isEmptyString($args[self::SCHEMA_ARG_NAME]))
{
show_error(UDFLib::SCHEMA_ARG_NAME.' parameter is missing!');
show_error(self::SCHEMA_ARG_NAME.' parameter is missing!');
}
if (!isset($args[UDFLib::TABLE_ARG_NAME]) || isEmptyString($args[UDFLib::TABLE_ARG_NAME]))
if (!isset($args[self::TABLE_ARG_NAME]) || isEmptyString($args[self::TABLE_ARG_NAME]))
{
show_error(UDFLib::TABLE_ARG_NAME.' parameter is missing!');
show_error(self::TABLE_ARG_NAME.' parameter is missing!');
}
}
}
@@ -105,12 +122,12 @@ class UDFLib
*/
public function displayUDFWidget(&$widgetData)
{
$schema = $widgetData[UDFLib::SCHEMA_ARG_NAME]; // schema attribute
$table = $widgetData[UDFLib::TABLE_ARG_NAME]; // table attribute
$schema = $widgetData[self::SCHEMA_ARG_NAME]; // schema attribute
$table = $widgetData[self::TABLE_ARG_NAME]; // table attribute
if (isset($widgetData[UDFLib::FIELD_ARG_NAME]))
if (isset($widgetData[self::FIELD_ARG_NAME]))
{
$field = $widgetData[UDFLib::FIELD_ARG_NAME]; // UDF name
$field = $widgetData[self::FIELD_ARG_NAME]; // UDF name
}
$udfResults = $this->_loadUDF($schema, $table); // loads UDF definition
@@ -122,6 +139,9 @@ class UDFLib
$jsonSchemas = json_decode($udf->jsons); // decode the json schema
if (is_object($jsonSchemas) || is_array($jsonSchemas))
{
//
$this->_printStartUDFBlock($widgetData);
// If the schema is an object then convert it into an array
if (is_object($jsonSchemas))
{
@@ -140,18 +160,18 @@ class UDFLib
foreach ($jsonSchemasArray as $jsonSchema)
{
// If the type property is not present then show an error
if (!isset($jsonSchema->{UDFLib::TYPE}))
if (!isset($jsonSchema->{self::TYPE}))
{
show_error(sprintf('%s.%s: Attribute "type" not present in the json schema', $schema, $table));
}
// If the name property is not present then show an error
if (!isset($jsonSchema->{UDFLib::NAME}))
if (!isset($jsonSchema->{self::NAME}))
{
show_error(sprintf('%s.%s: Attribute "name" not present in the json schema', $schema, $table));
}
// If a UDF is specified and is present in the json schemas list or no UDF is specified
if ((isset($field) && $field == $jsonSchema->{UDFLib::NAME}) || !isset($field))
if ((isset($field) && $field == $jsonSchema->{self::NAME}) || !isset($field))
{
// Set attributes using phrases
$this->_setAttributesWithPhrases($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
@@ -166,7 +186,7 @@ class UDFLib
$this->_render($jsonSchema, $widgetData);
// If a UDf is specified and it was found then stop looking through this list
if (isset($field) && $field == $jsonSchema->{UDFLib::NAME})
if (isset($field) && $field == $jsonSchema->{self::NAME})
{
$found = true;
break;
@@ -179,6 +199,9 @@ class UDFLib
{
show_error(sprintf('%s.%s: No schema present for field: %s', $schema, $table, $field));
}
//
$this->_printEndUDFBlock();
}
else // not a valid schema
{
@@ -218,7 +241,7 @@ class UDFLib
// Decodes json that define the UDFs for this table
$decodedUDFDefinitions = json_decode(
$resultUDFsDefinitions->retval[0]->{UDFLib::COLUMN_JSON_DESCRIPTION}
$resultUDFsDefinitions->retval[0]->{self::COLUMN_JSON_DESCRIPTION}
);
// Loops through the UDFs definitions
@@ -232,28 +255,28 @@ class UDFLib
$tmpValidate = success(true); // temporary variable used to store the returned value from _validateUDFs
// If this is the definition of this UDF
if ($decodedUDFDefinition->{UDFLib::NAME} == $key)
if ($decodedUDFDefinition->{self::NAME} == $key)
{
if (isset($decodedUDFDefinition->{UDFLib::VALIDATION})) // If validation rules are present for this UDF
if (isset($decodedUDFDefinition->{self::VALIDATION})) // If validation rules are present for this UDF
{
// Checks if the given UDF is required and the result will be stored in $chkRequiredPassed
// If $chkRequiredPassed == true => required check passed
// If $chkRequiredPassed == false => required check NOT passed
$chkRequiredPassed = true;
// If required property is present in the UDF description and it is true
if (isset($decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED})
&& $decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED} === true)
if (isset($decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED})
&& $decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED} === true)
{
// If this UDF is a checkbox and the given value is false
// OR
// if this UDF is NOT a checkbox and the given value is null
if (($decodedUDFDefinition->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE && $val === false)
|| ($decodedUDFDefinition->{UDFLib::TYPE} != UDFLib::CHKBOX_TYPE && $val == null))
// if this UD7F is NOT a checkbox and the given value is null
if (($decodedUDFDefinition->{self::TYPE} == self::CHKBOX_TYPE && $val === false)
|| ($decodedUDFDefinition->{self::TYPE} != self::CHKBOX_TYPE && $val == null))
{
$chkRequiredPassed = false; // not passed
// A new error is generated and added to array $requiredUDFsArray
$requiredUDFsArray[$decodedUDFDefinition->{UDFLib::NAME}] = error(
$decodedUDFDefinition->{UDFLib::NAME},
$requiredUDFsArray[$decodedUDFDefinition->{self::NAME}] = error(
$decodedUDFDefinition->{self::NAME},
EXIT_VALIDATION_UDF_REQUIRED
);
}
@@ -267,22 +290,22 @@ class UDFLib
// If $toBeValidated == false => validation is NOT performed
$toBeValidated = false;
// If this UDF is NOT a checkbox
if ($decodedUDFDefinition->{UDFLib::TYPE} != UDFLib::CHKBOX_TYPE)
if ($decodedUDFDefinition->{self::TYPE} != self::CHKBOX_TYPE)
{
// If required property is NOT present in the UDF description
if (!isset($decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED}))
if (!isset($decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED}))
{
$toBeValidated = true;
}
// If required property is present in the UDF description and it is true
if (isset($decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED})
&& $decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED} === true)
if (isset($decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED})
&& $decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED} === true)
{
$toBeValidated = true;
}
// If required property is present in the UDF description and it is true and the given value is null
if (isset($decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED})
&& $decodedUDFDefinition->{UDFLib::VALIDATION}->{UDFLib::REQUIRED} === false
if (isset($decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED})
&& $decodedUDFDefinition->{self::VALIDATION}->{self::REQUIRED} === false
&& $val != null)
{
$toBeValidated = true;
@@ -292,8 +315,8 @@ class UDFLib
if ($toBeValidated === true) // Checks if validation should be performed
{
$tmpValidate = $this->_validateUDFs(
$decodedUDFDefinition->{UDFLib::VALIDATION},
$decodedUDFDefinition->{UDFLib::NAME},
$decodedUDFDefinition->{self::VALIDATION},
$decodedUDFDefinition->{self::NAME},
$val
);
}
@@ -341,7 +364,7 @@ class UDFLib
if ($encodedToBeStoredUDFs !== false) // if encode was ok
{
// Save the supplied UDFs values
$data[UDFLib::COLUMN_NAME] = $encodedToBeStoredUDFs;
$data[self::COLUMN_NAME] = $encodedToBeStoredUDFs;
}
}
else // otherwise the returning value will be the list of UDFs validation errors
@@ -360,8 +383,8 @@ class UDFLib
{
$isUDFColumn = false;
if (substr($columnName, 0, strlen(UDFLib::COLUMN_PREFIX)) == UDFLib::COLUMN_PREFIX
&& $columnType == UDFLib::COLUMN_TYPE)
if (substr($columnName, 0, strlen(self::COLUMN_PREFIX)) == self::COLUMN_PREFIX
&& $columnType == self::COLUMN_TYPE)
{
$isUDFColumn = true;
}
@@ -369,9 +392,151 @@ class UDFLib
return $isUDFColumn;
}
/**
* Set the _udfUniqueId property
*/
public function setUDFUniqueId($udfUniqueId)
{
$this->_udfUniqueId = $udfUniqueId;
}
/**
* Return an unique string that identify this UDF widget
* NOTE: The default value is the URI where the FilterWidget is called
* If the fhc_controller_id is present then is also used
*/
public function setUDFUniqueIdByParams($params)
{
if ($params != null
&& is_array($params)
&& isset($params[self::UDF_UNIQUE_ID])
&& !isEmptyString($params[self::UDF_UNIQUE_ID]))
{
$udfUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'.
$this->_ci->router->method.'/'.
$params[self::UDF_UNIQUE_ID];
$this->setUDFUniqueId($udfUniqueId);
}
}
/**
* Wrapper method to the session helper funtions to retrieve the whole session for this UDF widget
*/
public function getSession()
{
return getSessionElement(self::SESSION_NAME, $this->_udfUniqueId);
}
/**
* Wrapper method to the session helper funtions to retrieve one element from the session of this UDF widget
*/
public function getSessionElement($name)
{
$session = getSessionElement(self::SESSION_NAME, $this->_udfUniqueId);
if (isset($session[$name]))
{
return $session[$name];
}
return null;
}
/**
* Wrapper method to the session helper funtions to set the whole session for this UDF widget
*/
public function setSession($data)
{
setSessionElement(self::SESSION_NAME, $this->_udfUniqueId, $data);
}
/**
* Wrapper method to the session helper funtions to set one element in the session for this UDF widget
*/
public function setSessionElement($name, $value)
{
$session = getSessionElement(self::SESSION_NAME, $this->_udfUniqueId);
$session[$name] = $value;
setSessionElement(self::SESSION_NAME, $this->_udfUniqueId, $session); // stores the single value
}
/**
* Save UDFs
*/
public function saveUDFs($udfUniqueId, $udfs)
{
// Read the all session for this udf widget
$session = $this->getSession();
// If session is empty then return an error
if ($session == null) return error('No UDFWidget loaded');
// Workaround to load CI
$this->_ci->load->model('system/UDF_model', 'UDFModel');
// Initialize a new DB_Model
$dbModel = new DB_Model();
// Setup the new dbModel object with...
$dbModel->setup(
$session[self::SCHEMA_ARG_NAME], // ... schema...
$session[self::TABLE_ARG_NAME], // ...table...
$session[self::PRIMARY_KEY_NAME] // ...and primary key name
);
// 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
);
}
/**
* 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
/**
* Print the block for UDFs
*/
private function _printStartUDFBlock($widgetData)
{
$startBlock = '<div type="%s" udfUniqueId="%s">'."\n";
echo sprintf(
$startBlock,
self::WIDGET_NAME,
$widgetData[self::UDF_UNIQUE_ID]
);
}
/**
* Print the end of the UDFs block
*/
private function _printEndUDFBlock()
{
echo '</div>'."\n";
}
/**
* Move UDFs from $data to $UDFs
*/
@@ -381,7 +546,7 @@ class UDFLib
foreach ($data as $key => $val)
{
if (substr($key, 0, 4) == UDFLib::COLUMN_PREFIX)
if (substr($key, 0, 4) == self::COLUMN_PREFIX)
{
$udfsParameters[$key] = $val; // stores UDF value into property UDFs
unset($data[$key]); // remove from data
@@ -416,8 +581,8 @@ class UDFLib
{
// If min value attribute is present in the validation for this UDF,
// then checks if the value of this UDF is compliant to this attribute
if (isset($decodedUDFValidation->{UDFLib::MIN_VALUE})
&& $udfVal < $decodedUDFValidation->{UDFLib::MIN_VALUE})
if (isset($decodedUDFValidation->{self::MIN_VALUE})
&& $udfVal < $decodedUDFValidation->{self::MIN_VALUE})
{
// validation is failed and the error is stored in $returnArrayValidation
$returnArrayValidation[] = error($udfName, EXIT_VALIDATION_UDF_MIN_VALUE);
@@ -425,8 +590,8 @@ class UDFLib
// If max value attribute is present in the validation for this UDF,
// then checks if the value of this UDF is compliant to this attribute
if (isset($decodedUDFValidation->{UDFLib::MAX_VALUE})
&& $udfVal > $decodedUDFValidation->{UDFLib::MAX_VALUE})
if (isset($decodedUDFValidation->{self::MAX_VALUE})
&& $udfVal > $decodedUDFValidation->{self::MAX_VALUE})
{
// validation is failed and the error is stored in $returnArrayValidation
$returnArrayValidation[] = error($udfName, EXIT_VALIDATION_UDF_MAX_VALUE);
@@ -436,8 +601,8 @@ class UDFLib
$strUdfVal = strval($udfVal); // store in $strUdfVal the string conversion of $udfVal
// If min length attribute is present in the validation for this UDF,
// then checks if the value of this UDF is compliant to this attribute
if (isset($decodedUDFValidation->{UDFLib::MIN_LENGTH}) && isset($strUdfVal)
&& strlen($strUdfVal) < $decodedUDFValidation->{UDFLib::MIN_LENGTH})
if (isset($decodedUDFValidation->{self::MIN_LENGTH}) && isset($strUdfVal)
&& strlen($strUdfVal) < $decodedUDFValidation->{self::MIN_LENGTH})
{
// validation is failed and the error is stored in $returnArrayValidation
$returnArrayValidation[] = error($udfName, EXIT_VALIDATION_UDF_MIN_LENGTH);
@@ -445,8 +610,8 @@ class UDFLib
// If max length attribute is present in the validation for this UDF,
// then checks if the value of this UDF is compliant to this attribute
if (isset($decodedUDFValidation->{UDFLib::MAX_LENGTH}) && isset($strUdfVal)
&& strlen($strUdfVal) > $decodedUDFValidation->{UDFLib::MAX_LENGTH})
if (isset($decodedUDFValidation->{self::MAX_LENGTH}) && isset($strUdfVal)
&& strlen($strUdfVal) > $decodedUDFValidation->{self::MAX_LENGTH})
{
// validation is failed and the error is stored in $returnArrayValidation
$returnArrayValidation[] = error($udfName, EXIT_VALIDATION_UDF_MAX_LENGTH);
@@ -457,12 +622,12 @@ class UDFLib
{
// Search for a php regular expression in the validation of this UDF, if one is found
// then checks if the value of this UDF is compliant to this attribute
if (isset($decodedUDFValidation->{UDFLib::REGEX})
&& is_array($decodedUDFValidation->{UDFLib::REGEX}))
if (isset($decodedUDFValidation->{self::REGEX})
&& is_array($decodedUDFValidation->{self::REGEX}))
{
foreach ($decodedUDFValidation->{UDFLib::REGEX} as $regexIndx => $regex)
foreach ($decodedUDFValidation->{self::REGEX} as $regexIndx => $regex)
{
if ($regex->language == UDFLib::BE_REGEX_LANGUAGE)
if ($regex->language == self::BE_REGEX_LANGUAGE)
{
if (preg_match($regex->expression, $udfVal) != 1)
{
@@ -494,8 +659,8 @@ class UDFLib
*/
private function _setNameAndId($jsonSchema, &$htmlParameters)
{
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{UDFLib::NAME};
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{UDFLib::NAME};
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
}
/**
@@ -504,20 +669,20 @@ class UDFLib
private function _sortJsonSchemas(&$jsonSchemasArray)
{
usort($jsonSchemasArray, function ($a, $b) {
if (!isset($a->{UDFLib::SORT}))
if (!isset($a->{self::SORT}))
{
$a->{UDFLib::SORT} = 9999;
$a->{self::SORT} = 9999;
}
if (!isset($b->{UDFLib::SORT}))
if (!isset($b->{self::SORT}))
{
$b->{UDFLib::SORT} = 9999;
$b->{self::SORT} = 9999;
}
if ($a->{UDFLib::SORT} == $b->{UDFLib::SORT})
if ($a->{self::SORT} == $b->{self::SORT})
{
return 0;
}
return ($a->{UDFLib::SORT} < $b->{UDFLib::SORT}) ? -1 : 1;
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
});
}
@@ -565,32 +730,32 @@ class UDFLib
private function _render($jsonSchema, &$widgetData)
{
// Checkbox
if ($jsonSchema->{UDFLib::TYPE} == 'checkbox')
if ($jsonSchema->{self::TYPE} == 'checkbox')
{
$this->_renderCheckbox($jsonSchema, $widgetData);
}
// Textfield
elseif ($jsonSchema->{UDFLib::TYPE} == 'textfield')
elseif ($jsonSchema->{self::TYPE} == 'textfield')
{
$this->_renderTextfield($jsonSchema, $widgetData);
}
// Textarea
elseif ($jsonSchema->{UDFLib::TYPE} == 'textarea')
elseif ($jsonSchema->{self::TYPE} == 'textarea')
{
$this->_renderTextarea($jsonSchema, $widgetData);
}
// Date
elseif ($jsonSchema->{UDFLib::TYPE} == 'date')
elseif ($jsonSchema->{self::TYPE} == 'date')
{
// To be done
}
// Dropdown
elseif ($jsonSchema->{UDFLib::TYPE} == 'dropdown')
elseif ($jsonSchema->{self::TYPE} == 'dropdown')
{
$this->_renderDropdown($jsonSchema, $widgetData);
}
// Multiple dropdown
elseif ($jsonSchema->{UDFLib::TYPE} == 'multipledropdown')
elseif ($jsonSchema->{self::TYPE} == 'multipledropdown')
{
$this->_renderDropdown($jsonSchema, $widgetData, true);
}
@@ -602,29 +767,29 @@ class UDFLib
private function _renderDropdown($jsonSchema, &$widgetData, $multiple = false)
{
// Selected element/s
if (isset($widgetData[UDFLib::UDFS_ARG_NAME])
&& isset($widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
if (isset($widgetData[self::UDFS_ARG_NAME])
&& isset($widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}]))
{
$widgetData[DropdownWidget::SELECTED_ELEMENT] = $widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
$widgetData[DropdownWidget::SELECTED_ELEMENT] = $widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}];
}
else
{
$widgetData[DropdownWidget::SELECTED_ELEMENT] = null;
}
$dropdownWidgetUDF = new DropdownWidgetUDF(UDFLib::WIDGET_NAME, $widgetData);
$dropdownWidgetUDF = new DropdownWidgetUDF(self::WIDGET_NAME, $widgetData);
$parameters = array();
// If the list of values to show is an array
if (isset($jsonSchema->{UDFLib::LIST_VALUES}->enum))
if (isset($jsonSchema->{self::LIST_VALUES}->enum))
{
$parameters = $jsonSchema->{UDFLib::LIST_VALUES}->enum;
$parameters = $jsonSchema->{self::LIST_VALUES}->enum;
}
// If the list of values to show should be retrieved with a SQL statement
elseif (isset($jsonSchema->{UDFLib::LIST_VALUES}->sql))
elseif (isset($jsonSchema->{self::LIST_VALUES}->sql))
{
// UDFModel is loaded in method _loadUDF that is called before the current method
$queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
$queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{self::LIST_VALUES}->sql);
if (hasData($queryResult))
{
$parameters = $queryResult->retval;
@@ -645,13 +810,13 @@ class UDFLib
private function _renderTextarea($jsonSchema, &$widgetData)
{
$text = null; // text value
$textareaUDF = new TextareaWidgetUDF(UDFLib::WIDGET_NAME, $widgetData);
$textareaUDF = new TextareaWidgetUDF(self::WIDGET_NAME, $widgetData);
// Set text value if present in the DB
if (isset($widgetData[UDFLib::UDFS_ARG_NAME])
&& isset($widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
if (isset($widgetData[self::UDFS_ARG_NAME])
&& isset($widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}]))
{
$text = $widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
$text = $widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}];
}
$textareaUDF->render($text);
@@ -663,13 +828,13 @@ class UDFLib
private function _renderTextfield($jsonSchema, &$widgetData)
{
$text = null; // text value
$textareaUDF = new TextfieldWidgetUDF(UDFLib::WIDGET_NAME, $widgetData);
$textareaUDF = new TextfieldWidgetUDF(self::WIDGET_NAME, $widgetData);
// Set text value if present in the DB
if (isset($widgetData[UDFLib::UDFS_ARG_NAME])
&& isset($widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
if (isset($widgetData[self::UDFS_ARG_NAME])
&& isset($widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}]))
{
$text = $widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
$text = $widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}];
}
$textareaUDF->render($text);
@@ -681,17 +846,17 @@ class UDFLib
private function _renderCheckbox($jsonSchema, &$widgetData)
{
// Set checkbox value if present in the DB
if (isset($widgetData[UDFLib::UDFS_ARG_NAME])
&& isset($widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
if (isset($widgetData[self::UDFS_ARG_NAME])
&& isset($widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}]))
{
$widgetData[CheckboxWidget::VALUE_FIELD] = $widgetData[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
$widgetData[CheckboxWidget::VALUE_FIELD] = $widgetData[self::UDFS_ARG_NAME][$jsonSchema->{self::NAME}];
}
else
{
$widgetData[CheckboxWidget::VALUE_FIELD] = CheckboxWidget::HTML_DEFAULT_VALUE;
}
$checkboxWidgetUDF = new CheckboxWidgetUDF(UDFLib::WIDGET_NAME, $widgetData);
$checkboxWidgetUDF = new CheckboxWidgetUDF(self::WIDGET_NAME, $widgetData);
$checkboxWidgetUDF->render();
}
@@ -707,21 +872,21 @@ class UDFLib
$htmlParameters[HTMLWidget::PLACEHOLDER] = null;
// Description, title and placeholder
if (isset($jsonSchema->{UDFLib::LABEL})
|| isset($jsonSchema->{UDFLib::TITLE})
|| isset($jsonSchema->{UDFLib::PLACEHOLDER}))
if (isset($jsonSchema->{self::LABEL})
|| isset($jsonSchema->{self::TITLE})
|| isset($jsonSchema->{self::PLACEHOLDER}))
{
// Loads phrases library
$this->_ci->load->library('PhrasesLib');
// If is set the label property in the json schema
if (isset($jsonSchema->{UDFLib::LABEL}))
if (isset($jsonSchema->{self::LABEL}))
{
// Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
UDFLib::PHRASES_APP_NAME,
self::PHRASES_APP_NAME,
getUserLanguage(),
$jsonSchema->{UDFLib::LABEL},
$jsonSchema->{self::LABEL},
null,
null,
'no'
@@ -733,13 +898,13 @@ class UDFLib
}
// If is set the title property in the json schema
if (isset($jsonSchema->{UDFLib::TITLE}))
if (isset($jsonSchema->{self::TITLE}))
{
// Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
UDFLib::PHRASES_APP_NAME,
self::PHRASES_APP_NAME,
getUserLanguage(),
$jsonSchema->{UDFLib::TITLE},
$jsonSchema->{self::TITLE},
null,
null,
'no'
@@ -751,13 +916,13 @@ class UDFLib
}
// If is set the placeholder property in the json schema
if (isset($jsonSchema->{UDFLib::PLACEHOLDER}))
if (isset($jsonSchema->{self::PLACEHOLDER}))
{
// Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
UDFLib::PHRASES_APP_NAME,
self::PHRASES_APP_NAME,
getUserLanguage(),
$jsonSchema->{UDFLib::PLACEHOLDER},
$jsonSchema->{self::PLACEHOLDER},
null,
null,
'no'
@@ -784,17 +949,17 @@ class UDFLib
$htmlParameters[HTMLWidget::MAX_LENGTH] = null;
// If validation property is present in the json schema
if (isset($jsonSchema->{UDFLib::VALIDATION}))
if (isset($jsonSchema->{self::VALIDATION}))
{
$jsonSchemaValidation =& $jsonSchema->{UDFLib::VALIDATION}; // Reference for a better code readability
$jsonSchemaValidation =& $jsonSchema->{self::VALIDATION}; // Reference for a better code readability
// Front-end regex
if (isset($jsonSchemaValidation->{UDFLib::REGEX})
&& is_array($jsonSchemaValidation->{UDFLib::REGEX}))
if (isset($jsonSchemaValidation->{self::REGEX})
&& is_array($jsonSchemaValidation->{self::REGEX}))
{
foreach ($jsonSchemaValidation->{UDFLib::REGEX} as $regex)
foreach ($jsonSchemaValidation->{self::REGEX} as $regex)
{
if ($regex->language === UDFLib::FE_REGEX_LANGUAGE)
if ($regex->language === self::FE_REGEX_LANGUAGE)
{
$htmlParameters[HTMLWidget::REGEX] = $regex->expression;
}
@@ -802,33 +967,33 @@ class UDFLib
}
// Required
if (isset($jsonSchemaValidation->{UDFLib::REQUIRED}))
if (isset($jsonSchemaValidation->{self::REQUIRED}))
{
$htmlParameters[HTMLWidget::REQUIRED] = $jsonSchemaValidation->{UDFLib::REQUIRED};
$htmlParameters[HTMLWidget::REQUIRED] = $jsonSchemaValidation->{self::REQUIRED};
}
// Min value
if (isset($jsonSchemaValidation->{UDFLib::MIN_VALUE}))
if (isset($jsonSchemaValidation->{self::MIN_VALUE}))
{
$htmlParameters[HTMLWidget::MIN_VALUE] = $jsonSchemaValidation->{UDFLib::MIN_VALUE};
$htmlParameters[HTMLWidget::MIN_VALUE] = $jsonSchemaValidation->{self::MIN_VALUE};
}
// Max value
if (isset($jsonSchemaValidation->{UDFLib::MAX_VALUE}))
if (isset($jsonSchemaValidation->{self::MAX_VALUE}))
{
$htmlParameters[HTMLWidget::MAX_VALUE] = $jsonSchemaValidation->{UDFLib::MAX_VALUE};
$htmlParameters[HTMLWidget::MAX_VALUE] = $jsonSchemaValidation->{self::MAX_VALUE};
}
// Min length
if (isset($jsonSchemaValidation->{UDFLib::MIN_LENGTH}))
if (isset($jsonSchemaValidation->{self::MIN_LENGTH}))
{
$htmlParameters[HTMLWidget::MIN_LENGTH] = $jsonSchemaValidation->{UDFLib::MIN_LENGTH};
$htmlParameters[HTMLWidget::MIN_LENGTH] = $jsonSchemaValidation->{self::MIN_LENGTH};
}
// Max length
if (isset($jsonSchemaValidation->{UDFLib::MAX_LENGTH}))
if (isset($jsonSchemaValidation->{self::MAX_LENGTH}))
{
$htmlParameters[HTMLWidget::MAX_LENGTH] = $jsonSchemaValidation->{UDFLib::MAX_LENGTH};
$htmlParameters[HTMLWidget::MAX_LENGTH] = $jsonSchemaValidation->{self::MAX_LENGTH};
}
}
}
+38 -18
View File
@@ -209,6 +209,9 @@ class Prestudent_model extends DB_Model
if (!hasData($prestudent))
return error('prestudent could not be loaded');
$prestudentdata = getData($prestudent);
$prestudentdata = $prestudentdata[0];
//Prestudentstatus
$lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id);
@@ -217,32 +220,41 @@ class Prestudent_model extends DB_Model
return $lastStatus;
}
if (count($lastStatus->retval) > 0)
if (hasData($lastStatus))
{
$lastStatusData = getData($lastStatus);
$lastStatusData = $lastStatusData[0];
//get Studiengangname from Studienplan and -ordnung
$studienordnung = $this->PrestudentstatusModel->getStudienordnungFromPrestudent($prestudent_id);
if ($studienordnung->error)
return $studienordnung;
if (count($studienordnung->retval) > 0)
if (hasData($studienordnung))
{
$lastStatus->retval[0]->studiengang_kz = $studienordnung->retval[0]->studiengang_kz;
$lastStatus->retval[0]->studiengangkurzbzlang = $studienordnung->retval[0]->studiengangkurzbzlang;
$lastStatus->retval[0]->studiengangbezeichnung = $studienordnung->retval[0]->studiengangbezeichnung;
$lastStatus->retval[0]->studiengangbezeichnung_englisch = $studienordnung->retval[0]->studiengangbezeichnung_englisch;
$lastStatus->retval[0]->regelstudiendauer = $studienordnung->retval[0]->regelstudiendauer;
$studienordnungdata = getData($studienordnung);
$studienordnungdata = $studienordnungdata[0];
$lastStatusData->studiengang_kz = $studienordnungdata->studiengang_kz;
$lastStatusData->studiengangkurzbzlang = $studienordnungdata->studiengangkurzbzlang;
$lastStatusData->studiengangbezeichnung = $studienordnungdata->studiengangbezeichnung;
$lastStatusData->studiengangbezeichnung_englisch = $studienordnungdata->studiengangbezeichnung_englisch;
$lastStatusData->regelstudiendauer = $studienordnungdata->regelstudiendauer;
}
//get Sprache
$this->load->model('system/sprache_model', 'SpracheModel');
$this->SpracheModel->addSelect('sprache, locale, bezeichnung');
$language = $this->SpracheModel->load($lastStatus->retval[0]->sprache);
$language = $this->SpracheModel->load($lastStatusData->sprache);
if ($language->error)
return $language;
if (count($language->retval) > 0)
$lastStatus->retval[0]->sprachedetails = $language->retval[0];
if (hasData($language))
{
$languagedata = getData($language);
$languagedata = $languagedata[0];
$lastStatusData->sprachedetails = $languagedata;
}
//get Bewerbungsfrist
$this->load->model('crm/bewerbungstermine_model', 'BewerbungstermineModel');
@@ -251,24 +263,32 @@ class Prestudent_model extends DB_Model
$this->BewerbungstermineModel->addLimit(1);
$bewerbungstermin = $this->BewerbungstermineModel->loadWhere(
array(
'studienplan_id' => $lastStatus->retval[0]->studienplan_id,
'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz,
'studiengang_kz' => $prestudent->retval[0]->studiengang_kz
'studienplan_id' => $lastStatusData->studienplan_id,
'studiensemester_kurzbz' => $lastStatusData->studiensemester_kurzbz,
'studiengang_kz' => $prestudentdata->studiengang_kz
)
);
if ($bewerbungstermin->error)
return $bewerbungstermin;
if (count($bewerbungstermin->retval) > 0)
if (hasData($bewerbungstermin))
{
$lastStatus->retval[0]->bewerbungstermin = $bewerbungstermin->retval[0]->ende;
$lastStatus->retval[0]->bewerbungsnachfrist = $bewerbungstermin->retval[0]->nachfrist_ende;
$bewerbungstermindata = getData($bewerbungstermin);
$bewerbungstermindata = $bewerbungstermindata[0];
$lastStatusData->bewerbungstermin = $bewerbungstermindata->ende;
$lastStatusData->bewerbungsnachfrist = $bewerbungstermindata->nachfrist_ende;
}
$prestudent->retval[0]->prestudentstatus = $lastStatus->retval[0];
$prestudentdata->prestudentstatus = $lastStatusData;
if ($this->hasUDF())
{
$prestudentdata->prestudentUdfs = $this->getUDFs($prestudent_id);
}
}
return success($prestudent->retval);
return success($prestudentdata);
}
/**
@@ -14,7 +14,7 @@ class Studienjahr_model extends DB_Model
}
/**
* Gets current Studienjahr, as determined by its start and enddate
* Gets current Studienjahr, as determined by start and enddate of current semester
* @return array|null
*/
public function getCurrStudienjahr()
-169
View File
@@ -1,169 +0,0 @@
<?php
class FAS_UDF_model extends DB_Model
{
// String values of booleans
const STRING_NULL = 'null';
const STRING_TRUE = 'true';
const STRING_FALSE = 'false';
const UDF_DROPDOWN_TYPE = 'dropdown';
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
/**
* Methods to save data from FAS
*/
public function saveUDFs($udfs)
{
$result = error('No way man!');
$resultPerson = success('person');
$resultPrestudent = success('prestudent');
$person_id = null;
if (isset($udfs['person_id'])) $person_id = $udfs['person_id'];
unset($udfs['person_id']);
$prestudent_id = null;
if (isset($udfs['prestudent_id'])) $prestudent_id = $udfs['prestudent_id'];
unset($udfs['prestudent_id']);
$jsons = array();
//
if (isset($person_id))
{
// Load model Person_model
$this->load->model('person/Person_model', 'PersonModel');
$result = $this->load(array('public', 'tbl_person'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
$resultPerson = $this->PersonModel->update($person_id, $udfs);
}
//
if (isset($prestudent_id))
{
// Load model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->load(array('public', 'tbl_prestudent'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
}
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
{
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
}
else if(isError($resultPerson))
{
$result = $resultPerson;
}
else if(isError($resultPrestudent))
{
$result = $resultPrestudent;
}
return $result;
}
/**
*
*/
private function _fillMissingChkboxUDF($udfs, $jsons)
{
$_fillMissingChkboxUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
{
if (!isset($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}]))
{
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
}
else
{
if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_FALSE)
{
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
}
else if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_TRUE)
{
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = true;
}
}
}
}
return $_fillMissingChkboxUDF;
}
/**
*
*/
private function _fillMissingDropdownUDF($udfs, $jsons)
{
$_fillMissingDropdownUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
|| $udfDescription->{UDFLib::TYPE} == UDF_model::UDF_MULTIPLEDROPDOWN_TYPE)
{
if (!isset($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}]))
{
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
}
else if($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_NULL)
{
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
}
}
}
return $_fillMissingDropdownUDF;
}
/**
*
*/
private function _fillMissingTextUDF($udfs, $jsons)
{
$_fillMissingTextUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
|| $udfDescription->{UDFLib::TYPE} == 'textfield')
{
if (!isset($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]))
{
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
}
else if(trim($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]) == '')
{
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
}
}
}
return $_fillMissingTextUDF;
}
}
+111 -150
View File
@@ -1,150 +1,111 @@
<?php $this->load->view("templates/header", array("title" => "UDF", "widgetsCSS" => true)); ?>
<body style="background-color: #eff0f1;">
<?php
if ($result != null)
{
if (isSuccess($result))
{
?>
<div style="color: black;">
Saved!
</div>
<br>
<?php
}
else
{
?>
<div style="color: red;">
Error while saving!
</div>
<br>
<div style="color: red;">
<?php
$errors = $result->retval;
if(is_array($errors))
{
foreach ($errors as $error)
{
foreach ($error as $fieldError)
{
echo $fieldError->code . ': ' . $fieldError->retval . '<br>';
}
}
}
else
echo $result->retval;
?>
</div>
<br>
<br>
<br>
<?php
}
}
?>
<form action="<?php echo site_url('system/FAS_UDF/saveUDF'); ?>" method="POST">
<div class="div-table">
<div class="div-row">
<div class="div-cell" style="font-size: 20px; font-weight: bold;">
Zusatzfelder
</div>
</div>
<div class="div-row">
<div class="div-cell">
&nbsp;
</div>
</div>
<div class="div-row">
<?php
if (isset($personUdfs))
{
?>
<div class="div-cell">
<?php
echo $this->udflib->UDFWidget(
array(
UDFLib::SCHEMA_ARG_NAME => 'public',
UDFLib::TABLE_ARG_NAME => 'tbl_person',
UDFLib::UDFS_ARG_NAME => $personUdfs
)
);
?>
</div>
<div class="div-cell" style="width: 40px;">
&nbsp;
</div>
<?php
}
?>
<?php
if (isset($prestudentUdfs))
{
?>
<div class="div-cell">
<?php
echo $this->udflib->UDFWidget(
array(
UDFLib::SCHEMA_ARG_NAME => 'public',
UDFLib::TABLE_ARG_NAME => 'tbl_prestudent',
UDFLib::UDFS_ARG_NAME => $prestudentUdfs
)
);
?>
</div>
<?php
}
?>
</div>
<div class="div-row">
<div class="div-cell">
&nbsp;
</div>
</div>
<div class="div-row halign-right">
<?php
if (isset($personUdfs) && isset($prestudentUdfs))
{
?>
<div class="div-cell">
&nbsp;
</div>
<div class="div-cell">
&nbsp;
</div>
<?php
}
?>
<div class="div-cell halign-right">
<input type="submit" value="&nbsp;Speichern&nbsp;">
</div>
</div>
</div>
<?php
if (isset($personUdfs))
{
?>
<input type="hidden" name="person_id" value="<?php echo $personUdfs['person_id']; ?>">
<?php
}
?>
<?php
if (isset($prestudentUdfs))
{
?>
<input type="hidden" name="prestudent_id" value="<?php echo $prestudentUdfs['prestudent_id']; ?>">
<?php
}
?>
</form>
</body>
<?php $this->load->view("templates/footer"); ?>
<?php
$this->load->view(
'templates/FHC-Header',
array(
'title' => 'InfocenterDetails',
'jquery' => true,
'bootstrap' => true,
'fontawesome' => true,
'jqueryui' => true,
'dialoglib' => true,
'ajaxlib' => true,
'udfs' => true,
'widgets' => true,
'sbadmintemplate' => true,
'customCSSs' => array(
'public/css/sbadmin2/admintemplate.css'
),
'customJSs' => array(
'public/js/bootstrapper.js'
)
)
);
?>
<body style="background-color: #eff0f1;">
<div class="div-table">
<div class="div-row">
<div class="div-cell" style="font-size: 20px; font-weight: bold;">
Zusatzfelder
</div>
</div>
<div class="div-row">
<div class="div-cell">
&nbsp;
</div>
</div>
<div class="div-row">
<?php
if (isset($personUdfs))
{
?>
<div class="div-cell">
<?php
echo $this->udflib->UDFWidget(
array(
UDFLib::UDF_UNIQUE_ID => 'fasPersonUDFs',
UDFLib::REQUIRED_PERMISSIONS_PARAMETER => 'basis/person',
UDFLib::SCHEMA_ARG_NAME => 'public',
UDFLib::TABLE_ARG_NAME => 'tbl_person',
UDFLib::PRIMARY_KEY_NAME => 'person_id',
UDFLib::PRIMARY_KEY_VALUE => $person_id,
UDFLib::UDFS_ARG_NAME => $personUdfs
)
);
?>
</div>
<div class="div-cell" style="width: 40px;">
&nbsp;
</div>
<?php
}
?>
<?php
if (isset($prestudentUdfs))
{
?>
<div class="div-cell">
<?php
echo $this->udflib->UDFWidget(
array(
UDFLib::UDF_UNIQUE_ID => 'fasPrestudentUDFs',
UDFLib::REQUIRED_PERMISSIONS_PARAMETER => 'basis/person',
UDFLib::SCHEMA_ARG_NAME => 'public',
UDFLib::TABLE_ARG_NAME => 'tbl_prestudent',
UDFLib::PRIMARY_KEY_NAME => 'prestudent_id',
UDFLib::PRIMARY_KEY_VALUE => $prestudent_id,
UDFLib::UDFS_ARG_NAME => $prestudentUdfs
)
);
?>
</div>
<?php
}
?>
</div>
<div class="div-row">
<div class="div-cell">
&nbsp;
</div>
</div>
<div class="div-row halign-right">
<?php
if (isset($personUdfs) && isset($prestudentUdfs))
{
?>
<div class="div-cell">
&nbsp;
</div>
<div class="div-cell">
&nbsp;
</div>
<?php
}
?>
</div>
</div>
</body>
<?php $this->load->view("templates/footer"); ?>
@@ -14,6 +14,8 @@
'sbadmintemplate' => true,
'addons' => true,
'navigationwidget' => true,
'udfs' => true,
'widgets' => true,
'customCSSs' => array(
'public/css/sbadmin2/admintemplate.css',
'public/css/sbadmin2/tablesort_bootstrap.css',
@@ -125,8 +125,7 @@
<div id="collapse<?php echo $zgvpruefung->prestudent_id ?>"
class="panel-collapse collapse<?php echo $infoonly ? '' : ' in' ?>">
<div class="panel-body">
<form method="post"
action="#" class="zgvform">
<form action="javascript:void(0);" class="zgvform" id="zgvform_<?php echo $zgvpruefung->prestudent_id ?>">
<input type="hidden" name="prestudentid" value="<?php echo $zgvpruefung->prestudent_id ?>" class="prestudentidinput">
<div class="row">
<div class="col-lg-<?php echo $columns[0] ?>">
@@ -309,21 +308,38 @@
</div>
<!-- show only master zgv if master studiengang - end -->
<?php endif; ?>
<?php if (!$infoonly): ?>
<div class="row">
<div class="col-xs-6 text-left">
<button type="button" class="btn btn-default zgvUebernehmen" id="zgvUebernehmen_<?php echo $zgvpruefung->prestudent_id ?>">
<?php echo $this->p->t('infocenter', 'letzteZgvUebernehmen') ?>
</button>
</div>
<div class="col-xs-6 text-right">
<button type="submit" class="btn btn-default saveZgv" id="zgvSpeichern_<?php echo $zgvpruefung->prestudent_id ?>">
<?php echo $this->p->t('ui', 'speichern') ?>
</button>
</div>
</div>
<?php endif; ?>
</form>
<?php if (!$infoonly): ?>
<div class="row">
<div class="col-xs-6 text-left">
<button type="button" class="btn btn-default zgvUebernehmen" id="zgvUebernehmen_<?php echo $zgvpruefung->prestudent_id ?>">
<?php echo $this->p->t('infocenter', 'letzteZgvUebernehmen') ?>
</button>
</div>
<div class="col-xs-6 text-right">
<button type="submit" class="btn btn-default saveZgv" id="zgvSpeichern_<?php echo $zgvpruefung->prestudent_id ?>">
<?php echo $this->p->t('ui', 'speichern') ?>
</button>
</div>
</div>
<?php endif; ?>
<br />
<?php
if (isset($zgvpruefung->prestudentUdfs))
{
echo $this->udflib->UDFWidget(
array(
UDFLib::UDF_UNIQUE_ID => 'infocenterPrestudentUDFs_'.$zgvpruefung->prestudent_id,
UDFLib::REQUIRED_PERMISSIONS_PARAMETER => 'infocenter',
UDFLib::SCHEMA_ARG_NAME => 'public',
UDFLib::TABLE_ARG_NAME => 'tbl_prestudent',
UDFLib::PRIMARY_KEY_NAME => 'prestudent_id',
UDFLib::PRIMARY_KEY_VALUE => $zgvpruefung->prestudent_id,
UDFLib::UDFS_ARG_NAME => $zgvpruefung->prestudentUdfs
)
);
}
?>
</div>
<?php
+6 -1
View File
@@ -34,6 +34,7 @@
$tablewidget = isset($tablewidget) ? $tablewidget : false;
$tabulator = isset($tabulator) ? $tabulator : false;
$tinymce = isset($tinymce) ? $tinymce : false;
$udfs = isset($udfs) ? $udfs : false;
$widgets = isset($widgets) ? $widgets : false;
?>
@@ -195,6 +196,7 @@
// From public folder
// DialogLib JS
// NOTE: must be called before including others JS libraries that use it
if ($dialoglib === true) generateJSsInclude('public/js/DialogLib.js');
// AjaxLib JS
@@ -213,8 +215,11 @@
// TableWidget JS
if ($tablewidget === true) generateJSsInclude('public/js/TableWidget.js');
// User Defined Fields
if ($udfs === true) generateJSsInclude('public/js/UDFWidget.js');
// Load addon hooks JS
// NOTE: keep it as the latest but one
// NOTE: keep it as the last but one
if ($addons === true) generateAddonsJSsInclude($calledPath.'/'.$calledMethod);
// Eventually required JS
+12 -12
View File
@@ -12,7 +12,7 @@ class DropdownWidgetUDF extends DropdownWidget
{
// Array that will contains the elements to be displayed in the dropdown
$tmpNewElements = array();
// Loops through the given parameters
foreach($parameters as $parameter)
{
@@ -29,27 +29,27 @@ class DropdownWidgetUDF extends DropdownWidget
// If the single element is an array of two element
if (is_array($parameter) && count($parameter) == 2)
{
$newElement->{DropdownWidget::ID_FIELD} = $parameter[0]; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter[1]; //
$newElement->{DropdownWidget::ID_FIELD} = $parameter[0]; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter[1]; //
}
// If the single element is a string or a number
else if (is_string($parameter) || is_numeric($parameter))
{
$newElement->{DropdownWidget::ID_FIELD} = $parameter; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter; //
$newElement->{DropdownWidget::ID_FIELD} = $parameter; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter; //
}
// If the single element is an object with two properties: id and description
else if (is_object($parameter) && isset($parameter->{DropdownWidget::ID_FIELD})
&& isset($parameter->{DropdownWidget::DESCRIPTION_FIELD}))
{
$newElement->{DropdownWidget::ID_FIELD} = $parameter->{DropdownWidget::ID_FIELD}; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter->{DropdownWidget::DESCRIPTION_FIELD}; //
$newElement->{DropdownWidget::ID_FIELD} = $parameter->{DropdownWidget::ID_FIELD}; //
$newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter->{DropdownWidget::DESCRIPTION_FIELD}; //
}
array_push($tmpNewElements, $newElement); // Add $newElement into $tmpNewElements
}
}
// Set the list of elements
$this->setElementsArray(
success($tmpNewElements),
@@ -57,9 +57,9 @@ class DropdownWidgetUDF extends DropdownWidget
$this->htmlParameters[HTMLWidget::PLACEHOLDER],
'No data found for this UDF'
);
$this->loadDropDownView();
echo $this->content();
}
}
}
+146 -5
View File
@@ -6,14 +6,155 @@
*/
class UDFWidget extends HTMLWidget
{
private $_requiredPermissions; // The required permissions to use this UDF widget
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
// Let's start if it's allowed
// NOTE: If it is NOT allowed then no data are loaded
if ($this->udflib->isAllowed($this->_requiredPermissions))
{
$this->_startUDFWidget($args[UDFLib::UDF_UNIQUE_ID]);
}
}
/**
* Called by the WidgetLib, it renders the HTML of the UDF
*/
public function display($widgetData)
{
// _ci is the instance of Code Igniter and the library UDFLib was previously loaded,
// so now is it possibile to call the method displayUDFWidget of UDFLib
// to render the HTML of this UDF
$this->_ci->udflib->displayUDFWidget($widgetData);
// Let's start if it's allowed
// NOTE: If it is NOT allowed then no data are loaded
if ($this->_ci->udflib->isAllowed($this->_requiredPermissions))
{
$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->_requiredPermissions = null;
$this->_schema = null;
$this->_table = null;
$this->_primaryKeyName = null;
$this->_primaryKeyValue = null;
// Retrieved the required permissions parameter if present
if (isset($args[UDFLib::REQUIRED_PERMISSIONS_PARAMETER]))
{
$this->_requiredPermissions = $args[UDFLib::REQUIRED_PERMISSIONS_PARAMETER];
}
// 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::REQUIRED_PERMISSIONS_PARAMETER]))
{
show_error('The parameter "'.UDFLib::REQUIRED_PERMISSIONS_PARAMETER.'" 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::REQUIRED_PERMISSIONS_PARAMETER => $this->_requiredPermissions, //
UDFLib::SCHEMA_ARG_NAME => $this->_schema, //
UDFLib::TABLE_ARG_NAME => $this->_table, //
UDFLib::PRIMARY_KEY_NAME => $this->_primaryKeyName, //
UDFLib::PRIMARY_KEY_VALUE => $this->_primaryKeyValue //
)
);
}
}
+100
View File
@@ -0,0 +1,100 @@
/**
* UDFWidget JS magic
*/
/**
* FHC_UDFWidget this object is used to render the GUI of a table widget and to operate with it
*/
var FHC_UDFWidget = {
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* To display the TableWidget using the loaded data prenset in the session
*/
display: function() {
$("div[type*='UDFWidget']").each(function(i, udfWidgetDiv) {
var saveButton = $('<input type="button" value="Speichern">');
saveButton.on('click', function() {
var udfs = {};
$("div[udfUniqueId*='" + udfWidgetDiv.attributes["udfUniqueId"].nodeValue + "']").find("[name^='udf_']").each(function(i, udf) {
if (udf.type == 'checkbox')
{
udfs[udf.id] = udf.checked == true;
}
else if (udf.type == 'select-one' || udf.type == 'select-multiple')
{
udfs[udf.id] = null;
if (!isNaN(udf.value) && udf.value.trim() != '')
{
udfs[udf.id] = Number(udf.value);
}
}
else
{
udfs[udf.id] = udf.value;
}
});
FHC_AjaxClient.ajaxCallPost(
"widgets/UDF/saveUDFs",
{
udfUniqueId: FHC_UDFWidget._getUDFUniqueIdPrefix() + "/" + udfWidgetDiv.attributes["udfUniqueId"].nodeValue,
udfs: JSON.stringify(udfs)
},
{
successCallback: function(data, textStatus, jqXHR) {
if (FHC_AjaxClient.hasData(data))
{
FHC_DialogLib.alertSuccess('Done!');
}
else
{
console.log(FHC_AjaxClient.getError(data));
}
}
},
{
errorCallback: function(data, textStatus, jqXHR) {
console.log('Contact the administrator');
}
}
);
});
saveButton.appendTo(udfWidgetDiv);
});
},
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
* To retrive the page where the TableWidget is used, using the FHC_JS_DATA_STORAGE_OBJECT
*/
_getUDFUniqueIdPrefix: function() {
return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method;
}
};
/**
* When JQuery is up
*/
$(document).ready(function() {
FHC_UDFWidget.display();
});
+21 -15
View File
@@ -38,7 +38,7 @@ $(document).ready(function ()
$(".prchbox").click(function ()
{
var boxid = this.id;
var akteid = boxid.substr(boxid.indexOf("_") + 1);
var akteid = InfocenterDetails._getPrestudentIdFromElementId(boxid);
var checked = this.checked;
InfocenterDetails.saveFormalGeprueft(personid, akteid, checked)
});
@@ -720,7 +720,7 @@ var InfocenterDetails = {
//up/down prioritize Bewerbungen
$(".prioup").click(function ()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var data = {
"prestudentid": prestudentid,
"change": -1
@@ -729,7 +729,7 @@ var InfocenterDetails = {
});
$(".priodown").click(function ()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var data = {
"prestudentid": prestudentid,
"change": 1
@@ -741,16 +741,16 @@ var InfocenterDetails = {
$(".zgvUebernehmen").click(function ()
{
var btn = $(this);
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
$('#zgvUebernehmenNotice').remove();
InfocenterDetails.zgvUebernehmen(personid, prestudentid, btn);
});
//zgv speichern
$(".zgvform").on('submit', function (e)
$(".saveZgv").click(function ()
{
e.preventDefault();
var formdata = $(this).serializeArray();
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var formdata = $("#zgvform_" + prestudentid).serializeArray();
var data = {};
@@ -766,14 +766,14 @@ var InfocenterDetails = {
//show popup with zgvinfo
$(".zgvinfo").click(function ()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
InfocenterDetails.openZgvInfoForPrestudent(prestudentid);
}
);
$(".freigabebtn").click(function()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
//true - Reihungstestfreigabe
InfocenterDetails._toggleFreigabeDialog(prestudentid, true);
}
@@ -781,7 +781,7 @@ var InfocenterDetails = {
$(".freigabebtnstg").click(function()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var statusgrel = $("#frgstatusgrselect_"+prestudentid+" select[name=frgstatusgrund]");
var statusgrund_id = statusgrel.val();
var statusgrund = statusgrel.find("option:selected").text();
@@ -800,7 +800,7 @@ var InfocenterDetails = {
$(".absageBtn").click(function()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
var prestudentid = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var statusgrund = $("#absgstatusgrselect_" + prestudentid + " select[name=absgstatusgrund]").val();
if (statusgrund === "null")
$("#absgstatusgrselect_" + prestudentid).addClass("has-error");
@@ -820,7 +820,7 @@ var InfocenterDetails = {
$(".saveAbsage").click(function()
{
$(".absageModal").modal("hide");
var prestudent_id = this.id.substr(this.id.indexOf("_") + 1);
var prestudent_id = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var statusgrund_id = $("#absgstatusgrselect_" + prestudent_id + " select[name=absgstatusgrund]").val();
var data = {"prestudent_id": prestudent_id , "statusgrund": statusgrund_id};
InfocenterDetails.saveAbsage(data);
@@ -830,7 +830,7 @@ var InfocenterDetails = {
$(".saveFreigabe").click(function()
{
$(".freigabeModal").modal("hide");
var prestudent_id = this.id.substr(this.id.indexOf("_") + 1);
var prestudent_id = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var data = {"prestudent_id": prestudent_id, "statusgrund_id": null};
InfocenterDetails.saveFreigabe(data);//Reihungstestfreigabe
}
@@ -839,14 +839,14 @@ var InfocenterDetails = {
$(".saveStgFreigabe").click(function()
{
$(".freigabeModal").modal("hide");
var prestudent_id = this.id.substr(this.id.indexOf("_") + 1);
var prestudent_id = InfocenterDetails._getPrestudentIdFromElementId(this.id);
var statusgrundel = $("#frgstatusgrselect_" + prestudent_id + " select[name=frgstatusgrund]");
var statusgrund_id = statusgrundel.val();
var statusgrundbezeichnung = statusgrundel.find("option[value="+statusgrund_id+"]").text();
var data = {"prestudent_id": prestudent_id, "statusgrund_id": statusgrund_id, "statusgrundbezeichnung": statusgrundbezeichnung};
InfocenterDetails.saveFreigabe(data);//Studiengangfreigabe
}
)
);
},
_refreshZgv: function(preserveCollapseState)
{
@@ -870,6 +870,8 @@ var InfocenterDetails = {
CONTROLLER_URL + '/reloadZgvPruefungen/' + personid + '?fhc_controller_id=' + FHC_AjaxClient.getUrlParameter('fhc_controller_id'),
function()
{
// call to UDFWidget again to add events and other JS functionality (before _addZgvPruefungEvents because it adds bootstrap format)
FHC_UDFWidget.display();
InfocenterDetails._addZgvPruefungEvents(personid);
if (preserveCollapseState)
{
@@ -1061,5 +1063,9 @@ var InfocenterDetails = {
},
_genericSaveError: function() {
FHC_DialogLib.alertError("error when saving!");
},
_getPrestudentIdFromElementId(elementid)
{
return elementid.substr(elementid.indexOf("_") + 1);
}
};