[Hw4mdl-svn] SF.net SVN: hw4mdl: [45] trunk/moodle/mod/liveclassroom/api.php
Brought to you by:
jhlinder,
trollinger
From: <sh...@us...> - 2006-08-25 09:16:01
|
Revision: 45 Author: shazan Date: 2006-08-25 02:15:56 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/hw4mdl/?rev=45&view=rev Log Message: ----------- added functions to query the server and to get the room and room list Modified Paths: -------------- trunk/moodle/mod/liveclassroom/api.php Modified: trunk/moodle/mod/liveclassroom/api.php =================================================================== --- trunk/moodle/mod/liveclassroom/api.php 2006-08-24 11:33:11 UTC (rev 44) +++ trunk/moodle/mod/liveclassroom/api.php 2006-08-25 09:15:56 UTC (rev 45) @@ -50,9 +50,9 @@ $LIVECLASSROOM_API_FUNCTION_CREATE_CLASS = 'function=createClass'; $LIVECLASSROOM_API_FUNCTION_CREATE_ROLE = 'function=createRole'; $LIVECLASSROOM_API_FUNCTION_DELETE_ROLE = 'function=deleteRole'; +$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST = 'function=listClass'; - /** * Creates a CURL session with the Live Classroom server. Upon success, it * returns a CURL Handle authenticated and ready for use. It returns false @@ -393,4 +393,135 @@ } return true; } + +/** + * Retrieve list of all rooms from the LC server available to the given user + * ID. + * + * @param userId User ID to filter by, null if none + * @param role Optional role to filter by, use ACCESS_PRIV_ constants from ListCommand. + * @param roomId + * @return List A List of LCRoom objects + * @throws + * If an error occurs in querying the server + */ + function liveclassroom_api_get_room_list($userid, $role, $roomid) { + + global $CFG; + global $LIVECLASSROOM_API_ADMIN, + $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; + + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&target=$roomid&longname=$roomname"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + + + } + +function liveclassroom_api_get_room($roomname) { + global $CFG; + 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"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + return $list; + +} + + + +/** +* Check if a room exist on the server +* +* @param roomname +*/ + + function liveclassroom_api_room_exist($roomname) { + global $CFG; + 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"); + + print $data; + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + // print($data); + $tok = split("100 OK",$data); + $tok1 = split("=END RECORD",$tok[1]); + /* while($tok) { + echo $tok."<br>"; + $tok = split("100 OK"); + $number++; + } + */ + // echo "number".$number."br"; +// print($tok1); +// echo "number".sizeof($tok1); + if(sizeof($tok1)>1){ + + return true; + } + else { + return false; + } + } + + + /** + * $param $ch + * $param $const : function called + * return $data : list of the result query + */ + function liveclassroom_api_send_query($ch,$const,$attribute) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + + if (!$ch = liveclassroom_api_authenticate()) { + return false; + } + + $url = $CFG->liveclassroom_servername. + $LIVECLASSROOM_API_ADMIN. + $const. + $attribute; + + curl_setopt($ch, CURLOPT_URL,$url); + $data = curl_exec($ch); + + if (curl_errno($ch)) { + print curl_error($ch); + return false; + } + + return $data; + } + + function liveclassroom_api_set_query_attribute($query,$attribute) { + + } + + function liveclassroom_api_set_query_filter($query) { + + } + + ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |