[Hw4mdl-svn] SF.net SVN: hw4mdl: [75] trunk/moodle/mod/liveclassroom/api.php
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-09-29 13:43:51
|
Revision: 75
http://svn.sourceforge.net/hw4mdl/?rev=75&view=rev
Author: shazan
Date: 2006-09-29 06:43:45 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
new functions :
get rooms and archives list
Modified Paths:
--------------
trunk/moodle/mod/liveclassroom/api.php
Modified: trunk/moodle/mod/liveclassroom/api.php
===================================================================
--- trunk/moodle/mod/liveclassroom/api.php 2006-09-29 13:42:12 UTC (rev 74)
+++ trunk/moodle/mod/liveclassroom/api.php 2006-09-29 13:43:45 UTC (rev 75)
@@ -146,7 +146,7 @@
global $LIVECLASSROOM_API_FUNCTION_CREATE_USER;
global $LIVECLASSROOM_MOODLE_PREFIX;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_CREATE_USER, "&target=$userid&first_name=$rolename&last_name=$coursename");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_CREATE_USER, "&target=$userid&first_name=$rolename&last_name=$coursename");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -176,7 +176,7 @@
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_CREATE_GROUP;
- $data = liveclassroom_api_send_query($ch,$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");
@@ -270,13 +270,20 @@
* @param $roomid : id of the room created
* @param $roomname : name of the room created
*/
-function liveclassroom_api_create_class ($roomid, $roomname) {
+function liveclassroom_api_create_class ($roomid, $roomname,$bool) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_CREATE_CLASS;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_CREATE_CLASS,"&target=$roomid&longname=$roomname&preview=0");
-
+ if($bool==true){ //lecture room
+ $attributes = "&target=$roomid&longname=$roomname&preview=0&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1&archive=0&can_archive=1";
+ }
+ else { //discussion room
+ $attributes = "&target=$roomid&longname=$roomname&preview=0&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1&archive=0&can_archive=1&can_liveshare=1&can_ppt_import=1";
+ }
+
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_CREATE_CLASS,$attributes);
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_create_class", "apres query".time());
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -288,7 +295,7 @@
error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
return false;
}
-
+ // add_to_log("", "liveclassroom", "", "liveclassroom_api_create_class", "avan retour".time());
return true;
}
@@ -313,7 +320,7 @@
"&role_id=$role";
//DEBUG
- add_to_log("", "liveclassroom", "", "liveclassroom_api_add_user_role", "URL Sent: $url");
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_add_user_role", "URL Sent: $url");
curl_setopt($ch, CURLOPT_URL,$url);
$data = curl_exec($ch);
@@ -355,7 +362,7 @@
"&role_id=$role";
//DEBUG
- add_to_log("", "liveclassroom", "", "liveclassroom_api_remove_user_role", "URL Sent: $url");
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_remove_user_role", "URL Sent: $url");
curl_setopt($ch, CURLOPT_URL,$url);
$data = curl_exec($ch);
@@ -394,7 +401,7 @@
"&role_id=$role";
//DEBUG
- add_to_log("", "liveclassroom", "", "liveclassroom_api_remove_group_role", "URL Sent: $url");
+ // add_to_log("", "liveclassroom", "", "liveclassroom_api_remove_group_role", "URL Sent: $url");
curl_setopt($ch, CURLOPT_URL,$url);
$data = curl_exec($ch);
@@ -425,23 +432,86 @@
* @param roomid
* @return
*/
- function liveclassroom_api_get_room_list($userid) {
+ function liveclassroom_api_get_room_list($userid,$course) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN,
+ $LIVECLASSROOM_API_RECORD_SEPERATOR,
$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&attribute=longname");
-
-
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&attribute=class_id&attribute=preview&attribute=longname&filter00=archive&filter00value=0&AccessUser=$userid");
+
+ $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
+// $studentuserid = "_moodle_hgh_S";
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", "apres get student user id".time());
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
if ( $respcode != 100) {
return false;
}
- print $data;
- return true;
+ // print $data."<br>";
+
+ $line = explode("\n",$data);
+ $j=0;
+ $k=0;
+ // $line = strtok($data,"\n");
+ // while (!empty($currentline) ) {
+ // $currentline = strtok("\n");
+ // }
+
+ for($i=1;$i<sizeof($line)-3;$i=$i+4){
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_list", "boucle".time());
+ if(liveclassroom_api_role_user_room(liveclassroom_parse_line($line[$i+1],"class_id="), $studentuserid)=='Student') { //lecture room
+ // add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_list", "boucle".time());
+ $table_result[0][$j]= liveclassroom_parse_line($line[$i+1],"class_id=");
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_list", "boucle2".$table_result[0][$j].time());
+ $table_result[0][$j+1]= liveclassroom_parse_line($line[$i],"preview=");
+ $table_result[0][$j+2]= liveclassroom_parse_line($line[$i+2],"longname=");
+ $j = $j+3;
+ }
+ else {
+ $table_result[1][$k]= liveclassroom_parse_line($line[$i+1],"class_id=");
+ $table_result[1][$k+1]= liveclassroom_parse_line($line[$i],"preview=");
+ $table_result[1][$k+2]= liveclassroom_parse_line($line[$i+2],"longname=");
+ $k = $k+3;
+ }
+
+ }
+ /*
+ $i=0;
+ $j=0;
+ $tok = split("100 OK",$data);
+ $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", "avant la boucle".time());
+ foreach($tok1 as $tok1value) {
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", "1ere boucle".time());
+ $line = explode("\n",$tok1value);
+ foreach ($line as $line_value) {
+ //add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", "2eme boucle".time());
+ $result = explode("=",$line_value);
+ $room_table[$result[0]]=$result[1];
+
+ if(liveclassroom_api_role_user_room($room_table['class_id'], $studentuserid)=='Student') { //lecture room
+ $table_result[0][$i] = $room_table;
+ add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", $room_table['class_id']." ".time());
+ $i++;
+ }
+ else { //breakout room
+ $table_result[1][$j] = $room_table;
+ add_to_log("", "liveclassroom", "", "liveclassroom_api_get_room_listp", $room_table['class_id']." ".time());
+ $j++;
+ }
+ //$table_result[$i]=$result[1];
+ // print $table_result[$i];
+ // $i++;
+ // add_to_log("", "liveclassroom", "", "liveclassroom_api_get_infos_room", $result[0]."=".$room_table[$result[0]] );
+ }
+ }
+ */
+ return $table_result;
+
+
}
@@ -458,7 +528,7 @@
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -487,7 +557,7 @@
* @param $attribute : different list of attribute for the function called
* return $data : list of the result query
*/
- function liveclassroom_api_send_query($ch,$const,$attribute) {
+ function liveclassroom_api_send_query($const,$attribute) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
@@ -536,6 +606,7 @@
function liveclassroom_parse_line($line,$pattern) {
$response = split($pattern,$line);
+ //$result = substr($response[1],0,-1);
return $response[1];
}
@@ -545,13 +616,14 @@
* @params $roomname
* return the room_id from the server
*/
+
function liveclassroom_api_get_roomid($roomname) {
global $CFG;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -581,7 +653,7 @@
global $CFG;
global $LIVECLASSROOM_API_ADMIN, $LIVECLASSROOM_API_FUNCTION_DELETE_ROOM;
- liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_DELETE_ROOM,"&target=$roomid");
+ liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_DELETE_ROOM,"&target=$roomid");
if ( $respcode == 302) {
error( "Target not found");
@@ -603,7 +675,7 @@
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM;
- liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=0");
+ liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=0");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -628,7 +700,7 @@
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM;
- liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=1");
+ liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM,"&target=$roomid&preview=1");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -650,52 +722,54 @@
*
* TO CHECK !!!!!
*/
-function liveclassroom_api_modify_attribute_room($roomid,$title,$description,$media_type,$student_eboard_enabled,$student_screengrab_enabled,$public_chatenable,$private_chatenable,$userlimit) {
+function liveclassroom_api_modify_room($roomid,$table_attributes) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM;
- $list_attributes_info ="&target=$roomid&longname=$title&description=$description" ;
+ //echo sizeof($table_attributes);
+ while (list($key, $val) = each($table_attributes)) {
+ if($key=='class_id'){
+ }
+ else $list_attributes .= "&".$key."=".$val;
+ }
+
+// echo $list_attributes;
+
- $list_attributes_media ="&media_type=$media_type&";
- $list_attributes_features ="&student-wb-enabled=$student_eboard_enabled" ; // GRAB TOOL ?? student-wb-liveapp
- $list_attributes_chat = "&chatenable=$public_chatenable&privatechatenable=$private_chatenable";
- $list_attributes_access = "&userlimit=$userlimit" ;
+ $final_list = "&target=$roomid".$list_attributes;
+ //echo $final_list;
- $final_list = $list_attributes_info.$list_attributes_media.$list_attributes_features.$list_attributes_chat.$list_attributes_access;
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $final_list);
-
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $final_list);
-
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
if ( $respcode != 100) {
return false;
}
-
-
- //Add in moodle database the new room
-
+ //modify in the moodle database!
+
return true;
}
+
/*
* List all the archive room associated with the room given
*
* @param $roomid : the id of the room
* return a table with all the archive room id
*/
-function liveclassroom_api_get_archive_list_for_a_room($roomid) {
+function liveclassroom_api_get_archive_list_for_a_room($roomid,$userid) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=class_id&filter01=archive&filter01value=1");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=preview&attribute=class_id&attribute=longname&filter01=archive&filter01value=1&AccessUser=$userid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -704,13 +778,30 @@
return false;
}
//print $data;
- $tok = split("100 OK",$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++;
+ }
+ }
+
+ /*
+ $tok = split("100 OK",$data);
$tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
$j=0;
-
- for($i=0;$i<sizeof($tok1);$i++) {
- $test = strstr($tok1[$i],$roomid);
+ foreach ($tok1 as $tok1_value) {
+ //for($i=0;$i<sizeof($tok1);$i++) {
+ // $test = strstr($tok1[$i],$roomid);
+ $test = strstr($tok1_value,$roomid);
if($test!=false){
// print "yrr";
// $result = liveclassroom_parse_line($tok1[$i],"class_id=");
@@ -719,8 +810,8 @@
$list_return[$j]=$response;
$j++;
}
-
}
+ */
return $list_return;
}
@@ -739,7 +830,7 @@
$name = $course->shortname;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$name");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$name");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -771,7 +862,7 @@
global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM;
- $data = liveclassroom_api_send_query($ch,$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];
@@ -792,7 +883,7 @@
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM;
- $data = liveclassroom_api_send_query($ch,$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];
@@ -819,7 +910,7 @@
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
global $LIVECLASSROOM_API_FUNCTION_LIST_ROLE;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_ROLE, "&attribute=role_id&filter01=user_id&filter01value=$userid&filter02=object_id&filter02value=$roomid");
+ $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];
@@ -849,7 +940,7 @@
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
global $LIVECLASSROOM_API_FUNCTION_LIST_USER;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$lastname&filter01=first_name&filter01value=Student");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$lastname&filter01=first_name&filter01value=Student");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -858,6 +949,18 @@
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;
+
+/*
$tok = split("100 OK",$data);
$tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
$result = liveclassroom_parse_line($tok1[0],"user_id=");
@@ -865,7 +968,7 @@
$response = substr($result,0,-1);
return $response;
-
+*/
}
@@ -881,7 +984,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&filter00=class_id&filter00value=$roomid&filter01=preview&filter01value=0");
+ $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];
@@ -911,7 +1014,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=archive&filter01=class_id&filter01value=$roomid");
+ $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];
@@ -999,7 +1102,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=description&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=description&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1030,7 +1133,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=longname&filter00=class_id&filter00value=$roomid");
+ $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];
@@ -1064,7 +1167,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=media_type&filter00=class_id&filter00value=$roomid");
+ $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];
@@ -1098,7 +1201,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=hms_two_way_enabled&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=hms_two_way_enabled&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1134,7 +1237,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=hms_simulcast_restricted&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=hms_simulcast_restricted&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1171,7 +1274,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=userlimit&filter00=class_id&filter00value=$roomid");
+ $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];
@@ -1204,7 +1307,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=privatechatenable&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=privatechatenable&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1241,7 +1344,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_ppt_import&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_ppt_import&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1278,7 +1381,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_liveshare&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_liveshare&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1315,7 +1418,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_archive&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=can_archive&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1352,7 +1455,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=student-wb-liveapp&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=student-wb-liveapp&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1389,7 +1492,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=student-wb-enabled&filter00=class_id&filter00value=$roomid");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&attribute=student-wb-enabled&filter00=class_id&filter00value=$roomid");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1427,7 +1530,7 @@
global $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
global $LIVECLASSROOM_API_RECORD_SEPERATOR;
- $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&filter00=class_id&filter00value=$roomid&attribute=archive&attribute=can_archive&attribute=can_eboard&attribute=can_liveshare&attribute=can_ppt_import&attribute=chatenable&attribute=privatechatenable&attribute=description&attribute=hms_simulcast&attribute=hms_simulcast_restricted&attribute=hms_two_way_enabled&attribute=media_type&attribute=preview&attribute=student_wb_enabled&attribute=student_wb_liveapp&attribute=userlimit&attribute=longname");
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&filter00=class_id&filter00value=$roomid&attribute=archive&attribute=can_archive&attribute=can_eboard&attribute=can_liveshare&attribute=can_ppt_import&attribute=chatenable&attribute=privatechatenable&attribute=description&attribute=hms_simulcast&attribute=hms_simulcast_restricted&attribute=hms_two_way_enabled&attribute=media_type&attribute=preview&attribute=student_wb_enabled&attribute=student_wb_liveapp&attribute=userlimit&attribute=longname");
preg_match("(\d*)", $data, $matches);
$respcode = $matches[0];
@@ -1438,16 +1541,51 @@
$tok = split("100 OK",$data);
$line = explode("\n",$tok[1]);
- for($i=0;$i<sizeof($line);$i++) {
- $result = explode("=",$line[$i]);
+ foreach ($line as $line_value) {
+ // for($i=0;$i<sizeof($line);$i++) {
+ $result = explode("=",$line_value);
$room_table[$result[0]]=$result[1];
+ // add_to_log("", "liveclassroom", "", "liveclassroom_api_get_infos_room", $result[0]."=".$room_table[$result[0]] );
}
return $room_table;
}
+/*
+* Give the user id for a room -- because of the link between the course->shortname and the user last_name
+*
+* @param $lastname : string user last_name
+* return a string : the id of the student user for a course
+*/
+function liveclassroom_api_get_teacher_user_id ($lastname){
+ global $CFG;
+ global $LIVECLASSROOM_API_ADMIN;
+ global $LIVECLASSROOM_API_RECORD_SEPERATOR;
+ global $LIVECLASSROOM_API_FUNCTION_LIST_USER;
+
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$lastname&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;
+
+}
+
/**
* Enroll the given user into the group.
*
@@ -1493,7 +1631,7 @@
}*/
/*
-function liveclassroom_api_get_room($roomname) {
+function ($roomname) {
global $CFG;
global $LIVECLASSROOM_API_ADMIN,
$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
@@ -1510,4 +1648,193 @@
}
*/
+
+
+
+/*
+* 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
+**/
+function liveclassroom_api_get_roomandarchive_list($userid,$course) {
+
+ global $CFG;
+ global $LIVECLASSROOM_API_ADMIN,
+ $LIVECLASSROOM_API_RECORD_SEPERATOR,
+ $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
+
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&attribute=class_id&attribute=preview&attribute=longname&attribute=archive&AccessUser=$userid");
+
+ $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+
+ $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){
+
+ 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
+
+ $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;
+
+ return $table_result;
+
+}
+
+function liveclassroom_create_xml() {
+
+ global $CFG;
+ global $LIVECLASSROOM_API_ADMIN,
+ $LIVECLASSROOM_API_RECORD_SEPERATOR,
+ $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST;
+
+ // Cr\xE9ation d'un nouvel objet document
+ $doc = new DOMDocument('1.0', 'ISO-8859-1');
+
+ $data = liveclassroom_api_send_query($LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&attribute=class_id&attribute=preview&attribute=longname&attribute=archive&AccessUser=$userid");
+
+ $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+
+ $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){
+
+ 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
+
+ $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;
+
+
+
+
+
+
+ $xml = '<racine><element>texte</element></racine>';
+ $doc->loadXML($xml);
+
+ // Cr\xE9ation de l'\xE9l\xE9ment racine
+ $root = $dom->createElement($xmlObject->root->name);
+ $dom->appendChild($root);
+
+ // appel d'une fonction r\xE9cursive qui construit l'\xE9l\xE9ment XML
+ // \xE0 partir de l'objet, en parcourant tout l'arbre de l'objet.
+ setElement($dom, $xmlObject->root, $root);
+
+ // Mise \xE0 jour du fichier source original
+ $dom->save($xmlObject->source);
+ echo $xmlObject->source;
+}
+
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|