@@ -44,107 +44,107 @@ discard block |
||
44 | 44 | |
45 | 45 | class BigBlueButtonBN { |
46 | 46 | |
47 | - private $_securitySalt; |
|
48 | - private $_bbbServerBaseUrl; |
|
47 | + private $_securitySalt; |
|
48 | + private $_bbbServerBaseUrl; |
|
49 | 49 | |
50 | - /* ___________ General Methods for the BigBlueButton Class __________ */ |
|
50 | + /* ___________ General Methods for the BigBlueButton Class __________ */ |
|
51 | 51 | |
52 | - function __construct() { |
|
53 | - /* |
|
52 | + function __construct() { |
|
53 | + /* |
|
54 | 54 | Establish just our basic elements in the constructor: |
55 | 55 | */ |
56 | - // BASE CONFIGS - set these for your BBB server in config.php and they will |
|
57 | - // simply flow in here via the constants: |
|
58 | - $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
59 | - $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
60 | - } |
|
61 | - |
|
62 | - private function _processXmlResponse($url){ |
|
63 | - /* |
|
56 | + // BASE CONFIGS - set these for your BBB server in config.php and they will |
|
57 | + // simply flow in here via the constants: |
|
58 | + $this->_securitySalt = CONFIG_SECURITY_SALT; |
|
59 | + $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL; |
|
60 | + } |
|
61 | + |
|
62 | + private function _processXmlResponse($url){ |
|
63 | + /* |
|
64 | 64 | A private utility method used by other public methods to process XML responses. |
65 | 65 | */ |
66 | - if (extension_loaded('curl')) { |
|
67 | - $ch = curl_init() or die ( curl_error($ch) ); |
|
68 | - $timeout = 10; |
|
69 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); |
|
70 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
71 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
72 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
73 | - $data = curl_exec( $ch ); |
|
74 | - curl_close( $ch ); |
|
75 | - |
|
76 | - if($data) |
|
77 | - return (new SimpleXMLElement($data)); |
|
78 | - else |
|
79 | - return false; |
|
80 | - } |
|
81 | - return (simplexml_load_file($url)); |
|
82 | - } |
|
83 | - |
|
84 | - private function _requiredParam($param) { |
|
85 | - /* Process required params and throw errors if we don't get values */ |
|
86 | - if ((isset($param)) && ($param != '')) { |
|
87 | - return $param; |
|
88 | - } |
|
89 | - elseif (!isset($param)) { |
|
90 | - throw new Exception('Missing parameter.'); |
|
91 | - } |
|
92 | - else { |
|
93 | - throw new Exception(''.$param.' is required.'); |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - private function _optionalParam($param) { |
|
98 | - /* Pass most optional params through as set value, or set to '' */ |
|
99 | - /* Don't know if we'll use this one, but let's build it in case. */ |
|
100 | - if ((isset($param)) && ($param != '')) { |
|
101 | - return $param; |
|
102 | - } |
|
103 | - else { |
|
104 | - $param = ''; |
|
105 | - return $param; |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - /* __________________ BBB ADMINISTRATION METHODS _________________ */ |
|
110 | - /* The methods in the following section support the following categories of the BBB API: |
|
66 | + if (extension_loaded('curl')) { |
|
67 | + $ch = curl_init() or die ( curl_error($ch) ); |
|
68 | + $timeout = 10; |
|
69 | + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); |
|
70 | + curl_setopt( $ch, CURLOPT_URL, $url ); |
|
71 | + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
72 | + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
73 | + $data = curl_exec( $ch ); |
|
74 | + curl_close( $ch ); |
|
75 | + |
|
76 | + if($data) |
|
77 | + return (new SimpleXMLElement($data)); |
|
78 | + else |
|
79 | + return false; |
|
80 | + } |
|
81 | + return (simplexml_load_file($url)); |
|
82 | + } |
|
83 | + |
|
84 | + private function _requiredParam($param) { |
|
85 | + /* Process required params and throw errors if we don't get values */ |
|
86 | + if ((isset($param)) && ($param != '')) { |
|
87 | + return $param; |
|
88 | + } |
|
89 | + elseif (!isset($param)) { |
|
90 | + throw new Exception('Missing parameter.'); |
|
91 | + } |
|
92 | + else { |
|
93 | + throw new Exception(''.$param.' is required.'); |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + private function _optionalParam($param) { |
|
98 | + /* Pass most optional params through as set value, or set to '' */ |
|
99 | + /* Don't know if we'll use this one, but let's build it in case. */ |
|
100 | + if ((isset($param)) && ($param != '')) { |
|
101 | + return $param; |
|
102 | + } |
|
103 | + else { |
|
104 | + $param = ''; |
|
105 | + return $param; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + /* __________________ BBB ADMINISTRATION METHODS _________________ */ |
|
110 | + /* The methods in the following section support the following categories of the BBB API: |
|
111 | 111 | -- create |
112 | 112 | -- join |
113 | 113 | -- end |
114 | 114 | */ |
115 | 115 | |
116 | - public function getCreateMeetingUrl($creationParams) { |
|
117 | - /* |
|
116 | + public function getCreateMeetingUrl($creationParams) { |
|
117 | + /* |
|
118 | 118 | USAGE: |
119 | 119 | (see $creationParams array in createMeetingArray method.) |
120 | 120 | */ |
121 | - $this->_meetingId = $this->_requiredParam($creationParams['meetingId']); |
|
122 | - $this->_meetingName = $this->_requiredParam($creationParams['meetingName']); |
|
123 | - // Set up the basic creation URL: |
|
124 | - $creationUrl = $this->_bbbServerBaseUrl."api/create?"; |
|
125 | - // Add params: |
|
126 | - $params = |
|
127 | - 'name='.urlencode($this->_meetingName). |
|
128 | - '&meetingID='.urlencode($this->_meetingId). |
|
129 | - '&attendeePW='.urlencode($creationParams['attendeePw']). |
|
130 | - '&moderatorPW='.urlencode($creationParams['moderatorPw']). |
|
131 | - '&dialNumber='.urlencode($creationParams['dialNumber']). |
|
132 | - '&voiceBridge='.urlencode($creationParams['voiceBridge']). |
|
133 | - '&webVoice='.urlencode($creationParams['webVoice']). |
|
134 | - '&logoutURL='.urlencode($creationParams['logoutUrl']). |
|
135 | - '&maxParticipants='.urlencode($creationParams['maxParticipants']). |
|
136 | - '&record='.urlencode($creationParams['record']). |
|
137 | - '&duration='.urlencode($creationParams['duration']); |
|
138 | - //'&meta_category='.urlencode($creationParams['meta_category']); |
|
139 | - $welcomeMessage = $creationParams['welcomeMsg']; |
|
140 | - if(trim($welcomeMessage)) |
|
141 | - $params .= '&welcome='.urlencode($welcomeMessage); |
|
142 | - // Return the complete URL: |
|
143 | - return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
|
144 | - } |
|
145 | - |
|
146 | - public function createMeetingWithXmlResponseArray($creationParams) { |
|
147 | - /* |
|
121 | + $this->_meetingId = $this->_requiredParam($creationParams['meetingId']); |
|
122 | + $this->_meetingName = $this->_requiredParam($creationParams['meetingName']); |
|
123 | + // Set up the basic creation URL: |
|
124 | + $creationUrl = $this->_bbbServerBaseUrl."api/create?"; |
|
125 | + // Add params: |
|
126 | + $params = |
|
127 | + 'name='.urlencode($this->_meetingName). |
|
128 | + '&meetingID='.urlencode($this->_meetingId). |
|
129 | + '&attendeePW='.urlencode($creationParams['attendeePw']). |
|
130 | + '&moderatorPW='.urlencode($creationParams['moderatorPw']). |
|
131 | + '&dialNumber='.urlencode($creationParams['dialNumber']). |
|
132 | + '&voiceBridge='.urlencode($creationParams['voiceBridge']). |
|
133 | + '&webVoice='.urlencode($creationParams['webVoice']). |
|
134 | + '&logoutURL='.urlencode($creationParams['logoutUrl']). |
|
135 | + '&maxParticipants='.urlencode($creationParams['maxParticipants']). |
|
136 | + '&record='.urlencode($creationParams['record']). |
|
137 | + '&duration='.urlencode($creationParams['duration']); |
|
138 | + //'&meta_category='.urlencode($creationParams['meta_category']); |
|
139 | + $welcomeMessage = $creationParams['welcomeMsg']; |
|
140 | + if(trim($welcomeMessage)) |
|
141 | + $params .= '&welcome='.urlencode($welcomeMessage); |
|
142 | + // Return the complete URL: |
|
143 | + return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) ); |
|
144 | + } |
|
145 | + |
|
146 | + public function createMeetingWithXmlResponseArray($creationParams) { |
|
147 | + /* |
|
148 | 148 | USAGE: |
149 | 149 | $creationParams = array( |
150 | 150 | 'name' => 'Meeting Name', -- A name for the meeting (or username) |
@@ -162,34 +162,34 @@ discard block |
||
162 | 162 | 'meta_category' => '', -- Use to pass additional info to BBB server. See API docs to enable. |
163 | 163 | ); |
164 | 164 | */ |
165 | - $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
|
165 | + $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); |
|
166 | 166 | |
167 | 167 | if ($xml) { |
168 | - if($xml->meetingID) |
|
169 | - return array( |
|
170 | - 'returncode' => $xml->returncode, |
|
171 | - 'message' => $xml->message, |
|
172 | - 'messageKey' => $xml->messageKey, |
|
173 | - 'meetingId' => $xml->meetingID, |
|
174 | - 'attendeePw' => $xml->attendeePW, |
|
175 | - 'moderatorPw' => $xml->moderatorPW, |
|
176 | - 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, |
|
177 | - 'createTime' => $xml->createTime |
|
178 | - ); |
|
179 | - else |
|
180 | - return array( |
|
181 | - 'returncode' => $xml->returncode, |
|
182 | - 'message' => $xml->message, |
|
183 | - 'messageKey' => $xml->messageKey |
|
184 | - ); |
|
185 | - } |
|
186 | - else { |
|
187 | - return null; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - public function getJoinMeetingURL($joinParams) { |
|
192 | - /* |
|
168 | + if($xml->meetingID) |
|
169 | + return array( |
|
170 | + 'returncode' => $xml->returncode, |
|
171 | + 'message' => $xml->message, |
|
172 | + 'messageKey' => $xml->messageKey, |
|
173 | + 'meetingId' => $xml->meetingID, |
|
174 | + 'attendeePw' => $xml->attendeePW, |
|
175 | + 'moderatorPw' => $xml->moderatorPW, |
|
176 | + 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, |
|
177 | + 'createTime' => $xml->createTime |
|
178 | + ); |
|
179 | + else |
|
180 | + return array( |
|
181 | + 'returncode' => $xml->returncode, |
|
182 | + 'message' => $xml->message, |
|
183 | + 'messageKey' => $xml->messageKey |
|
184 | + ); |
|
185 | + } |
|
186 | + else { |
|
187 | + return null; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + public function getJoinMeetingURL($joinParams) { |
|
192 | + /* |
|
193 | 193 | NOTE: At this point, we don't use a corresponding joinMeetingWithXmlResponse here because the API |
194 | 194 | doesn't respond on success, but you can still code that method if you need it. Or, you can take the URL |
195 | 195 | that's returned from this method and simply send your users off to that URL in your code. |
@@ -203,249 +203,249 @@ discard block |
||
203 | 203 | 'webVoiceConf' => '' -- OPTIONAL - string |
204 | 204 | ); |
205 | 205 | */ |
206 | - $this->_meetingId = $this->_requiredParam($joinParams['meetingId']); |
|
207 | - $this->_username = $this->_requiredParam($joinParams['username']); |
|
208 | - $this->_password = $this->_requiredParam($joinParams['password']); |
|
209 | - // Establish the basic join URL: |
|
210 | - $joinUrl = $this->_bbbServerBaseUrl."api/join?"; |
|
211 | - // Add parameters to the URL: |
|
212 | - $params = |
|
213 | - 'meetingID='.urlencode($this->_meetingId). |
|
214 | - '&fullName='.urlencode($this->_username). |
|
215 | - '&password='.urlencode($this->_password). |
|
216 | - '&userID='.urlencode($joinParams['userId']). |
|
217 | - '&webVoiceConf='.urlencode($joinParams['webVoiceConf']); |
|
218 | - // Only use createTime if we really want to use it. If it's '', then don't pass it: |
|
219 | - if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) { |
|
220 | - $params .= '&createTime='.urlencode($joinParams['createTime']); |
|
221 | - } |
|
222 | - // Return the URL: |
|
223 | - return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt)); |
|
224 | - } |
|
225 | - |
|
226 | - public function getEndMeetingURL($endParams) { |
|
227 | - /* USAGE: |
|
206 | + $this->_meetingId = $this->_requiredParam($joinParams['meetingId']); |
|
207 | + $this->_username = $this->_requiredParam($joinParams['username']); |
|
208 | + $this->_password = $this->_requiredParam($joinParams['password']); |
|
209 | + // Establish the basic join URL: |
|
210 | + $joinUrl = $this->_bbbServerBaseUrl."api/join?"; |
|
211 | + // Add parameters to the URL: |
|
212 | + $params = |
|
213 | + 'meetingID='.urlencode($this->_meetingId). |
|
214 | + '&fullName='.urlencode($this->_username). |
|
215 | + '&password='.urlencode($this->_password). |
|
216 | + '&userID='.urlencode($joinParams['userId']). |
|
217 | + '&webVoiceConf='.urlencode($joinParams['webVoiceConf']); |
|
218 | + // Only use createTime if we really want to use it. If it's '', then don't pass it: |
|
219 | + if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) { |
|
220 | + $params .= '&createTime='.urlencode($joinParams['createTime']); |
|
221 | + } |
|
222 | + // Return the URL: |
|
223 | + return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt)); |
|
224 | + } |
|
225 | + |
|
226 | + public function getEndMeetingURL($endParams) { |
|
227 | + /* USAGE: |
|
228 | 228 | $endParams = array ( |
229 | 229 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
230 | 230 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
231 | 231 | ); |
232 | 232 | */ |
233 | - $this->_meetingId = $this->_requiredParam($endParams['meetingId']); |
|
234 | - $this->_password = $this->_requiredParam($endParams['password']); |
|
235 | - $endUrl = $this->_bbbServerBaseUrl."api/end?"; |
|
236 | - $params = |
|
237 | - 'meetingID='.urlencode($this->_meetingId). |
|
238 | - '&password='.urlencode($this->_password); |
|
239 | - return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt)); |
|
240 | - } |
|
241 | - |
|
242 | - public function endMeetingWithXmlResponseArray($endParams) { |
|
243 | - /* USAGE: |
|
233 | + $this->_meetingId = $this->_requiredParam($endParams['meetingId']); |
|
234 | + $this->_password = $this->_requiredParam($endParams['password']); |
|
235 | + $endUrl = $this->_bbbServerBaseUrl."api/end?"; |
|
236 | + $params = |
|
237 | + 'meetingID='.urlencode($this->_meetingId). |
|
238 | + '&password='.urlencode($this->_password); |
|
239 | + return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt)); |
|
240 | + } |
|
241 | + |
|
242 | + public function endMeetingWithXmlResponseArray($endParams) { |
|
243 | + /* USAGE: |
|
244 | 244 | $endParams = array ( |
245 | 245 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
246 | 246 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
247 | 247 | ); |
248 | 248 | */ |
249 | - $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); |
|
250 | - if ($xml) { |
|
251 | - return array( |
|
252 | - 'returncode' => $xml->returncode, |
|
253 | - 'message' => $xml->message, |
|
254 | - 'messageKey' => $xml->messageKey |
|
255 | - ); |
|
256 | - } |
|
257 | - else { |
|
258 | - return null; |
|
259 | - } |
|
260 | - |
|
261 | - } |
|
262 | - |
|
263 | - /* __________________ BBB MONITORING METHODS _________________ */ |
|
264 | - /* The methods in the following section support the following categories of the BBB API: |
|
249 | + $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); |
|
250 | + if ($xml) { |
|
251 | + return array( |
|
252 | + 'returncode' => $xml->returncode, |
|
253 | + 'message' => $xml->message, |
|
254 | + 'messageKey' => $xml->messageKey |
|
255 | + ); |
|
256 | + } |
|
257 | + else { |
|
258 | + return null; |
|
259 | + } |
|
260 | + |
|
261 | + } |
|
262 | + |
|
263 | + /* __________________ BBB MONITORING METHODS _________________ */ |
|
264 | + /* The methods in the following section support the following categories of the BBB API: |
|
265 | 265 | -- isMeetingRunning |
266 | 266 | -- getMeetings |
267 | 267 | -- getMeetingInfo |
268 | 268 | */ |
269 | 269 | |
270 | - public function getIsMeetingRunningUrl($meetingId) { |
|
271 | - /* USAGE: |
|
270 | + public function getIsMeetingRunningUrl($meetingId) { |
|
271 | + /* USAGE: |
|
272 | 272 | $meetingId = '1234' -- REQUIRED - The unique id for the meeting |
273 | 273 | */ |
274 | - $this->_meetingId = $this->_requiredParam($meetingId); |
|
275 | - $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?"; |
|
276 | - $params = |
|
277 | - 'meetingID='.urlencode($this->_meetingId); |
|
278 | - return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt)); |
|
279 | - } |
|
280 | - |
|
281 | - public function isMeetingRunningWithXmlResponseArray($meetingId) { |
|
282 | - /* USAGE: |
|
274 | + $this->_meetingId = $this->_requiredParam($meetingId); |
|
275 | + $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?"; |
|
276 | + $params = |
|
277 | + 'meetingID='.urlencode($this->_meetingId); |
|
278 | + return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt)); |
|
279 | + } |
|
280 | + |
|
281 | + public function isMeetingRunningWithXmlResponseArray($meetingId) { |
|
282 | + /* USAGE: |
|
283 | 283 | $meetingId = '1234' -- REQUIRED - The unique id for the meeting |
284 | 284 | */ |
285 | - $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId)); |
|
286 | - if($xml) { |
|
287 | - return array( |
|
288 | - 'returncode' => $xml->returncode, |
|
289 | - 'running' => $xml->running // -- Returns true/false. |
|
290 | - ); |
|
291 | - } |
|
292 | - else { |
|
293 | - return null; |
|
294 | - } |
|
295 | - |
|
296 | - } |
|
297 | - |
|
298 | - public function getGetMeetingsUrl() { |
|
299 | - /* Simply formulate the getMeetings URL |
|
285 | + $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId)); |
|
286 | + if($xml) { |
|
287 | + return array( |
|
288 | + 'returncode' => $xml->returncode, |
|
289 | + 'running' => $xml->running // -- Returns true/false. |
|
290 | + ); |
|
291 | + } |
|
292 | + else { |
|
293 | + return null; |
|
294 | + } |
|
295 | + |
|
296 | + } |
|
297 | + |
|
298 | + public function getGetMeetingsUrl() { |
|
299 | + /* Simply formulate the getMeetings URL |
|
300 | 300 | We do this in a separate function so we have the option to just get this |
301 | 301 | URL and print it if we want for some reason. |
302 | 302 | */ |
303 | - $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt); |
|
304 | - return $getMeetingsUrl; |
|
305 | - } |
|
303 | + $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt); |
|
304 | + return $getMeetingsUrl; |
|
305 | + } |
|
306 | 306 | |
307 | - public function getMeetingsWithXmlResponseArray() { |
|
308 | - /* USAGE: |
|
307 | + public function getMeetingsWithXmlResponseArray() { |
|
308 | + /* USAGE: |
|
309 | 309 | We don't need to pass any parameters with this one, so we just send the query URL off to BBB |
310 | 310 | and then handle the results that we get in the XML response. |
311 | 311 | */ |
312 | - $xml = $this->_processXmlResponse($this->getGetMeetingsUrl()); |
|
313 | - if($xml) { |
|
314 | - // If we don't get a success code, stop processing and return just the returncode: |
|
315 | - if ($xml->returncode != 'SUCCESS') { |
|
316 | - $result = array( |
|
317 | - 'returncode' => $xml->returncode |
|
318 | - ); |
|
319 | - return $result; |
|
320 | - } |
|
321 | - elseif ($xml->messageKey == 'noMeetings') { |
|
322 | - /* No meetings on server, so return just this info: */ |
|
323 | - $result = array( |
|
324 | - 'returncode' => $xml->returncode, |
|
325 | - 'messageKey' => $xml->messageKey, |
|
326 | - 'message' => $xml->message |
|
327 | - ); |
|
328 | - return $result; |
|
329 | - } |
|
330 | - else { |
|
331 | - // In this case, we have success and meetings. First return general response: |
|
332 | - $result = array( |
|
333 | - 'returncode' => $xml->returncode, |
|
334 | - 'messageKey' => $xml->messageKey, |
|
335 | - 'message' => $xml->message |
|
336 | - ); |
|
337 | - // Then interate through meeting results and return them as part of the array: |
|
338 | - foreach ($xml->meetings->meeting as $m) { |
|
339 | - $result[] = array( |
|
340 | - 'meetingId' => $m->meetingID, |
|
341 | - 'meetingName' => $m->meetingName, |
|
342 | - 'createTime' => $m->createTime, |
|
343 | - 'attendeePw' => $m->attendeePW, |
|
344 | - 'moderatorPw' => $m->moderatorPW, |
|
345 | - 'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded, |
|
346 | - 'running' => $m->running |
|
347 | - ); |
|
348 | - } |
|
349 | - return $result; |
|
350 | - } |
|
351 | - } |
|
352 | - else { |
|
353 | - return null; |
|
354 | - } |
|
355 | - |
|
356 | - } |
|
357 | - |
|
358 | - public function getMeetingInfoUrl($infoParams) { |
|
359 | - /* USAGE: |
|
312 | + $xml = $this->_processXmlResponse($this->getGetMeetingsUrl()); |
|
313 | + if($xml) { |
|
314 | + // If we don't get a success code, stop processing and return just the returncode: |
|
315 | + if ($xml->returncode != 'SUCCESS') { |
|
316 | + $result = array( |
|
317 | + 'returncode' => $xml->returncode |
|
318 | + ); |
|
319 | + return $result; |
|
320 | + } |
|
321 | + elseif ($xml->messageKey == 'noMeetings') { |
|
322 | + /* No meetings on server, so return just this info: */ |
|
323 | + $result = array( |
|
324 | + 'returncode' => $xml->returncode, |
|
325 | + 'messageKey' => $xml->messageKey, |
|
326 | + 'message' => $xml->message |
|
327 | + ); |
|
328 | + return $result; |
|
329 | + } |
|
330 | + else { |
|
331 | + // In this case, we have success and meetings. First return general response: |
|
332 | + $result = array( |
|
333 | + 'returncode' => $xml->returncode, |
|
334 | + 'messageKey' => $xml->messageKey, |
|
335 | + 'message' => $xml->message |
|
336 | + ); |
|
337 | + // Then interate through meeting results and return them as part of the array: |
|
338 | + foreach ($xml->meetings->meeting as $m) { |
|
339 | + $result[] = array( |
|
340 | + 'meetingId' => $m->meetingID, |
|
341 | + 'meetingName' => $m->meetingName, |
|
342 | + 'createTime' => $m->createTime, |
|
343 | + 'attendeePw' => $m->attendeePW, |
|
344 | + 'moderatorPw' => $m->moderatorPW, |
|
345 | + 'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded, |
|
346 | + 'running' => $m->running |
|
347 | + ); |
|
348 | + } |
|
349 | + return $result; |
|
350 | + } |
|
351 | + } |
|
352 | + else { |
|
353 | + return null; |
|
354 | + } |
|
355 | + |
|
356 | + } |
|
357 | + |
|
358 | + public function getMeetingInfoUrl($infoParams) { |
|
359 | + /* USAGE: |
|
360 | 360 | $infoParams = array( |
361 | 361 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
362 | 362 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
363 | 363 | ); |
364 | 364 | */ |
365 | - $this->_meetingId = $this->_requiredParam($infoParams['meetingId']); |
|
366 | - $this->_password = $this->_requiredParam($infoParams['password']); |
|
367 | - $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?"; |
|
368 | - $params = |
|
369 | - 'meetingID='.urlencode($this->_meetingId). |
|
370 | - '&password='.urlencode($this->_password); |
|
371 | - return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt)); |
|
372 | - } |
|
373 | - |
|
374 | - public function getMeetingInfoWithXmlResponseArray($infoParams) { |
|
375 | - /* USAGE: |
|
365 | + $this->_meetingId = $this->_requiredParam($infoParams['meetingId']); |
|
366 | + $this->_password = $this->_requiredParam($infoParams['password']); |
|
367 | + $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?"; |
|
368 | + $params = |
|
369 | + 'meetingID='.urlencode($this->_meetingId). |
|
370 | + '&password='.urlencode($this->_password); |
|
371 | + return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt)); |
|
372 | + } |
|
373 | + |
|
374 | + public function getMeetingInfoWithXmlResponseArray($infoParams) { |
|
375 | + /* USAGE: |
|
376 | 376 | $infoParams = array( |
377 | 377 | 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting |
378 | 378 | 'password' => 'mp' -- REQUIRED - The moderator password for the meeting |
379 | 379 | ); |
380 | 380 | */ |
381 | - $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams)); |
|
382 | - if($xml) { |
|
383 | - // If we don't get a success code or messageKey, find out why: |
|
384 | - if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
385 | - $result = array( |
|
386 | - 'returncode' => $xml->returncode, |
|
387 | - 'messageKey' => $xml->messageKey, |
|
388 | - 'message' => $xml->message |
|
389 | - ); |
|
390 | - return $result; |
|
391 | - } |
|
392 | - else { |
|
393 | - // In this case, we have success and meeting info: |
|
394 | - $result = array( |
|
395 | - 'returncode' => $xml->returncode, |
|
396 | - 'meetingName' => $xml->meetingName, |
|
397 | - 'meetingId' => $xml->meetingID, |
|
398 | - 'createTime' => $xml->createTime, |
|
399 | - 'voiceBridge' => $xml->voiceBridge, |
|
400 | - 'attendeePw' => $xml->attendeePW, |
|
401 | - 'moderatorPw' => $xml->moderatorPW, |
|
402 | - 'running' => $xml->running, |
|
403 | - 'recording' => $xml->recording, |
|
404 | - 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, |
|
405 | - 'startTime' => $xml->startTime, |
|
406 | - 'endTime' => $xml->endTime, |
|
407 | - 'participantCount' => $xml->participantCount, |
|
408 | - 'maxUsers' => $xml->maxUsers, |
|
409 | - 'moderatorCount' => $xml->moderatorCount, |
|
410 | - ); |
|
411 | - // Then interate through attendee results and return them as part of the array: |
|
412 | - foreach ($xml->attendees->attendee as $a) { |
|
413 | - $result[] = array( |
|
414 | - 'userId' => $a->userID, |
|
415 | - 'fullName' => $a->fullName, |
|
416 | - 'role' => $a->role |
|
417 | - ); |
|
418 | - } |
|
419 | - return $result; |
|
420 | - } |
|
421 | - } |
|
422 | - else { |
|
423 | - return null; |
|
424 | - } |
|
425 | - |
|
426 | - } |
|
427 | - |
|
428 | - /* __________________ BBB RECORDING METHODS _________________ */ |
|
429 | - /* The methods in the following section support the following categories of the BBB API: |
|
381 | + $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams)); |
|
382 | + if($xml) { |
|
383 | + // If we don't get a success code or messageKey, find out why: |
|
384 | + if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
385 | + $result = array( |
|
386 | + 'returncode' => $xml->returncode, |
|
387 | + 'messageKey' => $xml->messageKey, |
|
388 | + 'message' => $xml->message |
|
389 | + ); |
|
390 | + return $result; |
|
391 | + } |
|
392 | + else { |
|
393 | + // In this case, we have success and meeting info: |
|
394 | + $result = array( |
|
395 | + 'returncode' => $xml->returncode, |
|
396 | + 'meetingName' => $xml->meetingName, |
|
397 | + 'meetingId' => $xml->meetingID, |
|
398 | + 'createTime' => $xml->createTime, |
|
399 | + 'voiceBridge' => $xml->voiceBridge, |
|
400 | + 'attendeePw' => $xml->attendeePW, |
|
401 | + 'moderatorPw' => $xml->moderatorPW, |
|
402 | + 'running' => $xml->running, |
|
403 | + 'recording' => $xml->recording, |
|
404 | + 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, |
|
405 | + 'startTime' => $xml->startTime, |
|
406 | + 'endTime' => $xml->endTime, |
|
407 | + 'participantCount' => $xml->participantCount, |
|
408 | + 'maxUsers' => $xml->maxUsers, |
|
409 | + 'moderatorCount' => $xml->moderatorCount, |
|
410 | + ); |
|
411 | + // Then interate through attendee results and return them as part of the array: |
|
412 | + foreach ($xml->attendees->attendee as $a) { |
|
413 | + $result[] = array( |
|
414 | + 'userId' => $a->userID, |
|
415 | + 'fullName' => $a->fullName, |
|
416 | + 'role' => $a->role |
|
417 | + ); |
|
418 | + } |
|
419 | + return $result; |
|
420 | + } |
|
421 | + } |
|
422 | + else { |
|
423 | + return null; |
|
424 | + } |
|
425 | + |
|
426 | + } |
|
427 | + |
|
428 | + /* __________________ BBB RECORDING METHODS _________________ */ |
|
429 | + /* The methods in the following section support the following categories of the BBB API: |
|
430 | 430 | -- getRecordings |
431 | 431 | -- publishRecordings |
432 | 432 | -- deleteRecordings |
433 | 433 | */ |
434 | 434 | |
435 | - public function getRecordingsUrl($recordingParams) { |
|
436 | - /* USAGE: |
|
435 | + public function getRecordingsUrl($recordingParams) { |
|
436 | + /* USAGE: |
|
437 | 437 | $recordingParams = array( |
438 | 438 | 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids |
439 | 439 | ); |
440 | 440 | */ |
441 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?"; |
|
442 | - $params = 'meetingID='.urlencode($recordingParams['meetingId']); |
|
443 | - return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt)); |
|
441 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?"; |
|
442 | + $params = 'meetingID='.urlencode($recordingParams['meetingId']); |
|
443 | + return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt)); |
|
444 | 444 | |
445 | - } |
|
445 | + } |
|
446 | 446 | |
447 | - public function getRecordingsWithXmlResponseArray($recordingParams) { |
|
448 | - /* USAGE: |
|
447 | + public function getRecordingsWithXmlResponseArray($recordingParams) { |
|
448 | + /* USAGE: |
|
449 | 449 | $recordingParams = array( |
450 | 450 | 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids |
451 | 451 | ); |
@@ -453,121 +453,121 @@ discard block |
||
453 | 453 | when creating a meeting, it will kick users out after the duration. Should |
454 | 454 | probably be required in user code when 'recording' is set to true. |
455 | 455 | */ |
456 | - $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); |
|
457 | - if($xml) { |
|
458 | - // If we don't get a success code or messageKey, find out why: |
|
459 | - if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
460 | - $result = array( |
|
461 | - 'returncode' => $xml->returncode, |
|
462 | - 'messageKey' => $xml->messageKey, |
|
463 | - 'message' => $xml->message |
|
464 | - ); |
|
465 | - return $result; |
|
466 | - } |
|
467 | - else { |
|
468 | - // In this case, we have success and recording info: |
|
469 | - $result = array( |
|
470 | - 'returncode' => $xml->returncode, |
|
471 | - 'messageKey' => $xml->messageKey, |
|
472 | - 'message' => $xml->message |
|
473 | - ); |
|
474 | - |
|
475 | - foreach ($xml->recordings->recording as $r) { |
|
476 | - $result[] = array( |
|
477 | - 'recordId' => $r->recordID, |
|
478 | - 'meetingId' => $r->meetingID, |
|
479 | - 'name' => $r->name, |
|
480 | - 'published' => $r->published, |
|
481 | - 'startTime' => $r->startTime, |
|
482 | - 'endTime' => $r->endTime, |
|
483 | - 'playbackFormatType' => $r->playback->format->type, |
|
484 | - 'playbackFormatUrl' => $r->playback->format->url, |
|
485 | - 'playbackFormatLength' => $r->playback->format->length, |
|
486 | - 'metadataTitle' => $r->metadata->title, |
|
487 | - 'metadataSubject' => $r->metadata->subject, |
|
488 | - 'metadataDescription' => $r->metadata->description, |
|
489 | - 'metadataCreator' => $r->metadata->creator, |
|
490 | - 'metadataContributor' => $r->metadata->contributor, |
|
491 | - 'metadataLanguage' => $r->metadata->language, |
|
492 | - // Add more here as needed for your app depending on your |
|
493 | - // use of metadata when creating recordings. |
|
494 | - ); |
|
495 | - } |
|
496 | - return $result; |
|
497 | - } |
|
498 | - } |
|
499 | - else { |
|
500 | - return null; |
|
501 | - } |
|
502 | - } |
|
503 | - |
|
504 | - public function getPublishRecordingsUrl($recordingParams) { |
|
505 | - /* USAGE: |
|
456 | + $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams)); |
|
457 | + if($xml) { |
|
458 | + // If we don't get a success code or messageKey, find out why: |
|
459 | + if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) { |
|
460 | + $result = array( |
|
461 | + 'returncode' => $xml->returncode, |
|
462 | + 'messageKey' => $xml->messageKey, |
|
463 | + 'message' => $xml->message |
|
464 | + ); |
|
465 | + return $result; |
|
466 | + } |
|
467 | + else { |
|
468 | + // In this case, we have success and recording info: |
|
469 | + $result = array( |
|
470 | + 'returncode' => $xml->returncode, |
|
471 | + 'messageKey' => $xml->messageKey, |
|
472 | + 'message' => $xml->message |
|
473 | + ); |
|
474 | + |
|
475 | + foreach ($xml->recordings->recording as $r) { |
|
476 | + $result[] = array( |
|
477 | + 'recordId' => $r->recordID, |
|
478 | + 'meetingId' => $r->meetingID, |
|
479 | + 'name' => $r->name, |
|
480 | + 'published' => $r->published, |
|
481 | + 'startTime' => $r->startTime, |
|
482 | + 'endTime' => $r->endTime, |
|
483 | + 'playbackFormatType' => $r->playback->format->type, |
|
484 | + 'playbackFormatUrl' => $r->playback->format->url, |
|
485 | + 'playbackFormatLength' => $r->playback->format->length, |
|
486 | + 'metadataTitle' => $r->metadata->title, |
|
487 | + 'metadataSubject' => $r->metadata->subject, |
|
488 | + 'metadataDescription' => $r->metadata->description, |
|
489 | + 'metadataCreator' => $r->metadata->creator, |
|
490 | + 'metadataContributor' => $r->metadata->contributor, |
|
491 | + 'metadataLanguage' => $r->metadata->language, |
|
492 | + // Add more here as needed for your app depending on your |
|
493 | + // use of metadata when creating recordings. |
|
494 | + ); |
|
495 | + } |
|
496 | + return $result; |
|
497 | + } |
|
498 | + } |
|
499 | + else { |
|
500 | + return null; |
|
501 | + } |
|
502 | + } |
|
503 | + |
|
504 | + public function getPublishRecordingsUrl($recordingParams) { |
|
505 | + /* USAGE: |
|
506 | 506 | $recordingParams = array( |
507 | 507 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
508 | 508 | 'publish' => 'true', -- REQUIRED - boolean: true/false |
509 | 509 | ); |
510 | 510 | */ |
511 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?"; |
|
512 | - $params = |
|
513 | - 'recordID='.urlencode($recordingParams['recordId']). |
|
514 | - '&publish='.urlencode($recordingParams['publish']); |
|
515 | - return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt)); |
|
511 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?"; |
|
512 | + $params = |
|
513 | + 'recordID='.urlencode($recordingParams['recordId']). |
|
514 | + '&publish='.urlencode($recordingParams['publish']); |
|
515 | + return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt)); |
|
516 | 516 | |
517 | - } |
|
517 | + } |
|
518 | 518 | |
519 | - public function publishRecordingsWithXmlResponseArray($recordingParams) { |
|
520 | - /* USAGE: |
|
519 | + public function publishRecordingsWithXmlResponseArray($recordingParams) { |
|
520 | + /* USAGE: |
|
521 | 521 | $recordingParams = array( |
522 | 522 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
523 | 523 | 'publish' => 'true', -- REQUIRED - boolean: true/false |
524 | 524 | ); |
525 | 525 | */ |
526 | - $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
|
527 | - if($xml) { |
|
528 | - return array( |
|
529 | - 'returncode' => $xml->returncode, |
|
530 | - 'published' => $xml->published // -- Returns true/false. |
|
531 | - ); |
|
532 | - } |
|
533 | - else { |
|
534 | - return null; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - } |
|
539 | - |
|
540 | - public function getDeleteRecordingsUrl($recordingParams) { |
|
541 | - /* USAGE: |
|
526 | + $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
|
527 | + if($xml) { |
|
528 | + return array( |
|
529 | + 'returncode' => $xml->returncode, |
|
530 | + 'published' => $xml->published // -- Returns true/false. |
|
531 | + ); |
|
532 | + } |
|
533 | + else { |
|
534 | + return null; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + } |
|
539 | + |
|
540 | + public function getDeleteRecordingsUrl($recordingParams) { |
|
541 | + /* USAGE: |
|
542 | 542 | $recordingParams = array( |
543 | 543 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
544 | 544 | ); |
545 | 545 | */ |
546 | - $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?"; |
|
547 | - $params = |
|
548 | - 'recordID='.urlencode($recordingParams['recordId']); |
|
549 | - return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt)); |
|
550 | - } |
|
551 | - |
|
552 | - public function deleteRecordingsWithXmlResponseArray($recordingParams) { |
|
553 | - /* USAGE: |
|
546 | + $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?"; |
|
547 | + $params = |
|
548 | + 'recordID='.urlencode($recordingParams['recordId']); |
|
549 | + return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt)); |
|
550 | + } |
|
551 | + |
|
552 | + public function deleteRecordingsWithXmlResponseArray($recordingParams) { |
|
553 | + /* USAGE: |
|
554 | 554 | $recordingParams = array( |
555 | 555 | 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids |
556 | 556 | ); |
557 | 557 | */ |
558 | 558 | |
559 | - $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
|
560 | - if($xml) { |
|
561 | - return array( |
|
562 | - 'returncode' => $xml->returncode, |
|
563 | - 'deleted' => $xml->deleted // -- Returns true/false. |
|
564 | - ); |
|
565 | - } |
|
566 | - else { |
|
567 | - return null; |
|
568 | - } |
|
569 | - |
|
570 | - } |
|
559 | + $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
|
560 | + if($xml) { |
|
561 | + return array( |
|
562 | + 'returncode' => $xml->returncode, |
|
563 | + 'deleted' => $xml->deleted // -- Returns true/false. |
|
564 | + ); |
|
565 | + } |
|
566 | + else { |
|
567 | + return null; |
|
568 | + } |
|
569 | + |
|
570 | + } |
|
571 | 571 | |
572 | 572 | |
573 | 573 |
@@ -6,12 +6,12 @@ |
||
6 | 6 | * main/img/icons/64/plugin_name_na.png |
7 | 7 | */ |
8 | 8 | /** |
9 | - * Videoconference plugin with BBB |
|
10 | - */ |
|
9 | + * Videoconference plugin with BBB |
|
10 | + */ |
|
11 | 11 | //namespace Chamilo\Plugin\BBB; |
12 | 12 | /** |
13 | - * Class BBBPlugin |
|
14 | - */ |
|
13 | + * Class BBBPlugin |
|
14 | + */ |
|
15 | 15 | class BBBPlugin extends Plugin |
16 | 16 | { |
17 | 17 | public $isCoursePlugin = true; |
@@ -22,40 +22,40 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | private $user_id; |
25 | - private $students; |
|
26 | - private $path; |
|
27 | - private $permission = array(DRH); |
|
25 | + private $students; |
|
26 | + private $path; |
|
27 | + private $permission = array(DRH); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Constructor |
|
31 | - */ |
|
29 | + /** |
|
30 | + * Constructor |
|
31 | + */ |
|
32 | 32 | public function __construct ($user_id) |
33 | 33 | { |
34 | - $this->user_id = $user_id; |
|
35 | - $this->path = 'block_student_graph'; |
|
36 | - if ($this->is_block_visible_for_user($user_id)) { |
|
37 | - /*if (api_is_platform_admin()) { |
|
34 | + $this->user_id = $user_id; |
|
35 | + $this->path = 'block_student_graph'; |
|
36 | + if ($this->is_block_visible_for_user($user_id)) { |
|
37 | + /*if (api_is_platform_admin()) { |
|
38 | 38 | $this->students = UserManager::get_user_list(array('status' => STUDENT)); |
39 | 39 | } else if (api_is_drh()) {*/ |
40 | - $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); |
|
41 | - //} |
|
42 | - } |
|
40 | + $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); |
|
41 | + //} |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | - * This method check if a user is allowed to see the block inside dashboard interface |
|
47 | - * @param int User id |
|
48 | - * @return bool Is block visible for user |
|
49 | - */ |
|
46 | + * This method check if a user is allowed to see the block inside dashboard interface |
|
47 | + * @param int User id |
|
48 | + * @return bool Is block visible for user |
|
49 | + */ |
|
50 | 50 | public function is_block_visible_for_user($user_id) |
51 | 51 | { |
52 | - $user_info = api_get_user_info($user_id); |
|
53 | - $user_status = $user_info['status']; |
|
54 | - $is_block_visible_for_user = false; |
|
55 | - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
56 | - $is_block_visible_for_user = true; |
|
57 | - } |
|
58 | - return $is_block_visible_for_user; |
|
52 | + $user_info = api_get_user_info($user_id); |
|
53 | + $user_status = $user_info['status']; |
|
54 | + $is_block_visible_for_user = false; |
|
55 | + if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
56 | + $is_block_visible_for_user = true; |
|
57 | + } |
|
58 | + return $is_block_visible_for_user; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | public function get_block() |
68 | 68 | { |
69 | 69 | |
70 | - global $charset; |
|
71 | - $column = 1; |
|
72 | - $data = array(); |
|
73 | - $students_attendance_graph = $this->get_students_attendance_graph(); |
|
70 | + global $charset; |
|
71 | + $column = 1; |
|
72 | + $data = array(); |
|
73 | + $students_attendance_graph = $this->get_students_attendance_graph(); |
|
74 | 74 | |
75 | - $html = '<div class="panel panel-default" id="intro"> |
|
75 | + $html = '<div class="panel panel-default" id="intro"> |
|
76 | 76 | <div class="panel-heading"> |
77 | 77 | '.get_lang('StudentsInformationsGraph').' |
78 | 78 | <div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'"> |
@@ -84,51 +84,51 @@ discard block |
||
84 | 84 | '.$students_attendance_graph.' |
85 | 85 | </div> |
86 | 86 | </div>'; |
87 | - $data['column'] = $column; |
|
88 | - $data['content_html'] = $html; |
|
89 | - return $data; |
|
87 | + $data['column'] = $column; |
|
88 | + $data['content_html'] = $html; |
|
89 | + return $data; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * This method return a graph containing information about students evaluation, |
|
93 | + * This method return a graph containing information about students evaluation, |
|
94 | 94 | * it's used inside get_block method for showing it inside dashboard interface |
95 | - * @return string img html |
|
96 | - */ |
|
95 | + * @return string img html |
|
96 | + */ |
|
97 | 97 | public function get_students_attendance_graph() |
98 | 98 | { |
99 | 99 | |
100 | - $students = $this->students; |
|
101 | - $attendance = new Attendance(); |
|
102 | - |
|
103 | - // get data |
|
104 | - $attendances_faults_avg = array(); |
|
105 | - if (is_array($students) && count($students) > 0) { |
|
106 | - foreach ($students as $student) { |
|
107 | - $student_id = $student['user_id']; |
|
108 | - //$student_info = api_get_user_info($student_id); |
|
109 | - // get average of faults in attendances by student |
|
110 | - $results_faults_avg = $attendance->get_faults_average_inside_courses($student_id); |
|
111 | - |
|
112 | - if (!empty($results_faults_avg)) { |
|
113 | - $attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent']; |
|
114 | - } else { |
|
115 | - $attendances_faults_avg[$student['lastname']] = 0; |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
100 | + $students = $this->students; |
|
101 | + $attendance = new Attendance(); |
|
102 | + |
|
103 | + // get data |
|
104 | + $attendances_faults_avg = array(); |
|
105 | + if (is_array($students) && count($students) > 0) { |
|
106 | + foreach ($students as $student) { |
|
107 | + $student_id = $student['user_id']; |
|
108 | + //$student_info = api_get_user_info($student_id); |
|
109 | + // get average of faults in attendances by student |
|
110 | + $results_faults_avg = $attendance->get_faults_average_inside_courses($student_id); |
|
111 | + |
|
112 | + if (!empty($results_faults_avg)) { |
|
113 | + $attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent']; |
|
114 | + } else { |
|
115 | + $attendances_faults_avg[$student['lastname']] = 0; |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - arsort($attendances_faults_avg); |
|
121 | - $usernames = array_keys($attendances_faults_avg); |
|
120 | + arsort($attendances_faults_avg); |
|
121 | + $usernames = array_keys($attendances_faults_avg); |
|
122 | 122 | |
123 | - $faults = array(); |
|
124 | - foreach ($usernames as $username) { |
|
125 | - $faults[] = $attendances_faults_avg[$username]; |
|
126 | - } |
|
123 | + $faults = array(); |
|
124 | + foreach ($usernames as $username) { |
|
125 | + $faults[] = $attendances_faults_avg[$username]; |
|
126 | + } |
|
127 | 127 | |
128 | - $graph = ''; |
|
129 | - $img_file = ''; |
|
128 | + $graph = ''; |
|
129 | + $img_file = ''; |
|
130 | 130 | |
131 | - if (is_array($usernames) && count($usernames) > 0) { |
|
131 | + if (is_array($usernames) && count($usernames) > 0) { |
|
132 | 132 | |
133 | 133 | // Defining data |
134 | 134 | $dataSet = new pData(); |
@@ -233,19 +233,19 @@ discard block |
||
233 | 233 | $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
234 | 234 | } |
235 | 235 | $graph = '<img src="' . $imgPath . '" >'; |
236 | - } else { |
|
237 | - $graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>'; |
|
238 | - } |
|
236 | + } else { |
|
237 | + $graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>'; |
|
238 | + } |
|
239 | 239 | |
240 | - return $graph; |
|
241 | - } |
|
240 | + return $graph; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | /** |
244 | - * Get number of students |
|
245 | - * @return int |
|
246 | - */ |
|
247 | - function get_number_of_students() |
|
244 | + * Get number of students |
|
245 | + * @return int |
|
246 | + */ |
|
247 | + function get_number_of_students() |
|
248 | 248 | { |
249 | - return count($this->students); |
|
250 | - } |
|
249 | + return count($this->students); |
|
250 | + } |
|
251 | 251 | } |
@@ -23,42 +23,42 @@ discard block |
||
23 | 23 | class BlockEvaluationGraph extends Block |
24 | 24 | { |
25 | 25 | private $user_id; |
26 | - private $courses; |
|
27 | - private $sessions; |
|
28 | - private $path; |
|
29 | - private $permission = array(DRH, SESSIONADMIN); |
|
30 | - |
|
31 | - /** |
|
32 | - * Constructor |
|
33 | - */ |
|
26 | + private $courses; |
|
27 | + private $sessions; |
|
28 | + private $path; |
|
29 | + private $permission = array(DRH, SESSIONADMIN); |
|
30 | + |
|
31 | + /** |
|
32 | + * Constructor |
|
33 | + */ |
|
34 | 34 | public function __construct($user_id) |
35 | 35 | { |
36 | - $this->path = 'block_evaluation_graph'; |
|
37 | - $this->user_id = $user_id; |
|
38 | - $this->bg_width = 450; |
|
39 | - $this->bg_height = 350; |
|
40 | - if ($this->is_block_visible_for_user($user_id)) { |
|
36 | + $this->path = 'block_evaluation_graph'; |
|
37 | + $this->user_id = $user_id; |
|
38 | + $this->bg_width = 450; |
|
39 | + $this->bg_height = 350; |
|
40 | + if ($this->is_block_visible_for_user($user_id)) { |
|
41 | 41 | if (!api_is_session_admin()) { |
42 | 42 | $this->courses = CourseManager::get_courses_followed_by_drh($user_id); |
43 | 43 | } |
44 | 44 | $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id); |
45 | - } |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * This method check if a user is allowed to see the block inside dashboard interface |
|
50 | - * @param int User id |
|
51 | - * @return bool Is block visible for user |
|
52 | - */ |
|
48 | + /** |
|
49 | + * This method check if a user is allowed to see the block inside dashboard interface |
|
50 | + * @param int User id |
|
51 | + * @return bool Is block visible for user |
|
52 | + */ |
|
53 | 53 | public function is_block_visible_for_user($user_id) |
54 | 54 | { |
55 | - $user_info = api_get_user_info($user_id); |
|
56 | - $user_status = $user_info['status']; |
|
57 | - $is_block_visible_for_user = false; |
|
58 | - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
59 | - $is_block_visible_for_user = true; |
|
60 | - } |
|
61 | - return $is_block_visible_for_user; |
|
55 | + $user_info = api_get_user_info($user_id); |
|
56 | + $user_status = $user_info['status']; |
|
57 | + $is_block_visible_for_user = false; |
|
58 | + if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
59 | + $is_block_visible_for_user = true; |
|
60 | + } |
|
61 | + return $is_block_visible_for_user; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function get_block() |
70 | 70 | { |
71 | - global $charset; |
|
72 | - $column = 1; |
|
73 | - $data = array(); |
|
71 | + global $charset; |
|
72 | + $column = 1; |
|
73 | + $data = array(); |
|
74 | 74 | |
75 | - $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph(); |
|
76 | - $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph(); |
|
75 | + $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph(); |
|
76 | + $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph(); |
|
77 | 77 | |
78 | - $html = '<div class="panel panel-default" id="intro"> |
|
78 | + $html = '<div class="panel panel-default" id="intro"> |
|
79 | 79 | <div class="panel-heading"> |
80 | 80 | '.get_lang('EvaluationsGraph').' |
81 | 81 | <div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'"> |
@@ -105,43 +105,43 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | - $html .= '</div> |
|
108 | + $html .= '</div> |
|
109 | 109 | </div>'; |
110 | 110 | |
111 | - $data['column'] = $column; |
|
112 | - $data['content_html'] = $html; |
|
111 | + $data['column'] = $column; |
|
112 | + $data['content_html'] = $html; |
|
113 | 113 | |
114 | - return $data; |
|
115 | - } |
|
114 | + return $data; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | /** |
118 | - * This method return a graph containing informations about evaluations |
|
118 | + * This method return a graph containing informations about evaluations |
|
119 | 119 | * inside base courses, it's used inside get_block method for showing |
120 | 120 | * it inside dashboard interface |
121 | - * @return string img html |
|
122 | - */ |
|
121 | + * @return string img html |
|
122 | + */ |
|
123 | 123 | public function get_evaluations_base_courses_graph() |
124 | 124 | { |
125 | - $graphs = array(); |
|
126 | - if (!empty($this->courses)) { |
|
127 | - $courses_code = array_keys($this->courses); |
|
128 | - foreach ($courses_code as $course_code) { |
|
129 | - $cats = Category::load(null, null, $course_code, null, null, null, false); |
|
130 | - |
|
131 | - if (isset($cats) && isset($cats[0])) { |
|
132 | - $alleval = $cats[0]->get_evaluations(null, true, $course_code); |
|
133 | - $alllinks = $cats[0]->get_links(null, true); |
|
134 | - $users = GradebookUtils::get_all_users($alleval, $alllinks); |
|
135 | - $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); |
|
136 | - $evaluation_sumary = $datagen->get_evaluation_sumary_results(); |
|
137 | - if (!empty($evaluation_sumary)) { |
|
138 | - $items = array_keys($evaluation_sumary); |
|
139 | - $max = $min = $avg = array(); |
|
140 | - foreach ($evaluation_sumary as $evaluation) { |
|
141 | - $max[] = $evaluation['max']; |
|
125 | + $graphs = array(); |
|
126 | + if (!empty($this->courses)) { |
|
127 | + $courses_code = array_keys($this->courses); |
|
128 | + foreach ($courses_code as $course_code) { |
|
129 | + $cats = Category::load(null, null, $course_code, null, null, null, false); |
|
130 | + |
|
131 | + if (isset($cats) && isset($cats[0])) { |
|
132 | + $alleval = $cats[0]->get_evaluations(null, true, $course_code); |
|
133 | + $alllinks = $cats[0]->get_links(null, true); |
|
134 | + $users = GradebookUtils::get_all_users($alleval, $alllinks); |
|
135 | + $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); |
|
136 | + $evaluation_sumary = $datagen->get_evaluation_sumary_results(); |
|
137 | + if (!empty($evaluation_sumary)) { |
|
138 | + $items = array_keys($evaluation_sumary); |
|
139 | + $max = $min = $avg = array(); |
|
140 | + foreach ($evaluation_sumary as $evaluation) { |
|
141 | + $max[] = $evaluation['max']; |
|
142 | 142 | $min[] = !empty($evaluation['min']) ? $evaluation['min'] : 0; |
143 | - $avg[] = $evaluation['avg']; |
|
144 | - } |
|
143 | + $avg[] = $evaluation['avg']; |
|
144 | + } |
|
145 | 145 | // Dataset definition |
146 | 146 | $dataSet = new pData(); |
147 | 147 | $dataSet->addPoints($min, 'Serie3'); |
@@ -283,43 +283,43 @@ discard block |
||
283 | 283 | if (!empty($imgPath)) { |
284 | 284 | $courses_graph[$course_code] = '<img src="' . $imgPath . '">'; |
285 | 285 | } |
286 | - } |
|
287 | - } |
|
288 | - } // end for |
|
289 | - } |
|
290 | - return $graphs; |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * This method return a graph containing information about evaluations |
|
286 | + } |
|
287 | + } |
|
288 | + } // end for |
|
289 | + } |
|
290 | + return $graphs; |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * This method return a graph containing information about evaluations |
|
295 | 295 | * inside courses in sessions, it's used inside get_block method for |
296 | 296 | * showing it inside dashboard interface |
297 | - * @return string img html |
|
298 | - */ |
|
297 | + * @return string img html |
|
298 | + */ |
|
299 | 299 | public function get_evaluations_courses_in_sessions_graph() |
300 | 300 | { |
301 | - $graphs = array(); |
|
302 | - if (!empty($this->sessions)) { |
|
303 | - $session_ids = array_keys($this->sessions); |
|
304 | - foreach ($session_ids as $session_id) { |
|
305 | - $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); |
|
306 | - $courses_graph = array(); |
|
307 | - foreach ($courses_code as $course_code) { |
|
308 | - $cats = Category::load(null, null, $course_code, null, null, $session_id); |
|
309 | - if (isset($cats) && isset($cats[0])) { |
|
310 | - $alleval = $cats[0]->get_evaluations(null, true, $course_code); |
|
311 | - $alllinks = $cats[0]->get_links(null, true); |
|
312 | - $users = GradebookUtils::get_all_users($alleval, $alllinks); |
|
313 | - $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); |
|
314 | - $evaluation_sumary = $datagen->get_evaluation_sumary_results(); |
|
315 | - if (!empty($evaluation_sumary)) { |
|
316 | - $items = array_keys($evaluation_sumary); |
|
317 | - $max = $min = $avg = array(); |
|
318 | - foreach ($evaluation_sumary as $evaluation) { |
|
319 | - $max[] = $evaluation['max']; |
|
320 | - $min[] = $evaluation['min']; |
|
321 | - $avg[] = $evaluation['avg']; |
|
322 | - } |
|
301 | + $graphs = array(); |
|
302 | + if (!empty($this->sessions)) { |
|
303 | + $session_ids = array_keys($this->sessions); |
|
304 | + foreach ($session_ids as $session_id) { |
|
305 | + $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); |
|
306 | + $courses_graph = array(); |
|
307 | + foreach ($courses_code as $course_code) { |
|
308 | + $cats = Category::load(null, null, $course_code, null, null, $session_id); |
|
309 | + if (isset($cats) && isset($cats[0])) { |
|
310 | + $alleval = $cats[0]->get_evaluations(null, true, $course_code); |
|
311 | + $alllinks = $cats[0]->get_links(null, true); |
|
312 | + $users = GradebookUtils::get_all_users($alleval, $alllinks); |
|
313 | + $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); |
|
314 | + $evaluation_sumary = $datagen->get_evaluation_sumary_results(); |
|
315 | + if (!empty($evaluation_sumary)) { |
|
316 | + $items = array_keys($evaluation_sumary); |
|
317 | + $max = $min = $avg = array(); |
|
318 | + foreach ($evaluation_sumary as $evaluation) { |
|
319 | + $max[] = $evaluation['max']; |
|
320 | + $min[] = $evaluation['min']; |
|
321 | + $avg[] = $evaluation['avg']; |
|
322 | + } |
|
323 | 323 | // Dataset definition |
324 | 324 | $dataSet = new pData(); |
325 | 325 | $dataSet->addPoints($min, 'Serie3'); |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | if (!empty($imgPath)) { |
456 | 456 | $courses_graph[$course_code] = '<img src="' . $imgPath . '">'; |
457 | 457 | } |
458 | - } |
|
459 | - } |
|
460 | - } |
|
461 | - if (!empty($courses_graph)) { |
|
462 | - $graphs[$session_id] = $courses_graph; |
|
463 | - } |
|
464 | - } |
|
465 | - } |
|
466 | - return $graphs; |
|
467 | - } |
|
458 | + } |
|
459 | + } |
|
460 | + } |
|
461 | + if (!empty($courses_graph)) { |
|
462 | + $graphs[$session_id] = $courses_graph; |
|
463 | + } |
|
464 | + } |
|
465 | + } |
|
466 | + return $graphs; |
|
467 | + } |
|
468 | 468 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This file is part of teacher graph block plugin for dashboard, |
|
4 | - * it should be required inside dashboard controller for showing it into dashboard interface from plattform |
|
5 | - * @package chamilo.dashboard |
|
6 | - * @author Christian Fasanando |
|
7 | - */ |
|
3 | + * This file is part of teacher graph block plugin for dashboard, |
|
4 | + * it should be required inside dashboard controller for showing it into dashboard interface from plattform |
|
5 | + * @package chamilo.dashboard |
|
6 | + * @author Christian Fasanando |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * required files for getting data |
@@ -26,32 +26,32 @@ discard block |
||
26 | 26 | private $path; |
27 | 27 | private $permission = array(DRH); |
28 | 28 | |
29 | - /** |
|
30 | - * Controller |
|
31 | - */ |
|
29 | + /** |
|
30 | + * Controller |
|
31 | + */ |
|
32 | 32 | public function __construct ($user_id) |
33 | 33 | { |
34 | - $this->user_id = $user_id; |
|
35 | - $this->path = 'block_teacher_graph'; |
|
36 | - if ($this->is_block_visible_for_user($user_id)) { |
|
34 | + $this->user_id = $user_id; |
|
35 | + $this->path = 'block_teacher_graph'; |
|
36 | + if ($this->is_block_visible_for_user($user_id)) { |
|
37 | 37 | $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); |
38 | - } |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * This method check if a user is allowed to see the block inside dashboard interface |
|
43 | - * @param int User id |
|
44 | - * @return bool Is block visible for user |
|
45 | - */ |
|
42 | + * This method check if a user is allowed to see the block inside dashboard interface |
|
43 | + * @param int User id |
|
44 | + * @return bool Is block visible for user |
|
45 | + */ |
|
46 | 46 | public function is_block_visible_for_user($user_id) |
47 | 47 | { |
48 | - $user_info = api_get_user_info($user_id); |
|
49 | - $user_status = $user_info['status']; |
|
50 | - $is_block_visible_for_user = false; |
|
51 | - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
52 | - $is_block_visible_for_user = true; |
|
53 | - } |
|
54 | - return $is_block_visible_for_user; |
|
48 | + $user_info = api_get_user_info($user_id); |
|
49 | + $user_status = $user_info['status']; |
|
50 | + $is_block_visible_for_user = false; |
|
51 | + if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
52 | + $is_block_visible_for_user = true; |
|
53 | + } |
|
54 | + return $is_block_visible_for_user; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function get_block() |
63 | 63 | { |
64 | - global $charset; |
|
65 | - $column = 1; |
|
66 | - $data = array(); |
|
67 | - $teacher_information_graph = $this->get_teachers_information_graph(); |
|
68 | - $html = ' |
|
64 | + global $charset; |
|
65 | + $column = 1; |
|
66 | + $data = array(); |
|
67 | + $teacher_information_graph = $this->get_teachers_information_graph(); |
|
68 | + $html = ' |
|
69 | 69 | <div class="panel panel-default" id="intro"> |
70 | 70 | <div class="panel-heading">'.get_lang('TeachersInformationsGraph').' |
71 | 71 | <div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'"> |
@@ -79,53 +79,53 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | '; |
81 | 81 | |
82 | - $data['column'] = $column; |
|
83 | - $data['content_html'] = $html; |
|
82 | + $data['column'] = $column; |
|
83 | + $data['content_html'] = $html; |
|
84 | 84 | |
85 | - return $data; |
|
85 | + return $data; |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * This method return a content html, it's used inside get_block method for showing it inside dashboard interface |
|
91 | - * @return string content html |
|
92 | - */ |
|
90 | + * This method return a content html, it's used inside get_block method for showing it inside dashboard interface |
|
91 | + * @return string content html |
|
92 | + */ |
|
93 | 93 | public function get_teachers_information_graph() |
94 | 94 | { |
95 | - $teachers = $this->teachers; |
|
96 | - $graph = ''; |
|
97 | - |
|
98 | - $user_ids = array_keys($teachers); |
|
99 | - $a_last_week = get_last_week(); |
|
100 | - |
|
101 | - if (is_array($user_ids) && count($user_ids) > 0) { |
|
102 | - $dataSet = new pData; |
|
103 | - foreach ($user_ids as $user_id) { |
|
104 | - $teacher_info = api_get_user_info($user_id); |
|
105 | - $username = $teacher_info['username']; |
|
106 | - $time_by_days = array(); |
|
107 | - foreach ($a_last_week as $day) { |
|
108 | - // day is received as y-m-d 12:00:00 |
|
109 | - $start_date = api_get_utc_datetime($day); |
|
110 | - $end_date = api_get_utc_datetime($day+(3600*24-1)); |
|
111 | - |
|
112 | - $time_on_platform_by_day = Tracking::get_time_spent_on_the_platform($user_id, 'custom', $start_date, $end_date); |
|
113 | - $hours = floor($time_on_platform_by_day / 3600); |
|
114 | - $min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60); |
|
115 | - $time_by_days[] = $min; |
|
116 | - } |
|
117 | - $dataSet->addPoints($time_by_days, $username); |
|
118 | - } |
|
119 | - |
|
120 | - $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); |
|
121 | - $days_on_week = array(); |
|
122 | - foreach ($a_last_week as $weekday) { |
|
123 | - $days_on_week[] = date('d/m',$weekday); |
|
124 | - } |
|
125 | - |
|
126 | - $dataSet->addPoints($days_on_week, 'Days'); |
|
127 | - $dataSet->setAbscissaName($last_week); |
|
128 | - $dataSet->setAxisName(0, get_lang('Minutes')); |
|
95 | + $teachers = $this->teachers; |
|
96 | + $graph = ''; |
|
97 | + |
|
98 | + $user_ids = array_keys($teachers); |
|
99 | + $a_last_week = get_last_week(); |
|
100 | + |
|
101 | + if (is_array($user_ids) && count($user_ids) > 0) { |
|
102 | + $dataSet = new pData; |
|
103 | + foreach ($user_ids as $user_id) { |
|
104 | + $teacher_info = api_get_user_info($user_id); |
|
105 | + $username = $teacher_info['username']; |
|
106 | + $time_by_days = array(); |
|
107 | + foreach ($a_last_week as $day) { |
|
108 | + // day is received as y-m-d 12:00:00 |
|
109 | + $start_date = api_get_utc_datetime($day); |
|
110 | + $end_date = api_get_utc_datetime($day+(3600*24-1)); |
|
111 | + |
|
112 | + $time_on_platform_by_day = Tracking::get_time_spent_on_the_platform($user_id, 'custom', $start_date, $end_date); |
|
113 | + $hours = floor($time_on_platform_by_day / 3600); |
|
114 | + $min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60); |
|
115 | + $time_by_days[] = $min; |
|
116 | + } |
|
117 | + $dataSet->addPoints($time_by_days, $username); |
|
118 | + } |
|
119 | + |
|
120 | + $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); |
|
121 | + $days_on_week = array(); |
|
122 | + foreach ($a_last_week as $weekday) { |
|
123 | + $days_on_week[] = date('d/m',$weekday); |
|
124 | + } |
|
125 | + |
|
126 | + $dataSet->addPoints($days_on_week, 'Days'); |
|
127 | + $dataSet->setAbscissaName($last_week); |
|
128 | + $dataSet->setAxisName(0, get_lang('Minutes')); |
|
129 | 129 | $dataSet->setAbscissa('Days'); |
130 | 130 | $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true); |
131 | 131 | |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
195 | 195 | } |
196 | 196 | $graph = '<img src="' . $imgPath . '" >'; |
197 | - } else { |
|
198 | - $graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>'; |
|
199 | - } |
|
197 | + } else { |
|
198 | + $graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>'; |
|
199 | + } |
|
200 | 200 | |
201 | - return $graph; |
|
202 | - } |
|
201 | + return $graph; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | /** |
205 | - * Get number of teachers |
|
206 | - * @return int |
|
207 | - */ |
|
208 | - function get_number_of_teachers() |
|
205 | + * Get number of teachers |
|
206 | + * @return int |
|
207 | + */ |
|
208 | + function get_number_of_teachers() |
|
209 | 209 | { |
210 | - return count($this->teachers); |
|
211 | - } |
|
210 | + return count($this->teachers); |
|
211 | + } |
|
212 | 212 | |
213 | 213 | } |
@@ -11,18 +11,18 @@ |
||
11 | 11 | |
12 | 12 | class action_plugin_jcapture extends DokuWiki_Action_Plugin { |
13 | 13 | |
14 | - /** |
|
15 | - * return some info |
|
16 | - */ |
|
17 | - function getInfo(){ |
|
14 | + /** |
|
15 | + * return some info |
|
16 | + */ |
|
17 | + function getInfo(){ |
|
18 | 18 | return array( |
19 | - 'author' => 'Pavel Vlasov', |
|
20 | - 'email' => '[email protected]', |
|
21 | - 'name' => 'JCapture', |
|
22 | - 'desc' => 'Plugin for making screen captures.', |
|
23 | - 'url' => 'http://www.nasdanika.com/wiki/doku.php?id=products:jcapture:start', |
|
24 | - ); |
|
25 | - } |
|
19 | + 'author' => 'Pavel Vlasov', |
|
20 | + 'email' => '[email protected]', |
|
21 | + 'name' => 'JCapture', |
|
22 | + 'desc' => 'Plugin for making screen captures.', |
|
23 | + 'url' => 'http://www.nasdanika.com/wiki/doku.php?id=products:jcapture:start', |
|
24 | + ); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Register the eventhandlers |
@@ -1,31 +1,31 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - //fix for Opera XMLHttpRequests |
|
4 | - if(!count($_POST) && $HTTP_RAW_POST_DATA){ |
|
5 | - parse_str($HTTP_RAW_POST_DATA, $_POST); |
|
6 | - } |
|
3 | + //fix for Opera XMLHttpRequests |
|
4 | + if(!count($_POST) && $HTTP_RAW_POST_DATA){ |
|
5 | + parse_str($HTTP_RAW_POST_DATA, $_POST); |
|
6 | + } |
|
7 | 7 | |
8 | - if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); |
|
9 | - require_once(DOKU_INC.'inc/init.php'); |
|
10 | - require_once(DOKU_INC.'inc/common.php'); |
|
11 | - require_once(DOKU_INC.'inc/pageutils.php'); |
|
12 | - require_once(DOKU_INC.'inc/auth.php'); |
|
13 | - //close sesseion |
|
14 | - session_write_close(); |
|
8 | + if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); |
|
9 | + require_once(DOKU_INC.'inc/init.php'); |
|
10 | + require_once(DOKU_INC.'inc/common.php'); |
|
11 | + require_once(DOKU_INC.'inc/pageutils.php'); |
|
12 | + require_once(DOKU_INC.'inc/auth.php'); |
|
13 | + //close sesseion |
|
14 | + session_write_close(); |
|
15 | 15 | |
16 | - header('Content-Type: text/html; charset=utf-8'); |
|
16 | + header('Content-Type: text/html; charset=utf-8'); |
|
17 | 17 | |
18 | - $hostName = "http".($_SERVER['HTTPS'] ? 's' : null).'://'.$_SERVER['HTTP_HOST']; |
|
18 | + $hostName = "http".($_SERVER['HTTPS'] ? 's' : null).'://'.$_SERVER['HTTP_HOST']; |
|
19 | 19 | |
20 | - $imageFormat = "PNG"; |
|
20 | + $imageFormat = "PNG"; |
|
21 | 21 | |
22 | - $cookies; |
|
23 | - foreach (array_keys($_COOKIE) as $cookieName) { |
|
24 | - $cookies.=bin2hex($cookieName)."=".bin2hex($_COOKIE[$cookieName]).";"; |
|
25 | - } |
|
22 | + $cookies; |
|
23 | + foreach (array_keys($_COOKIE) as $cookieName) { |
|
24 | + $cookies.=bin2hex($cookieName)."=".bin2hex($_COOKIE[$cookieName]).";"; |
|
25 | + } |
|
26 | 26 | |
27 | - $pageName = $_GET["pageName"]; |
|
28 | - $edid = $_GET["edid"]; |
|
27 | + $pageName = $_GET["pageName"]; |
|
28 | + $edid = $_GET["edid"]; |
|
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <script language="JavaScript" type="text/javascript"><!-- |
@@ -433,7 +433,7 @@ |
||
433 | 433 | $form->addElement( |
434 | 434 | 'checkbox', |
435 | 435 | 'confirmation', |
436 | - null, |
|
436 | + null, |
|
437 | 437 | $plugin->get_lang('RequestConfirmation') |
438 | 438 | ); |
439 | 439 | } |
@@ -563,7 +563,7 @@ |
||
563 | 563 | $photo = '<img src="' . $userPicture. '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />'; |
564 | 564 | $button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">' |
565 | 565 | . Display::return_icon('view_more_stats.gif', get_lang('Info')) . |
566 | - '</a> '; |
|
566 | + '</a> '; |
|
567 | 567 | $users[] = array( |
568 | 568 | $photo, |
569 | 569 | $user_id, |