843af5181667abb6572caea2717c20a7ef85aa55
[atutor.git] / mods / openmeetings / lib / SOAP_openmeetings.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Cindy Qi Li, Harris Wong                */
6 /* Adaptive Technology Resource Centre / University of Toronto                  */
7 /* http://atutor.ca                                                                                                             */
8 /*                                                                                                                                              */
9 /* This program is free software. You can redistribute it and/or                */
10 /* modify it under the terms of the GNU General Public License                  */
11 /* as published by the Free Software Foundation.                                                */
12 /************************************************************************/
13 // $Id: SOAP_openmeetings.php 7575 2008-06-02 18:17:14Z hwong $
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15
16 //require(AT_INCLUDE_PATH . 'classes/nusoap.php');
17 require('nusoap.php');  //newer version, come with the module
18
19 /**
20 * SOAP_openmeetings
21 * Class for using the SOAP service for openmeetings
22 * Please refer to the following API: 
23 *       http://code.google.com/p/openmeetings/wiki/SoapMethods
24 *
25 * @access       public
26 * @author       Harris Wong
27 */
28 class SOAP_openmeetings {
29         var $_sid                       = "";   //session id
30         var $_soapClient        = NULL; //soap connector
31         var $_wsdl                      = "";   //soap service link
32
33         function SOAP_openmeetings($wsdl) {
34                 $this->_wsdl                    = $wsdl;
35                 $this->_soapClient              = new nusoap_client($this->_wsdl, true);
36                 $getSession_obj                 = $this->_performAPICall('getSession', '');     
37                 //check session id
38                 if (!$getSession_obj){
39                         $this->_sid = session_id();  //openmeeting will return error code on this
40                 } else {
41                         $this->_sid = $getSession_obj['return']['session_id'];
42                 }
43         }
44
45     /**
46     * Login as an user and sets a session
47     *
48     * @param  array
49     * @return mixed
50     * @access public
51     */
52     function login($parameters = array()) {
53         if (!isset($parameters["username"])) {
54             return false;
55         }
56         return $this->_performAPICall(
57           "loginUser",
58
59           array(
60             "SID"         => $this->_sid,
61             "username"    => $parameters["username"],
62             "userpass"    => $parameters["userpass"]
63           )
64         );
65     }
66
67
68         /**
69          * Sets user object
70      * @param  array
71      * @return mixed
72      * @access public
73      */
74     function saveUserInstance($parameters = array()) {
75         return $this->_performAPICall(
76           "setUserObject",
77
78           array(
79             "SID"                                       => $this->_sid,
80             "username"                          => $parameters["username"],
81             "firstname"                         => $parameters["firstname"],
82                     "lastname"                          => $parameters["lastname"],
83                     "profilePictureUrl"         => $parameters[""],
84                     "email"                                     => $parameters["email"]
85           )
86         );
87     }
88
89         /**
90          * Get error message
91          */
92         function getError($code){
93                 return $this->_performAPICall(
94                         "getErrorByCode",
95                         array(
96                                 "SID"                           => $this->_sid,
97                                 "errorid"                       => $code,
98                                 "language_id"           => 1
99                                 )
100                 );
101         }
102
103         /**
104          * Creating a room
105          */
106         function addRoom($parameters = array()){
107         return $this->_performAPICall(
108           "addRoom",
109
110           array(
111             "SID"                                               => $parameters["SID"],
112                         'name'                                          => $parameters["name"],
113                         'roomtypes_id'                          => $parameters["roomtypes_id"],
114                         'comment'                                       => 'Room created by ATutor',
115                         'numberOfPartizipants'          => $parameters["numberOfPartizipants"],
116                         'ispublic'                                      => $parameters["ispublic"],
117                         'videoPodWidth'                         => $parameters["videoPodWidth"],
118                         'videoPodHeight'                        => $parameters["videoPodHeight"],
119                         'videoPodXPosition'                     => 2, 
120                         'videoPodYPosition'                     => 2, 
121                         'moderationPanelXPosition'      => 400, 
122                         'showWhiteBoard'                        => $parameters["showWhiteBoard"],
123                         'whiteBoardPanelXPosition'      => 276, 
124                         'whiteBoardPanelYPosition'      => 2, 
125                         'whiteBoardPanelHeight'         => $parameters["whiteBoardPanelHeight"],
126                         'whiteBoardPanelWidth'          => $parameters["whiteBoardPanelWidth"],
127                         'showFilesPanel'                        => $parameters["showFilesPanel"], 
128                         'filesPanelXPosition'           => 2, 
129                         'filesPanelYPosition'           => 284, 
130                         'filesPanelHeight'                      => $parameters["filesPanelHeight"], 
131                         'filesPanelWidth'                       => $parameters["filesPanelWidth"]
132           )
133         );
134         }
135
136
137         /**
138          * Updating a room
139          */
140         function updateRoom($parameters = array()){
141         return $this->_performAPICall(
142           "updateRoom",
143
144           array(
145             'SID'                                               => $parameters["SID"],
146                         'rooms_id'                                      => $parameters["rooms_id"],
147                         'name'                                          => $parameters["name"],
148                         'roomtypes_id'                          => $parameters["roomtypes_id"],
149                         'comment'                                       => 'Room created by ATutor',
150                         'numberOfPartizipants'          => $parameters["numberOfPartizipants"],
151                         'ispublic'                                      => $parameters["ispublic"],
152                         'videoPodWidth'                         => $parameters["videoPodWidth"],
153                         'videoPodHeight'                        => $parameters["videoPodHeight"],
154                         'videoPodXPosition'                     => 2, 
155                         'videoPodYPosition'                     => 2, 
156                         'moderationPanelXPosition'      => 400, 
157                         'showWhiteBoard'                        => $parameters["showWhiteBoard"],
158                         'whiteBoardPanelXPosition'      => 276, 
159                         'whiteBoardPanelYPosition'      => 2, 
160                         'whiteBoardPanelHeight'         => $parameters["whiteBoardPanelHeight"],
161                         'whiteBoardPanelWidth'          => $parameters["whiteBoardPanelWidth"],
162                         'showFilesPanel'                        => $parameters["showFilesPanel"], 
163                         'filesPanelXPosition'           => 2, 
164                         'filesPanelYPosition'           => 284, 
165                         'filesPanelHeight'                      => $parameters["filesPanelHeight"], 
166                         'filesPanelWidth'                       => $parameters["filesPanelWidth"]
167           )
168         );
169         }
170
171
172         /**
173          * Delete room
174          */
175         function deleteRoom($parameters = array()){
176                 return $this->_performAPICall(
177                         "deleteRoom",
178                         array(
179                                 "SID"           => $parameters["SID"],
180                                 "rooms_id"      => $parameters["rooms_id"]
181                         )
182                 );
183         }
184
185
186         /**
187          * return the session id.
188          */
189         function getSid(){
190                 return $this->_sid;
191         }
192
193         /**
194          * Get room by id
195          */
196         function getRoomById($parameters = array()){
197                 return $this->_performAPICall(
198                         "getRoomById",
199                         array(
200                                 "SID"           => $parameters["SID"],
201                                 "rooms_id"      => $parameters["rooms_id"]
202                         )
203                 );      
204         }
205          
206
207
208    /**
209     * @param  string
210     * @param  array
211     * @return mixed
212     * @access private
213     */
214     function _performAPICall($apiCall, $parameters) {
215                         $result = $this->_soapClient->call(
216                           $apiCall,
217                           $parameters
218                         );
219
220                 if ($this->_soapClient->fault){
221                         return false;
222                 } elseif ($this->_soapClient->getError()){
223                         return false;
224                 }
225
226                 // if (!PEAR::isError($result)) {
227                 if (is_array($result)) {
228             return $result;
229         } else {
230                         return false;
231         }
232     }
233
234         function myErrors(){
235                 return $this->_soapClient->getError();
236         }
237 }
238 ?>