diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index 658f523a..f8d5d405 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -186,11 +186,14 @@ class quota extends baseModule { $temp = explode(":", $lamdaemonServers[$s]); $server = $temp[0]; // get quotas - $quotas = lamdaemon(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope())), $server); + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope()))); + $remote->disconnect(); if (sizeof($quotas) == 0) { continue; } - $allQuotas = explode(":", $quotas[0]); + $allQuotas = explode(":", $quotas); array_pop($allQuotas); // remove empty element at the end for ($i = 0; $i < sizeof($allQuotas); $i++) { if (strpos($allQuotas[$i], quota::$QUOTA_PREFIX) !== 0) continue; @@ -280,7 +283,10 @@ class quota extends baseModule { $quotastring = $quotastring . $this->quota[$server][$i][0] . ',' . $this->quota[$server][$i][2] . ',' . $this->quota[$server][$i][3] . ',' . $this->quota[$server][$i][6] . ',' . $this->quota[$server][$i][7] . ':'; } - lamdaemon(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")), $server); + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))); + $remote->disconnect(); } return $messages; } @@ -319,7 +325,10 @@ class quota extends baseModule { $quotastring = $quotastring . $this->quota[$server][$i][0] . ',0,0,0,0:'; $i++; } - lamdaemon(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")), $server); + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))); + $remote->disconnect(); } return array(); } @@ -483,11 +492,14 @@ class quota extends baseModule { $description = $temp[1] . ' (' . $temp[0] . ')'; } // Get quotas - $quotas = lamdaemon(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())), $server); - if (sizeof($quotas) == 0) { + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); + $remote->disconnect(); + if (empty($quotas)) { continue; } - $dirs = explode(":", $quotas[0]); + $dirs = explode(":", $quotas); array_pop($dirs); // remove empty element at the end for ($i = 0; $i < sizeof($dirs); $i++) { if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) { @@ -556,8 +568,11 @@ class quota extends baseModule { $server = $temp[0]; $id = $this->replaceSpecialChars($server); // Get quotas - $quotas = lamdaemon(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())), $server); - $dirs = explode(":", $quotas[0]); + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); + $remote->disconnect(); + $dirs = explode(":", $quotas); array_pop($dirs); // remove empty element at the end for ($i = 0; $i < sizeof($dirs); $i++) { if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) { @@ -669,8 +684,11 @@ class quota extends baseModule { $temp = explode(":", $lamdaemonServers[$s]); $server = $temp[0]; // Get quotas - $quotas = lamdaemon(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())), $server); - $dirs = explode(":", $quotas[0]); + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); + $remote->disconnect(); + $dirs = explode(":", $quotas); array_pop($dirs); // remove empty element at the end for ($i = 0; $i < sizeof($dirs); $i++) { if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) { @@ -786,13 +804,14 @@ class quota extends baseModule { $dir = $mpParts[1]; $quotaString = implode(quota::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' . implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n")); - $result = lamdaemon($quotaString, $server); - if (is_array($result)) { - for ($i = 0; $i < sizeof($result); $i++) { - $parts = explode(",", $result); - if ($parts[0] == 'ERROR') { - $errors[] = array('ERROR', $parts[1], $parts[2]); - } + $remote = new \LAM\REMOTE\Remote(); + $remote->connect($server); + $result = $remote->execute($quotaString); + $remote->disconnect(); + if (!empty($result)) { + $parts = explode(",", $result); + if ($parts[0] == 'ERROR') { + $errors[] = array('ERROR', $parts[1], $parts[2]); } } } diff --git a/lam/templates/misc/ajax.php b/lam/templates/misc/ajax.php index 67b406ed..e16e2a50 100644 --- a/lam/templates/misc/ajax.php +++ b/lam/templates/misc/ajax.php @@ -95,7 +95,7 @@ class Ajax { elseif ($function == 'upload') { include_once('../../lib/upload.inc'); $typeManager = new \LAM\TYPES\TypeManager(); - $uploader = new LAM\UPLOAD\Uploader($typeManager->getConfiguredType($_GET['typeId'])); + $uploader = new \LAM\UPLOAD\Uploader($typeManager->getConfiguredType($_GET['typeId'])); ob_start(); $jsonOut = $uploader->doUpload(); ob_end_clean(); diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php index 1a0dbb55..de87f864 100644 --- a/lam/templates/tests/lamdaemonTest.php +++ b/lam/templates/tests/lamdaemonTest.php @@ -130,7 +130,7 @@ include '../main_footer.php'; * @param htmlTable $container container for HTML output * @return boolean true, if errors occured */ -function lamTestLamdaemon($command, $stopTest, $remote, $testText, $container) { +function testRemoteCommand($command, $stopTest, $remote, $testText, $container) { $okImage = "../../graphics/pass.png"; $failImage = "../../graphics/fail.png"; $spacer = new htmlSpacer('10px', null); @@ -283,18 +283,18 @@ function lamRunTestSuite($serverName, $serverTitle, $testQuota, $container) { flush(); if (!$stopTest) { - $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "basic", $stopTest, $remote, _("Execute lamdaemon"), $container); + $stopTest = testRemoteCommand("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "basic", $stopTest, $remote, _("Execute lamdaemon"), $container); } if (!$stopTest) { - $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "version" . $SPLIT_DELIMITER . $LAMDAEMON_PROTOCOL_VERSION, $stopTest, $remote, _("Lamdaemon version"), $container); + $stopTest = testRemoteCommand("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "version" . $SPLIT_DELIMITER . $LAMDAEMON_PROTOCOL_VERSION, $stopTest, $remote, _("Lamdaemon version"), $container); } if (!$stopTest) { - $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "nss" . $SPLIT_DELIMITER . "$userName", $stopTest, $remote, _("Lamdaemon: check NSS LDAP"), $container); + $stopTest = testRemoteCommand("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "nss" . $SPLIT_DELIMITER . "$userName", $stopTest, $remote, _("Lamdaemon: check NSS LDAP"), $container); if (!$stopTest && $testQuota) { - $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "quota", $stopTest, $remote, _("Lamdaemon: Quota module installed"), $container); - $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "quota" . $SPLIT_DELIMITER . "get" . $SPLIT_DELIMITER . "user", $stopTest, $remote, _("Lamdaemon: read quotas"), $container); + $stopTest = testRemoteCommand("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "quota", $stopTest, $remote, _("Lamdaemon: Quota module installed"), $container); + $stopTest = testRemoteCommand("+" . $SPLIT_DELIMITER . "quota" . $SPLIT_DELIMITER . "get" . $SPLIT_DELIMITER . "user", $stopTest, $remote, _("Lamdaemon: read quotas"), $container); } } $remote->disconnect();