refactoring
This commit is contained in:
parent
c192886117
commit
bd7d32d2d0
|
@ -1400,12 +1400,12 @@ class moduleCache {
|
||||||
* @param String $scope module scope (e.g. user)
|
* @param String $scope module scope (e.g. user)
|
||||||
*/
|
*/
|
||||||
public static function getModule($name, $scope) {
|
public static function getModule($name, $scope) {
|
||||||
if (isset(moduleCache::$cache[$name . ':' . $scope])) {
|
if (isset(self::$cache[$name . ':' . $scope])) {
|
||||||
return moduleCache::$cache[$name . ':' . $scope];
|
return self::$cache[$name . ':' . $scope];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
moduleCache::$cache[$name . ':' . $scope] = new $name($scope);
|
self::$cache[$name . ':' . $scope] = new $name($scope);
|
||||||
return moduleCache::$cache[$name . ':' . $scope];
|
return self::$cache[$name . ':' . $scope];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2011 - 2019 Roland Gruber
|
Copyright (C) 2011 - 2020 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -509,7 +509,7 @@ class freeRadius extends baseModule {
|
||||||
$date = new DateTime('@' . (time() + 3600*24*365), new DateTimeZone('UTC'));
|
$date = new DateTime('@' . (time() + 3600*24*365), new DateTimeZone('UTC'));
|
||||||
$year = $date->format('Y');
|
$year = $date->format('Y');
|
||||||
$month = $date->format('m');
|
$month = $date->format('m');
|
||||||
$month = freeRadius::$monthList[$month];
|
$month = self::$monthList[$month];
|
||||||
$day = $date->format('d');
|
$day = $date->format('d');
|
||||||
$hour = '00';
|
$hour = '00';
|
||||||
$minute = '00';
|
$minute = '00';
|
||||||
|
@ -541,7 +541,7 @@ class freeRadius extends baseModule {
|
||||||
$daySelect = new htmlSelect('expire_day', $dayList, array($day));
|
$daySelect = new htmlSelect('expire_day', $dayList, array($day));
|
||||||
$daySelect->setWidth('3rem');
|
$daySelect->setWidth('3rem');
|
||||||
$dateGroup->addElement($daySelect);
|
$dateGroup->addElement($daySelect);
|
||||||
$monthSelect = new htmlSelect('expire_mon', freeRadius::$monthList, array($month));
|
$monthSelect = new htmlSelect('expire_mon', self::$monthList, array($month));
|
||||||
$monthSelect->setHasDescriptiveElements(true);
|
$monthSelect->setHasDescriptiveElements(true);
|
||||||
$monthSelect->setWidth('3rem');
|
$monthSelect->setWidth('3rem');
|
||||||
$dateGroup->addElement($monthSelect);
|
$dateGroup->addElement($monthSelect);
|
||||||
|
@ -649,7 +649,7 @@ class freeRadius extends baseModule {
|
||||||
if (preg_match('/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4} [0-9]{1,2}:[0-9]{1,2}$/', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']])) {
|
if (preg_match('/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4} [0-9]{1,2}:[0-9]{1,2}$/', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']])) {
|
||||||
$dateParts = explode(' ', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']]);
|
$dateParts = explode(' ', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']]);
|
||||||
$dateParts1 = explode('.', $dateParts[0]);
|
$dateParts1 = explode('.', $dateParts[0]);
|
||||||
$radiusExpiration = str_pad($dateParts1[0], 2, '0', STR_PAD_LEFT) . ' ' . freeRadius::$monthList[str_pad($dateParts1[1], 2, '0', STR_PAD_LEFT)] . ' ' . $dateParts1[2];
|
$radiusExpiration = str_pad($dateParts1[0], 2, '0', STR_PAD_LEFT) . ' ' . self::$monthList[str_pad($dateParts1[1], 2, '0', STR_PAD_LEFT)] . ' ' . $dateParts1[2];
|
||||||
$dateParts2 = explode(':', $dateParts[1]);
|
$dateParts2 = explode(':', $dateParts[1]);
|
||||||
$radiusExpiration .= ' ' . str_pad($dateParts2[0], 2, '0', STR_PAD_LEFT) . ':' . str_pad($dateParts2[1], 2, '0', STR_PAD_LEFT);
|
$radiusExpiration .= ' ' . str_pad($dateParts2[0], 2, '0', STR_PAD_LEFT) . ':' . str_pad($dateParts2[1], 2, '0', STR_PAD_LEFT);
|
||||||
$partialAccounts[$i]['radiusExpiration'] = $radiusExpiration;
|
$partialAccounts[$i]['radiusExpiration'] = $radiusExpiration;
|
||||||
|
@ -750,7 +750,7 @@ class freeRadius extends baseModule {
|
||||||
if (is_null($date) || ($date == '')) {
|
if (is_null($date) || ($date == '')) {
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
foreach (freeRadius::$monthList as $replace => $search) {
|
foreach (self::$monthList as $replace => $search) {
|
||||||
$date = str_replace($search, $replace, $date);
|
$date = str_replace($search, $replace, $date);
|
||||||
}
|
}
|
||||||
$dateParts = explode(' ', $date);
|
$dateParts = explode(' ', $date);
|
||||||
|
|
|
@ -6,7 +6,7 @@ use \LAM\PDF\PDFTableRow;
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2003 - 2006 Tilo Lutz
|
Copyright (C) 2003 - 2006 Tilo Lutz
|
||||||
2007 - 2019 Roland Gruber
|
2007 - 2020 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -193,7 +193,7 @@ class quota extends baseModule {
|
||||||
// get quotas
|
// get quotas
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remote->connect($lamdaemonServer);
|
$remote->connect($lamdaemonServer);
|
||||||
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope())));
|
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope())));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
if (empty($quotas)) {
|
if (empty($quotas)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -201,10 +201,10 @@ class quota extends baseModule {
|
||||||
$allQuotas = explode(":", $quotas);
|
$allQuotas = explode(":", $quotas);
|
||||||
array_pop($allQuotas); // remove empty element at the end
|
array_pop($allQuotas); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($allQuotas); $i++) {
|
for ($i = 0; $i < sizeof($allQuotas); $i++) {
|
||||||
if (strpos($allQuotas[$i], quota::$QUOTA_PREFIX) !== 0) {
|
if (strpos($allQuotas[$i], self::$QUOTA_PREFIX) !== 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$allQuotas[$i] = substr($allQuotas[$i], strlen(quota::$QUOTA_PREFIX));
|
$allQuotas[$i] = substr($allQuotas[$i], strlen(self::$QUOTA_PREFIX));
|
||||||
$singleQuota = explode(",", $allQuotas[$i]);
|
$singleQuota = explode(",", $allQuotas[$i]);
|
||||||
$this->quota[$server][$i] = $singleQuota;
|
$this->quota[$server][$i] = $singleQuota;
|
||||||
if ($this->quota[$server][$i][4] < time()) {
|
if ($this->quota[$server][$i][4] < time()) {
|
||||||
|
@ -295,7 +295,7 @@ class quota extends baseModule {
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
||||||
$remote->connect($remoteServer);
|
$remote->connect($remoteServer);
|
||||||
$remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
|
$remote->execute(implode(self::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
}
|
}
|
||||||
return $messages;
|
return $messages;
|
||||||
|
@ -374,7 +374,7 @@ class quota extends baseModule {
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
||||||
$remote->connect($remoteServer);
|
$remote->connect($remoteServer);
|
||||||
$remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
|
$remote->execute(implode(self::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
|
@ -535,7 +535,7 @@ class quota extends baseModule {
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remote->connect($lamdaemonServer);
|
$remote->connect($lamdaemonServer);
|
||||||
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
if (empty($quotas)) {
|
if (empty($quotas)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -543,13 +543,13 @@ class quota extends baseModule {
|
||||||
$dirs = explode(":", $quotas);
|
$dirs = explode(":", $quotas);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
|
||||||
unset($dirs[$i]);
|
unset($dirs[$i]);
|
||||||
$dirs = array_values($dirs);
|
$dirs = array_values($dirs);
|
||||||
$i--;
|
$i--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
@ -599,17 +599,17 @@ class quota extends baseModule {
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remote->connect($lamdaemonServer);
|
$remote->connect($lamdaemonServer);
|
||||||
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
$dirs = explode(":", $quotas);
|
$dirs = explode(":", $quotas);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
|
||||||
unset($dirs[$i]);
|
unset($dirs[$i]);
|
||||||
$i--;
|
$i--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
@ -760,17 +760,17 @@ class quota extends baseModule {
|
||||||
// Get quotas
|
// Get quotas
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remote->connect($lamdaemonServer);
|
$remote->connect($lamdaemonServer);
|
||||||
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
|
||||||
$remote->disconnect();
|
$remote->disconnect();
|
||||||
$dirs = explode(":", $quotas);
|
$dirs = explode(":", $quotas);
|
||||||
array_pop($dirs); // remove empty element at the end
|
array_pop($dirs); // remove empty element at the end
|
||||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||||
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
|
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
|
||||||
unset($dirs[$i]);
|
unset($dirs[$i]);
|
||||||
$i--;
|
$i--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
|
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
|
||||||
$dirs[$i] = explode(",", $dirs[$i]);
|
$dirs[$i] = explode(",", $dirs[$i]);
|
||||||
$dirs[$i] = $dirs[$i][0];
|
$dirs[$i] = $dirs[$i][0];
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ class quota extends baseModule {
|
||||||
$mpParts = explode(":", $mountPoints[$m]);
|
$mpParts = explode(":", $mountPoints[$m]);
|
||||||
$server = $mpParts[0];
|
$server = $mpParts[0];
|
||||||
$dir = $mpParts[1];
|
$dir = $mpParts[1];
|
||||||
$quotaString = implode(quota::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' .
|
$quotaString = implode(self::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' .
|
||||||
implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n"));
|
implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n"));
|
||||||
$remote = new \LAM\REMOTE\Remote();
|
$remote = new \LAM\REMOTE\Remote();
|
||||||
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
|
||||||
|
|
Loading…
Reference in New Issue