Revision: 164
http://svn.sourceforge.net/hw4mdl/?rev=164&view=rev
Author: hugues
Date: 2007-01-04 06:51:15 -0800 (Thu, 04 Jan 2007)
Log Message:
-----------
http://u.horizonwimba.com/bugzilla/show_bug.cgi?id=10620
- Fixed the room creation parameters by forcing a couple of media parameters
Modified Paths:
--------------
trunk/moodle/mod/liveclassroom/api.php
trunk/moodle/mod/liveclassroom/generateSettings.php
trunk/moodle/mod/liveclassroom/js/hwCommons.js
trunk/moodle/mod/liveclassroom/lib.php
trunk/moodle/mod/liveclassroom/manageRoomAction.php
Modified: trunk/moodle/mod/liveclassroom/api.php
===================================================================
--- trunk/moodle/mod/liveclassroom/api.php 2007-01-04 11:17:35 UTC (rev 163)
+++ trunk/moodle/mod/liveclassroom/api.php 2007-01-04 14:51:15 UTC (rev 164)
@@ -66,25 +66,25 @@
/*
-* Get the prefix to use for creating rooms and users.
+* Get the prefix to use for creating rooms and users.
*
* return $prefix : a string which is the prefix to use
*/
function liveclassroom_api_get_prefix() {
- global $CFG;
+ global $CFG;
- //get the admin user name
- $aun = $CFG->liveclassroom_adminusername;
- if( (substr($aun, 0,1)=='_') && (substr($aun, -1,1)=='_') ) { //Prefix
- $prefix = $aun;
+ //get the admin user name
+ $aun = $CFG->liveclassroom_adminusername;
+ if( (substr($aun, 0,1)=='_') && (substr($aun, -1,1)=='_') ) { //Prefix
+ $prefix = $aun;
- }
- else {
- $prefix = '';
+ }
+ else {
+ $prefix = '';
- }
- return $prefix;
-
+ }
+ return $prefix;
+
}
/**
@@ -103,12 +103,12 @@
*/
function liveclassroom_api_authenticate ($servername='', $login='', $passwd='') {
global $CFG;
- global $COURSE;
-
+ global $COURSE;
+
if (empty($servername)) { // feed them with $CFG
- $servername = $CFG->liveclassroom_servername;
- $login = $CFG->liveclassroom_adminusername;
- $passwd = $CFG->liveclassroom_adminpassword;
+ $servername = $CFG->liveclassroom_servername;
+ $login = $CFG->liveclassroom_adminusername;
+ $passwd = $CFG->liveclassroom_adminpassword;
}
$url = $servername.
@@ -120,7 +120,7 @@
"&credential_1=". $passwd;
$cookie_file_path = $CFG->dataroot.'/cookie.txt'; // Cookie File path
- $cook = fopen($CFG->dataroot.'/tmp.txt', "w+"); //temporary file to check the date
+ $cook = fopen($CFG->dataroot.'/tmp.txt', "w+"); //temporary file to check the date
fputs($cook,time()); // Add the current time into the file = last authenticate time
$ch = curl_init();
@@ -133,17 +133,17 @@
$data = curl_exec($ch);
if (curl_errno($ch)) {
- add_to_log($COURSE->id, "liveclassroom", "URL", liveclassroom_send_logs("errorUrlUnavailable","courseId=".$COURSE->id), "URL incorrect");
+ add_to_log($COURSE->id, "liveclassroom", "URL", liveclassroom_send_logs("errorUrlUnavailable","courseId=".$COURSE->id), "URL incorrect");
// print curl_error($ch);
return false;
}
preg_match("(\d*)", $data, $matches);
$resp_code = $matches[0];
- if ( $resp_code == 204 ) {
+ if ( $resp_code == 204 ) {
add_to_log($COURSE->id, "liveclassroom", "Authentication", liveclassroom_send_logs("errorAuthentication2","respcode=$resp_code&courseId=".$COURSE->id), "Authentication Failed");
error(get_string('wrongadminpass', 'liveclassroom'));
- return false;
+ return false;
}
else if ( $resp_code != 100 && $resp_code != 301) {
//error( "Response: Authentication Failed: $resp_code");
@@ -162,38 +162,38 @@
/**
* Send a query to the server with the given function and the given attributes
* Check if the session cookie exist and get the cookie creation date.
- * If it's less than 30 minutes, the cookie is got for the request, if not a new authenticate is done.
- * @param $const : function called
+ * If it's less than 30 minutes, the cookie is got for the request, if not a new authenticate is done.
+ * @param $const : function called
* @param $attribute : different list of attributes for the function called
* return $data : result query
*/
function liveclassroom_api_send_query($const,$attribute) {
- global $CFG;
+ global $CFG;
- $cook = $CFG->dataroot.'/tmp.txt'; //Open the temp file to check the last modification date
- $cookie_file_path = $CFG->dataroot.'/cookie.txt'; // Cookie File path
-
- if(file_exists($cook)) {
- $fileContent = file_get_contents($cook);
+ $cook = $CFG->dataroot.'/tmp.txt'; //Open the temp file to check the last modification date
+ $cookie_file_path = $CFG->dataroot.'/cookie.txt'; // Cookie File path
+
+ if(file_exists($cook)) {
+ $fileContent = file_get_contents($cook);
- }
- else {
- $lastModifTime = 0;
- }
- //1800 seconds = 30 minutes
- $modif = $fileContent+1800;
+ }
+ else {
+ $lastModifTime = 0;
+ }
+ //1800 seconds = 30 minutes
+ $modif = $fileContent+1800;
- if( (!file_exists($cookie_file_path)) || ((file_exists($cook)) && (time()>$modif)) ){
- if (!$ch = liveclassroom_api_authenticate()) {
- return false;
- }
- }
-
+ if( (!file_exists($cookie_file_path)) || ((file_exists($cook)) && (time()>$modif)) ){
+ if (!$ch = liveclassroom_api_authenticate()) {
+ return false;
+ }
+ }
+
- $url = $CFG->liveclassroom_servername.
- LIVECLASSROOM_API_ADMIN.
- $const.
- $attribute;
+ $url = $CFG->liveclassroom_servername.
+ LIVECLASSROOM_API_ADMIN.
+ $const.
+ $attribute;
$ch = curl_init();
@@ -203,15 +203,15 @@
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-
- $data = curl_exec($ch);
-
- if (curl_errno($ch)) {
- print curl_error($ch);
- return false;
- }
-
- return $data;
+
+ $data = curl_exec($ch);
+
+ if (curl_errno($ch)) {
+ print curl_error($ch);
+ return false;
+ }
+
+ return $data;
}
@@ -231,28 +231,28 @@
function liveclassroom_api_create_user ($userid, $coursename, $rolename) {
global $CFG;
global $COURSE;
-
- $final_list = "&target=$userid&first_name=$rolename&last_name=$coursename";
- $enc_list = str_replace(" ", "+", $final_list);
+
+ $final_list = "&target=$userid&first_name=$rolename&last_name=$coursename";
+ $enc_list = str_replace(" ", "+", $final_list);
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_USER, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-/*
- if ( $respcode == 302) {
- error( "Creation user failed, malformed exist");
- return false;
- }
- */
-
-
- if ( $respcode != 100 && $respcode != 301) {
- add_to_log($COURSE->id, "liveclassroom", "Create User", liveclassroom_send_logs("errorCreateUser","userId=$userid&respcode=$respcode&courseId=".$COURSE->id), "User Creation Failed");
- // error( "Response: Account ($userId) Creation Failed: $resp_code");
- return false;
- }
- add_to_log($COURSE->id, "liveclassroom", "Create User", liveclassroom_send_logs("createUser","userId=$userid&courseId=".$COURSE->id), "User Creation succeeded");
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_USER, $enc_list);
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+/*
+ if ( $respcode == 302) {
+ error( "Creation user failed, malformed exist");
+ return false;
+ }
+ */
+
+
+ if ( $respcode != 100 && $respcode != 301) {
+ add_to_log($COURSE->id, "liveclassroom", "Create User", liveclassroom_send_logs("errorCreateUser","userId=$userid&respcode=$respcode&courseId=".$COURSE->id), "User Creation Failed");
+ // error( "Response: Account ($userId) Creation Failed: $resp_code");
+ return false;
+ }
+ add_to_log($COURSE->id, "liveclassroom", "Create User", liveclassroom_send_logs("createUser","userId=$userid&courseId=".$COURSE->id), "User Creation succeeded");
return true;
}
@@ -263,22 +263,22 @@
*
*/
function liveclassroom_api_create_group($groupid) {
-
+
global $CFG;
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_GROUP, "&target=$groupid");
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_GROUP, "&target=$groupid");
if ( $respcode == 301) {
- error( "Response: Authentication Failed: $resp_code");
- return false;
- }
- if ( $respcode != 100 && $respcode != 301) {
- error( "Response: Cannot Create group with id:$groupid");
- return false;
- }
+ error( "Response: Authentication Failed: $resp_code");
+ return false;
+ }
+ if ( $respcode != 100 && $respcode != 301) {
+ error( "Response: Cannot Create group with id:$groupid");
+ return false;
+ }
-
- return true;
+
+ return true;
}
@@ -295,22 +295,22 @@
function liveclassroom_api_get_session ($userid, $nickname) {
global $CFG;
global $USER;
- global $COURSE;
-
-
- $final_list = "&target=$userid&nickname=$nickname";
- $enc_list = str_replace(" ", "+", $final_list);
+ global $COURSE;
+
+
+ $final_list = "&target=$userid&nickname=$nickname";
+ $enc_list = str_replace(" ", "+", $final_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_TOKEN, $enc_list);
-
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_TOKEN, $enc_list);
+
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
if ( $respcode != 100) {
-
- add_to_log($COURSE->id, "liveclassroom", "Create Session", liveclassroom_send_logs("errorCreateSession","respcode=$respcode&nickname=$nickname&courseId=".$COURSE->id), "Cannot Create Session.");
+
+ add_to_log($COURSE->id, "liveclassroom", "Create Session", liveclassroom_send_logs("errorCreateSession","respcode=$respcode&nickname=$nickname&courseId=".$COURSE->id), "Cannot Create Session.");
return false;
}
@@ -334,8 +334,8 @@
//error ("Token empty, data=<pre>$data</pre>");
return false;
}
- add_to_log($COURSE->id, "liveclassroom", "Create Session", liveclassroom_send_logs("createSession","nickname=$nickname&courseId=".$COURSE->id), "Creating Session for $nickname");
-
+ add_to_log($COURSE->id, "liveclassroom", "Create Session", liveclassroom_send_logs("createSession","nickname=$nickname&courseId=".$COURSE->id), "Creating Session for $nickname");
+
return $authtoken;
}
@@ -347,37 +347,40 @@
*/
function liveclassroom_api_create_class ($roomid, $roomname, $bool, $attributes) {
global $CFG;
- global $COURSE;
-
- $list_attributes = '';
-
- unset($attributes['longname']);
- while (list($key, $val) = each($attributes)) {
- if(($key!='class_id')&&(isset($val))&&($val!="")){
- $list_attributes .= "&".$key."=".$val;
- }
- }
+ global $COURSE;
+
+ $list_attributes = '';
+
+ unset($attributes['longname']);
+ unset($attributes['led']);
- $final_list = "&target=$roomid"."&longname=$roomname".$list_attributes;
- $enc_list = str_replace(" ", "+", $final_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_CLASS, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode == 301) {
- error( "Class $roomname already exist");
- return false;
- }
- if ( $respcode != 100) {
- add_to_log($COURSE->id, "liveclassroom", "Create Room", liveclassroom_send_logs("errorCreateClass","roomname=$roomname&roomId=$roomid&respcode=$respcode&courseId=".$COURSE->id), "Cannot Create Class with id : $roomid, and name : $roomname.");
- return false;
- }
+ while (list($key, $val) = each($attributes)) {
+ if(($key!='class_id')&&(isset($val))&&($val!="")){
+ $list_attributes .= "&".$key."=".$val;
+ }
+ }
- add_to_log($COURSE->id, "liveclassroom", "Create Room", liveclassroom_send_logs("createClass","roomname=$roomname&courseId=".$COURSE->id), "$roomname create with success");
- return true;
+ $final_list = "&target=$roomid"."&longname=$roomname".$list_attributes;
+ $enc_list = str_replace(" ", "+", $final_list);
+
+//DEBUG: error($enc_list);
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_CLASS, $enc_list);
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode == 301) {
+ error( "Class $roomname already exist");
+ return false;
+ }
+ if ( $respcode != 100) {
+ add_to_log($COURSE->id, "liveclassroom", "Create Room", liveclassroom_send_logs("errorCreateClass","roomname=$roomname&roomId=$roomid&respcode=$respcode&courseId=".$COURSE->id), "Cannot Create Class with id : $roomid, and name : $roomname.");
+ return false;
+ }
+ add_to_log($COURSE->id, "liveclassroom", "Create Room", liveclassroom_send_logs("createClass","roomname=$roomname&courseId=".$COURSE->id), "$roomname create with success");
+ return true;
}
/*
@@ -390,7 +393,7 @@
function liveclassroom_api_add_user_role ($roomid, $userid, $role) {
global $CFG;
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_ROLE, "&target=$roomid&user_id=$userid&role_id=$role");
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_ROLE, "&target=$roomid&user_id=$userid&role_id=$role");
preg_match("(\d*)", $data, $matches);
@@ -414,7 +417,7 @@
function liveclassroom_api_remove_user_role ($roomid, $userid, $role) {
global $CFG;
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROLE, "&target=$roomid&user_id=$userid&role_id=$role");
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROLE, "&target=$roomid&user_id=$userid&role_id=$role");
preg_match("(\d*)", $data, $matches);
@@ -430,7 +433,7 @@
function liveclassroom_api_remove_group_role ($roomid, $groupid, $role) {
global $CFG;
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROLE, "&target=$roomid&user_id=$groupid&role_id=$role");
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROLE, "&target=$roomid&user_id=$groupid&role_id=$role");
preg_match("(\d*)", $data, $matches);
@@ -453,30 +456,30 @@
*/
function liveclassroom_api_room_exist($roomname) {
- global $CFG;
+ global $CFG;
- $final_list = "&filter00=longname&filter00value=$roomname";
- $enc_list = str_replace(" ", "+", $final_list);
+ $final_list = "&filter00=longname&filter00value=$roomname";
+ $enc_list = str_replace(" ", "+", $final_list);
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
- if(sizeof($tok1)>1){
-
- return true;
- }
- else {
- return false;
- }
+ if(sizeof($tok1)>1){
+
+ return true;
+ }
+ else {
+ return false;
+ }
}
@@ -487,43 +490,43 @@
* return a string delimited by the pattern and the end of line
*/
function liveclassroom_parse_line($line,$pattern) {
-
- $response = split($pattern,$line);
- //$result = substr($response[1],0,-1);
-
+
+ $response = split($pattern,$line);
+ //$result = substr($response[1],0,-1);
+
- return $response[1];
+ return $response[1];
}
/**
* Get the room id from a roomname
-* @param $roomname
-* return the room_id from the server
+* @param $roomname
+* return the room_id from the server
*/
function liveclassroom_api_get_roomid($roomname) {
- global $CFG;
+ global $CFG;
- $final_list = "&filter00=longname&filter00value=$roomname";
- $enc_list = str_replace(" ", "+", $final_list);
-
+ $final_list = "&filter00=longname&filter00value=$roomname";
+ $enc_list = str_replace(" ", "+", $final_list);
+
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
- $result = liveclassroom_parse_line($tok1[0],"class_id=");
-
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ $result = liveclassroom_parse_line($tok1[0],"class_id=");
+
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
- return $response;
+ return $response;
}
@@ -536,25 +539,25 @@
* return true if the room is deleted, false otherwise
*/
function liveclassroom_api_delete_room($roomid) {
- global $CFG;
- global $COURSE;
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROOM,"&target=$roomid");
+ global $CFG;
+ global $COURSE;
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_DELETE_ROOM,"&target=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
-
- if ( $respcode == 302) {
+
+ if ( $respcode == 302) {
add_to_log($COURSE->id, "liveclassroom", "Delete Room", liveclassroom_send_logs("errorDeleteRoom302","roomId=$roomid&courseId=".$COURSE->id), "$roomid suppression failed");
- // error( "Target not found");
- return false;
- }
- else if ( $respcode != 100) {
+ // error( "Target not found");
+ return false;
+ }
+ else if ( $respcode != 100) {
add_to_log($COURSE->id, "liveclassroom", "Delete Room", liveclassroom_send_logs("errorDeleteRoom100","roomId=$roomid&courseId=".$COURSE->id), "$roomid suppression failed");
return false;
}
-
- add_to_log($COURSE->id, "liveclassroom", "Delete Room", liveclassroom_send_logs("deleteRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been deleted with success");
- return true;
+
+ add_to_log($COURSE->id, "liveclassroom", "Delete Room", liveclassroom_send_logs("deleteRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been deleted with success");
+ return true;
}
/**
@@ -564,24 +567,24 @@
* return true if the room has being opened, false otherwise
*/
function liveclassroom_api_open_room($roomid) {
- global $CFG;
- global $COURSE;
-
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=0");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode == 302) {
- add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("errorOpenRoom302","roomId=$roomid&courseId=".$COURSE->id), "$roomid opening failed");
- return false;
+ global $CFG;
+ global $COURSE;
+
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=0");
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode == 302) {
+ add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("errorOpenRoom302","roomId=$roomid&courseId=".$COURSE->id), "$roomid opening failed");
+ return false;
}
- if ( $respcode != 100) {
- add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("errorOpenRoom100","roomId=$roomid&courseId=".$COURSE->id), "$roomid opening failed");
- return false;
- }
- add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("openRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been opened with success");
- return true;
+ if ( $respcode != 100) {
+ add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("errorOpenRoom100","roomId=$roomid&courseId=".$COURSE->id), "$roomid opening failed");
+ return false;
+ }
+ add_to_log($COURSE->id, "liveclassroom", "Open Room", liveclassroom_send_logs("openRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been opened with success");
+ return true;
}
/**
@@ -591,24 +594,24 @@
* return true if the room has being closed, false otherwise
*/
function liveclassroom_api_close_room($roomid) {
- global $CFG;
- global $COURSE;
-
- liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=1");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode == 302) {
- add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("errorCloseRoom302","roomId=$roomid&courseId=".$COURSE->id), "$roomid closing failed");
-
- return false;
+ global $CFG;
+ global $COURSE;
+
+ liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=1");
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode == 302) {
+ add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("errorCloseRoom302","roomId=$roomid&courseId=".$COURSE->id), "$roomid closing failed");
+
+ return false;
}
- if ( $respcode != 100) {
- add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("errorCloseRoom100","roomId=$roomid&courseId=".$COURSE->id), "$roomid closing failed");
- return false;
- }
- add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("closeRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been closed with success");
- return true;
+ if ( $respcode != 100) {
+ add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("errorCloseRoom100","roomId=$roomid&courseId=".$COURSE->id), "$roomid closing failed");
+ return false;
+ }
+ add_to_log($COURSE->id, "liveclassroom", "Close Room", liveclassroom_send_logs("closeRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been closed with success");
+ return true;
}
@@ -620,31 +623,31 @@
*/
function liveclassroom_api_modify_room($roomid,$table_attributes) {
global $CFG;
- global $COURSE;
+ global $COURSE;
while (list($key, $val) = each($table_attributes)) {
- if(($key!='class_id')&&(isset($val))&&($val!="")){
+ if(($key!='class_id')&&(isset($val))&&($val!="")){
- $list_attributes .= "&".$key."=".$val;
- }
+ $list_attributes .= "&".$key."=".$val;
+ }
}
$final_list = "&target=$roomid".$list_attributes;
- $enc_list = str_replace(" ", "+", $final_list);
+ $enc_list = str_replace(" ", "+", $final_list);
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $enc_list);
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $enc_list);
preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
+ $respcode = $matches[0];
if ( $respcode != 100) {
- add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("errorModifyRoom100","roomId=$roomid&courseId=".$COURSE->id), "Room modification failed");
- return false;
- }
+ add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("errorModifyRoom100","roomId=$roomid&courseId=".$COURSE->id), "Room modification failed");
+ return false;
+ }
- add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("modifyRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been modified with success");
+ add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("modifyRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been modified with success");
return true;
}
@@ -666,31 +669,31 @@
$enc_list = str_replace(" ", "+", $final_list);
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- //print $data;
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ //print $data;
-
- $line = explode ("\n",$data);
+
+ $line = explode ("\n",$data);
- $j=0;
-
- for($i=1;$i<sizeof($line)-3;$i=$i+4) {
- $test = strstr($line[$i+1],$roomid);
- if($test!=false) {
- $list_return[$j][0]= liveclassroom_parse_line($line[$i],"preview=");
- $list_return[$j][1]= liveclassroom_parse_line($line[$i+1],"class_id=");
- $list_return[$j][2] = liveclassroom_parse_line($line[$i+2],"longname=");
- $j++;
- }
- }
-
- return $list_return;
+ $j=0;
+
+ for($i=1;$i<sizeof($line)-3;$i=$i+4) {
+ $test = strstr($line[$i+1],$roomid);
+ if($test!=false) {
+ $list_return[$j][0]= liveclassroom_parse_line($line[$i],"preview=");
+ $list_return[$j][1]= liveclassroom_parse_line($line[$i+1],"class_id=");
+ $list_return[$j][2] = liveclassroom_parse_line($line[$i+2],"longname=");
+ $j++;
+ }
+ }
+
+ return $list_return;
}
/*
@@ -707,33 +710,33 @@
$enc_list = str_replace(" ", "+", $final_list);
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- //print $data;
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ //print $data;
-
- $line = explode ("\n",$data);
+
+ $line = explode ("\n",$data);
- $j=0;
-
- for($i=1;$i<sizeof($line)-3;$i=$i+4) {
- $test = strstr($line[$i+1],$roomid);
- if($test!=false) {
- if(liveclassroom_parse_line($line[$i],"preview=")==0) {
- $list_return[$j][1]= liveclassroom_parse_line($line[$i+1],"class_id=");
- $list_return[$j][2] = liveclassroom_parse_line($line[$i+2],"longname=");
- $j++;
- }
- }
- }
-
+ $j=0;
+
+ for($i=1;$i<sizeof($line)-3;$i=$i+4) {
+ $test = strstr($line[$i+1],$roomid);
+ if($test!=false) {
+ if(liveclassroom_parse_line($line[$i],"preview=")==0) {
+ $list_return[$j][1]= liveclassroom_parse_line($line[$i+1],"class_id=");
+ $list_return[$j][2] = liveclassroom_parse_line($line[$i+2],"longname=");
+ $j++;
+ }
+ }
+ }
+
- return $list_return;
+ return $list_return;
}
@@ -750,31 +753,31 @@
$enc_list = str_replace(" ", "+", $final_list);
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- //print $data;
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ //print $data;
-
- $line = explode ("\n",$data);
+
+ $line = explode ("\n",$data);
- $j=0;
-
- for($i=1;$i<sizeof($line)-3;$i=$i+4) {
- $id = liveclassroom_parse_line($line[$i+1],"class_id=");
- $list_return[$id][0]= liveclassroom_parse_line($line[$i],"preview=");
- $list_return[$id][1]= $id;
- $list_return[$id][2] = liveclassroom_parse_line($line[$i+2],"longname=");
- $j++;
-
- }
-
+ $j=0;
+
+ for($i=1;$i<sizeof($line)-3;$i=$i+4) {
+ $id = liveclassroom_parse_line($line[$i+1],"class_id=");
+ $list_return[$id][0]= liveclassroom_parse_line($line[$i],"preview=");
+ $list_return[$id][1]= $id;
+ $list_return[$id][2] = liveclassroom_parse_line($line[$i+2],"longname=");
+ $j++;
+
+ }
+
- return $list_return;
+ return $list_return;
}
/*
@@ -788,52 +791,52 @@
global $CFG;
$name = $course->shortname;
- $enc_name = str_replace(" ", "_", $name);
-
- $final_list = "&filter00=last_name&filter00value=$enc_name";
+ $enc_name = str_replace(" ", "_", $name);
+
+ $final_list = "&filter00=last_name&filter00value=$enc_name";
$enc_list = str_replace(" ", "+", $final_list);
-
+
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_LIST_USER, $enc_list);
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
- if(sizeof($tok1)>1){
- return true;
- }
- else {
- return false;
- }
+ if(sizeof($tok1)>1){
+ return true;
+ }
+ else {
+ return false;
+ }
}
/*
* Give the rights for a lecture room to the room given
* @param $roomid : the id of the room to modifiy the settings
-*
+*
*/
function liveclassroom_api_give_lectureroom_attributes() {
global $CFG;
- $attributes = array('media_type'=>'two-way-audio','preview' =>'0','archive'=>'0','can_archive'=>'1','hms_simulcast'=>'public','chatenable'=>'1','privatechatenable'=>'1','hms_two_way_enabled'=>'1','userlimit'=>'-1');
-
+ $attributes = array('media_type'=>'two-way-audio','preview' =>'0','archive'=>'0','can_archive'=>'1','hms_simulcast'=>'public','chatenable'=>'1','privatechatenable'=>'1','hms_two_way_enabled'=>'1','userlimit'=>'-1');
+
/*
- $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1");
preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
return true;
*/
return $attributes;
@@ -842,29 +845,29 @@
/*
* Give the rights for a breackout room to the room given
* @param $roomid : the id of the room to modifiy the settings
-*
+*
*/
function liveclassroom_api_give_discussionroom_attributes() {
global $CFG;
- $attributes = array('media_type'=>'two-way-audio','hms_simulcast'=>'public','archive'=>'0','preview'=>'0','chatenable'=>'1','privatechatenable'=>'1','hms_two_way_enabled'=>'1','userlimit'=>'-1','can_archive'=>'1','can_liveshare'=>'1','can_ppt_import'=>'1');
+ $attributes = array('media_type'=>'two-way-audio','hms_simulcast'=>'public','archive'=>'0','preview'=>'0','chatenable'=>'1','privatechatenable'=>'1','hms_two_way_enabled'=>'1','userlimit'=>'-1','can_archive'=>'1','can_liveshare'=>'1','can_ppt_import'=>'1');
/*
- $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1&can_archive=1&can_liveshare=1&can_ppt_import=1");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1&can_archive=1&can_liveshare=1&can_ppt_import=1");
preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
-
- return true;
- */
- return $attributes;
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+
+ return true;
+ */
+ return $attributes;
}
@@ -877,24 +880,24 @@
* return a string : the role of the user
*/
function liveclassroom_api_role_user_room($roomid, $userid) {
- global $CFG;
-
+ global $CFG;
+
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_LIST_ROLE, "&attribute=role_id&filter01=user_id&filter01value=$userid&filter02=object_id&filter02value=$roomid");
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
- $result = liveclassroom_parse_line($tok1[0],"role_id=");
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
- return $response;
-
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ $result = liveclassroom_parse_line($tok1[0],"role_id=");
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
+ return $response;
+
}
/*
@@ -911,24 +914,24 @@
$enc_coursename = str_replace(" ", "_", $course->shortname);
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$enc_coursename&filter01=first_name&filter01value=Student");
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $line = explode("\n",$data);
-
-// $tok = split("100 OK",$data);
- // $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-// $result = liveclassroom_parse_line($tok1[0],"user_id=");
- $result = liveclassroom_parse_line($line[1],"user_id=");
- //Remove le " " at the end of the line
- //$response = substr($result,0,-1);
-
- return $result;
+ $line = explode("\n",$data);
+
+// $tok = split("100 OK",$data);
+ // $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+// $result = liveclassroom_parse_line($tok1[0],"user_id=");
+ $result = liveclassroom_parse_line($line[1],"user_id=");
+ //Remove le " " at the end of the line
+ //$response = substr($result,0,-1);
+
+ return $result;
}
@@ -945,22 +948,22 @@
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&filter00=class_id&filter00value=$roomid&filter01=preview&filter01value=0");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
- if(sizeof($tok1)>1){
- return true;
- }
- else {
- return false;
- }
+ if(sizeof($tok1)>1){
+ return true;
+ }
+ else {
+ return false;
+ }
}
/* Check if the room is an archive
@@ -972,122 +975,122 @@
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=archive&filter01=class_id&filter01value=$roomid");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
- $test = strstr($tok1[0],"archive=");
-
- //$tok2 = split("class_id=",$tok1[0]);
- $result = liveclassroom_parse_line($test,"archive=");
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
-
- if($response==1) {
- return true;
- }
- else return false;
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+
+ $test = strstr($tok1[0],"archive=");
+
+ //$tok2 = split("class_id=",$tok1[0]);
+ $result = liveclassroom_parse_line($test,"archive=");
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
+
+ if($response==1) {
+ return true;
+ }
+ else return false;
}
/*
-* Give the name of the room given
-* @param $roomid : the id of the room
-* return a String :name of the room
+* Give the name of the room given
+* @param $roomid : the id of the room
+* return a String :name of the room
*/
function liveclassroom_api_get_room_name($roomid){
global $CFG;
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=longname&filter00=class_id&filter00value=$roomid");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
- $test = strstr($tok1[0],"longname=");
-
- //$tok2 = split("class_id=",$tok1[0]);
- $result = liveclassroom_parse_line($test,"longname=");
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
-
- return $response;
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+
+ $test = strstr($tok1[0],"longname=");
+
+ //$tok2 = split("class_id=",$tok1[0]);
+ $result = liveclassroom_parse_line($test,"longname=");
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
+
+ return $response;
}
/*
-* Give the media type of the room given
-* @param $roomid : the id of the room
-* return a String :media type of the room
+* Give the media type of the room given
+* @param $roomid : the id of the room
+* return a String :media type of the room
*/
function liveclassroom_api_get_media_type($roomid){
global $CFG;
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=media_type&filter00=class_id&filter00value=$roomid");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- //print $url;
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
- $test = strstr($tok1[0],"media_type=");
-
- //$tok2 = split("class_id=",$tok1[0]);
- $result = liveclassroom_parse_line($test,"media_type=");
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
-
- return $response;
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ //print $url;
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+
+ $test = strstr($tok1[0],"media_type=");
+
+ //$tok2 = split("class_id=",$tok1[0]);
+ $result = liveclassroom_parse_line($test,"media_type=");
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
+
+ return $response;
}
-
+
/*
-* Get the number of user limit of the room given
-* @param $roomid : the id of the room
-* return a int : number of user limit
+* Get the number of user limit of the room given
+* @param $roomid : the id of the room
+* return a int : number of user limit
*/
function liveclassroom_api_room_get_user_limit($roomid){
global $CFG;
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=userlimit&filter00=class_id&filter00value=$roomid");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- //print $url;
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
- $test = strstr($tok1[0],"userlimit=");
-
- //$tok2 = split("class_id=",$tok1[0]);
- $result = liveclassroom_parse_line($test,"userlimit=");
- //Remove le " " at the end of the line
- $response = substr($result,0,-1);
- return $response;
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ //print $url;
+ $tok = split("100 OK",$data);
+ $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+
+ $test = strstr($tok1[0],"userlimit=");
+
+ //$tok2 = split("class_id=",$tok1[0]);
+ $result = liveclassroom_parse_line($test,"userlimit=");
+ //Remove le " " at the end of the line
+ $response = substr($result,0,-1);
+ return $response;
}
@@ -1096,7 +1099,7 @@
* Give the information about a room given
* @param $roomid : the id of the room
* return an array with the key as the name of the attribute
-* and the value as the value of the attribute
+* and the value as the value of the attribute
*/
function liveclassroom_api_get_infos_room($roomid) {
global $CFG;
@@ -1105,19 +1108,19 @@
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
-
+
if ( $respcode != 100) {
return false;
}
$tok = split("100 OK",$data);
$line = explode("\n",$tok[1]);
- foreach ($line as $line_value) {
- $result = explode("=",$line_value);
- $room_table[$result[0]]=$result[1];
- }
+ foreach ($line as $line_value) {
+ $result = explode("=",$line_value);
+ $room_table[$result[0]]=$result[1];
+ }
- return $room_table;
+ return $room_table;
}
@@ -1130,28 +1133,28 @@
function liveclassroom_api_get_teacher_user_id ($courseid){
global $CFG;
- $course = get_record("course", "id", $courseid);
+ $course = get_record("course", "id", $courseid);
$enc_coursename = str_replace(" ", "_", $course->shortname);
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$enc_coursename&filter01=first_name&filter01value=Teacher");
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- $line = explode("\n",$data);
-
-// $tok = split("100 OK",$data);
- // $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-// $result = liveclassroom_parse_line($tok1[0],"user_id=");
- $result = liveclassroom_parse_line($line[1],"user_id=");
- //Remove le " " at the end of the line
- //$response = substr($result,0,-1);
-
- return $result;
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ $line = explode("\n",$data);
+
+// $tok = split("100 OK",$data);
+ // $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+// $result = liveclassroom_parse_line($tok1[0],"user_id=");
+ $result = liveclassroom_parse_line($line[1],"user_id=");
+ //Remove le " " at the end of the line
+ //$response = substr($result,0,-1);
+
+ return $result;
}
@@ -1166,15 +1169,15 @@
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP;
-
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&add_user=$user");
+
+ $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&add_user=$user");
- if ( $respcode != 100 && $respcode != 301) {
- error( "Can't add user from group");
- return false;
- }
-
- return true;
+ if ( $respcode != 100 && $respcode != 301) {
+ error( "Can't add user from group");
+ return false;
+ }
+
+ return true;
}*/
@@ -1188,145 +1191,145 @@
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP;
-
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&delete_user=$user");
+
+ $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&delete_user=$user");
- if ( $respcode != 100 && $respcode != 301) {
- error( "Can't remove user from group");
- return false;
- }
-
- return true;
+ if ( $respcode != 100 && $respcode != 301) {
+ error( "Can't remove user from group");
+ return false;
+ }
+
+ return true;
}*/
function liveclassroom_api_get_room_list($userid,$course) {
- global $CFG;
-
- $final_list = "&attribute=class_id&attribute=longname&filter00=archive&filter00value=0&AccessUser=$userid";
- $enc_list = str_replace(" ", "+", $final_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
+ global $CFG;
+
+ $final_list = "&attribute=class_id&attribute=longname&filter00=archive&filter00value=0&AccessUser=$userid";
+ $enc_list = str_replace(" ", "+", $final_list);
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
- $line = explode("\n",$data);
- $rooms=array();
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ $line = explode("\n",$data);
+ $rooms=array();
- for($i=1;$i<sizeof($line)-2;$i=$i+3){
- $room[0] = liveclassroom_parse_line($line[$i],"class_id="); //class_id
- $room[1]= liveclassroom_parse_line($line[$i+1],"longname="); //longname
- array_push($rooms,$room);
- }
- return $rooms;
+ for($i=1;$i<sizeof($line)-2;$i=$i+3){
+ $room[0] = liveclassroom_parse_line($line[$i],"class_id="); //class_id
+ $room[1]= liveclassroom_parse_line($line[$i+1],"longname="); //longname
+ array_push($rooms,$room);
+ }
+ return $rooms;
}
function inputRightPlace($array, $value){
-
- $return = array();
- foreach($array as $room){
- if(strcmp($room[0],$value[0])<0) array_push($return,$room);
- else array_push($return,$value);
- }
- return $return;
+
+ $return = array();
+ foreach($array as $room){
+ if(strcmp($room[0],$value[0])<0) array_push($return,$room);
+ else array_push($return,$value);
+ }
+ return $return;
}
/*
-* List all the rooms and their archives associed + the orphaned archives list
+* List all the rooms and their archives associed + the orphaned archives list
*
* @param $userid : the user id of the current user
* @param $course : the current course
*
* Return a table composed of 3 parts:
-* - a table who list all the lecture rooms and their archives associed
-* - a table who list all the breakout rooms and their archives associed
-* - a table who list all the orphaned archives
+* - a table who list all the lecture rooms and their archives associed
+* - a table who list all the breakout rooms and their archives associed
+* - a table who list all the orphaned archives
**/
function liveclassroom_api_get_roomandarchive_list($userid,$course) {
-
- global $CFG;
-
- $final_list = "&attribute=class_id&attribute=preview&attribute=longname&attribute=archive&AccessUser=$userid";
- $enc_list = str_replace(" ", "+", $final_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
+
+ global $CFG;
+
+ $final_list = "&attribute=class_id&attribute=preview&attribute=longname&attribute=archive&AccessUser=$userid";
+ $enc_list = str_replace(" ", "+", $final_list);
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
- $studentuserid = liveclassroom_api_get_student_user_id($course->id);
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+ $studentuserid = liveclassroom_api_get_student_user_id($course->id);
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $line = explode("\n",$data);
+ $line = explode("\n",$data);
- $tabarchive = array();
- $orphanedarchives = array();
- $rooms=array(); //lecture rooms table
- $rooms1=array();//breakout rooms table
-
- for($i=1;$i<sizeof($line)-4;$i=$i+5){
+ $tabarchive = array();
+ $orphanedarchives = array();
+ $rooms=array(); //lecture rooms table
+ $rooms1=array();//breakout rooms table
+
+ for($i=1;$i<sizeof($line)-4;$i=$i+5){
- if((liveclassroom_parse_line($line[$i+3],"archive=")!=1)){ // it is a room
+ if((liveclassroom_parse_line($line[$i+3],"archive=")!=1)){ // it is a room
- $room[0] = liveclassroom_parse_line($line[$i+1],"class_id="); //class_id
- $room[1]= liveclassroom_parse_line($line[$i+2],"longname="); //longname
- $room[2]= liveclassroom_parse_line($line[$i],"preview="); //preview
- $room[3]= array();
-
- if(liveclassroom_api_role_user_room($room[0], $studentuserid)=='Student') { //lecture room
+ $room[0] = liveclassroom_parse_line($line[$i+1],"class_id="); //class_id
+ $room[1]= liveclassroom_parse_line($line[$i+2],"longname="); //longname
+ $room[2]= liveclassroom_parse_line($line[$i],"preview="); //preview
+ $room[3]= array();
+
+ if(liveclassroom_api_role_user_room($room[0], $studentuserid)=='Student') { //lecture room
- $rooms[$room[0]]=$room;
- }
- else { //Breakout room
-
- $rooms1[$room[0]]=$room;
- }
+ $rooms[$room[0]]=$room;
+ }
+ else { //Breakout room
+
+ $rooms1[$room[0]]=$room;
+ }
- }
- else { // it is an archive
-
- $archiveid=liveclassroom_parse_line($line[$i+1],"class_id=");// larchive id
- $roomid = substr($archiveid,0,strlen($archiveid)-18);//room id
-
- $archive=array();
- $archive[0]=$archiveid;
- $archive[1]=liveclassroom_parse_line($line[$i+2],"longname="); //longname
- $archive[2]=liveclassroom_parse_line($line[$i],"preview=");
- $archive[3]=$roomid; //preview
- array_push($tabarchive,$archive);
-
- }
- }
- foreach($tabarchive as $value) {
- if (array_key_exists($value[3],$rooms)) { //lecture room table
- array_push($rooms[$value[3]][3],$value);
- }
- else if (array_key_exists($value[3],$rooms1)) { //breakout room table
- array_push($rooms1[$value[3]][3],$value);
- }
- else { //orphaned archive
- array_push($orphanedarchives,$value);
- }
- }
-
- $table_result[0]=$rooms;
- $table_result[1]=$rooms1;
- $table_result[2]=$orphanedarchives;
+ }
+ else { // it is an archive
+
+ $archiveid=liveclassroom_parse_line($line[$i+1],"class_id=");// larchive id
+ $roomid = substr($archiveid,0,strlen($archiveid)-18);//room id
+
+ $archive=array();
+ $archive[0]=$archiveid;
+ $archive[1]=liveclassroom_parse_line($line[$i+2],"longname="); //longname
+ $archive[2]=liveclassroom_parse_line($line[$i],"preview=");
+ $archive[3]=$roomid; //preview
+ array_push($tabarchive,$archive);
+
+ }
+ }
+ foreach($tabarchive as $value) {
+ if (array_key_exists($value[3],$rooms)) { //lecture room table
+ array_push($rooms[$value[3]][3],$value);
+ }
+ else if (array_key_exists($value[3],$rooms1)) { //breakout room table
+ array_push($rooms1[$value[3]][3],$value);
+ }
+ else { //orphaned archive
+ array_push($orphanedarchives,$value);
+ }
+ }
+
+ $table_result[0]=$rooms;
+ $table_result[1]=$rooms1;
+ $table_result[2]=$orphanedarchives;
- return $table_result;
+ return $table_result;
}
/*
-* List all the rooms and their archives associed + the orphaned archives list
+* List all the rooms and their archives associed + the orphaned archives list
*
* @param $xmldoc : the DOM document to add the list
* @param $userid : the user id of the current user
@@ -1337,132 +1340,132 @@
**/
function liveclassroom_roomsarchiveslist($xmldoc,$userid,$courseid,$isteacher) {
- global $CFG;
+ global $CFG;
-
- $final_list = "&attribute=class_id&attribute=preview&attribute=longname&filter01=archive&filter01value=0&AccessUser=$userid";
- $enc_list = str_replace(" ", "+", $final_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
-
- $studentuserid = liveclassroom_api_get_student_user_id($courseid);
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
+
+ $final_list = "&attribute=class_id&attribute=preview&attribute=longname&filter01=archive&filter01value=0&AccessUser=$userid";
+ $enc_list = str_replace(" ", "+", $final_list);
+
+ $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, $enc_list);
+
+ $studentuserid = liveclassroom_api_get_student_user_id($courseid);
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
- $listElements = $xmldoc->create_element('listElements');
- //$orphanedArchivesForStudent = $xmldoc->createElement('orphanedArchivesForStudent');
+ $listElements = $xmldoc->create_element('listElements');
+ //$orphanedArchivesForStudent = $xmldoc->createElement('orphanedArchivesForStudent');
- $line = explode("\n",$data);
-
- $tabarchive = array();
- $orphanedArchives = liveclassroom_api_get_archive_list($userid);
-
- add_to_log($COURSE->id, "liveclassroom", "archive", "action", sizeof($orphanedArchives));
- $nbrClosedArchive = 0;
-
- for($i=1;$i<sizeof($line)-3;$i=$i+4){
+ $line = explode("\n",$data);
+
+ $tabarchive = array();
+ $orphanedArchives = liveclassroom_api_get_archive_list($userid);
+
+ add_to_log($COURSE->id, "liveclassroom", "archive", "action", sizeof($orphanedArchives));
+ $nbrClosedArchive = 0;
+
+ for($i=1;$i<sizeof($line)-3;$i=$i+4){
- $roomid= liveclassroom_parse_line($line[$i+1],"class_id="); //class_id
- $roomname= liveclassroom_parse_line($line[$i+2],"longname="); //longname
-
- $roompreview= liveclassroom_parse_line($line[$i],"preview="); //preview
+ $roomid= liveclassroom_parse_line($line[$i+1],"class_id="); //class_id
+ $roomname= liveclassroom_parse_line($line[$i+2],"longname="); //longname
+
+ $roompreview= liveclassroom_parse_line($line[$i],"preview="); //preview
- $element = $xmldoc->create_element('listElement');
+ $element = $xmldoc->create_element('listElement');
-
- $roomParameters = $xmldoc->create_element('listElementParameters');
-
- if ($isteacher=="1")
+
+ $roomParameters = $xmldoc->create_element('listElementParameters');
+
+ if ($isteacher=="1")
{
$tabarchive = liveclassroom_api_get_archive_list_for_a_room($roomid,$userid);
add_to_log($COURSE->id, "liveclassroom", "archiveteacher", "action", sizeof($tabarchive));
- foreach ($tabarchive as $tabarchive_value) {
- unset($orphanedArchives[$tabarchive_value[1]]) ;
- }
+ foreach ($tabarchive as $tabarchive_value) {
+ unset($orphanedArchives[$tabarchive_value[1]]) ;
+ }
}
else //just the open archive
{
$tabarchive = liveclassroom_api_get_open_archive_list_for_a_room($roomid,$userid);
add_to_log($COURSE->id, "liveclassroom", "archivestudent", "action", sizeof($tabarchive));
$tabarchiveall = $tabarchive = liveclassroom_api_get_archive_list_for_a_room($roomid,$userid);
- foreach ($tabarchiveall as $tabarchiveall_value) {
- unset($orphanedArchives[$tabarchiveall_value[1]]) ;
- }
+ foreach ($tabarchiveall as $tabarchiveall_value) {
+ unset($orphanedArchives[$tabarchiveall_value[1]]) ;
+ }
}
-
- if(liveclassroom_api_role_user_room($roomid, $studentuserid)=='Student') { //lecture room
- $type = $xmldoc->create_element('typeOfElement');
- $type->append_child($xmldoc->create_text_node("MainLecture"));
- $positionValue = 1;
- }
- else{
- $type = $xmldoc->create_element('typeOfElement');
- $type->append_child($xmldoc->create_text_node("Discussion"));
- $positionValue = 2;
- }
-
-
- $position = $xmldoc->create_element('position');
- $position->append_child($xmldoc->create_text_node("$positionValue"));
- $id = $xmldoc->create_element('id');
- $id->append_child($xmldoc->create_text_node("$roomid"));
- $longname = $xmldoc->create_element('nameDisplay');
- $longname->append_child($xmldoc->create_text_node("$roomname"));
- $preview = $xmldoc->create_element('preview');
- if ($roompreview=="1")
+
+ if(liveclassroom_api_role_user_room($roomid, $studentuserid)=='Student') { //lecture room
+ $type = $xmldoc->create_element('typeOfElement');
+ $type->append_child($xmldoc->create_text_node("MainLecture"));
+ $positionValue = 1;
+ }
+ else{
+ $type = $xmldoc->create_element('typeOfElement');
+ $type->append_child($xmldoc->create_text_node("Discussion"));
+ $positionValue = 2;
+ }
+
+
+ $position = $xmldoc->create_element('position');
+ $position->append_child($xmldoc->create_text_node("$positionValue"));
+ $id = $xmldoc->create_element('id');
+ $id->append_child($xmldoc->create_text_node("$roomid"));
+ $longname = $xmldoc->create_element('nameDisplay');
+ $longname->append_child($xmldoc->create_text_node("$roomname"));
+ $preview = $xmldoc->create_element('preview');
+ if ($roompreview=="1")
{
- $preview->append_child($xmldoc->create_text_node("unavailable"));
+ $preview->append_child($xmldoc->create_text_node("unavailable"));
}
else
{
$preview->append_child($xmldoc->create_text_node("available"));
}
-
-
- $roomParameters->append_child($type);
- $roomParameters->append_child($position);
- $roomParameters->append_child($id);
- $roomParameters->append_child($longname);
- $roomParameters->append_child($preview);
- $element->append_child($roomParameters);
-
- // $tabarchive = liveclassroom_api_get_archive_list_for_a_room($roomid,$userid);
-
- if(sizeof($tabarchive)>0){ //archives
-
- $nbrClosedArchive = 0;
-
- $archives = $xmldoc->create_element('archives');
-
- foreach ($tabarchive as $tabarchive_value) {
- $archive = $xmldoc->create_element('archive');
-
- $archiveid = $xmldoc->create_element('id');
- $archiveid->append_child($xmldoc->create_text_node("$tabarchive_value[1]"));
- $archivename = $xmldoc->create_element('nameDisplay');
- $archivename->append_child($xmldoc->create_text_node("$tabarchive_value[2]"));
- $archivepreview = $xmldoc->create_element('preview');
-
-
- if($tabarchive_value[0]=="1") {
- $archivepreview->append_child($xmldoc->create_text_node("unavailable"));
- $nbrClosedArchive++;
- }
- else {
- $archivepreview->append_child($xmldoc->create_text_node("available"));
- }
- $archive->append_child($archiveid);
- $arc...
[truncated message content] |