diff --git a/application/controllers/DBTools.php b/application/controllers/DBTools.php index 6f54fdc13..1330c7ac8 100644 --- a/application/controllers/DBTools.php +++ b/application/controllers/DBTools.php @@ -8,7 +8,7 @@ if (! defined('BASEPATH')) * */ -class DBTools extends FHC_Controller +class DBTools extends Auth_Controller { private $cli = false; /** diff --git a/application/controllers/MailJob.php b/application/controllers/MailJob.php index 70fb754f2..0e86eb425 100644 --- a/application/controllers/MailJob.php +++ b/application/controllers/MailJob.php @@ -14,7 +14,7 @@ if (!defined("BASEPATH")) exit("No direct script access allowed"); -class MailJob extends FHC_Controller +class MailJob extends Auth_Controller { /** * API constructor diff --git a/application/controllers/Redirect.php b/application/controllers/Redirect.php index 6f3d457a8..52eceff6d 100644 --- a/application/controllers/Redirect.php +++ b/application/controllers/Redirect.php @@ -14,7 +14,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); -class Redirect extends CI_Controller +class Redirect extends FHC_Controller { /** * API constructor diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index 1d510d9a3..019c1013e 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -19,7 +19,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); * NOTE: in this controller is not possible to include/call everything * that automatically call the authentication system, like the most of models or libraries */ -class ViewMessage extends CI_Controller +class ViewMessage extends FHC_Controller { /** * API constructor diff --git a/application/controllers/Vilesci.php b/application/controllers/Vilesci.php index e4af6d2b8..d14e60d27 100644 --- a/application/controllers/Vilesci.php +++ b/application/controllers/Vilesci.php @@ -1,7 +1,7 @@ load->library('session'); - // Load permission library - $this->load->library('PermissionLib'); - - $this->load->model('system/Filters_model', 'FiltersModel'); - $this->load->model('person/Benutzer_model', 'BenutzerModel'); + // Loads the FiltersLib with HTTP GET/POST parameters + $this->_loadFiltersLib(); + // Checks if the caller is allow to read this data $this->_isAllowed(); } + //------------------------------------------------------------------------------------------------------------------ + // Public methods + /** - * + * Retrives data about the current filter from the session and will be written on the output in JSON format */ - public function tableDataset() + public function getFilter() { - $json = new stdClass(); - - $session = $this->_readSession($this->input->get('fhc_controller_id')); - - $json->selectedFields = $session['selectedFields']; - $json->columnsAliases = $session['columnsAliases']; - $json->additionalColumns = $session['additionalColumns']; - $json->checkboxes = $session['checkboxes']; - $json->dataset = $session['dataset']; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); + $this->outputJsonSuccess($this->filterslib->getSession()); } /** - * - */ - public function selectFields() - { - $json = new stdClass(); - - $session = $this->_readSession($this->input->get('fhc_controller_id')); - - $json->allSelectedFields = $session['allSelectedFields']; - $json->allColumnsAliases = $session['allColumnsAliases']; - - $json->selectedFields = $session['selectedFields']; - $json->columnsAliases = $session['columnsAliases']; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function sortSelectedFields() - { - $selectedFieldsLst = $this->input->post('selectedFieldsLst'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $json = new stdClass(); - - $session = $this->_readSession($fhc_controller_id); - - $allSelectedFields = $session['allSelectedFields']; - $allColumnsAliases = $session['allColumnsAliases']; - - $json->selectedFields = $session['selectedFields']; - $json->columnsAliases = $session['columnsAliases']; - - if (isset($selectedFieldsLst) && is_array($selectedFieldsLst)) - { - $json->selectedFields = $selectedFieldsLst; - $json->columnsAliases = array(); - - for ($i = 0; $i < count($json->selectedFields); $i++) - { - $pos = array_search($json->selectedFields[$i], $allSelectedFields); - - $json->columnsAliases[$i] = $json->selectedFields[$i]; - - if ($pos !== false) - { - if ($allColumnsAliases != null && is_array($allColumnsAliases)) - { - $json->columnsAliases[$i] = $allColumnsAliases[$pos]; - } - } - } - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['selectedFields'] = $json->selectedFields; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['columnsAliases'] = $json->columnsAliases; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function selectFilters() - { - $json = new stdClass(); - - $session = $this->_readSession($this->input->get('fhc_controller_id')); - - $json->allSelectedFields = $session['allSelectedFields']; - $json->allColumnsAliases = $session['allColumnsAliases']; - - $json->selectedFilters = $session['selectedFilters']; - $json->selectedFiltersAliases = array(); - $json->selectedFiltersMetaData = array(); - - $json->selectedFiltersActiveFilters = array(); - $json->selectedFiltersActiveFiltersOperation = array(); - $json->selectedFiltersActiveFiltersOption = array(); - - $metaData = $session['metaData']; - $activeFilters = $session['activeFilters']; - $activeFiltersOperation = $session['activeFiltersOperation']; - $activeFiltersOption = $session['activeFiltersOption']; - - for ($i = 0; $i < count($json->selectedFilters); $i++) - { - $pos = array_search($json->selectedFilters[$i], $json->allSelectedFields); - - if ($pos !== false) - { - $json->selectedFiltersAliases[$i] = $json->selectedFilters[$i]; - if ($json->allColumnsAliases != null && is_array($json->allColumnsAliases)) - { - $json->selectedFiltersAliases[$i] = $json->allColumnsAliases[$pos]; - } - - $json->selectedFiltersMetaData[] = $metaData[$pos]; - - if (isset($activeFilters[$json->selectedFilters[$i]])) - { - $json->selectedFiltersActiveFilters[] = $activeFilters[$json->selectedFilters[$i]]; - } - - if (isset($activeFiltersOperation[$json->selectedFilters[$i]])) - { - $json->selectedFiltersActiveFiltersOperation[] = $activeFiltersOperation[$json->selectedFilters[$i]]; - } - - if (isset($activeFiltersOption[$json->selectedFilters[$i]])) - { - $json->selectedFiltersActiveFiltersOption[] = $activeFiltersOption[$json->selectedFilters[$i]]; - } - } - } - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function saveFilter() - { - $this->_saveFilter($this->input->post("customFilterDescription"), $this->input->post("fhc_controller_id")); - - $this->output->set_content_type('application/json')->set_output(json_encode('Tutto bene!!!')); - } - - /** - * - */ - private function _saveFilter($customFilterDescription, $fhc_controller_id) - { - $objToBeSaved = new stdClass(); - - $filterSessionArray = $this->_readSession($fhc_controller_id); - - $objToBeSaved->name = $customFilterDescription; - - if (isset($filterSessionArray[self::SELECTED_FIELDS])) - { - $selectedFields = $filterSessionArray[self::SELECTED_FIELDS]; - $objToBeSaved->columns = array(); - - for ($selectedFieldsCounter = 0; $selectedFieldsCounter < count($selectedFields); $selectedFieldsCounter++) - { - $objToBeSaved->columns[$selectedFieldsCounter] = new stdClass(); - $objToBeSaved->columns[$selectedFieldsCounter]->name = $selectedFields[$selectedFieldsCounter]; - } - } - - if (isset($filterSessionArray[self::SELECTED_FILTERS])) - { - $selectedFilters = $filterSessionArray[self::SELECTED_FILTERS]; - $objToBeSaved->filters = array(); - - for ($selectedFiltersCounter = 0; $selectedFiltersCounter < count($selectedFilters); $selectedFiltersCounter++) - { - $objToBeSaved->filters[$selectedFiltersCounter] = new stdClass(); - $objToBeSaved->filters[$selectedFiltersCounter]->name = $selectedFilters[$selectedFiltersCounter]; - - if (isset($filterSessionArray[self::ACTIVE_FILTERS]) - && isset($filterSessionArray[self::ACTIVE_FILTERS][$selectedFilters[$selectedFiltersCounter]])) - { - $objToBeSaved->filters[$selectedFiltersCounter]->condition = $filterSessionArray[self::ACTIVE_FILTERS][$selectedFilters[$selectedFiltersCounter]]; - } - - if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION]) - && isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION][$selectedFilters[$selectedFiltersCounter]])) - { - $objToBeSaved->filters[$selectedFiltersCounter]->operation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION][$selectedFilters[$selectedFiltersCounter]]; - } - - if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION]) - && isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION][$selectedFilters[$selectedFiltersCounter]])) - { - $objToBeSaved->filters[$selectedFiltersCounter]->option = $filterSessionArray[self::ACTIVE_FILTERS_OPTION][$selectedFilters[$selectedFiltersCounter]]; - } - } - } - - $desc = $customFilterDescription; - $descPGArray = '{"'.$desc.'", "'.$desc.'", "'.$desc.'", "'.$desc.'"}'; - - $resultBenutzer = $this->BenutzerModel->load(getAuthUID()); - $personId = $resultBenutzer->retval[0]->person_id; - - $result = $this->FiltersModel->loadWhere(array( - 'app' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['app'], - 'dataset_name' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['datasetName'], - 'description' => $descPGArray, - 'person_id' => $personId - )); - - if (hasData($result)) - { - $this->FiltersModel->update( - array( - 'app' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['app'], - 'dataset_name' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['datasetName'], - 'description' => $descPGArray, - 'person_id' => $personId - ), - array( - 'filter' => json_encode($objToBeSaved) - ) - ); - } - else - { - $this->FiltersModel->insert(array( - 'app' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['app'], - 'dataset_name' => $_SESSION[self::SESSION_NAME][$fhc_controller_id]['datasetName'], - 'filter_kurzbz' => uniqid($personId, true), - 'person_id' => $personId, - 'description' => $descPGArray, - 'sort' => null, - 'default_filter' => false, - 'filter' => json_encode($objToBeSaved), - 'oe_kurzbz' => null - )); - } - } - - /** - * - */ - public function deleteCustomFilter() - { - $filter_id = $this->input->post('filter_id'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - if (is_numeric($filter_id)) - { - $this->FiltersModel->deleteCustomFilter($filter_id); - - $this->output->set_content_type('application/json')->set_output(json_encode('Removed')); - } - } - - /** - * - */ - public function removeSelectedFields() - { - $fieldName = $this->input->post('fieldName'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $session = $this->_readSession($fhc_controller_id); - - $allSelectedFields = $session['allSelectedFields']; - $allColumnsAliases = $session['allColumnsAliases']; - - $selectedFields = $session['selectedFields']; - $columnsAliases = $session['columnsAliases']; - - if (($pos = array_search($fieldName, $selectedFields)) !== false) - { - array_splice($selectedFields, $pos, 1); - - if ($columnsAliases != null && is_array($columnsAliases)) - { - array_splice($columnsAliases, $pos, 1); - } - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['selectedFields'] = $selectedFields; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['columnsAliases'] = $columnsAliases; - - $json = new stdClass(); - - $json->allSelectedFields = $allSelectedFields; - $json->allColumnsAliases = $allColumnsAliases; - $json->selectedFields = $selectedFields; - $json->columnsAliases = $columnsAliases; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function removeSelectedFilters() - { - $fieldName = $this->input->post('fieldName'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $session = $this->_readSession($fhc_controller_id); - - $selectedFilters = $session['selectedFilters']; - $selectedFiltersActiveFilters = $session['activeFilters']; - $selectedFiltersActiveFiltersOperation = $session['activeFiltersOperation']; - $selectedFiltersActiveFiltersOption = $session['activeFiltersOption']; - - if (($pos = array_search($fieldName, $selectedFilters)) !== false) - { - array_splice($selectedFilters, $pos, 1); - array_splice($selectedFiltersActiveFilters, $pos, 1); - array_splice($selectedFiltersActiveFiltersOperation, $pos, 1); - array_splice($selectedFiltersActiveFiltersOption, $pos, 1); - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['selectedFilters'] = $selectedFilters; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFilters'] = $selectedFiltersActiveFilters; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOperation'] = $selectedFiltersActiveFiltersOperation; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOption'] = $selectedFiltersActiveFiltersOption; - - $json = new stdClass(); - - $json->selectedFilters = $selectedFilters; - $json->selectedFiltersActiveFilters = $selectedFiltersActiveFilters; - $json->selectedFiltersActiveFiltersOperation = $selectedFiltersActiveFiltersOperation; - $json->selectedFiltersActiveFiltersOption = $selectedFiltersActiveFiltersOption; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function addSelectedFields() - { - $fieldName = $this->input->post('fieldName'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $session = $this->_readSession($fhc_controller_id); - - $allSelectedFields = $session['allSelectedFields']; - $allColumnsAliases = $session['allColumnsAliases']; - - $selectedFields = $session['selectedFields']; - $columnsAliases = $session['columnsAliases']; - - if (($pos = array_search($fieldName, $allSelectedFields)) !== false - && array_search($fieldName, $selectedFields) === false) - { - array_push($selectedFields, $fieldName); - - if ($columnsAliases != null && is_array($columnsAliases)) - { - array_push($columnsAliases, $allColumnsAliases[$pos]); - } - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['selectedFields'] = $selectedFields; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['columnsAliases'] = $columnsAliases; - - $json = new stdClass(); - - $json->allSelectedFields = $allSelectedFields; - $json->allColumnsAliases = $allColumnsAliases; - $json->selectedFields = $selectedFields; - $json->columnsAliases = $columnsAliases; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function addSelectedFilters() - { - $fieldName = $this->input->post('fieldName'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $session = $this->_readSession($fhc_controller_id); - - $selectedFilters = $session['selectedFilters']; - $selectedFiltersActiveFilters = $session['activeFilters']; - $selectedFiltersActiveFiltersOperation = $session['activeFiltersOperation']; - $selectedFiltersActiveFiltersOption = $session['activeFiltersOption']; - - if (!in_array($fieldName, $selectedFilters)) - { - array_push($selectedFilters, $fieldName); - $selectedFiltersActiveFilters[$fieldName] = ""; - $selectedFiltersActiveFiltersOperation[$fieldName] = ""; - $selectedFiltersActiveFiltersOption[$fieldName] = ""; - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['selectedFilters'] = $selectedFilters; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFilters'] = $selectedFiltersActiveFilters; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOperation'] = $selectedFiltersActiveFiltersOperation; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOption'] = $selectedFiltersActiveFiltersOption; - - $json = new stdClass(); - - $json->selectedFilters = $selectedFilters; - $json->selectedFiltersActiveFilters = $selectedFiltersActiveFilters; - $json->selectedFiltersActiveFiltersOperation = $selectedFiltersActiveFiltersOperation; - $json->selectedFiltersActiveFiltersOption = $selectedFiltersActiveFiltersOption; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * - */ - public function applyFilter() - { - $fieldNames = $this->input->post('filterNames'); - $filterOperations = $this->input->post('filterOperations'); - $filterOperationValues = $this->input->post('filterOperationValues'); - $filterOptions = $this->input->post('filterOptions'); - $fhc_controller_id = $this->input->post('fhc_controller_id'); - - $session = $this->_readSession($fhc_controller_id); - - if ($fieldNames == null) $fieldNames = array(); - if ($filterOperationValues == null) $filterOperationValues = array(); - if ($filterOperations == null) $filterOperations = array(); - if ($filterOptions == null) $filterOptions = array(); - - $activeFilters = array_combine($fieldNames, $filterOperationValues); - $activeFiltersOperation = array_combine($fieldNames, $filterOperations); - $activeFiltersOption = array_combine($fieldNames, $filterOptions); - - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFilters'] = $activeFilters; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOperation'] = $activeFiltersOperation; - $_SESSION[self::SESSION_NAME][$fhc_controller_id]['activeFiltersOption'] = $activeFiltersOption; - - $json = new stdClass(); - - $json->fieldNames = $fieldNames; - $json->activeFilters = $activeFilters; - $json->activeFiltersOperation = $activeFiltersOperation; - $json->activeFiltersOption = $activeFiltersOption; - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); - } - - /** - * + * Retrives the number of records present in the current dataset and will be written on the output in JSON format */ public function rowNumber() { - $json = new stdClass(); + $rowNumber = 0; + $dataset = $this->filterslib->getElementSession(FiltersLib::SESSION_DATASET); - $session = $this->_readSession($this->input->get('fhc_controller_id')); - - $dataset = $session['dataset']; - - if (is_array($dataset)) + if (isset($dataset) && is_array($dataset)) { - $json->rowNumber = count($dataset); + $rowNumber = count($dataset); } - $this->output->set_content_type('application/json')->set_output(json_encode($json)); + $this->outputJsonSuccess($rowNumber); } + /** + * Change the sort of the selected fields of the current filter and + * its data will be written on the output in JSON format + */ + public function sortSelectedFields() + { + $selectedFields = $this->input->post('selectedFields'); + + if ($this->filterslib->sortSelectedFields($selectedFields) == true) + { + $this->getFilter(); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Remove a selected field from the current filter and + * its data will be written on the output in JSON format + */ + public function removeSelectedField() + { + $selectedField = $this->input->post('selectedField'); + + if ($this->filterslib->removeSelectedField($selectedField) == true) + { + $this->getFilter(); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Add a field to the current filter and its data will be written on the output in JSON format + */ + public function addSelectedField() + { + $selectedField = $this->input->post('selectedField'); + + if ($this->filterslib->addSelectedField($selectedField) == true) + { + $this->getFilter(); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Remove an applied filter (SQL where condition) from the current filter + */ + public function removeAppliedFilter() + { + $appliedFilter = $this->input->post('appliedFilter'); + + if ($this->filterslib->removeAppliedFilter($appliedFilter) == true) + { + $this->outputJsonSuccess('Removed'); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Apply all the applied filters (SQL where conditions) to the current filter + */ + public function applyFilters() + { + $appliedFilters = $this->input->post('appliedFilters'); + $appliedFiltersOperations = $this->input->post('appliedFiltersOperations'); + $appliedFiltersConditions = $this->input->post('appliedFiltersConditions'); + $appliedFiltersOptions = $this->input->post('appliedFiltersOptions'); + + if ($this->filterslib->applyFilters( + $appliedFilters, + $appliedFiltersOperations, + $appliedFiltersConditions, + $appliedFiltersOptions + ) == true) + { + $this->outputJsonSuccess('Applied'); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Add a filter (SQL where clause) to be applied to the current filter + */ + public function addFilter() + { + $filter = $this->input->post('filter'); + + if ($this->filterslib->addFilter($filter) == true) + { + $this->getFilter(); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Save the current filter as a custom filter for this user with the given description + */ + public function saveCustomFilter() + { + $customFilterDescription = $this->input->post('customFilterDescription'); + + if ($this->filterslib->saveCustomFilter($customFilterDescription) == true) + { + $this->outputJsonSuccess('Saved'); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + /** + * Remove a custom filter by its filter_id + */ + public function removeCustomFilter() + { + $filter_id = $this->input->post('filter_id'); + + if ($this->filterslib->removeCustomFilter($filter_id) == true) + { + $this->outputJsonSuccess('Removed'); + } + else + { + $this->outputJsonError('Wrong parameter'); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + /** * Checks if the user is allowed to use this filter */ private function _isAllowed() { - $isAllowed = false; - - $session = $this->_readSession($this->input->get('fhc_controller_id')); - - if (isset($session['requiredPermissions'])) + if (!$this->filterslib->isAllowed()) { - $tmpRequiredPermissions = $session['requiredPermissions']; - if (!is_array($tmpRequiredPermissions)) - { - $tmpRequiredPermissions = array($session['requiredPermissions']); - } - - for ($i = 0; $i < count($tmpRequiredPermissions); $i++) - { - $requiredPermissions = array( - 'filters' => $tmpRequiredPermissions[$i].':rw' - ); - - if ($this->permissionlib->isEntitled($requiredPermissions, 'filters')) - { - $isAllowed = true; - break; - } - } - } - - if (!$isAllowed) - { - header('Content-Type: application/json'); - - echo json_encode('You are not allowed to access to this content'); - - exit(1); + $this->_terminateWithJsonError('You are not allowed to access to this content'); } } /** - * + * Loads the FiltersLib with the FILTER_PAGE_PARAM parameter + * If the parameter FILTER_PAGE_PARAM is not given then the execution of the controller is terminated and + * an error message is printed */ - private function _readSession($fhc_controller_id) + private function _loadFiltersLib() { - if (isset($_SESSION[self::SESSION_NAME]) && isset($_SESSION[self::SESSION_NAME][$fhc_controller_id])) - return $_SESSION[self::SESSION_NAME][$fhc_controller_id]; + // If the parameter FILTER_PAGE_PARAM is present in the HTTP GET or POST + if (isset($_GET[self::FILTER_PAGE_PARAM]) || isset($_POST[self::FILTER_PAGE_PARAM])) + { + // If it is present in the HTTP GET + if (isset($_GET[self::FILTER_PAGE_PARAM])) + { + $filterPage = $this->input->get(self::FILTER_PAGE_PARAM); // is retrived from the HTTP GET + } + elseif (isset($_POST[self::FILTER_PAGE_PARAM])) // Else if it is present in the HTTP POST + { + $filterPage = $this->input->post(self::FILTER_PAGE_PARAM); // is retrived from the HTTP POST + } - return array(); + // Loads the FiltersLib that contains all the used logic + $this->load->library('FiltersLib', array(self::FILTER_PAGE_PARAM => $filterPage)); + } + else // Otherwise an error will be written in the output + { + $this->_terminateWithJsonError('Parameter "'.self::FILTER_PAGE_PARAM.'" not provided!'); + } } /** - * + * Terminate the execution of the page after have printed a message encoded to JSON. + * Used directly header and echo to speed up the output before the exit command stops the execution. */ - private function _writeSession($data, $fhc_controller_id) + private function _terminateWithJsonError($message) { - if (!isset($_SESSION[self::SESSION_NAME]) - || (isset($_SESSION[self::SESSION_NAME]) && !is_array($_SESSION[self::SESSION_NAME]))) - { - $_SESSION[self::SESSION_NAME] = array(); - } - - $_SESSION[self::SESSION_NAME][$fhc_controller_id] = $data; + header('Content-Type: application/json'); + echo json_encode(error($message)); + exit; } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index ace825832..fbdd7641b 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -2,7 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class Messages extends FHC_Controller +class Messages extends Auth_Controller { private $uid; // contains the UID of the logged user @@ -29,6 +29,13 @@ class Messages extends FHC_Controller $this->load->model('person/Person_model', 'PersonModel'); + $this->loadPhrases(array( + 'global', + 'person', + 'lehre', + 'ui', + 'infocenter')); + $this->_setAuthUID(); // sets property uid } diff --git a/application/controllers/system/Navigation.php b/application/controllers/system/Navigation.php index 240172f3e..f8a8f6dd2 100644 --- a/application/controllers/system/Navigation.php +++ b/application/controllers/system/Navigation.php @@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * */ -class Navigation extends FHC_Controller +class Navigation extends Auth_Controller { const SESSION_NAME = 'NAVIGATION_MENU'; diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index 1b77d03a9..40c2d09bc 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -2,7 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class Phrases extends FHC_Controller +class Phrases extends Auth_Controller { /** * diff --git a/application/controllers/system/UDF.php b/application/controllers/system/UDF.php index 304ca166b..464f8af9a 100644 --- a/application/controllers/system/UDF.php +++ b/application/controllers/system/UDF.php @@ -2,7 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class UDF extends FHC_Controller +class UDF extends Auth_Controller { public function __construct() { diff --git a/application/controllers/system/Vorlage.php b/application/controllers/system/Vorlage.php index 9e53474df..9bb80d72e 100644 --- a/application/controllers/system/Vorlage.php +++ b/application/controllers/system/Vorlage.php @@ -2,7 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class Vorlage extends FHC_Controller +class Vorlage extends Auth_Controller { public function __construct() { diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php index addde4d6a..6fc51d7dc 100644 --- a/application/controllers/system/aufnahme/PrestudentMultiAssign.php +++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php @@ -2,7 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class PrestudentMultiAssign extends FHC_Controller +class PrestudentMultiAssign extends Auth_Controller { public function __construct() { diff --git a/application/controllers/system/extensions/Manager.php b/application/controllers/system/extensions/Manager.php index 8172e9912..4c88d1b8a 100644 --- a/application/controllers/system/extensions/Manager.php +++ b/application/controllers/system/extensions/Manager.php @@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * */ -class Manager extends FHC_Controller +class Manager extends Auth_Controller { /** * diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d328bdce3..d50d20388 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -6,7 +6,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); * Also shows infocenter-related data for a person and its prestudents, enables document and zgv checks, * displays and saves Notizen for a person, logs infocenter-related actions for a person */ -class InfoCenter extends FHC_Controller +class InfoCenter extends Auth_Controller { // App and Verarbeitungstaetigkeit name for logging const APP = 'infocenter'; @@ -21,12 +21,14 @@ class InfoCenter extends FHC_Controller 'saveformalgep' => array( 'logtype' => 'Action', 'name' => 'Document formally checked', - 'message' => 'Document %s formally checked, set to %s' + 'message' => 'Document %s formally checked, set to %s', + 'success' => null ), 'savezgv' => array( 'logtype' => 'Action', 'name' => 'ZGV saved', - 'message' => 'ZGV saved for degree program %s, prestudentid %s' + 'message' => 'ZGV saved for degree program %s, prestudentid %s', + 'success' => null ), 'abgewiesen' => array( 'logtype' => 'Processstate', @@ -41,12 +43,14 @@ class InfoCenter extends FHC_Controller 'savenotiz' => array( 'logtype' => 'Action', 'name' => 'Note added', - 'message' => 'Note with title %s was added' + 'message' => 'Note with title %s was added', + 'success' => null ), 'updatenotiz' => array( 'logtype' => 'Action', 'name' => 'Note updated', - 'message' => 'Note with title %s was updated' + 'message' => 'Note with title %s was updated', + 'success' => null ) ); private $uid; // contains the UID of the logged user @@ -59,6 +63,7 @@ class InfoCenter extends FHC_Controller parent::__construct( array( 'index' => 'infocenter:r', + 'infocenterFreigegeben' => 'infocenter:r', 'showDetails' => 'infocenter:r', 'unlockPerson' => 'infocenter:rw', 'saveFormalGeprueft' => 'infocenter:rw', @@ -89,13 +94,26 @@ class InfoCenter extends FHC_Controller $this->load->library('PersonLogLib'); $this->load->library('WidgetLib'); + $this->loadPhrases( + array( + 'global', + 'person', + 'lehre', + 'ui', + 'infocenter', + 'filter' + ) + ); + $this->_setAuthUID(); // sets property uid $this->load->library('PermissionLib'); if(!$this->permissionlib->isBerechtigt('basis/person')) show_error('You have no Permission! You need Infocenter Role'); - $this->_setControllerId(); // sets the controller id + $this->setControllerId(); // sets the controller id + + $this->fhc_controller_id = $this->getControllerId(); $this->setNavigationMenuArray(); // sets property navigationMenuArray } @@ -127,46 +145,54 @@ class InfoCenter extends FHC_Controller $personexists = $this->PersonModel->load($person_id); - if(isError($personexists)) + if (isError($personexists)) show_error($personexists->retval); if (empty($personexists->retval)) show_error('person does not exist!'); - //mark person as locked for editing - $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + $show_lock_link_get = $this->input->get('show_lock_link'); + $show_lock_link = !isset($show_lock_link_get) || $show_lock_link_get === '1'; - if(isError($result)) - show_error($result->retval); + if ($show_lock_link) + { + //mark person as locked for editing + $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + + if (isError($result)) + show_error($result->retval); + } $persondata = $this->_loadPersonData($person_id); $prestudentdata = $this->_loadPrestudentData($person_id); - $this->load->view( - 'system/infocenter/infocenterDetails.php', - array_merge( - $persondata, - $prestudentdata - ) + $data = array_merge( + $persondata, + $prestudentdata, + array('show_lock_link' => $show_lock_link) ); + + $data['fhc_controller_id'] = $this->fhc_controller_id; + + $this->load->view('system/infocenter/infocenterDetails.php', $data); } /** - * unlocks page from edit by a person, redirects to overview filter page + * Unlocks page from edit by a person, redirects to overview filter page * @param $person_id */ public function unlockPerson($person_id) { $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); - if(isError($result)) + if (isError($result)) show_error($result->retval); - redirect(self::URL_PREFIX); + redirect(self::URL_PREFIX.'?fhc_controller_id='.$this->fhc_controller_id); } /** - * Saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not. + * Saves if a document has been formal geprueft. Saves current timestamp if checked as geprueft, or null if not. * @param $person_id */ public function saveFormalGeprueft($person_id) @@ -174,37 +200,36 @@ class InfoCenter extends FHC_Controller $akte_id = $this->input->post('akte_id'); $formalgeprueft = $this->input->post('formal_geprueft'); - if (!isset($akte_id) || !isset($formalgeprueft) || !isset($person_id)) - show_error('Parameters not set!'); + $json = false; - $akte = $this->AkteModel->load($akte_id); - - if (isError($akte)) + if (isset($akte_id) && isset($formalgeprueft) && isset($person_id)) { - show_error($akte->retval); + $akte = $this->AkteModel->load($akte_id); + + if (hasData($akte)) + { + $timestamp = ($formalgeprueft === 'true') ? date('Y-m-d H:i:s') : null; + $result = $this->AkteModel->update($akte_id, array('formal_geprueft_amum' => $timestamp)); + + if (isSuccess($result)) + { + $json = $timestamp; + + $this->_log( + $person_id, + 'saveformalgep', + array( + empty($akte->retval[0]->titel) ? $akte->retval[0]->bezeichnung : $akte->retval[0]->titel, + is_null($timestamp) ? 'NULL' : $timestamp + ) + ); + } + } } - $timestamp = ($formalgeprueft === 'true') ? date('Y-m-d H:i:s') : null; - $result = $this->AkteModel->update($akte_id, array('formal_geprueft_amum' => $timestamp)); - - if (isError($result)) - { - show_error($result->retval); - } - - //write person log - $this->_log( - $person_id, - 'saveformalgep', - array( - empty($akte->retval[0]->titel) ? $akte->retval[0]->bezeichnung : $akte->retval[0]->titel, - is_null($timestamp) ? 'NULL' : $timestamp - ) - ); - $this->output ->set_content_type('application/json') - ->set_output(json_encode($timestamp)); + ->set_output(json_encode($json)); } /** @@ -215,20 +240,13 @@ class InfoCenter extends FHC_Controller { $prestudent = $this->PrestudentModel->getLastPrestudent($person_id, true); - if (isError($prestudent)) - { - show_error($prestudent->retval); - } - - $jsonoutput = count($prestudent->retval) > 0 ? $prestudent->retval[0] : null; - $this->output ->set_content_type('application/json') - ->set_output(json_encode($jsonoutput)); + ->set_output(json_encode($prestudent)); } /** - * Gets Zugangsvoraussetzungen for a prestudents as a description text + * Gets Zugangsvoraussetzungen for a prestudent as a description text and shows them in a view * @param $prestudent_id */ public function getZgvInfoForPrestudent($prestudent_id) @@ -239,67 +257,73 @@ class InfoCenter extends FHC_Controller $studiengangkurzbz = $prestudentdata['studiengang_kurzbz']; $studiengangbezeichnung = $prestudentdata['studiengang_bezeichnung']; - $data = array('studiengang_bezeichnung' => $studiengangbezeichnung, 'studiengang_kurzbz' => $studiengangkurzbz, 'data' => null); + $data = array( + 'studiengang_bezeichnung' => $studiengangbezeichnung, + 'studiengang_kurzbz' => $studiengangkurzbz, + 'data' => null + ); if (hasData($studienordnung)) { $data['data'] = $studienordnung->retval[0]->data; } - $this->load->view('system/infocenter/studiengangZgvInfo.php', - $data - ); + $this->load->view('system/infocenter/studiengangZgvInfo.php', $data); } /** - * Saves a zgv for a prestudent. includes Ort, Datum, Nation for bachelor and master. + * Saves a ZGV for a prestudent, includes Ort, Datum, Nation for bachelor and master * @param $prestudent_id */ - public function saveZgvPruefung($prestudent_id) + public function saveZgvPruefung() { - // zgvdata - // Check for string null, in case dropdown changed to default value - $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv'); - $zgvort = $this->input->post('zgvort'); - $zgvdatum = $this->input->post('zgvdatum'); - $zgvdatum = empty($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); - $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); + $prestudent_id = $this->input->post('prestudentid'); - //zgvmasterdata - $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); - $zgvmaort = $this->input->post('zgvmaort'); - $zgvmadatum = $this->input->post('zgvmadatum'); - $zgvmadatum = empty($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); - $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); - - $result = $this->PrestudentModel->update( - $prestudent_id, - array( - 'zgv_code' => $zgv_code, - 'zgvort' => $zgvort, - 'zgvdatum' => $zgvdatum, - 'zgvnation' => $zgvnation_code, - 'zgvmas_code' => $zgvmas_code, - 'zgvmaort' => $zgvmaort, - 'zgvmadatum' => $zgvmadatum, - 'zgvmanation' => $zgvmanation_code, - 'updateamum' => date('Y-m-d H:i:s') - ) - ); - - if (isError($result)) + if (empty($prestudent_id)) + $result = error('Prestudentid missing'); + else { - show_error($result->retval); + // zgvdata + // Check for string null, in case dropdown changed to default value + $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv'); + $zgvort = $this->input->post('zgvort'); + $zgvdatum = $this->input->post('zgvdatum'); + $zgvdatum = empty($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); + $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); + + //zgvmasterdata + $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); + $zgvmaort = $this->input->post('zgvmaort'); + $zgvmadatum = $this->input->post('zgvmadatum'); + $zgvmadatum = empty($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); + $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); + + $result = $this->PrestudentModel->update( + $prestudent_id, + array( + 'zgv_code' => $zgv_code, + 'zgvort' => $zgvort, + 'zgvdatum' => $zgvdatum, + 'zgvnation' => $zgvnation_code, + 'zgvmas_code' => $zgvmas_code, + 'zgvmaort' => $zgvmaort, + 'zgvmadatum' => $zgvmadatum, + 'zgvmanation' => $zgvmanation_code, + 'updateamum' => date('Y-m-d H:i:s') + ) + ); + + if (isSuccess($result)) + { + //get extended Prestudent data for logging + $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id)); + } } - - //get extended Prestudent data for logging - $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); - - $this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id)); - $this->output ->set_content_type('application/json') - ->set_output(json_encode($result->retval)); + ->set_output(json_encode($result)); } /** @@ -310,6 +334,7 @@ class InfoCenter extends FHC_Controller public function saveAbsage($prestudent_id) { $statusgrund = $this->input->post('statusgrund'); + $this->fhc_controller_id = $this->input->post('fhc_controller_id'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); @@ -420,7 +445,8 @@ class InfoCenter extends FHC_Controller $result = $this->DokumentprestudentModel->setAcceptedDocuments($prestudent_id, $dokument_kurzbzs); - if (isError($result)) + //returns null if no documents to accept + if ($result !== null && isError($result)) { show_error($result->retval); } @@ -446,16 +472,14 @@ class InfoCenter extends FHC_Controller $result = $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->uid); - if (isError($result)) + if (isSuccess($result)) { - show_error($result->retval); + $this->_log($person_id, 'savenotiz', array($titel)); } - $this->_log($person_id, 'savenotiz', array($titel)); - $this->output ->set_content_type('application/json') - ->set_output(json_encode($result->retval)); + ->set_output(json_encode($result)); } /** @@ -480,20 +504,15 @@ class InfoCenter extends FHC_Controller ) ); - - $json = FALSE; - if (isSuccess($result)) { - $json = TRUE; - //set log "Notiz updated" $this->_log($person_id, 'updatenotiz', array($titel)); } $this->output ->set_content_type('application/json') - ->set_output(json_encode($json)); + ->set_output(json_encode($result)); } /** @@ -550,6 +569,69 @@ class InfoCenter extends FHC_Controller ->_display(); } + /** + * Gets the date until which a person is parked + * @param $person_id + */ + public function getParkedDate($person_id) + { + $result = $this->personloglib->getParkedDate($person_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($result)); + } + + /** + * Initializes parking of a person, i.e. a person is not expected to do any actions while parked + */ + public function park() + { + $person_id = $this->input->post('person_id'); + $date = $this->input->post('parkdate'); + + $result = $this->personloglib->park($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->uid); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($result)); + } + + /** + * Removes parking of a person + */ + public function unPark() + { + $person_id = $this->input->post('person_id'); + + $result = $this->personloglib->unPark($person_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($result)); + } + + /** + * Gets the End date of the current Studienjahr + */ + public function getStudienjahrEnd() + { + $this->load->model('organisation/studienjahr_model', 'StudienjahrModel'); + + $result = $this->StudienjahrModel->getCurrStudienjahr(); + + $json = false; + + if (hasData($result)) + { + $json = $result->retval[0]->ende; + } + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($json)); + } + // ----------------------------------------------------------------------------------------------------------------- // Private methods @@ -607,13 +689,13 @@ class InfoCenter extends FHC_Controller $filtersarray = array( 'abgeschickt' => array( 'link' => '#', - 'description' => 'Abgeschickt', + 'description' => ucfirst($this->p->t('global', 'abgeschickt')), 'expand' => true, 'children' => array() ), 'nichtabgeschickt' => array( 'link' => '#', - 'description' => 'Nicht abgeschickt', + 'description' => ucfirst($this->p->t('global', 'nichtAbgeschickt')), 'expand' => true, 'children' => array() ) @@ -660,14 +742,26 @@ class InfoCenter extends FHC_Controller ); } + /** + * Wrapper for setNavigationMenu, returns JSON message + */ + public function setNavigationMenuArrayJson() + { + $this->setNavigationMenuArray(); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(success('success'))); + } + private function _fillFilters($filters, &$tofill) { foreach ($filters as $filterId => $description) { - $toPrint = "%s?%s=%s&%s=%s"; + $toPrint = "%s?%s=%s"; $tofill['children'][] = array( - 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId, 'fhc_controller_id', $this->fhc_controller_id), + 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId), 'description' => $description ); } @@ -677,13 +771,13 @@ class InfoCenter extends FHC_Controller { foreach ($filters as $filterId => $description) { - $toPrint = "%s?%s=%s&%s=%s"; + $toPrint = "%s?%s=%s"; $tofill['children'][] = array( - 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId, 'fhc_controller_id', $this->fhc_controller_id), + 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId), 'description' => $description, 'subscriptDescription' => 'Remove', - 'subscriptLinkClass' => 'remove-filter', + 'subscriptLinkClass' => 'remove-custom-filter', 'subscriptLinkValue' => $filterId ); } @@ -769,7 +863,7 @@ class InfoCenter extends FHC_Controller show_error($user_person->retval); } - $messagelink = base_url('/index.ci.php/system/Messages/write/'.$user_person->retval[0]->person_id); + $messagelink = site_url('/system/Messages/write/'.$user_person->retval[0]->person_id); $data = array ( 'lockedby' => $lockedby, @@ -871,7 +965,7 @@ class InfoCenter extends FHC_Controller $this->PrestudentModel->addSelect('person_id'); $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; - redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#'.$section); + redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'?fhc_controller_id='.$this->fhc_controller_id.'#'.$section); } /** @@ -905,15 +999,20 @@ class InfoCenter extends FHC_Controller { $logdata = $this->logparams[$logname]; + $datatolog = array( + 'name' => $logdata['name'] + ); + + if (isset($logdata['message'])) + $datatolog['message'] = vsprintf($logdata['message'], $messageparams); + + if (array_key_exists('success', $logdata)) + $datatolog['success'] = true; + $this->personloglib->log( $person_id, $logdata['logtype'], - array( - 'name' => $logdata['name'], - 'message' => vsprintf($logdata['message'], - $messageparams), - 'success' => 'true' - ), + $datatolog, self::TAETIGKEIT, self::APP, null, @@ -1019,7 +1118,7 @@ class InfoCenter extends FHC_Controller if (!empty($receiver)) { //Freigabeinformationmail sent from default system mail to studiengang mail(s) - $sent = $this->maillib->send('', $receiver, $subject, $email); + $sent = $this->maillib->send('', $receiver, $subject, $email, '', null, null, 'Bitte sehen Sie sich die Nachricht in HTML Sicht an, um den Inhalt vollständig darzustellen.'); if (!$sent) $this->loglib->logError('Error when sending Freigabe mail'); @@ -1029,21 +1128,4 @@ class InfoCenter extends FHC_Controller $this->loglib->logError('Studiengang has no mail for sending Freigabe mail'); } } - - /** - * Sets the unique id for the called controller - */ - private function _setControllerId() - { - $fhc_controller_id = $this->input->get('fhc_controller_id'); - - if (!isset($fhc_controller_id) || empty($fhc_controller_id)) - { - $fhc_controller_id = uniqid(); - header('Location: '.$_SERVER['REQUEST_URI'].'?fhc_controller_id='.$fhc_controller_id); - exit; - } - - $this->fhc_controller_id = $fhc_controller_id; - } } diff --git a/application/core/Auth_Controller.php b/application/core/Auth_Controller.php new file mode 100644 index 000000000..fe661f1e3 --- /dev/null +++ b/application/core/Auth_Controller.php @@ -0,0 +1,38 @@ +load->helper('fhcauth'); + + // Checks if the caller is allowed to access to this content + $this->_isAllowed($requiredPermissions); + } + + /** + * Checks if the caller is allowed to access to this content with the given permissions + * If it is not allowed will set the HTTP header with code 401 + * Wrapper for _checkPermissions + */ + private function _isAllowed($requiredPermissions) + { + // Loads permission lib + $this->load->library('PermissionLib'); + + if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) + { + header('HTTP/1.0 401 Unauthorized'); + echo 'You are not allowed to access to this content'; + exit; + } + } +} diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 52265e6ab..dafa70e81 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -4,45 +4,101 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class FHC_Controller extends CI_Controller { + const FHC_CONTROLLER_ID = 'fhc_controller_id'; // name of the parameter used to identify uniquely a call to a controller + + private $_controllerId; // contains the unique identifier of a call to a controller + /** - * Standard construct for all the controllers, loads the authentication system - * Checks the caller permissions + * Standard construct for all the controllers */ - public function __construct($requiredPermissions) + public function __construct() { parent::__construct(); - // Loads authentication helper - $this->load->helper('fhcauth'); - - // Loads permission lib - $this->load->library('PermissionLib'); - - $this->_isAllowed($requiredPermissions); + // Set _controllerId as null by default + $this->_controllerId = null; } - /** - * Checks if the caller is allowed to access to this content with the given permissions - * If it is not allowed will set the HTTP header with code 401 - * Wrapper for _checkPermissions - */ - private function _isAllowed($requiredPermissions) - { - if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) - { - header('HTTP/1.0 401 Unauthorized'); - echo 'You are not allowed to access to this content'; - exit; - } - } + //------------------------------------------------------------------------------------------------------------------ + // Public methods /** * Wrapper to load phrases using the PhrasesLib * NOTE: The library is loaded with the alias 'p', so must me used with this alias in the rest of the code. * EX: $this->p->t(, ) */ - public function loadPhrases($categories, $language = null) + protected function loadPhrases($categories, $language = null) { $this->load->library('PhrasesLib', array($categories, $language), 'p'); } + + //------------------------------------------------------------------------------------------------------------------ + // Protected methods + + /** + * Sets the unique id for the called controller + * NOTE: it is only working with HTTP GET request, not neeaded with POST + * because the first call to the controller is via HTTP GET, + * therefore a fhc_controller_id is already generated + */ + protected function setControllerId() + { + if ($_SERVER['REQUEST_METHOD'] === 'GET') + { + $this->_controllerId = $this->input->get(self::FHC_CONTROLLER_ID); + + if (!isset($this->_controllerId) || empty($this->_controllerId)) + { + $this->_controllerId = uniqid(); // generate a unique id + // Redirect to the same URL, but giving FHC_CONTROLLER_ID as HTTP GET parameter + header( + sprintf( + 'Location: %s%s%s=%s', + $_SERVER['REQUEST_URI'], + strpos($_SERVER['REQUEST_URI'], '?') === false ? '?' : '&', // place the corret character to divide parameters + self::FHC_CONTROLLER_ID, + $this->_controllerId + ) + ); + exit; // terminate immediately the execution of this controller + } + } + } + + /** + * Return the value of the property _controllerId + */ + protected function getControllerId() + { + return $this->_controllerId; + } + + /** + * Utility method to output a success using JSON as content type + * Wraps the private method _outputJson + */ + protected function outputJsonSuccess($mixed) + { + $this->_outputJson(success($mixed)); + } + + /** + * Utility method to output an error using JSON as content type + * Wraps the private method _outputJson + */ + protected function outputJsonError($mixed) + { + $this->_outputJson(error($mixed)); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Utility method to output using JSON as content type + */ + private function _outputJson($mixed) + { + $this->output->set_content_type('application/json')->set_output(json_encode($mixed)); + } } diff --git a/application/libraries/DocumentLib.php b/application/libraries/DocumentLib.php index 204b1d30f..ed87a9f38 100644 --- a/application/libraries/DocumentLib.php +++ b/application/libraries/DocumentLib.php @@ -57,8 +57,19 @@ class DocumentLib case 'application/vnd.ms-word': case 'application/vnd.oasis.opendocument.text': case 'text/plain': - $this->convert($filename, $outFile, 'pdf'); - return success($outFile); + // Unoconv Version 0.6 seems to fail on converting TXT Files + if ($this->unoconv_version == '0.6') + return error(); + + $ret = $this->convert($filename, $outFile, 'pdf'); + if(isSuccess($ret)) + { + return success($outFile); + } + else + { + return error($ret->retval); + } case 'application/pdf': return success($filename); default: diff --git a/application/libraries/FiltersLib.php b/application/libraries/FiltersLib.php new file mode 100644 index 000000000..188261f45 --- /dev/null +++ b/application/libraries/FiltersLib.php @@ -0,0 +1,864 @@ +_ci =& get_instance(); + + // Loads helper message to manage returning messages + $this->_ci->load->helper('message'); + + $this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * 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 FilterWidget. + * If the parameter requiredPermissions is NOT given, then no one is allow to use this FilterWidget + */ + public function isAllowed($requiredPermissions = null) + { + $this->_ci->load->library('PermissionLib'); // Load permission library + + $isAllowed = false; // by default is not allowed + + // Gets the required permissions from the session if they are not provided as parameter + $rq = $requiredPermissions; + if ($rq == null) $rq = $this->getElementSession(self::REQUIRED_PERMISSIONS_PARAMETER); + + // If the parameter requiredPermissions is NOT given, then no one is allow to use this FilterWidget + if ($rq != null) + { + // If requiredPermissions is NOT an array then converts it to an array + if (!is_array($rq)) + { + $rq = array($rq); + } + + // Checks if at least one of the permissions given as parameter belongs to the authenticated user... + for ($p = 0; $p < count($rq); $p++) + { + $isAllowed = $this->_ci->permissionlib->isEntitled( + array( + self::PERMISSION_FILTER_METHOD => $rq[$p].':'.self::PERMISSION_TYPE + ), + self::PERMISSION_FILTER_METHOD + ); + + if ($isAllowed) break; // ...if confirmed then is allowed to use this FilterWidget + } + } + + return $isAllowed; + } + + /** + * Returns the whole session for this filter widget if found, otherwise null + */ + public function getSession() + { + $session = null; + + // If it is present a session for this filter + if (isset($_SESSION[self::SESSION_NAME]) && isset($_SESSION[self::SESSION_NAME][$this->_filterUniqueId])) + { + $session = $_SESSION[self::SESSION_NAME][$this->_filterUniqueId]; + } + + return $session; + } + + /** + * Returns one element from the session of this filter widget, otherwise null + */ + public function getElementSession($name) + { + $session = $this->getSession(); // get the whole session for this filter + + if (isset($session[$name])) + { + return $session[$name]; + } + + return null; + } + + /** + * Sets the whole session for this filter widget + */ + public function setSession($data) + { + // If is NOT already present into the session + if (!isset($_SESSION[self::SESSION_NAME]) + || (isset($_SESSION[self::SESSION_NAME]) && !is_array($_SESSION[self::SESSION_NAME]))) + { + $_SESSION[self::SESSION_NAME] = array(); // then create it + } + + $_SESSION[self::SESSION_NAME][$this->_filterUniqueId] = $data; // stores data + } + + /** + * Sets one element of the session of this filter widget + */ + public function setElementSession($name, $value) + { + // If is NOT already present into the session + if (!isset($_SESSION[self::SESSION_NAME]) + || (isset($_SESSION[self::SESSION_NAME]) && !is_array($_SESSION[self::SESSION_NAME]))) + { + $_SESSION[self::SESSION_NAME] = array(); // then create it + } + + // If the session for this filter is NOT already present into the session + if (!isset($_SESSION[self::SESSION_NAME][$this->_filterUniqueId]) + || (isset($_SESSION[self::SESSION_NAME][$this->_filterUniqueId]) + && !is_array($_SESSION[self::SESSION_NAME][$this->_filterUniqueId]))) + { + $_SESSION[self::SESSION_NAME][$this->_filterUniqueId] = array(); // then create it + } + + $_SESSION[self::SESSION_NAME][$this->_filterUniqueId][$name] = $value; // stores the single value + } + + /** + * Loads the definition data from DB for a filter widget + */ + public function loadDefinition($filterId, $app, $datasetName, $filterKurzbz) + { + // Loads the needed models + $this->_ci->load->model('system/Filters_model', 'FiltersModel'); + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); // to get the default custom filter + + $this->_ci->FiltersModel->resetQuery(); // reset any previous built query + + $this->_ci->FiltersModel->addJoin('public.tbl_benutzer', 'person_id', 'LEFT'); // left join with benutzer table + $this->_ci->FiltersModel->addSelect('system.tbl_filters.*'); // select only from table filters + $this->_ci->FiltersModel->addOrder('sort', 'ASC'); // sort on column sort + $this->_ci->FiltersModel->addLimit(1); // if more than one filter is set as default only one will be retrived + + $definition = null; + $whereParameters = null; // where clause parameters + + // If we have a good filterId then use it! + if ($filterId != null && is_numeric($filterId) && $filterId > 0) + { + $whereParameters = array( + 'filter_id' => $filterId + ); + } + else + { + // If we can univocally retrive a filter + if ($app != null && $datasetName != null && $filterKurzbz != null) + { + $whereParameters = array( + 'app' => $app, + 'dataset_name' => $datasetName, + 'filter_kurzbz' => $filterKurzbz + ); + } + // Else if we have only app and datasetName + elseif ($app != null && $datasetName != null && $filterKurzbz == null) + { + // Try to load the custom filter (person_id = logged user person_id) with the given "app" and "dataset_name" + // that is set as default filter (default_filter = true) + $whereParameters = array( + 'app' => $app, + 'dataset_name' => $datasetName, + 'uid' => getAuthUID(), + 'default_filter' => true + ); + + $definition = $this->_ci->FiltersModel->loadWhere($whereParameters); + if (!hasData($definition)) // If a custom filter is NOT found + { + // Try to load the global filter (person_id = null) with the given "app" and "dataset_name" that is set as + // default filter (default_filter = true) + $whereParameters = array( + 'app' => $app, + 'dataset_name' => $datasetName, + 'default_filter' => true + ); + + $definition = $this->_ci->FiltersModel->loadWhere($whereParameters); + } + } + } + + // If no definition where loaded and where parameters were set + if ($definition == null && $whereParameters != null) + { + $definition = $this->_ci->FiltersModel->loadWhere($whereParameters); + } + + return $definition; + } + + /** + * Checks if the json definition of this filter is valid + */ + public function parseFilterJson($definition) + { + $jsonEncodedFilter = null; + + // If the definition contains data and they are valid + if (hasData($definition) && isset($definition->retval[0]->filter) && trim($definition->retval[0]->filter) != '') + { + // Get the json definition of the filter + $tmpJsonEncodedFilter = json_decode($definition->retval[0]->filter); + + // Checks required filter's properies + if (isset($tmpJsonEncodedFilter->name) + && isset($tmpJsonEncodedFilter->columns) + && is_array($tmpJsonEncodedFilter->columns) + && isset($tmpJsonEncodedFilter->filters) + && is_array($tmpJsonEncodedFilter->filters)) + { + $jsonEncodedFilter = $tmpJsonEncodedFilter; + } + } + + return $jsonEncodedFilter; + } + + /** + * Generate the query to retrive the dataset for a filter + */ + public function generateDatasetQuery($query, $filters) + { + $datasetQuery = null; + + // If the given query is valid and the parameter filters is an array + if (!empty(trim($query)) && $filters != null && is_array($filters)) + { + $where = ''; // starts building the SQL where clause + + // Loops through the given applied filters + for ($filtersCounter = 0; $filtersCounter < count($filters); $filtersCounter++) + { + $filterDefinition = $filters[$filtersCounter]; // definition of one filter + + if ($filtersCounter > 0) $where .= ' AND '; // if it's NOT the last one + + if (!empty(trim($filterDefinition->name))) // if the name of the applied filter is valid + { + // ...build the condition + $where .= '"'.$filterDefinition->name.'"'.$this->_getDatasetQueryCondition($filterDefinition); + } + } + + if ($where != '') // if the SQL where clause was built + { + $datasetQuery = 'SELECT * FROM ('.$query.') '.self::DATASET_TABLE_ALIAS.' WHERE '.$where; + } + } + + return $datasetQuery; + } + + /** + * Retrives the dataset from the DB + */ + public function getDataset($datasetQuery) + { + $dataset = null; + + if ($datasetQuery != null) + { + // Execute the given SQL statement suppressing error messages + $dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery); + } + + return $dataset; + } + + /** + * Get the filter name, the default is the "name" property of the JSON definition + * If the property namePhrase is present into the JSON definition, then try to load that from the phrases system + * NOTE: filterJson should be already checked using the method parseFilterJson + */ + public function getFilterName($filterJson) + { + $filterName = $filterJson->name; // always present, used as default + + // Filter name from phrases system + if (isset($filterJson->namePhrase) && !empty(trim($filterJson->namePhrase))) + { + // Loads the library to use the phrases system + $this->_ci->load->library('PhrasesLib', array(self::FILTER_PHRASES_CATEGORY)); + + $tmpFilterNamePhrase = $this->_ci->phraseslib->t(self::FILTER_PHRASES_CATEGORY, $filterJson->namePhrase); + if (isset($tmpFilterNamePhrase) && !empty(trim($tmpFilterNamePhrase))) // if is not null or an empty string + { + $filterName = $tmpFilterNamePhrase; + } + } + + return $filterName; + } + + /** + * Change the sort of the selected fields of the current filter + */ + public function sortSelectedFields($selectedFields) + { + $sortSelectedFields = false; + + // Checks the parameter selectedFields + if (isset($selectedFields) && is_array($selectedFields) && count($selectedFields) > 0) + { + // Retrives all the used fields by the current filter + $fields = $this->getElementSession(self::SESSION_FIELDS); + + // Checks that the given selected fields are present in all the used fields by the current filter + if (!array_diff($selectedFields, $fields)) + { + $this->setElementSession(self::SESSION_SELECTED_FIELDS, $selectedFields); // write changes into the session + + $sortSelectedFields = true; + } + } + + return $sortSelectedFields; + } + + /** + * Remove a selected field from the current filter + */ + public function removeSelectedField($selectedField) + { + $removeSelectedField = false; + + // Checks the parameter selectedField + if (isset($selectedField) && !empty(trim($selectedField))) + { + // Retrives all the used fields by the current filter + $fields = $this->getElementSession(self::SESSION_FIELDS); + // Retrives the selected fields by the current filter + $selectedFields = $this->getElementSession(self::SESSION_SELECTED_FIELDS); + + // Checks that the given selected field is present in the list of all the used fields by the current filter + if (in_array($selectedField, $fields)) + { + // If the selected field is present in the list of the selected fields by the current filter + if (($pos = array_search($selectedField, $selectedFields)) !== false) + { + // Then remove it and shift the rest of elements by one if needed + array_splice($selectedFields, $pos, 1); + } + + $this->setElementSession(self::SESSION_SELECTED_FIELDS, $selectedFields); // write changes into the session + + $removeSelectedField = true; + } + } + + return $removeSelectedField; + } + + /** + * Add a field to the current filter + */ + public function addSelectedField($selectedField) + { + $removeSelectedField = false; + + // Checks the parameter selectedField + if (isset($selectedField) && !empty(trim($selectedField))) + { + // Retrives all the used fields by the current filter + $fields = $this->getElementSession(self::SESSION_FIELDS); + // Retrives the selected fields by the current filter + $selectedFields = $this->getElementSession(self::SESSION_SELECTED_FIELDS); + + // Checks that the given selected field is present in the list of all the used fields by the current filter + if (in_array($selectedField, $fields)) + { + array_push($selectedFields, $selectedField); // place the new filed at the end of the selected fields list + + $this->setElementSession(self::SESSION_SELECTED_FIELDS, $selectedFields); // write changes into the session + + $removeSelectedField = true; + } + } + + return $removeSelectedField; + } + + /** + * Remove an applied filter (SQL where condition) from the current filter + */ + public function removeAppliedFilter($appliedFilter) + { + $removeAppliedFilter = false; + + // Checks the parameter appliedFilter + if (isset($appliedFilter) && !empty(trim($appliedFilter))) + { + // Retrives all the used fields by the current filter + $fields = $this->getElementSession(self::SESSION_FIELDS); + // Retrives the applied filters by the current filter + $filters = $this->getElementSession(self::SESSION_FILTERS); + + // Checks that the given applied filter is present in the list of all the used fields by the current filter + if (in_array($appliedFilter, $fields)) + { + // Search in what position the given applied filter is + $pos = $this->_searchFilterByName($filters, $appliedFilter); + if ($pos !== false) // If found + { + array_splice($filters, $pos, 1); // Then remove it and shift the rest of elements by one if needed + } + + // Write changes into the session + $this->setElementSession(self::SESSION_FILTERS, $filters); + $this->setElementSession(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + + $removeAppliedFilter = true; + } + } + + return $removeAppliedFilter; + } + + /** + * Apply all the applied filters (SQL where conditions) to the current filter + */ + public function applyFilters($appliedFilters, $appliedFiltersOperations, $appliedFiltersConditions, $appliedFiltersOptions) + { + $applyFilters = false; + + // Checks the required parameters: appliedFilters and appliedFiltersOperations + if (isset($appliedFilters) && is_array($appliedFilters) + && isset($appliedFiltersOperations) && is_array($appliedFiltersOperations)) + { + $fields = $this->getElementSession(self::SESSION_FIELDS); // Retrives all the used fields by the current filter + + // Checks that the given applied filters are present in all the used fields by the current filter + if (!array_diff($appliedFilters, $fields)) + { + $filters = array(); // starts building the new applied filters list + for ($i = 0; $i < count($appliedFilters); $i++) // loops through the given applied filters + { + $filterDefinition = new stdClass(); // new applied filter definition + + // Sets the filter definition required properties + $filterDefinition->name = $appliedFilters[$i]; + $filterDefinition->operation = $appliedFiltersOperations[$i]; + + // Sets the filter definition optional properties + $filterDefinition->condition = null; + if (isset($appliedFiltersConditions) && isset($appliedFiltersConditions[$i])) + { + $filterDefinition->condition = $appliedFiltersConditions[$i]; + } + + $filterDefinition->option = null; + if (isset($appliedFiltersOptions) && isset($appliedFiltersOptions[$i])) + { + $filterDefinition->option = $appliedFiltersOptions[$i]; + } + + $filters[$i] = $filterDefinition; // adds the new definition to the list + } + + // Write changes into the session + $this->setElementSession(self::SESSION_FILTERS, $filters); + $this->setElementSession(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + + $applyFilters = true; + } + } + + return $applyFilters; + } + + /** + * Add a filter (SQL where clause) to be applied to the current filter + */ + public function addFilter($filter) + { + $addFilter = false; + + // Checks the parameter filter + if (isset($filter) && !empty(trim($filter))) + { + // Retrives all the used fields by the current filter + $fields = $this->getElementSession(self::SESSION_FIELDS); + // Retrives the applied filters by the current filter + $filters = $this->getElementSession(self::SESSION_FILTERS); + + // Checks that the given applied filter is present in the list of all the used fields by the current filter + if (in_array($filter, $fields)) + { + // Search in what position the given applied filter is + $pos = $this->_searchFilterByName($filters, $filter); + if ($pos === false) // If NOT found then add it + { + // New filter definition + $filterDefinition = new stdClass(); + // Sets filter definition required properties + $filterDefinition->name = $filter; + // Sets filter definition optional properties + $filterDefinition->operation = null; + $filterDefinition->condition = null; + $filterDefinition->option = null; + // Place the new applied filter at the end of the applied filters list + array_push($filters, $filterDefinition); + } + + $this->setElementSession(self::SESSION_FILTERS, $filters); // write changes into the session + + $addFilter = true; + } + } + + return $addFilter; + } + + /** + * Save the current filter as a custom filter for this user with the given description + */ + public function saveCustomFilter($customFilterDescription) + { + $saveCustomFilter = false; // by default returns a failure + + // Checks parameter customFilterDescription if not valid stop the execution + if (!isset($customFilterDescription) || empty(trim($customFilterDescription))) + { + return $saveCustomFilter; + } + + $this->_ci->load->model('system/Filters_model', 'FiltersModel'); // to load the filter definitions + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); // to get the person_id of the authenticated user + + $this->_ci->FiltersModel->resetQuery(); // reset any previous built query + $this->_ci->BenutzerModel->resetQuery(); // reset any previous built query + + // Loads data for the authenticated user + $authBenutzer = $this->_ci->BenutzerModel->loadWhere(array('uid' => getAuthUID())); + if (hasData($authBenutzer)) // if data are found + { + // person_id of the authenticated user + $authPersonId = $authBenutzer->retval[0]->person_id; + // Postgres array for the description + $descPGArray = str_replace('%desc%', $customFilterDescription, '{"%desc%", "%desc%", "%desc%", "%desc%"}'); + + // Loads the definition to check if is already present in the DB + $definition = $this->_ci->FiltersModel->loadWhere(array( + 'app' => $this->getElementSession(self::APP_PARAMETER), + 'dataset_name' => $this->getElementSession(self::DATASET_NAME_PARAMETER), + 'description' => $descPGArray, + 'person_id' => $authPersonId + )); + + // New definition to be json encoded + $jsonDeifinition = new stdClass(); + $jsonDeifinition->name = $customFilterDescription; // name of the filter + + // Generates the "column" property + $jsonDeifinition->columns = array(); + $selectedFields = $this->getElementSession(self::SESSION_SELECTED_FIELDS); // retrived the selected fields + for ($i = 0; $i < count($selectedFields); $i++) + { + // Each element is an object with a property called "name" + $jsonDeifinition->columns[$i] = new stdClass(); + $jsonDeifinition->columns[$i]->name = $selectedFields[$i]; + } + + // List of applied filters + $jsonDeifinition->filters = $this->getElementSession(self::SESSION_FILTERS); + + // If it is already present + if (hasData($definition)) + { + // update it + $this->_ci->FiltersModel->update( + array( + 'app' => $this->getElementSession(self::APP_PARAMETER), + 'dataset_name' => $this->getElementSession(self::DATASET_NAME_PARAMETER), + 'description' => $descPGArray, + 'person_id' => $authPersonId + ), + array( + 'filter' => json_encode($jsonDeifinition) + ) + ); + + $saveCustomFilter = true; + } + else // otherwise insert a new one + { + $this->_ci->FiltersModel->insert( + array( + 'app' => $this->getElementSession(self::APP_PARAMETER), + 'dataset_name' => $this->getElementSession(self::DATASET_NAME_PARAMETER), + 'filter_kurzbz' => uniqid($authPersonId, true), + 'description' => $descPGArray, + 'person_id' => $authPersonId, + 'sort' => null, + 'default_filter' => false, + 'filter' => json_encode($jsonDeifinition), + 'oe_kurzbz' => null + ) + ); + + $saveCustomFilter = true; + } + } + + return $saveCustomFilter; + } + + /** + * Remove a custom filter by its filter_id + */ + public function removeCustomFilter($filterId) + { + $removeCustomFilter = false; + + // Checks the parameter filterId + if (isset($filterId) && is_numeric($filterId) && $filterId > 0) + { + $this->_ci->load->model('system/Filters_model', 'FiltersModel'); // to remove the filter definitions from DB + + // delete it! + $this->_ci->FiltersModel->delete(array('filter_id' => $filterId)); + + $removeCustomFilter = true; + } + + return $removeCustomFilter; + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Return an unique string that identify this filter widget + * NOTE: The default value is the URI where the FilterWidget is called + * If the fhc_controller_id is present then is also used + */ + private function _getFilterUniqueId($params) + { + // + if ($params != null + && is_array($params) + && isset($params[self::FILTER_PAGE_PARAM]) + && !empty(trim($params[self::FILTER_PAGE_PARAM]))) + { + $filterUniqueId = $params[self::FILTER_PAGE_PARAM]; + } + else + { + // Gets the current page URI + $filterUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'.$this->_ci->router->method; + } + + // If the FHC_CONTROLLER_ID parameter is present in the HTTP GET + if (isset($_GET[self::FHC_CONTROLLER_ID])) + { + $filterUniqueId .= '/'.$this->_ci->input->get(self::FHC_CONTROLLER_ID); // then use it + } + elseif (isset($_POST[self::FHC_CONTROLLER_ID])) // else if the FHC_CONTROLLER_ID parameter is present in the HTTP POST + { + $filterUniqueId .= '/'.$this->_ci->input->post(self::FHC_CONTROLLER_ID); // then use it + } + + return $filterUniqueId; + } + + /** + * Generates a condition for a SQL where clause using the given applied filter definition. + * By default an empty string is returned. + */ + private function _getDatasetQueryCondition($filterDefinition) + { + $condition = ''; // starts building the condition + + // "operation" is a required property for the applied filter definition + if (!empty(trim($filterDefinition->operation))) + { + // Checks what operation is required + switch ($filterDefinition->operation) + { + // comparison (==) + case self::OP_EQUAL: + if (is_numeric($filterDefinition->condition)) $condition = '= '.$filterDefinition->condition; + break; + // not equal (!=) + case self::OP_NOT_EQUAL: + if (is_numeric($filterDefinition->condition)) $condition = '!= '.$filterDefinition->condition; + break; + // greater than (>) + case self::OP_GREATER_THAN: + // It it's a date type + if (is_numeric($filterDefinition->condition) + && isset($filterDefinition->option) + && ($filterDefinition->option == self::OPT_DAYS + || $filterDefinition->option == self::OPT_MONTHS)) + { + $condition = '< (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)'; + } + else // otherwise is a number + { + $condition = '> '.$filterDefinition->condition; + } + break; + // less than (<) + case self::OP_LESS_THAN: + // It it's a date type + if (is_numeric($filterDefinition->condition) + && isset($filterDefinition->option) + && ($filterDefinition->option == self::OPT_DAYS + || $filterDefinition->option == self::OPT_MONTHS)) + { + $condition = '> (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)'; + } + else // otherwise is a number + { + $condition = '< '.$filterDefinition->condition; + } + break; + // contains (ILIKE) + case self::OP_CONTAINS: + $condition = 'ILIKE \'%'.$this->_ci->FiltersModel->escapeLike($filterDefinition->condition).'%\''; + break; + // not contains (NOT ILIKE) + case self::OP_NOT_CONTAINS: + $condition = 'NOT ILIKE \'%'.$this->_ci->FiltersModel->escapeLike($filterDefinition->condition).'%\''; + break; + // is true (=== true) + case self::OP_IS_TRUE: + $condition = 'IS TRUE'; + break; + // is false (=== false) + case self::OP_IS_FALSE: + $condition = 'IS FALSE'; + break; + // is set + case self::OP_SET: + $condition = 'IS NOT NULL'; + break; + // is NOT set + case self::OP_NOT_SET: + $condition = 'IS NULL'; + break; + // by default must not be null (!= null) + default: + $condition = 'IS NOT NULL'; + break; + } + } + + // if the condition is valid + if (!empty(trim($condition))) $condition = ' '.$condition; // add a white space before + + return $condition; + } + + /** + * Search for a filter inside a list of filters by the given filter name + * Returns false if NOT found, otherwise the position inside the list + */ + private function _searchFilterByName($filters, $filterName) + { + $pos = false; + + for($i = 0; $i < count($filters); $i++) + { + if ($filters[$i]->name == $filterName) + { + $pos = $i; + break; + } + } + + return $pos; + } +} diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index cf713825d..e933f532e 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class PersonLogLib { + const PARKED_LOGNAME = 'Parked'; + /** * Constructor */ @@ -79,4 +81,90 @@ class PersonLogLib else show_error($result->retval); } + + /** + * Parks a person, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent) + * Done by adding a logentry in the future + * @param $person_id + * @param $date + * @param $taetigkeit_kurzbz + * @param string $app + * @param null $oe_kurzbz + * @param null $user + * @return insert object + */ + public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) + { + $logdata = array( + 'name' => self::PARKED_LOGNAME + ); + + $data = array( + 'person_id' => $person_id, + 'zeitpunkt' => $date, + 'taetigkeit_kurzbz' => $taetigkeit_kurzbz, + 'app' => $app, + 'oe_kurzbz' => $oe_kurzbz, + 'logtype_kurzbz' => 'Processstate', + 'logdata' => json_encode($logdata), + 'insertvon' => $user + ); + + return $this->ci->PersonLogModel->insert($data); + } + + /** + * Unparks a person, i.e. removes all log entries in the future + * @param $person_id + * @return array with deleted logids + */ + public function unPark($person_id) + { + $result = $this->ci->PersonLogModel->getLogsInFuture($person_id); + + $deleted = array(); + + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME) + { + $delresult = $this->ci->PersonLogModel->deleteLog($log->log_id); + if (isSuccess($delresult)) + $deleted[] = $log->log_id; + } + } + } + + return $deleted; + } + + /** + * Gets date until which a person is parked + * @param $person_id + * @return the date if person is parked, null otherwise + */ + public function getParkedDate($person_id) + { + $result = $this->ci->PersonLogModel->getLogsInFuture($person_id); + + $parkeddate = null; + + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME) + { + $parkeddate = $log->zeitpunkt; + break; + } + } + } + + return $parkeddate; + } } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index 99b73732b..f895cf637 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -14,6 +14,8 @@ class PhrasesLib { $this->_ci =& get_instance(); + $this->_phrases = null; // set the property _phrases as null by default + // CI parser $this->_ci->load->library('parser'); @@ -78,7 +80,6 @@ class PhrasesLib return $this->_ci->PhraseModel->update($phrase_id, $data); } - /** * getVorlagetextByVorlage() - will load tbl_vorlagestudiengang for a spezific Template. */ @@ -179,28 +180,39 @@ class PhrasesLib } /** - * + * Retrives a phrases from the the property _phrases with the given parameters + * It also replace parameters inside the phrase if they are provided + * @param string $category Category name which is used to categorize the phrase. + * @param string $phrase Phrase name. + * @param array $parameters Array of String var(s) to be set into phrases' placeholder values (order matters). + * @return string Phrase text */ public function t($category, $phrase, $parameters = array(), $orgeinheit_kurzbz = null, $orgform_kurzbz = null) { - if (isset($this->_phrases) && is_array($this->_phrases)) + // If the property _phrases is populated + if (is_array($this->_phrases)) { + // Loops through the _phrases property for ($i = 0; $i < count($this->_phrases); $i++) { - $_phrase = $this->_phrases[$i]; + $_phrase = $this->_phrases[$i]; // single phrase + // If the single phrase match the given parameters and is not an empty string if ($_phrase->category == $category && $_phrase->phrase == $phrase && $_phrase->orgeinheit_kurzbz == $orgeinheit_kurzbz - && $_phrase->orgform_kurzbz== $orgform_kurzbz) + && $_phrase->orgform_kurzbz == $orgform_kurzbz + && (!empty(trim($_phrase->text)))) { - if ($parameters == null) $parameters = array(); + if (!is_array($parameters)) $parameters = array(); // if params is not an array - echo $this->_ci->parser->parse_string($_phrase->text, $parameters, true)."\n"; - break; + return $this->_ci->parser->parse_string($_phrase->text, $parameters, true); // parsing } } } + + // If a valid phrase is not found + return '<< PHRASE '.$phrase.' >>'; } // ----------------------------------------------------------------------------------------------------------------- @@ -209,16 +221,19 @@ class PhrasesLib /** * Extends the functionalities of the constructor of this class * This is a workaround to use more parameters in the construct since PHP doesn't support many constructors - * The new accepted parameters are: - * - categories: could be a string or an array of strings. These are the categories used to load phrases - * - language: optional parameter must be a string. It's used to load phrases + * @param (array) $params Array of categories and (optional) language. + * categories: + * - could be a string or an array of strings. These are the categories used to load phrases + * - could be an array of categories, and for each category there is an array of phrases + * language: optional parameter must be a string. It's used to load phrases */ private function _extend_construct($params) { // Checks if the $params is an array with at least one element if (is_array($params) && count($params) > 0) { - $parameters = $params[0]; // temporary variable + $parameters = $params[0]; // temporary variable + $isIndexArray = false; //flag for indexed array // If there are parameters if (is_array($parameters) && count($parameters) > 0) @@ -242,15 +257,101 @@ class PhrasesLib $language = $this->_ci->PersonModel->getLanguage(getAuthUID()); } - // Loads phrases - $phrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndLanguage($categories, $language); - - // If there are phrases loaded then store them in the property _phrases - if (hasData($phrases)) - { - $this->_phrases = $phrases->retval; - } + // If only categories is not an empty array then loads phrases + if (count($categories) > 0) $this->_setPhrases($categories, $language); } } } + + /** + * Retrieves phrases in the users language. + * If a phrase is not set in the users language it will be retrieved in the default language. + * Stores phrases-array in property $_phrases. + * @param array $categories Could be an: + * - indexed array: string or an array of strings. These are the categories used to load phrases. + * - associative array: of categories, and for each category there is an array of phrases. + * @param string User's language or default language. + */ + private function _setPhrases($categories, $language) + { + $phrases = null; + // Checks if categories is associative or indexed array + if (ctype_digit(implode('', array_keys($categories)))) + { + // is indexed array -> Loads phrases + $isIndexArray = true; + $phrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndLanguage($categories, $language); + } + else + { + // is assoc array -> Loads specific phrasentexte by category and phrases + $isIndexArray = false; + $phrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndPhrasesAndLanguage($categories, $language); + } + + // If language is not default language and phrasentext is null -> fallback to default language + if ($language != DEFAULT_LANGUAGE) + { + // get array with phrasentexte in the default language + $defaultPhrases = null; + if ($isIndexArray) + { + $defaultPhrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndLanguage($categories, DEFAULT_LANGUAGE); + } + else + { + $defaultPhrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndPhrasesAndLanguage($categories, DEFAULT_LANGUAGE); + } + + // combine array with phrasentexte in users language and in default language + // (default used if phrasentext in users language is null or not set) + if (hasData($phrases) && hasData($defaultPhrases)) + { + // loop through phrases in default language + foreach ($defaultPhrases->retval as $defaultPhrase) + { + $found = false; // flag for found phrase + + // loop through phrases in users language + foreach ($phrases->retval as $phrase) + { + // if same phrase and category found and text is not null + // use phrase in users language + if ($phrase->phrase == $defaultPhrase->phrase + && $phrase->category == $defaultPhrase->category + && !is_null($phrase->text)) + { + $found = true; + break; + } + } + + // otherwise use phrase in default language + if (!$found) + { + array_push($phrases->retval, $defaultPhrase); + } + } + } + elseif (hasData($defaultPhrases)) + { + $phrases = $defaultPhrases; + } + } + + // If there are phrases loaded then store them in the property _phrases + if (hasData($phrases)) + { + $this->_phrases = $phrases->retval; + } + } + + /** + * Returns the property _phrases JSON encoded + * @return json encoded property _phrases + */ + public function getJSON() + { + return json_encode($this->_phrases); + } } diff --git a/application/models/organisation/Geschaeftsjahr_model.php b/application/models/organisation/Geschaeftsjahr_model.php index e806058ae..9c856f40e 100644 --- a/application/models/organisation/Geschaeftsjahr_model.php +++ b/application/models/organisation/Geschaeftsjahr_model.php @@ -21,7 +21,9 @@ class Geschaeftsjahr_model extends DB_Model $query = 'SELECT * FROM public.tbl_geschaeftsjahr WHERE start <= now() - AND ende >= now()'; + AND ende >= now() + ORDER BY start DESC + LIMIT 1'; return $this->execQuery($query); } diff --git a/application/models/organisation/Studienjahr_model.php b/application/models/organisation/Studienjahr_model.php index ace9c1525..36784a280 100644 --- a/application/models/organisation/Studienjahr_model.php +++ b/application/models/organisation/Studienjahr_model.php @@ -12,4 +12,21 @@ class Studienjahr_model extends DB_Model $this->pk = 'studienjahr_kurzbz'; $this->hasSequence = false; } + + /** + * Gets current Studienjahr, as determined by its start and enddate + * @return array|null + */ + public function getCurrStudienjahr() + { + $query = 'SELECT * + FROM public.tbl_studienjahr + JOIN public.tbl_studiensemester using(studienjahr_kurzbz) + WHERE start <= now() + AND ende >= now() + ORDER by start DESC + LIMIT 1'; + + return $this->execQuery($query); + } } diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php index d84cddf80..eb81dbb32 100644 --- a/application/models/system/Filters_model.php +++ b/application/models/system/Filters_model.php @@ -44,7 +44,6 @@ class Filters_model extends DB_Model $filterParametersArray = array( 'app' => $app, 'dataset_name' => $dataset_name, - 'default_filter' => false, 'array_length(description, 1) >' => 0, 'uid' => $uid ); diff --git a/application/models/system/PersonLog_model.php b/application/models/system/PersonLog_model.php index 95863ea57..325fba88e 100644 --- a/application/models/system/PersonLog_model.php +++ b/application/models/system/PersonLog_model.php @@ -80,4 +80,36 @@ class PersonLog_model extends CI_Model return success($result->result()); } + + /** + * Gets all logs with zeitpunkt > today + * @param $person_id + * @return array + */ + public function getLogsInFuture($person_id) + { + $this->db->order_by('zeitpunkt', 'DESC'); + $this->db->order_by('log_id', 'DESC'); + + $where = "logtype_kurzbz = 'Processstate' + AND person_id=".$this->db->escape($person_id)." + AND zeitpunkt >= now()"; + + $result = $this->db->get_where($this->dbTable, $where); + + return success($result->result()); + } + + /** + * Deletes a log + * @param $log_id + * @return array + */ + public function deleteLog($log_id) + { + $this->db->where('log_id', $log_id); + $result = $this->db->delete($this->dbTable); + + return success($result); + } } diff --git a/application/models/system/Phrase_model.php b/application/models/system/Phrase_model.php index a1d771cee..696d46917 100644 --- a/application/models/system/Phrase_model.php +++ b/application/models/system/Phrase_model.php @@ -71,4 +71,32 @@ class Phrase_model extends DB_Model return $this->execQuery($query, array($categories, $language)); } + + /** + * Loads phrases using category(s) and language as keys using associative category array + * that contains also phrases for each category + */ + public function getPhrasesByCategoryAndPhrasesAndLanguage($phrasesParams, $language) + { + $query = ' + SELECT p.category, p.phrase, pt.orgeinheit_kurzbz, pt.orgform_kurzbz, pt.text + FROM system.tbl_phrase p + INNER JOIN system.tbl_phrasentext pt USING(phrase_id) + WHERE pt.sprache = ? AND '; + + $parametersArray = array($language); + + foreach ($phrasesParams as $category => $phrases) + { + $query .= '(category = ? AND phrase IN ?) OR '; + $parametersArray[] = $category; + $parametersArray[] = $phrases; + } + + $query = rtrim($query, ' OR '); + + $query .= ' ORDER BY p.category, p.phrase, pt.orgeinheit_kurzbz DESC, pt.orgform_kurzbz DESC'; + + return $this->execQuery($query, $parametersArray); + } } diff --git a/application/views/home.php b/application/views/home.php index cd032bc71..598413c32 100644 --- a/application/views/home.php +++ b/application/views/home.php @@ -5,7 +5,9 @@ $this->load->view('templates/FHC-Header', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, - 'sbadmintemplate' => true + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'navigationwidget' => true ) ); ?> diff --git a/application/views/system/infocenter/addNotiz.php b/application/views/system/infocenter/addNotiz.php index a8396fe40..56bccbfaf 100644 --- a/application/views/system/infocenter/addNotiz.php +++ b/application/views/system/infocenter/addNotiz.php @@ -2,11 +2,11 @@
- +
- +
@@ -21,8 +21,9 @@
- - + + +
- \ No newline at end of file + diff --git a/application/views/system/infocenter/anmerkungenZurBewerbung.php b/application/views/system/infocenter/anmerkungenZurBewerbung.php index 565db79db..85682d2a4 100644 --- a/application/views/system/infocenter/anmerkungenZurBewerbung.php +++ b/application/views/system/infocenter/anmerkungenZurBewerbung.php @@ -5,7 +5,7 @@ - + diff --git a/application/views/system/infocenter/dokpruefung.php b/application/views/system/infocenter/dokpruefung.php index 8261a2ebd..b7fbbd4a7 100644 --- a/application/views/system/infocenter/dokpruefung.php +++ b/application/views/system/infocenter/dokpruefung.php @@ -2,11 +2,11 @@
Anmerkungen zur Bewerbungp->t('infocenter','anmerkungenZurBewerbung')) ?>
- - - - - + + + + + @@ -35,14 +35,14 @@ 0): ?>
-

Nachzureichende Dokumente:

+

p->t('infocenter','nachzureichendeDokumente')) ?>

NameTypUploaddatumAusstellungsnationFormal geprüftp->t('global','name')) ?>p->t('global','typ')) ?>p->t('global','uploaddatum')) ?>p->t('infocenter','ausstellungsnation')) ?>p->t('infocenter','formalGeprueft')) ?>
- - - - + + + + diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index ab9746a8e..80534c800 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -5,10 +5,18 @@ 'title' => 'Info Center', 'jquery' => true, 'jqueryui' => true, + 'ajaxlib' => true, 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, 'tablesorter' => true, + 'filterwidget' => true, + 'phrases' => array( + 'person' => array('vorname', 'nachname'), + 'global' => array('mailAnXversandt'), + 'ui' => array('bitteEintragWaehlen') + ), + 'navigationwidget' => true, 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/infocenterPersonDataset.js') ) @@ -24,12 +32,17 @@
- +
load->view('system/infocenter/infocenterData.php', array('fhc_controller_id' => $fhc_controller_id)); + $this->load->view( + 'system/infocenter/infocenterData.php', + array('fhc_controller_id' => $fhc_controller_id) + ); ?>
diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index bdb2f719b..e829b6daf 100755 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -82,7 +82,7 @@ FROM public.tbl_studiensemester WHERE ende >= NOW() ) - AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\') + AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\' and psss.studiensemester_kurzbz = \'WS2018\') LIMIT 1 ) AS "AnzahlAbgeschickt", array_to_string( @@ -103,7 +103,7 @@ FROM public.tbl_studiensemester WHERE ende >= NOW() ) - AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\') + AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\' and psss.studiensemester_kurzbz = \'WS2018\') LIMIT 1 ),\', \' ) AS "StgAbgeschickt", @@ -125,7 +125,7 @@ FROM public.tbl_studiensemester WHERE ende >= NOW() ) - AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\') + AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\' and psss.studiensemester_kurzbz = \'WS2018\') LIMIT 1 ),\', \' ) AS "StgNichtAbgeschickt", @@ -146,14 +146,22 @@ FROM public.tbl_studiensemester WHERE start >= NOW() ) - AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\') + AND not exists (select 1 from tbl_prestudentstatus psss where psss.prestudent_id = pss.prestudent_id and psss.status_kurzbz = \'Abgewiesener\' and psss.studiensemester_kurzbz = \'WS2018\') LIMIT 1 ),\', \' ) AS "StgAktiv", pl.zeitpunkt AS "LockDate", - pl.lockuser as "LockUser" + pl.lockuser AS "LockUser", + pd.parkdate AS "ParkDate" FROM public.tbl_person p LEFT JOIN (SELECT person_id, zeitpunkt, uid as lockuser FROM system.tbl_person_lock WHERE app = \''.$APP.'\') pl USING(person_id) + LEFT JOIN ( + SELECT person_id, zeitpunkt as parkdate + FROM system.tbl_log + WHERE logtype_kurzbz = \'Processstate\' + AND logdata->>\'name\' = \'Parked\' + AND zeitpunkt >= now() + ) pd USING(person_id) WHERE EXISTS( SELECT 1 @@ -187,22 +195,33 @@ ORDER BY "LastAction" ASC ', 'requiredPermissions' => 'infocenter', - 'fhc_controller_id' => $fhc_controller_id, 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), 'columnsAliases' => array( - 'PersonID', 'Vorname', 'Nachname', - 'GebDatum', 'Nation', 'Letzte Aktion', - 'Letzter Bearbeiter', 'StSem', 'GesendetAm', - 'NumAbgeschickt', 'StgSent', 'StgNotSent', - 'StgAktiv', 'Sperrdatum', 'GesperrtVon' + 'PersonID', + ucfirst($this->p->t('person', 'vorname')) , + ucfirst($this->p->t('person', 'nachname')), + ucfirst($this->p->t('person', 'geburtsdatum')), + ucfirst($this->p->t('person', 'nation')), + ucfirst($this->p->t('global', 'letzteAktion')), + ucfirst($this->p->t('global', 'letzterBearbeiter')), + ucfirst($this->p->t('lehre', 'studiensemester')), + ucfirst($this->p->t('global', 'gesendetAm')), + ucfirst($this->p->t('global', 'abgeschickt')).' ('.$this->p->t('global', 'anzahl').')', + ucfirst($this->p->t('lehre', 'studiengang')).' ('.$this->p->t('global', 'gesendet').')', + ucfirst($this->p->t('lehre', 'studiengang')).' ('.$this->p->t('global', 'nichtGesendet').')', + ucfirst($this->p->t('lehre', 'studiengang')).' ('.$this->p->t('global', 'aktiv').')', + ucfirst($this->p->t('global', 'sperrdatum')), + ucfirst($this->p->t('global', 'gesperrtVon')), + ucfirst($this->p->t('global', 'parkdatum')) ), - 'formatRaw' => function($datasetRaw) { + 'formatRow' => function($datasetRaw) { $datasetRaw->{'Details'} = sprintf( - 'Details', - site_url('system/infocenter/InfoCenter/showDetails/'), - $datasetRaw->{'PersonId'} + 'Details', + site_url('system/infocenter/InfoCenter/showDetails'), + $datasetRaw->{'PersonId'}, + (isset($_GET['fhc_controller_id'])?$_GET['fhc_controller_id']:'') ); if ($datasetRaw->{'SendDate'} == null) @@ -211,7 +230,7 @@ } else { - $datasetRaw->{'SendDate'} = date_format(date_create($datasetRaw->{'SendDate'}),'Y-m-d H:i'); + $datasetRaw->{'SendDate'} = date_format(date_create($datasetRaw->{'SendDate'}), 'Y-m-d H:i'); } if ($datasetRaw->{'LastAction'} == null) @@ -220,7 +239,7 @@ } else { - $datasetRaw->{'LastAction'} = date_format(date_create($datasetRaw->{'LastAction'}),'Y-m-d H:i'); + $datasetRaw->{'LastAction'} = date_format(date_create($datasetRaw->{'LastAction'}), 'Y-m-d H:i'); } if ($datasetRaw->{'User/Operator'} == '') @@ -238,6 +257,11 @@ $datasetRaw->{'LockUser'} = '-'; } + if ($datasetRaw->{'ParkDate'} == null) + { + $datasetRaw->{'ParkDate'} = '-'; + } + if ($datasetRaw->{'StgAbgeschickt'} == null) { $datasetRaw->{'StgAbgeschickt'} = '-'; @@ -259,25 +283,26 @@ }, 'markRow' => function($datasetRaw) { + $mark = ''; + if ($datasetRaw->LockDate != null) { - return FilterWidget::DEFAULT_MARK_ROW_CLASS; + $mark = FilterWidget::DEFAULT_MARK_ROW_CLASS; } + + if ($datasetRaw->ParkDate != null) + { + // Parking has priority over locking + $mark = "text-info"; + } + + return $mark; } ); - $filterId = isset($_GET[InfoCenter::FILTER_ID]) ? $_GET[InfoCenter::FILTER_ID] : null; - - if (isset($filterId) && is_numeric($filterId)) - { - $filterWidgetArray[InfoCenter::FILTER_ID] = $filterId; - } - else - { - $filterWidgetArray['app'] = $APP; - $filterWidgetArray['datasetName'] = 'PersonActions'; - $filterWidgetArray['filterKurzbz'] = 'InfoCenterNotSentApplicationAll'; - } + $filterWidgetArray[InfoCenter::FILTER_ID] = $this->input->get(InfoCenter::FILTER_ID); + $filterWidgetArray['app'] = $APP; + $filterWidgetArray['datasetName'] = 'PersonActions'; echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); ?> diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 7038031a0..d8ccd10be 100755 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -7,10 +7,12 @@ 'bootstrap' => true, 'fontawesome' => true, 'jqueryui' => true, + 'ajaxlib' => true, 'tablesorter' => true, 'tinymce' => true, 'sbadmintemplate' => true, 'addons' => true, + 'navigationwidget' => true, 'customCSSs' => array( 'public/css/sbadmin2/admintemplate.css', @@ -20,8 +22,33 @@ array( 'public/js/bootstrapper.js', 'public/js/tablesort/tablesort.js', - 'public/js/infocenter/infocenterDetails.js') + 'public/js/infocenter/infocenterDetails.js' + ), + 'phrases' => + array( + 'infocenter' => + array( + 'notizHinzufuegen', + 'notizAendern', + 'bewerberParken', + 'bewerberAusparken', + 'nichtsZumAusparken', + 'fehlerBeimAusparken', + 'fehlerBeimParken', + 'bewerberGeparktBis' + ), + 'ui' => + array( + 'gespeichert', + 'fehlerBeimSpeichern' + ), + 'global' => + array( + 'bis', + 'zeilen' + ) ) + ) ); ?> @@ -40,14 +67,16 @@
- wird bearbeitet von: p->t('global', 'wirdBearbeitetVon') . ': '; echo $lockedby; - ?> -    -  Freigeben + if (!isset($show_lock_link) || $show_lock_link === true): ?> +    + +  p->t('ui', 'freigeben')) ?> + +
@@ -57,7 +86,9 @@
-

Stammdaten

+
+

p->t('global', 'stammdaten')) ?>

+
load->view('system/infocenter/stammdaten.php'); ?> load->view('system/infocenter/anmerkungenZurBewerbung.php'); ?> @@ -71,7 +102,9 @@
-

Dokumentenprüfung

+
+

p->t('infocenter', 'dokumentenpruefung')) ?>

+
load->view('system/infocenter/dokpruefung.php'); ?>
@@ -85,7 +118,8 @@
-

ZGV-Prüfung

+

p->t('infocenter', 'zgv'). ' - '. + ucfirst($this->p->t('lehre', 'pruefung'))?>

load->view('system/infocenter/zgvpruefungen.php'); ?> @@ -100,7 +134,7 @@
-

Nachrichten

+

p->t('global', 'nachrichten')) ?>

@@ -119,7 +153,8 @@
-

Notizen & Aktivitäten

+

p->t('global', 'notizen')). ' & '. + ucfirst($this->p->t('global', 'aktivitaeten')) ?>

@@ -131,8 +166,11 @@ load->view('system/infocenter/notizen.php'); ?>
-
+
+
+
load->view('system/infocenter/logs.php'); ?> +
diff --git a/application/views/system/infocenter/infocenterFreigegeben.php b/application/views/system/infocenter/infocenterFreigegeben.php old mode 100644 new mode 100755 index 03da9b718..556aac966 --- a/application/views/system/infocenter/infocenterFreigegeben.php +++ b/application/views/system/infocenter/infocenterFreigegeben.php @@ -9,6 +9,9 @@ 'fontawesome' => true, 'sbadmintemplate' => true, 'tablesorter' => true, + 'ajaxlib' => true, + 'filterwidget' => true, + 'navigationwidget' => true, 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/infocenterPersonDataset.js') ) @@ -66,7 +69,6 @@ INNER JOIN public.tbl_prestudent ps USING(prestudent_id) JOIN public.tbl_studiengang USING(studiengang_kz) WHERE pss.status_kurzbz = \'Interessent\' - AND pss.bestaetigtam IS NULL AND ps.person_id = p.person_id AND tbl_studiengang.typ in(\'b\') AND studiensemester_kurzbz IN ( @@ -85,7 +87,6 @@ JOIN public.tbl_studiengang USING(studiengang_kz) WHERE pss.status_kurzbz = \'Interessent\' AND (pss.bewerbung_abgeschicktamum IS NOT NULL AND pss.bewerbung_abgeschicktamum>=\''.$NOTBEFORE.'\') - AND pss.bestaetigtam IS NULL AND ps.person_id = p.person_id AND tbl_studiengang.typ in(\'b\') AND studiensemester_kurzbz IN ( @@ -104,7 +105,6 @@ JOIN public.tbl_studiengang USING(studiengang_kz) WHERE pss.status_kurzbz = \'Interessent\' AND (pss.bewerbung_abgeschicktamum IS NOT NULL AND pss.bewerbung_abgeschicktamum>=\''.$NOTBEFORE.'\') - AND pss.bestaetigtam IS NULL AND ps.person_id = p.person_id AND tbl_studiengang.typ in(\'b\') AND studiensemester_kurzbz IN ( @@ -123,7 +123,6 @@ JOIN public.tbl_studiengang USING(studiengang_kz) WHERE pss.status_kurzbz = \'Interessent\' AND (pss.bewerbung_abgeschicktamum IS NOT NULL AND pss.bewerbung_abgeschicktamum>=\''.$NOTBEFORE.'\') - AND pss.bestaetigtam IS NULL AND ps.person_id = p.person_id AND tbl_studiengang.typ in(\'b\') AND studiensemester_kurzbz IN ( @@ -147,11 +146,7 @@ WHERE person_id=p.person_id AND tbl_studiengang.typ in(\'b\') - AND \'Interessent\' = (SELECT status_kurzbz FROM public.tbl_prestudentstatus - WHERE prestudent_id=tbl_prestudent.prestudent_id - ORDER BY datum DESC, insertamum DESC, ext_id DESC - LIMIT 1 - ) + AND EXISTS ( SELECT 1 @@ -160,7 +155,7 @@ WHERE prestudent_id = tbl_prestudent.prestudent_id AND status_kurzbz = \'Interessent\' - AND (bestaetigtam IS NOT NULL AND (bewerbung_abgeschicktamum is null OR bewerbung_abgeschicktamum>=\''.$NOTBEFORE.'\')) + AND (bestaetigtam IS NOT NULL AND bewerbung_abgeschicktamum >= \''.$NOTBEFORE.'\') AND studiensemester_kurzbz IN ( SELECT studiensemester_kurzbz FROM public.tbl_studiensemester @@ -168,19 +163,33 @@ ) ) ) - ORDER BY "LastAction" ASC + ORDER BY "LastAction" DESC ', - 'fhc_controller_id' => $fhc_controller_id, + 'requiredPermissions' => 'infocenter', 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), - 'columnsAliases' => array('PersonID','Vorname','Nachname','GebDatum','Nation','Letzte Aktion','Letzter Bearbeiter', - 'StSem','GesendetAm','NumAbgeschickt','Studiengänge','Sperrdatum','GesperrtVon'), - 'formatRaw' => function($datasetRaw) { + 'columnsAliases' => array( + 'PersonID', + 'Vorname', + 'Nachname', + 'GebDatum', + 'Nation', + 'Letzte Aktion', + 'Letzter Bearbeiter', + 'StSem', + 'GesendetAm', + 'NumAbgeschickt', + 'Studiengänge', + 'Sperrdatum', + 'GesperrtVon' + ), + 'formatRow' => function($datasetRaw) { $datasetRaw->{'Details'} = sprintf( - 'Details', - base_url('index.ci.php/system/infocenter/InfoCenter/showDetails/'), - $datasetRaw->{'PersonId'} + 'Details', + site_url('system/infocenter/InfoCenter/showDetails'), + $datasetRaw->{'PersonId'}, + (isset($_GET['fhc_controller_id'])?$_GET['fhc_controller_id']:'') ); if ($datasetRaw->{'SendDate'} == null) @@ -237,19 +246,9 @@ } ); - - $filterId = isset($_GET[InfoCenter::FILTER_ID]) ? $_GET[InfoCenter::FILTER_ID] : null; - - if (isset($filterId) && is_numeric($filterId)) - { - $filterWidgetArray[InfoCenter::FILTER_ID] = $filterId; - } - else - { - $filterWidgetArray['app'] = $APP; - $filterWidgetArray['datasetName'] = 'PersonActions'; - $filterWidgetArray['filterKurzbz'] = 'InfoCenterNotSentApplicationAll'; - } + $filterWidgetArray[InfoCenter::FILTER_ID] = $this->input->get(InfoCenter::FILTER_ID); + $filterWidgetArray['app'] = $APP; + $filterWidgetArray['datasetName'] = 'PersonActions'; echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); ?> diff --git a/application/views/system/infocenter/logs.php b/application/views/system/infocenter/logs.php index 65b67624e..de97d5055 100644 --- a/application/views/system/infocenter/logs.php +++ b/application/views/system/infocenter/logs.php @@ -1,19 +1,19 @@ -
TypNachzureichen amAusstellungsnationAnmerkungp->t('global','typ')) ?>p->t('infocenter','nachzureichenAm')) ?>p->t('infocenter','ausstellungsnation')) ?>p->t('global','anmerkung')) ?>
- - - - - - - - - - - - - - - - +
DatumAktivitätUser
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
+ + + + + + + + + + + + + + + +
p->t('global', 'datum')) ?>p->t('global', 'aktivitaet')) ?>User
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
\ No newline at end of file diff --git a/application/views/system/infocenter/notizen.php b/application/views/system/infocenter/notizen.php index 646645ae3..53d289721 100644 --- a/application/views/system/infocenter/notizen.php +++ b/application/views/system/infocenter/notizen.php @@ -1,8 +1,8 @@ - - + + diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index daf0b7d24..709370012 100755 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -2,41 +2,41 @@
DatumNotizp->t('global', 'datum')) ?>p->t('global', 'notiz')) ?> User
- + - + - + - + - + - + - + - +
Vornamep->t('person','vorname')) ?> vorname ?>
Nachnamep->t('person','nachname')) ?> nachname ?>
Geburtsdatump->t('person','geburtsdatum')) ?> gebdatum), 'd.m.Y') ?>
Sozialversicherungsnrp->t('person','svnr')) ?> svnr ?>
Staatsbürgerschaftp->t('person','staatsbuergerschaft')) ?> staatsbuergerschaft ?>
Geschlechtp->t('person','geschlecht')) ?> geschlecht ?>
Geburtsnationp->t('person','geburtsnation')) ?> geburtsnation ?>
Geburtsortp->t('person','geburtsort')) ?> gebort ?>
@@ -45,18 +45,22 @@ - + - - - + + + kontakte as $kontakt): ?> - + kontakttyp === 'email'): ?> + + kontakttyp === 'telefon'): ?> + +
Kontaktep->t('global','kontakt')) ?>
TypKontaktAnmerkungp->t('global','typ')) ?>p->t('global','kontakt')) ?>p->t('global','anmerkung')) ?>
kontakttyp); ?>p->t('person','email')) ?>p->t('person','telefon')) ?> kontakttyp.'">';?> kontakttyp === 'email'): ?> @@ -76,7 +80,7 @@ adressen as $adresse): ?>
- Adresse + p->t('person','adresse')) ?> strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?> @@ -97,13 +101,13 @@  Nachricht senden + class="fa fa-envelope"> p->t('ui','nachrichtSenden') ?> zugangscode)): ?>
 Zugang Bewerbung + target='_blank'> p->t('infocenter','zugangBewerbung') ?>
diff --git a/application/views/system/infocenter/studiengangZgvInfo.php b/application/views/system/infocenter/studiengangZgvInfo.php index 6242d0db6..813a87889 100644 --- a/application/views/system/infocenter/studiengangZgvInfo.php +++ b/application/views/system/infocenter/studiengangZgvInfo.php @@ -17,13 +17,13 @@ $this->load->view(
- +
- Keine Zugangsvoraussetzungen für den Studiengang definiert - p->t('infocenter', 'keineZugangsvoraussetzungenTxt'); ?> + prestudentstatus->bestaetigtam)): ?>
- An Studiengang freigegeben + p->t('global', 'anStudiengangFreigegeben') ?>
- prestudentstatus->bewerbung_abgeschicktamum) ? '' : ''); ?> - prestudentstatus->bewerbungsnachfrist) ? ' | Nachfrist: '. date_format(date_create($zgvpruefung->prestudentstatus->bewerbungsnachfrist), 'd.m.Y') : ''); ?> - prestudentstatus->bewerbungstermin) ? ' | Bewerbungsfrist: '. date_format(date_create($zgvpruefung->prestudentstatus->bewerbungstermin), 'd.m.Y') : ''); ?> + p->t('infocenter','bewerbung')) . ' ' . $this->p->t('global','abgeschickt') . ': '.(isset($zgvpruefung->prestudentstatus->bewerbung_abgeschicktamum) ? '' : ''); ?> + prestudentstatus->bewerbungsnachfrist) ? ' | ' . $this->p->t('infocenter', 'nachfrist') . ': ' . date_format(date_create($zgvpruefung->prestudentstatus->bewerbungsnachfrist), 'd.m.Y') : ''); ?> + prestudentstatus->bewerbungstermin) ? ' | ' . $this->p->t('infocenter', 'bewerbungsfrist') . ': ' . date_format(date_create($zgvpruefung->prestudentstatus->bewerbungstermin), 'd.m.Y') : ''); ?>
@@ -49,7 +49,7 @@
- + prestudentstatus->status_kurzbz)) { @@ -60,7 +60,7 @@
- + prestudentstatus->studiensemester_kurzbz) ? $zgvpruefung->prestudentstatus->studiensemester_kurzbz : '' ?>
@@ -73,7 +73,7 @@
- + prestudentstatus->orgform)) ? ', ' : ''; @@ -90,18 +90,18 @@
- + zgv_bez; ?>
- +
- + zgvort); else: @@ -127,7 +127,7 @@
- + zgvdatum) ? "" : date_format(date_create($zgvpruefung->zgvdatum), 'd.m.Y'); if ($infoonly): @@ -143,7 +143,7 @@
- + zgvnation_bez; else @@ -159,7 +159,7 @@ studiengangtyp === 'm') : ?>
-
+
zgvmas_bez; @@ -173,7 +173,7 @@
- + zgvmaort; else: @@ -186,7 +186,7 @@
- + zgvmadatum) ? "" : date_format(date_create($zgvpruefung->zgvmadatum), 'd.m.Y'); if ($infoonly): @@ -201,8 +201,7 @@
-
+
zgvmanation_bez; @@ -221,12 +220,12 @@
@@ -244,13 +243,13 @@
+
- - - - - - - - - - - - - - - - - - - - -
Gesendet amSenderEmpfängerBetreffGelesen am
insertamum) ? date_format(date_create($message->insertamum), 'd.m.Y H:i:s') : '' ?>sevorname.' '.$message->senachname ?>revorname.' '.$message->renachname ?>subject ?>statusamum) ? date_format(date_create($message->statusamum), 'd.m.Y H:i:s') : '' ?>
-
- -
-
-
-
- -
-
- - \ No newline at end of file diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index 89c408687..483d06010 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -22,11 +22,82 @@ $href = site_url().'/system/Messages/send/';
- +
- load->view('system/messageForm.php'); ?> +
+
+
+ +
+
+ 1 && $i % 10 == 0) + { + echo '
'; + } + echo $receiver->Vorname." ".$receiver->Nachname."; "; + } + ?> +
+
+
+
+
+
+ +
  + subject; + } + ?> +
+ +
+
+
+
+
+
+ + body; + } + ?> + +
+ +
+
+ + +
+
+ +

@@ -38,21 +109,24 @@ $href = site_url().'/system/Messages/send/'; ); ?>
+
+ +
0): ?>
- +
- + + - +
diff --git a/application/views/widgets/filter/selectFields.php b/application/views/widgets/filter/selectFields.php index a011e5555..644bbf277 100644 --- a/application/views/widgets/filter/selectFields.php +++ b/application/views/widgets/filter/selectFields.php @@ -1,247 +1,11 @@ - - -
- -
- - Add field: - - - - - -
+ + + +
diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php index cf5443069..4b98c629c 100644 --- a/application/views/widgets/filter/selectFilters.php +++ b/application/views/widgets/filter/selectFilters.php @@ -1,296 +1,17 @@ - -
-
+
- - Add filter: + + p->t('filter', 'filterHinzufuegen')); ?>: - + - +
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php index 1a19876f4..ca917503a 100644 --- a/application/views/widgets/filter/tableDataset.php +++ b/application/views/widgets/filter/tableDataset.php @@ -1,153 +1,3 @@ - -
diff --git a/application/views/widgets/navigation.php b/application/views/widgets/navigation.php index 8a57dab57..efc953f5f 100644 --- a/application/views/widgets/navigation.php +++ b/application/views/widgets/navigation.php @@ -1,9 +1,9 @@ - diff --git a/application/views/widgets/navigationHeader.php b/application/views/widgets/navigationHeader.php index 0d050df2a..8e2a936a4 100644 --- a/application/views/widgets/navigationHeader.php +++ b/application/views/widgets/navigationHeader.php @@ -1,39 +1,11 @@ - - - + diff --git a/application/views/widgets/navigationMenu.php b/application/views/widgets/navigationMenu.php index 9ef727083..42dd901fb 100644 --- a/application/views/widgets/navigationMenu.php +++ b/application/views/widgets/navigationMenu.php @@ -1,169 +1,3 @@ - - - -