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

View File

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