refactoring

This commit is contained in:
Roland Gruber 2019-10-06 11:13:44 +02:00
parent 0240dec74e
commit ff8fd47bed
5 changed files with 81 additions and 51 deletions

View File

@ -1381,8 +1381,12 @@ class LAMConfig {
* @return boolean true if $value has correct format * @return boolean true if $value has correct format
*/ */
public function set_defaultLanguage($value) { public function set_defaultLanguage($value) {
if (is_string($value)) $this->defaultLanguage = $value; if (is_string($value)) {
else return false; $this->defaultLanguage = $value;
}
else {
return false;
}
return true; return true;
} }
@ -1425,9 +1429,15 @@ class LAMConfig {
* @return boolean true if $value has correct format * @return boolean true if $value has correct format
*/ */
public function set_scriptPath($value) { public function set_scriptPath($value) {
if (!$value) $this->scriptPath = ""; // optional parameter if (!$value) {
elseif (is_string($value) && preg_match("/^\\/([a-z0-9_-])+(\\/([a-z0-9_\\.-])+)+$/i", $value)) $this->scriptPath = $value; $this->scriptPath = ""; // optional parameter
else return false; }
elseif (is_string($value) && preg_match("/^\\/([a-z0-9_-])+(\\/([a-z0-9_\\.-])+)+$/i", $value)) {
$this->scriptPath = $value;
}
else {
return false;
}
return true; return true;
} }
@ -1502,7 +1512,9 @@ class LAMConfig {
* @return string rights * @return string rights
*/ */
public function get_scriptRights() { public function get_scriptRights() {
if (!isset($this->scriptRights)) return '755'; if (!isset($this->scriptRights)) {
return '755';
}
return $this->scriptRights; return $this->scriptRights;
} }
@ -1583,8 +1595,12 @@ class LAMConfig {
* @return integer cache time * @return integer cache time
*/ */
public function get_cacheTimeout() { public function get_cacheTimeout() {
if (isset($this->cachetimeout)) return $this->cachetimeout; if (isset($this->cachetimeout)) {
else return 5; return $this->cachetimeout;
}
else {
return 5;
}
} }
/** /**
@ -1606,7 +1622,9 @@ class LAMConfig {
if (is_numeric($value) && ($value > -1)) { if (is_numeric($value) && ($value > -1)) {
$this->cachetimeout = $value; $this->cachetimeout = $value;
} }
else return false; else {
return false;
}
return true; return true;
} }
@ -1663,15 +1681,21 @@ class LAMConfig {
* @return boolean true if $modules has correct format * @return boolean true if $modules has correct format
*/ */
public function set_AccountModules($modules, $scope) { public function set_AccountModules($modules, $scope) {
if (! is_array($modules)) return false; if (!is_array($modules)) {
return false;
}
// check module names // check module names
$available = getAvailableModules($scope); $available = getAvailableModules($scope);
for ($i = 0; $i < sizeof($modules); $i++) { for ($i = 0; $i < sizeof($modules); $i++) {
if (! in_array($modules[$i], $available)) return false; if (! in_array($modules[$i], $available)) return false;
} }
// check depends/conflicts // check depends/conflicts
if (check_module_conflicts($modules, getModulesDependencies($scope)) != false) return false; if (check_module_conflicts($modules, getModulesDependencies($scope))) {
if (check_module_depends($modules, getModulesDependencies($scope)) != false) return false; return false;
}
if (check_module_depends($modules, getModulesDependencies($scope))) {
return false;
}
$this->typeSettings["modules_" . $scope] = implode(",", $modules); $this->typeSettings["modules_" . $scope] = implode(",", $modules);
return true; return true;
} }
@ -1683,7 +1707,9 @@ class LAMConfig {
* @return boolean true if $settings has correct format * @return boolean true if $settings has correct format
*/ */
public function set_moduleSettings($settings) { public function set_moduleSettings($settings) {
if (!is_array($settings)) return false; if (!is_array($settings)) {
return false;
}
$this->moduleSettings = $settings; $this->moduleSettings = $settings;
return true; return true;
} }
@ -1703,8 +1729,12 @@ class LAMConfig {
* @return array list of types * @return array list of types
*/ */
public function get_ActiveTypes() { public function get_ActiveTypes() {
if (($this->activeTypes == '') || !isset($this->activeTypes)) return array(); if (($this->activeTypes == '') || !isset($this->activeTypes)) {
else return explode(",", $this->activeTypes); return array();
}
else {
return explode(",", $this->activeTypes);
}
} }
/** /**
@ -1723,7 +1753,9 @@ class LAMConfig {
* @return boolean true if $settings has correct format * @return boolean true if $settings has correct format
*/ */
public function set_typeSettings($settings) { public function set_typeSettings($settings) {
if (!is_array($settings)) return false; if (!is_array($settings)) {
return false;
}
$this->typeSettings = $settings; $this->typeSettings = $settings;
return true; return true;
} }
@ -1753,7 +1785,9 @@ class LAMConfig {
* @return boolean true if ok * @return boolean true if ok
*/ */
public function setToolSettings($toolSettings) { public function setToolSettings($toolSettings) {
if (!is_array($toolSettings)) return false; if (!is_array($toolSettings)) {
return false;
}
$this->toolSettings = $toolSettings; $this->toolSettings = $toolSettings;
return true; return true;
} }
@ -2553,11 +2587,15 @@ class LAMCfgMain {
private function reload() { private function reload() {
if (is_file($this->conffile) == True) { if (is_file($this->conffile) == True) {
$file = @fopen($this->conffile, "r"); $file = @fopen($this->conffile, "r");
if (!$file) return false; // abort if file is not readable if (!$file) {
return false; // abort if file is not readable
}
while (!feof($file)) { while (!feof($file)) {
$line = fgets($file, 1024); $line = fgets($file, 1024);
$line = trim($line); // remove spaces at the beginning and end $line = trim($line); // remove spaces at the beginning and end
if (($line == "")||($line[0] == "#")) continue; // ignore comments if (($line == "")||($line[0] == "#")) {
continue; // ignore comments
}
// search keywords // search keywords
for ($i = 0; $i < sizeof($this->settings); $i++) { for ($i = 0; $i < sizeof($this->settings); $i++) {
$keyword = $this->settings[$i]; $keyword = $this->settings[$i];
@ -2577,7 +2615,7 @@ class LAMCfgMain {
* Saves preferences to config file config.cfg * Saves preferences to config file config.cfg
*/ */
public function save() { public function save() {
if (is_file($this->conffile) == True) { if (is_file($this->conffile)) {
$file = fopen($this->conffile, "r"); $file = fopen($this->conffile, "r");
$file_array = array(); $file_array = array();
// read config file // read config file
@ -2589,7 +2627,9 @@ class LAMCfgMain {
$saved = array(); $saved = array();
for ($i = 0; $i < sizeof($file_array); $i++) { for ($i = 0; $i < sizeof($file_array); $i++) {
$line = trim($file_array[$i]); $line = trim($file_array[$i]);
if (($line == "")||($line[0] == "#")) continue; // ignore comments and empty lines if (($line == "")||($line[0] == "#")) {
continue; // ignore comments and empty lines
}
// search keywords // search keywords
for ($k = 0; $k < sizeof($this->settings); $k++) { for ($k = 0; $k < sizeof($this->settings); $k++) {
$keyword = $this->settings[$k]; $keyword = $this->settings[$k];

View File

@ -383,7 +383,7 @@ class asteriskExtension extends baseModule {
* @param String $on key * @param String $on key
* @param String $order order (SORT_ASC or SORT_DESC) * @param String $order order (SORT_ASC or SORT_DESC)
*/ */
function array_sort($array, $on, $order='SORT_ASC') { private function array_sort($array, $on, $order='SORT_ASC') {
$new_array = array(); $new_array = array();
$sortable_array = array(); $sortable_array = array();
@ -399,16 +399,12 @@ class asteriskExtension extends baseModule {
$sortable_array[$k] = $v; $sortable_array[$k] = $v;
} }
} }
if ($order === 'SORT_ASC') {
switch ($order) {
case 'SORT_ASC':
asort($sortable_array); asort($sortable_array);
break;
case 'SORT_DESC':
arsort($sortable_array);
break;
} }
else {
arsort($sortable_array);
}
foreach ($sortable_array as $k => $v) { foreach ($sortable_array as $k => $v) {
$new_array[] = $array[$k]; $new_array[] = $array[$k];
} }

View File

@ -226,8 +226,6 @@ class group extends baseType {
*/ */
class lamGroupList extends lamList { class lamGroupList extends lamList {
/** Controls if include primary group members into group memebers */
private $use_primary = false;
/** Primary group members hash */ /** Primary group members hash */
private $primary_hash = array(); private $primary_hash = array();
/** Controls if primary group members needs refresh */ /** Controls if primary group members needs refresh */
@ -309,7 +307,9 @@ class lamGroupList extends lamList {
(sizeof($this->primary_hash[$gid]) > 0)); (sizeof($this->primary_hash[$gid]) > 0));
} }
if (!$use_primary) { if (!$use_primary) {
if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return; if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) {
return;
}
// sort array // sort array
sort($entry[$attribute]); sort($entry[$attribute]);
} }

View File

@ -8,9 +8,6 @@
*/ */
/** basic grid */ /** basic grid */
html, body {
height: 100%;
}
*, *,
*:before, *:before,
@ -22,13 +19,12 @@ html, body {
html { html {
font-size: 100%; font-size: 100%;
height: 100%;
} }
body { body {
height: 100%;
font-size: 100%; font-size: 100%;
}
body {
cursor: auto; cursor: auto;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
font-style: normal; font-style: normal;

View File

@ -497,15 +497,13 @@ function dryRun() {
* @param int $errline error line * @param int $errline error line
*/ */
function multiEditLdapErrorHandler($errno, $errstr, $errfile, $errline) { function multiEditLdapErrorHandler($errno, $errstr, $errfile, $errline) {
switch ($errno) { if ($errno === E_USER_ERROR) {
case E_USER_ERROR:
logNewMessage(LOG_ERR, 'Error occured: ' . $errstr . " ($errfile: $errline)"); logNewMessage(LOG_ERR, 'Error occured: ' . $errstr . " ($errfile: $errline)");
$_REQUEST['multiEdit_error'] = true; $_REQUEST['multiEdit_error'] = true;
break; }
case E_USER_WARNING: elseif ($errno === E_USER_WARNING) {
logNewMessage(LOG_WARNING, 'Error occured: ' . $errstr . " ($errfile: $errline)"); logNewMessage(LOG_WARNING, 'Error occured: ' . $errstr . " ($errfile: $errline)");
$_REQUEST['multiEdit_error'] = true; $_REQUEST['multiEdit_error'] = true;
break;
} }
} }