diff --git a/application/config/udfmasterschema.json b/application/config/udfmasterschema.json index fa06dc80d..ab3faa8c9 100644 --- a/application/config/udfmasterschema.json +++ b/application/config/udfmasterschema.json @@ -9,6 +9,13 @@ "name": { "type": "string" }, + "type": { + "type": "string", + "enum": ["checkbox", "textfield", "textarea", "date", "dropdown", "multipledropdown"] + }, + "requiredPermissions": { + "type": "array" + }, "description": { "type": "array", }, @@ -18,10 +25,6 @@ "title": { "type": "array", }, - "type": { - "type": "string", - "enum": ["checkbox", "textfield", "textarea", "date", "dropdown", "multipledropdown"] - }, "sort": { "type": "integer" }, @@ -67,5 +70,6 @@ } } }, - "required": ["type", "name"] -} \ No newline at end of file + "required": ["type", "name", "requiredPermissions"] +} + diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index d76c0d79b..8982b9970 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -85,7 +85,7 @@ class approveAnrechnungDetail extends Auth_Controller // Get Anrechung data $anrechnungData = $this->anrechnunglib->getAnrechnungData($anrechnung_id); - + // Get Antrag data $antragData = $this->anrechnunglib->getAntragData( $anrechnungData->prestudent_id, @@ -98,7 +98,7 @@ class approveAnrechnungDetail extends Auth_Controller // Get Genehmigung data $genehmigungData = $this->anrechnunglib->getGenehmigungData($anrechnung_id); - + $viewData = array( 'antragData' => $antragData, 'anrechnungData' => $anrechnungData, @@ -121,13 +121,13 @@ class approveAnrechnungDetail extends Auth_Controller { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + // Get STGLs person data if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0]) { show_error('Failed retrieving person data'); } - + // Approve Anrechnung foreach ($data as $item) { @@ -166,13 +166,13 @@ class approveAnrechnungDetail extends Auth_Controller { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + // Get STGLs person data if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0]) { show_error('Failed retrieving person data'); } - + // Reject Anrechnung foreach ($data as $item) { @@ -210,10 +210,10 @@ class approveAnrechnungDetail extends Auth_Controller { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + $retval = array(); $counter = 0; - + foreach ($data as $item) { // Check if Anrechnungs-LV has lector @@ -221,18 +221,18 @@ class approveAnrechnungDetail extends Auth_Controller { // Count up LV with no lector $counter++; - + // Break, if LV has no lector break; } - + // Get full name of LV Leitung. // If LV Leitung is not present, get full name of LV lectors. $lector_arr = $this->anrechnunglib->getLectors($item['anrechnung_id']); $empfehlungsanfrage_an = !isEmptyArray($lector_arr) ? implode(', ', array_column($lector_arr, 'fullname')) : ''; - + // Request Recommendation if($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])) { @@ -246,7 +246,7 @@ class approveAnrechnungDetail extends Auth_Controller ); } } - + /** * Send mails to lectors * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector @@ -255,11 +255,11 @@ class approveAnrechnungDetail extends Auth_Controller if (!isEmptyArray($retval)) { self::_sendSanchoMailToLectors($retval); - + // Output json to ajax return $this->outputJsonSuccess($retval); } - + // Output json to ajax if (isEmptyArray($retval) && $counter > 0) { @@ -267,22 +267,22 @@ class approveAnrechnungDetail extends Auth_Controller "Empfehlung wurde nicht angefordert,\nDer LV sind keine LektorInnen zugeteilt." ); } - + return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); } - + /** * Withdraw approved / rejected Anrechnung and reset to 'inProgressDP'. */ public function withdraw() { $anrechnung_id = $this->input->post('anrechnung_id'); - + if (!is_numeric($anrechnung_id)) { $this->terminateWithJsonError($this->p->t('ui', 'errorFelderFehlen')); } - + // Delete last status approved / rejected. // If last status is 'approved', Genehmigung is resetted. $result = $this->AnrechnungModel->withdrawApprovement($anrechnung_id); @@ -291,13 +291,13 @@ class approveAnrechnungDetail extends Auth_Controller { $this->terminateWithJsonError(getError($result)); } - + // Success output to AJAX $this->outputJsonSuccess(array( 'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id)) ); } - + /** * Withdraw request for reommendation and reset to 'inProgressDP'. * This is only possible if the lector has not provided a recommendation yet. @@ -305,69 +305,69 @@ class approveAnrechnungDetail extends Auth_Controller public function withdrawRequestRecommendation() { $anrechnung_id = $this->input->post('anrechnung_id'); - + if (!is_numeric($anrechnung_id)) { show_error('Wrong parameter.'); } - + // Get boolean empfehlung of given Anrechnung if (!$result = getData($this->AnrechnungModel->load($anrechnung_id))[0]) { show_error('Failed loading Anrechnung'); } - + $empfehlung = $result->empfehlung_anrechnung; - + // Get last Anrechnungstatus if (!$result = getData($this->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0]) { show_error('Failed loading last Anrechnungstatus'); } - + $last_status = $result->status_kurzbz; $anrechnungstatus_id = $result->anrechnungstatus_id; - + // Return if Anrechnung was not waiting for recommendation or if Anrechnung has already been recommended - if ($last_status != self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR && !is_null($empfehlung)) + if ($last_status != self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR || !is_null($empfehlung)) { return $this->outputJsonError('No recommendation to withdraw.'); } - + // Reset status to 'inProgressDP' $result = $this->AnrechnungModel->deleteAnrechnungstatus($anrechnungstatus_id); - + if (isError($result)) { return $this->outputJsonError('Could not withdraw this application.'); } - + // Success output to AJAX return $this->outputJsonSuccess(array( 'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id)) ); } - + public function saveEmpfehlungsNotiz() { $anrechnung_id = $this->input->post('anrechnung_id'); $notiz_id = $this->input->post('notiz_id'); $empfehlungstext = $this->input->post('empfehlung_text'); - + // Validate data if (isEmptyString($anrechnung_id)) { $this->terminateWithJsonError($this->p->t('ui', 'systemFehler')); } - + // Save Empfehlungstext $result = self::_saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id); - + if (isError($result)) { $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); } - + // Output success message $this->outputJsonSuccess($this->p->t('ui', 'gespeichert')); } @@ -386,10 +386,10 @@ class approveAnrechnungDetail extends Auth_Controller // Check if user is entitled to read dms doc self::_checkIfEntitledToReadDMSDoc($dms_id); - + // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); - + // Download file $this->dmslib->download($dms_id, $filename); } @@ -475,7 +475,7 @@ class approveAnrechnungDetail extends Auth_Controller show_error('You are not entitled to read this document'); } - + /** * Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv) * @param $mail_params @@ -503,8 +503,8 @@ class approveAnrechnungDetail extends Auth_Controller * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. * **/ $lector_arr = $this->_getLectors($anrechnung_arr); - - + + // Send mail to lectors foreach ($lector_arr as $lector) @@ -594,11 +594,11 @@ class approveAnrechnungDetail extends Auth_Controller return $lector_arr; } - + private function _saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id) { $this->load->model('person/Notiz_model', 'NotizModel'); - + if (!isEmptyString($notiz_id)) { return $this->NotizModel->update( @@ -610,15 +610,15 @@ class approveAnrechnungDetail extends Auth_Controller ) ); } - + return $this->NotizModel->addNotizForAnrechnung( $anrechnung_id, self::ANRECHNUNG_NOTIZTITEL_EMPFEHLUNGSNOTIZ_BY_STGL, trim($empfehlungstext), $this->_uid ); - - + + } } diff --git a/application/controllers/system/FAS_UDF.php b/application/controllers/system/FAS_UDF.php index febe266c7..ecaa44393 100644 --- a/application/controllers/system/FAS_UDF.php +++ b/application/controllers/system/FAS_UDF.php @@ -31,7 +31,7 @@ class FAS_UDF extends Auth_Controller if (isset($person_id) && is_numeric($person_id)) { - if ($this->PersonModel->hasUDF()) + if ($this->PersonModel->udfsExistAndDefined()) { $personUdfs = $this->PersonModel->getUDFs($person_id); $data['person_id'] = $person_id; @@ -41,7 +41,7 @@ class FAS_UDF extends Auth_Controller if (isset($prestudent_id) && is_numeric($prestudent_id)) { - if ($this->PrestudentModel->hasUDF()) + if ($this->PrestudentModel->udfsExistAndDefined()) { $prestudentUdfs = $this->PrestudentModel->getUDFs($prestudent_id); $data['prestudent_id'] = $prestudent_id; diff --git a/application/controllers/widgets/UDF.php b/application/controllers/widgets/UDF.php index 5b4c45776..26c30293c 100644 --- a/application/controllers/widgets/UDF.php +++ b/application/controllers/widgets/UDF.php @@ -26,9 +26,6 @@ class UDF extends FHC_Controller // Loads the UDFLib with HTTP GET/POST parameters $this->_loadUDFLib(); - - // Checks if the caller is allow to use this UDF widget - $this->_isAllowed(); } //------------------------------------------------------------------------------------------------------------------ @@ -39,7 +36,6 @@ class UDF extends FHC_Controller */ public function saveUDFs() { - $udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID); $udfs = $this->input->post(UDFLib::UDFS_ARG_NAME); if (!isEmptyString($udfs)) @@ -47,7 +43,7 @@ class UDF extends FHC_Controller $jsonDecodedUDF = json_decode($udfs); if ($jsonDecodedUDF != null) { - $this->outputJson($this->udflib->saveUDFs($udfUniqueId, $jsonDecodedUDF)); + $this->outputJson($this->udflib->saveUDFs($jsonDecodedUDF)); } else { @@ -63,17 +59,6 @@ class UDF extends FHC_Controller //------------------------------------------------------------------------------------------------------------------ // 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 @@ -105,3 +90,4 @@ class UDF extends FHC_Controller } } } + diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 4b89ae5bf..4e555be6c 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -86,7 +86,7 @@ class DB_Model extends CI_Model if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL); // If this table has UDF and the validation of them is ok - if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate; + if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable))) return $validate; // DB-INSERT $insert = $this->db->insert($this->dbTable, $data); @@ -137,7 +137,7 @@ class DB_Model extends CI_Model if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL); // If this table has UDF and the validation of them is ok - if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate; + if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id))) return $validate; $tmpId = $id; @@ -670,6 +670,7 @@ class DB_Model extends CI_Model /** * Returns all the UDF contained in this table ($dbTable) * If no UDF are present, an empty array will be returned + * NOTE: only the UDFs that the logged user is allowed to read are loaded by this method */ public function getUDFs($id, $udfName = null) { @@ -700,9 +701,9 @@ class DB_Model extends CI_Model } /** - * Checks if this table has the field udf_values + * Checks if this table has the field udf_values and if there is a UDF definition for this table */ - public function hasUDF() + public function udfsExistAndDefined() { if ($this->fieldExists(UDFLib::COLUMN_NAME)) { @@ -844,25 +845,25 @@ class DB_Model extends CI_Model } /** - * Wrapper method for UDFLib->manageUDFs + * Wrapper method for UDFLib->prepareUDFsWrite */ - private function _manageUDFs(&$data, $schemaAndTable, $id = null) + private function _prepareUDFsWrite(&$data, $schemaAndTable, $id = null) { - $manageUDFs = success(); + $prepareUDFsWrite = success(); - if ($this->hasUDF()) + if ($this->udfsExistAndDefined()) { if ($id != null) { - $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable, $this->getUDFs($id)); + $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable, $this->_getUDFsNoPerms($id)); } else { - $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable); + $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable); } } - return $manageUDFs; + return $prepareUDFsWrite; } /** @@ -874,9 +875,10 @@ class DB_Model extends CI_Model */ private function _toPhp($result) { + $udfs = false; // if UDFs are inside the given result set $toPhp = $result; // if there is nothing to convert then return the result from DB - // If it's an object its fields will be parsed to find booleans and arrays types + // If it's an object its fields will be parsed to find booleans, arrays and UDFs types if (is_object($result)) { $toBeConverterdArray = array(); // Fields to be converted @@ -884,40 +886,48 @@ class DB_Model extends CI_Model $this->executedQueryMetaData = $result->field_data(); // Fields information $this->executedQueryListFields = $result->list_fields(); // List of the retrieved fields - for ($i = 0; $i < count($this->executedQueryMetaData); $i++) // Looking for booleans and arrays + // Looking for booleans, arrays and UDFs + foreach ($this->executedQueryMetaData as $eqmd) { // If array type, boolean type OR a UDF - if (strpos($this->executedQueryMetaData[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false - || $this->executedQueryMetaData[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE - || $this->udflib->isUDFColumn($this->executedQueryMetaData[$i]->name, $this->executedQueryMetaData[$i]->type)) + if (strpos($eqmd->type, DB_Model::PGSQL_ARRAY_TYPE) !== false + || $eqmd->type == DB_Model::PGSQL_BOOLEAN_TYPE + || $this->udflib->isUDFColumn($eqmd->name, $eqmd->type)) { - // Name and type of the field to be converted - $toBeConverted = new stdClass(); - // Set the type of the field to be converted - $toBeConverted->type = $this->executedQueryMetaData[$i]->type; - // Set the name of the field to be converted - $toBeConverted->name = $this->executedQueryMetaData[$i]->name; - // Add the field to be converted to $toBeConverterdArray - array_push($toBeConverterdArray, $toBeConverted); + // If UDFs are inside this result set + if ($this->udflib->isUDFColumn($eqmd->name, $eqmd->type)) + { + $udfs = true; + } + else // all the other cases + { + // Name and type of the field to be converted + $toBeConverted = new stdClass(); + // Set the type of the field to be converted + $toBeConverted->type = $eqmd->type; + // Set the name of the field to be converted + $toBeConverted->name = $eqmd->name; + // Add the field to be converted to $toBeConverterdArray + array_push($toBeConverterdArray, $toBeConverted); + } } } - // If there is something to convert, otherwhise don't lose time - if (count($toBeConverterdArray) > 0) - { - // Returns the array of objects, each of them represents a DB record - $resultsArray = $result->result(); - // Looping on results - for ($i = 0; $i < count($resultsArray); $i++) - { - // Single element - $resultElement = $resultsArray[$i]; - // Looping on fields to be converted - for ($j = 0; $j < count($toBeConverterdArray); $j++) - { - // Single element - $toBeConverted = $toBeConverterdArray[$j]; + // Returns the array of objects, each of them represents a DB record + $resultsArray = $result->result(); + // If in this result set there are UDFs then prepare them + if ($udfs) $this->udflib->prepareUDFsRead($resultsArray, $this->dbTable); + + // If there is something to convert, otherwhise don't waste time + if (!isEmptyArray($toBeConverterdArray)) + { + // Looping on results + foreach ($resultsArray as $resultElement) + { + // Looping on fields to be converted + foreach ($toBeConverterdArray as $toBeConverted) + { // Array type if (strpos($toBeConverted->type, DB_Model::PGSQL_ARRAY_TYPE) !== false) { @@ -931,30 +941,12 @@ class DB_Model extends CI_Model { $resultElement->{$toBeConverted->name} = $this->pgBoolPhp($resultElement->{$toBeConverted->name}); } - // UDF - elseif ($this->udflib->isUDFColumn($toBeConverted->name, $toBeConverted->type)) - { - $jsonValues = json_decode($resultElement->{$toBeConverted->name}); // decode UDFs values - if ($jsonValues != null) // if decode is ok - { - // For every UDF - foreach ($jsonValues as $key => $value) - { - $resultElement->{$key} = $value; // create a new element called like the UDF - } - } - unset($resultElement->{UDFLib::COLUMN_NAME}); // remove udf_values from the response - } } } - // Returns DB data as an array - $toPhp = $resultsArray; - } - // And returns DB data as an array - else - { - $toPhp = $result->result(); } + + // Returns DB data as an array + $toPhp = $resultsArray; } return $toPhp; @@ -998,4 +990,48 @@ class DB_Model extends CI_Model { if ($this->debugMode) $this->loglib->logDebug($this->db->last_query()); } + + /** + * Returns all the UDF contained in this table ($dbTable) + * If no UDF are present, an empty array will be returned + * NOTE: it returns all the UDFs, does _not_ check the permissions + */ + private function _getUDFsNoPerms($id) + { + $udfs = array(); + + $this->db->select(UDFLib::COLUMN_NAME, true); // get only the UDF column + + // Primary key management + $tmpId = $id; + + // Check for composite Primary Key + if (is_array($id)) + { + if (isset($id[0])) + { + $tmpId = $this->_arrayCombine($this->pk, $id); + } + } + elseif ($id != null) + { + $tmpId = array($this->pk => $id); + } + + // Read the record from the table + $result = $this->db->get_where($this->dbTable, $tmpId); + + // If was a success and there are data + if ($result && count($result->result()) == 1) + { + // Get the UDF column and decode it from JSON + $jsonValues = json_decode($result->result()[0]->{UDFLib::COLUMN_NAME}); + + // If the JSON convertion was fine convert the object to an array + if ($jsonValues != null) $udfs = get_object_vars($jsonValues); + } + + return $udfs; + } } + diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index f9ad7d20d..827bdc989 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -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 } } } + diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index fbc0f2981..4111e5f19 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -290,7 +290,8 @@ class Prestudent_model extends DB_Model $prestudentdata->prestudentstatus = $lastStatusData; - if ($this->hasUDF()) + + if ($this->udfsExistAndDefined()) { $prestudentdata->prestudentUdfs = $this->getUDFs($prestudent_id); } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index ef5373f5f..8517d7f9d 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -169,18 +169,34 @@ class Lehrveranstaltung_model extends DB_Model */ public function getLecturersByLv($studiensemester_kurzbz, $lehrveranstaltung_id) { - $query = "SELECT * FROM (SELECT distinct on(uid) vorname, nachname, tbl_benutzer.uid as uid, - CASE WHEN lehrfunktion_kurzbz='LV-Leitung' THEN true ELSE false END as lvleiter - FROM lehre.tbl_lehreinheit, lehre.tbl_lehreinheitmitarbeiter, public.tbl_benutzer, public.tbl_person - WHERE - tbl_lehreinheit.lehreinheit_id=tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND - tbl_person.person_id=tbl_benutzer.person_id AND - lehrveranstaltung_id=? AND - tbl_lehreinheitmitarbeiter.mitarbeiter_uid NOT like '_Dummy%' AND - tbl_benutzer.aktiv=true AND tbl_person.aktiv=true AND - studiensemester_kurzbz=?) AS a - ORDER BY lvleiter DESC, nachname, vorname"; + $query = "SELECT + * + FROM + (SELECT distinct on(uid) vorname, nachname, tbl_benutzer.uid as uid, + CASE WHEN + EXISTS( + SELECT + 1 + FROM + lehre.tbl_lehreinheitmitarbeiter lvllem + JOIN lehre.tbl_lehreinheit lvlle USING(lehreinheit_id) + WHERE + lehrfunktion_kurzbz='LV-Leitung' + AND lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id + AND studiensemester_kurzbz=tbl_lehreinheit.studiensemester_kurzbz + AND mitarbeiter_uid=tbl_benutzer.uid + ) THEN true ELSE false END as lvleiter + FROM lehre.tbl_lehreinheit, lehre.tbl_lehreinheitmitarbeiter, public.tbl_benutzer, public.tbl_person + WHERE + tbl_lehreinheit.lehreinheit_id=tbl_lehreinheitmitarbeiter.lehreinheit_id AND + tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND + tbl_person.person_id=tbl_benutzer.person_id AND + lehrveranstaltung_id=? AND + tbl_lehreinheitmitarbeiter.mitarbeiter_uid NOT like '_Dummy%' AND + tbl_benutzer.aktiv=true AND tbl_person.aktiv=true AND + studiensemester_kurzbz=? + ) AS a + ORDER BY lvleiter DESC, nachname, vorname"; return $this->execQuery($query, array($lehrveranstaltung_id, $studiensemester_kurzbz)); } @@ -273,7 +289,7 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($query, $parametersarray); } - + /** * Gets Lehrveranstaltung and its Lehreinheiten (multiple rows possible). * Returns empty array if student has no Lehrveranstaltung. @@ -290,7 +306,7 @@ class Lehrveranstaltung_model extends DB_Model AND studiensemester_kurzbz = ? AND lehrveranstaltung_id = ?; '; - + return $this->execQuery($query, array($uid, $studiensemester_kurzbz, $lehrveranstaltung_id)); } } diff --git a/application/views/system/fas_udf.php b/application/views/system/fas_udf.php index 8a1200b6a..e6fa396cf 100644 --- a/application/views/system/fas_udf.php +++ b/application/views/system/fas_udf.php @@ -45,7 +45,6 @@ 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', @@ -70,7 +69,6 @@ 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', @@ -109,3 +107,4 @@ load->view("templates/footer"); ?> + diff --git a/application/views/system/infocenter/zgvpruefungen.php b/application/views/system/infocenter/zgvpruefungen.php index a2b2f8da8..253145557 100644 --- a/application/views/system/infocenter/zgvpruefungen.php +++ b/application/views/system/infocenter/zgvpruefungen.php @@ -341,7 +341,6 @@ 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', @@ -553,3 +552,4 @@ endforeach; // end foreach zgvpruefungen ?> + diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 6a0969cd4..f4ba1bb4b 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -44,6 +44,8 @@ <?php printPageTitle($title); ?> + + + - \ No newline at end of file + + diff --git a/application/views/widgets/dropdown.php b/application/views/widgets/dropdown.php index d9faf1978..51db6d536 100644 --- a/application/views/widgets/dropdown.php +++ b/application/views/widgets/dropdown.php @@ -33,6 +33,7 @@ + > + diff --git a/application/views/widgets/textarea.php b/application/views/widgets/textarea.php index c72b52658..5346fefa8 100644 --- a/application/views/widgets/textarea.php +++ b/application/views/widgets/textarea.php @@ -29,9 +29,11 @@ + > - \ No newline at end of file + + diff --git a/application/views/widgets/textfield.php b/application/views/widgets/textfield.php index 73b1daa1b..c5ba81710 100644 --- a/application/views/widgets/textfield.php +++ b/application/views/widgets/textfield.php @@ -31,10 +31,12 @@ + value="" > - \ No newline at end of file + + diff --git a/application/widgets/html/HTMLWidget.php b/application/widgets/html/HTMLWidget.php index 9639890ea..0034edfd9 100644 --- a/application/widgets/html/HTMLWidget.php +++ b/application/widgets/html/HTMLWidget.php @@ -6,18 +6,18 @@ class HTMLWidget extends Widget { // The name of the array present in the data array given to the view that will render this widget - const HTML_ARG_NAME = 'HTML'; + const HTML_ARG_NAME = 'HTML'; const HTML_DEFAULT_VALUE = ''; // Default value of the html element - const HTML_NAME = 'name'; // HTML name attribute - const HTML_ID = 'id'; // HTML id attribute - - // External block definition - const EXTERNAL_BLOCK = 'externalBlock'; // External block name - const EXTERNAL_START_BLOCK_HTML_TAG = '
'; // External block start tag - const EXTERNAL_END_BLOCK_HTML_TAG = '
'; // External block end tag - - // HTML attributes - const LABEL = 'title'; + const HTML_NAME = 'name'; // HTML name attribute + const HTML_ID = 'id'; // HTML id attribute + + // External block definition + const EXTERNAL_BLOCK = 'externalBlock'; // External block name + const EXTERNAL_START_BLOCK_HTML_TAG = '
'; // External block start tag + const EXTERNAL_END_BLOCK_HTML_TAG = '
'; // External block end tag + + // HTML attributes + const LABEL = 'title'; const REGEX = 'regex'; const TITLE = 'description'; const REQUIRED = 'required-field'; @@ -26,11 +26,12 @@ class HTMLWidget extends Widget const MAX_LENGTH = 'max-length'; const MIN_LENGTH = 'min-length'; const PLACEHOLDER = 'placeholder'; + const DISABLED = 'disabled'; - /** - * It gets also the htmlArgs array as parameter, it will be used to set the HTML properties - */ - public function __construct($name, $args = array(), $htmlArgs = array()) + /** + * It gets also the htmlArgs array as parameter, it will be used to set the HTML properties + */ + public function __construct($name, $args = array(), $htmlArgs = array()) { parent::__construct($name, $args); @@ -38,11 +39,11 @@ class HTMLWidget extends Widget $this->_setHtmlProperties($htmlArgs); } - /** - * Initialising html properties, such as the id and name attributes of the HTML element - */ - private function _setHtmlProperties($htmlArgs) - { + /** + * Initialising html properties, such as the id and name attributes of the HTML element + */ + private function _setHtmlProperties($htmlArgs) + { // If $htmlArgs wasn't already stored in $this->_args if (!isset($this->_args[HTMLWidget::HTML_ARG_NAME])) { @@ -58,9 +59,9 @@ class HTMLWidget extends Widget $this->_args[HTMLWidget::HTML_ARG_NAME][$argName] = $argValue; } } - } + } - /** + /** * Prints an attribute name and eventually also the value extracted from $htmlArgs * Set $isValuePresent to false the value should not be displayed */ @@ -113,3 +114,4 @@ class HTMLWidget extends Widget } } } + diff --git a/application/widgets/udf/UDFWidget.php b/application/widgets/udf/UDFWidget.php index 7af3dd926..abbbab022 100644 --- a/application/widgets/udf/UDFWidget.php +++ b/application/widgets/udf/UDFWidget.php @@ -6,8 +6,6 @@ */ 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 @@ -26,26 +24,16 @@ class UDFWidget extends HTMLWidget $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]); - } + $this->_startUDFWidget($args[UDFLib::UDF_UNIQUE_ID]); } /** * Called by the WidgetLib, it renders the HTML of the UDF */ - public function display($widgetData) + public function display($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); - } - } + $this->_ci->udflib->displayUDFWidget($widgetData); + } //------------------------------------------------------------------------------------------------------------------ // Private methods @@ -60,18 +48,11 @@ class UDFWidget extends HTMLWidget // 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])) { @@ -113,11 +94,6 @@ class UDFWidget extends HTMLWidget 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'); @@ -149,7 +125,6 @@ class UDFWidget extends HTMLWidget $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, // @@ -158,3 +133,4 @@ class UDFWidget extends HTMLWidget ); } } + diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index 2a7939e17..fcf3dd811 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -22,6 +22,7 @@ * Manfred Kindl * Gerald Raab * Alexei Karpenko + * Manuela Thamer */ require_once('../../../config/cis.config.inc.php'); require_once('../../../include/functions.inc.php'); @@ -44,6 +45,7 @@ require_once('../../../include/bisverwendung.class.php'); require_once('../../../include/studiensemester.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); + $sprache = getSprache(); $p=new phrasen($sprache); $sprache_obj = new sprache(); @@ -88,7 +90,7 @@ $fieldheadings = array( 'oe1' => $p->t("zeitaufzeichnung/oe"), 'oe2' => $p->t("zeitaufzeichnung/oe").'2', 'aktivitaet' => $p->t("zeitaufzeichnung/aktivitaet"), 'service' => $p->t("zeitaufzeichnung/service"), 'start' => $p->t("zeitaufzeichnung/start"), 'ende' => $p->t("zeitaufzeichnung/ende"), 'dauer' => $p->t("zeitaufzeichnung/dauer"), 'kunde' => $p->t("zeitaufzeichnung/kunde"), 'beschreibung' => $p->t("global/beschreibung"), 'aktion' => $p->t("global/aktion"), - 'datum' => $p->t("global/datum") + 'datum' => $p->t("global/datum"),'homeoffice' => $p->t("zeitaufzeichnung/homeoffice") ); if ($rechte->isBerechtigt('basis/servicezeitaufzeichnung')) @@ -131,10 +133,13 @@ $bis_datum = (isset($_REQUEST['bis_datum'])?$_REQUEST['bis_datum']:date('d.m.Y') $bis_uhrzeit = (isset($_POST['bis_uhrzeit'])?$_POST['bis_uhrzeit']:date('H:i',mktime(date('H'), date('i')+10))); $bis = $bis_datum.' '.$bis_uhrzeit; +$homeoffice = (isset($_POST['homeoffice'])?true:false); $pause_von = (isset($_POST['pause_von'])?$_POST['pause_von']:date('H:i')); $pause_bis = (isset($_POST['pause_bis'])?$_POST['pause_bis']:date('H:i')); $von_pause = $von_datum.' '.$pause_von; $bis_pause = $bis_datum.' '.$pause_bis; +$homeofficeChecked = ''; +//$reload = false; $beschreibung = (isset($_POST['beschreibung'])?$_POST['beschreibung']:''); $service_id = (isset($_POST['service_id'])?$_POST['service_id']:''); @@ -221,7 +226,7 @@ echo ' @@ -806,6 +923,39 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $zeit->projektphase_id = $data[7]; if (isset($data[8])) $zeit->service_id = $data[8]; + if (isset($data[9])) + { + if (strtolower($data[9] == 'true')) + { + // check, ob homeoffice gemäß Bisverwendung + $verwendung = new bisverwendung(); + $verwendung->getVerwendungDatum($data[0],$vonCSV); + + foreach ($verwendung->result as $v) + // echo "homeoffice für Tag " . $vonCSV . " ". $v->homeoffice . " " . $v->bisverwendung_id . "
"; + + if ($v->homeoffice) + { + + // echo "homeoffice erlaubt
"; + $zeit->homeoffice = true; + } + else + { + echo ''.$p->t("zeitaufzeichnung/homeofficeNichtErlaubt", ($vonCSV)) .'
'; + + $zeit->homeoffice = false; + } + } + else + { + $zeit->homeoffice = false; + } + } + else + { + $zeit->homeoffice = false; + } $tag = $datum->formatDatum($data[2], $format='Y-m-d'); if(!in_array($tag, $importtage_array)) @@ -829,6 +979,7 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $pause->start = $ende_vorher; $pause->ende = $zeit->start; $pause->beschreibung = ''; + $pause->homeoffice = $homeoffice; if(!$pause->save()) { echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$pause->errormsg.'
'; @@ -908,6 +1059,7 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $zeit->updatevon = $user; $zeit->projekt_kurzbz = $projekt_kurzbz; $zeit->projektphase_id = $projektphase_id; + $zeit->homeoffice = $homeoffice; $zeit->service_id = $service_id; $zeit->kunde_uid = $kunde_uid; $saveerror = 0; @@ -924,8 +1076,10 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) } elseif (!$projectphase->checkProjectphaseInCorrectTime($projektphase_id, $datum->formatDatum($von, $format='Y-m-d'), $datum->formatDatum($bis, $format='Y-m-d'))) { - echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Eingabe nicht möglich, da angegebenes Anfangs und Enddatum nicht in den Projektphasenzeitrahmen fällt.
'; + echo '

'.$p->t("global/fehlerBeimSpeichernDerDaten").': + Eingabe nicht möglich, da angegebenes Anfangs und Enddatum nicht in den Projektphasenzeitrahmen fällt.


'; $saveerror = 1; + } elseif (abs($von-$bis)>0 && $aktivitaet_kurzbz!="DienstreiseMT") { @@ -968,6 +1122,7 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $pause->insertvon = $user; $pause->uid = $user; $pause->aktivitaet_kurzbz = 'Pause'; + $pause->homeoffice = $homeoffice; $pause->start = $datum->formatDatum($von_pause, $format='Y-m-d H:i:s'); $pause->ende = $datum->formatDatum($bis_pause, $format='Y-m-d H:i:s'); $pause->beschreibung = ''; @@ -1055,13 +1210,12 @@ else echo ' '; //Laden der Daten zum aendern -if(isset($_GET['type']) && $_GET['type']=='edit') +if (isset($_GET['type']) && $_GET['type'] == 'edit') { $zeit = new zeitaufzeichnung(); - - if($zeit->load($zeitaufzeichnung_id)) + if ($zeit->load($zeitaufzeichnung_id)) { - if($zeit->uid==$user) + if ($zeit->uid == $user) { $uid = $zeit->uid; $aktivitaet_kurzbz = $zeit->aktivitaet_kurzbz; @@ -1072,13 +1226,15 @@ if(isset($_GET['type']) && $_GET['type']=='edit') $oe_kurzbz_2 = $zeit->oe_kurzbz_2; $projekt_kurzbz = $zeit->projekt_kurzbz; $projektphase_id = $zeit->projektphase_id; + $homeoffice = $zeit->homeoffice; + $homeoffice[0] == 't' ? $homeofficeChecked = 'checked' : $homeofficeChecked = ''; $service_id = $zeit->service_id; $kunde_uid = $zeit->kunde_uid; $projektphase = new projektphase(); - $projektphasen = array(); - if($projektphase->getProjektphasen($projekt_kurzbz)) + + if ($projektphase->getProjectphaseForMitarbeiterByKurzBz($uid, $projekt_kurzbz)) { foreach ($projektphase->result as $row) { @@ -1089,15 +1245,16 @@ if(isset($_GET['type']) && $_GET['type']=='edit') else { echo "".$p->t("global/keineBerechtigungZumAendernDesDatensatzes").""; - $zeitaufzeichnung_id=''; + $zeitaufzeichnung_id = ''; } } } + //Projekte holen zu denen der Benutzer zugeteilt ist $projekt = new projekt(); -if($projekt->getProjekteMitarbeiter($user, true)) +if ($projekt->getProjekteMitarbeiter($user, true)) { //if(count($projekt->result)>0) //{ @@ -1324,36 +1481,48 @@ if($projekt->getProjekteMitarbeiter($user, true)) $selected = ''; echo ''; - } - echo ''; - - //Projektphase - $showprojphases = isset($projektphasen) && is_array($projektphasen) && count($projektphasen) > 0 && $projektfound; - $hiddentext = $showprojphases ? "" : " style='display:none'"; - - echo - '    '. - $p->t("zeitaufzeichnung/projektphase").' - '; - } - echo ''; } + echo ''; - if ($za_simple == 0) + //Projektphase + $showprojphases = isset($projektphasen) && is_array($projektphasen) && count($projektphasen) > 0 && $projektfound; + $hiddentext = $showprojphases ? "" : " style='display:none'"; + + echo + '    '. + $p->t("zeitaufzeichnung/projektphase").' + '; + } + echo ''; + } + + echo ""; + + if ($za_simple == 0) { // Service echo ' @@ -1402,6 +1571,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) $von_ts = $datum->mktime_fromtimestamp($datum->formatDatum($von, $format='Y-m-d H:i:s')); $bis_ts = $datum->mktime_fromtimestamp($datum->formatDatum($bis, $format='Y-m-d H:i:s')); $diff = $bis_ts - $von_ts; + echo ' '.$p->t("global/von").' - '.$p->t("global/bis").' @@ -1444,6 +1614,20 @@ if($projekt->getProjekteMitarbeiter($user, true)) '; + + //Homeoffice Checkbox + echo ' + +   + + + Homeoffice + + + + + '; + //Beschreibung echo ''.$p->t("global/beschreibung").''; echo ''; @@ -1505,7 +1689,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) echo ''; else echo ''; - //echo ''; + //echo ''; $za = new zeitaufzeichnung(); if(isset($_GET['filter'])) @@ -1621,6 +1805,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) elseif ($tagessaldo > 18000 && $tagessaldo < 19800 && $pausesumme < $tagessaldo - 18000) $pausefehlt_str = '-- Pause fehlt oder zu kurz --'; + $tagessaldo = date('H:i', ($tagessaldo)); $colspan = ($za_simple)?6:8; echo ''; @@ -1770,6 +1955,11 @@ if($projekt->getProjekteMitarbeiter($user, true)) $style = 'style="border-top: 3px solid #8DBDD8; border-bottom: 3px solid #8DBDD8"'; if ($row->aktivitaet_kurzbz=='Pause' || $row->aktivitaet_kurzbz=='LehreExtern'|| $row->aktivitaet_kurzbz=='Ersatzruhe') $style .= ' style="color: grey;"'; + if($db->convert_html_chars($row->homeoffice)=='t') + { + $homeoffice = " - Homeoffice"; + }else + $homeoffice=""; $summe = $row->summe; $service = new service(); $service->load($row->service_id); @@ -1785,7 +1975,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) { echo ' '.$db->convert_html_chars($row->oe_kurzbz_2).''; } - echo ''.$db->convert_html_chars($row->aktivitaet_kurzbz).''; + echo ''.$db->convert_html_chars($row->aktivitaet_kurzbz).($homeoffice).''; if(!$za_simple) { echo ' '.StringCut($db->convert_html_chars($service->bezeichnung),20,null,'...').' '; @@ -1919,8 +2109,8 @@ function getDataForCSV($rawdata, $fieldheadings, $za_simple = false) $datum = new datum(); $csvData = array(); //headers schreiben - $csvData[] = ($za_simple) ? array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['aktivitaet'], $fieldheadings['beschreibung']) - : array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['oe2'], $fieldheadings['aktivitaet'], $fieldheadings['service'], $fieldheadings['kunde'], $fieldheadings['beschreibung']); + $csvData[] = ($za_simple) ? array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['aktivitaet'], $fieldheadings['beschreibung'], $fieldheadings['homeoffice']) + : array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['oe2'], $fieldheadings['aktivitaet'], $fieldheadings['service'], $fieldheadings['kunde'], $fieldheadings['beschreibung'], $fieldheadings['homeoffice']); foreach ($rawdata as $zeitauf) { //Newline characters bei Beschreibung ersetzen @@ -1933,13 +2123,13 @@ function getDataForCSV($rawdata, $fieldheadings, $za_simple = false) if($za_simple) { $csvData[] = array($zeitauf->uid, $hauptdatum, $datum->formatDatum($zeitauf->start, 'H:i'), - $bisdatum, $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->aktivitaet_kurzbz, $beschreibung); + $bisdatum, $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->aktivitaet_kurzbz, $beschreibung, $zeitauf->homeoffice); } else { $servicebez = ($service->load($zeitauf->service_id))?$service->bezeichnung:""; $csvData[] = array($zeitauf->uid, $hauptdatum, $datum->formatDatum($zeitauf->start, 'H:i'), $bisdatum, - $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->oe_kurzbz_2, $zeitauf->aktivitaet_kurzbz, $servicebez, $zeitauf->kunde_uid, $beschreibung); + $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->oe_kurzbz_2, $zeitauf->aktivitaet_kurzbz, $servicebez, $zeitauf->kunde_uid, $beschreibung, $zeitauf->homeoffice); } } return $csvData; @@ -2014,7 +2204,7 @@ function getDataForProjectOverviewCSV($user) { if (true) { - $titel = $prjp->projekt_kurzbz; + $titel = $prjp->projekttitel; $projekt_kurzbz = $prjp->projekt_kurzbz; $projekt_phase = $prjp->bezeichnung; $projekt_phase_id = $prjp->projektphase_id; diff --git a/cis/private/tools/zeitaufzeichnung_bisverwendung.php b/cis/private/tools/zeitaufzeichnung_bisverwendung.php new file mode 100644 index 000000000..2f430ecda --- /dev/null +++ b/cis/private/tools/zeitaufzeichnung_bisverwendung.php @@ -0,0 +1,75 @@ + + */ +/** + * Checks, if there is the possibility for homeoffice for the given bisverwendung of + * a certain date. + */ +require_once('../../../config/cis.config.inc.php'); +require_once('../../../include/globals.inc.php'); +require_once('../../../include/phrasen.class.php'); +require_once('../../../include/datum.class.php'); +require_once('../../../include/Excel/excel.php'); +require_once('../../../include/benutzer.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/mitarbeiter.class.php'); +require_once('../../../include/zeitaufzeichnung.class.php'); +require_once('../../../include/projekt.class.php'); +require_once('../../../include/bisverwendung.class.php'); + +if ((isset($_GET['uid'])) && (isset($_GET['day']))) +{ + $uid = get_uid(); + + //Wenn User Administrator ist und UID uebergeben wurde, dann die Zeitaufzeichnung + //des uebergebenen Users anzeigen + if (isset($_GET['uid']) && $_GET['uid'] != $uid) + { + $p = new phrasen(); + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($uid); + + if ($rechte->isBerechtigt('admin')) + { + $uid = $_GET['uid']; + } + else + { + die($p->t('global/FuerDieseAktionBenoetigenSieAdministrationsrechte')); + } + } + + $day = $_GET['day']; + + $verwendung = new bisverwendung(); + + $verwendung->getVerwendungDatum($uid, $day); + $homeoffice = false; + + foreach ($verwendung->result as $v) + { + if ($v->homeoffice) + { + $homeoffice = true; + } + } + + echo json_encode($homeoffice); + +} diff --git a/cis/private/tools/zeitaufzeichnung_projektliste.php b/cis/private/tools/zeitaufzeichnung_projektliste.php index 4621c4a66..177f1f8aa 100644 --- a/cis/private/tools/zeitaufzeichnung_projektliste.php +++ b/cis/private/tools/zeitaufzeichnung_projektliste.php @@ -559,9 +559,11 @@ $totalworktimewidth = 13; $worktimewidth = 14; $timecolumnswidth = 2 * $daywidth + $totalworktimewidth + $worktimewidth; -if ($nrProjects < 1)//no projekts - merge all cells and write notice +if ($nrProjects < 1) //no projekts - write notice { - $projektnames[] = "Keine Projekte vorhanden"; + $worksheet =& $workbook->addWorksheet('Tabelle'); + $worksheet->setInputEncoding('utf-8'); + $worksheet->write(0,0,'Für diesen Zeitraum sind keine Projekte zugeordnet'); } foreach ($projektnames as $projektname) diff --git a/cis/private/tools/zeitaufzeichnung_projektphasen.php b/cis/private/tools/zeitaufzeichnung_projektphasen.php index 4e4671367..cd0acc0bd 100644 --- a/cis/private/tools/zeitaufzeichnung_projektphasen.php +++ b/cis/private/tools/zeitaufzeichnung_projektphasen.php @@ -1,18 +1,59 @@ + Andreas Oesterreicher + Manuela Thamer + */ require_once('../../../config/cis.config.inc.php'); require_once('../../../include/functions.inc.php'); require_once('../../../include/basis_db.class.php'); require_once('../../../include/projektphase.class.php'); require_once('../../../include/datum.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/phrasen.class.php'); if (!$db = new basis_db()) die('Es konnte keine Verbindung zum Server aufgebaut werden.'); + $user = get_uid(); +//Wenn User Administrator ist und UID uebergeben wurde, dann die Phasen +//des uebergebenen Users anzeigen +if (isset($_GET['uid']) && $user != $_GET['uid']) +{ + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($user); + + if ($rechte->isBerechtigt('admin')) + { + $user = $_GET['uid']; + } + else + { + $p = new phrasen(); + die($p->t('global/FuerDieseAktionBenoetigenSieAdministrationsrechte')); + } +} + $datum_obj = new datum(); -if(isset($_GET['projekt_kurzbz'])) // TODO maybe check that phasen only shown if projekt is projekt of logged in user +if (isset($_GET['projekt_kurzbz'])) { $projekt_kurzbz = $_GET['projekt_kurzbz']; $projektphase = new projektphase(); @@ -28,12 +69,12 @@ if(isset($_GET['projekt_kurzbz'])) // TODO maybe check that phasen only shown if array_push($pp_user_ids, $pp_user->projektphase_id); } - if($projektphase->getProjektphasen($projekt_kurzbz)) + if ($projektphase->getProjektphasen($projekt_kurzbz)) { $result_obj = array(); - foreach($projektphase->result as $row) + foreach ($projektphase->result as $row) { - if(in_array($row->projektphase_id, $pp_user_ids)) + if (in_array($row->projektphase_id, $pp_user_ids)) { $item['projektphase_id'] = $row->projektphase_id; $item['bezeichnung'] = $row->bezeichnung; diff --git a/cis/testtool/admin/auswertung_detail.php b/cis/testtool/admin/auswertung_detail.php index 05a6143ee..775234670 100644 --- a/cis/testtool/admin/auswertung_detail.php +++ b/cis/testtool/admin/auswertung_detail.php @@ -104,9 +104,11 @@ if(isset($_GET['show'])) SELECT distinct on(tbl_frage.frage_id) *, tbl_gebiet.kurzbz as gebiet FROM - testtool.tbl_frage - JOIN testtool.tbl_ablauf USING(gebiet_id) - JOIN testtool.tbl_frage_sprache USING(frage_id) + testtool.tbl_frage "; + if($stg_kz!='') + $qry.=" JOIN testtool.tbl_ablauf USING(gebiet_id) "; + + $qry.=" JOIN testtool.tbl_frage_sprache USING(frage_id) JOIN testtool.tbl_gebiet USING(gebiet_id) WHERE demo=false"; diff --git a/cis/testtool/login.php b/cis/testtool/login.php index b7cbc02b5..a738c0a88 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -1,734 +1,736 @@ -, - * Andreas Oesterreicher , - * Rudolf Hangl , - * Manfred Kindl - * Cristina Hainberger - */ - -require_once('../../config/cis.config.inc.php'); -require_once('../../config/global.config.inc.php'); -require_once('../../include/person.class.php'); -require_once('../../include/prestudent.class.php'); -require_once('../../include/pruefling.class.php'); -require_once('../../include/studiengang.class.php'); -require_once('../../include/studienplan.class.php'); -require_once('../../include/ablauf.class.php'); -require_once('../../include/reihungstest.class.php'); -require_once('../../include/sprache.class.php'); -require_once '../../include/phrasen.class.php'; -require_once '../../include/datum.class.php'; - -if (!$db = new basis_db()) - die('Fehler beim Oeffnen der Datenbankverbindung'); - -// Start session -session_start(); - -// Logout (triggered by logout button in menu.php) -if (isset($_GET['logout']) && $_GET['logout'] == true) -{ - // Unset global vars - unset($_GET['logout']); - unset($_GET['sprache_user']); - $_POST = []; - $_SESSION = []; - - // Destroy session - session_destroy(); - - echo ' - - '; -} - -$gebdatum=''; -$date = new datum(); - -$reload_menu=false; -$alertmsg = ''; - -$sg_var = new studiengang(); - -if (isset($_POST['gebdatum']) && $_POST['gebdatum']!='') -{ - $gebdatum = $date->formatDatum($_POST['gebdatum'],'Y-m-d'); -} -else - $gebdatum=''; - -if (isset($_REQUEST['prestudent'])) -{ - $ps = new prestudent($_REQUEST['prestudent']); - - $login_ok = false; - if (defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') && TESTTOOL_LOGIN_BEWERBUNGSTOOL && isset($_GET['confirmation'])) - { - if (isset($_SESSION['bewerbung/personId']) && $ps->person_id == $_SESSION['bewerbung/personId']) - { - $login_ok = true; - } - else - { - $alertmsg .= '
Login ist nicht korrekt. - Bitte schließen Sie ihren Browser und versuchen es erneut -
'; - } - } - elseif(!defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') || TESTTOOL_LOGIN_BEWERBUNGSTOOL == false) - { - //Geburtsdatum Pruefen - if (isset($gebdatum) && $gebdatum == $ps->gebdatum) - { - $login_ok = true; - } - else - { - $alertmsg .= '
'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'
'; - } - } - - if ($login_ok) - { - $reihungstest_id=''; - //Freischaltung fuer zugeteilten Reihungstest pruefen - $rt = new reihungstest(); - - // Wenns der Dummy ist dann extra laden - // An der FHTW gibt es 3 Testuser für den Camus International - $prestudent_id_dummy_student = (defined('PRESTUDENT_ID_DUMMY_STUDENT')?PRESTUDENT_ID_DUMMY_STUDENT:''); - if ($prestudent_id_dummy_student==$ps->prestudent_id || - (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30891) || - (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30890) || - (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30889)) - { - $rt->getReihungstestPerson($ps->person_id); - if (isset($rt->result[0])) - $reihungstest_id = $rt->result[0]->reihungstest_id; - else - { - $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; - } - } - else - { - if ($rt->getReihungstestPersonDatum($ps->prestudent_id, date('Y-m-d'))) - { - // TODO Was ist wenn da mehrere Zurueckkommen?! - if (isset($rt->result[0])) - $reihungstest_id = $rt->result[0]->reihungstest_id; - else - { - $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; - } - } - else - { - echo 'Failed:'.$rt->errormsg; - } - } - if ($reihungstest_id != '' && $rt->load($reihungstest_id)) - { - if ($rt->freigeschaltet) - { - // regenerate Session ID after Login - session_regenerate_id(); - - $pruefling = new pruefling(); - if ($pruefling->getPruefling($ps->prestudent_id)) - { - $studiengang = $pruefling->studiengang_kz; - $semester = $pruefling->semester; - } - else - { - $studiengang = $ps->studiengang_kz; - $ps->getLastStatus($ps->prestudent_id); - $semester = $ps->ausbildungssemester; - } - if ($semester=='') - $semester=1; - - $_SESSION['prestudent_id']=$_REQUEST['prestudent']; - $_SESSION['studiengang_kz']=$studiengang; - $_SESSION['nachname']=$ps->nachname; - $_SESSION['vorname']=$ps->vorname; - $_SESSION['gebdatum']=$ps->gebdatum; - $stg_obj = new studiengang($studiengang); - - $_SESSION['semester']=$semester; - $_SESSION['reihungstestID'] = $reihungstest_id; - $stg_obj->getStudiengangTyp($stg_obj->typ); - - // STG und Studienplan mit der höchsten Prio ermitteln - $firstPrio_studienplan_id = ''; - $firstPrio_studiengang_kz = ''; - - // * wenn STG des eingeloggten Prestudenten vom Typ Bachelor ist, dann höchste Prio aller - // Bachelor-STG ermitteln, an denen die Person noch interessiert ist - // Wenn STG vom Typ Master, dann wird als firstPrio der STPL bzw. der STG des MasterSTG gesetzt. - if ($stg_obj->typ == 'b') - { - $ps->getActualInteressenten($_REQUEST['prestudent'], true); - } - elseif ($stg_obj->typ == 'm') - { - $ps->getActualInteressenten($_REQUEST['prestudent'], false, 'm', $studiengang); - } - - foreach($ps->result as $row) - { - if (isset($row->studiengang_kz)) - { - $firstPrio_studienplan_id = $row->studienplan_id; - break; - } - } - foreach($ps->result as $row) - { - if (isset($row->studiengang_kz)) - { - $firstPrio_studiengang_kz = $row->studiengang_kz; - break; - } - } - // Sprachvorgaben zu STG mit höchster Prio ermitteln - - // * 1. Sprache über Ablauf Vorgaben ermitteln - $ablauf = new Ablauf(); - $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); - $rt_sprache = ''; - - if (empty($ablauf->result[0])) - { - $ablauf->getAblaufGebiete($firstPrio_studiengang_kz); - } - - if (!empty($ablauf->result[0])) - { - $rt_sprache = $ablauf->result[0]->sprache; - } - - // * 2. falls keine Sprache vorhanden -> Sprache über Studienplan ermitteln - if (empty($rt_sprache)) - { - $stpl = new Studienplan(); - $stpl->loadStudienplan($firstPrio_studienplan_id); - $rt_sprache = $stpl->sprache; - } - - // * 3. falls keine Sprache vorhanden -> Sprache über Studiengang ermitteln - if (empty($rt_sprache)) - { - $stg = new Studiengang($firstPrio_studiengang_kz); - $rt_sprache = $stg->sprache; - } - - // * 4. Sprache setzen. Falls keine Sprache vorhanden -> DEFAULT language verwenden - if (empty($rt_sprache)) - { - $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; - } - else - { - $_SESSION['sprache_user'] = $rt_sprache; - } - } - else - { - $alertmsg .= '
'.$p->t('testtool/reihungstestNichtFreigeschalten').'
'; - } - } - else - { - $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; - } - } -} - -// Set language of user. -// NOTE: don't move the code in order to check first the right studies' reihungstest language -// (in case it was overruled by other STG with higher priority) - -// Start with default language on first login (before any prestudent has been selected) -$sprache_user = DEFAULT_LANGUAGE; -if (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) -{ - // If session var already exists, overwrite language var - // (session var changes e.g. when user selects other language with language-select-menu) - $sprache_user = $_SESSION['sprache_user']; -} -elseif (isset($_SESSION['prestudent_id'])) -{ - // If session var does not exist but prestudent is known, set the session var - $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; -} - -// If language is changed by language select menu, reset language variables -if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) -{ - $sprache_user = $_GET['sprache_user']; - $_SESSION['sprache_user'] = $_GET['sprache_user']; -} - -// NOTE: leave phrasen here, as the final users language is not defined until here -$p = new phrasen($sprache_user); - -if (isset($_SESSION['prestudent_id'])) -{ - $prestudent_id=$_SESSION['prestudent_id']; -} -else -{ - //$prestudent_id=null; - $ps=new prestudent(); - $datum=date('Y-m-d'); - // An der FHTW wird ein Bewerber nur einmal ausgegeben (1. Prio) falls es mehrere Bewerbungen gibt - /*if (CAMPUS_NAME == 'FH Technikum Wien') - { - $ps->getFirstPrioPrestudentRT($datum); - } - else*/ - { - $ps->getPrestudentRT($datum); - } -} - - -if (isset($_SESSION['prestudent_id']) && !isset($_SESSION['pruefling_id'])) -{ - $pruefling = new pruefling(); - - //wenn kein Prüfling geladen werden kann - if (!$pruefling->getPruefling($_SESSION['prestudent_id'])) - $pruefling->new = true; - else - $pruefling->new = false; - - $pruefling->studiengang_kz = $_SESSION['studiengang_kz']; - $pruefling->semester = $_SESSION['semester']; - - $pruefling->idnachweis = ''; - $pruefling->registriert = date('Y-m-d H:i:s'); - $pruefling->prestudent_id = $_SESSION['prestudent_id']; - if ($pruefling->save()) - { - $_SESSION['pruefling_id']=$pruefling->pruefling_id; - $reload_menu=true; - } -} - -if (isset($_POST['save']) && isset($_SESSION['prestudent_id'])) -{ - $pruefling = new pruefling(); - if ($_POST['pruefling_id']!='') - if (!$pruefling->load($_POST['pruefling_id'])) - die('Pruefling wurde nicht gefunden'); - else - $pruefling->new=false; - else - $pruefling->new=true; - - $pruefling->studiengang_kz = $_SESSION['studiengang_kz']; - $pruefling->idnachweis = isset($_POST['idnachweis'])?$_POST['idnachweis']:''; - $pruefling->registriert = date('Y-m-d H:i:s'); - $pruefling->prestudent_id = $_SESSION['prestudent_id']; - $pruefling->semester = $_POST['semester']; - if ($pruefling->save()) - { - $_SESSION['pruefling_id']=$pruefling->pruefling_id; - $_SESSION['semester']=$pruefling->semester; - $reload_menu=true; - } -} -?> - - - - - - - - - - - -parent.menu.location.reload();'; -?> - - - -
- -studiengang_kz); - $pruefling = new pruefling(); - $typ = new studiengang($prestudent->studiengang_kz); - $typ->getStudiengangTyp($stg_obj->typ); - - // STG mit der höchsten Prio ermitteln - $ps = new Prestudent(); - - // * prinzipiell STG der session übernehmem - $firstPrio_studiengang_kz = $prestudent->studiengang_kz; - - // * wenn STG des eingeloggten Prestudenten vom Typ Bachelor ist, dann höchste Prio aller - // Bachelor-STG ermitteln, an denen die Person noch interessiert ist - if ($typ->typ == 'b') - { - $ps->getActualInteressenten($prestudent_id, true, 'b'); - foreach($ps->result as $row_prio) - { - if (isset($row_prio->studiengang_kz)) - { - $firstPrio_studiengang_kz = $row_prio->studiengang_kz; - $firstPrio_studienplan_id = $row_prio->studienplan_id; - break; - } - } - } - - // Sprachwahl zu STG mit höchster Prio ermitteln - $ablauf = new Ablauf(); - $sprachwahl = false; - - $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); - - if (empty($ablauf->result[0])) - { - $ablauf->getAblaufGebiete($firstPrio_studiengang_kz); - } - - if (isset($ablauf->result[0]) - && is_bool($ablauf->result[0]->sprachwahl)) - { - $sprachwahl = $ablauf->result[0]->sprachwahl; - } - - // If language can be switched, display language select menu on the top - if ($sprachwahl) - { - $_SESSION['sprache_auswahl'] = true; - ?> - - '; - echo ' -

'. $p->t('testtool/begruessungstext'). '


-

'. $p->t('testtool/anmeldedaten'). '


- '; - - echo ' - - - - - - - - - - - - - -
'.$p->t('zeitaufzeichnung/id').''.$_SESSION['prestudent_id'].'
'.$p->t('global/name').''.$_SESSION['vorname'].' '.$_SESSION['nachname'].'
'.$p->t('global/geburtsdatum').''.$date->formatDatum($_SESSION["gebdatum"],"d.m.Y").'
- '; - echo '
'; - echo ' -

'. $p->t('testtool/fuerFolgendeStgAngemeldet'). '


- - - - - - - - - - '; - - // * wenn Prestudent an 1 - n Bachelor-Studiengängen interessiert ist, dann STG anführen - if ($typ->typ == 'b') - { - $ps_arr = new Prestudent(); - $ps_arr->getActualInteressenten($prestudent_id, false, 'b'); - - if (count($ps_arr->result) > 0) - { - // Jeweils letzten Status ermitteln (ob Interessent oder Abgewiesener) - foreach ($ps_arr->result as $ps_obj) - { - $ps_tmp = new Prestudent(); - $ps_tmp->getLastStatus($ps_obj->prestudent_id); - - $ps_obj->lastStatus = $ps_tmp->status_kurzbz; // letzten Status dem result array hinzufügen - $ps_obj->status_mehrsprachig = $ps_tmp->status_mehrsprachig; - } - - // Falls Status 'Abgewiesene' vorhanden, nach hinten reihen - usort($ps_arr->result, function($a, $b){ - return strcmp($b->lastStatus, $a->lastStatus); // Order by DESC - }); - foreach ($ps_arr->result as $ps_obj) - { - echo ''; - $stg = new Studiengang($ps_obj->studiengang_kz); - - if ($ps_obj->lastStatus == "Interessent" - || $ps_obj->lastStatus == "Bewerber" - || $ps_obj->lastStatus == "Wartender" - || $ps_obj->lastStatus == "Aufgenommener") - { - echo ''; - if ($ps_obj->ausbildungssemester == '1') - { - echo ''; - } - elseif ($ps_obj->ausbildungssemester == '3') - { - echo ''; - } - } - // wenn letzter Status \'Abgewiesener\' ist, dann als solchen kennzeichnen - elseif ($ps_obj->lastStatus == "Abgewiesener") - { - echo ' - - - '; - } - echo ''; - } - } - } - // * wenn Prestudent an einem Master-Studiengang interessiert ist, dann nur den einen STG anführen - else - { - // Letzten Status für des Prestudenten einholen - $ps_master = new Prestudent(); - $ps_master->getLastStatus($prestudent_id); - echo ''; - echo ''; - } - - echo ' - -
'. $p->t('global/studiengang'). 'Status
'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). ' ('.$ps_obj->orgform_bezeichnung[$sprache_user].')'. $p->t('testtool/regulaererEinstieg'). ' (1. Semester)'. $p->t('testtool/quereinstieg'). ' (3. Semester)'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). ''. $ps_obj->status_mehrsprachig[$sprache_user]. '
'. $typ->bezeichnung.' '.($sprache_user=='English'?$stg_obj->english:$stg_obj->bezeichnung).''. $ps_master->status_mehrsprachig[$sprache_user]. '
- '; - - echo '
'; - - if ($pruefling->getPruefling($prestudent_id)) - { - echo '
'; - echo ''; - echo ''; - //echo ''; - //echo ''; - //echo ''; - echo '
'.$p->t('global/semester').': 
ID Nachweis:
'; - echo '
'; - echo '

'; - echo ' -
- '.$p->t('testtool/klickenSieAufEinTeilgebiet').' -
- '; - if ($pruefling->pruefling_id!='') - { - $_SESSION['pruefling_id']=$pruefling->pruefling_id; - } - } - else - { - echo ''.$p->t('testtool/keinPrueflingseintragVorhanden').''; - } - echo '
'; -} -else // LOGIN Site (vor Login) -{ - if (defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') && TESTTOOL_LOGIN_BEWERBUNGSTOOL) - { - echo '
'; - echo '
'.$alertmsg.'
'; - echo $p->t('testtool/einfuehrungsText'); - - if (isset($_SESSION['bewerbung/personId'])) - { - echo ''; - echo '
- '.$p->t('testtool/loginNoetig').'

-
- - - '.$p->t('testtool/confirmationText').' -

- -
'; - } - else - { - echo '
- '.$p->t('testtool/loginNoetig').'

-
- -
'; - } - echo ' -
'; - echo '
'; - } - else - { - $prestudent_id_dummy_student = (defined('PRESTUDENT_ID_DUMMY_STUDENT')?PRESTUDENT_ID_DUMMY_STUDENT:''); - echo '
'; - - // Welcome text - echo '
'.$alertmsg.'
'; - echo ' -
-
-

Herzlich Willkommen zum Reihungstest



- Bitte warten Sie mit dem Login auf die Anweisung der Aufsichtsperson.

- Wir wünschen Ihnen einen erfolgreichen Start ins Studium. -
-
-

Welcome to the placement test



- Please wait for the tutor\'s instructions before you log in.

- We wish you a good start to your studies. -
-
- '; - - // Begin form - echo '
'; - echo '
'; - - // Name select menu - echo '
'; - echo ''; - echo '
'; - echo ''; - echo '
'; // end col-xs - echo '
'; // end form-group - - // Datepicker input - echo '
'; - echo ''; - echo '
'; - echo ''; - echo '
'; // end col-xs - echo '
'; // end form-group - - // Login button - echo ''; - - echo '
'; // end form - - echo '
'; // end row - echo '
'; // end col-xs-11 - } -} - -?> -
- - +, + * Andreas Oesterreicher , + * Rudolf Hangl , + * Manfred Kindl + * Cristina Hainberger + */ + +require_once('../../config/cis.config.inc.php'); +require_once('../../config/global.config.inc.php'); +require_once('../../include/person.class.php'); +require_once('../../include/prestudent.class.php'); +require_once('../../include/pruefling.class.php'); +require_once('../../include/studiengang.class.php'); +require_once('../../include/studienplan.class.php'); +require_once('../../include/ablauf.class.php'); +require_once('../../include/reihungstest.class.php'); +require_once('../../include/sprache.class.php'); +require_once '../../include/phrasen.class.php'; +require_once '../../include/datum.class.php'; + +if (!$db = new basis_db()) + die('Fehler beim Oeffnen der Datenbankverbindung'); + +// Start session +session_start(); + +// Logout (triggered by logout button in menu.php) +if (isset($_GET['logout']) && $_GET['logout'] == true) +{ + // Unset global vars + unset($_GET['logout']); + unset($_GET['sprache_user']); + $_POST = []; + $_SESSION = []; + + // Destroy session + session_destroy(); + + echo ' + + '; +} + +$gebdatum=''; +$date = new datum(); + +$reload_menu=false; +$alertmsg = ''; + +$sg_var = new studiengang(); + +if (isset($_POST['gebdatum']) && $_POST['gebdatum']!='') +{ + $gebdatum = $date->formatDatum($_POST['gebdatum'],'Y-m-d'); +} +else + $gebdatum=''; + +if (isset($_REQUEST['prestudent'])) +{ + $ps = new prestudent($_REQUEST['prestudent']); + + $login_ok = false; + if (defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') && TESTTOOL_LOGIN_BEWERBUNGSTOOL && isset($_GET['confirmation'])) + { + if (isset($_SESSION['bewerbung/personId']) && $ps->person_id == $_SESSION['bewerbung/personId']) + { + $login_ok = true; + } + else + { + $alertmsg .= '
Login ist nicht korrekt. + Bitte schließen Sie ihren Browser und versuchen es erneut +
'; + } + } + elseif(!defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') || TESTTOOL_LOGIN_BEWERBUNGSTOOL == false) + { + //Geburtsdatum Pruefen + if (isset($gebdatum) && $gebdatum == $ps->gebdatum) + { + $login_ok = true; + } + else + { + $alertmsg .= '
'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'
'; + } + } + + if ($login_ok) + { + $reihungstest_id=''; + //Freischaltung fuer zugeteilten Reihungstest pruefen + $rt = new reihungstest(); + + // Wenns der Dummy ist dann extra laden + // An der FHTW gibt es 3 Testuser für den Camus International + $prestudent_id_dummy_student = (defined('PRESTUDENT_ID_DUMMY_STUDENT')?PRESTUDENT_ID_DUMMY_STUDENT:''); + if ($prestudent_id_dummy_student==$ps->prestudent_id || + (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30891) || + (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30890) || + (CAMPUS_NAME == 'FH Technikum Wien' && $ps->prestudent_id == 30889)) + { + $rt->getReihungstestPerson($ps->person_id); + if (isset($rt->result[0])) + $reihungstest_id = $rt->result[0]->reihungstest_id; + else + { + $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; + } + } + else + { + if ($rt->getReihungstestPersonDatum($ps->prestudent_id, date('Y-m-d'))) + { + // TODO Was ist wenn da mehrere Zurueckkommen?! + if (isset($rt->result[0])) + $reihungstest_id = $rt->result[0]->reihungstest_id; + else + { + $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; + } + } + else + { + echo 'Failed:'.$rt->errormsg; + } + } + if ($reihungstest_id != '' && $rt->load($reihungstest_id)) + { + if ($rt->freigeschaltet) + { + // regenerate Session ID after Login + session_regenerate_id(); + + $pruefling = new pruefling(); + if ($pruefling->getPruefling($ps->prestudent_id)) + { + $studiengang = $pruefling->studiengang_kz; + $semester = $pruefling->semester; + } + else + { + $studiengang = $ps->studiengang_kz; + $ps->getLastStatus($ps->prestudent_id); + $semester = $ps->ausbildungssemester; + } + if ($semester=='') + $semester=1; + + $_SESSION['prestudent_id']=$_REQUEST['prestudent']; + $_SESSION['studiengang_kz']=$studiengang; + $_SESSION['nachname']=$ps->nachname; + $_SESSION['vorname']=$ps->vorname; + $_SESSION['gebdatum']=$ps->gebdatum; + $stg_obj = new studiengang($studiengang); + + $_SESSION['semester']=$semester; + $_SESSION['reihungstestID'] = $reihungstest_id; + $stg_obj->getStudiengangTyp($stg_obj->typ); + + // STG und Studienplan mit der höchsten Prio ermitteln + $firstPrio_studienplan_id = ''; + $firstPrio_studiengang_kz = ''; + + // * wenn STG des eingeloggten Prestudenten vom Typ Bachelor ist, dann höchste Prio aller + // Bachelor-STG ermitteln, an denen die Person noch interessiert ist + // Wenn STG vom Typ Master, dann wird als firstPrio der STPL bzw. der STG des MasterSTG gesetzt. + if ($stg_obj->typ == 'b') + { + $ps->getActualInteressenten($_REQUEST['prestudent'], true); + } + elseif ($stg_obj->typ == 'm') + { + $ps->getActualInteressenten($_REQUEST['prestudent'], false, 'm', $studiengang); + } + + foreach($ps->result as $row) + { + if (isset($row->studiengang_kz)) + { + $firstPrio_studienplan_id = $row->studienplan_id; + break; + } + } + foreach($ps->result as $row) + { + if (isset($row->studiengang_kz)) + { + $firstPrio_studiengang_kz = $row->studiengang_kz; + break; + } + } + // Sprachvorgaben zu STG mit höchster Prio ermitteln + + // * 1. Sprache über Ablauf Vorgaben ermitteln + $ablauf = new Ablauf(); + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); + $rt_sprache = ''; + + if (empty($ablauf->result[0])) + { + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz); + } + + if (!empty($ablauf->result[0])) + { + $rt_sprache = $ablauf->result[0]->sprache; + } + + // * 2. falls keine Sprache vorhanden -> Sprache über Studienplan ermitteln + if (empty($rt_sprache)) + { + $stpl = new Studienplan(); + $stpl->loadStudienplan($firstPrio_studienplan_id); + $rt_sprache = $stpl->sprache; + } + + // * 3. falls keine Sprache vorhanden -> Sprache über Studiengang ermitteln + if (empty($rt_sprache)) + { + $stg = new Studiengang($firstPrio_studiengang_kz); + $rt_sprache = $stg->sprache; + } + + // * 4. Sprache setzen. Falls keine Sprache vorhanden -> DEFAULT language verwenden + if (empty($rt_sprache)) + { + $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; + } + else + { + $_SESSION['sprache_user'] = $rt_sprache; + } + } + else + { + $alertmsg .= '
'.$p->t('testtool/reihungstestNichtFreigeschalten').'
'; + } + } + else + { + $alertmsg .= '
'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'
'; + } + } +} + +// Set language of user. +// NOTE: don't move the code in order to check first the right studies' reihungstest language +// (in case it was overruled by other STG with higher priority) + +// Start with default language on first login (before any prestudent has been selected) +$sprache_user = DEFAULT_LANGUAGE; +if (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) +{ + // If session var already exists, overwrite language var + // (session var changes e.g. when user selects other language with language-select-menu) + $sprache_user = $_SESSION['sprache_user']; +} +elseif (isset($_SESSION['prestudent_id'])) +{ + // If session var does not exist but prestudent is known, set the session var + $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; +} + +// If language is changed by language select menu, reset language variables +if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) +{ + $sprache_user = $_GET['sprache_user']; + $_SESSION['sprache_user'] = $_GET['sprache_user']; +} + +// NOTE: leave phrasen here, as the final users language is not defined until here +$p = new phrasen($sprache_user); + +if (isset($_SESSION['prestudent_id'])) +{ + $prestudent_id=$_SESSION['prestudent_id']; +} +else +{ + //$prestudent_id=null; + $ps=new prestudent(); + $datum=date('Y-m-d'); + // An der FHTW wird ein Bewerber nur einmal ausgegeben (1. Prio) falls es mehrere Bewerbungen gibt + /*if (CAMPUS_NAME == 'FH Technikum Wien') + { + $ps->getFirstPrioPrestudentRT($datum); + } + else*/ + { + $ps->getPrestudentRT($datum); + } +} + + +if (isset($_SESSION['prestudent_id']) && !isset($_SESSION['pruefling_id'])) +{ + $pruefling = new pruefling(); + + //wenn kein Prüfling geladen werden kann + if (!$pruefling->getPruefling($_SESSION['prestudent_id'])) + $pruefling->new = true; + else + $pruefling->new = false; + + $pruefling->studiengang_kz = $_SESSION['studiengang_kz']; + $pruefling->semester = $_SESSION['semester']; + + $pruefling->idnachweis = ''; + $pruefling->registriert = date('Y-m-d H:i:s'); + $pruefling->prestudent_id = $_SESSION['prestudent_id']; + if ($pruefling->save()) + { + $_SESSION['pruefling_id']=$pruefling->pruefling_id; + $reload_menu=true; + } +} + +if (isset($_POST['save']) && isset($_SESSION['prestudent_id'])) +{ + $pruefling = new pruefling(); + if ($_POST['pruefling_id']!='') + if (!$pruefling->load($_POST['pruefling_id'])) + die('Pruefling wurde nicht gefunden'); + else + $pruefling->new=false; + else + $pruefling->new=true; + + $pruefling->studiengang_kz = $_SESSION['studiengang_kz']; + $pruefling->idnachweis = isset($_POST['idnachweis'])?$_POST['idnachweis']:''; + $pruefling->registriert = date('Y-m-d H:i:s'); + $pruefling->prestudent_id = $_SESSION['prestudent_id']; + $pruefling->semester = $_POST['semester']; + if ($pruefling->save()) + { + $_SESSION['pruefling_id']=$pruefling->pruefling_id; + $_SESSION['semester']=$pruefling->semester; + $reload_menu=true; + } +} +?> + + + + + + + + + + + +parent.menu.location.reload();'; +?> + + + +
+ +studiengang_kz); + $pruefling = new pruefling(); + $typ = new studiengang($prestudent->studiengang_kz); + $typ->getStudiengangTyp($stg_obj->typ); + + // STG mit der höchsten Prio ermitteln + $ps = new Prestudent(); + + // * prinzipiell STG der session übernehmem + $firstPrio_studiengang_kz = $prestudent->studiengang_kz; + + // * wenn STG des eingeloggten Prestudenten vom Typ Bachelor ist, dann höchste Prio aller + // Bachelor-STG ermitteln, an denen die Person noch interessiert ist + $firstPrio_studienplan_id = ''; + $firstPrio_studiengang_kz = ''; + if ($typ->typ == 'b') + { + $ps->getActualInteressenten($prestudent_id, true, 'b'); + foreach($ps->result as $row_prio) + { + if (isset($row_prio->studiengang_kz)) + { + $firstPrio_studiengang_kz = $row_prio->studiengang_kz; + $firstPrio_studienplan_id = $row_prio->studienplan_id; + break; + } + } + } + + // Sprachwahl zu STG mit höchster Prio ermitteln + $ablauf = new Ablauf(); + $sprachwahl = false; + + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); + + if (empty($ablauf->result[0])) + { + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz); + } + + if (isset($ablauf->result[0]) + && is_bool($ablauf->result[0]->sprachwahl)) + { + $sprachwahl = $ablauf->result[0]->sprachwahl; + } + + // If language can be switched, display language select menu on the top + if ($sprachwahl) + { + $_SESSION['sprache_auswahl'] = true; + ?> + + '; + echo ' +

'. $p->t('testtool/begruessungstext'). '


+

'. $p->t('testtool/anmeldedaten'). '


+ '; + + echo ' + + + + + + + + + + + + + +
'.$p->t('zeitaufzeichnung/id').''.$_SESSION['prestudent_id'].'
'.$p->t('global/name').''.$_SESSION['vorname'].' '.$_SESSION['nachname'].'
'.$p->t('global/geburtsdatum').''.$date->formatDatum($_SESSION["gebdatum"],"d.m.Y").'
+ '; + echo '
'; + echo ' +

'. $p->t('testtool/fuerFolgendeStgAngemeldet'). '


+ + + + + + + + + + '; + + // * wenn Prestudent an 1 - n Bachelor-Studiengängen interessiert ist, dann STG anführen + if ($typ->typ == 'b') + { + $ps_arr = new Prestudent(); + $ps_arr->getActualInteressenten($prestudent_id, false, 'b'); + + if (count($ps_arr->result) > 0) + { + // Jeweils letzten Status ermitteln (ob Interessent oder Abgewiesener) + foreach ($ps_arr->result as $ps_obj) + { + $ps_tmp = new Prestudent(); + $ps_tmp->getLastStatus($ps_obj->prestudent_id); + + $ps_obj->lastStatus = $ps_tmp->status_kurzbz; // letzten Status dem result array hinzufügen + $ps_obj->status_mehrsprachig = $ps_tmp->status_mehrsprachig; + } + + // Falls Status 'Abgewiesene' vorhanden, nach hinten reihen + usort($ps_arr->result, function($a, $b){ + return strcmp($b->lastStatus, $a->lastStatus); // Order by DESC + }); + foreach ($ps_arr->result as $ps_obj) + { + echo ''; + $stg = new Studiengang($ps_obj->studiengang_kz); + + if ($ps_obj->lastStatus == "Interessent" + || $ps_obj->lastStatus == "Bewerber" + || $ps_obj->lastStatus == "Wartender" + || $ps_obj->lastStatus == "Aufgenommener") + { + echo ''; + if ($ps_obj->ausbildungssemester == '1') + { + echo ''; + } + elseif ($ps_obj->ausbildungssemester == '3') + { + echo ''; + } + } + // wenn letzter Status \'Abgewiesener\' ist, dann als solchen kennzeichnen + elseif ($ps_obj->lastStatus == "Abgewiesener") + { + echo ' + + + '; + } + echo ''; + } + } + } + // * wenn Prestudent an einem Master-Studiengang interessiert ist, dann nur den einen STG anführen + else + { + // Letzten Status für des Prestudenten einholen + $ps_master = new Prestudent(); + $ps_master->getLastStatus($prestudent_id); + echo ''; + echo ''; + } + + echo ' + +
'. $p->t('global/studiengang'). 'Status
'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). ' ('.$ps_obj->orgform_bezeichnung[$sprache_user].')'. $p->t('testtool/regulaererEinstieg'). ' (1. Semester)'. $p->t('testtool/quereinstieg'). ' (3. Semester)'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). ''. $ps_obj->status_mehrsprachig[$sprache_user]. '
'. $typ->bezeichnung.' '.($sprache_user=='English'?$stg_obj->english:$stg_obj->bezeichnung).''. $ps_master->status_mehrsprachig[$sprache_user]. '
+ '; + + echo '
'; + + if ($pruefling->getPruefling($prestudent_id)) + { + echo '
'; + echo ''; + echo ''; + //echo ''; + //echo ''; + //echo ''; + echo '
'.$p->t('global/semester').': 
ID Nachweis:
'; + echo '
'; + echo '

'; + echo ' +
+ '.$p->t('testtool/klickenSieAufEinTeilgebiet').' +
+ '; + if ($pruefling->pruefling_id!='') + { + $_SESSION['pruefling_id']=$pruefling->pruefling_id; + } + } + else + { + echo ''.$p->t('testtool/keinPrueflingseintragVorhanden').''; + } + echo '
'; +} +else // LOGIN Site (vor Login) +{ + if (defined('TESTTOOL_LOGIN_BEWERBUNGSTOOL') && TESTTOOL_LOGIN_BEWERBUNGSTOOL) + { + echo '
'; + echo '
'.$alertmsg.'
'; + echo $p->t('testtool/einfuehrungsText'); + + if (isset($_SESSION['bewerbung/personId'])) + { + echo ''; + echo '
+ '.$p->t('testtool/loginNoetig').'

+
+ + + '.$p->t('testtool/confirmationText').' +

+ +
'; + } + else + { + echo '
+ '.$p->t('testtool/loginNoetig').'

+
+ +
'; + } + echo ' +
'; + echo '
'; + } + else + { + $prestudent_id_dummy_student = (defined('PRESTUDENT_ID_DUMMY_STUDENT')?PRESTUDENT_ID_DUMMY_STUDENT:''); + echo '
'; + + // Welcome text + echo '
'.$alertmsg.'
'; + echo ' +
+
+

Herzlich Willkommen zum Reihungstest



+ Bitte warten Sie mit dem Login auf die Anweisung der Aufsichtsperson.

+ Wir wünschen Ihnen einen erfolgreichen Start ins Studium. +
+
+

Welcome to the placement test



+ Please wait for the tutor\'s instructions before you log in.

+ We wish you a good start to your studies. +
+
+ '; + + // Begin form + echo '
'; + echo '
'; + + // Name select menu + echo '
'; + echo ''; + echo '
'; + echo ''; + echo '
'; // end col-xs + echo '
'; // end form-group + + // Datepicker input + echo '
'; + echo ''; + echo '
'; + echo ''; + echo '
'; // end col-xs + echo '
'; // end form-group + + // Login button + echo ''; + + echo '
'; // end form + + echo '
'; // end row + echo '
'; // end col-xs-11 + } +} + +?> +
+ + diff --git a/cms/tinymce_dms.php b/cms/tinymce_dms.php index 7aff94860..f15695be8 100644 --- a/cms/tinymce_dms.php +++ b/cms/tinymce_dms.php @@ -332,6 +332,7 @@ if (isset($_POST['fileupload'])) $dms_id = $_POST['dms_id']; $beschreibung = $_POST['beschreibung']; $schlagworte = $_POST['schlagworte']; + $mimetype = isset($_POST['mimetype']) ? $_POST['mimetype'] : ''; $cis_suche = isset($_POST['cis_suche']) ? true : false; $ext = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION); $filename = uniqid(); @@ -363,7 +364,14 @@ if (isset($_POST['fileupload'])) $dms->insertamum = date('Y-m-d H:i:s'); $dms->insertvon = $user; - $dms->mimetype = finfo_file($finfo, $uploadfile); // Davor deprecated: $_FILES['userfile']['type']; + if ($mimetype != '') + { + $dms->mimetype = $mimetype; + } + else + { + $dms->mimetype = finfo_file($finfo, $uploadfile); + } $dms->filename = $filename; $dms->name = $_FILES['userfile']['name']; $dms->beschreibung = $beschreibung; @@ -404,6 +412,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'rename') $version = $_POST['version']; $beschreibung = $_POST['beschreibung']; $schlagworte = $_POST['schlagworte']; + $mimetype = isset($_POST['mimetype']) ? $_POST['mimetype'] : ''; $cis_suche = isset($_POST['cis_suche']) ? true : false; $dms = new dms(); @@ -413,6 +422,14 @@ if (isset($_POST['action']) && $_POST['action'] == 'rename') $dms->beschreibung = $beschreibung; $dms->schlagworte = $schlagworte; $dms->cis_suche = $cis_suche; + if ($mimetype != '') + { + $dms->mimetype = $mimetype; + } + else + { + $dms->mimetype = finfo_file($finfo, $uploadfile); + } $dms->updateamum = date('Y-m-d H:i:s'); $dms->updatevon = $user; @@ -1012,6 +1029,10 @@ else Schlagworte
(Semikolon getrennt) + + Mimetype + + CIS-Suche @@ -1088,6 +1109,7 @@ function drawAllVersions($id) CIS-Suche Kategorie Filename intern + Mimetype Datum User @@ -1102,6 +1124,7 @@ function drawAllVersions($id) '.($dms_help->cis_suche == 'true'?'Ja':'Nein').' '.$dms_help->kategorie_kurzbz.' '.$dms_help->filename.' + '.$dms_help->mimetype.' '.$dms_help->insertamum.' '.$dms_help->insertvon.' @@ -1568,6 +1591,10 @@ function drawRenameForm($dms_id, $version, $page = NULL, $dpp = NULL, $searching Schlagworte
(Semikolon getrennt): + + Mimetype + + CIS-Suche: cis_suche == 'true'?'checked="checked"':'').'> diff --git a/content/lvplanung/lehrveranstaltungDBDML.php b/content/lvplanung/lehrveranstaltungDBDML.php index f764545a6..438844071 100644 --- a/content/lvplanung/lehrveranstaltungDBDML.php +++ b/content/lvplanung/lehrveranstaltungDBDML.php @@ -365,7 +365,7 @@ if(!$error) { if($row->summe>$max_stunden) { - if(!$fixangestellt) + if(!$fixangestellt && !$rechte->isBerechtigt('admin')) { if(!LehrauftragAufFirma($lem->mitarbeiter_uid)) { @@ -624,7 +624,7 @@ if(!$error) if($row_std = $db->db_fetch_object($result_std)) { //Grenze ueberschritten - if($row_std->summe>=$max_stunden) + if($row_std->summe>=$max_stunden && !$rechte->isBerechtigt('admin')) { $return = false; $error = true; diff --git a/content/lvplanung/lehrveranstaltungoverlay.xul.php b/content/lvplanung/lehrveranstaltungoverlay.xul.php index cbe9b89ec..f2cc27b2d 100644 --- a/content/lvplanung/lehrveranstaltungoverlay.xul.php +++ b/content/lvplanung/lehrveranstaltungoverlay.xul.php @@ -159,7 +159,7 @@ echo ' -