Revision: 214
http://hw4mdl.svn.sourceforge.net/hw4mdl/?rev=214&view=rev
Author: trollinger
Date: 2008-01-11 08:47:18 -0800 (Fri, 11 Jan 2008)
Log Message:
-----------
add a file to group the common function
Added Paths:
-----------
branches/team/Thomas/moodle/mod/liveclassroom/lib/common/WimbaLib.php
Added: branches/team/Thomas/moodle/mod/liveclassroom/lib/common/WimbaLib.php
===================================================================
--- branches/team/Thomas/moodle/mod/liveclassroom/lib/common/WimbaLib.php (rev 0)
+++ branches/team/Thomas/moodle/mod/liveclassroom/lib/common/WimbaLib.php 2008-01-11 16:47:18 UTC (rev 214)
@@ -0,0 +1,281 @@
+<?php
+/**
+ * Returns the keys of the general parameters passed by GET or POST
+ */
+function getKeysOfGeneralParameters(){
+
+ return array(
+ array("value"=>"enc_courseId","type"=>PARAM_INT,"default_value"=>null),
+ array("value"=>"enc_email","type"=>PARAM_CLEAN,"default_value"=>null),
+ array("value"=>"enc_firstname","type"=>PARAM_ALPHANUM,"default_value"=>null),
+ array("value"=>"enc_lastname","type"=>PARAM_ALPHANUM,"default_value"=>null),
+ array("value"=>"enc_role","type"=>PARAM_ALPHA,"default_value"=>null),
+ array("value"=>"time","type"=>PARAM_INT,"default_value"=>null),
+ array("value"=>"signature","type"=>PARAM_ALPHANUM,"default_value"=>null),
+ array("value"=>"product","type"=>PARAM_ALPHA,"default_value"=>null),
+ array("value"=>"type","type"=>PARAM_ALPHA,"default_value"=>null),
+ array("value"=>"studentView","type"=>PARAM_BOOL,"default_value"=>null),
+ array("value"=>"createWorkflow","type"=>PARAM_BOOL,"default_value"=>null),
+
+ );
+
+}
+
+
+function getKeyWimbaClassroomForm(){
+
+
+ return array (
+ array("value"=>"longname","type"=>PARAM_CLEAN,"default_value"=>null),
+ array("value"=>"description","type"=>PARAM_CLEAN,"default_value"=>null),
+ array("value"=>"led","type"=>PARAM_ALPHA,"default_value"=>"instructor"),
+ array("value"=>"hms_two_way_enabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"enable_student_video_on_startup","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"hms_simulcast_restricted","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"video_bandwidth","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"status_appear","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"enabled_breakoutrooms","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"archiveEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"appshareEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"pptEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"chatEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"privateChatEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"accessAvailable","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"privateChatEnabled","type"=>PARAM_BOOL,"default_value"=>0),
+ array("value"=>"userlimit","type"=>PARAM_INT,"default_value"=>-1)
+ ) ;
+}
+
+
+function isSwitch(){
+ global $USER;
+
+ if((isset($USER->studentview) && $USER->studentview==1) || (!empty($USER->switchrole)) ) {
+ return true;
+ }
+ return false;
+
+
+}
+function getRoleForWimbaTools($courseId,$userId){
+ global $CFG;
+ global $USER;
+ $role="";
+ if(strstr($CFG->release,"1.7")) {
+ $context = get_context_instance(CONTEXT_COURSE, $courseId) ;
+ }
+
+ //the role of the current user is switched
+ //the role of the current user is switched
+ if((isset($USER->studentview) && $USER->studentview==1)||(isset($context) && isset($USER->switchrole) && !empty($USER->switchrole) && $USER->switchrole[$context->id]>3)) {
+ $role='StudentBis';
+ } else{
+
+
+ if(isstudent($courseId)) { //Student
+ $role='Student';
+ }
+ else if (isadmin() || isteacher($courseId, $USER->id)) { // Admin, Teacher
+ $role='Instructor';
+ }
+
+ if(strstr($CFG->release,"1.7")) { // 1.7.* version
+ if (iscreator()) { // Course Creator
+ $role='Instructor';
+ }
+ else if (!isteacheredit($courseId)) { // Non-editing Teacher
+ $role='Student';
+ }
+ }
+
+ }
+
+ return $role;
+}
+
+/*
+* Give the parameters with the signature md5 to give to the frame
+* @param $courseid : the id of the current course
+* return a string with all the parameters to give to the url
+*/
+function get_url_params($courseid) {
+
+ global $USER;
+ global $CFG;
+
+ $role=getRoleForWimbaTools($courseid,$USER->id);
+ $signature = md5($courseid.$USER->email.$USER->firstname.$USER->lastname.$role);
+ $url_params = "enc_courseId=".rawurlencode($courseid).
+ "&enc_email=".rawurlencode($USER->email).
+ "&enc_firstname=".rawurlencode($USER->firstname).
+ "&enc_lastname=".rawurlencode($USER->lastname).
+ "&enc_role=".rawurlencode($role).
+ "&signature=".rawurlencode($signature);
+ return $url_params;
+}
+
+
+/* list the element of the pictures directory
+* return a String wich contains the pictures separated by a ,
+*/
+function list_dir($name,&$s) {
+
+ if ($dir = opendir($name)) {
+
+ while($file = readdir($dir)) {
+
+
+ if(is_dir($name."/".$file) && !in_array($file, array(".",".."))) {
+
+ list_dir($name."/".$file,$s);
+ }
+ else if($file!="." && $file !="..") {
+ $s.=$file.";";
+ }
+
+ }
+
+ closedir($dir);
+ }
+
+
+}
+
+function storeResource($rid,$courseId,$type,$name,$params=NULL){
+ $voicetools->rid=$rid;
+ $voicetools->course= $courseId;
+ $voicetools->name= $name;
+ $voicetools->type=$type;
+ if($params!=null){
+
+ if(isset($params["accessAvailable"]))
+ {
+ $voicetools->availability=1;
+ }
+ else
+ {
+ $voicetools->availability=0;
+ }
+ if(isset($params["start_date"]) && $params["start_date"]=="true"){
+ if($params["start_hr"]=="--")
+ {
+ $start_hr=0;
+ }
+ else
+ {
+ $start_hr=intval($params["start_hr"]);
+ }
+ if($params["start_min"]=="--")
+ {
+ $start_min=0;
+ }
+ else
+ {
+ $start_min=intval($params["start_min"]);
+ }
+ $voicetools->start_date= mktime($start_hr, $start_min,0, intval($params["start_month"]),intval($params["start_day"]), intval($params["start_year"]));
+
+
+
+
+ }
+ else
+ {
+ $voicetools->start_date=-1;
+ }
+ if(isset($params["end_date"]) && $params["end_date"]=="true"){
+ if($params["end_hr"]=="--")
+ {
+ $end_hr=0;
+ }
+ else
+ {
+ $end_hr=intval($params["end_hr"]);
+ }
+ if($params["end_min"]=="--")
+ {
+ $end_min=0;
+ }
+ else
+ {
+ $end_min=intval($params["start_min"]);
+ }
+
+ $voicetools->end_date=mktime($end_hr, $end_min,0, intval($params["end_month"]),intval( $params["end_day"]), intval($params["end_year"]));
+ }
+ else
+ {
+ $voicetools->end_date="-1";
+ }
+ }
+
+ return voicetools_store_new_element($voicetools);
+
+}
+function updateResource($rid,$courseId,$type,$params){
+
+ $voicetools->rid=$rid;
+ $voicetools->course= $courseId;
+ $voicetools->type=$type;
+ if(isset($params["accessAvailable"]))
+ {
+ $voicetools->availability=1;
+ }
+ else
+ {
+ $voicetools->availability=0;
+ }
+
+ if(isset($params["start_date"]) && $params["start_date"]=="true"){
+
+ if($params["start_hr"]=="--")
+ {
+ $start_hr=0;
+ }else
+ {
+ $start_hr=intval($params["start_hr"]);
+ }
+ if($params["start_min"]=="--")
+ {
+ $start_min=0;
+ }
+ else
+ {
+ $start_min=intval($params["start_min"]);
+ }
+ $voicetools->start_date=mktime($start_hr, $start_min,0, intval($params["start_month"]), intval($params["start_day"]), intval($params["start_year"]));
+ }
+ else
+ {
+ $voicetools->start_date=-1;
+ }
+ if(isset($params["end_date"]) && $params["end_date"]=="true"){
+ if($params["end_hr"]=="--")
+ {
+ $end_hr=0;
+ }
+ else
+ {
+ $end_hr=intval($params["end_hr"]);
+ }
+ if($params["end_min"]=="--")
+ {
+ $end_min=0;
+ }
+ else
+ {
+ $end_min=intval($params["start_min"]);
+ }
+ $voicetools->end_date=mktime($end_hr, $end_min,0, intval($params["end_month"]), intval($params["end_day"]), intval($params["end_year"]));
+ }
+ else
+ {
+ $voicetools->end_date="-1";
+ }
+ // $voicetools->id=$id;
+
+ return voicetools_update_element($voicetools);
+
+}
+
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|