diff --git a/application/config/routes.php b/application/config/routes.php index b139c6fa3..15da5698f 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -67,21 +67,19 @@ $dirlist = scandir($subdir); if ($dirlist) { - $files = array_diff($dirlist, array('.','..')); + $files = array_diff($dirlist, array('.','..')); - foreach ($files as &$item) - { + foreach ($files as &$item) + { + if (is_dir($subdir . DIRECTORY_SEPARATOR . $item)) + { + $routes_file = $subdir . DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . 'routes.php'; - if (is_dir($subdir . DIRECTORY_SEPARATOR . $item)) - { - $routes_file = $subdir . DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . 'routes.php'; - - if (file_exists($routes_file)) - { - require($routes_file); - } - - } - - } + if (file_exists($routes_file)) + { + require($routes_file); + } + } + } } + diff --git a/application/controllers/person/Gruppenmanagement.php b/application/controllers/person/Gruppenmanagement.php index 4bc80c760..acf32b00b 100644 --- a/application/controllers/person/Gruppenmanagement.php +++ b/application/controllers/person/Gruppenmanagement.php @@ -77,8 +77,8 @@ class Gruppenmanagement extends Auth_Controller } /** - * Gets Benutzer assigned to a Gruppe - */ + * Gets Benutzer assigned to a Gruppe + */ public function getBenutzer() { $gruppe_kurzbz = $this->input->get('gruppe_kurzbz'); @@ -92,8 +92,8 @@ class Gruppenmanagement extends Auth_Controller } /** - * Gets all Benutzer for assignment to Gruppe - */ + * Gets all Benutzer for assignment to Gruppe + */ public function getAllBenutzer() { $this->BenutzerModel->addSelect('uid, vorname, nachname'); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index ab67d70a1..913d29b54 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -1,20 +1,19 @@ . */ if (! defined('BASEPATH')) exit('No direct script access allowed'); @@ -42,15 +41,19 @@ function generateToken($length = 64) { $firstGeneratedToken = random_bytes($length); // try to generates cryptographically secure pseudo-random bytes... } - catch (Exception $e) { $firstGeneratedToken = null; } // if fails $firstGeneratedToken is set to null + catch (Exception $e) + { + // If fails $firstGeneratedToken is set to null + $firstGeneratedToken = null; + } } // For PHP >= 5.3 and < 7 and openssl is available elseif (function_exists('openssl_random_pseudo_bytes')) { $firstGeneratedToken = openssl_random_pseudo_bytes($length, $strong); // If the token generation ended with errors OR the generated token is NOT strong enough - if ($firstGeneratedToken == false || $strong == false) $firstGeneratedToken = null; // $firstGeneratedToken is set to null - } + if ($firstGeneratedToken == false || $strong == false) $firstGeneratedToken = null; // $firstGeneratedToken is set to null + } if ($firstGeneratedToken != null) // If everything was fine { @@ -107,10 +110,7 @@ function var_dump_to_error_log($parameter) function loadResource($path, $resources = null, $subdir = false) { // Place a / character at the and of the string if not present - if (strrpos($path, '/') < strlen($path) - 1) - { - $path .= '/'; - } + if (strrpos($path, '/') < strlen($path) - 1) $path .= '/'; // Loads in $tmpResources all the given resources $tmpResources = $resources; @@ -125,28 +125,36 @@ function loadResource($path, $resources = null, $subdir = false) // Loads in $tmpPaths path and eventually the subdirectories $tmpPaths = array($path); - // NOTE: Used @ to prevent ugly error messages - if (is_dir($path) && ($dirHandler = @opendir($path)) !== false) + + // If path is a directory + if (is_dir($path)) { - // Reads all file system entries present in path - while (($entry = readdir($dirHandler)) !== false) + // NOTE: Used @ to prevent ugly error messages + $dirHandler = @opendir($path); + + // Successfully opened + if ($dirHandler !== false) { - // If entry is a directory but not the current and subdirectories should be loaded - if ($subdir === true && $entry != '.' && $entry != '..' && is_dir($path.$entry)) + // Reads all file system entries present in path + while (($entry = readdir($dirHandler)) !== false) { - $tmpPaths[] = $path.$entry.'/'; - } - // If no resources are specified and the current file system entry is a file - if ($resources == null && is_file($path.$entry)) - { - // If the current entry is a php file store the name without extension - if ($entry != ($tmpName = str_replace('.php', '', $entry))) + // If entry is a directory but not the current and subdirectories should be loaded + if ($subdir === true && $entry != '.' && $entry != '..' && is_dir($path.$entry)) { - $tmpResources[] = $tmpName; + $tmpPaths[] = $path.$entry.'/'; + } + // If no resources are specified and the current file system entry is a file + if ($resources == null && is_file($path.$entry)) + { + // Name without php extension + $tmpName = str_replace('.php', '', $entry); + + // If the current entry is a php file store the name without extension + if ($entry != $tmpName) $tmpResources[] = $tmpName; } } + closedir($dirHandler); } - closedir($dirHandler); } // Loops through the resources @@ -156,10 +164,7 @@ function loadResource($path, $resources = null, $subdir = false) foreach ($tmpPaths as $tmpPath) { $fileName = $tmpPath.$tmpResource.'.php'; // Php extension - if (file_exists($fileName)) - { - include_once($fileName); - } + if (file_exists($fileName)) include_once($fileName); } } } @@ -362,36 +367,39 @@ function findResource($path, $resource, $subdir = false, $extraDir = null) // Loads in $tmpPaths path and eventually the subdirectories $tmpPaths = array($path); - // NOTE: Used @ to prevent ugly error messages - if (is_dir($path) && ($dirHandler = @opendir($path)) !== false) + if (is_dir($path)) { - // Reads all file system entries present in path - while (($entry = readdir($dirHandler)) !== false) + // NOTE: Used @ to prevent ugly error messages + $dirHandler = @opendir($path); + + // Successfully opened + if ($dirHandler !== false) { - // If entry is a directory but not the current and subdirectories should be loaded - if ($subdir === true && $entry != '.' && $entry != '..' && is_dir($path.$entry)) + // Reads all file system entries present in path + while (($entry = readdir($dirHandler)) !== false) { - if ($extraDir == null) + // If entry is a directory but not the current and subdirectories should be loaded + if ($subdir === true && $entry != '.' && $entry != '..' && is_dir($path.$entry)) { - $tmpPaths[] = $path.$entry.'/'; - } - else - { - $tmpPaths[] = $path.$entry.'/'.$extraDir.'/'; + if ($extraDir == null) + { + $tmpPaths[] = $path.$entry.'/'; + } + else + { + $tmpPaths[] = $path.$entry.'/'.$extraDir.'/'; + } } } + closedir($dirHandler); } - closedir($dirHandler); } // Loops through the paths foreach ($tmpPaths as $tmpPath) { $fileName = $tmpPath.$resource.'.php'; // Php extension - if (file_exists($fileName)) - { - return $fileName; - } + if (file_exists($fileName)) return $fileName; } return null; diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 5d197e3be..05bba48c4 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -181,16 +181,26 @@ function generateAddonsJSsInclude($calledFrom) { $aktive_addons = array_filter(explode(";", ACTIVE_ADDONS)); + // For each active addon foreach ($aktive_addons as $addon) { + // Build the path to the hook file $hookfile = DOC_ROOT.'addons/'.$addon.'/hooks.config.inc.php'; + + // If the hook file exists if (file_exists($hookfile)) { - include($hookfile); + $js_hooks = array(); // default value + + include($hookfile); // include the hook file where the array js_hooks should be setup + + // If it contains the provided key calledFrom if (key_exists($calledFrom, $js_hooks)) { foreach ($js_hooks[$calledFrom] as $js_file) + { generateJSsInclude('addons/'.$addon.'/'.$js_file); + } } } } diff --git a/application/libraries/ExtensionsLib.php b/application/libraries/ExtensionsLib.php index f338c942b..77085b182 100644 --- a/application/libraries/ExtensionsLib.php +++ b/application/libraries/ExtensionsLib.php @@ -1,7 +1,25 @@ . + */ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \stdClass as stdClass; + /** * Library to manage core extensions */ @@ -181,17 +199,15 @@ class ExtensionsLib // Select all the version of this extension $this->_ci->ExtensionsModel->addSelect('extension_id'); $result = $this->_ci->ExtensionsModel->loadWhere(array('name' => $extensionName)); - if (hasData($result)) // if something was found + // If something was found + if (hasData($result)) { - $extsArray = array(); - foreach ($result->retval as $key => $extension) // loops on them + // Loops on them + foreach ($result->retval as $extension) { // Remove them all $result = $this->_ci->ExtensionsModel->delete($extension->extension_id); - if (isSuccess($result)) - { - $delExtension = true; - } + if (isSuccess($result)) $delExtension = true; } } } @@ -432,7 +448,11 @@ class ExtensionsLib // If no errors occurred if ($extensionJson != null) { + // Default value + $fhcomplete_version = 0; + require_once('version.php'); // get the core version + // Checks if the required core version of the extension is the same of this system if (isset($extensionJson->core_version) && $extensionJson->core_version == $fhcomplete_version) { @@ -587,18 +607,22 @@ class ExtensionsLib for ($sqlDir = $startVersion; $sqlDir <= $extensionJson->version; $sqlDir++) { // If a directory with the same value of the version is present in the sql scripts directory - if (($files = glob($pkgSQLsPath.'/'.$sqlDir.'/*'.ExtensionsLib::SQL_FILE_EXTENSION)) != false) - { + $files = glob($pkgSQLsPath.'/'.$sqlDir.'/*'.ExtensionsLib::SQL_FILE_EXTENSION); + if ($files != false) + { // Loads every sql files - foreach ($files as $file) - { - $sql = file_get_contents($file); // gets the entire content of the file + foreach ($files as $file) + { + $sql = file_get_contents($file); // gets the entire content of the file $this->_printMessage('Executing query:'); $this->_printMessage($sql); // Try to execute that - if (!isSuccess($result = @$this->_ci->ExtensionsModel->executeQuery($sql))) + $resultQuery = @$this->_ci->ExtensionsModel->executeQuery($sql); + + // If _not_ a success + if (!isSuccess($resultQuery)) { $this->_errorOccurred = true; $this->_printFailure(' error occurred while executing the query'); @@ -608,11 +632,11 @@ class ExtensionsLib else { $this->_printMessage('Query result:'); - var_dump($result->retval); // KEEP IT!!! + var_dump(getData($resultQuery)); // KEEP IT!!! $this->_ci->eprintflib->printEOL(); } - } - } + } + } } $this->_printSuccess(!$this->_errorOccurred); @@ -673,7 +697,7 @@ class ExtensionsLib foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories) { - foreach ($targetDirectories as $key => $targetDirectory) + foreach ($targetDirectories as $targetDirectory) { if (file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName)) { @@ -727,7 +751,7 @@ class ExtensionsLib // For every target directory foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories) { - foreach ($targetDirectories as $key => $targetDirectory) + foreach ($targetDirectories as $targetDirectory) { // If destination of the symlink does not exist if (!file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName)) diff --git a/application/libraries/FilterCmptLib.php b/application/libraries/FilterCmptLib.php index fc7bb036d..429bc1b3b 100644 --- a/application/libraries/FilterCmptLib.php +++ b/application/libraries/FilterCmptLib.php @@ -18,6 +18,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \stdClass as stdClass; + /** * Filter component logic */ @@ -92,8 +94,8 @@ class FilterCmptLib private $_ci; // Code igniter instance private $_filterUniqueId; // Unique id for this filter component - private $_filterType; // - private $_filterId; // + private $_filterType; // + private $_filterId; // private $_app; private $_datasetName; @@ -133,6 +135,8 @@ class FilterCmptLib // if (!$this->_checkJSParameters()) return; + $filterCmptArray = array(); // default value + // $filePath = findResource(APPPATH.'components/filters/', $this->_filterType, true); if (!isEmptyString($filePath)) @@ -147,7 +151,7 @@ class FilterCmptLib } // - if (!isset($filterCmptArray)) + if (!isset($filterCmptArray) && isEmptyArray($filterCmptArray)) { $this->_setSession(error('Component definition file '.$this->_filterType.' not found')); return; @@ -156,7 +160,7 @@ class FilterCmptLib // if (!$this->_checkPHPParameters($filterCmptArray)) return; - // + // $this->_initFilterCmpt($filterCmptArray); // @@ -340,7 +344,8 @@ class FilterCmptLib 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) + $pos = array_search($selectedField, $selectedFields); + if ($pos !== false) { // Then remove it and shift the rest of elements by one if needed array_splice($selectedFields, $pos, 1); @@ -453,7 +458,7 @@ class FilterCmptLib // If not an empty array if ($filterField != null) { - // + // if (isset($filterField->name) && isset($filterField->operation) && isset($filterField->condition) && !isEmptyString($filterField->name) && !isEmptyString($filterField->operation) && !isEmptyString($filterField->condition)) @@ -479,14 +484,14 @@ class FilterCmptLib break; } } - else // + else // { $fine = false; break; } } - // + // if ($fine) { // Write changes into the session @@ -640,9 +645,6 @@ class FilterCmptLib // If filters were loaded if (hasData($filters)) { - $childrenArray = array(); // contains all the children elements in a menu entry - $childrenPersonalArray = array(); // contains all the children elements in menu enty for personal filters - // Loops through loaded filters foreach (getData($filters) as $filter) { @@ -977,12 +979,11 @@ class FilterCmptLib { $columnsNames = array(); - foreach ($columns as $key => $obj) + // For each column + foreach ($columns as $obj) { - if (isset($obj->name)) - { - $columnsNames[] = $obj->name; - } + // If it is set the property name of the column + if (isset($obj->name)) $columnsNames[] = $obj->name; } return $columnsNames; @@ -1209,7 +1210,7 @@ class FilterCmptLib private function _getFilterName($filterJson) { $filterName = $filterJson->name; // always present, used as default - $trimedname = (isset($filterJson->namePhrase)?trim($filterJson->namePhrase):''); + // Filter name from phrases system if (isset($filterJson->namePhrase) && !isEmptyString($filterJson->namePhrase)) { diff --git a/application/libraries/NavigationLib.php b/application/libraries/NavigationLib.php index e2e71c4f1..95ce67610 100644 --- a/application/libraries/NavigationLib.php +++ b/application/libraries/NavigationLib.php @@ -83,9 +83,19 @@ class NavigationLib * 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, $target = '', - $sort = null, $requiredPermissions = null, $subscriptLinkHref = '#') + $description, + $link = '#', + $children = null, + $icon = '', + $expand = false, + $subscriptDescription = null, + $subscriptLinkClass = null, + $subscriptLinkValue = null, + $target = '', + $sort = null, + $requiredPermissions = null, + $subscriptLinkHref = '#' + ) { return array( 'description' => $description, @@ -239,7 +249,8 @@ class NavigationLib $filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME; if (file_exists($filename)) { - unset($config); + $config = array(); // default value + include($filename); if (isset($config[$configName]) && is_array($config[$configName])) @@ -294,7 +305,7 @@ class NavigationLib } else { - foreach ($navigationArray as $key=>$row) + foreach ($navigationArray as $key => $row) { // Search for * Entries if (mb_strpos($key, '*') === 0 || mb_strpos($key, '*') === mb_strlen($key) - 1) diff --git a/application/libraries/SearchBarLib.php b/application/libraries/SearchBarLib.php index 3599f2a73..ff2ae8934 100644 --- a/application/libraries/SearchBarLib.php +++ b/application/libraries/SearchBarLib.php @@ -18,12 +18,14 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \stdClass as stdClass; + /** * */ class SearchBarLib { - // + // Error constats const ERROR_WRONG_JSON = 'ERR001'; const ERROR_WRONG_SEARCHSTR = 'ERR002'; const ERROR_NO_TYPES = 'ERR003'; diff --git a/application/views/lehre/anrechnung/createAnrechnung.php b/application/views/lehre/anrechnung/createAnrechnung.php index 5bd9f015f..e3cc9cad1 100644 --- a/application/views/lehre/anrechnung/createAnrechnung.php +++ b/application/views/lehre/anrechnung/createAnrechnung.php @@ -101,7 +101,7 @@ $this->load->view(