Revision: 212
http://hw4mdl.svn.sourceforge.net/hw4mdl/?rev=212&view=rev
Author: trollinger
Date: 2008-01-10 09:23:50 -0800 (Thu, 10 Jan 2008)
Log Message:
-----------
delete old files
Modified Paths:
--------------
branches/team/Thomas/moodle/mod/liveclassroom/index.php
Removed Paths:
-------------
branches/team/Thomas/moodle/mod/liveclassroom/api.php
branches/team/Thomas/moodle/mod/liveclassroom/manageRoomAction.php
Deleted: branches/team/Thomas/moodle/mod/liveclassroom/api.php
===================================================================
--- branches/team/Thomas/moodle/mod/liveclassroom/api.php 2008-01-10 08:29:35 UTC (rev 211)
+++ branches/team/Thomas/moodle/mod/liveclassroom/api.php 2008-01-10 17:23:50 UTC (rev 212)
@@ -1,1569 +0,0 @@
-<?PHP
-/******************************************************************************
- * *
- * Copyright (c) 1999-2006 Horizon Wimba, All Rights Reserved. *
- * *
- * COPYRIGHT: *
- * This software is the property of Horizon Wimba. *
- * You can redistribute it and/or modify it under the terms of *
- * the GNU General Public License as published by the *
- * Free Software Foundation. *
- * *
- * WARRANTIES: *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with the Horizon Wimba Moodle Integration; *
- * if not, write to the Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- * *
- * Author: Hugues Pisapia *
- * *
- * Date: 15th April 2006 *
- * *
- ******************************************************************************/
-
-/* $Id: api.php 180 2007-01-11 21:55:02Z hugues $ */
-
-/**
- * api.php - Sets up sessions, connects to LC server and so on
- *
- * This is the API to authenticate and perform transactions with the Live cLassroom server
- * All functions here should start with liveclassroom_api_
- *
- * Normally this is only called by liveclassroom *lib.php files
- * @author Hugues Pisapia
- * @version $Revision: 180 $
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package liveclassroom
- */
-
-require_once('lib.php');
-
-define("LIVECLASSROOM_MOODLE_PREFIX", liveclassroom_api_get_prefix());
-
-define("LIVECLASSROOM_API_ADMIN","/admin/api/api.pl?");
-define("LIVECLASSROOM_API_FUNCTION_NOOP","function=NOOP");
-define("LIVECLASSROOM_API_FUNCTION_CREATE_USER","function=createUser");
-define("LIVECLASSROOM_API_FUNCTION_MODIFY_USER","function=modifyUser");
-define("LIVECLASSROOM_API_FUNCTION_LIST_USER","function=listUser");
-define("LIVECLASSROOM_API_FUNCTION_GET_TOKEN","function=getAuthToken");
-define("LIVECLASSROOM_API_FUNCTION_CREATE_CLASS","function=createClass");
-define("LIVECLASSROOM_API_FUNCTION_DELETE_ROOM","function=deleteClass");
-define("LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM","function=modifyClass");
-define("LIVECLASSROOM_API_FUNCTION_CREATE_ROLE","function=createRole");
-define("LIVECLASSROOM_API_FUNCTION_DELETE_ROLE","function=deleteRole");
-define("LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST","function=listClass");
-define("LIVECLASSROOM_API_FUNCTION_LIST_ROLE","function=listRole");
-define("LIVECLASSROOM_API_FUNCTION_CREATE_GROUP","function=createGroup");
-define("LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP","function=modifyGroup");
-define("LIVECLASSROOM_API_FUNCTION_STATUS","function=statusServer");
-
-define("LIVECLASSROOM_API_RECORD_SEPERATOR","=END RECORD");
-
-
-/*
-* 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;
-
- //get the admin user name
- $aun = $CFG->liveclassroom_adminusername;
- if( (substr($aun, 0,1)=='_') && (substr($aun, -1,1)=='_') ) { //Prefix
- $prefix = $aun;
-
- }
- else {
- $prefix = '';
-
- }
- return $prefix;
-
-}
-
-/**
- * Creates a CURL session with the Live Classroom server. Upon success, it
- * returns a CURL Handle authenticated and ready for use. It returns false
- * otherwise.
- *
- * If the $servername param is the empty string, the function will collect
- * the data from $CFG->liveclassroom_*
- *
- * @param string $servername
- * @param string $login
- * @param string $password
- * @return object - a CURL Handle authenticated and ready for use, false otherwise
- * @uses CFG, LIVECLASSROOM_API_ADMIN, LIVECLASSROOM_API_FUNCTION_NOOP
- */
-function liveclassroom_api_authenticate ($servername='', $login='', $passwd='') {
- global $CFG;
- global $COURSE;
-
- if (empty($servername)) { // feed them with $CFG
- $servername = $CFG->liveclassroom_servername;
- $login = $CFG->liveclassroom_adminusername;
- $passwd = $CFG->liveclassroom_adminpassword;
- }
-
- $url = $servername.
- LIVECLASSROOM_API_ADMIN.
- LIVECLASSROOM_API_FUNCTION_NOOP.
- "&AuthType=AuthCookieHandler".
- "&AuthName=Horizon".
- "&credential_0=". $login.
- "&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
- fputs($cook,time()); // Add the current time into the file = last authenticate time
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 4);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- $data = curl_exec($ch);
-
- if (curl_errno($ch)) {
- 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 ) {
- 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;
- }
- else if ( $resp_code != 100 && $resp_code != 301) {
- //error( "Response: Authentication Failed: $resp_code");
- add_to_log($COURSE->id, "liveclassroom", "Authentication", liveclassroom_send_logs("errorAuthentication","respcode=$resp_code&courseId=".$COURSE->id), "Authentication Failed");
- return false;
- }
-
-
- curl_close($ch);
- //fclose($cook);
- add_to_log($COURSE->id, "liveclassroom", "Authentication", liveclassroom_send_logs("authentication","courseId=".$COURSE->id), "Authentication succeeded");
- return $ch;
-
-}
-
- /**
- * 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
- * @param $attribute : different list of attributes for the function called
- * return $data : result query
- */
- function liveclassroom_api_send_query($const,$attribute) {
- 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);
-
- }
- 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;
- }
- }
-
-
- $url = $CFG->liveclassroom_servername.
- LIVECLASSROOM_API_ADMIN.
- $const.
- $attribute;
-
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 4);
- 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;
- }
-
-
-
-
-/**
- * Create the Live Classroom User $user with the role $rolename. This function
- * actually creates profiles that will further be used for teacher/student
- * roles.
- *
- * @uses CFG, LIVECLASSROOM_API_ADMIN, LIVECLASSROOM_API_FUNCTION_CREATE_USER
- * @param $userid string - LC login for this profile
- * @param $coursename string - LC first name for this profile. We use the couse name
- * @param $rolename string - LC lastname of this profile. Usually 'Teacher' or 'Student'
- * @return bool - true if the user is successfuly created, false otherwise
- */
-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);
-
- $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;
-
-}
-
-/*
-* Create a group on the LC server
-* @param $groupid : id of the group created
-*
-*/
-function liveclassroom_api_create_group($groupid) {
-
- global $CFG;
-
- $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;
- }
-
-
- return true;
-
-
-}
-
-/**
- * Returns a session id (hzA) to be inserted in URLs to access the LC server
- * @uses CFG, USER
- * @uses LIVECLASSROOM_API_ADMIN, LIVECLASSROOM_API_FUNCTION_GET_TOKEN
- * @param $userid string - the userid/login of the profile to be used
- * @param $nickname string - the name of the user that will be displayed in the LC
- * @return string - the session token (hzA) if the request was successful,
- * false otherwise.
- */
-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);
-
-
- $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.");
- return false;
- }
-
- $currentline = strtok($data,"\n");
- while (!empty($currentline) && !preg_match("/authToken=/", $currentline, $matches)) {
- $currentline = strtok("\n");
- }
-
- if (empty($currentline)) {
- //error ("Did not find authToken, data=<pre>$data</pre>");
- return false;
- }
-
-
- $authtoken= substr($currentline, 10);
-
- //DEBUG
-
-
- if (empty($authtoken)) {
- //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");
-
- return $authtoken;
-}
-
-/*
-* Create a room on the LC server
-* @param $roomid : id of the room created
-* @param $roomname : name of the room created
-* return true if the room is created on the server, false otherwise
-*/
-function liveclassroom_api_create_class ($roomid, $roomname, $bool, $attributes) {
- global $CFG;
- global $COURSE;
-
- $list_attributes = '';
-
- unset($attributes['longname']);
- unset($attributes['led']);
-
- while (list($key, $val) = each($attributes)) {
- if(($key!='class_id')&&(isset($val))&&($val!="")){
- $list_attributes .= "&".$key."=".$val;
- }
- }
-
- $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;
- }
-
- add_to_log($COURSE->id, "liveclassroom", "Create Room", liveclassroom_send_logs("createClass","roomname=$roomname&courseId=".$COURSE->id), "$roomname create with success");
- return true;
-}
-
-/*
-* Add a role to a user for a room given
-* @param $roomid : id of the room on the server
-* @param $userid : id of the user on the server
-* @param $role : role of the user for the room
-* return true if the role is added, false otherwise
-*/
-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");
-
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- //error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
- return false;
- }
-
- return true;
-}
-
-/*
-* Remove a role to a user for a room given
-* @param $roomid : id of the room on the server
-* @param $userid : id of the user on the server
-* @param $role : role of the user for the room
-* return true if the role is removed, false otherwise
-*/
-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");
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- //error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
- return false;
- }
- return true;
-}
-
-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");
-
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- //error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
- return false;
- }
- return true;
-}
-
-
-
-
-/**
-* Check if a room exist on the server
-* @param roomname
-* return true if the room exist, false otherwise
-*/
-
- function liveclassroom_api_room_exist($roomname) {
- global $CFG;
-
- $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]);
-
- if(sizeof($tok1)>1){
-
- return true;
- }
- else {
- return false;
- }
- }
-
-
-
-
-/**
-*
-* 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);
-
-
- return $response[1];
-
-}
-
-/**
-* Get the room id from a roomname
-* @param $roomname
-* return the room_id from the server
-*/
-
-function liveclassroom_api_get_roomid($roomname) {
- global $CFG;
-
- $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);
-
- return $response;
-}
-
-
-
-
- /**
- * delete Room from the server
- *
- * @param roomid : id of the to delete
- * 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");
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- 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) {
- 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;
- }
-
- /**
- * Open Room on the LC server
- *
- * @param roomid : id of the room to open
- * 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;
- }
- 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;
- }
-
- /**
- * Close Room on the LC server
- *
- * @param roomid : id of the room to close
- * 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;
- }
- 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;
-}
-
-
-/*
-* Modify the settings of a room
-* @param $roomid : the id of the room
-* return true if the room has being modified, false otherwise
-* return true if the room has being modified, false otherwise
-*/
-function liveclassroom_api_modify_room($roomid,$table_attributes) {
- global $CFG;
- global $COURSE;
-
- $list_attributes = "";
-
- while (list($key, $val) = each($table_attributes)) {
- if(($key!='class_id')&&(isset($val))&&($val!="")){
- $list_attributes .= "&".$key."=".$val;
- }
- }
-
- $final_list = "&target=$roomid".$list_attributes;
-
- $enc_list = str_replace(" ", "+", $final_list);
-
-//DEBUG:
-//error($enc_list);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $enc_list);
-
- preg_match("(\d*)", $data, $matches);
- $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("modifyRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been modified with success");
- return true;
-}
-
-
-
-
-/*
-* List all the archive room associated with the room given
-*
-* @param $roomid : the id of the room
-* @param $userid : the id of the user
-* return an array with all the archive room id
-*/
-function liveclassroom_api_get_archive_list_for_a_room($roomid,$userid) {
- global $CFG;
-
- $final_list = "&attribute=preview&attribute=class_id&attribute=longname&filter01=archive&filter01value=1&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;
- }
- //print $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;
-}
-
-/*
-* List all the open archive room associated with the room given
-*
-* @param $roomid : the id of the room
-* @param $userid : the id of the user
-* return an array with all the archive room id
-*/
-function liveclassroom_api_get_open_archive_list_for_a_room($roomid,$userid) {
- global $CFG;
-
- $final_list = "&attribute=preview&attribute=class_id&attribute=longname&filter01=archive&filter01value=1&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;
- }
- //print $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++;
- }
- }
- }
-
-
- return $list_return;
-
-}
-
-/*
-* List all the archive room (used for the orphaned archives)
-*
-* @param $roomid : the id of the room
-* return an array with all the archive room id
-*/
-function liveclassroom_api_get_archive_list($userid) {
- global $CFG;
-
- $final_list = "&attribute=preview&attribute=class_id&attribute=longname&filter01=archive&filter01value=1&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;
- }
- //print $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++;
-
- }
-
-
- return $list_return;
-}
-
-/*
-* Check if a user exist in the course given
-* link : user last name = course shortname
-* @param $course : an instance of a course
-* Return boolean : true if the user exist, false if not!
-*/
-
-function liveclassroom_api_user_exist($course) {
- global $CFG;
-
- $name = $course->shortname;
- $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;
- }
-
- $tok = split("100 OK",$data);
- $tok1 = split(LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
-
- 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');
-
- /*
- $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;
- }
- return true;
- */
- return $attributes;
-}
-
-/*
-* 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');
-
-
-
- /*
- $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;
-}
-
-
-/*
-* Give the role of the user on a room given
-*
-* @param $roomid : the id of the room
-* @param $userid : the id of the user
-*
-* return a string : the role of the user
-*/
-function liveclassroom_api_role_user_room($roomid, $userid) {
- 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;
- }
-
- $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;
-
-}
-
-/*
-* 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_student_user_id ($courseid){
- global $CFG;
-
- $course = get_record("course", "id", $courseid);
-
- if (empty($course)) {
- error(_FUNCTION_." empty course");
- }
- $enc_coursename = str_replace(" ", "_", $course->shortname);
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter01=last_name&filter01value=$enc_coursename&filter02=first_name&filter02value=Student");
-
- preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
-
- if ( $respcode != 100) {
- return false;
- }
-
- $line = explode("\n",$data);
-
- $result = liveclassroom_parse_line($line[1],"user_id=");
-
- return $result;
-
-
-}
-
-
-
-
-/* Check if the room is open or not (preview=0 => room is open)
-* @param $roomid : the id of the room
-* return a boolean : true if the room is open, false if it's closed
-*/
-function liveclassroom_api_room_is_preview ($roomid){
- global $CFG;
-
- $data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST, "&filter01=class_id&filter01value=$roomid&filter02=preview&filter02value=0");
-
- 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]);
-
- if(sizeof($tok1)>1){
- return true;
- }
- else {
- return false;
- }
-}
-
-/* Check if the room is an archive
-* @param $roomid : the id of the room
-* return a boolean : true if the room is an archive, false if it's closed
-*/
-function liveclassroom_api_room_is_archive ($roomid){
- global $CFG;
-
- $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;
- }
-
- $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
-*/
-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;
- }
-
- $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
-*/
-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;
-
-}
-
-
-
-/*
-* 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;
-
-}
-
-
-/*
-* 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
-*/
-function liveclassroom_api_get_infos_room($roomid) {
- global $CFG;
-
- $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];
-
- 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];
- }
-
- 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 ($courseid){
- global $CFG;
-
- $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;
-
-}
-
-/**
- * Enroll the given user into the group.
- *
- * @param userid
- * @param groupid
- *//*
-function liveclassroom_api_add_user_in_group($userid, $groupid) {
-
- 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");
-
- if ( $respcode != 100 && $respcode != 301) {
- error( "Can't add user from group");
- return false;
- }
-
- return true;
-
-}*/
-
- /**
- * Remove the given user from the group.
- *
- * @param userif
- * @param groupif
- *//*
-function liveclassroom_api_remove_user_from_group($userid, $groupid) {
- 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");
-
- 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);
-
- 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;
-}
-
-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;
-}
-
-/*
-* 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;
-
- $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;
- }
-
- $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;
-
-}
-
-
-/*
-* 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
-* @param $course : the current course
-* @param $isteacher : 1 if the user is a teacher, 0 else
-*
-* Return a DOM document element who list all the rooms and their archives associed
-**/
-function liveclassroom_roomsarchiveslist($xmldoc,$userid,$courseid,$isteacher) {
-
- 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;
- }
-
- $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){
-
- $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');
-
-
- $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]]) ;
- }
- }
- 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]]) ;
- }
- }
-
- 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"));
- }
- 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);
- $archive->append_child($archivename);
- $archive->append_child($archivepreview);
- $archives->append_child($archive);
-
- /*
- if ( ($roompreview==1) && ($tabarchive_value[0]==0))
- {
-
- $id_orphanedArchiveForStudent = $xmldoc->createElement("id");
- $id_orphanedArchiveForStudent->appendChild($xmldoc->createTextNode("$tabarchive_value[1]"));
-
- $longname_orphanedArchiveForStudent = $xmldoc->createElement("longname");
- $longname_orphanedArchiveForStudent->appendChild($xmldoc->createTextNode("$tabarchive_value[2]"));
-
- $preview_orphanedArchiveForStudent = $xmldoc->createElement("preview");
-
- $preview_orphanedArchiveForStudent->appendChild($xmldoc->createTextNode("available"));
-
- $xmlOrphanedArchiveForStudent->appendChild($id_orphanedArchiveForStudent);
- $xmlOrphanedArchiveForStudent->appendChild($longname_orphanedArchiveForStudent);
- $xmlOrphanedArchiveForStudent->appendChild($preview_orphanedArchiveForStudent);
-
- $orphanedArchivesForStudent->appendChild(xmlOrphanedArchiveForStudent);
- }
- */
- }
- $roomParameters->append_child($archives);
-
-
-
- }
- $closedArchive = $xmldoc->create_element("closedArchive");
- if (sizeof($tabarchive) == $nbrClosedArchive)
- {
- $closedArchive->append_child($xmldoc->create_text_node("true"));
-
- }
- else
- {
- $closedArchive->append_child($xmldoc->create_text_node("false"));
- }
- $roomParameters->append_child($closedArchive);
-
- $element->append_child($roomParameters);
-
-
- $listElements->append_child($element);
- }
- add_to_log($COURSE->id, "liveclassroom", "orphaned", "action", sizeof($orphanedArchives));
- foreach ($orphanedArchives as $orphanedArchive)
- {
- $xmlOrphanedArchive = $xmldoc->create_element("listElement");
-
- $parametersOrphaned = $xmldoc->create_element("listElementParameters");
-
- $typeOrphaned = $xmldoc->create_element("typeOfElement");
- $typeOrphaned->append_child($xmldoc->create_text_node("orphanedArchive"));
- $parametersOrphaned->append_child($typeOrphaned);
-
-
- $pos = $xmldoc->create_element("position");
- $pos->append_child($xmldoc->create_text_node("3"));
- $parametersOrphaned->append_child($pos);
-
-
- $typeOrphanedArchive = $xmldoc->create_element("type");
- if(liveclassroom_api_role_user_room($orphanedArchive[1], $studentuserid)=='Student') { //lecture room
- $typeOrphanedArchive->append_child($xmldoc->create_text_node("MainLecture"));
- }
- else{
- $typeOrphanedArchive->append_child($xmldoc->create_text_node("Discussion"));
- }
- $parametersOrphaned->append_child($typeOrphanedArchive);
-
- $idOrphanedArchive = $xmldoc->create_element("id");
- $idOrphanedArchive->append_child($xmldoc->create_text_node($orphanedArchive[1]));
- $parametersOrphaned->append_child($idOrphanedArchive);
-
- $longnameOrphanedArchive = $xmldoc->create_element("nameDisplay");
- $longnameOrphanedArchive->append_child($xmldoc->create_text_node($orphanedArchive[2]));
- $parametersOrphaned->append_child($longnameOrphanedArchive);
-
- $previewOrphanedArchive = $xmldoc->create_element("preview");
-
- if ($orphanedArchive[$j][0]==1)
- {
- $previewOrphanedArchive->append_child($xmldoc->create_text_node("unavailable"));
- }
- else
- {
- $previewOrphanedArchive->append_child($xmldoc->create_text_node("available"));
- }
- $parametersOrphaned->append_child($previewOrphanedArchive);
-
-
- $xmlOrphanedArchive->append_child($parametersOrphaned);
-
- $listElements->append_child($xmlOrphanedArchive);
- }
-
-
- $xmldoc->append_child($listElements);
-
-
- return $listElements;
-
-
-}
-
-?>
Modified: branches/team/Thomas/moodle/mod/liveclassroom/index.php
===================================================================
--- branches/team/Thomas/moodle/mod/liveclassroom/index.php 2008-01-10 08:29:35 UTC (rev 211)
+++ branches/team/Thomas/moodle/mod/liveclassroom/index.php 2008-01-10 17:23:50 UTC (rev 212)
@@ -37,7 +37,7 @@
require_once("lib.php");
require_once("lib/common/WimbaCommons.php");
-
+require_once("lib/common/WimbaLib.php");
$id = optional_param('id', 0, PARAM_INT);
$roomname = optional_param('idroomname', 0, PARAM_TEXT);
Deleted: branches/team/Thomas/moodle/mod/liveclassroom/manageRoomAction.php
===================================================================
--- branches/team/Thomas/moodle/mod/liveclassroom/manageRoomAction.php 2008-01-10 08:29:35 UTC (rev 211)
+++ branches/team/Thomas/moodle/mod/liveclassroom/manageRoomAction.php 2008-01-10 17:23:50 UTC (rev 212)
@@ -1,154 +0,0 @@
-<?php
-/******************************************************************************
- * *
- * Copyright (c) 1999-2007 Horizon Wimba, All Rights Reserved. *
- * *
- * COPYRIGHT: *
- * This software is the property of Horizon Wimba. *
- * You can redistribute it and/or modify it under the terms of *
- * the GNU General Public License as published by the *
- * Free Software Foundation. *
- * *
- * WARRANTIES: *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with the Horizon Wimba Moodle Integration; *
- * if not, write to the Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- * *
- * Author: Samy Hazan *
- * *
- * Date: September 2006 *
- * *
- ******************************************************************************/
-
-/* $Id: manageRoomAction.php 188 2007-04-13 13:23:01Z hugues $ */
-
-/* This page manage the action create, update, delete for a room */
-require_once('../../config.php');
-require_once('lib.php');
-
-$courseid = optional_param('enc_course_id', 0, PARAM_INT);
-$action = required_param('action', PARAM_ALPHA);
-$time = required_param('time', PARAM_INT);
-
-require_login($courseid, false);
-
-$course = get_record("course", "id", $courseid);
-if (isguest()) {
- error("Guests are not allowed to create rooms", $_SERVER["HTTP_REFERER"]);
-}
-
-if (isstudent($courseid)) {
- error("Students are not allowed to create rooms", $_SERVER["HTTP_REFERER"]);
-}
-
-if (!liveclassroom_init_session($_GET)) {
- error("ExpiredSessionException");
-}
-
-$url = liveclassroom_get_url_params($courseid);
-
-session_start(); // to get the previous type of the room
-
-
-if(!empty($_POST)) {
- while (list($key, $val) = each($_POST)) {
- $list_attributes[$key] = $val;
- }
-}
-
-
-if(isteacher($courseid)) {
-
- $instructor_led = ($list_attributes['led']=='instructor');
-
- if($action=='createRoom') {
-
- if($list_attributes['led']=='instructor'){
- if (!isset($list_attributes['student_wb_liveapp'])) $list_attributes['student_wb_liveapp']="0";
- if (!isset($list_attributes['hms_two_way_enabled'])) $list_attributes['hms_two_way_enabled']="0";
- if (!isset($list_attributes['hms_simulcast_restricted'])) $list_attributes['hms_simulcast_restricted']=1;
- }
- else {
- if (!isset($list_attributes['can_archive'])) $list_attributes['can_archive']="0";
- if (!isset($list_attributes['can_liveshare'])) $list_attributes['can_liveshare']="0";
- if (!isset($list_attributes['can_ppt_import'])) $list_attributes['can_ppt_import']="0";
- }
-
- //Available
- if (!isset($list_attributes['preview'])) $list_attributes['preview']=1;
- if (!isset($list_attributes['student_wb_enabled'])) $list_attributes['student_wb_enabled']="0";
- //user limit
- if (isset($list_attributes['userlimit']) && $list_attributes['userlimit']==0) $list_attributes['userlimit']=$list_attributes['userlimitvalue'];
-
- if (!liveclassroom_create_room ($courseid, $list_attributes['longname'], $instructor_led, $list_attributes)) {
- notice(get_string("roomcreationfailed", "liveclassroom"), $_SERVER["HTTP_REFERER"]);
- exit;
- }
- $messageType = 'roomCreated';
- }
- else if($action=='updateRoom') {
-
- if($instructor_led){
- if (!isset($list_attributes['student_wb_liveapp'])) $list_attributes['student_wb_liveapp']="0";
- if (!isset($list_attributes['hms_two_way_enabled'])) $list_attributes['hms_two_way_enabled']="0";
- if (!isset($list_attributes['hms_simulcast_restricted'])) $list_attributes['hms_simulcast_restricted']=1;
- }
- else {
- if (!isset($list_attributes['can_archive'])) $list_attributes['can_archive']="0";
- if (!isset($list_attributes['can_liveshare'])) $list_attributes['can_liveshare']="0";
- if (!isset($list_attributes['can_ppt_import'])) $list_attributes['can_ppt_import']="0";
- }
-
- //Available
- if (!isset($list_attributes['preview'])) $list_attributes['preview']=1;
- if (!isset($list_attributes['student_wb_enabled'])) $list_attributes['student_wb_enabled']="0";
-
- if (isset($list_attributes['userlimit']) && $list_attributes['userlimit']==0) $list_attributes...
[truncated message content] |