diff --git a/application/config/navigation.php b/application/config/navigation.php index 64397f681..86dc3bdde 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -61,21 +61,16 @@ $config['navigation_menu']['Vilesci/index'] = array( $config['navigation_menu']['system/infocenter/InfoCenter/index'] = array( 'Freigegeben' => array( - 'link' => base_url('index.ci.php/system/infocenter/InfoCenter/infocenterFreigegeben'), + 'link' => base_url('index.ci.php/system/infocenter/InfoCenter/freigegeben'), 'description' => 'Freigegeben', 'icon' => 'thumbs-up' - )); + ) +); -$config['navigation_menu']['system/infocenter/InfoCenter/showDetails'] = array( - 'Freigegeben' => array( - 'link' => base_url('index.ci.php/system/infocenter/InfoCenter/infocenterFreigegeben'), - 'description' => 'Freigegeben', - 'icon' => 'thumbs-up' - )); - -$config['navigation_menu']['system/infocenter/InfoCenter/infocenterFreigegeben'] = array( +$config['navigation_menu']['system/infocenter/InfoCenter/freigegeben'] = array( 'Zurück' => array( 'link' => base_url('index.ci.php/system/infocenter/InfoCenter/index'), - 'description' => 'Zurück', + 'description' => 'Home', 'icon' => 'angle-left' - )); + ) +); diff --git a/application/controllers/system/Navigation.php b/application/controllers/system/Navigation.php index f8a8f6dd2..3471165a8 100644 --- a/application/controllers/system/Navigation.php +++ b/application/controllers/system/Navigation.php @@ -3,14 +3,16 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** - * + * This controller operates between (interface) the JS (GUI) and the NavigationLib (back-end) + * Provides data to the ajax get calls about the filter + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON */ class Navigation extends Auth_Controller { - const SESSION_NAME = 'NAVIGATION_MENU'; + const NAVIGATION_PAGE_PARAM = 'navigation_page'; // Navigation page parameter name /** - * Constructor + * Loads the NavigationLib where the used logic lies */ public function __construct() { @@ -21,165 +23,67 @@ class Navigation extends Auth_Controller ) ); - $this->config->load('navigation'); - - // Load session library - $this->load->library('session'); - $this->load->library('ExtensionsLib'); + $this->_loadNavigationLib(); // Loads the NavigationLib with parameters } + //------------------------------------------------------------------------------------------------------------------ + // Public methods + /** * This function creates the left Menu for each Page - * @param navigation_widget_called GET Parameter witch holds the currently called Page + * @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page * @return JSON object with the Menu Entries */ public function menu() { - $navigation_widget_called = $this->input->get('navigation_widget_called'); - $json = array(); + $menuArray = $this->navigationlib->getMenuArray($this->input->get(self::NAVIGATION_PAGE_PARAM)); - if (isset($navigation_widget_called)) - { - // Get Menu Entries of the Core - $navigationMenuArray = $this->config->item('navigation_menu'); - $json = $this->wildcardsearch($navigationMenuArray, $navigation_widget_called); - - // Load Menu Entries of Extensions - $extensions = $this->extensionslib->getInstalledExtensions(); - if(hasData($extensions)) - { - $json_extension = array(); - foreach($extensions->retval as $ext) - { - $filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/navigation.php'; - if (file_exists($filename)) - { - unset($config); - include($filename); - if(isset($config['navigation_menu']) && is_array($config['navigation_menu'])) - { - $json_extension = array_merge_recursive($json_extension, $this->wildcardsearch($config['navigation_menu'], $navigation_widget_called)); - } - } - } - // Merge Extension Menuentries with the Core Entries - $json = array_merge_recursive($json, $json_extension); - } - - // Load dynamic Menu Entries from Session - if (isset($_SESSION['navigation_menu'])) - { - $navigationMenuSessionArray = $_SESSION['navigation_menu']; - - if (isset($navigationMenuSessionArray) && is_array($navigationMenuSessionArray)) - { - if (isset($navigationMenuSessionArray[$navigation_widget_called])) - { - $json = array_merge_recursive($json, $navigationMenuSessionArray[$navigation_widget_called]); - } - } - } - } - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); + $this->outputJsonSuccess($menuArray); } /** * This function creates the Top Menu for each Page - * @param navigation_widget_called GET Parameter witch holds the currently called Page + * @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page * @return JSON object with the Menu Entries */ public function header() { - $navigation_widget_called = $this->input->get('navigation_widget_called'); - $json = array(); + $headerArray = $this->navigationlib->getHeaderArray($this->input->get(self::NAVIGATION_PAGE_PARAM)); - if (isset($navigation_widget_called)) - { - // Load Header Entries of Core - $navigationHeaderArray = $this->config->item('navigation_header'); - $json = $this->wildcardsearch($navigationHeaderArray, $navigation_widget_called); - - // Load Header Entries of Extensions - $extensions = $this->extensionslib->getInstalledExtensions(); - if(hasData($extensions)) - { - $json_extension = array(); - foreach($extensions->retval as $ext) - { - $filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/navigation.php'; - if (file_exists($filename)) - { - unset($config); - include($filename); - if(isset($config['navigation_header']) && is_array($config['navigation_header'])) - { - $json_extension = array_merge_recursive($json_extension, $this->wildcardsearch($config['navigation_header'], $navigation_widget_called)); - } - } - } - $json = array_merge_recursive($json, $json_extension); - } - - // Load dynamic Header Entries from Session - if (isset($_SESSION['navigation_header'])) - { - $navigationHeaderSessionArray = $_SESSION['navigation_header']; - - if (isset($navigationHeaderSessionArray) && is_array($navigationHeaderSessionArray)) - { - if (isset($navigationHeaderSessionArray[$navigation_widget_called])) - { - $jsontmp = $this->wildcardsearch($navigationHeaderSessionArray, $navigation_widget_called); - $json = array_merge_recursive($json, $jsontmp); - } - } - } - } - - $this->output->set_content_type('application/json')->set_output(json_encode($json)); + $this->outputJsonSuccess($headerArray); } + //------------------------------------------------------------------------------------------------------------------ + // Private methods + /** - * Searches a Menuentry. If there is no exact entry it searches for Wildcard Entries with a Star - * Example: - * Searching for /system/foo/index will Match the following Menuentries: - * /system/foo/index - * /system/foo/* - * /system/* - * * - * - * @param $navigationArray Array to Search in. - * @param $navigation_widget_called Navigation to search for. - * @return Navigation Array if found, empty array otherwise + * Loads the FiltersLib with the NAVIGATION_PAGE_PARAM parameter + * If the parameter NAVIGATION_PAGE_PARAM is not given then the execution of the controller is terminated and + * an error message is printed */ - private function wildcardsearch($navigationArray, $navigation_widget_called) + private function _loadNavigationLib() { - // Sort Navigation to have them in correct order - krsort($navigationArray); - - // 100% match found - if(isset($navigationArray[$navigation_widget_called])) + // If the parameter NAVIGATION_PAGE_PARAM is present in the HTTP GET or POST + if (isset($_GET[self::NAVIGATION_PAGE_PARAM]) || isset($_POST[self::NAVIGATION_PAGE_PARAM])) { - return $navigationArray[$navigation_widget_called]; - } - else - { - foreach($navigationArray as $key=>$row) + // If it is present in the HTTP GET + if (isset($_GET[self::NAVIGATION_PAGE_PARAM])) { - // Search for * Entries - if(mb_strpos($key, '*') === 0 || mb_strpos($key, '*') === mb_strlen($key) - 1) - { - // Take * Entry if Matches - $search = mb_substr($key, 0, -1); - if($search == '' || mb_strpos($navigation_widget_called, $search) === 0) - { - return $row; - } - } + $navigationPage = $this->input->get(self::NAVIGATION_PAGE_PARAM); // is retrived from the HTTP GET + } + elseif (isset($_POST[self::NAVIGATION_PAGE_PARAM])) // Else if it is present in the HTTP POST + { + $navigationPage = $this->input->post(self::NAVIGATION_PAGE_PARAM); // is retrived from the HTTP POST } - } - return array(); + // Loads the FiltersLib that contains all the used logic + $this->load->library('NavigationLib', array(self::NAVIGATION_PAGE_PARAM => $navigationPage)); + } + else // Otherwise an error will be written in the output + { + // NOTE: Used echo to speed up the output before the exit otherwise it's not shown + echo 'Parameter "'.self::NAVIGATION_PAGE_PARAM.'" not provided!'; + exit; + } } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d50d20388..0380a150b 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -3,7 +3,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, + * 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 Auth_Controller @@ -11,10 +11,10 @@ class InfoCenter extends Auth_Controller // App and Verarbeitungstaetigkeit name for logging const APP = 'infocenter'; const TAETIGKEIT = 'bewerbung'; - const FILTER_ID = 'filter_id'; - // URL prefix for this controller - const URL_PREFIX = '/system/infocenter/InfoCenter'; + const URL_PREFIX = '/system/infocenter/InfoCenter'; // URL prefix for this controller + + private $_uid; // contains the UID of the logged user // Used to log with PersonLogLib private $logparams = array( @@ -53,7 +53,6 @@ class InfoCenter extends Auth_Controller 'success' => null ) ); - private $uid; // contains the UID of the logged user /** * Constructor @@ -63,7 +62,7 @@ class InfoCenter extends Auth_Controller parent::__construct( array( 'index' => 'infocenter:r', - 'infocenterFreigegeben' => 'infocenter:r', + 'freigegeben' => 'infocenter:r', 'showDetails' => 'infocenter:r', 'unlockPerson' => 'infocenter:rw', 'saveFormalGeprueft' => 'infocenter:rw', @@ -90,7 +89,6 @@ class InfoCenter extends Auth_Controller $this->load->model('system/personLock_model', 'PersonLockModel'); // Loads libraries - $this->load->library('DmsLib'); $this->load->library('PersonLogLib'); $this->load->library('WidgetLib'); @@ -112,10 +110,6 @@ class InfoCenter extends Auth_Controller show_error('You have no Permission! You need Infocenter Role'); $this->setControllerId(); // sets the controller id - - $this->fhc_controller_id = $this->getControllerId(); - - $this->setNavigationMenuArray(); // sets property navigationMenuArray } // ----------------------------------------------------------------------------------------------------------------- @@ -126,20 +120,28 @@ class InfoCenter extends Auth_Controller */ public function index() { - $this->load->view('system/infocenter/infocenter.php', array('fhc_controller_id' => $this->fhc_controller_id)); + $this->setNavigationMenuIndex(); // define the navigation menu for this page + + $this->load->view('system/infocenter/infocenter.php'); } - public function infocenterFreigegeben() + public function freigegeben() { - $this->load->view('system/infocenter/infocenterFreigegeben.php', array('fhc_controller_id' => $this->fhc_controller_id)); + $this->setNavigationMenuFreigegeben(); // define the navigation menu for this page + + $this->load->view('system/infocenter/infocenterFreigegeben.php'); } /** * Initialization function, gets person and prestudent data and loads the view with the data * @param $person_id */ - public function showDetails($person_id) + public function showDetails() { + $this->setNavigationMenuShowDetails(); + + $person_id = $this->input->get('person_id'); + if (!is_numeric($person_id)) show_error('person id is not numeric!'); @@ -151,13 +153,11 @@ class InfoCenter extends Auth_Controller if (empty($personexists->retval)) show_error('person does not exist!'); - $show_lock_link_get = $this->input->get('show_lock_link'); - $show_lock_link = !isset($show_lock_link_get) || $show_lock_link_get === '1'; - - if ($show_lock_link) + $origin_page = $this->input->get('origin_page'); + if ($origin_page == 'index') { - //mark person as locked for editing - $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + // mark person as locked for editing + $result = $this->PersonLockModel->lockPerson($person_id, $this->_uid, self::APP); if (isError($result)) show_error($result->retval); @@ -168,11 +168,11 @@ class InfoCenter extends Auth_Controller $data = array_merge( $persondata, - $prestudentdata, - array('show_lock_link' => $show_lock_link) + $prestudentdata ); - $data['fhc_controller_id'] = $this->fhc_controller_id; + $data['fhc_controller_id'] = $this->getControllerId(); + $data['origin_page'] = $origin_page; $this->load->view('system/infocenter/infocenterDetails.php', $data); } @@ -188,7 +188,7 @@ class InfoCenter extends Auth_Controller if (isError($result)) show_error($result->retval); - redirect(self::URL_PREFIX.'?fhc_controller_id='.$this->fhc_controller_id); + redirect(self::URL_PREFIX.'?fhc_controller_id='.$this->getControllerId()); } /** @@ -334,7 +334,6 @@ class InfoCenter extends Auth_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); @@ -356,7 +355,7 @@ class InfoCenter extends Auth_Controller 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, 'status_kurzbz' => 'Abgewiesener', 'statusgrund_id' => $statusgrund, - 'insertvon' => $this->uid, + 'insertvon' => $this->_uid, 'insertamum' => date('Y-m-d H:i:s') ) ); @@ -412,9 +411,9 @@ class InfoCenter extends Auth_Controller 'ausbildungssemester' => $lastStatus->ausbildungssemester ), array( - 'bestaetigtvon' => $this->uid, + 'bestaetigtvon' => $this->_uid, 'bestaetigtam' => date('Y-m-d'), - 'updatevon' => $this->uid, + 'updatevon' => $this->_uid, 'updateamum' => date('Y-m-d H:i:s') ) ); @@ -470,7 +469,7 @@ class InfoCenter extends Auth_Controller $text = $this->input->post('notiz'); $erledigt = false; - $result = $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->uid); + $result = $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->_uid); if (isSuccess($result)) { @@ -498,9 +497,9 @@ class InfoCenter extends Auth_Controller array( 'titel' => $titel, 'text' => $text, - 'verfasser_uid' => $this->uid, + 'verfasser_uid' => $this->_uid, "updateamum" => 'NOW()', - "updatevon" => $this->uid + "updatevon" => $this->_uid ) ); @@ -547,6 +546,8 @@ class InfoCenter extends Auth_Controller */ public function outputAkteContent($akte_id) { + $this->load->library('DmsLib'); + $akte = $this->AkteModel->load($akte_id); if (isError($akte)) @@ -590,7 +591,7 @@ class InfoCenter extends Auth_Controller $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); + $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') @@ -640,18 +641,21 @@ class InfoCenter extends Auth_Controller */ private function _setAuthUID() { - $this->uid = getAuthUID(); + $this->_uid = getAuthUID(); - if (!$this->uid) show_error('User authentification failed'); + if (!$this->_uid) show_error('User authentification failed'); } /** - * + * Define the navigation menu for the index page */ - public function setNavigationMenuArray() + public function setNavigationMenuIndex() { + $this->load->library('NavigationLib', array('navigation_page' => 'system/infocenter/InfoCenter/index')); + $listFiltersSent = array(); $listFiltersNotSent = array(); + $listCustomFilters = array(); $filtersSent = $this->FiltersModel->getFilterList('infocenter', 'PersonActions', '%InfoCenterSentApplication%'); if (hasData($filtersSent)) @@ -675,7 +679,7 @@ class InfoCenter extends Auth_Controller } } - $customFilters = $this->FiltersModel->getCustomFiltersList('infocenter', 'PersonActions', $this->uid); + $customFilters = $this->FiltersModel->getCustomFiltersList('infocenter', 'PersonActions', $this->_uid); if (hasData($customFilters)) { for ($filtersCounter = 0; $filtersCounter < count($customFilters->retval); $filtersCounter++) @@ -686,58 +690,139 @@ class InfoCenter extends Auth_Controller } } - $filtersarray = array( - 'abgeschickt' => array( - 'link' => '#', - 'description' => ucfirst($this->p->t('global', 'abgeschickt')), - 'expand' => true, - 'children' => array() - ), - 'nichtabgeschickt' => array( - 'link' => '#', - 'description' => ucfirst($this->p->t('global', 'nichtAbgeschickt')), - 'expand' => true, - 'children' => array() - ) + $filtersArray = array(); + + $filtersArray['abgeschickt'] = $this->navigationlib->oneLevel( + ucfirst($this->p->t('global', 'abgeschickt')), // description + '#', // link + array(), // children + '', // icon + true // expand ); - $this->_fillFilters($listFiltersSent, $filtersarray['abgeschickt']); - $this->_fillFilters($listFiltersNotSent, $filtersarray['nichtabgeschickt']); + $filtersArray['nichtabgeschickt'] = $this->navigationlib->oneLevel( + ucfirst($this->p->t('global', 'nichtAbgeschickt')), // description + '#', // link + array(), // children + '', // icon + true // expand + ); - if (isset($listCustomFilters) && is_array($listCustomFilters) && count($listCustomFilters) > 0) + $this->_fillFilters($listFiltersSent, $filtersArray['abgeschickt']); + $this->_fillFilters($listFiltersNotSent, $filtersArray['nichtabgeschickt']); + + if (count($listCustomFilters) > 0) { - $filtersarray['personal'] = array( - 'link' => '#', - 'description' => 'Personal filters', - 'expand' => true, - 'children' => array() + $filtersArray['personal'] = $this->navigationlib->oneLevel( + 'Personal filters', // description + '#', // link + array(), // children + '', // icon + true // expand ); - $this->_fillCustomFilters($listCustomFilters, $filtersarray['personal']); + $this->_fillCustomFilters($listCustomFilters, $filtersArray['personal']); } - if (!isset($_SESSION['navigation_menu'])) - { - $_SESSION['navigation_menu'] = array(); - } - - $_SESSION['navigation_menu']['system/infocenter/InfoCenter/index'] = array( - 'filters' => array( - 'link' => '#', - 'description' => 'Filter', - 'icon' => 'filter', - 'expand' => true, - 'children' => $filtersarray + $this->navigationlib->setSessionMenu( + array( + 'filters' => $this->navigationlib->oneLevel( + 'Filter', // description + '#', // link + $filtersArray, // children + '', // icon + true // expand + ) ) ); + } - $_SESSION['navigation_menu']['system/infocenter/InfoCenter/showDetails'] = array( - 'filters' => array( - 'link' => '#', - 'description' => 'Filter', - 'icon' => 'filter', - 'expand' => true, - 'children' => $filtersarray + /** + * Define the navigation menu for the showDetails page + */ + public function setNavigationMenuShowDetails() + { + $this->load->library('NavigationLib', array('navigation_page' => 'system/infocenter/InfoCenter/showDetails')); + + $origin_page = $this->input->get('origin_page'); + + $link = base_url('index.ci.php/system/infocenter/InfoCenter/index'); + if ($origin_page == 'freigegeben') + { + $link = base_url('index.ci.php/system/infocenter/InfoCenter/freigegeben'); + } + + $this->navigationlib->setSessionMenu( + array( + 'back' => $this->navigationlib->oneLevel( + '<< Züruck', // description + $link, // link + array(), // children + '', // icon + true // expand + ) + ) + ); + } + + /** + * Define the navigation menu for the freigegeben page + */ + public function setNavigationMenuFreigegeben() + { + $this->load->library('NavigationLib', array('navigation_page' => 'system/infocenter/InfoCenter/freigegeben')); + + $listFilters = array(); + $listCustomFilters = array(); + + $filters = $this->FiltersModel->getFilterList('infocenter', 'PersonActions', '%InfoCenterFreigegeben%'); + if (hasData($filters)) + { + for ($filtersCounter = 0; $filtersCounter < count($filters->retval); $filtersCounter++) + { + $filter = $filters->retval[$filtersCounter]; + + $listFilters[$filter->filter_id] = $filter->description[0]; + } + } + + $customFilters = $this->FiltersModel->getCustomFiltersList('infocenter', 'PersonActions', $this->_uid); + if (hasData($customFilters)) + { + for ($filtersCounter = 0; $filtersCounter < count($customFilters->retval); $filtersCounter++) + { + $filter = $customFilters->retval[$filtersCounter]; + + $listCustomFilters[$filter->filter_id] = $filter->description[0]; + } + } + + $filtersArray = array(); + + $this->_fillFiltersFreigegeben($listFilters, $filtersArray); + + if (count($listCustomFilters) > 0) + { + $filtersArray['children']['personal'] = $this->navigationlib->oneLevel( + 'Personal filters', // description + '#', // link + array(), // children + '', // icon + true // expand + ); + + $this->_fillCustomFilters($listCustomFilters, $filtersArray['children']['personal']); + } + + $this->navigationlib->setSessionMenu( + array( + 'filters' => $this->navigationlib->oneLevel( + 'Filter', // description + '#', // link + $filtersArray['children'], // children + '', // icon + true // expand + ) ) ); } @@ -747,21 +832,51 @@ class InfoCenter extends Auth_Controller */ public function setNavigationMenuArrayJson() { - $this->setNavigationMenuArray(); + $navigation_page = $this->input->get('navigation_page'); - $this->output - ->set_content_type('application/json') - ->set_output(json_encode(success('success'))); + if (strpos($navigation_page, 'index') !== false) + { + $this->setNavigationMenuIndex(); + } + else + { + $this->setNavigationMenuFreigegeben(); + } + + $this->outputJsonSuccess('success'); } private function _fillFilters($filters, &$tofill) { + $toPrint = "%s?%s=%s&%s=%s"; + foreach ($filters as $filterId => $description) { - $toPrint = "%s?%s=%s"; - $tofill['children'][] = array( - 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId), + 'link' => sprintf( + $toPrint, + site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId, + FHC_Controller::FHC_CONTROLLER_ID, + $this->getControllerId() + ), + 'description' => $description + ); + } + } + + private function _fillFiltersFreigegeben($filters, &$tofill) + { + $toPrint = "%s?%s=%s&%s=%s"; + + foreach ($filters as $filterId => $description) + { + $tofill['children'][] = array( + 'link' => sprintf( + $toPrint, + site_url('system/infocenter/InfoCenter/freigegeben'), 'filter_id', $filterId, + FHC_Controller::FHC_CONTROLLER_ID, + $this->getControllerId() + ), 'description' => $description ); } @@ -769,12 +884,17 @@ class InfoCenter extends Auth_Controller private function _fillCustomFilters($filters, &$tofill) { + $toPrint = "%s?%s=%s&%s=%s"; + foreach ($filters as $filterId => $description) { - $toPrint = "%s?%s=%s"; - $tofill['children'][] = array( - 'link' => sprintf($toPrint, site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId), + 'link' => sprintf( + $toPrint, + site_url('system/infocenter/InfoCenter'), 'filter_id', $filterId, + FHC_Controller::FHC_CONTROLLER_ID, + $this->getControllerId() + ), 'description' => $description, 'subscriptDescription' => 'Remove', 'subscriptLinkClass' => 'remove-custom-filter', @@ -805,7 +925,7 @@ class InfoCenter extends Auth_Controller if (isset($locked->retval[0]->uid)) { $lockedby = $locked->retval[0]->uid; - if ($lockedby !== $this->uid) + if ($lockedby !== $this->_uid) $lockedbyother = true; } @@ -856,7 +976,7 @@ class InfoCenter extends Auth_Controller show_error($notizen_bewerbung->retval); } - $user_person = $this->PersonModel->getByUid($this->uid); + $user_person = $this->PersonModel->getByUid($this->_uid); if (isError($user_person)) { @@ -965,7 +1085,7 @@ class InfoCenter extends Auth_Controller $this->PrestudentModel->addSelect('person_id'); $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; - redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'?fhc_controller_id='.$this->fhc_controller_id.'#'.$section); + redirect(self::URL_PREFIX.'/showDetails?person_id='.$person_id.'&fhc_controller_id='.$this->getControllerId().'#'.$section); } /** @@ -1016,7 +1136,7 @@ class InfoCenter extends Auth_Controller self::TAETIGKEIT, self::APP, null, - $this->uid + $this->_uid ); } diff --git a/application/helpers/session_helper.php b/application/helpers/session_helper.php new file mode 100644 index 000000000..e74468896 --- /dev/null +++ b/application/helpers/session_helper.php @@ -0,0 +1,88 @@ +_ci =& get_instance(); + $this->_ci =& get_instance(); // get code igniter instance // Loads helper message to manage returning messages $this->_ci->load->helper('message'); + // Loads helper session to manage the php session + $this->_ci->load->helper('session'); $this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget } @@ -137,27 +139,19 @@ class FiltersLib } /** - * Returns the whole session for this filter widget if found, otherwise null + * Wrapper method to the session helper funtions to retrive the whole session for this filter */ 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; + return getElementSession(self::SESSION_NAME, $this->_filterUniqueId); } /** - * Returns one element from the session of this filter widget, otherwise null + * Wrapper method to the session helper funtions to retrive one element from the session of this filter */ public function getElementSession($name) { - $session = $this->getSession(); // get the whole session for this filter + $session = getElementSession(self::SESSION_NAME, $this->_filterUniqueId); if (isset($session[$name])) { @@ -168,41 +162,23 @@ class FiltersLib } /** - * Sets the whole session for this filter widget + * Wrapper method to the session helper funtions to set the whole session for this filter */ 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 + setElementSession(self::SESSION_NAME, $this->_filterUniqueId, $data); } /** - * Sets one element of the session of this filter widget + * Wrapper method to the session helper funtions to set one element in the session for this filter */ 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 - } + $session = getElementSession(self::SESSION_NAME, $this->_filterUniqueId); - // 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[$name] = $value; - $_SESSION[self::SESSION_NAME][$this->_filterUniqueId][$name] = $value; // stores the single value + setElementSession(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value } /** @@ -311,7 +287,7 @@ class FiltersLib */ public function generateDatasetQuery($query, $filters) { - $datasetQuery = null; + $datasetQuery = 'SELECT * FROM ('.$query.') '.self::DATASET_TABLE_ALIAS; // If the given query is valid and the parameter filters is an array if (!empty(trim($query)) && $filters != null && is_array($filters)) @@ -334,7 +310,7 @@ class FiltersLib if ($where != '') // if the SQL where clause was built { - $datasetQuery = 'SELECT * FROM ('.$query.') '.self::DATASET_TABLE_ALIAS.' WHERE '.$where; + $datasetQuery .= ' WHERE '.$where; } } diff --git a/application/libraries/NavigationLib.php b/application/libraries/NavigationLib.php new file mode 100644 index 000000000..4d2187e04 --- /dev/null +++ b/application/libraries/NavigationLib.php @@ -0,0 +1,353 @@ +_ci =& get_instance(); // get code igniter instance + + // Loads navigation configs + $this->_ci->config->load('navigation'); + + // Loads helper message to manage returning messages + $this->_ci->load->helper('message'); + // Loads helper session to manage the php session + $this->_ci->load->helper('session'); + + // Loads library ExtensionsLib + $this->_ci->load->library('ExtensionsLib'); + + $this->_navigationPage = $this->_getNavigationtPage($params); // sets the id for the related navigation widget + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Creates the left Menu for each Page + * @param navigation_widget_called GET Parameter witch holds the currently called Page + * @return array with the Menu Entries + */ + public function getMenuArray($navigationPage) + { + $menuArray = array(); + + if (isset($navigationPage)) + { + // Get Menu Entries of the Core + $navigationMenuArray = $this->_ci->config->item(self::CONFIG_MENU_NAME); + $menuArray = $this->_wildcardsearch($navigationMenuArray, $navigationPage); + + // Load Menu Entries of Extensions + $extensions = $this->_ci->extensionslib->getInstalledExtensions(); + if(hasData($extensions)) + { + $json_extension = array(); + foreach($extensions->retval as $ext) + { + $filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME; + if (file_exists($filename)) + { + unset($config); + include($filename); + if(isset($config[self::CONFIG_MENU_NAME]) && is_array($config[self::CONFIG_MENU_NAME])) + { + $json_extension = array_merge_recursive( + $json_extension, + $this->_wildcardsearch($config[self::CONFIG_MENU_NAME], + $navigationPage) + ); + } + } + } + // Merge Extension Menuentries with the Core Entries + $menuArray = array_merge_recursive($menuArray, $json_extension); + } + + // Load dynamic Menu Entries from Session + if (($navigationMenuSessionArray = $this->getSessionMenu()) != null) + { + if (isset($navigationMenuSessionArray) && is_array($navigationMenuSessionArray)) + { + $menuArray = array_merge_recursive($menuArray, $navigationMenuSessionArray); + } + } + } + + return $menuArray; + } + + /** + * Creates the Top Menu for each Page + * @param navigation_widget_called GET Parameter witch holds the currently called Page + * @return array with the Menu Entries + */ + public function getHeaderArray($navigationPage) + { + $headerArray = array(); + + if (isset($navigationPage)) + { + // Load Header Entries of Core + $navigationHeaderArray = $this->_ci->config->item(self::CONFIG_HEADER_NAME); + $headerArray = $this->_wildcardsearch($navigationHeaderArray, $navigationPage); + + // Load Header Entries of Extensions + $extensions = $this->_ci->extensionslib->getInstalledExtensions(); + if(hasData($extensions)) + { + $headerArray_extension = array(); + foreach($extensions->retval as $ext) + { + $filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME; + if (file_exists($filename)) + { + unset($config); + include($filename); + if(isset($config[self::CONFIG_HEADER_NAME]) && is_array($config[self::CONFIG_HEADER_NAME])) + { + $headerArray_extension = array_merge_recursive( + $json_extension, + $this->_wildcardsearch($config[self::CONFIG_HEADER_NAME], + $navigationPage) + ); + } + } + } + $headerArray = array_merge_recursive($headerArray, $headerArray_extension); + } + + // Load dynamic Header Entries from Session + if (($navigationHeaderSessionArray = $this->getSessionHeader()) != null) + { + if (isset($navigationHeaderSessionArray) && is_array($navigationHeaderSessionArray)) + { + $headerArray = array_merge_recursive($headerArray, $navigationHeaderSessionArray); + } + } + } + + return $headerArray; + } + + /** + * Returns the structure for one level of the menu + */ + public function oneLevel( + $description, $link = '#', $children = null, $icon = '', $expand = false, + $subscriptDescription = null, $subscriptLinkClass = null, $subscriptLinkValue = null) + { + return array( + 'description' => $description, + 'link' => $link, + 'children'=> $children, + 'icon' => $icon, + 'expand' => $expand, + 'subscriptDescription' => $subscriptDescription, + 'subscriptLinkClass' => $subscriptLinkClass, + 'subscriptLinkValue' => $subscriptLinkValue + ); + } + + /** + * Wrapper method to the session helper funtions to retrive the whole session for this navigation widget + */ + public function getSessionMenu() + { + $session = getElementSession(self::SESSION_NAME, self::SESSION_MENU_NAME); + + if (isset($session[$this->_navigationPage])) + { + return $session[$this->_navigationPage]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to retrive the whole session for this navigation widget + */ + public function getSessionHeader() + { + $session = getElementSession(self::SESSION_NAME, self::SESSION_HEADER_NAME); + + if (isset($session[$this->_navigationPage])) + { + return $session[$this->_navigationPage]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to retrive one element from the session of this navigation widget + */ + public function getElementSessionMenu($name) + { + $session = $this->getSessionMenu(); + + if (isset($session[$name])) + { + return $session[$name]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to retrive one element from the session of this navigation widget + */ + public function getElementSessionHeader($name) + { + $session = $this->getSessionHeader(); + + if (isset($session[$name])) + { + return $session[$name]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to set the whole session for this navigation widget + */ + public function setSessionMenu($data) + { + setElementSession(self::SESSION_NAME, self::SESSION_MENU_NAME, array($this->_navigationPage => $data)); + } + + /** + * Wrapper method to the session helper funtions to set the whole session for this navigation widget + */ + public function setSessionHeader($data) + { + setElementSession(self::SESSION_NAME, self::SESSION_HEADER_NAME, array($this->_navigationPage => $data)); + } + + /** + * Wrapper method to the session helper funtions to set one element in the session for this navigation widget + */ + public function setElementSessionMenu($name, $value) + { + $session = $this->getSessionMenu(); + + if (!isset($session[$this->_navigationPage])) + { + $session[$this->_navigationPage] = array(); + } + + $session[$this->_navigationPage][$name] = $value; + + setElementSession(self::SESSION_NAME, self::SESSION_MENU_NAME, $session); // stores the single value + } + + /** + * Wrapper method to the session helper funtions to set one element in the session for this navigation widget + */ + public function setElementSessionHeader($name, $value) + { + $session = $this->getSessionHeader(); + + if (!isset($session[$this->_navigationPage])) + { + $session[$this->_navigationPage] = array(); + } + + $session[$this->_navigationPage][$name] = $value; + + setElementSession(self::SESSION_NAME, self::SESSION_HEADER_NAME, $session); // stores the single value + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Searches a Menuentry. If there is no exact entry it searches for Wildcard Entries with a Star + * Example: + * Searching for /system/foo/index will Match the following Menuentries: + * /system/foo/index + * /system/foo/* + * /system/* + * * + * + * @param $navigationArray Array to Search in. + * @param $navigationPage Navigation to search for. + * @return Navigation Array if found, empty array otherwise + */ + private function _wildcardsearch($navigationArray, $navigationPage) + { + // Sort Navigation to have them in correct order + krsort($navigationArray); + + // 100% match found + if(isset($navigationArray[$navigationPage])) + { + return $navigationArray[$navigationPage]; + } + else + { + foreach($navigationArray as $key=>$row) + { + // Search for * Entries + if(mb_strpos($key, '*') === 0 || mb_strpos($key, '*') === mb_strlen($key) - 1) + { + // Take * Entry if Matches + $search = mb_substr($key, 0, -1); + if($search == '' || mb_strpos($navigationPage, $search) === 0) + { + return $row; + } + } + } + } + + return array(); + } + + /** + * Return an unique string that identify this navigation widget + * NOTE: The default value is the URI where the NavigationWidget is called + */ + private function _getNavigationtPage($params) + { + // + if ($params != null + && is_array($params) + && isset($params[self::NAVIGATION_PAGE_PARAM]) + && !empty(trim($params[self::NAVIGATION_PAGE_PARAM]))) + { + $navigationPage = $params[self::NAVIGATION_PAGE_PARAM]; + } + else + { + // Gets the current page URI + $navigationPage = $this->_ci->router->directory.$this->_ci->router->class.'/'.$this->_ci->router->method; + } + + return $navigationPage; + } +} diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php index eb81dbb32..20ab6419e 100644 --- a/application/models/system/Filters_model.php +++ b/application/models/system/Filters_model.php @@ -13,7 +13,7 @@ class Filters_model extends DB_Model } /** - * + * Loads a filter by its app, dataset_name and filter_kurzbz */ public function getFilterList($app, $dataset_name, $filter_kurzbz) { @@ -24,7 +24,6 @@ class Filters_model extends DB_Model 'app' => $app, 'dataset_name' => $dataset_name, 'person_id' => null, - 'default_filter' => false, 'array_length(description, 1) >' => 0, 'filter_kurzbz ILIKE' => $filter_kurzbz ); @@ -33,7 +32,7 @@ class Filters_model extends DB_Model } /** - * + * Loads a custom filter by its app, dataset_name and the uid of the owner */ public function getCustomFiltersList($app, $dataset_name, $uid) { @@ -50,12 +49,4 @@ class Filters_model extends DB_Model return $this->loadWhere($filterParametersArray); } - - /** - * - */ - public function deleteCustomFilter($filter_id) - { - return $this->delete($filter_id); - } } diff --git a/application/views/system/infocenter/dokpruefung.php b/application/views/system/infocenter/dokpruefung.php index b7fbbd4a7..fae23c48b 100644 --- a/application/views/system/infocenter/dokpruefung.php +++ b/application/views/system/infocenter/dokpruefung.php @@ -16,7 +16,7 @@ ?>