use getConfiguredScriptServers()

This commit is contained in:
Roland Gruber 2019-10-17 21:18:13 +02:00
parent de988316a5
commit 162ed79946
2 changed files with 38 additions and 74 deletions

View File

@ -183,10 +183,9 @@ class quota extends baseModule {
}
}
// get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
$server = $temp[0];
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
foreach ($lamdaemonServers as $lamdaemonServer) {
$server = $lamdaemonServer->getServer();
// get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@ -277,14 +276,6 @@ class quota extends baseModule {
$id = $this->getCn();
}
// get list of lamdaemon servers
$serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
if (isset($temp[1])) {
$serverDescriptions[$temp[0]] = $temp[1];
}
}
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@ -366,14 +357,6 @@ class quota extends baseModule {
$id = $this->getCn();
}
// get list of lamdaemon servers
$serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
if (isset($temp[1])) {
$serverDescriptions[$temp[0]] = $temp[1];
}
}
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@ -403,14 +386,6 @@ class quota extends baseModule {
}
$errors = array();
// get list of lamdaemon servers
$serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
if (isset($temp[1])) {
$serverDescriptions[$temp[0]] = $temp[1];
}
}
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@ -467,19 +442,17 @@ class quota extends baseModule {
}
// get list of lamdaemon servers
$serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
if (isset($temp[1])) {
$serverDescriptions[$temp[0]] = $temp[1];
}
$lamdaemonServer = $lamdaemonServers[$s];
$serverDescriptions[$lamdaemonServer->getServer()] = $lamdaemonServer->getLabel();
}
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
$id = $this->replaceSpecialChars($server);
$title = $server;
if (isset($serverDescriptions[$server])) {
if ($serverDescriptions[$server] != $server) {
$title = $serverDescriptions[$server] . " (" . $server . ")";
}
$return->add(new htmlSubTitle($title), 12);
@ -544,15 +517,14 @@ class quota extends baseModule {
$return = new htmlResponsiveRow();
$optionsAvailable = false;
// get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
try {
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
$server = $temp[0];
foreach ($lamdaemonServers as $lamdaemonServer) {
$server = $lamdaemonServer->getServer();
$id = $this->replaceSpecialChars($server);
$description = $temp[0];
if (isset($temp[1])) {
$description = $temp[1] . ' (' . $temp[0] . ')';
$description = $lamdaemonServer->getLabel();
if ($description != $server) {
$description = $description . ' (' . $server . ')';
}
// Get quotas
$remote = new \LAM\REMOTE\Remote();
@ -614,10 +586,9 @@ class quota extends baseModule {
function check_profileOptions($options, $typeId) {
$return = array();
// get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
$server = $temp[0];
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
foreach ($lamdaemonServers as $lamdaemonServer) {
$server = $lamdaemonServer->getServer();
$id = $this->replaceSpecialChars($server);
// Get quotas
$remote = new \LAM\REMOTE\Remote();
@ -717,13 +688,12 @@ class quota extends baseModule {
if (sizeof($this->quota) > 0) {
$pdfTable = new PDFTable();
// get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
$server = $temp[0];
$description = $server;
if (isset($temp[1])) {
$description = $temp[1] . " (" . $server . ")";
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
foreach ($lamdaemonServers as $lamdaemonServer) {
$server = $lamdaemonServer->getServer();
$description = $lamdaemonServer->getLabel();
if ($description != $server) {
$description = $description . " (" . $server . ")";
}
if (!isset($this->quota[$server]) || (sizeof($this->quota[$server]) < 1)) {
continue;
@ -778,10 +748,9 @@ class quota extends baseModule {
$return = array();
if (sizeof($this->quota) > 0) {
// get list of lamdaemon servers
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
$temp = explode(":", $lamdaemonServers[$s]);
$server = $temp[0];
$lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
foreach ($lamdaemonServers as $lamdaemonServer) {
$server = $lamdaemonServer->getServer();
// Get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);

View File

@ -1542,14 +1542,11 @@ class sambaSamAccount extends baseModule implements passwordService {
$homeServerContainer = new htmlTable();
$homeServerContainer->colspan = 5;
// get list of remote servers
$remoteServers = explode(";", $_SESSION['config']->get_scriptServers());
$remoteServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($remoteServers); $i++) {
$temp = explode(":", $remoteServers[$i]);
$server = $temp[0];
$label = $temp[0];
if (isset($temp[1])) {
$label = $temp[1];
}
$remoteServer = $remoteServers[$i];
$server = $remoteServer->getServer();
$label = $remoteServer->getLabel();
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
$result = $remote->execute(
@ -1617,10 +1614,10 @@ class sambaSamAccount extends baseModule implements passwordService {
return;
}
// get list of remote servers
$remoteServers = explode(";", $_SESSION['config']->get_scriptServers());
$remoteServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($remoteServers); $i++) {
$temp = explode(":", $remoteServers[$i]);
$server = $temp[0];
$remoteServer = $remoteServers[$i];
$server = $remoteServer->getServer();
if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@ -1640,13 +1637,12 @@ class sambaSamAccount extends baseModule implements passwordService {
// remote command results
if (!empty($result)) {
$singleresult = explode(",", $result);
if (is_array($singleresult)) {
if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) {
if (is_array($singleresult)
&& (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO'))) {
$return[] = $singleresult;
}
}
}
}
elseif (isset($_POST['form_subpage_' . get_class($this) . '_homedir_delete_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@ -1665,14 +1661,13 @@ class sambaSamAccount extends baseModule implements passwordService {
// remote command results
if (!empty($result)) {
$singleresult = explode(",", $result);
if (is_array($singleresult)) {
if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) {
if (is_array($singleresult)
&& (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO'))) {
$return[] = $singleresult;
}
}
}
}
}
return $return;
}