diff --git a/vilesci/moodle/account_verwaltung.php b/vilesci/moodle/account_verwaltung.php
index 4bea8e304..5038def00 100644
--- a/vilesci/moodle/account_verwaltung.php
+++ b/vilesci/moodle/account_verwaltung.php
@@ -1,5 +1,27 @@
+ * Andreas Oesterreicher < andreas.oesterreicher@technikum-wien.at >
+ * Rudolf Hangl < rudolf.hangl@technikum-wien.at >
+ * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at >
+ */
+
/*
Dieses Programm listet nach einem Suchbegriff bestehender Benutzer auf.
Fuer jede UserID wird geprueft ob dieser bereits einen Moodle ID besitzt.
diff --git a/vilesci/moodle/kurs_verwaltung.php b/vilesci/moodle/kurs_verwaltung.php
index 187ef4c4f..b17824058 100644
--- a/vilesci/moodle/kurs_verwaltung.php
+++ b/vilesci/moodle/kurs_verwaltung.php
@@ -1,5 +1,28 @@
+ * Andreas Oesterreicher < andreas.oesterreicher@technikum-wien.at >
+ * Rudolf Hangl < rudolf.hangl@technikum-wien.at >
+ * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at >
+ */
+
+
/*
Dieses Programm listet nach Selektinskreterien alle Moodelkurse zu einem Studiengang auf.
Fuer jede MoodleID werden die Anzahl Benotungen, und erfassten sowie angelegte Zusaetze angezeigt.
@@ -11,7 +34,6 @@
require_once('../../include/globals.inc.php');
// ---------------- Moodle Daten Classe
include_once('../../include/moodle_course.class.php');
-
// ***********************************************************************************************
// Variable Initialisieren
// ***********************************************************************************************
@@ -56,27 +78,45 @@
// Moodlekurs wird zum bearbeiten (loeschen) freigegeben
if ($mdl_course_id!='' && $studiensemester_kurzbz!='')
{
- require_once("/var/www/htdocs/moodle/config.php");
- if (! $course = get_record("course", "id", $mdl_course_id))
- {
- $content.="
Moodlekurs $mdl_course_id wurde NICHT gelöscht.
";
- }
- else
- {
- // Moodle config Einbinden
- add_to_log(SITEID, "course", "delete", "view.php?id=$mdl_course_id", $course->fullname." (ID $mdl_course_id)");
- delete_course($course);
- ob_clean();
+ include(dirname(__FILE__)."/xmlrpcutils/utils.php");
- fix_course_sortorder(); //update course count in catagories
+ // Variable Daten
+ $uri = "/moodle/xmlrpc/xmlrpc.php";
+ $method = "DeleteCourseByID";
+ $args['CourseID']="$mdl_course_id";
- $qry = "DELETE FROM lehre.tbl_moodle WHERE mdl_course_id='".addslashes($mdl_course_id)."' ";
- if ($moodle_id!='')
- $qry.= " and moodle_id='".addslashes($moodle_id)."'";
- if(!pg_query($conn, $qry))
- $content.="Moodlekurs $mdl_course_id in Lehre wurde NICHT gelöscht.
";
- $content.="Moodlekurs $mdl_course_id wurde gelöscht.
";
- }
+ // Achtung!
+ // Im Produktion muss die vilesci.technikum-wien gegen cis.technikum-wien getauscht werden
+ // Secure sollte nur bei Port 80 True sein
+ $callspec = array(
+ 'method' => $method,
+ 'host' => str_replace('vilesci.','cis.',$_SERVER["SERVER_NAME"]),
+ 'port' => $_SERVER["SERVER_PORT"],
+ 'uri' => $uri,
+ 'user' => (isset($_SERVER["PHP_AUTH_USER"])?$_SERVER["PHP_AUTH_USER"]:""),
+ 'pass' => (isset($_SERVER["PHP_AUTH_PW"])?$_SERVER["PHP_AUTH_PW"]:""),
+ 'secure' => (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"]=="80"?false:true),
+ 'debug' => 0,
+ 'args' => $args);
+ $result = xu_rpc_http_concise($callspec);
+
+ $del_moodle=false;
+ if (!is_array($result)) // Server wurde nicht erreicht.
+ {
+ $content.="Fehler xmlrpc call $result";
+ }
+ else if ($result[0]==1) // Methodenaufruf erfolgreich
+ {
+# $content.=(isset($result[1])?$result[1]:"Moodel-Kurs gelöscht ");
+ $qry = "DELETE FROM lehre.tbl_moodle WHERE mdl_course_id='".addslashes($mdl_course_id)."' ";
+ if ($moodle_id!='')
+ $qry.= " and moodle_id='".addslashes($moodle_id)."'";
+ if(!pg_query($conn, $qry))
+ $content.="Moodlekurs $mdl_course_id in Lehre wurde NICHT gelöscht.
";
+ $content.="Moodlekurs $mdl_course_id wurde gelöscht.
";
+ }
+ else
+ $content.=(isset($result[1])?$result[1]:"Fehler beim Kurs löschen ");
}
diff --git a/vilesci/moodle/xmlrpcutils/utils.php b/vilesci/moodle/xmlrpcutils/utils.php
new file mode 100644
index 000000000..401d0d933
--- /dev/null
+++ b/vilesci/moodle/xmlrpcutils/utils.php
@@ -0,0 +1,267 @@
+
+ * Andreas Oesterreicher < andreas.oesterreicher@technikum-wien.at >
+ * Rudolf Hangl < rudolf.hangl@technikum-wien.at >
+ * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at >
+ */
+
+ /*
+ This file is part of, or distributed with, libXMLRPC - a C library for
+ xml-encoded function calls.
+
+ Author: Dan Libby (dan@libby.com)
+ Epinions.com may be contacted at feedback@epinions-inc.com
+ */
+
+
+// ensure extension is loaded.
+// a function to ensure the xmlrpc extension is loaded.
+// xmlrpc_epi_dir = directory where libxmlrpc.so.0 is located
+// xmlrpc_php_dir = directory where xmlrpc-epi-php.so is located
+function xu_load_extension($xmlrpc_php_dir="") {
+ $bSuccess = false;
+ if(!extension_loaded('xmlrpc')) {
+ $bSuccess = true;
+ @putenv("LD_LIBRARY_PATH=/usr/lib/php4/apache/xmlrpc/");
+ if ($xmlrpc_php_dir) {
+ $xmlrpc_php_dir .= '/';
+ }
+ if (!extension_loaded("xmlrpc")) {
+ $bSuccess = @dl($xmlrpc_php_dir . "xmlrpc-epi-php.so");
+ }
+ }
+ return $bSuccess;
+}
+
+/* generic function to call an http server with post method */
+function xu_query_http_post($request, $host, $uri, $port, $debug,
+ $timeout, $user, $pass, $secure=false) {
+ $response_buf = "";
+ if ($host && $uri && $port) {
+ $content_len = strlen($request);
+
+ $fsockopen = $secure ? "fsockopen_ssl" : "fsockopen";
+ if (!function_exists($fsockopen)) {
+ dbg1("opening socket not OK : change from $fsockopen to fsockopen", $debug);
+ $fsockopen="fsockopen";
+ }
+
+ dbg1("opening socket to host: $host, port: $port, uri: $uri", $debug);
+ $query_fd = $fsockopen($host, $port, $errno, $errstr, 10);
+
+ if ($query_fd) {
+
+ $auth = "";
+ if ($user) {
+ dbg1("sending User Authorization: \n$user\n", $debug);
+ $auth = "Authorization: Basic " .base64_encode($user . ":" . $pass) . "\r\n";
+ }
+
+ $http_request =
+ "POST $uri HTTP/1.0\r\n" .
+ "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
+ "Host: $host".($port!=''?":$port":"")."\r\n" .
+ $auth .
+ "Content-Type: text/xml\r\n" .
+ "Content-Length: $content_len\r\n" .
+ "\r\n" .
+ $request;
+
+ dbg1("sending http request: \n$http_request\n", $debug);
+ fputs($query_fd, $http_request, strlen($http_request));
+ dbg1("receiving response...", $debug);
+ $header_parsed = false;
+ $line = fgets($query_fd, 4096);
+ $response_buf="";
+ while ($line) {
+ if (!$header_parsed) {
+ if ($line === "\r\n" || $line === "\n") {
+ $header_parsed = 1;
+ }
+ dbg2("got header - $line", $debug);
+ }
+ else {
+ $response_buf .= $line;
+ }
+ $line = fgets($query_fd, 4096);
+ }
+ if (isset($query_fd))
+ fclose($query_fd);
+ }
+ else {
+ dbg1("socket open failed", $debug);
+ return false;
+ }
+ }
+ else {
+ dbg1("missing param(s)", $debug);
+ return false;
+ }
+ dbg1("got response:. \n$response_buf\n\n", $debug);
+ return $response_buf;
+}
+
+function xu_fault_code($code, $string) {
+ return array('faultCode' => $code,
+ 'faultString' => $string);
+}
+
+function find_and_decode_xml($buf, $debug) {
+ $retval='';
+ if (strlen($buf)) {
+ $xml_begin = substr($buf, strpos($buf, " 'xml',
+ * 'verbosity' => 'pretty',
+ * 'escaping' => array('markup', 'non-ascii', 'non-print'),
+ * 'version' => 'xmlrpc',
+ * 'encoding' => 'utf-8'
+ * );
+ * or
+ *
+ * $output_options = array('output_type' => 'php');
+ */
+function xu_rpc_http_concise($params) {
+ $host = $uri = $port = $method = $args = $debug = null;
+ $timeout = $user = $pass = $secure = $debug = $output= null;
+
+ extract($params);
+
+ // default values
+ if(!$port) {
+ $port = 80;
+ }
+ if(!$uri) {
+ $uri = '/';
+ }
+ if(!$output) {
+ $output = array('version' => 'xmlrpc');
+ }
+
+ $response_buf = "";
+ $retval= "fail: utils.php Param not OK ";
+ if ($host && $uri && $port) {
+ if (!$request_xml = xmlrpc_encode_request($method, $args, $output))
+ return "fail: xmlrpc_encode_request ";
+
+ if (!$response_buf = xu_query_http_post($request_xml,
+ $host,
+ $uri,
+ $port,
+ $debug,
+ $timeout,
+ $user,
+ $pass,
+ $secure))
+ return "fail: xu_query_http_post ";
+
+ $retval = find_and_decode_xml($response_buf, $debug);
+ }
+ return $retval;
+}
+
+/* call an xmlrpc method on a remote http server. legacy support. */
+function xu_rpc_http($method, $args, $host, $uri="/", $port=80, $debug=false,
+ $timeout=0, $user=false, $pass=false, $secure=false) {
+ return xu_rpc_http_concise(
+ array(
+ method => $method,
+ args => $args,
+ host => $host,
+ uri => $uri,
+ port => $port,
+ debug => $debug,
+ timeout => $timeout,
+ user => $user,
+ pass => $pass,
+ secure => $secure
+ ));
+}
+
+function xu_is_fault($arg) {
+ // xmlrpc extension finally supports this.
+ return is_array($arg) ? xmlrpc_is_fault($arg) : false;
+}
+
+/* sets some http headers and prints xml */
+function xu_server_send_http_response($xml) {
+ header("Content-type: text/xml");
+ header("Content-length: " . strlen($xml) );
+ echo $xml;
+}
+
+function dbg($msg) {
+ echo "$msg
"; flush();
+}
+function dbg1($msg, $debug_level) {
+ if ($debug_level >= 1) {
+ dbg($msg);
+ }
+}
+function dbg2($msg, $debug_level) {
+ if ($debug_level >= 2) {
+ dbg($msg);
+ }
+}
+?>