Passed
Push — 1.10.x ( 08890a...2189d7 )
by Yannick
116:38 queued 75:46
created
main/webservices/cm_webservice_user.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
     /**
138 138
     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139 139
     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
140
+    * @param string[] $order_by a list of fields on which sort
141 141
     * @return array An array with all users of the platform.
142 142
     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         global $charset;
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98
-		    $user_id = UserManager::get_user_id_from_username($username);
98
+            $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100 100
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
101 101
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
     /**
138
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
141
-    * @return array An array with all users of the platform.
142
-    * @todo optional course code parameter, optional sorting parameters...
138
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
+     * @param array $order_by a list of fields on which sort
141
+     * @return array An array with all users of the platform.
142
+     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
144 144
      * @todo security filter order by
145
-    */
145
+     */
146 146
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
147 147
     {
148 148
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function find_id_user($username, $password, $name)
15 15
     {
16
-        if($this->verifyUserPass($username, $password) == "valid")
16
+        if ($this->verifyUserPass($username, $password) == "valid")
17 17
         {
18 18
 
19 19
             $listResult = "#";
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
             }
41 41
 
42 42
             $listArrayResult = array_unique($listArray);
43
-            foreach($listArrayResult as $result)
43
+            foreach ($listArrayResult as $result)
44 44
             {
45
-                $listResult .= $result . "#";
45
+                $listResult .= $result."#";
46 46
             }
47 47
 
48 48
             return $listResult;
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98 98
 		    $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100
-            $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
100
+            $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message);
101 101
 
102 102
             if ($count_is_true) {
103
-                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
103
+                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false);
104 104
             } else {
105
-                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
105
+                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false);
106 106
             }
107 107
         }
108 108
         return get_lang('InvalidId');
Please login to merge, or discard this patch.
main/webservices/lp.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@
 block discarded – undo
20 20
 
21 21
 define('WS_ERROR_SECRET_KEY', 1);
22 22
 
23
+/**
24
+ * @param integer $code
25
+ */
23 26
 function return_error($code) {
24 27
     $fault = null;
25 28
     switch ($code) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -581,7 +581,7 @@
 block discarded – undo
581 581
     /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
582 582
     $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
583 583
 
584
-     $courseInfo = CourseManager::getCourseInfoFromOriginalId(
584
+        $courseInfo = CourseManager::getCourseInfoFromOriginalId(
585 585
         $courseIdValue,
586 586
         $courseIdName
587 587
     );
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     if ($debug) {
68
-        error_log("checkip " . intval($check_ip));
68
+        error_log("checkip ".intval($check_ip));
69 69
     }
70 70
 
71 71
     if ($check_ip) {
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 );
121 121
 
122 122
 // Register the method to expose
123
-$server->register('WSImportLP',                            // method name
124
-    array('params' => 'tns:params'),  // input parameters
125
-    array('return' => 'xsd:string'),                                        // output parameters
126
-    'urn:WSLP',                                                   // namespace
127
-    'urn:WSLP#WSImportLP',                       // soapaction
128
-    'rpc',                                                                  // style
129
-    'encoded',                                                              // use
123
+$server->register('WSImportLP', // method name
124
+    array('params' => 'tns:params'), // input parameters
125
+    array('return' => 'xsd:string'), // output parameters
126
+    'urn:WSLP', // namespace
127
+    'urn:WSLP#WSImportLP', // soapaction
128
+    'rpc', // style
129
+    'encoded', // use
130 130
     'This service adds users'                                               // documentation
131 131
 );
132 132
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     $uniqueFile = uniqid();
185 185
     $userId = 1; // admin
186
-    $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile;
186
+    $filePath = api_get_path(SYS_ARCHIVE_PATH).$uniqueFile;
187 187
     file_put_contents($filePath, $fileData);
188 188
 
189 189
     $fileName = $params['filename'];
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
     'all',
258 258
     '',
259 259
     array(
260
-        'id'    => array('name' => 'id',    'type' => 'xsd:string'),
261
-        'name'  => array('name' => 'name',  'type' => 'xsd:string'),
260
+        'id'    => array('name' => 'id', 'type' => 'xsd:string'),
261
+        'name'  => array('name' => 'name', 'type' => 'xsd:string'),
262 262
     )
263 263
 );
264 264
 
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 );
275 275
 
276 276
 // Register the method to expose
277
-$server->register('WSGetLpList',                            // method name
278
-    array('params' => 'tns:paramsGetLpList'),  // input parameters
279
-    array('return' => 'tns:lpList'),                                        // output parameters
280
-    'urn:WSLP',                                                   // namespace
281
-    'urn:WSLP#WSGetLpList',                       // soapaction
282
-    'rpc',                                                                  // style
283
-    'encoded',                                                              // use
277
+$server->register('WSGetLpList', // method name
278
+    array('params' => 'tns:paramsGetLpList'), // input parameters
279
+    array('return' => 'tns:lpList'), // output parameters
280
+    'urn:WSLP', // namespace
281
+    'urn:WSLP#WSGetLpList', // soapaction
282
+    'rpc', // style
283
+    'encoded', // use
284 284
     'This service adds users'                                               // documentation
285 285
 );
286 286
 
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 );
370 370
 
371 371
 // Register the method to expose
372
-$server->register('WSDeleteLp',                            // method name
373
-    array('params' => 'tns:paramsDeleteLp'),  // input parameters
374
-    array('return' => 'xsd:string'),                                        // output parameters
375
-    'urn:WSLP',                                                   // namespace
376
-    'urn:WSLP#WSDeleteLp',                       // soapaction
377
-    'rpc',                                                                  // style
378
-    'encoded',                                                              // use
372
+$server->register('WSDeleteLp', // method name
373
+    array('params' => 'tns:paramsDeleteLp'), // input parameters
374
+    array('return' => 'xsd:string'), // output parameters
375
+    'urn:WSLP', // namespace
376
+    'urn:WSLP#WSDeleteLp', // soapaction
377
+    'rpc', // style
378
+    'encoded', // use
379 379
     'This service deletes a LP'                                               // documentation
380 380
 );
381 381
 
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
     if ($lp) {
435 435
         if ($debug) error_log("LP deleted $lpId");
436 436
 
437
-        $course_dir = $courseInfo['directory'] . '/document';
437
+        $course_dir = $courseInfo['directory'].'/document';
438 438
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
439
-        $base_work_dir = $sys_course_path . $course_dir;
439
+        $base_work_dir = $sys_course_path.$course_dir;
440 440
 
441 441
         $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId);
442 442
 
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
     'all',
496 496
     '',
497 497
     array(
498
-        'data'  => array('name' => 'data',  'type' => 'xsd:string'),
499
-        'title'  => array('name' => 'title',  'type' => 'xsd:string'),
500
-        'filename'  => array('name' => 'filename',  'type' => 'xsd:string'),
498
+        'data'  => array('name' => 'data', 'type' => 'xsd:string'),
499
+        'title'  => array('name' => 'title', 'type' => 'xsd:string'),
500
+        'filename'  => array('name' => 'filename', 'type' => 'xsd:string'),
501 501
     )
502 502
 );
503 503
 
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 );
549 549
 
550 550
 // Register the method to expose
551
-$server->register('WSCreateLp',                            // method name
552
-    array('params' => 'tns:paramsCreateLp'),  // input parameters
553
-    array('return' => 'xsd:string'),                                        // output parameters
554
-    'urn:WSLP',                                                   // namespace
555
-    'urn:WSLP#WSCreateLp',                       // soapaction
556
-    'rpc',                                                                  // style
557
-    'encoded',                                                              // use
551
+$server->register('WSCreateLp', // method name
552
+    array('params' => 'tns:paramsCreateLp'), // input parameters
553
+    array('return' => 'xsd:string'), // output parameters
554
+    'urn:WSLP', // namespace
555
+    'urn:WSLP#WSCreateLp', // soapaction
556
+    'rpc', // style
557
+    'encoded', // use
558 558
     'This service creates a LP'                                               // documentation
559 559
 );
560 560
 
Please login to merge, or discard this patch.
Braces   +48 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,19 +48,22 @@  discard block
 block discarded – undo
48 48
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
49 49
         $ip = trim($ip1);
50 50
     }
51
-    if ($debug)
52
-        error_log("ip: $ip");
51
+    if ($debug) {
52
+            error_log("ip: $ip");
53
+    }
53 54
     // Check if a file that limits access from webservices exists and contains
54 55
     // the restraining check
55 56
     if (is_file('webservice-auth-ip.conf.php')) {
56 57
         include 'webservice-auth-ip.conf.php';
57
-        if ($debug)
58
-            error_log("webservice-auth-ip.conf.php file included");
58
+        if ($debug) {
59
+                    error_log("webservice-auth-ip.conf.php file included");
60
+        }
59 61
         if (!empty($ws_auth_ip)) {
60 62
             $check_ip = true;
61 63
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
62
-            if ($debug)
63
-                error_log("ip_matches: $ip_matches");
64
+            if ($debug) {
65
+                            error_log("ip_matches: $ip_matches");
66
+            }
64 67
         }
65 68
     }
66 69
 
@@ -76,8 +79,9 @@  discard block
 block discarded – undo
76 79
     }
77 80
     $result = api_is_valid_secret_key($secret_key, $security_key);
78 81
     //error_log($secret_key.'-'.$security_key);
79
-    if ($debug)
80
-        error_log('WSHelperVerifyKey result: '.intval($result));
82
+    if ($debug) {
83
+            error_log('WSHelperVerifyKey result: '.intval($result));
84
+    }
81 85
     return $result;
82 86
 }
83 87
 
@@ -140,7 +144,9 @@  discard block
 block discarded – undo
140 144
     if (!WSHelperVerifyKey($params)) {
141 145
         return return_error(WS_ERROR_SECRET_KEY);
142 146
     }
143
-    if ($debug) error_log('WSImportLP');
147
+    if ($debug) {
148
+        error_log('WSImportLP');
149
+    }
144 150
 
145 151
     $courseIdName = $params['course_id_name'];
146 152
     $courseIdValue = $params['course_id_value'];
@@ -156,7 +162,9 @@  discard block
 block discarded – undo
156 162
     $courseId = $courseInfo['real_id'];
157 163
 
158 164
     if (empty($courseInfo)) {
159
-        if ($debug) error_log('Course not found');
165
+        if ($debug) {
166
+            error_log('Course not found');
167
+        }
160 168
         return 'Course not found';
161 169
     }
162 170
 
@@ -169,7 +177,9 @@  discard block
 block discarded – undo
169 177
 
170 178
         if (empty($sessionId)) {
171 179
 
172
-            if ($debug) error_log('Session not found');
180
+            if ($debug) {
181
+                error_log('Session not found');
182
+            }
173 183
             return 'Session not found';
174 184
         }
175 185
     }
@@ -196,7 +206,9 @@  discard block
 block discarded – undo
196 206
     $manifest = $oScorm->import_package($fileInfo, '', $courseInfo);
197 207
 
198 208
     if (!$manifest) {
199
-        if ($debug) error_log('manifest.xml file not found');
209
+        if ($debug) {
210
+            error_log('manifest.xml file not found');
211
+        }
200 212
         //if api_set_failure
201 213
         return 'manifest.xml file not found';
202 214
     }
@@ -215,10 +227,14 @@  discard block
 block discarded – undo
215 227
         $oScorm->set_maker($maker, $courseId);
216 228
         //$oScorm->set_jslib('scorm_api.php');
217 229
 
218
-        if ($debug) error_log('scorm was added');
230
+        if ($debug) {
231
+            error_log('scorm was added');
232
+        }
219 233
         return 1;
220 234
     } else {
221
-        if ($debug) error_log('manifest data empty');
235
+        if ($debug) {
236
+            error_log('manifest data empty');
237
+        }
222 238
         return 'manifest data empty';
223 239
     }
224 240
 }
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
     );
312 328
 
313 329
     if (empty($courseInfo)) {
314
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
330
+        if ($debug) {
331
+            error_log("Course not found: $courseIdName : $courseIdValue");
332
+        }
315 333
         return 'Course not found';
316 334
     }
317 335
 
@@ -326,7 +344,9 @@  discard block
 block discarded – undo
326 344
 
327 345
         if (empty($sessionId)) {
328 346
 
329
-            if ($debug) error_log('Session not found');
347
+            if ($debug) {
348
+                error_log('Session not found');
349
+            }
330 350
             return 'Session not found';
331 351
         }
332 352
     }
@@ -407,7 +427,9 @@  discard block
 block discarded – undo
407 427
     );
408 428
 
409 429
     if (empty($courseInfo)) {
410
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
430
+        if ($debug) {
431
+            error_log("Course not found: $courseIdName : $courseIdValue");
432
+        }
411 433
         return 'Course not found';
412 434
     }
413 435
     $courseId = $courseInfo['real_id'];
@@ -432,7 +454,9 @@  discard block
 block discarded – undo
432 454
 
433 455
     $lp = new learnpath($courseCode, $lpId, null);
434 456
     if ($lp) {
435
-        if ($debug) error_log("LP deleted $lpId");
457
+        if ($debug) {
458
+            error_log("LP deleted $lpId");
459
+        }
436 460
 
437 461
         $course_dir = $courseInfo['directory'] . '/document';
438 462
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
@@ -448,7 +472,9 @@  discard block
 block discarded – undo
448 472
                 if ($item) {
449 473
                     $documentId = $item->get_path();
450 474
 
451
-                    if ($debug) error_log("lp item id found #$itemId");
475
+                    if ($debug) {
476
+                        error_log("lp item id found #$itemId");
477
+                    }
452 478
 
453 479
                     $documentInfo = DocumentManager::get_document_data_by_id(
454 480
                         $documentId,
@@ -474,7 +500,9 @@  discard block
 block discarded – undo
474 500
                         }
475 501
                     }
476 502
                 } else {
477
-                    if ($debug) error_log("Document not found #$itemId");
503
+                    if ($debug) {
504
+                        error_log("Document not found #$itemId");
505
+                    }
478 506
                 }
479 507
             }
480 508
         }
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -2617,6 +2617,9 @@
 block discarded – undo
2617 2617
     )
2618 2618
 );
2619 2619
 
2620
+/**
2621
+ * @param string $type
2622
+ */
2620 2623
 function WSHelperActionOnUsers($params, $type) {
2621 2624
     if(!WSHelperVerifyKey($params)) {
2622 2625
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4930,9 +4930,9 @@
 block discarded – undo
4930 4930
     'This service unsubscribe a user from a course'                     // documentation
4931 4931
 );
4932 4932
 /**
4933
- * @param array $params
4934
- * @return array|null|soap_fault
4935
- */
4933
+     * @param array $params
4934
+     * @return array|null|soap_fault
4935
+     */
4936 4936
 function WSUnSubscribeUserFromCourseSimple($params)
4937 4937
 {
4938 4938
     global $debug;
Please login to merge, or discard this patch.
Spacing   +454 added lines, -454 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
     if ($debug) {
83
-        error_log("checkip " . intval($check_ip));
83
+        error_log("checkip ".intval($check_ip));
84 84
     }
85 85
 
86 86
     if ($check_ip) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     '',
139 139
     'SOAP-ENC:Array',
140 140
     array(),
141
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),
141
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')),
142 142
     'tns:extras'
143 143
 );
144 144
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     '',
172 172
     'SOAP-ENC:Array',
173 173
     array(),
174
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),
174
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:usersParams[]')),
175 175
     'tns:usersParams'
176 176
 );
177 177
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
     '',
211 211
     'SOAP-ENC:Array',
212 212
     array(),
213
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers'
213
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsers[]')), 'tns:result_createUsers'
214 214
 );
215 215
 
216 216
 // Register the method to expose
217
-$server->register('WSCreateUsers',                 // method name
218
-    array('createUsers' => 'tns:createUsers'),     // input parameters
219
-    array('return' => 'tns:results_createUsers'),  // output parameters
220
-    'urn:WSRegistration',                          // namespace
221
-    'urn:WSRegistration#WSCreateUsers',            // soapaction
222
-    'rpc',                                         // style
223
-    'encoded',                                     // use
217
+$server->register('WSCreateUsers', // method name
218
+    array('createUsers' => 'tns:createUsers'), // input parameters
219
+    array('return' => 'tns:results_createUsers'), // output parameters
220
+    'urn:WSRegistration', // namespace
221
+    'urn:WSRegistration#WSCreateUsers', // soapaction
222
+    'rpc', // style
223
+    'encoded', // use
224 224
     'This service adds a user'                     // documentation
225 225
 );
226 226
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             continue;
402 402
         }
403 403
 
404
-        $results[] =  $userId;
404
+        $results[] = $userId;
405 405
 
406 406
     } // end principal foreach
407 407
 
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
 
448 448
 
449 449
 // Register the method to expose
450
-$server->register('WSCreateUser',                // method name
451
-    array('createUser' => 'tns:createUser'),     // input parameters
452
-    array('return' => 'xsd:string'),             // output parameters
453
-    'urn:WSRegistration',                        // namespace
454
-    'urn:WSRegistration#WSCreateUser',           // soapaction
455
-    'rpc',                                       // style
456
-    'encoded',                                   // use
450
+$server->register('WSCreateUser', // method name
451
+    array('createUser' => 'tns:createUser'), // input parameters
452
+    array('return' => 'xsd:string'), // output parameters
453
+    'urn:WSRegistration', // namespace
454
+    'urn:WSRegistration#WSCreateUser', // soapaction
455
+    'rpc', // style
456
+    'encoded', // use
457 457
     'This service adds a user'                   // documentation
458 458
 );
459 459
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     }
559 559
 
560 560
     if (isset($original_user_id_name) && isset($original_user_id_value)) {
561
-        $_SESSION['ws_' . $original_user_id_name] = $original_user_id_value;
561
+        $_SESSION['ws_'.$original_user_id_name] = $original_user_id_value;
562 562
     }
563 563
 
564 564
     /** @var User $user */
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         );
607 607
 
608 608
         if (isset($original_user_id_name) && isset($original_user_id_value)) {
609
-            unset($_SESSION['ws_' . $original_user_id_name]);
609
+            unset($_SESSION['ws_'.$original_user_id_name]);
610 610
         }
611 611
 
612 612
         if (is_array($extra_list) && count($extra_list) > 0) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         'language'              => array('name' => 'language', 'type' => 'xsd:string'),
659 659
         'phone'                 => array('name' => 'phone', 'type' => 'xsd:string'),
660 660
         'expiration_date'       => array('name' => 'expiration_date', 'type' => 'xsd:string'),
661
-        'official_code'         => array('name' => 'official_code',    'type' => 'xsd:string'),
661
+        'official_code'         => array('name' => 'official_code', 'type' => 'xsd:string'),
662 662
         'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
663 663
         'original_user_id_value'=> array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
664 664
         'extra'                 => array('name' => 'extra', 'type' => 'tns:extrasList')
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     'all',
687 687
     '',
688 688
     array(
689
-        'users'         => array('name' => 'users',      'type' => 'tns:createUsersPassEncryptParamsList'),
689
+        'users'         => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'),
690 690
         'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
691 691
     )
692 692
 );
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 );
717 717
 
718 718
 // Register the method to expose
719
-$server->register('WSCreateUsersPasswordCrypted',                            // method name
719
+$server->register('WSCreateUsersPasswordCrypted', // method name
720 720
     array('createUsersPasswordCrypted' => 'tns:createUsersPasswordCrypted'), // input parameters
721
-    array('return' => 'tns:results_createUsersPassEncrypt'),                 // output parameters
722
-    'urn:WSRegistration',                                                    // namespace
723
-    'urn:WSRegistration#WSCreateUsersPasswordCrypted',                       // soapaction
724
-    'rpc',                                                                   // style
725
-    'encoded',                                                               // use
721
+    array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters
722
+    'urn:WSRegistration', // namespace
723
+    'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction
724
+    'rpc', // style
725
+    'encoded', // use
726 726
     'This service adds users to the system'                                  // documentation
727 727
 );
728 728
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $salt = '';
770 770
 
771 771
         if (!empty($_configuration['password_encryption'])) {
772
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
772
+            if ($_configuration['password_encryption'] === $encrypt_method) {
773 773
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
774 774
                     $msg = "Encryption $encrypt_method is invalid";
775 775
                     $results[] = $msg;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
         if (is_array($extra_list) && count($extra_list) > 0) {
794 794
             foreach ($extra_list as $extra) {
795
-                if($extra['field_name'] == 'salt') {
795
+                if ($extra['field_name'] == 'salt') {
796 796
                     $salt = $extra['field_value'];
797 797
                     break;
798 798
                 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
                         active='1',
848 848
                         hr_dept_id=".intval($hr_dept_id);
849 849
 
850
-                $sql .=  " WHERE user_id='".$r_check_user[0]."'";
850
+                $sql .= " WHERE user_id='".$r_check_user[0]."'";
851 851
                 Database::query($sql);
852 852
 
853 853
                 if (is_array($extra_list) && count($extra_list) > 0) {
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 
968 968
     $count_results = count($results);
969 969
     $output = array();
970
-    for($i = 0; $i < $count_results; $i++) {
970
+    for ($i = 0; $i < $count_results; $i++) {
971 971
         $output[] = array(
972 972
             'original_user_id_value' => $orig_user_id_value[$i],
973 973
             'result' => $results[$i],
@@ -986,9 +986,9 @@  discard block
 block discarded – undo
986 986
     'all',
987 987
     '',
988 988
     array(
989
-        'user_id' => array('name' => 'course',     'type' => 'xsd:string'), // Chamilo user Id
990
-        'session_id' => array('name' => 'user_id',    'type' => 'xsd:string'), // Current Session course ID
991
-        'course_id' =>array('name' => 'courseId',      'type' => 'xsd:string'), // Course Real Id
989
+        'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id
990
+        'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID
991
+        'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id
992 992
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
993 993
 
994 994
         // optional
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
         );
1045 1045
     }
1046 1046
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1047
+    if ($debug) error_log('$userId found: '.$userId);
1048
+    if ($debug) error_log('$courseId found: '.$courseId);
1049
+    if ($debug) error_log('$sessionId found: '.$sessionId);
1050 1050
 
1051 1051
     return [
1052 1052
         'user_id' => $userId,
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         return returnError(WS_ERROR_SECRET_KEY);
1083 1083
     }
1084 1084
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1085
+    if ($debug) error_log('Params '.print_r($params, 1));
1086 1086
 
1087 1087
     $params = parseCourseSessionUserParams($params);
1088 1088
 
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
     $result = 0;
1096 1096
 
1097 1097
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1098
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1099 1099
         if (in_array($userId, $coaches)) {
1100 1100
             $result = 1;
1101 1101
         }
1102 1102
     }
1103 1103
 
1104
-    if ($debug) error_log('Result:  '. $result);
1104
+    if ($debug) error_log('Result:  '.$result);
1105 1105
 
1106 1106
     return $result;
1107 1107
 }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
         return returnError(WS_ERROR_SECRET_KEY);
1134 1134
     }
1135 1135
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1136
+    if ($debug) error_log('Params '.print_r($params, 1));
1137 1137
 
1138 1138
     $params = parseCourseSessionUserParams($params);
1139 1139
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
     $result = 0;
1148 1148
 
1149 1149
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1150
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1151 1151
         if (!in_array($userId, $coaches)) {
1152 1152
             $result = 1;
1153 1153
         }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
         $result = 1;
1156 1156
     }
1157 1157
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1158
+    if ($debug) error_log('Final Result: '.$result);
1159 1159
 
1160 1160
     return $result;
1161 1161
 }
@@ -1173,32 +1173,32 @@  discard block
 block discarded – undo
1173 1173
     'all',
1174 1174
     '',
1175 1175
     array(
1176
-        'firstname'                 => array('name' => 'firstname',                 'type' => 'xsd:string'),
1177
-        'lastname'                  => array('name' => 'lastname',                  'type' => 'xsd:string'),
1178
-        'status'                    => array('name' => 'status',                    'type' => 'xsd:string'),
1179
-        'email'                     => array('name' => 'email',                     'type' => 'xsd:string'),
1180
-        'loginname'                 => array('name' => 'loginname',                 'type' => 'xsd:string'),
1181
-        'password'                  => array('name' => 'password',                  'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
-        'encrypt_method'            => array('name' => 'encrypt_method',            'type' => 'xsd:string'),
1183
-        'language'                  => array('name' => 'language',                  'type' => 'xsd:string'),
1184
-        'phone'                     => array('name' => 'phone',                     'type' => 'xsd:string'),
1185
-        'expiration_date'           => array('name' => 'expiration_date',           'type' => 'xsd:string'),
1186
-        'official_code'             => array('name' => 'official_code',             'type' => 'xsd:string'),
1187
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
1188
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
1189
-        'extra'                     => array('name' => 'extra',                     'type' => 'tns:extrasList'),
1190
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
1176
+        'firstname'                 => array('name' => 'firstname', 'type' => 'xsd:string'),
1177
+        'lastname'                  => array('name' => 'lastname', 'type' => 'xsd:string'),
1178
+        'status'                    => array('name' => 'status', 'type' => 'xsd:string'),
1179
+        'email'                     => array('name' => 'email', 'type' => 'xsd:string'),
1180
+        'loginname'                 => array('name' => 'loginname', 'type' => 'xsd:string'),
1181
+        'password'                  => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
+        'encrypt_method'            => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
1183
+        'language'                  => array('name' => 'language', 'type' => 'xsd:string'),
1184
+        'phone'                     => array('name' => 'phone', 'type' => 'xsd:string'),
1185
+        'expiration_date'           => array('name' => 'expiration_date', 'type' => 'xsd:string'),
1186
+        'official_code'             => array('name' => 'official_code', 'type' => 'xsd:string'),
1187
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
1188
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
1189
+        'extra'                     => array('name' => 'extra', 'type' => 'tns:extrasList'),
1190
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
1191 1191
     )
1192 1192
 );
1193 1193
 
1194 1194
 // Register the method to expose
1195
-$server->register('WSCreateUserPasswordCrypted',                            // method name
1196
-    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'),  // input parameters
1197
-    array('return' => 'xsd:string'),                                        // output parameters
1198
-    'urn:WSRegistration',                                                   // namespace
1199
-    'urn:WSRegistration#WSCreateUserPasswordCrypted',                       // soapaction
1200
-    'rpc',                                                                  // style
1201
-    'encoded',                                                              // use
1195
+$server->register('WSCreateUserPasswordCrypted', // method name
1196
+    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters
1197
+    array('return' => 'xsd:string'), // output parameters
1198
+    'urn:WSRegistration', // namespace
1199
+    'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction
1200
+    'rpc', // style
1201
+    'encoded', // use
1202 1202
     'This service adds users'                                               // documentation
1203 1203
 );
1204 1204
 
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
     global $_user, $_configuration, $debug;
1209 1209
     $debug = 1;
1210 1210
     if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1211
+    if ($debug) error_log(print_r($params, 1));
1212 1212
 
1213 1213
     if (!WSHelperVerifyKey($params)) {
1214 1214
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     $extra_list = isset($params['extra']) ? $params['extra'] : '';
1242 1242
 
1243 1243
     if (!empty($_configuration['password_encryption'])) {
1244
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
1244
+        if ($_configuration['password_encryption'] === $encrypt_method) {
1245 1245
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1246
                 $msg = "Encryption $encrypt_method is invalid";
1247 1247
                 if ($debug) error_log($msg);
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
             if (!is_null($auth_source)) {
1304 1304
                 $sql .= " auth_source='".Database::escape_string($auth_source)."',";
1305 1305
             }
1306
-            $sql .=    "
1306
+            $sql .= "
1307 1307
                     password='".Database::escape_string($password)."',
1308 1308
                     email='".Database::escape_string($email)."',
1309 1309
                     status='".Database::escape_string($status)."',
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
                     expiration_date='".Database::escape_string($expiration_date)."',
1313 1313
                     active='1',
1314 1314
                     hr_dept_id=".intval($hr_dept_id);
1315
-            $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1315
+            $sql .= " WHERE user_id='".$r_check_user[0]."'";
1316 1316
             if ($debug) error_log($sql);
1317 1317
             Database::query($sql);
1318 1318
 
@@ -1492,13 +1492,13 @@  discard block
 block discarded – undo
1492 1492
 );
1493 1493
 
1494 1494
 // Register the method to expose
1495
-$server->register('WSEditUserCredentials',                      // method name
1496
-    array('editUserCredentials' => 'tns:editUserCredentials'),  // input parameters
1497
-    array('return' => 'xsd:string'),                            // output parameters
1498
-    'urn:WSRegistration',                                       // namespace
1499
-    'urn:WSRegistration#WSEditUserCredentials',                 // soapaction
1500
-    'rpc',                                                      // style
1501
-    'encoded',                                                  // use
1495
+$server->register('WSEditUserCredentials', // method name
1496
+    array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters
1497
+    array('return' => 'xsd:string'), // output parameters
1498
+    'urn:WSRegistration', // namespace
1499
+    'urn:WSRegistration#WSEditUserCredentials', // soapaction
1500
+    'rpc', // style
1501
+    'encoded', // use
1502 1502
     'This service edits the username and password of a user'    // documentation
1503 1503
 );
1504 1504
 
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
 );
1598 1598
 
1599 1599
 // Register the method to expose
1600
-$server->register('WSEditUsers',                // method name
1601
-    array('editUsers' => 'tns:editUsers'),      // input parameters
1600
+$server->register('WSEditUsers', // method name
1601
+    array('editUsers' => 'tns:editUsers'), // input parameters
1602 1602
     array('return' => 'tns:results_editUsers'), // output parameters
1603
-    'urn:WSRegistration',                       // namespace
1604
-    'urn:WSRegistration#WSEditUsers',           // soapaction
1605
-    'rpc',                                      // style
1606
-    'encoded',                                  // use
1603
+    'urn:WSRegistration', // namespace
1604
+    'urn:WSRegistration#WSEditUsers', // soapaction
1605
+    'rpc', // style
1606
+    'encoded', // use
1607 1607
     'This service edits a user from wiener'     // documentation
1608 1608
 );
1609 1609
 
@@ -1795,13 +1795,13 @@  discard block
 block discarded – undo
1795 1795
 );
1796 1796
 
1797 1797
 // Register the method to expose
1798
-$server->register('WSEditUser',              // method name
1799
-    array('editUser' => 'tns:editUser'),     // input parameters
1800
-    array('return' => 'xsd:string'),         // output parameters
1801
-    'urn:WSRegistration',                    // namespace
1802
-    'urn:WSRegistration#WSEditUser',         // soapaction
1803
-    'rpc',                                   // style
1804
-    'encoded',                               // use
1798
+$server->register('WSEditUser', // method name
1799
+    array('editUser' => 'tns:editUser'), // input parameters
1800
+    array('return' => 'xsd:string'), // output parameters
1801
+    'urn:WSRegistration', // namespace
1802
+    'urn:WSRegistration#WSEditUser', // soapaction
1803
+    'rpc', // style
1804
+    'encoded', // use
1805 1805
     'This service edits a user from wiener'  // documentation
1806 1806
 );
1807 1807
 
@@ -1972,13 +1972,13 @@  discard block
 block discarded – undo
1972 1972
 );
1973 1973
 
1974 1974
 // Register the method to expose
1975
-$server->register('WSEditUserWithPicture',              // method name
1976
-    array('editUserWithPicture' => 'tns:editUserWithPicture'),     // input parameters
1977
-    array('return' => 'xsd:string'),                    // output parameters
1978
-    'urn:WSRegistration',                               // namespace
1979
-    'urn:WSRegistration#WSEditUserWithPicture',         // soapaction
1980
-    'rpc',                                              // style
1981
-    'encoded',                                          // use
1975
+$server->register('WSEditUserWithPicture', // method name
1976
+    array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters
1977
+    array('return' => 'xsd:string'), // output parameters
1978
+    'urn:WSRegistration', // namespace
1979
+    'urn:WSRegistration#WSEditUserWithPicture', // soapaction
1980
+    'rpc', // style
1981
+    'encoded', // use
1982 1982
     'This service edits a user from wiener'             // documentation
1983 1983
 );
1984 1984
 
@@ -2036,8 +2036,8 @@  discard block
 block discarded – undo
2036 2036
     $tempDir = api_get_path(SYS_ARCHIVE_PATH);
2037 2037
     // Make sure the file download was OK by checking the HTTP headers for OK
2038 2038
     if (strpos(get_headers($picture_url)[0], "OK")) {
2039
-        file_put_contents($tempDir . $filename, file_get_contents($picture_url));
2040
-        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir . $filename);
2039
+        file_put_contents($tempDir.$filename, file_get_contents($picture_url));
2040
+        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir.$filename);
2041 2041
     }
2042 2042
 
2043 2043
     if ($user_id == 0) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
         ->setExpirationDate($expiration_date)
2109 2109
         ->setHrDeptId($hr_dept_id)
2110 2110
         ->setActive(true)
2111
-        ->setPictureUri($pictureUri);;
2111
+        ->setPictureUri($pictureUri); ;
2112 2112
 
2113 2113
     if (!is_null($creator_id)) {
2114 2114
         $user->setCreatorId($creator_id);
@@ -2205,13 +2205,13 @@  discard block
 block discarded – undo
2205 2205
 );
2206 2206
 
2207 2207
 // Register the method to expose
2208
-$server->register('WSEditUsersPasswordCrypted',                           // method name
2209
-    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'),  // input parameters
2210
-    array('return' => 'tns:results_editUsersPasswordCrypted'),            // output parameters
2211
-    'urn:WSRegistration',                                                 // namespace
2212
-    'urn:WSRegistration#WSEditUsersPasswordCrypted',                      // soapaction
2213
-    'rpc',                                                                // style
2214
-    'encoded',                                                            // use
2208
+$server->register('WSEditUsersPasswordCrypted', // method name
2209
+    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters
2210
+    array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters
2211
+    'urn:WSRegistration', // namespace
2212
+    'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction
2213
+    'rpc', // style
2214
+    'encoded', // use
2215 2215
     'This service edits a user'                                           // documentation
2216 2216
 );
2217 2217
 
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
 function WSEditUsersPasswordCrypted($params) {
2220 2220
     global $_configuration;
2221 2221
 
2222
-    if(!WSHelperVerifyKey($params)) {
2222
+    if (!WSHelperVerifyKey($params)) {
2223 2223
         return returnError(WS_ERROR_SECRET_KEY);
2224 2224
     }
2225 2225
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
 
2257 2257
             $password = $user_param['password'];
2258 2258
             $encrypt_method = $user_param['encrypt_method'];
2259
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
2259
+            if ($_configuration['password_encryption'] === $encrypt_method) {
2260 2260
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2261 2261
                     $msg = "Encryption $encrypt_method is invalid";
2262 2262
                     $results[] = $msg;
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
                 $results[] = $msg;
2272 2272
                 continue;
2273 2273
             }
2274
-        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])){
2274
+        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])) {
2275 2275
             $msg = "If password is not empty the encrypt_method param is required ";
2276 2276
             $results[] = $msg;
2277 2277
             continue;
2278
-        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])){
2278
+        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])) {
2279 2279
             $msg = "If encrypt_method is not empty the password param is required ";
2280 2280
             $results[] = $msg;
2281 2281
             continue;
@@ -2411,13 +2411,13 @@  discard block
 block discarded – undo
2411 2411
 );
2412 2412
 
2413 2413
 // Register the method to expose
2414
-$server->register('WSEditUserPasswordCrypted',                         // method name
2414
+$server->register('WSEditUserPasswordCrypted', // method name
2415 2415
     array('editUserPasswordCrypted' => 'tns:editUserPasswordCrypted'), // input parameters
2416
-    array('return' => 'xsd:string'),                                   // output parameters
2417
-    'urn:WSRegistration',                                              // namespace
2418
-    'urn:WSRegistration#WSEditUserPasswordCrypted',                    // soapaction
2419
-    'rpc',                                                             // style
2420
-    'encoded',                                                         // use
2416
+    array('return' => 'xsd:string'), // output parameters
2417
+    'urn:WSRegistration', // namespace
2418
+    'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction
2419
+    'rpc', // style
2420
+    'encoded', // use
2421 2421
     'This service edits a user'                                        // documentation
2422 2422
 );
2423 2423
 
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
     if (!empty($params['password']) && !empty($params['encrypt_method'])) {
2462 2462
         $password = $params['password'];
2463 2463
         $encrypt_method = $params['encrypt_method'];
2464
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
2464
+        if ($_configuration['password_encryption'] === $encrypt_method) {
2465 2465
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2466 2466
                 $msg = "Encryption $encrypt_method is invalid";
2467 2467
                 return $msg;
@@ -2602,7 +2602,7 @@  discard block
 block discarded – undo
2602 2602
     '',
2603 2603
     'SOAP-ENC:Array',
2604 2604
     array(),
2605
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id'
2605
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_id[]')), 'tns:user_id'
2606 2606
 );
2607 2607
 
2608 2608
 $server->wsdl->addComplexType(
@@ -2618,35 +2618,35 @@  discard block
 block discarded – undo
2618 2618
 );
2619 2619
 
2620 2620
 function WSHelperActionOnUsers($params, $type) {
2621
-    if(!WSHelperVerifyKey($params)) {
2621
+    if (!WSHelperVerifyKey($params)) {
2622 2622
         return returnError(WS_ERROR_SECRET_KEY);
2623 2623
     }
2624 2624
 
2625 2625
     $original_user_ids = $params['ids'];
2626
-    foreach($original_user_ids as $original_user_id) {
2626
+    foreach ($original_user_ids as $original_user_id) {
2627 2627
         $user_id = UserManager::get_user_id_from_original_id(
2628 2628
             $original_user_id['original_user_id_value'],
2629 2629
             $original_user_id['original_user_id_name']
2630 2630
         );
2631
-        if($user_id > 0) {
2632
-            if($type == "delete") {
2631
+        if ($user_id > 0) {
2632
+            if ($type == "delete") {
2633 2633
                 UserManager::delete_user($user_id);
2634
-            } else if($type == "disable") {
2634
+            } else if ($type == "disable") {
2635 2635
                 UserManager::disable($user_id);
2636
-            } else if($type == "enable") {
2636
+            } else if ($type == "enable") {
2637 2637
                 UserManager::enable($user_id);
2638 2638
             }
2639 2639
         }
2640 2640
     }
2641 2641
 }
2642 2642
 
2643
-$server->register('WSDeleteUsers',                         // method name
2644
-    array('user_ids' => 'tns:user_ids'),                   // input parameters
2645
-    array(),                                               // output parameters
2646
-    'urn:WSRegistration',                                  // namespace
2647
-    'urn:WSRegistration#WSDeleteUsers',                    // soapaction
2648
-    'rpc',                                                 // style
2649
-    'encoded',                                             // use
2643
+$server->register('WSDeleteUsers', // method name
2644
+    array('user_ids' => 'tns:user_ids'), // input parameters
2645
+    array(), // output parameters
2646
+    'urn:WSRegistration', // namespace
2647
+    'urn:WSRegistration#WSDeleteUsers', // soapaction
2648
+    'rpc', // style
2649
+    'encoded', // use
2650 2650
     'Deletes users provided as parameters from the system' // documentation
2651 2651
 );
2652 2652
 
@@ -2655,13 +2655,13 @@  discard block
 block discarded – undo
2655 2655
 }
2656 2656
 
2657 2657
 /** WSDisableUsers **/
2658
-$server->register('WSDisableUsers',                         // method name
2659
-    array('user_ids' => 'tns:user_ids'),                    // input parameters
2660
-    array(),                                                // output parameters
2661
-    'urn:WSRegistration',                                   // namespace
2662
-    'urn:WSRegistration#WSDisableUsers',                    // soapaction
2663
-    'rpc',                                                  // style
2664
-    'encoded',                                              // use
2658
+$server->register('WSDisableUsers', // method name
2659
+    array('user_ids' => 'tns:user_ids'), // input parameters
2660
+    array(), // output parameters
2661
+    'urn:WSRegistration', // namespace
2662
+    'urn:WSRegistration#WSDisableUsers', // soapaction
2663
+    'rpc', // style
2664
+    'encoded', // use
2665 2665
     'Disables users provided as parameters from the system' // documentation
2666 2666
 );
2667 2667
 
@@ -2670,13 +2670,13 @@  discard block
 block discarded – undo
2670 2670
 }
2671 2671
 
2672 2672
 /** WSEnableUsers **/
2673
-$server->register('WSEnableUsers',            // method name
2674
-    array('user_ids' => 'tns:user_ids'),      // input parameters
2675
-    array(),                                  // output parameters
2676
-    'urn:WSRegistration',                     // namespace
2677
-    'urn:WSRegistration#WSEnableUsers',       // soapaction
2678
-    'rpc',                                    // style
2679
-    'encoded',                                // use
2673
+$server->register('WSEnableUsers', // method name
2674
+    array('user_ids' => 'tns:user_ids'), // input parameters
2675
+    array(), // output parameters
2676
+    'urn:WSRegistration', // namespace
2677
+    'urn:WSRegistration#WSEnableUsers', // soapaction
2678
+    'rpc', // style
2679
+    'encoded', // use
2680 2680
     'Enables users provided as parameters'    // documentation
2681 2681
 );
2682 2682
 
@@ -2726,7 +2726,7 @@  discard block
 block discarded – undo
2726 2726
     '',
2727 2727
     'SOAP-ENC:Array',
2728 2728
     array(),
2729
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams'
2729
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseParams[]')), 'tns:createCourseParams'
2730 2730
 );
2731 2731
 
2732 2732
 // Register the data structures used by the service
@@ -2767,13 +2767,13 @@  discard block
 block discarded – undo
2767 2767
 );
2768 2768
 
2769 2769
 // Register the method to expose
2770
-$server->register('WSCreateCourse',                // method name
2771
-    array('createCourse' => 'tns:createCourse'),   // input parameters
2770
+$server->register('WSCreateCourse', // method name
2771
+    array('createCourse' => 'tns:createCourse'), // input parameters
2772 2772
     array('return' => 'tns:results_createCourse'), // output parameters
2773
-    'urn:WSRegistration',                          // namespace
2774
-    'urn:WSRegistration#WSCreateCourse',           // soapaction
2775
-    'rpc',                                         // style
2776
-    'encoded',                                     // use
2773
+    'urn:WSRegistration', // namespace
2774
+    'urn:WSRegistration#WSCreateCourse', // soapaction
2775
+    'rpc', // style
2776
+    'encoded', // use
2777 2777
     'This service adds a course'                   // documentation
2778 2778
 );
2779 2779
 
@@ -2829,7 +2829,7 @@  discard block
 block discarded – undo
2829 2829
                             category_code='".Database::escape_string($category_code)."',
2830 2830
                             tutor_name='".Database::escape_string($tutor_name)."',
2831 2831
                             visual_code='".Database::escape_string($wanted_code)."'";
2832
-                if($visibility !== null) {
2832
+                if ($visibility !== null) {
2833 2833
                     $sql .= ", visibility = '$visibility' ";
2834 2834
                 }
2835 2835
                 $sql .= " WHERE id='".$courseInfo['real_id']."'";
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
         $params['title'] = $title;
2880 2880
         $params['wanted_code'] = $wanted_code;
2881 2881
         $params['category_code'] = $category_code;
2882
-        $params['course_category']    = $category_code;
2882
+        $params['course_category'] = $category_code;
2883 2883
         $params['tutor_name'] = $tutor_name;
2884 2884
         $params['course_language'] = $course_language;
2885 2885
         $params['user_id'] = api_get_user_id();
@@ -3010,13 +3010,13 @@  discard block
 block discarded – undo
3010 3010
 
3011 3011
 
3012 3012
 // Register the method to expose
3013
-$server->register('WSCreateCourseByTitle',                     // method name
3013
+$server->register('WSCreateCourseByTitle', // method name
3014 3014
     array('createCourseByTitle' => 'tns:createCourseByTitle'), // input parameters
3015
-    array('return' => 'tns:results_createCourseByTitle'),      // output parameters
3016
-    'urn:WSRegistration',                                      // namespace
3017
-    'urn:WSRegistration#WSCreateCourseByTitle',                // soapaction
3018
-    'rpc',                                                     // style
3019
-    'encoded',                                                 // use
3015
+    array('return' => 'tns:results_createCourseByTitle'), // output parameters
3016
+    'urn:WSRegistration', // namespace
3017
+    'urn:WSRegistration#WSCreateCourseByTitle', // soapaction
3018
+    'rpc', // style
3019
+    'encoded', // use
3020 3020
     'This service adds a course by title'                      // documentation
3021 3021
 );
3022 3022
 
@@ -3247,18 +3247,18 @@  discard block
 block discarded – undo
3247 3247
 );
3248 3248
 
3249 3249
 // Register the method to expose
3250
-$server->register('WSEditCourse',                // method name
3251
-    array('editCourse' => 'tns:editCourse'),     // input parameters
3250
+$server->register('WSEditCourse', // method name
3251
+    array('editCourse' => 'tns:editCourse'), // input parameters
3252 3252
     array('return' => 'tns:results_editCourse'), // output parameters
3253
-    'urn:WSRegistration',                        // namespace
3254
-    'urn:WSRegistration#WSEditCourse',           // soapaction
3255
-    'rpc',                                       // style
3256
-    'encoded',                                   // use
3253
+    'urn:WSRegistration', // namespace
3254
+    'urn:WSRegistration#WSEditCourse', // soapaction
3255
+    'rpc', // style
3256
+    'encoded', // use
3257 3257
     'This service edits a course'                // documentation
3258 3258
 );
3259 3259
 
3260 3260
 // Define the method WSEditCourse
3261
-function WSEditCourse($params){
3261
+function WSEditCourse($params) {
3262 3262
 
3263 3263
     global $_configuration;
3264 3264
     if (!WSHelperVerifyKey($params)) {
@@ -3413,13 +3413,13 @@  discard block
 block discarded – undo
3413 3413
 
3414 3414
 
3415 3415
 // Register the method to expose
3416
-$server->register('WSCourseDescription',                    // method name
3417
-    array('courseDescription' => 'tns:courseDescription'),  // input parameters
3418
-    array('return' => 'tns:fields_course_desc_list'),       // output parameters
3419
-    'urn:WSRegistration',                                   // namespace
3420
-    'urn:WSRegistration#WSCourseDescription',               // soapaction
3421
-    'rpc',                                                  // style
3422
-    'encoded',                                              // use
3416
+$server->register('WSCourseDescription', // method name
3417
+    array('courseDescription' => 'tns:courseDescription'), // input parameters
3418
+    array('return' => 'tns:fields_course_desc_list'), // output parameters
3419
+    'urn:WSRegistration', // namespace
3420
+    'urn:WSRegistration#WSCourseDescription', // soapaction
3421
+    'rpc', // style
3422
+    'encoded', // use
3423 3423
     'This service edits a course description'               // documentation
3424 3424
 );
3425 3425
 
@@ -3472,14 +3472,14 @@  discard block
 block discarded – undo
3472 3472
     }
3473 3473
 
3474 3474
     while ($row = Database::fetch_array($result)) {
3475
-        $ind = (int)$row['id'];
3475
+        $ind = (int) $row['id'];
3476 3476
         $array_course_desc_title[$ind] = $row['title'];
3477 3477
         $array_course_desc_content[$ind] = $row['content'];
3478 3478
     }
3479 3479
 
3480 3480
     $count_results = count($default_titles);
3481 3481
     $output = array();
3482
-    for($i = 1; $i <= $count_results; $i++) {
3482
+    for ($i = 1; $i <= $count_results; $i++) {
3483 3483
         $output[] = array(
3484 3484
             'course_desc_id' => $array_course_desc_id[$i],
3485 3485
             'course_desc_default_title' => $array_course_desc_default_title[$i],
@@ -3559,13 +3559,13 @@  discard block
 block discarded – undo
3559 3559
 
3560 3560
 
3561 3561
 // Register the method to expose
3562
-$server->register('WSEditCourseDescription',                       // method name
3562
+$server->register('WSEditCourseDescription', // method name
3563 3563
     array('editCourseDescription' => 'tns:editCourseDescription'), // input parameters
3564
-    array('return' => 'tns:results_editCourseDescription'),        // output parameters
3565
-    'urn:WSRegistration',                                          // namespace
3566
-    'urn:WSRegistration#WSEditCourseDescription',                  // soapaction
3567
-    'rpc',                                                         // style
3568
-    'encoded',                                                     // use
3564
+    array('return' => 'tns:results_editCourseDescription'), // output parameters
3565
+    'urn:WSRegistration', // namespace
3566
+    'urn:WSRegistration#WSEditCourseDescription', // soapaction
3567
+    'rpc', // style
3568
+    'encoded', // use
3569 3569
     'This service edits a course description'                      // documentation
3570 3570
 );
3571 3571
 
@@ -3609,7 +3609,7 @@  discard block
 block discarded – undo
3609 3609
         $course_desc_title = Database::escape_string($course_desc_title);
3610 3610
         $course_desc_content = Database::escape_string($course_desc_content);
3611 3611
 
3612
-        $course_desc_id = (int)$course_desc_id;
3612
+        $course_desc_id = (int) $course_desc_id;
3613 3613
         if ($course_desc_id > 8 && $course_desc_id < 1) {
3614 3614
             $results[] = 0; // course_desc_id invalid.
3615 3615
             continue;
@@ -3643,7 +3643,7 @@  discard block
 block discarded – undo
3643 3643
 
3644 3644
     $count_results = count($results);
3645 3645
     $output = array();
3646
-    for($i = 0; $i < $count_results; $i++) {
3646
+    for ($i = 0; $i < $count_results; $i++) {
3647 3647
         $output[] = array(
3648 3648
             'original_course_id_value' => $orig_course_id_value[$i],
3649 3649
             'result' => $results[$i],
@@ -3715,13 +3715,13 @@  discard block
 block discarded – undo
3715 3715
     'tns:result_deleteCourse'
3716 3716
 );
3717 3717
 
3718
-$server->register('WSDeleteCourse',                // method name
3719
-    array('deleteCourse' => 'tns:deleteCourse'),   // input parameters
3718
+$server->register('WSDeleteCourse', // method name
3719
+    array('deleteCourse' => 'tns:deleteCourse'), // input parameters
3720 3720
     array('return' => 'tns:results_deleteCourse'), // output parameters
3721
-    'urn:WSRegistration',                          // namespace
3722
-    'urn:WSRegistration#WSDeleteCourse',           // soapaction
3723
-    'rpc',                                         // style
3724
-    'encoded',                                     // use
3721
+    'urn:WSRegistration', // namespace
3722
+    'urn:WSRegistration#WSDeleteCourse', // soapaction
3723
+    'rpc', // style
3724
+    'encoded', // use
3725 3725
     'This service deletes a course '               // documentation
3726 3726
 );
3727 3727
 
@@ -3847,13 +3847,13 @@  discard block
 block discarded – undo
3847 3847
 );
3848 3848
 
3849 3849
 // Register the method to expose
3850
-$server->register('WSCreateSession',                // method name
3851
-    array('createSession' => 'tns:createSession'),  // input parameters
3850
+$server->register('WSCreateSession', // method name
3851
+    array('createSession' => 'tns:createSession'), // input parameters
3852 3852
     array('return' => 'tns:results_createSession'), // output parameters
3853
-    'urn:WSRegistration',                           // namespace
3854
-    'urn:WSRegistration#WSCreateSession',           // soapaction
3855
-    'rpc',                                          // style
3856
-    'encoded',                                      // use
3853
+    'urn:WSRegistration', // namespace
3854
+    'urn:WSRegistration#WSCreateSession', // soapaction
3855
+    'rpc', // style
3856
+    'encoded', // use
3857 3857
     'This service edits a session'                  // documentation
3858 3858
 );
3859 3859
 
@@ -3907,8 +3907,8 @@  discard block
 block discarded – undo
3907 3907
         }
3908 3908
 
3909 3909
         if (empty($nolimit)) {
3910
-            $date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start) . ' 00:00:00';
3911
-            $date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end) . ' 23:59:59';
3910
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00';
3911
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end).' 23:59:59';
3912 3912
         } else {
3913 3913
             $date_start = "";
3914 3914
             $date_end = "";
@@ -3926,7 +3926,7 @@  discard block
 block discarded – undo
3926 3926
             }
3927 3927
             $results[] = 0;
3928 3928
             continue;
3929
-        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,  $day_end, $year_end))) {
3929
+        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
3930 3930
             $results[] = 0;
3931 3931
             if ($debug) {
3932 3932
                 error_log("There's an error with the end date: $month_end - $day_end - $year_end");
@@ -4029,7 +4029,7 @@  discard block
 block discarded – undo
4029 4029
 
4030 4030
     $count_results = count($results);
4031 4031
     $output = array();
4032
-    for($i = 0; $i < $count_results; $i++) {
4032
+    for ($i = 0; $i < $count_results; $i++) {
4033 4033
         $output[] = array(
4034 4034
             'original_session_id_value' => $orig_session_id_value[$i],
4035 4035
             'result' => $results[$i],
@@ -4114,13 +4114,13 @@  discard block
 block discarded – undo
4114 4114
 
4115 4115
 
4116 4116
 // Register the method to expose
4117
-$server->register('WSEditSession',                // method name
4118
-    array('editSession' => 'tns:editSession'),    // input parameters
4117
+$server->register('WSEditSession', // method name
4118
+    array('editSession' => 'tns:editSession'), // input parameters
4119 4119
     array('return' => 'tns:results_editSession'), // output parameters
4120
-    'urn:WSRegistration',                         // namespace
4121
-    'urn:WSRegistration#WSEditSession',           // soapaction
4122
-    'rpc',                                        // style
4123
-    'encoded',                                    // use
4120
+    'urn:WSRegistration', // namespace
4121
+    'urn:WSRegistration#WSEditSession', // soapaction
4122
+    'rpc', // style
4123
+    'encoded', // use
4124 4124
     'This service edits a session'                // documentation
4125 4125
 );
4126 4126
 
@@ -4170,11 +4170,11 @@  discard block
 block discarded – undo
4170 4170
         }
4171 4171
 
4172 4172
         if (empty($nolimit)) {
4173
-            $date_start="$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
4174
-            $date_end="$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
4173
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
4174
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
4175 4175
         } else {
4176
-            $date_start="";
4177
-            $date_end="";
4176
+            $date_start = "";
4177
+            $date_end = "";
4178 4178
         }
4179 4179
         if (empty($name)) {
4180 4180
             $results[] = 0; //SessionNameIsRequired
@@ -4318,13 +4318,13 @@  discard block
 block discarded – undo
4318 4318
     'tns:result_deleteSession'
4319 4319
 );
4320 4320
 
4321
-$server->register('WSDeleteSession',                // method name
4322
-    array('deleteSession' => 'tns:deleteSession'),  // input parameters
4321
+$server->register('WSDeleteSession', // method name
4322
+    array('deleteSession' => 'tns:deleteSession'), // input parameters
4323 4323
     array('return' => 'tns:results_deleteSession'), // output parameters
4324
-    'urn:WSRegistration',                           // namespace
4325
-    'urn:WSRegistration#WSDeleteSession',           // soapaction
4326
-    'rpc',                                          // style
4327
-    'encoded',                                      // use
4324
+    'urn:WSRegistration', // namespace
4325
+    'urn:WSRegistration#WSDeleteSession', // soapaction
4326
+    'rpc', // style
4327
+    'encoded', // use
4328 4328
     'This service deletes a session '               // documentation
4329 4329
 );
4330 4330
 
@@ -4406,10 +4406,10 @@  discard block
 block discarded – undo
4406 4406
     'struct',
4407 4407
     'all',
4408 4408
     '',
4409
-    array (
4409
+    array(
4410 4410
         'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'),
4411
-        'user_id'   => array('name' => 'user_id',   'type' => 'tns:user_id'),
4412
-        'status'    => array('name' => 'status',    'type' => 'xsd:int')
4411
+        'user_id'   => array('name' => 'user_id', 'type' => 'tns:user_id'),
4412
+        'status'    => array('name' => 'status', 'type' => 'xsd:int')
4413 4413
     )
4414 4414
 );
4415 4415
 
@@ -4419,9 +4419,9 @@  discard block
 block discarded – undo
4419 4419
     'struct',
4420 4420
     'all',
4421 4421
     '',
4422
-    array (
4423
-        'userscourses'  => array('name' => 'userscourses',  'type' => 'tns:user_course_status_array'), //removed []
4424
-        'secret_key'    => array('name' => 'secret_key',    'type' => 'xsd:string')
4422
+    array(
4423
+        'userscourses'  => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed []
4424
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4425 4425
     )
4426 4426
 );
4427 4427
 
@@ -4446,9 +4446,9 @@  discard block
 block discarded – undo
4446 4446
     'all',
4447 4447
     '',
4448 4448
     array(
4449
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4450
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4451
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
4449
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4450
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4451
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
4452 4452
     )
4453 4453
 );
4454 4454
 
@@ -4464,13 +4464,13 @@  discard block
 block discarded – undo
4464 4464
 );
4465 4465
 
4466 4466
 // Register the method to expose
4467
-$server->register('WSSubscribeUserToCourse',                            // method name
4468
-    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'),  // input parameters
4467
+$server->register('WSSubscribeUserToCourse', // method name
4468
+    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters
4469 4469
     array('return' => 'tns:subscribeUserToCourse_return_global'),
4470
-    'urn:WSRegistration',                                               // namespace
4471
-    'urn:WSRegistration#WSSubscribeUserToCourse',                       // soapaction
4472
-    'rpc',                                                              // style
4473
-    'encoded',                                                          // use
4470
+    'urn:WSRegistration', // namespace
4471
+    'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction
4472
+    'rpc', // style
4473
+    'encoded', // use
4474 4474
     'This service subscribes a user to a course'                        // documentation
4475 4475
 );
4476 4476
 
@@ -4480,7 +4480,7 @@  discard block
 block discarded – undo
4480 4480
     if (!WSHelperVerifyKey($params)) {
4481 4481
         return returnError(WS_ERROR_SECRET_KEY);
4482 4482
     }
4483
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4483
+    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1));
4484 4484
 
4485 4485
     $results = array();
4486 4486
     $userscourses = $params['userscourses'];
@@ -4548,8 +4548,8 @@  discard block
 block discarded – undo
4548 4548
     'all',
4549 4549
     '',
4550 4550
     array(
4551
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
4552
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
4551
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
4552
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
4553 4553
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
4554 4554
     )
4555 4555
 );
@@ -4562,18 +4562,18 @@  discard block
 block discarded – undo
4562 4562
     'struct',
4563 4563
     'all',
4564 4564
     '',
4565
-    array('message' => array('name' => 'message',    'type' => 'xsd:string'))
4565
+    array('message' => array('name' => 'message', 'type' => 'xsd:string'))
4566 4566
 );
4567 4567
 
4568 4568
 
4569 4569
 // Register the method to expose
4570
-$server->register('WSSubscribeUserToCourseSimple',                                 // method name
4570
+$server->register('WSSubscribeUserToCourseSimple', // method name
4571 4571
     array('subscribeUserToCourseSimple' => 'tns:subscribeUserToCourseSimple_arg'), // input parameters
4572
-    array('return' => 'xsd:string'),                                               // output parameters
4573
-    'urn:WSRegistration',                                                          // namespace
4574
-    'urn:WSRegistration#WSSubscribeUserToCourseSimple',                            // soapaction
4575
-    'rpc',                                                                         // style
4576
-    'encoded',                                                                     // use
4572
+    array('return' => 'xsd:string'), // output parameters
4573
+    'urn:WSRegistration', // namespace
4574
+    'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction
4575
+    'rpc', // style
4576
+    'encoded', // use
4577 4577
     'This service subscribes a user to a course in a simple way'                   // documentation
4578 4578
 );
4579 4579
 
@@ -4582,7 +4582,7 @@  discard block
 block discarded – undo
4582 4582
     global $debug;
4583 4583
 
4584 4584
     if ($debug) error_log('WSSubscribeUserToCourseSimple');
4585
-    if ($debug) error_log('Params '. print_r($params, 1));
4585
+    if ($debug) error_log('Params '.print_r($params, 1));
4586 4586
     if (!WSHelperVerifyKey($params)) {
4587 4587
         return returnError(WS_ERROR_SECRET_KEY);
4588 4588
     }
@@ -4630,9 +4630,9 @@  discard block
 block discarded – undo
4630 4630
     'all',
4631 4631
     '',
4632 4632
     array(
4633
-        'original_user_id_value'      => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4634
-        'original_user_id_name'       => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4635
-        'secret_key'                  => array('name' => 'secret_key',                'type' => 'xsd:string')
4633
+        'original_user_id_value'      => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4634
+        'original_user_id_name'       => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4635
+        'secret_key'                  => array('name' => 'secret_key', 'type' => 'xsd:string')
4636 4636
     )
4637 4637
 );
4638 4638
 
@@ -4643,21 +4643,21 @@  discard block
 block discarded – undo
4643 4643
     'struct',
4644 4644
     'all',
4645 4645
     '',
4646
-    array (
4647
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'),
4648
-        'firstname'    => array('name' => 'firstname',  'type' => 'xsd:string'),
4649
-        'lastname'     => array('name' => 'lastname',   'type' => 'xsd:string'),
4646
+    array(
4647
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'),
4648
+        'firstname'    => array('name' => 'firstname', 'type' => 'xsd:string'),
4649
+        'lastname'     => array('name' => 'lastname', 'type' => 'xsd:string'),
4650 4650
     )
4651 4651
 );
4652 4652
 
4653 4653
 // Register the method to expose
4654
-$server->register('WSGetUser',                   // method name
4655
-    array('GetUser' => 'tns:GetUserArg'),        // input parameters
4656
-    array('return' => 'tns:User'),               // output parameters
4657
-    'urn:WSRegistration',                        // namespace
4658
-    'urn:WSRegistration#WSGetUser',              // soapaction
4659
-    'rpc',                                       // style
4660
-    'encoded',                                   // use
4654
+$server->register('WSGetUser', // method name
4655
+    array('GetUser' => 'tns:GetUserArg'), // input parameters
4656
+    array('return' => 'tns:User'), // output parameters
4657
+    'urn:WSRegistration', // namespace
4658
+    'urn:WSRegistration#WSGetUser', // soapaction
4659
+    'rpc', // style
4660
+    'encoded', // use
4661 4661
     'This service get user information by id'    // documentation
4662 4662
 );
4663 4663
 
@@ -4701,17 +4701,17 @@  discard block
 block discarded – undo
4701 4701
     '',
4702 4702
     array(
4703 4703
         'username'      => array('name' => 'username', 'type' => 'xsd:string'),
4704
-        'secret_key'    => array('name' => 'secret_key','type' => 'xsd:string')
4704
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4705 4705
     )
4706 4706
 );
4707 4707
 // Register the method to expose
4708
-$server->register('WSGetUserFromUsername',                     // method name
4709
-    array('GetUserFromUsername' => 'tns:GetUserArgUsername'),  // input params
4710
-    array('return' => 'tns:User'),                             // output parameters
4711
-    'urn:WSRegistration',                                      // namespace
4712
-    'urn:WSRegistration#WSGetUserFromUsername',                // soapaction
4713
-    'rpc',                                                     // style
4714
-    'encoded',                                                 // use
4708
+$server->register('WSGetUserFromUsername', // method name
4709
+    array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params
4710
+    array('return' => 'tns:User'), // output parameters
4711
+    'urn:WSRegistration', // namespace
4712
+    'urn:WSRegistration#WSGetUserFromUsername', // soapaction
4713
+    'rpc', // style
4714
+    'encoded', // use
4715 4715
     'This service get user information by username'            // documentation
4716 4716
 );
4717 4717
 
@@ -4752,10 +4752,10 @@  discard block
 block discarded – undo
4752 4752
     'all',
4753 4753
     '',
4754 4754
     array(
4755
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
4756
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4757
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4758
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
4755
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
4756
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4757
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4758
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
4759 4759
     )
4760 4760
 );
4761 4761
 
@@ -4808,13 +4808,13 @@  discard block
 block discarded – undo
4808 4808
 );
4809 4809
 
4810 4810
 // Register the method to expose
4811
-$server->register('WSUnsubscribeUserFromCourse',                         // method name
4811
+$server->register('WSUnsubscribeUserFromCourse', // method name
4812 4812
     array('unsuscribeUserFromCourse' => 'tns:unsuscribeUserFromCourse'), // input parameters
4813
-    array('return' => 'tns:results_unsuscribeUserFromCourse'),           // output parameters
4814
-    'urn:WSRegistration',                                                // namespace
4815
-    'urn:WSRegistration#WSUnsubscribeUserFromCourse',                    // soapaction
4816
-    'rpc',                                                               // style
4817
-    'encoded',                                                           // use
4813
+    array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters
4814
+    'urn:WSRegistration', // namespace
4815
+    'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction
4816
+    'rpc', // style
4817
+    'encoded', // use
4818 4818
     'This service unsubscribes a user from a course'                     // documentation
4819 4819
 );
4820 4820
 
@@ -4826,7 +4826,7 @@  discard block
 block discarded – undo
4826 4826
     }
4827 4827
 
4828 4828
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
4829
-    $table_course     = Database :: get_main_table(TABLE_MAIN_COURSE);
4829
+    $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
4830 4830
     $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
4831 4831
 
4832 4832
     $userscourses_params = $params['userscourses'];
@@ -4836,8 +4836,8 @@  discard block
 block discarded – undo
4836 4836
     foreach ($userscourses_params as $usercourse_param) {
4837 4837
 
4838 4838
         $original_user_id_values     = $usercourse_param['original_user_id_values'];
4839
-        $original_user_id_name         = $usercourse_param['original_user_id_name'];
4840
-        $original_course_id_value     = $usercourse_param['original_course_id_value'];
4839
+        $original_user_id_name = $usercourse_param['original_user_id_name'];
4840
+        $original_course_id_value = $usercourse_param['original_course_id_value'];
4841 4841
         $original_course_id_name     = $usercourse_param['original_course_id_name'];
4842 4842
         $orig_course_id_value[] = $original_course_id_value;
4843 4843
 
@@ -4858,7 +4858,7 @@  discard block
 block discarded – undo
4858 4858
             $usersList[] = $user_id;
4859 4859
         }
4860 4860
 
4861
-        $orig_user_id_value[] = implode(',',$usersList);
4861
+        $orig_user_id_value[] = implode(',', $usersList);
4862 4862
 
4863 4863
         $courseInfo = CourseManager::getCourseInfoFromOriginalId(
4864 4864
             $original_course_id_value,
@@ -4891,7 +4891,7 @@  discard block
 block discarded – undo
4891 4891
 
4892 4892
     $count_results = count($results);
4893 4893
     $output = array();
4894
-    for($i = 0; $i < $count_results; $i++) {
4894
+    for ($i = 0; $i < $count_results; $i++) {
4895 4895
         $output[] = array(
4896 4896
             'original_user_id_values' => $orig_user_id_value[$i],
4897 4897
             'original_course_id_value' => $orig_course_id_value[$i],
@@ -4920,13 +4920,13 @@  discard block
 block discarded – undo
4920 4920
 
4921 4921
 
4922 4922
 // Register the method to expose
4923
-$server->register('WSUnSubscribeUserFromCourseSimple',                         // method name
4923
+$server->register('WSUnSubscribeUserFromCourseSimple', // method name
4924 4924
     array('unSubscribeUserFromCourseSimple' => 'tns:unSubscribeUserFromCourseSimple'), // input parameters
4925
-    array('return' => 'tns:result_createUsersPassEncrypt'),           // output parameters
4926
-    'urn:WSRegistration',                                                // namespace
4927
-    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple',                    // soapaction
4928
-    'rpc',                                                               // style
4929
-    'encoded',                                                           // use
4925
+    array('return' => 'tns:result_createUsersPassEncrypt'), // output parameters
4926
+    'urn:WSRegistration', // namespace
4927
+    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction
4928
+    'rpc', // style
4929
+    'encoded', // use
4930 4930
     'This service unsubscribe a user from a course'                     // documentation
4931 4931
 );
4932 4932
 /**
@@ -4996,10 +4996,10 @@  discard block
 block discarded – undo
4996 4996
     'all',
4997 4997
     '',
4998 4998
     array(
4999
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
5000
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5001
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
5002
-        'original_course_id_name'   => array('name' => 'original_course_id_value',  'type' => 'xsd:string')
4999
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
5000
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5001
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
5002
+        'original_course_id_name'   => array('name' => 'original_course_id_value', 'type' => 'xsd:string')
5003 5003
     )
5004 5004
 );
5005 5005
 
@@ -5093,13 +5093,13 @@  discard block
 block discarded – undo
5093 5093
 
5094 5094
 
5095 5095
 // Register the method to expose
5096
-$server->register('WSSuscribeUsersToSession',                          // method name
5096
+$server->register('WSSuscribeUsersToSession', // method name
5097 5097
     array('subscribeUsersToSession' => 'tns:subscribeUsersToSession'), // input parameters
5098
-    array('return' => 'tns:results_subscribeUsersToSession'),          // output parameters
5099
-    'urn:WSRegistration',                                              // namespace
5100
-    'urn:WSRegistration#WSSuscribeUsersToSession',                     // soapaction
5101
-    'rpc',                                                             // style
5102
-    'encoded',                                                         // use
5098
+    array('return' => 'tns:results_subscribeUsersToSession'), // output parameters
5099
+    'urn:WSRegistration', // namespace
5100
+    'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction
5101
+    'rpc', // style
5102
+    'encoded', // use
5103 5103
     'This service subscribes a user to a session'                      // documentation
5104 5104
 );
5105 5105
 
@@ -5176,7 +5176,7 @@  discard block
 block discarded – undo
5176 5176
 
5177 5177
     $count_results = count($results);
5178 5178
     $output = array();
5179
-    for($i = 0; $i < $count_results; $i++) {
5179
+    for ($i = 0; $i < $count_results; $i++) {
5180 5180
         $output[] = array(
5181 5181
             'original_user_id_values' => $orig_user_id_value[$i],
5182 5182
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5196,25 +5196,25 @@  discard block
 block discarded – undo
5196 5196
     'all',
5197 5197
     '',
5198 5198
     array(
5199
-        'session'    => array('name' => 'session',    'type' => 'xsd:string'), // Session ID
5200
-        'user_id'    => array('name' => 'user_id',    'type' => 'xsd:string'), // Chamilo user_id
5199
+        'session'    => array('name' => 'session', 'type' => 'xsd:string'), // Session ID
5200
+        'user_id'    => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id
5201 5201
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string')
5202 5202
     )
5203 5203
 );
5204
-$server->register('WSSubscribeUserToSessionSimple',                                   // method name
5205
-    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'),  // input parameters
5206
-    array('return' => 'xsd:string'),                                                  // output parameters
5207
-    'urn:WSRegistration',                                                             // namespace
5208
-    'urn:WSRegistration#WSSubscribeUserToSessionSimple',                              // soapaction
5209
-    'rpc',                                                                            // style
5210
-    'encoded',                                                                        // use
5204
+$server->register('WSSubscribeUserToSessionSimple', // method name
5205
+    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters
5206
+    array('return' => 'xsd:string'), // output parameters
5207
+    'urn:WSRegistration', // namespace
5208
+    'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction
5209
+    'rpc', // style
5210
+    'encoded', // use
5211 5211
     'This service subscribes a user to a session in a simple way'                     // documentation
5212 5212
 );
5213 5213
 function WSSubscribeUserToSessionSimple($params) {
5214 5214
     global $debug;
5215 5215
 
5216 5216
     if ($debug) {
5217
-        error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']');
5217
+        error_log('WSSubscribeUserToSessionSimple with params=['.serialize($params).']');
5218 5218
     }
5219 5219
 
5220 5220
     // Check security key
@@ -5223,8 +5223,8 @@  discard block
 block discarded – undo
5223 5223
     }
5224 5224
 
5225 5225
     // Get input parameters
5226
-    $session_id = intval($params['session']);  // Session ID
5227
-    $user_id    = intval($params['user_id']);  // Chamilo user id
5226
+    $session_id = intval($params['session']); // Session ID
5227
+    $user_id    = intval($params['user_id']); // Chamilo user id
5228 5228
 
5229 5229
     // Get user id
5230 5230
     $user_data = api_get_user_info($user_id);
@@ -5325,13 +5325,13 @@  discard block
 block discarded – undo
5325 5325
 );
5326 5326
 
5327 5327
 // Register the method to expose
5328
-$server->register('WSUnsuscribeUsersFromSession',                              // method name
5328
+$server->register('WSUnsuscribeUsersFromSession', // method name
5329 5329
     array('unsubscribeUsersFromSession' => 'tns:unsubscribeUsersFromSession'), // input parameters
5330
-    array('return' => 'tns:results_unsubscribeUsersFromSession'),              // output parameters
5331
-    'urn:WSRegistration',                                                      // namespace
5332
-    'urn:WSRegistration#WSUnsuscribeUsersFromSession',                         // soapaction
5333
-    'rpc',                                                                     // style
5334
-    'encoded',                                                                 // use
5330
+    array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters
5331
+    'urn:WSRegistration', // namespace
5332
+    'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction
5333
+    'rpc', // style
5334
+    'encoded', // use
5335 5335
     'This service unsubscribes a user to a session'                            // documentation
5336 5336
 );
5337 5337
 
@@ -5345,7 +5345,7 @@  discard block
 block discarded – undo
5345 5345
     global $debug;
5346 5346
 
5347 5347
     if ($debug) {
5348
-        error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params). ']');
5348
+        error_log('WSUnsuscribeUsersFromSession with params=['.serialize($params).']');
5349 5349
     }
5350 5350
 
5351 5351
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -5437,7 +5437,7 @@  discard block
 block discarded – undo
5437 5437
     'all',
5438 5438
     '',
5439 5439
     array(
5440
-        'course_code'   => array('name' => 'course_code',   'type' => 'xsd:string'),
5440
+        'course_code'   => array('name' => 'course_code', 'type' => 'xsd:string'),
5441 5441
     )
5442 5442
 );
5443 5443
 
@@ -5473,9 +5473,9 @@  discard block
 block discarded – undo
5473 5473
     '',
5474 5474
     array(
5475 5475
         'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'tns:originalCoursesList'),
5476
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
5476
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
5477 5477
         'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'),
5478
-        'original_session_id_name'  => array('name' => 'original_session_id_name',  'type' => 'xsd:string')
5478
+        'original_session_id_name'  => array('name' => 'original_session_id_name', 'type' => 'xsd:string')
5479 5479
     )
5480 5480
 );
5481 5481
 
@@ -5528,13 +5528,13 @@  discard block
 block discarded – undo
5528 5528
 );
5529 5529
 
5530 5530
 // Register the method to expose
5531
-$server->register('WSSuscribeCoursesToSession',                            // method name
5531
+$server->register('WSSuscribeCoursesToSession', // method name
5532 5532
     array('subscribeCoursesToSession' => 'tns:subscribeCoursesToSession'), // input parameters
5533
-    array('return' => 'tns:results_subscribeCoursesToSession'),            // output parameters
5534
-    'urn:WSRegistration',                                                  // namespace
5535
-    'urn:WSRegistration#WSSuscribeCoursesToSession',                       // soapaction
5536
-    'rpc',                                                                 // style
5537
-    'encoded',                                                             // use
5533
+    array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters
5534
+    'urn:WSRegistration', // namespace
5535
+    'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction
5536
+    'rpc', // style
5537
+    'encoded', // use
5538 5538
     'This service subscribes a course to a session'                        // documentation
5539 5539
 );
5540 5540
 
@@ -5672,13 +5672,13 @@  discard block
 block discarded – undo
5672 5672
 
5673 5673
 
5674 5674
 // Register the method to expose
5675
-$server->register('WSUnsuscribeCoursesFromSession',                                // method name
5675
+$server->register('WSUnsuscribeCoursesFromSession', // method name
5676 5676
     array('unsubscribeCoursesFromSession' => 'tns:unsubscribeCoursesFromSession'), // input parameters
5677
-    array('return' => 'tns:results_unsubscribeCoursesFromSession'),                // output parameters
5678
-    'urn:WSRegistration',                                                          // namespace
5679
-    'urn:WSRegistration#WSUnsuscribeCoursesFromSession',                           // soapaction
5680
-    'rpc',                                                                         // style
5681
-    'encoded',                                                                     // use
5677
+    array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters
5678
+    'urn:WSRegistration', // namespace
5679
+    'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction
5680
+    'rpc', // style
5681
+    'encoded', // use
5682 5682
     'This service subscribes a course to a session'                                // documentation
5683 5683
 );
5684 5684
 
@@ -5785,7 +5785,7 @@  discard block
 block discarded – undo
5785 5785
 
5786 5786
     $count_results = count($results);
5787 5787
     $output = array();
5788
-    for($i = 0; $i < $count_results; $i++) {
5788
+    for ($i = 0; $i < $count_results; $i++) {
5789 5789
         $output[] = array(
5790 5790
             'original_course_id_values' => $orig_course_id_value[$i],
5791 5791
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5829,13 +5829,13 @@  discard block
 block discarded – undo
5829 5829
 
5830 5830
 
5831 5831
 // Register the method to expose
5832
-$server->register('WSListCourses',                                                  // method name
5832
+$server->register('WSListCourses', // method name
5833 5833
     array('secret_key' => 'xsd:string', 'original_course_id_name' => 'xsd:string'), // input parameters
5834
-    array('return' => 'tns:courses'),                                               // output parameters
5835
-    'urn:WSRegistration',                                                           // namespace
5836
-    'urn:WSRegistration#WSListCourses',                                             // soapaction
5837
-    'rpc',                                                                          // style
5838
-    'encoded',                                                                      // use
5834
+    array('return' => 'tns:courses'), // output parameters
5835
+    'urn:WSRegistration', // namespace
5836
+    'urn:WSRegistration#WSListCourses', // soapaction
5837
+    'rpc', // style
5838
+    'encoded', // use
5839 5839
     'This service list courses available on the system'                             // documentation
5840 5840
 );
5841 5841
 
@@ -5902,27 +5902,27 @@  discard block
 block discarded – undo
5902 5902
     'all',
5903 5903
     '',
5904 5904
     array(
5905
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5906
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
5907
-        'chamilo_username'          => array('name' => 'chamilo_username',          'type' => 'xsd:string'),
5908
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
5905
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5906
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
5907
+        'chamilo_username'          => array('name' => 'chamilo_username', 'type' => 'xsd:string'),
5908
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
5909 5909
     )
5910 5910
 );
5911 5911
 
5912 5912
 // Register the method to expose
5913
-$server->register('WSUpdateUserApiKey',      // method name
5913
+$server->register('WSUpdateUserApiKey', // method name
5914 5914
     array('userApiKey' => 'tns:userApiKey'), // input parameters
5915
-    array('return' => 'xsd:string'),         // output parameters
5916
-    'urn:WSRegistration',                    // namespace
5917
-    'urn:WSRegistration#WSListCourses',      // soapaction
5918
-    'rpc',                                   // style
5919
-    'encoded',                               // use
5915
+    array('return' => 'xsd:string'), // output parameters
5916
+    'urn:WSRegistration', // namespace
5917
+    'urn:WSRegistration#WSListCourses', // soapaction
5918
+    'rpc', // style
5919
+    'encoded', // use
5920 5920
     'This service return user api key'       // documentation
5921 5921
 );
5922 5922
 
5923 5923
 
5924 5924
 function WSUpdateUserApiKey($params) {
5925
-    if(!WSHelperVerifyKey($params)) {
5925
+    if (!WSHelperVerifyKey($params)) {
5926 5926
         return returnError(WS_ERROR_SECRET_KEY);
5927 5927
     }
5928 5928
 
@@ -5964,9 +5964,9 @@  discard block
 block discarded – undo
5964 5964
     'all',
5965 5965
     '',
5966 5966
     array(
5967
-        'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
5968
-        'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
5969
-        'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
5967
+        'date_start'  => array('name' => 'date_start', 'type' => 'xsd:string'),
5968
+        'date_end'    => array('name' => 'date_end', 'type' => 'xsd:string'),
5969
+        'secret_key'  => array('name' => 'secret_key', 'type' => 'xsd:string')
5970 5970
     )
5971 5971
 );
5972 5972
 
@@ -5977,11 +5977,11 @@  discard block
 block discarded – undo
5977 5977
     'all',
5978 5978
     '',
5979 5979
     array(
5980
-        'id' => array ('name' => 'id'  , 'type' => 'xsd:int'),
5981
-        'title' => array ('name' => 'title', 'type' => 'xsd:string'),
5982
-        'url' => array ('name' => 'url', 'type' => 'xsd:string'),
5983
-        'date_start' => array ('name' => 'date_start', 'type' => 'xsd:string'),
5984
-        'date_end' => array ('name' => 'date_end', 'type' => 'xsd:string'),
5980
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
5981
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
5982
+        'url' => array('name' => 'url', 'type' => 'xsd:string'),
5983
+        'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'),
5984
+        'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'),
5985 5985
     )
5986 5986
 );
5987 5987
 
@@ -6000,13 +6000,13 @@  discard block
 block discarded – undo
6000 6000
 );
6001 6001
 
6002 6002
 // Register the method to expose
6003
-$server->register('WSListSessions',           // method name
6004
-    array('input'  => 'tns:session_arg'),     // input parameters
6005
-    array('return' => 'tns:sessions'),        // output parameters
6006
-    'urn:WSRegistration',                     // namespace
6007
-    'urn:WSRegistration#WSListSessions',      // soapaction
6008
-    'rpc',                                    // style
6009
-    'encoded',                                // use
6003
+$server->register('WSListSessions', // method name
6004
+    array('input'  => 'tns:session_arg'), // input parameters
6005
+    array('return' => 'tns:sessions'), // output parameters
6006
+    'urn:WSRegistration', // namespace
6007
+    'urn:WSRegistration#WSListSessions', // soapaction
6008
+    'rpc', // style
6009
+    'encoded', // use
6010 6010
     'This service returns a list of sessions' // documentation
6011 6011
 );
6012 6012
 
@@ -6021,7 +6021,7 @@  discard block
 block discarded – undo
6021 6021
  * @return array Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>''])
6022 6022
  */
6023 6023
 function WSListSessions($params) {
6024
-    if(!WSHelperVerifyKey($params)) {
6024
+    if (!WSHelperVerifyKey($params)) {
6025 6025
         return returnError(WS_ERROR_SECRET_KEY);
6026 6026
     }
6027 6027
     $sql_params = array();
@@ -6060,20 +6060,20 @@  discard block
 block discarded – undo
6060 6060
     'all',
6061 6061
     '',
6062 6062
     array(
6063
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
6064
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
6063
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
6064
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
6065 6065
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
6066 6066
     )
6067 6067
 );
6068 6068
 
6069 6069
 // Register the method to expose
6070
-$server->register('WSUserSubscribedInCourse',                            // method name
6071
-    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'),    // input parameters
6072
-    array('return' => 'xsd:string'),                                        // output parameters
6073
-    'urn:WSRegistration',                                                    // namespace
6074
-    'urn:WSRegistration#WSUserSubscribedInCourse',                       // soapaction
6075
-    'rpc',                                                                    // style
6076
-    'encoded',                                                                // use
6070
+$server->register('WSUserSubscribedInCourse', // method name
6071
+    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters
6072
+    array('return' => 'xsd:string'), // output parameters
6073
+    'urn:WSRegistration', // namespace
6074
+    'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction
6075
+    'rpc', // style
6076
+    'encoded', // use
6077 6077
     'This service checks if user assigned to course'    // documentation
6078 6078
 );
6079 6079
 
@@ -6087,7 +6087,7 @@  discard block
 block discarded – undo
6087 6087
     global $debug;
6088 6088
 
6089 6089
     if ($debug) error_log('WSUserSubscribedInCourse');
6090
-    if ($debug) error_log('Params '. print_r($params, 1));
6090
+    if ($debug) error_log('Params '.print_r($params, 1));
6091 6091
     if (!WSHelperVerifyKey($params)) {
6092 6092
 
6093 6093
         return returnError(WS_ERROR_SECRET_KEY);
@@ -6095,7 +6095,7 @@  discard block
 block discarded – undo
6095 6095
     $courseCode  = $params['course']; //Course code
6096 6096
     $userId      = $params['user_id']; //chamilo user id
6097 6097
 
6098
-    return (CourseManager::is_user_subscribed_in_course($userId,$courseCode));
6098
+    return (CourseManager::is_user_subscribed_in_course($userId, $courseCode));
6099 6099
 }
6100 6100
 
6101 6101
 
@@ -6123,8 +6123,8 @@  discard block
 block discarded – undo
6123 6123
     'all',
6124 6124
     '',
6125 6125
     array(
6126
-        'variable' => array('name'=>'variable','type'=>'xsd:string'),
6127
-        'value' => array('name'=>'value','type'=>'xsd:string')
6126
+        'variable' => array('name'=>'variable', 'type'=>'xsd:string'),
6127
+        'value' => array('name'=>'value', 'type'=>'xsd:string')
6128 6128
     )
6129 6129
 );
6130 6130
 
@@ -6186,12 +6186,12 @@  discard block
 block discarded – undo
6186 6186
 //Reister WSSearchSession
6187 6187
 $server->register(
6188 6188
     'WSSearchSession',
6189
-    array('SearchSession' => 'tns:SearchSession'),      // input parameters
6190
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6191
-    'urn:WSRegistration',                               // namespace
6192
-    'urn:WSRegistration#WSSearchSession',               // soapaction
6193
-    'rpc',                                              // style
6194
-    'encoded',                                          // use
6189
+    array('SearchSession' => 'tns:SearchSession'), // input parameters
6190
+    array('return' => 'tns:searchedSessionList'), // output parameters
6191
+    'urn:WSRegistration', // namespace
6192
+    'urn:WSRegistration#WSSearchSession', // soapaction
6193
+    'rpc', // style
6194
+    'encoded', // use
6195 6195
     'This service to get a session list filtered by name, description or short description extra field'    // documentation
6196 6196
 );
6197 6197
 
@@ -6246,12 +6246,12 @@  discard block
 block discarded – undo
6246 6246
 //Reister WSFetchSession
6247 6247
 $server->register(
6248 6248
     'WSFetchSession',
6249
-    array('SearchSession' => 'tns:FetchSession'),                    // input parameters
6250
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6251
-    'urn:WSRegistration',                               // namespace
6252
-    'urn:WSRegistration#WSFetchSession',                // soapaction
6253
-    'rpc',                                              // style
6254
-    'encoded',                                          // use
6249
+    array('SearchSession' => 'tns:FetchSession'), // input parameters
6250
+    array('return' => 'tns:searchedSessionList'), // output parameters
6251
+    'urn:WSRegistration', // namespace
6252
+    'urn:WSRegistration#WSFetchSession', // soapaction
6253
+    'rpc', // style
6254
+    'encoded', // use
6255 6255
     'This service get a session by its id. Optionally can get its extra fields values'    // documentation
6256 6256
 );
6257 6257
 
@@ -6328,16 +6328,16 @@  discard block
 block discarded – undo
6328 6328
 );
6329 6329
 // Register the method to expose
6330 6330
 $server->register(
6331
-    'WSCertificatesList',                           // method name
6331
+    'WSCertificatesList', // method name
6332 6332
     array(
6333
-        'startingDate' => 'xsd:string',             // input parameters
6333
+        'startingDate' => 'xsd:string', // input parameters
6334 6334
         'endingDate' => 'xsd:string'
6335 6335
     ),
6336
-    array('return' => 'tns:certificatesList'),      // output parameters
6337
-    'urn:WSRegistration',                           // namespace
6338
-    'urn:WSRegistration#WSCertificatesList',        // soapaction
6339
-    'rpc',                                          // style
6340
-    'encoded',                                      // use
6336
+    array('return' => 'tns:certificatesList'), // output parameters
6337
+    'urn:WSRegistration', // namespace
6338
+    'urn:WSRegistration#WSCertificatesList', // soapaction
6339
+    'rpc', // style
6340
+    'encoded', // use
6341 6341
     'This service returns a list of certificates'   // documentation
6342 6342
 );
6343 6343
 
@@ -6403,13 +6403,13 @@  discard block
 block discarded – undo
6403 6403
 );
6404 6404
 
6405 6405
 // Register the method to expose
6406
-$server->register('WSCreateGroup',              // method name
6407
-    array('createGroup' => 'tns:createGroup'),  // input parameters
6408
-    array('return' => 'xsd:string'),            // output parameters
6409
-    'urn:WSRegistration',                       // namespace
6410
-    'urn:WSRegistration#WSCreateGroup',         // soapaction
6411
-    'rpc',                                      // style
6412
-    'encoded',                                  // use
6406
+$server->register('WSCreateGroup', // method name
6407
+    array('createGroup' => 'tns:createGroup'), // input parameters
6408
+    array('return' => 'xsd:string'), // output parameters
6409
+    'urn:WSRegistration', // namespace
6410
+    'urn:WSRegistration#WSCreateGroup', // soapaction
6411
+    'rpc', // style
6412
+    'encoded', // use
6413 6413
     'This service adds a group'                 // documentation
6414 6414
 );
6415 6415
 
@@ -6452,13 +6452,13 @@  discard block
 block discarded – undo
6452 6452
 );
6453 6453
 
6454 6454
 // Register the method to expose
6455
-$server->register('WSUpdateGroup',              // method name
6456
-    array('updateGroup' => 'tns:updateGroup'),  // input parameters
6457
-    array('return' => 'xsd:string'),            // output parameters
6458
-    'urn:WSRegistration',                       // namespace
6459
-    'urn:WSRegistration#WSUpdateGroup',         // soapaction
6460
-    'rpc',                                      // style
6461
-    'encoded',                                  // use
6455
+$server->register('WSUpdateGroup', // method name
6456
+    array('updateGroup' => 'tns:updateGroup'), // input parameters
6457
+    array('return' => 'xsd:string'), // output parameters
6458
+    'urn:WSRegistration', // namespace
6459
+    'urn:WSRegistration#WSUpdateGroup', // soapaction
6460
+    'rpc', // style
6461
+    'encoded', // use
6462 6462
     'This service updates a group'              // documentation
6463 6463
 );
6464 6464
 
@@ -6503,13 +6503,13 @@  discard block
 block discarded – undo
6503 6503
 );
6504 6504
 
6505 6505
 // Register the method to expose
6506
-$server->register('WSDeleteGroup',              // method name
6507
-    array('deleteGroup' => 'tns:deleteGroup'),  // input parameters
6508
-    array('return' => 'xsd:string'),            // output parameters
6509
-    'urn:WSRegistration',                       // namespace
6510
-    'urn:WSRegistration#WSDeleteGroup',         // soapaction
6511
-    'rpc',                                      // style
6512
-    'encoded',                                  // use
6506
+$server->register('WSDeleteGroup', // method name
6507
+    array('deleteGroup' => 'tns:deleteGroup'), // input parameters
6508
+    array('return' => 'xsd:string'), // output parameters
6509
+    'urn:WSRegistration', // namespace
6510
+    'urn:WSRegistration#WSDeleteGroup', // soapaction
6511
+    'rpc', // style
6512
+    'encoded', // use
6513 6513
     'This service deletes a group'              // documentation
6514 6514
 );
6515 6515
 
@@ -6546,13 +6546,13 @@  discard block
 block discarded – undo
6546 6546
 );
6547 6547
 
6548 6548
 // Register the method to expose
6549
-$server->register('GroupBindToParent',                      // method name
6550
-    array('groupBindToParent' => 'tns:groupBindToParent'),  // input parameters
6551
-    array('return' => 'xsd:string'),                        // output parameters
6552
-    'urn:WSRegistration',                                   // namespace
6553
-    'urn:WSRegistration#GroupBindToParent',                 // soapaction
6554
-    'rpc',                                                  // style
6555
-    'encoded',                                              // use
6549
+$server->register('GroupBindToParent', // method name
6550
+    array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters
6551
+    array('return' => 'xsd:string'), // output parameters
6552
+    'urn:WSRegistration', // namespace
6553
+    'urn:WSRegistration#GroupBindToParent', // soapaction
6554
+    'rpc', // style
6555
+    'encoded', // use
6556 6556
     'This service binds a group to a parent'                // documentation
6557 6557
 );
6558 6558
 
@@ -6588,13 +6588,13 @@  discard block
 block discarded – undo
6588 6588
 );
6589 6589
 
6590 6590
 // Register the method to expose
6591
-$server->register('GroupUnbindFromParent',                          // method name
6592
-    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'),  // input parameters
6593
-    array('return' => 'xsd:string'),                                // output parameters
6594
-    'urn:WSRegistration',                                           // namespace
6595
-    'urn:WSRegistration#GroupUnbindFromParent',                     // soapaction
6596
-    'rpc',                                                          // style
6597
-    'encoded',                                                      // use
6591
+$server->register('GroupUnbindFromParent', // method name
6592
+    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters
6593
+    array('return' => 'xsd:string'), // output parameters
6594
+    'urn:WSRegistration', // namespace
6595
+    'urn:WSRegistration#GroupUnbindFromParent', // soapaction
6596
+    'rpc', // style
6597
+    'encoded', // use
6598 6598
     'This service unbinds a group from its parent'                  // documentation
6599 6599
 );
6600 6600
 
@@ -6628,13 +6628,13 @@  discard block
 block discarded – undo
6628 6628
 );
6629 6629
 
6630 6630
 // Register the method to expose
6631
-$server->register('WSAddUserToGroup',                   // method name
6632
-    array('addUserToGroup' => 'tns:addUserToGroup'),    // input parameters
6633
-    array('return' => 'xsd:string'),                    // output parameters
6634
-    'urn:WSRegistration',                               // namespace
6635
-    'urn:WSRegistration#WSAddUserToGroup',              // soapaction
6636
-    'rpc',                                              // style
6637
-    'encoded',                                          // use
6631
+$server->register('WSAddUserToGroup', // method name
6632
+    array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters
6633
+    array('return' => 'xsd:string'), // output parameters
6634
+    'urn:WSRegistration', // namespace
6635
+    'urn:WSRegistration#WSAddUserToGroup', // soapaction
6636
+    'rpc', // style
6637
+    'encoded', // use
6638 6638
     'This service adds a user to a group'               // documentation
6639 6639
 );
6640 6640
 
@@ -6671,13 +6671,13 @@  discard block
 block discarded – undo
6671 6671
 );
6672 6672
 
6673 6673
 // Register the method to expose
6674
-$server->register('WSUpdateUserRoleInGroup',                        // method name
6675
-    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'),  // input parameters
6676
-    array('return' => 'xsd:string'),                                // output parameters
6677
-    'urn:WSRegistration',                                           // namespace
6678
-    'urn:WSRegistration#WSUpdateUserRoleInGroup',                   // soapaction
6679
-    'rpc',                                                          // style
6680
-    'encoded',                                                      // use
6674
+$server->register('WSUpdateUserRoleInGroup', // method name
6675
+    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters
6676
+    array('return' => 'xsd:string'), // output parameters
6677
+    'urn:WSRegistration', // namespace
6678
+    'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction
6679
+    'rpc', // style
6680
+    'encoded', // use
6681 6681
     'This service updates a user role in group'                     // documentation
6682 6682
 );
6683 6683
 
@@ -6716,13 +6716,13 @@  discard block
 block discarded – undo
6716 6716
 );
6717 6717
 
6718 6718
 // Register the method to expose
6719
-$server->register('WSDeleteUserFromGroup',                      // method name
6720
-    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'),  // input parameters
6721
-    array('return' => 'xsd:string'),                            // output parameters
6722
-    'urn:WSRegistration',                                       // namespace
6723
-    'urn:WSRegistration#WSDeleteUserFromGroup',                 // soapaction
6724
-    'rpc',                                                      // style
6725
-    'encoded',                                                  // use
6719
+$server->register('WSDeleteUserFromGroup', // method name
6720
+    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters
6721
+    array('return' => 'xsd:string'), // output parameters
6722
+    'urn:WSRegistration', // namespace
6723
+    'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction
6724
+    'rpc', // style
6725
+    'encoded', // use
6726 6726
     'This service deletes a user from a group'                  // documentation
6727 6727
 );
6728 6728
 
Please login to merge, or discard this patch.
Braces   +169 added lines, -62 removed lines patch added patch discarded remove patch
@@ -63,19 +63,22 @@  discard block
 block discarded – undo
63 63
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
64 64
         $ip = trim($ip1);
65 65
     }
66
-    if ($debug)
67
-        error_log("ip: $ip");
66
+    if ($debug) {
67
+            error_log("ip: $ip");
68
+    }
68 69
     // Check if a file that limits access from webservices exists and contains
69 70
     // the restraining check
70 71
     if (is_file('webservice-auth-ip.conf.php')) {
71 72
         include 'webservice-auth-ip.conf.php';
72
-        if ($debug)
73
-            error_log("webservice-auth-ip.conf.php file included");
73
+        if ($debug) {
74
+                    error_log("webservice-auth-ip.conf.php file included");
75
+        }
74 76
         if (!empty($ws_auth_ip)) {
75 77
             $check_ip = true;
76 78
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
77
-            if ($debug)
78
-                error_log("ip_matches: $ip_matches");
79
+            if ($debug) {
80
+                            error_log("ip_matches: $ip_matches");
81
+            }
79 82
         }
80 83
     }
81 84
 
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 
93 96
     $result = api_is_valid_secret_key($secret_key, $security_key);
94 97
 
95
-    if ($debug)
96
-        error_log('WSHelperVerifyKey result: '.intval($result));
98
+    if ($debug) {
99
+            error_log('WSHelperVerifyKey result: '.intval($result));
100
+    }
97 101
     return $result;
98 102
 }
99 103
 
@@ -553,7 +557,9 @@  discard block
 block discarded – undo
553 557
 
554 558
     // First check wether the login already exists
555 559
     if (!UserManager::is_username_available($loginName)) {
556
-        if ($debug) error_log("Username $loginName is not available");
560
+        if ($debug) {
561
+            error_log("Username $loginName is not available");
562
+        }
557 563
         return 0;
558 564
     }
559 565
 
@@ -1012,7 +1018,9 @@  discard block
 block discarded – undo
1012 1018
     if (empty($userId) && empty($sessionId) && empty($courseId)) {
1013 1019
         // try original values
1014 1020
 
1015
-        if ($debug) error_log('try original values');
1021
+        if ($debug) {
1022
+            error_log('try original values');
1023
+        }
1016 1024
 
1017 1025
         $userIdName = isset($params['original_user_id_name']) ? $params['original_user_id_name'] : 0;
1018 1026
         $userIdValue = isset($params['original_user_id_value']) ? $params['original_user_id_value'] : 0;
@@ -1044,9 +1052,15 @@  discard block
 block discarded – undo
1044 1052
         );
1045 1053
     }
1046 1054
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1055
+    if ($debug) {
1056
+        error_log('$userId found: '. $userId);
1057
+    }
1058
+    if ($debug) {
1059
+        error_log('$courseId found: '. $courseId);
1060
+    }
1061
+    if ($debug) {
1062
+        error_log('$sessionId found: '. $sessionId);
1063
+    }
1050 1064
 
1051 1065
     return [
1052 1066
         'user_id' => $userId,
@@ -1076,13 +1090,17 @@  discard block
 block discarded – undo
1076 1090
 {
1077 1091
     global $debug;
1078 1092
 
1079
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1093
+    if ($debug) {
1094
+        error_log('WSSubscribeTeacherToSessionCourse');
1095
+    }
1080 1096
 
1081 1097
     if (!WSHelperVerifyKey($params)) {
1082 1098
         return returnError(WS_ERROR_SECRET_KEY);
1083 1099
     }
1084 1100
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1101
+    if ($debug) {
1102
+        error_log('Params '. print_r($params, 1));
1103
+    }
1086 1104
 
1087 1105
     $params = parseCourseSessionUserParams($params);
1088 1106
 
@@ -1095,13 +1113,17 @@  discard block
 block discarded – undo
1095 1113
     $result = 0;
1096 1114
 
1097 1115
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1116
+        if ($debug) {
1117
+            error_log('Coaches:  '. print_r($coaches, 1));
1118
+        }
1099 1119
         if (in_array($userId, $coaches)) {
1100 1120
             $result = 1;
1101 1121
         }
1102 1122
     }
1103 1123
 
1104
-    if ($debug) error_log('Result:  '. $result);
1124
+    if ($debug) {
1125
+        error_log('Result:  '. $result);
1126
+    }
1105 1127
 
1106 1128
     return $result;
1107 1129
 }
@@ -1127,13 +1149,17 @@  discard block
 block discarded – undo
1127 1149
 {
1128 1150
     global $debug;
1129 1151
 
1130
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1152
+    if ($debug) {
1153
+        error_log('WSSubscribeTeacherToSessionCourse');
1154
+    }
1131 1155
 
1132 1156
     if (!WSHelperVerifyKey($params)) {
1133 1157
         return returnError(WS_ERROR_SECRET_KEY);
1134 1158
     }
1135 1159
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1160
+    if ($debug) {
1161
+        error_log('Params '. print_r($params, 1));
1162
+    }
1137 1163
 
1138 1164
     $params = parseCourseSessionUserParams($params);
1139 1165
 
@@ -1147,7 +1173,9 @@  discard block
 block discarded – undo
1147 1173
     $result = 0;
1148 1174
 
1149 1175
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1176
+        if ($debug) {
1177
+            error_log('Coaches:  ' . print_r($coaches, 1));
1178
+        }
1151 1179
         if (!in_array($userId, $coaches)) {
1152 1180
             $result = 1;
1153 1181
         }
@@ -1155,7 +1183,9 @@  discard block
 block discarded – undo
1155 1183
         $result = 1;
1156 1184
     }
1157 1185
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1186
+    if ($debug) {
1187
+        error_log('Final Result: '. $result);
1188
+    }
1159 1189
 
1160 1190
     return $result;
1161 1191
 }
@@ -1207,8 +1237,12 @@  discard block
 block discarded – undo
1207 1237
 {
1208 1238
     global $_user, $_configuration, $debug;
1209 1239
     $debug = 1;
1210
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1240
+    if ($debug) {
1241
+        error_log('WSCreateUserPasswordCrypted');
1242
+    }
1243
+    if ($debug) {
1244
+        error_log(print_r($params,1));
1245
+    }
1212 1246
 
1213 1247
     if (!WSHelperVerifyKey($params)) {
1214 1248
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1244,22 +1278,30 @@  discard block
 block discarded – undo
1244 1278
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1245 1279
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1280
                 $msg = "Encryption $encrypt_method is invalid";
1247
-                if ($debug) error_log($msg);
1281
+                if ($debug) {
1282
+                    error_log($msg);
1283
+                }
1248 1284
                 return $msg;
1249 1285
 
1250 1286
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1251 1287
                 $msg = "Encryption $encrypt_method is invalid";
1252
-                if ($debug) error_log($msg);
1288
+                if ($debug) {
1289
+                    error_log($msg);
1290
+                }
1253 1291
                 return $msg;
1254 1292
             }
1255 1293
         } else {
1256 1294
             $msg = "This encryption $encrypt_method is not configured";
1257
-            if ($debug) error_log($msg);
1295
+            if ($debug) {
1296
+                error_log($msg);
1297
+            }
1258 1298
             return $msg;
1259 1299
         }
1260 1300
     } else {
1261 1301
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1262
-        if ($debug) error_log($msg);
1302
+        if ($debug) {
1303
+            error_log($msg);
1304
+        }
1263 1305
         return $msg;
1264 1306
     }
1265 1307
 
@@ -1279,10 +1321,14 @@  discard block
 block discarded – undo
1279 1321
         $original_user_id_name
1280 1322
     );
1281 1323
 
1282
-    if ($debug) error_log('Ready to create user');
1324
+    if ($debug) {
1325
+        error_log('Ready to create user');
1326
+    }
1283 1327
 
1284 1328
     if ($user_id > 0) {
1285
-        if ($debug) error_log('User found with id: '.$user_id);
1329
+        if ($debug) {
1330
+            error_log('User found with id: '.$user_id);
1331
+        }
1286 1332
 
1287 1333
         // Check whether user is not active
1288 1334
         //@todo why this condition exists??
@@ -1293,7 +1339,9 @@  discard block
 block discarded – undo
1293 1339
         $count_check_user = Database::num_rows($resu);
1294 1340
         if ($count_check_user > 0) {
1295 1341
 
1296
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1342
+            if ($debug) {
1343
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1344
+            }
1297 1345
 
1298 1346
             $sql = "UPDATE $table_user SET
1299 1347
                     lastname='".Database::escape_string($lastName)."',
@@ -1313,7 +1361,9 @@  discard block
 block discarded – undo
1313 1361
                     active='1',
1314 1362
                     hr_dept_id=".intval($hr_dept_id);
1315 1363
             $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1316
-            if ($debug) error_log($sql);
1364
+            if ($debug) {
1365
+                error_log($sql);
1366
+            }
1317 1367
             Database::query($sql);
1318 1368
 
1319 1369
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1330,11 +1380,15 @@  discard block
 block discarded – undo
1330 1380
             }
1331 1381
             return $r_check_user[0];
1332 1382
         } else {
1333
-            if ($debug) error_log('User exists but is active. Cant be updated');
1383
+            if ($debug) {
1384
+                error_log('User exists but is active. Cant be updated');
1385
+            }
1334 1386
             return 0;
1335 1387
         }
1336 1388
     } else {
1337
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1389
+        if ($debug) {
1390
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1391
+        }
1338 1392
     }
1339 1393
 
1340 1394
     // Default language.
@@ -1350,7 +1404,9 @@  discard block
 block discarded – undo
1350 1404
 
1351 1405
     // First check wether the login already exists
1352 1406
     if (!UserManager::is_username_available($loginName)) {
1353
-        if ($debug) error_log("Username $loginName is not available");
1407
+        if ($debug) {
1408
+            error_log("Username $loginName is not available");
1409
+        }
1354 1410
         return 0;
1355 1411
     }
1356 1412
 
@@ -1372,7 +1428,9 @@  discard block
 block discarded – undo
1372 1428
             expiration_date     = '".Database::escape_string($expiration_date)."',
1373 1429
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1374 1430
             active              = '".Database::escape_string($active)."'";
1375
-    if ($debug) error_log($sql);
1431
+    if ($debug) {
1432
+        error_log($sql);
1433
+    }
1376 1434
 
1377 1435
     Database::query($sql);
1378 1436
     $return = Database::insert_id();
@@ -1384,7 +1442,9 @@  discard block
 block discarded – undo
1384 1442
 
1385 1443
         $url_id = api_get_current_access_url_id();
1386 1444
         UrlManager::add_user_to_url($return, $url_id);
1387
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1445
+        if ($debug) {
1446
+            error_log("Adding user_id = $return to URL id $url_id ");
1447
+        }
1388 1448
 
1389 1449
         // Create extra field for the original_user_id_name
1390 1450
         UserManager::create_extra_field(
@@ -1421,7 +1481,9 @@  discard block
 block discarded – undo
1421 1481
             }
1422 1482
         }
1423 1483
     } else {
1424
-        if ($debug) error_log('Error while inserting a user');
1484
+        if ($debug) {
1485
+            error_log('Error while inserting a user');
1486
+        }
1425 1487
         return 0;
1426 1488
     }
1427 1489
 
@@ -4480,7 +4542,9 @@  discard block
 block discarded – undo
4480 4542
     if (!WSHelperVerifyKey($params)) {
4481 4543
         return returnError(WS_ERROR_SECRET_KEY);
4482 4544
     }
4483
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4545
+    if ($debug) {
4546
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4547
+    }
4484 4548
 
4485 4549
     $results = array();
4486 4550
     $userscourses = $params['userscourses'];
@@ -4499,7 +4563,9 @@  discard block
 block discarded – undo
4499 4563
             $original_user_id['original_user_id_value'],
4500 4564
             $original_user_id['original_user_id_name']
4501 4565
         );
4502
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4566
+        if ($debug) {
4567
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4568
+        }
4503 4569
 
4504 4570
         if ($user_id == 0) {
4505 4571
             // If user was not found, there was a problem
@@ -4517,13 +4583,19 @@  discard block
 block discarded – undo
4517 4583
                 // Course was not found
4518 4584
                 $resultValue = 0;
4519 4585
             } else {
4520
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4586
+                if ($debug) {
4587
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4588
+                }
4521 4589
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4522 4590
                 if ($result) {
4523 4591
                     $resultValue = 1;
4524
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4592
+                    if ($debug) {
4593
+                        error_log('WSSubscribeUserToCourse subscribed');
4594
+                    }
4525 4595
                 } else {
4526
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4596
+                    if ($debug) {
4597
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4598
+                    }
4527 4599
                 }
4528 4600
             }
4529 4601
         }
@@ -4581,8 +4653,12 @@  discard block
 block discarded – undo
4581 4653
 function WSSubscribeUserToCourseSimple($params) {
4582 4654
     global $debug;
4583 4655
 
4584
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4585
-    if ($debug) error_log('Params '. print_r($params, 1));
4656
+    if ($debug) {
4657
+        error_log('WSSubscribeUserToCourseSimple');
4658
+    }
4659
+    if ($debug) {
4660
+        error_log('Params '. print_r($params, 1));
4661
+    }
4586 4662
     if (!WSHelperVerifyKey($params)) {
4587 4663
         return returnError(WS_ERROR_SECRET_KEY);
4588 4664
     }
@@ -4597,7 +4673,9 @@  discard block
 block discarded – undo
4597 4673
     if (empty($user_data)) {
4598 4674
         // If user was not found, there was a problem
4599 4675
         $result = "User $user_id does not exist";
4600
-        if ($debug) error_log($result);
4676
+        if ($debug) {
4677
+            error_log($result);
4678
+        }
4601 4679
         return $result;
4602 4680
     }
4603 4681
     if (!empty($course_code)) {
@@ -4605,14 +4683,22 @@  discard block
 block discarded – undo
4605 4683
         if (empty($course_data)) {
4606 4684
             // Course was not found
4607 4685
             $result = "Course $course_code does not exist in the platform ";
4608
-            if ($debug) error_log($result);
4686
+            if ($debug) {
4687
+                error_log($result);
4688
+            }
4609 4689
         } else {
4610
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4690
+            if ($debug) {
4691
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4692
+            }
4611 4693
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4612 4694
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4613
-                if ($debug) error_log($result);
4695
+                if ($debug) {
4696
+                    error_log($result);
4697
+                }
4614 4698
             } else {
4615
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4699
+                if ($debug) {
4700
+                    error_log('User registered to the course: '.$course_data['code']);
4701
+                }
4616 4702
                 $result = 1;
4617 4703
             }
4618 4704
         }
@@ -4664,8 +4750,12 @@  discard block
 block discarded – undo
4664 4750
 // define the method WSGetUser
4665 4751
 function WSGetUser($params) {
4666 4752
     global $debug;
4667
-    if ($debug) error_log('WSGetUser');
4668
-    if ($debug) error_log('$params: '.print_r($params, 1));
4753
+    if ($debug) {
4754
+        error_log('WSGetUser');
4755
+    }
4756
+    if ($debug) {
4757
+        error_log('$params: '.print_r($params, 1));
4758
+    }
4669 4759
 
4670 4760
     if (!WSHelperVerifyKey($params)) {
4671 4761
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4718,8 +4808,12 @@  discard block
 block discarded – undo
4718 4808
 // define the method WSGetUserFromUsername
4719 4809
 function WSGetUserFromUsername($params) {
4720 4810
     global $debug;
4721
-    if ($debug) error_log('WSGetUserFromUsername');
4722
-    if ($debug) error_log('$params: '.print_r($params, 1));
4811
+    if ($debug) {
4812
+        error_log('WSGetUserFromUsername');
4813
+    }
4814
+    if ($debug) {
4815
+        error_log('$params: '.print_r($params, 1));
4816
+    }
4723 4817
 
4724 4818
     if (!WSHelperVerifyKey($params)) {
4725 4819
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5169,7 +5263,9 @@  discard block
 block discarded – undo
5169 5263
                 $orig_session_id_value[] = $original_session_id_value;
5170 5264
                 $results[] = 1;
5171 5265
 
5172
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5266
+                if ($debug) {
5267
+                    error_log("subscribe user:$user_id to session $sessionId");
5268
+                }
5173 5269
             }
5174 5270
         }
5175 5271
     } // end principal foreach
@@ -5253,7 +5349,9 @@  discard block
 block discarded – undo
5253 5349
                 SESSION_VISIBLE_READ_ONLY,
5254 5350
                 false
5255 5351
             );
5256
-            if ($debug) error_log('User registered to the course: '.$session_id);
5352
+            if ($debug) {
5353
+                error_log('User registered to the course: '.$session_id);
5354
+            }
5257 5355
             $result = 1;
5258 5356
         }
5259 5357
     }
@@ -5399,7 +5497,9 @@  discard block
 block discarded – undo
5399 5497
                 $orig_session_id_value[] = $original_session_id_value;
5400 5498
                 $results[] = 1;
5401 5499
 
5402
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5500
+                if ($debug) {
5501
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5502
+                }
5403 5503
             }
5404 5504
         }
5405 5505
     } // end principal foreach
@@ -5546,7 +5646,9 @@  discard block
 block discarded – undo
5546 5646
         return returnError(WS_ERROR_SECRET_KEY);
5547 5647
     }
5548 5648
 
5549
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5649
+    if ($debug) {
5650
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5651
+    }
5550 5652
 
5551 5653
     $coursessessions_params = $params['coursessessions'];
5552 5654
     $results = array();
@@ -5584,7 +5686,9 @@  discard block
 block discarded – undo
5584 5686
                     array($courseInfo['real_id']),
5585 5687
                     false
5586 5688
                 );
5587
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5689
+                if ($debug) {
5690
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5691
+                }
5588 5692
 
5589 5693
                 $results[] = 1;
5590 5694
                 $orig_course_id_value[] = $original_session_id_value;
@@ -5935,8 +6039,7 @@  discard block
 block discarded – undo
5935 6039
             UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], '');
5936 6040
             // Save the external system's id into user_field_value table.
5937 6041
             UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']);
5938
-        }
5939
-        else {
6042
+        } else {
5940 6043
             return 0;
5941 6044
         }
5942 6045
     }
@@ -6086,8 +6189,12 @@  discard block
 block discarded – undo
6086 6189
 {
6087 6190
     global $debug;
6088 6191
 
6089
-    if ($debug) error_log('WSUserSubscribedInCourse');
6090
-    if ($debug) error_log('Params '. print_r($params, 1));
6192
+    if ($debug) {
6193
+        error_log('WSUserSubscribedInCourse');
6194
+    }
6195
+    if ($debug) {
6196
+        error_log('Params '. print_r($params, 1));
6197
+    }
6091 6198
     if (!WSHelperVerifyKey($params)) {
6092 6199
 
6093 6200
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
main/webservices/webservice.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,8 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param int Error code
39 39
 	 * @param string Error message
40
+	 * @param integer $code
41
+	 * @param string $message
40 42
 	 */
41 43
 	public function __construct($code, $message) {
42 44
 		$this->code = $code;
@@ -47,6 +49,7 @@  discard block
 block discarded – undo
47 49
 	 * Sets the error handler
48 50
 	 *
49 51
 	 * @param WSErrorHandler Error handler
52
+	 * @param WSSoapErrorHandler $handler
50 53
 	 */
51 54
 	public static function setErrorHandler($handler) {
52 55
 		if($handler instanceof WSErrorHandler) {
@@ -81,6 +84,7 @@  discard block
 block discarded – undo
81 84
 	 * Handle method
82 85
 	 *
83 86
 	 * @param WSError Error
87
+	 * @return void
84 88
 	 */
85 89
 	public function handle($error);
86 90
 }
@@ -107,7 +111,7 @@  discard block
 block discarded – undo
107 111
 	 * Verifies the API key
108 112
 	 *
109 113
 	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
114
+	 * @return WSError|null WSError in case of failure, null in case of success
111 115
 	 */
112 116
 	protected function verifyKey($secret_key) {
113 117
 		$ip = trim($_SERVER['REMOTE_ADDR']);
Please login to merge, or discard this patch.
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @package chamilo.webservices
5
- */
4
+     * @package chamilo.webservices
5
+     */
6 6
 require_once(dirname(__FILE__).'/../inc/global.inc.php');
7 7
 
8 8
 /**
@@ -11,237 +11,237 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class WSError
13 13
 {
14
-	/**
15
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
-	 *
17
-	 * @var WSErrorHandler
18
-	 */
19
-	protected static $_handler;
20
-
21
-	/**
22
-	 * Error code
23
-	 *
24
-	 * @var int
25
-	 */
26
-	public $code;
27
-
28
-	/**
29
-	 * Error message
30
-	 *
31
-	 * @var string
32
-	 */
33
-	public $message;
34
-
35
-	/**
36
-	 * Constructor
37
-	 *
38
-	 * @param int Error code
39
-	 * @param string Error message
40
-	 */
41
-	public function __construct($code, $message) {
42
-		$this->code = $code;
43
-		$this->message = $message;
44
-	}
45
-
46
-	/**
47
-	 * Sets the error handler
48
-	 *
49
-	 * @param WSErrorHandler Error handler
50
-	 */
51
-	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
53
-			self::$_handler = $handler;
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Returns the error handler
59
-	 *
60
-	 * @return WSErrorHandler Error handler
61
-	 */
62
-	public static function getErrorHandler() {
63
-		return self::$_handler;
64
-	}
65
-
66
-	/**
67
-	 * Transforms the error into an array
68
-	 *
69
-	 * @return array Associative array with code and message
70
-	 */
71
-	public function toArray() {
72
-		return array('code' => $this->code, 'message' => $this->message);
73
-	}
14
+    /**
15
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
+     *
17
+     * @var WSErrorHandler
18
+     */
19
+    protected static $_handler;
20
+
21
+    /**
22
+     * Error code
23
+     *
24
+     * @var int
25
+     */
26
+    public $code;
27
+
28
+    /**
29
+     * Error message
30
+     *
31
+     * @var string
32
+     */
33
+    public $message;
34
+
35
+    /**
36
+     * Constructor
37
+     *
38
+     * @param int Error code
39
+     * @param string Error message
40
+     */
41
+    public function __construct($code, $message) {
42
+        $this->code = $code;
43
+        $this->message = $message;
44
+    }
45
+
46
+    /**
47
+     * Sets the error handler
48
+     *
49
+     * @param WSErrorHandler Error handler
50
+     */
51
+    public static function setErrorHandler($handler) {
52
+        if($handler instanceof WSErrorHandler) {
53
+            self::$_handler = $handler;
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Returns the error handler
59
+     *
60
+     * @return WSErrorHandler Error handler
61
+     */
62
+    public static function getErrorHandler() {
63
+        return self::$_handler;
64
+    }
65
+
66
+    /**
67
+     * Transforms the error into an array
68
+     *
69
+     * @return array Associative array with code and message
70
+     */
71
+    public function toArray() {
72
+        return array('code' => $this->code, 'message' => $this->message);
73
+    }
74 74
 }
75 75
 
76 76
 /**
77 77
  * Interface that must be implemented by any error handler
78 78
  */
79 79
 interface WSErrorHandler {
80
-	/**
81
-	 * Handle method
82
-	 *
83
-	 * @param WSError Error
84
-	 */
85
-	public function handle($error);
80
+    /**
81
+     * Handle method
82
+     *
83
+     * @param WSError Error
84
+     */
85
+    public function handle($error);
86 86
 }
87 87
 
88 88
 /**
89 89
  * Main class of the webservice. Webservice classes extend this class
90 90
  */
91 91
 class WS {
92
-	/**
93
-	 * Chamilo configuration
94
-	 *
95
-	 * @var array
96
-	 */
97
-	protected $_configuration;
98
-
99
-	/**
100
-	 * Constructor
101
-	 */
102
-	public function __construct() {
103
-		$this->_configuration = $GLOBALS['_configuration'];
104
-	}
105
-
106
-	/**
107
-	 * Verifies the API key
108
-	 *
109
-	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
111
-	 */
112
-	protected function verifyKey($secret_key) {
113
-		$ip = trim($_SERVER['REMOTE_ADDR']);
114
-		// if we are behind a reverse proxy, assume it will send the
115
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
116
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
-			$ip = trim($ip1);
119
-		}
120
-		$security_key = $ip.$this->_configuration['security_key'];
121
-
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
-			return new WSError(1, "API key is invalid");
124
-		} else {
125
-			return null;
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Gets the real user id based on the user id field name and value.
131
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
-	 * in the system database
133
-	 *
134
-	 * @param string User id field name
135
-	 * @param string User id value
136
-	 * @return mixed System user id if the user was found, WSError otherwise
137
-	 */
138
-	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
-				return intval($user_id_value);
142
-			} else {
143
-				return new WSError(100, "User not found");
144
-			}
145
-		} else {
146
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
148
-				return new WSError(100, "User not found");
149
-			} else {
150
-				return $user_id;
151
-			}
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the real course id based on the course id field name and value.
157
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
-	 * in the system database
159
-	 *
160
-	 * @param string Course id field name
161
-	 * @param string Course id value
162
-	 * @return mixed System course id if the course was found, WSError otherwise
163
-	 */
164
-	protected function getCourseId($course_id_field_name, $course_id_value)
165
-	{
166
-		if ($course_id_field_name == "chamilo_course_id") {
167
-			if (CourseManager::get_course_code_from_course_id(
168
-					intval($course_id_value)
169
-				) != null
170
-			) {
171
-				return intval($course_id_value);
172
-			} else {
173
-				return new WSError(200, "Course not found");
174
-			}
175
-		} else {
176
-			$courseId = CourseManager::get_course_code_from_original_id(
177
-				$course_id_value,
178
-				$course_id_field_name
179
-			);
180
-			if (!empty($courseId)) {
181
-				return $courseId;
182
-			} else {
183
-				return new WSError(200, "Course not found");
184
-			}
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Gets the real session id based on the session id field name and value.
190
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
-	 * in the system database
192
-	 *
193
-	 * @param string Session id field name
194
-	 * @param string Session id value
195
-	 * @return mixed System session id if the session was found, WSError otherwise
196
-	 */
197
-	protected function getSessionId($session_id_field_name, $session_id_value)
198
-	{
199
-		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
201
-			if (!empty($session)) {
202
-				return intval($session_id_value);
203
-			} else {
204
-				return new WSError(300, "Session not found");
205
-			}
206
-		} else {
207
-			$session_id = SessionManager::getSessionIdFromOriginalId(
208
-				$session_id_value,
209
-				$session_id_field_name
210
-			);
211
-			if ($session_id == 0) {
212
-				return new WSError(300, "Session not found");
213
-			} else {
214
-				return $session_id;
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Handles an error by calling the WSError error handler
221
-	 *
222
-	 * @param WSError Error
223
-	 */
224
-	protected function handleError($error) {
225
-		$handler = WSError::getErrorHandler();
226
-		$handler->handle($error);
227
-	}
228
-
229
-	/**
230
-	 * Gets a successful result
231
-	 *
232
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
233
-	 */
234
-	protected function getSuccessfulResult() {
235
-		return array('code' => 0, 'message' => 'Operation was successful');
236
-	}
237
-
238
-	/**
239
-	 * Test function. Returns the string success
240
-	 *
241
-	 * @return string Success
242
-	 */
243
-	public function test() {
244
-		return "success";
245
-	}
92
+    /**
93
+     * Chamilo configuration
94
+     *
95
+     * @var array
96
+     */
97
+    protected $_configuration;
98
+
99
+    /**
100
+     * Constructor
101
+     */
102
+    public function __construct() {
103
+        $this->_configuration = $GLOBALS['_configuration'];
104
+    }
105
+
106
+    /**
107
+     * Verifies the API key
108
+     *
109
+     * @param string Secret key
110
+     * @return mixed WSError in case of failure, null in case of success
111
+     */
112
+    protected function verifyKey($secret_key) {
113
+        $ip = trim($_SERVER['REMOTE_ADDR']);
114
+        // if we are behind a reverse proxy, assume it will send the
115
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
116
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
+            list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
+            $ip = trim($ip1);
119
+        }
120
+        $security_key = $ip.$this->_configuration['security_key'];
121
+
122
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
+            return new WSError(1, "API key is invalid");
124
+        } else {
125
+            return null;
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Gets the real user id based on the user id field name and value.
131
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
+     * in the system database
133
+     *
134
+     * @param string User id field name
135
+     * @param string User id value
136
+     * @return mixed System user id if the user was found, WSError otherwise
137
+     */
138
+    protected function getUserId($user_id_field_name, $user_id_value) {
139
+        if($user_id_field_name == "chamilo_user_id") {
140
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
+                return intval($user_id_value);
142
+            } else {
143
+                return new WSError(100, "User not found");
144
+            }
145
+        } else {
146
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
+            if($user_id == 0) {
148
+                return new WSError(100, "User not found");
149
+            } else {
150
+                return $user_id;
151
+            }
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the real course id based on the course id field name and value.
157
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
+     * in the system database
159
+     *
160
+     * @param string Course id field name
161
+     * @param string Course id value
162
+     * @return mixed System course id if the course was found, WSError otherwise
163
+     */
164
+    protected function getCourseId($course_id_field_name, $course_id_value)
165
+    {
166
+        if ($course_id_field_name == "chamilo_course_id") {
167
+            if (CourseManager::get_course_code_from_course_id(
168
+                    intval($course_id_value)
169
+                ) != null
170
+            ) {
171
+                return intval($course_id_value);
172
+            } else {
173
+                return new WSError(200, "Course not found");
174
+            }
175
+        } else {
176
+            $courseId = CourseManager::get_course_code_from_original_id(
177
+                $course_id_value,
178
+                $course_id_field_name
179
+            );
180
+            if (!empty($courseId)) {
181
+                return $courseId;
182
+            } else {
183
+                return new WSError(200, "Course not found");
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Gets the real session id based on the session id field name and value.
190
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
+     * in the system database
192
+     *
193
+     * @param string Session id field name
194
+     * @param string Session id value
195
+     * @return mixed System session id if the session was found, WSError otherwise
196
+     */
197
+    protected function getSessionId($session_id_field_name, $session_id_value)
198
+    {
199
+        if ($session_id_field_name == "chamilo_session_id") {
200
+            $session = SessionManager::fetch((int)$session_id_value);
201
+            if (!empty($session)) {
202
+                return intval($session_id_value);
203
+            } else {
204
+                return new WSError(300, "Session not found");
205
+            }
206
+        } else {
207
+            $session_id = SessionManager::getSessionIdFromOriginalId(
208
+                $session_id_value,
209
+                $session_id_field_name
210
+            );
211
+            if ($session_id == 0) {
212
+                return new WSError(300, "Session not found");
213
+            } else {
214
+                return $session_id;
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Handles an error by calling the WSError error handler
221
+     *
222
+     * @param WSError Error
223
+     */
224
+    protected function handleError($error) {
225
+        $handler = WSError::getErrorHandler();
226
+        $handler->handle($error);
227
+    }
228
+
229
+    /**
230
+     * Gets a successful result
231
+     *
232
+     * @return array Array with a code of 0 and a message 'Operation was successful'
233
+     */
234
+    protected function getSuccessfulResult() {
235
+        return array('code' => 0, 'message' => 'Operation was successful');
236
+    }
237
+
238
+    /**
239
+     * Test function. Returns the string success
240
+     *
241
+     * @return string Success
242
+     */
243
+    public function test() {
244
+        return "success";
245
+    }
246 246
 }
247 247
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param WSErrorHandler Error handler
50 50
 	 */
51 51
 	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
52
+		if ($handler instanceof WSErrorHandler) {
53 53
 			self::$_handler = $handler;
54 54
 		}
55 55
 	}
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 		// if we are behind a reverse proxy, assume it will send the
115 115
 		// HTTP_X_FORWARDED_FOR header and use this IP instead
116 116
 		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
117
+			list($ip1, $ip2) = preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']);
118 118
 			$ip = trim($ip1);
119 119
 		}
120 120
 		$security_key = $ip.$this->_configuration['security_key'];
121 121
 
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
122
+		if (!api_is_valid_secret_key($secret_key, $security_key)) {
123 123
 			return new WSError(1, "API key is invalid");
124 124
 		} else {
125 125
 			return null;
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 * @return mixed System user id if the user was found, WSError otherwise
137 137
 	 */
138 138
 	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
139
+		if ($user_id_field_name == "chamilo_user_id") {
140
+			if (UserManager::is_user_id_valid(intval($user_id_value))) {
141 141
 				return intval($user_id_value);
142 142
 			} else {
143 143
 				return new WSError(100, "User not found");
144 144
 			}
145 145
 		} else {
146 146
 			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
147
+			if ($user_id == 0) {
148 148
 				return new WSError(100, "User not found");
149 149
 			} else {
150 150
 				return $user_id;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	protected function getSessionId($session_id_field_name, $session_id_value)
198 198
 	{
199 199
 		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
200
+			$session = SessionManager::fetch((int) $session_id_value);
201 201
 			if (!empty($session)) {
202 202
 				return intval($session_id_value);
203 203
 			} else {
Please login to merge, or discard this patch.
main/webservices/webservice_session.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -453,6 +453,7 @@
 block discarded – undo
453 453
 	 * @param string Session id field name
454 454
 	 * @param string Session id value
455 455
 	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
+	 * @param integer $state
456 457
 	 * @return mixed True on success, WSError otherwise
457 458
 	 */
458 459
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
Please login to merge, or discard this patch.
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -14,177 +14,177 @@  discard block
 block discarded – undo
14 14
 class WSSession extends WS
15 15
 {
16 16
 
17
-	/**
18
-	 * Creates a session (helper method)
19
-	 *
20
-	 * @param string Name of the session
21
-	 * @param string Start date, use the 'YYYY-MM-DD' format
22
-	 * @param string End date, use the 'YYYY-MM-DD' format
23
-	 * @param int Access delays of the coach (days before)
24
-	 * @param int Access delays of the coach (days after)
25
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
-	 * @param int Visibility
27
-	 * @param string User id field name for the coach
28
-	 * @param string User id value for the coach
29
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
-	 * @param string Original session id value
31
-	 * @param array Array of extra fields
32
-	 * @return mixed Generated id in case of success, WSError otherwise
33
-	 */
34
-	protected function createSessionHelper(
35
-		$name,
36
-		$start_date,
37
-		$end_date,
38
-		$nb_days_access_before,
39
-		$nb_days_access_after,
40
-		$nolimit,
41
-		$visibility,
42
-		$user_id_field_name,
43
-		$user_id_value,
44
-		$session_id_field_name,
45
-		$session_id_value,
46
-		$extras
47
-	) {
48
-		// Verify that coach exists and get its id
49
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
-		if ($user_id instanceof WSError) {
51
-			return $user_id;
52
-		}
17
+    /**
18
+     * Creates a session (helper method)
19
+     *
20
+     * @param string Name of the session
21
+     * @param string Start date, use the 'YYYY-MM-DD' format
22
+     * @param string End date, use the 'YYYY-MM-DD' format
23
+     * @param int Access delays of the coach (days before)
24
+     * @param int Access delays of the coach (days after)
25
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
+     * @param int Visibility
27
+     * @param string User id field name for the coach
28
+     * @param string User id value for the coach
29
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
+     * @param string Original session id value
31
+     * @param array Array of extra fields
32
+     * @return mixed Generated id in case of success, WSError otherwise
33
+     */
34
+    protected function createSessionHelper(
35
+        $name,
36
+        $start_date,
37
+        $end_date,
38
+        $nb_days_access_before,
39
+        $nb_days_access_after,
40
+        $nolimit,
41
+        $visibility,
42
+        $user_id_field_name,
43
+        $user_id_value,
44
+        $session_id_field_name,
45
+        $session_id_value,
46
+        $extras
47
+    ) {
48
+        // Verify that coach exists and get its id
49
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
+        if ($user_id instanceof WSError) {
51
+            return $user_id;
52
+        }
53 53
 
54
-		$coachStartDate = null;
55
-		if (!empty($nb_days_access_before)) {
56
-			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
-		}
54
+        $coachStartDate = null;
55
+        if (!empty($nb_days_access_before)) {
56
+            $day = intval($nb_days_access_before);
57
+            $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
+        }
59 59
 
60
-		$coachEndDate = null;
61
-		if (!empty($nb_days_access_after)) {
62
-			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
-		}
60
+        $coachEndDate = null;
61
+        if (!empty($nb_days_access_after)) {
62
+            $day = intval($nb_days_access_after);
63
+            $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
+        }
65 65
 
66
-		// Try to create the session
67
-		$session_id = SessionManager::create_session(
68
-			$name,
69
-			$start_date,
70
-			$end_date,
71
-			$start_date,
72
-			$end_date,
73
-			$coachStartDate,
74
-			$coachEndDate,
75
-			$user_id,
76
-			0,
77
-			$visibility
78
-		);
79
-		if(!is_int($session_id)) {
80
-			return new WSError(301, 'Could not create the session');
81
-		} else {
82
-			// Add the Original session id to the extra fields
83
-			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
85
-				$extras_associative[$session_id_field_name] = $session_id_value;
86
-			}
87
-			foreach($extras as $extra) {
88
-				$extras_associative[$extra['field_name']] = $extra['field_value'];
89
-			}
90
-			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
92
-				SessionManager::create_session_extra_field($fname, 1, $fname);
93
-				SessionManager::update_session_extra_field_value(
94
-					$session_id,
95
-					$fname,
96
-					$fvalue
97
-				);
98
-			}
99
-			return $session_id;
100
-		}
101
-	}
66
+        // Try to create the session
67
+        $session_id = SessionManager::create_session(
68
+            $name,
69
+            $start_date,
70
+            $end_date,
71
+            $start_date,
72
+            $end_date,
73
+            $coachStartDate,
74
+            $coachEndDate,
75
+            $user_id,
76
+            0,
77
+            $visibility
78
+        );
79
+        if(!is_int($session_id)) {
80
+            return new WSError(301, 'Could not create the session');
81
+        } else {
82
+            // Add the Original session id to the extra fields
83
+            $extras_associative = array();
84
+            if($session_id_field_name != "chamilo_session_id") {
85
+                $extras_associative[$session_id_field_name] = $session_id_value;
86
+            }
87
+            foreach($extras as $extra) {
88
+                $extras_associative[$extra['field_name']] = $extra['field_value'];
89
+            }
90
+            // Create the extra fields
91
+            foreach($extras_associative as $fname => $fvalue) {
92
+                SessionManager::create_session_extra_field($fname, 1, $fname);
93
+                SessionManager::update_session_extra_field_value(
94
+                    $session_id,
95
+                    $fname,
96
+                    $fvalue
97
+                );
98
+            }
99
+            return $session_id;
100
+        }
101
+    }
102 102
 
103
-	/**
104
-	 * Creates a session
105
-	 *
106
-	 * @param string API secret key
107
-	 * @param string Name of the session
108
-	 * @param string Start date, use the 'YYYY-MM-DD' format
109
-	 * @param string End date, use the 'YYYY-MM-DD' format
110
-	 * @param int Access delays of the coach (days before)
111
-	 * @param int Access delays of the coach (days after)
112
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
-	 * @param int Visibility
114
-	 * @param string User id field name for the coach
115
-	 * @param string User id value for the coach
116
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
-	 * @param string Original session id value
118
-	 * @param array Array of extra fields
119
-	 * @return int Session id generated
120
-	 */
121
-	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
-		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
124
-			$this->handleError($verifKey);
125
-		} else {
126
-			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
128
-				$this->handleError($session_id);
129
-			} else {
130
-				return $session_id;
131
-			}
132
-		}
133
-	}
103
+    /**
104
+     * Creates a session
105
+     *
106
+     * @param string API secret key
107
+     * @param string Name of the session
108
+     * @param string Start date, use the 'YYYY-MM-DD' format
109
+     * @param string End date, use the 'YYYY-MM-DD' format
110
+     * @param int Access delays of the coach (days before)
111
+     * @param int Access delays of the coach (days after)
112
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
+     * @param int Visibility
114
+     * @param string User id field name for the coach
115
+     * @param string User id value for the coach
116
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
+     * @param string Original session id value
118
+     * @param array Array of extra fields
119
+     * @return int Session id generated
120
+     */
121
+    public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
+        $verifKey = $this->verifyKey($secret_key);
123
+        if($verifKey instanceof WSError) {
124
+            $this->handleError($verifKey);
125
+        } else {
126
+            $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
+            if($session_id instanceof WSError) {
128
+                $this->handleError($session_id);
129
+            } else {
130
+                return $session_id;
131
+            }
132
+        }
133
+    }
134 134
 
135
-	/**
136
-	 * Deletes a session (helper method)
137
-	 *
138
-	 * @param string Session id field name
139
-	 * @param string Session id value
140
-	 * @return mixed True in case of success, WSError otherwise
141
-	 */
142
-	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
145
-			return $session_id;
146
-		} else {
147
-			SessionManager::delete($session_id, true);
148
-			return true;
149
-		}
150
-	}
135
+    /**
136
+     * Deletes a session (helper method)
137
+     *
138
+     * @param string Session id field name
139
+     * @param string Session id value
140
+     * @return mixed True in case of success, WSError otherwise
141
+     */
142
+    protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
+        if($session_id instanceof WSError) {
145
+            return $session_id;
146
+        } else {
147
+            SessionManager::delete($session_id, true);
148
+            return true;
149
+        }
150
+    }
151 151
 
152
-	/**
153
-	 * Deletes a session
154
-	 *
155
-	 * @param string API secret key
156
-	 * @param string Session id field name
157
-	 * @param string Session id value
158
-	 */
159
-	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
-		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
162
-			$this->handleError($verifKey);
163
-		} else {
164
-			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
166
-				$this->handleError($result);
167
-			}
168
-		}
169
-	}
152
+    /**
153
+     * Deletes a session
154
+     *
155
+     * @param string API secret key
156
+     * @param string Session id field name
157
+     * @param string Session id value
158
+     */
159
+    public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
+        $verifKey = $this->verifyKey($secret_key);
161
+        if($verifKey instanceof WSError) {
162
+            $this->handleError($verifKey);
163
+        } else {
164
+            $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
+            if($result instanceof WSError) {
166
+                $this->handleError($result);
167
+            }
168
+        }
169
+    }
170 170
 
171
-	/**
172
-	 * Edits a session (helper method)
173
-	 *
174
-	 * @param string Name of the session
175
-	 * @param string Start date, use the 'YYYY-MM-DD' format
176
-	 * @param string End date, use the 'YYYY-MM-DD' format
177
-	 * @param int Access delays of the coach (days before)
178
-	 * @param int Access delays of the coach (days after)
179
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
-	 * @param int Visibility
181
-	 * @param string User id field name for the coach
182
-	 * @param string User id value for the coach
183
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
-	 * @param string Original session id value
185
-	 * @param array Array of extra fields
186
-	 * @return mixed True on success, WSError otherwise
187
-	 */
171
+    /**
172
+     * Edits a session (helper method)
173
+     *
174
+     * @param string Name of the session
175
+     * @param string Start date, use the 'YYYY-MM-DD' format
176
+     * @param string End date, use the 'YYYY-MM-DD' format
177
+     * @param int Access delays of the coach (days before)
178
+     * @param int Access delays of the coach (days after)
179
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
+     * @param int Visibility
181
+     * @param string User id field name for the coach
182
+     * @param string User id value for the coach
183
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
+     * @param string Original session id value
185
+     * @param array Array of extra fields
186
+     * @return mixed True on success, WSError otherwise
187
+     */
188 188
     protected function editSessionHelper(
189 189
         $name,
190 190
         $start_date,
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
         $session_id_value,
200 200
         $extras
201 201
     ) {
202
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
204
-			return $session_id;
205
-		} else {
206
-			// Verify that coach exists and get its id
207
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
-			if ($user_id instanceof WSError) {
209
-				return $user_id;
210
-			}
202
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
+        if($session_id instanceof WSError) {
204
+            return $session_id;
205
+        } else {
206
+            // Verify that coach exists and get its id
207
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
+            if ($user_id instanceof WSError) {
209
+                return $user_id;
210
+            }
211 211
 
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
@@ -234,127 +234,127 @@  discard block
 block discarded – undo
234 234
                 0,
235 235
                 (int)$visibility
236 236
             );
237
-			if(!is_int($result_id)) {
238
-				return new WSError(302, 'Could not edit the session');
239
-			} else {
240
-				if(!empty($extras)) {
241
-					$extras_associative = array();
242
-					foreach($extras as $extra) {
243
-						$extras_associative[$extra['field_name']] = $extra['field_value'];
244
-					}
245
-					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
247
-						SessionManager::create_session_extra_field($fname, 1, $fname);
248
-						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
-					}
250
-				}
251
-				return true;
252
-			}
253
-		}
254
-	}
237
+            if(!is_int($result_id)) {
238
+                return new WSError(302, 'Could not edit the session');
239
+            } else {
240
+                if(!empty($extras)) {
241
+                    $extras_associative = array();
242
+                    foreach($extras as $extra) {
243
+                        $extras_associative[$extra['field_name']] = $extra['field_value'];
244
+                    }
245
+                    // Create the extra fields
246
+                    foreach($extras_associative as $fname => $fvalue) {
247
+                        SessionManager::create_session_extra_field($fname, 1, $fname);
248
+                        SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
+                    }
250
+                }
251
+                return true;
252
+            }
253
+        }
254
+    }
255 255
 
256
-	/**
257
-	 * Edits a session
258
-	 *
259
-	 * @param string API secret key
260
-	 * @param string Name of the session
261
-	 * @param string Start date, use the 'YYYY-MM-DD' format
262
-	 * @param string End date, use the 'YYYY-MM-DD' format
263
-	 * @param int Access delays of the coach (days before)
264
-	 * @param int Access delays of the coach (days after)
265
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
-	 * @param int Visibility
267
-	 * @param string User id field name for the coach
268
-	 * @param string User id value for the coach
269
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
-	 * @param string Original session id value
271
-	 * @param array Array of extra fields
272
-	 */
273
-	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
-		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
276
-			$this->handleError($verifKey);
277
-		} else {
278
-			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
280
-				$this->handleError($result);
281
-			}
282
-		}
283
-	}
256
+    /**
257
+     * Edits a session
258
+     *
259
+     * @param string API secret key
260
+     * @param string Name of the session
261
+     * @param string Start date, use the 'YYYY-MM-DD' format
262
+     * @param string End date, use the 'YYYY-MM-DD' format
263
+     * @param int Access delays of the coach (days before)
264
+     * @param int Access delays of the coach (days after)
265
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
+     * @param int Visibility
267
+     * @param string User id field name for the coach
268
+     * @param string User id value for the coach
269
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
+     * @param string Original session id value
271
+     * @param array Array of extra fields
272
+     */
273
+    public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
+        $verifKey = $this->verifyKey($secret_key);
275
+        if($verifKey instanceof WSError) {
276
+            $this->handleError($verifKey);
277
+        } else {
278
+            $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
+            if($session_id_value instanceof WSError) {
280
+                $this->handleError($result);
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Change user subscription (helper method)
287
-	 *
288
-	 * @param string User id field name
289
-	 * @param string User id value
290
-	 * @param string Session id field name
291
-	 * @param string Session id value
292
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
293
-	 * @return mixed True on success, WSError otherwise
294
-	 */
295
-	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
298
-			return $session_id;
299
-		} else {
300
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
302
-				return $user_id;
303
-			} else {
304
-				if($state  == 1) {
305
-					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
-				} else {
307
-					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
-					if (!$result) {
309
-						return new WSError(303, 'There was an error unsubscribing this user from the session');
310
-					}
311
-				}
312
-				return true;
313
-			}
314
-		}
315
-	}
285
+    /**
286
+     * Change user subscription (helper method)
287
+     *
288
+     * @param string User id field name
289
+     * @param string User id value
290
+     * @param string Session id field name
291
+     * @param string Session id value
292
+     * @param int State (1 to subscribe, 0 to unsubscribe)
293
+     * @return mixed True on success, WSError otherwise
294
+     */
295
+    protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
+        if($session_id instanceof WSError) {
298
+            return $session_id;
299
+        } else {
300
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
+            if($user_id instanceof WSError) {
302
+                return $user_id;
303
+            } else {
304
+                if($state  == 1) {
305
+                    SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
+                } else {
307
+                    $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
+                    if (!$result) {
309
+                        return new WSError(303, 'There was an error unsubscribing this user from the session');
310
+                    }
311
+                }
312
+                return true;
313
+            }
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Subscribe user to a session
319
-	 *
320
-	 * @param string API secret key
321
-	 * @param string User id field name
322
-	 * @param string User id value
323
-	 * @param string Session id field name
324
-	 * @param string Session id value
325
-	 */
326
-	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
-		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
329
-			$this->handleError($verifKey);
330
-		} else {
331
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
333
-				$this->handleError($result);
334
-			}
335
-		}
336
-	}
317
+    /**
318
+     * Subscribe user to a session
319
+     *
320
+     * @param string API secret key
321
+     * @param string User id field name
322
+     * @param string User id value
323
+     * @param string Session id field name
324
+     * @param string Session id value
325
+     */
326
+    public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
+        $verifKey = $this->verifyKey($secret_key);
328
+        if($verifKey instanceof WSError) {
329
+            $this->handleError($verifKey);
330
+        } else {
331
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
+            if($result instanceof WSError) {
333
+                $this->handleError($result);
334
+            }
335
+        }
336
+    }
337 337
 
338
-	/**
339
-	 * Subscribe user to a session
340
-	 *
341
-	 * @param string API secret key
342
-	 * @param string User id field name
343
-	 * @param string User id value
344
-	 * @param string Session id field name
345
-	 * @param string Session id value
346
-	 */
347
-	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
-		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
350
-			$this->handleError($verifKey);
351
-		} else {
352
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
354
-				$this->handleError($result);
355
-			}
356
-		}
357
-	}
338
+    /**
339
+     * Subscribe user to a session
340
+     *
341
+     * @param string API secret key
342
+     * @param string User id field name
343
+     * @param string User id value
344
+     * @param string Session id field name
345
+     * @param string Session id value
346
+     */
347
+    public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
+        $verifKey = $this->verifyKey($secret_key);
349
+        if($verifKey instanceof WSError) {
350
+            $this->handleError($verifKey);
351
+        } else {
352
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
+            if($result instanceof WSError) {
354
+                $this->handleError($result);
355
+            }
356
+        }
357
+    }
358 358
     
359 359
     /**
360 360
      * Change Teacher subscription (helper method)
@@ -446,79 +446,79 @@  discard block
 block discarded – undo
446 446
     }
447 447
 
448 448
     /**
449
-	 * Change course subscription
450
-	 *
451
-	 * @param string Course id field name
452
-	 * @param string Course id value
453
-	 * @param string Session id field name
454
-	 * @param string Session id value
455
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
-	 * @return mixed True on success, WSError otherwise
457
-	 */
458
-	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
461
-			return $session_id;
462
-		} else {
463
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
465
-				return $course_id;
466
-			} else {
467
-				if($state  == 1) {
468
-					SessionManager::add_courses_to_session($session_id, array($course_id));
469
-					return true;
470
-				} else {
471
-					$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
-					if ($result) {
473
-						return true;
474
-					} else {
475
-						return new WSError(304, 'Error unsubscribing course from session');
476
-					}
477
-				}
478
-			}
479
-		}
449
+     * Change course subscription
450
+     *
451
+     * @param string Course id field name
452
+     * @param string Course id value
453
+     * @param string Session id field name
454
+     * @param string Session id value
455
+     * @param int State (1 to subscribe, 0 to unsubscribe)
456
+     * @return mixed True on success, WSError otherwise
457
+     */
458
+    protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
+        if($session_id instanceof WSError) {
461
+            return $session_id;
462
+        } else {
463
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
+            if($course_id instanceof WSError) {
465
+                return $course_id;
466
+            } else {
467
+                if($state  == 1) {
468
+                    SessionManager::add_courses_to_session($session_id, array($course_id));
469
+                    return true;
470
+                } else {
471
+                    $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
+                    if ($result) {
473
+                        return true;
474
+                    } else {
475
+                        return new WSError(304, 'Error unsubscribing course from session');
476
+                    }
477
+                }
478
+            }
479
+        }
480 480
     }
481 481
 
482
-	/**
483
-	 * Subscribe course to session
484
-	 *
485
-	 * @param string API secret key
486
-	 * @param string Course id field name
487
-	 * @param string Course id value
488
-	 * @param string Session id field name
489
-	 * @param string Session id value
490
-	 */
491
-	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
-		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
494
-			$this->handleError($verifKey);
495
-		} else {
496
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
498
-				$this->handleError($result);
499
-			}
500
-		}
501
-	}
482
+    /**
483
+     * Subscribe course to session
484
+     *
485
+     * @param string API secret key
486
+     * @param string Course id field name
487
+     * @param string Course id value
488
+     * @param string Session id field name
489
+     * @param string Session id value
490
+     */
491
+    public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
+        $verifKey = $this->verifyKey($secret_key);
493
+        if($verifKey instanceof WSError) {
494
+            $this->handleError($verifKey);
495
+        } else {
496
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
+            if($result instanceof WSError) {
498
+                $this->handleError($result);
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	 * Unsubscribe course from session
505
-	 *
506
-	 * @param string API secret key
507
-	 * @param string Course id field name
508
-	 * @param string Course id value
509
-	 * @param string Session id field name
510
-	 * @param string Session id value
511
-	 */
512
-	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
-		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
515
-			$this->handleError($verifKey);
516
-		} else {
517
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
519
-				$this->handleError($result);
520
-			}
521
-		}
522
-	}
503
+    /**
504
+     * Unsubscribe course from session
505
+     *
506
+     * @param string API secret key
507
+     * @param string Course id field name
508
+     * @param string Course id value
509
+     * @param string Session id field name
510
+     * @param string Session id value
511
+     */
512
+    public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
+        $verifKey = $this->verifyKey($secret_key);
514
+        if($verifKey instanceof WSError) {
515
+            $this->handleError($verifKey);
516
+        } else {
517
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
+            if($result instanceof WSError) {
519
+                $this->handleError($result);
520
+            }
521
+        }
522
+    }
523 523
 
524 524
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 		$coachStartDate = null;
55 55
 		if (!empty($nb_days_access_before)) {
56 56
 			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
57
+			$coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
58 58
 		}
59 59
 
60 60
 		$coachEndDate = null;
61 61
 		if (!empty($nb_days_access_after)) {
62 62
 			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
63
+			$coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
64 64
 		}
65 65
 
66 66
 		// Try to create the session
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 			0,
77 77
 			$visibility
78 78
 		);
79
-		if(!is_int($session_id)) {
79
+		if (!is_int($session_id)) {
80 80
 			return new WSError(301, 'Could not create the session');
81 81
 		} else {
82 82
 			// Add the Original session id to the extra fields
83 83
 			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
84
+			if ($session_id_field_name != "chamilo_session_id") {
85 85
 				$extras_associative[$session_id_field_name] = $session_id_value;
86 86
 			}
87
-			foreach($extras as $extra) {
87
+			foreach ($extras as $extra) {
88 88
 				$extras_associative[$extra['field_name']] = $extra['field_value'];
89 89
 			}
90 90
 			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
91
+			foreach ($extras_associative as $fname => $fvalue) {
92 92
 				SessionManager::create_session_extra_field($fname, 1, $fname);
93 93
 				SessionManager::update_session_extra_field_value(
94 94
 					$session_id,
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122 122
 		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
123
+		if ($verifKey instanceof WSError) {
124 124
 			$this->handleError($verifKey);
125 125
 		} else {
126 126
 			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
127
+			if ($session_id instanceof WSError) {
128 128
 				$this->handleError($session_id);
129 129
 			} else {
130 130
 				return $session_id;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143 143
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
144
+		if ($session_id instanceof WSError) {
145 145
 			return $session_id;
146 146
 		} else {
147 147
 			SessionManager::delete($session_id, true);
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160 160
 		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
161
+		if ($verifKey instanceof WSError) {
162 162
 			$this->handleError($verifKey);
163 163
 		} else {
164 164
 			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
165
+			if ($result instanceof WSError) {
166 166
 				$this->handleError($result);
167 167
 			}
168 168
 		}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         $extras
201 201
     ) {
202 202
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
203
+		if ($session_id instanceof WSError) {
204 204
 			return $session_id;
205 205
 		} else {
206 206
 			// Verify that coach exists and get its id
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
214 214
                 $day = intval($nb_days_access_before);
215
-                $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
215
+                $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
216 216
             }
217 217
 
218 218
             $coachEndDate = null;
219 219
             if (!empty($nb_days_access_after)) {
220 220
                 $day = intval($nb_days_access_after);
221
-                $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
221
+                $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
222 222
             }
223 223
 
224 224
             $result_id = SessionManager::edit_session(
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
                 $coachEndDate,
233 233
                 $user_id,
234 234
                 0,
235
-                (int)$visibility
235
+                (int) $visibility
236 236
             );
237
-			if(!is_int($result_id)) {
237
+			if (!is_int($result_id)) {
238 238
 				return new WSError(302, 'Could not edit the session');
239 239
 			} else {
240
-				if(!empty($extras)) {
240
+				if (!empty($extras)) {
241 241
 					$extras_associative = array();
242
-					foreach($extras as $extra) {
242
+					foreach ($extras as $extra) {
243 243
 						$extras_associative[$extra['field_name']] = $extra['field_value'];
244 244
 					}
245 245
 					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
246
+					foreach ($extras_associative as $fname => $fvalue) {
247 247
 						SessionManager::create_session_extra_field($fname, 1, $fname);
248 248
 						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249 249
 					}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274 274
 		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
275
+		if ($verifKey instanceof WSError) {
276 276
 			$this->handleError($verifKey);
277 277
 		} else {
278 278
 			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
279
+			if ($session_id_value instanceof WSError) {
280 280
 				$this->handleError($result);
281 281
 			}
282 282
 		}
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296 296
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
297
+		if ($session_id instanceof WSError) {
298 298
 			return $session_id;
299 299
 		} else {
300 300
 			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
301
+			if ($user_id instanceof WSError) {
302 302
 				return $user_id;
303 303
 			} else {
304
-				if($state  == 1) {
304
+				if ($state == 1) {
305 305
 					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306 306
 				} else {
307 307
 					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327 327
 		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
328
+		if ($verifKey instanceof WSError) {
329 329
 			$this->handleError($verifKey);
330 330
 		} else {
331 331
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
332
+			if ($result instanceof WSError) {
333 333
 				$this->handleError($result);
334 334
 			}
335 335
 		}
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348 348
 		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
349
+		if ($verifKey instanceof WSError) {
350 350
 			$this->handleError($verifKey);
351 351
 		} else {
352 352
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
353
+			if ($result instanceof WSError) {
354 354
 				$this->handleError($result);
355 355
 			}
356 356
 		}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                     if ($state == 1) {
386 386
                         SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id);
387 387
                     } else {
388
-                        $user_id = array (0 => $user_id);
388
+                        $user_id = array(0 => $user_id);
389 389
                         $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id);
390 390
                         if (!$result) {
391 391
                             return new WSError(303, 'There was an error unsubscribing this Teacher from the session');
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459 459
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
460
+		if ($session_id instanceof WSError) {
461 461
 			return $session_id;
462 462
 		} else {
463 463
 			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
464
+			if ($course_id instanceof WSError) {
465 465
 				return $course_id;
466 466
 			} else {
467
-				if($state  == 1) {
467
+				if ($state == 1) {
468 468
 					SessionManager::add_courses_to_session($session_id, array($course_id));
469 469
 					return true;
470 470
 				} else {
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492 492
 		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
493
+		if ($verifKey instanceof WSError) {
494 494
 			$this->handleError($verifKey);
495 495
 		} else {
496 496
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
497
+			if ($result instanceof WSError) {
498 498
 				$this->handleError($result);
499 499
 			}
500 500
 		}
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	 */
512 512
 	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513 513
 		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
514
+		if ($verifKey instanceof WSError) {
515 515
 			$this->handleError($verifKey);
516 516
 		} else {
517 517
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
518
+			if ($result instanceof WSError) {
519 519
 				$this->handleError($result);
520 520
 			}
521 521
 		}
Please login to merge, or discard this patch.
main/webservices/webservice_user.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -36,6 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param array Users
38 38
 	 * @param int Set to 1 to enable and to 0 to disable
39
+	 * @param integer $state
39 40
 	 * @return array Array of results
40 41
 	 */
41 42
 	protected function changeUsersActiveState($users, $state) {
@@ -217,6 +218,11 @@  discard block
 block discarded – undo
217 218
 	 * @param string Phone.
218 219
 	 * @param string Expiration date
219 220
 	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
221
+	 * @param integer|null $visibility
222
+	 * @param string|null $email
223
+	 * @param string|null $language
224
+	 * @param string|null $phone
225
+	 * @param string|null $expiration_date
220 226
 	 * @return mixed New user id generated by the system, WSError otherwise
221 227
 	 */
222 228
 	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
Please login to merge, or discard this patch.
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -11,458 +11,458 @@
 block discarded – undo
11 11
  */
12 12
 class WSUser extends WS {
13 13
 
14
-	/**
15
-	 * Enables or disables a user
16
-	 *
17
-	 * @param string User id field name
18
-	 * @param string User id value
19
-	 * @param int Set to 1 to enable and to 0 to disable
20
-	 */
21
-	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
24
-			return $user_id;
25
-		} else {
26
-			if($state == 0) {
27
-				UserManager::disable($user_id);
28
-			} else if($state == 1) {
29
-				UserManager::enable($user_id);
30
-			}
31
-		}
32
-	}
14
+    /**
15
+     * Enables or disables a user
16
+     *
17
+     * @param string User id field name
18
+     * @param string User id value
19
+     * @param int Set to 1 to enable and to 0 to disable
20
+     */
21
+    protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
+        if($user_id instanceof WSError) {
24
+            return $user_id;
25
+        } else {
26
+            if($state == 0) {
27
+                UserManager::disable($user_id);
28
+            } else if($state == 1) {
29
+                UserManager::enable($user_id);
30
+            }
31
+        }
32
+    }
33 33
 
34
-	/**
35
-	 * Enables or disables multiple users
36
-	 *
37
-	 * @param array Users
38
-	 * @param int Set to 1 to enable and to 0 to disable
39
-	 * @return array Array of results
40
-	 */
41
-	protected function changeUsersActiveState($users, $state) {
42
-		$results = array();
43
-		foreach($users as $user) {
44
-			$result_tmp = array();
45
-			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
-			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
48
-				// Return the error in the results
49
-				$result_tmp['result'] = $result_op->toArray();
50
-			} else {
51
-				$result_tmp['result'] = $this->getSuccessfulResult();
52
-			}
53
-			$results[] = $result_tmp;
54
-		}
55
-		return $results;
56
-	}
34
+    /**
35
+     * Enables or disables multiple users
36
+     *
37
+     * @param array Users
38
+     * @param int Set to 1 to enable and to 0 to disable
39
+     * @return array Array of results
40
+     */
41
+    protected function changeUsersActiveState($users, $state) {
42
+        $results = array();
43
+        foreach($users as $user) {
44
+            $result_tmp = array();
45
+            $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
+            $result_tmp['user_id_value'] = $user['user_id_value'];
47
+            if($result_op instanceof WSError) {
48
+                // Return the error in the results
49
+                $result_tmp['result'] = $result_op->toArray();
50
+            } else {
51
+                $result_tmp['result'] = $this->getSuccessfulResult();
52
+            }
53
+            $results[] = $result_tmp;
54
+        }
55
+        return $results;
56
+    }
57 57
 
58
-	/**
59
-	 * Disables a user
60
-	 *
61
-	 * @param string API secret key
62
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
-	 * @param string User id value
64
-	 */
65
-	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
-		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
68
-			// Let the implementation handle it
69
-			$this->handleError($verifKey);
70
-		} else {
71
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
73
-				$this->handleError($result);
74
-			}
75
-		}
76
-	}
58
+    /**
59
+     * Disables a user
60
+     *
61
+     * @param string API secret key
62
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
+     * @param string User id value
64
+     */
65
+    public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
+        $verifKey = $this->verifyKey($secret_key);
67
+        if($verifKey instanceof WSError) {
68
+            // Let the implementation handle it
69
+            $this->handleError($verifKey);
70
+        } else {
71
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
+            if($result instanceof WSError) {
73
+                $this->handleError($result);
74
+            }
75
+        }
76
+    }
77 77
 
78
-	/**
79
-	 * Disables multiple users
80
-	 *
81
-	 * @param string API secret key
82
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
-	 * than 0, an error occured
85
-	 */
86
-	public function DisableUsers($secret_key, $users) {
87
-		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
89
-			// Let the implementation handle it
90
-			$this->handleError($verifKey);
91
-		} else {
92
-			return $this->changeUsersActiveState($users, 0);
93
-		}
94
-	}
78
+    /**
79
+     * Disables multiple users
80
+     *
81
+     * @param string API secret key
82
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
+     * than 0, an error occured
85
+     */
86
+    public function DisableUsers($secret_key, $users) {
87
+        $verifKey = $this->verifyKey($secret_key);
88
+        if($verifKey instanceof WSError) {
89
+            // Let the implementation handle it
90
+            $this->handleError($verifKey);
91
+        } else {
92
+            return $this->changeUsersActiveState($users, 0);
93
+        }
94
+    }
95 95
 
96
-	/**
97
-	 * Enables a user
98
-	 *
99
-	 * @param string API secret key
100
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
-	 * @param string User id value
102
-	 */
103
-	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
-		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
106
-			$this->handleError($verifKey);
107
-		} else {
108
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
110
-				$this->handleError($result);
111
-			}
112
-		}
113
-	}
96
+    /**
97
+     * Enables a user
98
+     *
99
+     * @param string API secret key
100
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
+     * @param string User id value
102
+     */
103
+    public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
+        $verifKey = $this->verifyKey($secret_key);
105
+        if($verifKey instanceof WSError) {
106
+            $this->handleError($verifKey);
107
+        } else {
108
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
+            if($result instanceof WSError) {
110
+                $this->handleError($result);
111
+            }
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Enables multiple users
117
-	 *
118
-	 * @param string API secret key
119
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
-	 * than 0, an error occured
122
-	 */
123
-	public function EnableUsers($secret_key, $users) {
124
-		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
126
-			// Let the implementation handle it
127
-			$this->handleError($verifKey);
128
-		} else {
129
-			return $this->changeUsersActiveState($users, 1);
130
-		}
131
-	}
115
+    /**
116
+     * Enables multiple users
117
+     *
118
+     * @param string API secret key
119
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
+     * than 0, an error occured
122
+     */
123
+    public function EnableUsers($secret_key, $users) {
124
+        $verifKey = $this->verifyKey($secret_key);
125
+        if($verifKey instanceof WSError) {
126
+            // Let the implementation handle it
127
+            $this->handleError($verifKey);
128
+        } else {
129
+            return $this->changeUsersActiveState($users, 1);
130
+        }
131
+    }
132 132
 
133
-	/**
134
-	 * Deletes a user (helper method)
135
-	 *
136
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
-	 * @param string User id value
138
-	 * @return mixed True if user was successfully deleted, WSError otherwise
139
-	 */
140
-	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
143
-			return $user_id;
144
-		} else {
145
-			if(!UserManager::delete_user($user_id)) {
146
-				return new WSError(101, "There was a problem while deleting this user");
147
-			} else {
148
-				return true;
149
-			}
150
-		}
151
-	}
133
+    /**
134
+     * Deletes a user (helper method)
135
+     *
136
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
+     * @param string User id value
138
+     * @return mixed True if user was successfully deleted, WSError otherwise
139
+     */
140
+    protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
+        if($user_id instanceof WSError) {
143
+            return $user_id;
144
+        } else {
145
+            if(!UserManager::delete_user($user_id)) {
146
+                return new WSError(101, "There was a problem while deleting this user");
147
+            } else {
148
+                return true;
149
+            }
150
+        }
151
+    }
152 152
 
153
-	/**
154
-	 * Deletes a user
155
-	 *
156
-	 * @param string API secret key
157
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
-	 * @param string User id value
159
-	 */
160
-	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
-		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
163
-			$this->handleError($verifKey);
164
-		} else {
165
-			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
167
-				$this->handleError($result);
168
-			}
169
-		}
170
-	}
153
+    /**
154
+     * Deletes a user
155
+     *
156
+     * @param string API secret key
157
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
+     * @param string User id value
159
+     */
160
+    public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
+        $verifKey = $this->verifyKey($secret_key);
162
+        if($verifKey instanceof WSError) {
163
+            $this->handleError($verifKey);
164
+        } else {
165
+            $result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
+            if($result instanceof WSError) {
167
+                $this->handleError($result);
168
+            }
169
+        }
170
+    }
171 171
 
172
-	/**
173
-	 * Deletes multiple users
174
-	 *
175
-	 * @param string API secret key
176
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
-	 * than 0, an error occured
179
-	 */
180
-	public function DeleteUsers($secret_key, $users) {
181
-		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
183
-			$this->handleError($verifKey);
184
-		} else {
185
-			$results = array();
186
-			foreach($users as $user) {
187
-				$result_tmp = array();
188
-				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
-				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
191
-					// Return the error in the results
192
-					$result_tmp['result'] = $result_op->toArray();
193
-				} else {
194
-					$result_tmp['result'] = $this->getSuccessfulResult();
195
-				}
196
-				$results[] = $result_tmp;
197
-			}
198
-			return $results;
199
-		}
200
-	}
172
+    /**
173
+     * Deletes multiple users
174
+     *
175
+     * @param string API secret key
176
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
+     * than 0, an error occured
179
+     */
180
+    public function DeleteUsers($secret_key, $users) {
181
+        $verifKey = $this->verifyKey($secret_key);
182
+        if($verifKey instanceof WSError) {
183
+            $this->handleError($verifKey);
184
+        } else {
185
+            $results = array();
186
+            foreach($users as $user) {
187
+                $result_tmp = array();
188
+                $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
+                $result_tmp['user_id_value'] = $user['user_id_value'];
190
+                if($result_op instanceof WSError) {
191
+                    // Return the error in the results
192
+                    $result_tmp['result'] = $result_op->toArray();
193
+                } else {
194
+                    $result_tmp['result'] = $this->getSuccessfulResult();
195
+                }
196
+                $results[] = $result_tmp;
197
+            }
198
+            return $results;
199
+        }
200
+    }
201 201
 
202
-	/**
203
-	 * Creates a user (helper method)
204
-	 *
205
-	 * @param string User first name
206
-	 * @param string User last name
207
-	 * @param int User status
208
-	 * @param string Login name
209
-	 * @param string Password (encrypted or not)
210
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
-	 * to include the salt in the extra fields if you are encrypting the password
212
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
-	 * @param string User id value. Leave blank if you are using the internal user_id
214
-	 * @param int Visibility.
215
-	 * @param string User email.
216
-	 * @param string Language.
217
-	 * @param string Phone.
218
-	 * @param string Expiration date
219
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
-	 * @return mixed New user id generated by the system, WSError otherwise
221
-	 */
222
-	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
202
+    /**
203
+     * Creates a user (helper method)
204
+     *
205
+     * @param string User first name
206
+     * @param string User last name
207
+     * @param int User status
208
+     * @param string Login name
209
+     * @param string Password (encrypted or not)
210
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
+     * to include the salt in the extra fields if you are encrypting the password
212
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
+     * @param string User id value. Leave blank if you are using the internal user_id
214
+     * @param int Visibility.
215
+     * @param string User email.
216
+     * @param string Language.
217
+     * @param string Phone.
218
+     * @param string Expiration date
219
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
+     * @return mixed New user id generated by the system, WSError otherwise
221
+     */
222
+    protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
223 223
         global $api_failureList;
224
-		// Add the original user id field name and value to the extra fields if needed
225
-		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
227
-			$extras_associative[$user_id_field_name] = $user_id_value;
228
-		}
224
+        // Add the original user id field name and value to the extra fields if needed
225
+        $extras_associative = array();
226
+        if($user_id_field_name != "chamilo_user_id") {
227
+            $extras_associative[$user_id_field_name] = $user_id_value;
228
+        }
229 229
                 if (!empty($extras)) {
230 230
                     foreach($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
234
-		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
-		if (!$result) {
236
-			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
238
-				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
240
-				return new WSError(103, 'The encryption of the password is invalid');
241
-			} else {
242
-				return new WSError(104, 'There was an error creating the user');
243
-			}
244
-		} else {
245
-			return $result;
246
-		}
247
-	}
234
+        $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
+        if (!$result) {
236
+            $failure = $api_failureList[0];
237
+            if($failure == 'login-pass already taken') {
238
+                return new WSError(102, 'This username is already taken');
239
+            } else if($failure == 'encrypt_method invalid') {
240
+                return new WSError(103, 'The encryption of the password is invalid');
241
+            } else {
242
+                return new WSError(104, 'There was an error creating the user');
243
+            }
244
+        } else {
245
+            return $result;
246
+        }
247
+    }
248 248
 
249
-	/**
250
-	 * Creates a user
251
-	 *
252
-	 * @param string API secret key
253
-	 * @param string User first name
254
-	 * @param string User last name
255
-	 * @param int User status
256
-	 * @param string Login name
257
-	 * @param string Password (encrypted or not)
258
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
259
-	 * to include the salt in the extra fields if you are encrypting the password
260
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
-	 * @param string User id value. Leave blank if you are using the internal user_id
262
-	 * @param int Visibility. Set by default to 1
263
-	 * @param string User email. Set by default to an empty string
264
-	 * @param string Language. Set by default to english
265
-	 * @param string Phone. Set by default to an empty string
266
-	 * @param string Expiration date. Set to null by default
267
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
268
-	 * @return int New user id generated by the system
269
-	 */
270
-	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271
-		// First, verify the secret key
272
-		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
274
-			$this->handleError($verifKey);
275
-		} else {
276
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
278
-				$this->handleError($result);
279
-			} else {
280
-				return $result;
281
-			}
282
-		}
283
-	}
249
+    /**
250
+     * Creates a user
251
+     *
252
+     * @param string API secret key
253
+     * @param string User first name
254
+     * @param string User last name
255
+     * @param int User status
256
+     * @param string Login name
257
+     * @param string Password (encrypted or not)
258
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
259
+     * to include the salt in the extra fields if you are encrypting the password
260
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
+     * @param string User id value. Leave blank if you are using the internal user_id
262
+     * @param int Visibility. Set by default to 1
263
+     * @param string User email. Set by default to an empty string
264
+     * @param string Language. Set by default to english
265
+     * @param string Phone. Set by default to an empty string
266
+     * @param string Expiration date. Set to null by default
267
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
268
+     * @return int New user id generated by the system
269
+     */
270
+    public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271
+        // First, verify the secret key
272
+        $verifKey = $this->verifyKey($secret_key);
273
+        if($verifKey instanceof WSError) {
274
+            $this->handleError($verifKey);
275
+        } else {
276
+            $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
+            if($result instanceof WSError) {
278
+                $this->handleError($result);
279
+            } else {
280
+                return $result;
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Creates multiple users
287
-	 *
288
-	 * @param string API secret key
289
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
-	 * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
291
-	 */
292
-	public function CreateUsers($secret_key, $users) {
293
-		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
295
-			$this->handleError($verifKey);
296
-		} else {
297
-			$results = array();
298
-			foreach($users as $user) {
299
-				$result_tmp = array();
285
+    /**
286
+     * Creates multiple users
287
+     *
288
+     * @param string API secret key
289
+     * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
+     * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
291
+     */
292
+    public function CreateUsers($secret_key, $users) {
293
+        $verifKey = $this->verifyKey($secret_key);
294
+        if($verifKey instanceof WSError) {
295
+            $this->handleError($verifKey);
296
+        } else {
297
+            $results = array();
298
+            foreach($users as $user) {
299
+                $result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302
-				extract($user);
303
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
305
-					$result_tmp['result'] = $result->toArray();
306
-					$result_tmp['user_id_value'] = $user_id_value;
307
-					$result_tmp['user_id_generated'] = 0;
308
-				} else {
309
-					$result_tmp['result'] = $this->getSuccessfulResult();
310
-					$result_tmp['user_id_value'] = $user_id_value;
311
-					$result_tmp['user_id_generated'] = $result;
312
-				}
313
-				$results[] = $result_tmp;
314
-			}
315
-			return $results;
316
-		}
317
-	}
302
+                extract($user);
303
+                $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
+                if($result instanceof WSError) {
305
+                    $result_tmp['result'] = $result->toArray();
306
+                    $result_tmp['user_id_value'] = $user_id_value;
307
+                    $result_tmp['user_id_generated'] = 0;
308
+                } else {
309
+                    $result_tmp['result'] = $this->getSuccessfulResult();
310
+                    $result_tmp['user_id_value'] = $user_id_value;
311
+                    $result_tmp['user_id_generated'] = $result;
312
+                }
313
+                $results[] = $result_tmp;
314
+            }
315
+            return $results;
316
+        }
317
+    }
318 318
 
319
-	/**
320
-	 * Edits user info (helper method)
321
-	 *
322
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
-	 * @param string User id value
324
-	 * @param string First name
325
-	 * @param string Last name
326
-	 * @param int User status
327
-	 * @param string Login name
328
-	 * @param string Password. Leave blank if you don't want to update it
329
-	 * @param string Encrypt method
330
-	 * @param string User email
331
-	 * @param string Language. Set by default to english
332
-	 * @param string Phone. Set by default to an empty string
333
-	 * @param string Expiration date. Set to null by default
334
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
335
-	 * @return mixed True if user was successfully updated, WSError otherwise
336
-	 */
337
-	protected function editUserHelper(
338
-		$user_id_field_name,
339
-		$user_id_value,
340
-		$firstname,
341
-		$lastname,
342
-		$status,
343
-		$loginname,
344
-		$password,
345
-		$encrypt_method,
346
-		$email,
347
-		$language,
348
-		$phone,
349
-		$expiration_date,
350
-		$extras
351
-	) {
319
+    /**
320
+     * Edits user info (helper method)
321
+     *
322
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
+     * @param string User id value
324
+     * @param string First name
325
+     * @param string Last name
326
+     * @param int User status
327
+     * @param string Login name
328
+     * @param string Password. Leave blank if you don't want to update it
329
+     * @param string Encrypt method
330
+     * @param string User email
331
+     * @param string Language. Set by default to english
332
+     * @param string Phone. Set by default to an empty string
333
+     * @param string Expiration date. Set to null by default
334
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
335
+     * @return mixed True if user was successfully updated, WSError otherwise
336
+     */
337
+    protected function editUserHelper(
338
+        $user_id_field_name,
339
+        $user_id_value,
340
+        $firstname,
341
+        $lastname,
342
+        $status,
343
+        $loginname,
344
+        $password,
345
+        $encrypt_method,
346
+        $email,
347
+        $language,
348
+        $phone,
349
+        $expiration_date,
350
+        $extras
351
+    ) {
352 352
         global $api_failureList;
353
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
355
-			return $user_id;
356
-		} else {
357
-			if($password == '') {
358
-				$password = null;
359
-			}
360
-			$user_info = api_get_user_info($user_id);
361
-			if (count($extras) == 0) {
362
-				$extras = null;
363
-			}
353
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
+        if($user_id instanceof WSError) {
355
+            return $user_id;
356
+        } else {
357
+            if($password == '') {
358
+                $password = null;
359
+            }
360
+            $user_info = api_get_user_info($user_id);
361
+            if (count($extras) == 0) {
362
+                $extras = null;
363
+            }
364 364
 
365
-			$result = UserManager::update_user(
366
-				$user_id,
367
-				$firstname,
368
-				$lastname,
369
-				$loginname,
370
-				$password,
371
-				PLATFORM_AUTH_SOURCE,
372
-				$email,
373
-				$status,
374
-				'',
375
-				$phone,
376
-				$user_info['picture_uri'],
377
-				$expiration_date,
378
-				$user_info['active'],
379
-				null,
380
-				$user_info['hr_dept_id'],
381
-				$extras,
382
-				$encrypt_method
383
-			);
384
-			if (!$result) {
385
-				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
387
-					return new WSError(103, 'The encryption of the password is invalid');
388
-				} else {
389
-					return new WSError(105, 'There was an error updating the user');
390
-				}
391
-			} else {
392
-				return $result;
393
-			}
394
-		}
395
-	}
365
+            $result = UserManager::update_user(
366
+                $user_id,
367
+                $firstname,
368
+                $lastname,
369
+                $loginname,
370
+                $password,
371
+                PLATFORM_AUTH_SOURCE,
372
+                $email,
373
+                $status,
374
+                '',
375
+                $phone,
376
+                $user_info['picture_uri'],
377
+                $expiration_date,
378
+                $user_info['active'],
379
+                null,
380
+                $user_info['hr_dept_id'],
381
+                $extras,
382
+                $encrypt_method
383
+            );
384
+            if (!$result) {
385
+                $failure = $api_failureList[0];
386
+                if($failure == 'encrypt_method invalid') {
387
+                    return new WSError(103, 'The encryption of the password is invalid');
388
+                } else {
389
+                    return new WSError(105, 'There was an error updating the user');
390
+                }
391
+            } else {
392
+                return $result;
393
+            }
394
+        }
395
+    }
396 396
 
397
-	/**
398
-	 * Edits user info
399
-	 *
400
-	 * @param string API secret key
401
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
-	 * @param string User id value
403
-	 * @param string First name
404
-	 * @param string Last name
405
-	 * @param int User status
406
-	 * @param string Login name
407
-	 * @param string Password. Leave blank if you don't want to update it
408
-	 * @param string Encrypt method
409
-	 * @param string User email
410
-	 * @param string Language. Set by default to english
411
-	 * @param string Phone. Set by default to an empty string
412
-	 * @param string Expiration date. Set to null by default
413
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
414
-	 */
415
-	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416
-		// First, verify the secret key
417
-		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
419
-			$this->handleError($verifKey);
420
-		} else {
397
+    /**
398
+     * Edits user info
399
+     *
400
+     * @param string API secret key
401
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
+     * @param string User id value
403
+     * @param string First name
404
+     * @param string Last name
405
+     * @param int User status
406
+     * @param string Login name
407
+     * @param string Password. Leave blank if you don't want to update it
408
+     * @param string Encrypt method
409
+     * @param string User email
410
+     * @param string Language. Set by default to english
411
+     * @param string Phone. Set by default to an empty string
412
+     * @param string Expiration date. Set to null by default
413
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
414
+     */
415
+    public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416
+        // First, verify the secret key
417
+        $verifKey = $this->verifyKey($secret_key);
418
+        if($verifKey instanceof WSError) {
419
+            $this->handleError($verifKey);
420
+        } else {
421 421
 
422
-			$extras_associative = array();
423
-			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
425
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
426
-				}
427
-			}
422
+            $extras_associative = array();
423
+            if (!empty($extras)) {
424
+                foreach($extras as $extra) {
425
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
426
+                }
427
+            }
428 428
 
429
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
431
-				$this->handleError($result);
432
-			}
433
-		}
434
-	}
429
+            $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
+            if($result instanceof WSError) {
431
+                $this->handleError($result);
432
+            }
433
+        }
434
+    }
435 435
 
436
-	/**
437
-	 * Edits multiple users
438
-	 *
439
-	 * @param string API secret key
440
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
442
-	 * than 0, an error occured
443
-	 */
444
-	public function EditUsers($secret_key, $users) {
445
-		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
447
-			$this->handleError($verifKey);
448
-		} else {
449
-			$results = array();
450
-			foreach($users as $user) {
451
-				$result_tmp = array();
436
+    /**
437
+     * Edits multiple users
438
+     *
439
+     * @param string API secret key
440
+     * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
442
+     * than 0, an error occured
443
+     */
444
+    public function EditUsers($secret_key, $users) {
445
+        $verifKey = $this->verifyKey($secret_key);
446
+        if($verifKey instanceof WSError) {
447
+            $this->handleError($verifKey);
448
+        } else {
449
+            $results = array();
450
+            foreach($users as $user) {
451
+                $result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454
-				extract($user);
455
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
-				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
458
-					// Return the error in the results
459
-					$result_tmp['result'] = $result_op->toArray();
460
-				} else {
461
-					$result_tmp['result'] = $this->getSuccessfulResult();
462
-				}
463
-				$results[] = $result_tmp;
464
-			}
465
-			return $results;
466
-		}
467
-	}
454
+                extract($user);
455
+                $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
+                $result_tmp['user_id_value'] = $user['user_id_value'];
457
+                if($result_op instanceof WSError) {
458
+                    // Return the error in the results
459
+                    $result_tmp['result'] = $result_op->toArray();
460
+                } else {
461
+                    $result_tmp['result'] = $this->getSuccessfulResult();
462
+                }
463
+                $results[] = $result_tmp;
464
+            }
465
+            return $results;
466
+        }
467
+    }
468 468
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22 22
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
23
+		if ($user_id instanceof WSError) {
24 24
 			return $user_id;
25 25
 		} else {
26
-			if($state == 0) {
26
+			if ($state == 0) {
27 27
 				UserManager::disable($user_id);
28
-			} else if($state == 1) {
28
+			} else if ($state == 1) {
29 29
 				UserManager::enable($user_id);
30 30
 			}
31 31
 		}
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected function changeUsersActiveState($users, $state) {
42 42
 		$results = array();
43
-		foreach($users as $user) {
43
+		foreach ($users as $user) {
44 44
 			$result_tmp = array();
45 45
 			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46 46
 			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
47
+			if ($result_op instanceof WSError) {
48 48
 				// Return the error in the results
49 49
 				$result_tmp['result'] = $result_op->toArray();
50 50
 			} else {
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66 66
 		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
67
+		if ($verifKey instanceof WSError) {
68 68
 			// Let the implementation handle it
69 69
 			$this->handleError($verifKey);
70 70
 		} else {
71 71
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
72
+			if ($result instanceof WSError) {
73 73
 				$this->handleError($result);
74 74
 			}
75 75
 		}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function DisableUsers($secret_key, $users) {
87 87
 		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
88
+		if ($verifKey instanceof WSError) {
89 89
 			// Let the implementation handle it
90 90
 			$this->handleError($verifKey);
91 91
 		} else {
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104 104
 		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
105
+		if ($verifKey instanceof WSError) {
106 106
 			$this->handleError($verifKey);
107 107
 		} else {
108 108
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
109
+			if ($result instanceof WSError) {
110 110
 				$this->handleError($result);
111 111
 			}
112 112
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function EnableUsers($secret_key, $users) {
124 124
 		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
125
+		if ($verifKey instanceof WSError) {
126 126
 			// Let the implementation handle it
127 127
 			$this->handleError($verifKey);
128 128
 		} else {
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141 141
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
142
+		if ($user_id instanceof WSError) {
143 143
 			return $user_id;
144 144
 		} else {
145
-			if(!UserManager::delete_user($user_id)) {
145
+			if (!UserManager::delete_user($user_id)) {
146 146
 				return new WSError(101, "There was a problem while deleting this user");
147 147
 			} else {
148 148
 				return true;
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161 161
 		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
162
+		if ($verifKey instanceof WSError) {
163 163
 			$this->handleError($verifKey);
164 164
 		} else {
165 165
 			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
166
+			if ($result instanceof WSError) {
167 167
 				$this->handleError($result);
168 168
 			}
169 169
 		}
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function DeleteUsers($secret_key, $users) {
181 181
 		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
182
+		if ($verifKey instanceof WSError) {
183 183
 			$this->handleError($verifKey);
184 184
 		} else {
185 185
 			$results = array();
186
-			foreach($users as $user) {
186
+			foreach ($users as $user) {
187 187
 				$result_tmp = array();
188 188
 				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189 189
 				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
190
+				if ($result_op instanceof WSError) {
191 191
 					// Return the error in the results
192 192
 					$result_tmp['result'] = $result_op->toArray();
193 193
 				} else {
@@ -223,20 +223,20 @@  discard block
 block discarded – undo
223 223
         global $api_failureList;
224 224
 		// Add the original user id field name and value to the extra fields if needed
225 225
 		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
226
+		if ($user_id_field_name != "chamilo_user_id") {
227 227
 			$extras_associative[$user_id_field_name] = $user_id_value;
228 228
 		}
229 229
                 if (!empty($extras)) {
230
-                    foreach($extras as $extra) {
230
+                    foreach ($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
234 234
 		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235 235
 		if (!$result) {
236 236
 			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
237
+			if ($failure == 'login-pass already taken') {
238 238
 				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
239
+			} else if ($failure == 'encrypt_method invalid') {
240 240
 				return new WSError(103, 'The encryption of the password is invalid');
241 241
 			} else {
242 242
 				return new WSError(104, 'There was an error creating the user');
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271 271
 		// First, verify the secret key
272 272
 		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
273
+		if ($verifKey instanceof WSError) {
274 274
 			$this->handleError($verifKey);
275 275
 		} else {
276 276
 			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
277
+			if ($result instanceof WSError) {
278 278
 				$this->handleError($result);
279 279
 			} else {
280 280
 				return $result;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function CreateUsers($secret_key, $users) {
293 293
 		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
294
+		if ($verifKey instanceof WSError) {
295 295
 			$this->handleError($verifKey);
296 296
 		} else {
297 297
 			$results = array();
298
-			foreach($users as $user) {
298
+			foreach ($users as $user) {
299 299
 				$result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302 302
 				extract($user);
303 303
 				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
304
+				if ($result instanceof WSError) {
305 305
 					$result_tmp['result'] = $result->toArray();
306 306
 					$result_tmp['user_id_value'] = $user_id_value;
307 307
 					$result_tmp['user_id_generated'] = 0;
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 	) {
352 352
         global $api_failureList;
353 353
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
354
+		if ($user_id instanceof WSError) {
355 355
 			return $user_id;
356 356
 		} else {
357
-			if($password == '') {
357
+			if ($password == '') {
358 358
 				$password = null;
359 359
 			}
360 360
 			$user_info = api_get_user_info($user_id);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			);
384 384
 			if (!$result) {
385 385
 				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
386
+				if ($failure == 'encrypt_method invalid') {
387 387
 					return new WSError(103, 'The encryption of the password is invalid');
388 388
 				} else {
389 389
 					return new WSError(105, 'There was an error updating the user');
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
 	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416 416
 		// First, verify the secret key
417 417
 		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
418
+		if ($verifKey instanceof WSError) {
419 419
 			$this->handleError($verifKey);
420 420
 		} else {
421 421
 
422 422
 			$extras_associative = array();
423 423
 			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
424
+				foreach ($extras as $extra) {
425 425
 					$extras_associative[$extra['field_name']] = $extra['field_value'];
426 426
 				}
427 427
 			}
428 428
 
429 429
 			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
430
+			if ($result instanceof WSError) {
431 431
 				$this->handleError($result);
432 432
 			}
433 433
 		}
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function EditUsers($secret_key, $users) {
445 445
 		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
446
+		if ($verifKey instanceof WSError) {
447 447
 			$this->handleError($verifKey);
448 448
 		} else {
449 449
 			$results = array();
450
-			foreach($users as $user) {
450
+			foreach ($users as $user) {
451 451
 				$result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454 454
 				extract($user);
455 455
 				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456 456
 				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
457
+				if ($result_op instanceof WSError) {
458 458
 					// Return the error in the results
459 459
 					$result_tmp['result'] = $result_op->toArray();
460 460
 				} else {
Please login to merge, or discard this patch.
main/wiki/wiki.inc.php 3 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use Chamilo\CoreBundle\Component\Editor\Connector;
5 4
 use Chamilo\CoreBundle\Component\Filesystem\Data;
6 5
 use ChamiloSession as Session;
7
-use MediaAlchemyst\Alchemyst;
8
-use MediaAlchemyst\DriversContainer;
9
-use Neutron\TemporaryFilesystem\Manager;
10
-use Neutron\TemporaryFilesystem\TemporaryFilesystem;
11
-use Symfony\Component\Filesystem\Filesystem;
12 6
 
13 7
 /**
14 8
  * Class Wiki
Please login to merge, or discard this patch.
Spacing   +648 added lines, -648 removed lines patch added patch discarded remove patch
@@ -99,25 +99,25 @@  discard block
 block discarded – undo
99 99
      **/
100 100
     public function links_to($input)
101 101
     {
102
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
102
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
103 103
         $all_links = array();
104 104
 
105 105
         foreach ($input_array as $key=>$value) {
106
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' &&
107
-                isset($input_array[$key+1]) && $input_array[$key+1] == ']]'
106
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' &&
107
+                isset($input_array[$key + 1]) && $input_array[$key + 1] == ']]'
108 108
             ) {
109 109
                 if (api_strpos($value, "|") !== false) {
110
-                    $full_link_array=explode("|", $value);
111
-                    $link=trim($full_link_array[0]);
112
-                    $title=trim($full_link_array[1]);
110
+                    $full_link_array = explode("|", $value);
111
+                    $link = trim($full_link_array[0]);
112
+                    $title = trim($full_link_array[1]);
113 113
                 } else {
114
-                    $link=trim($value);
115
-                    $title=trim($value);
114
+                    $link = trim($value);
115
+                    $title = trim($value);
116 116
                 }
117
-                unset($input_array[$key-1]);
118
-                unset($input_array[$key+1]);
117
+                unset($input_array[$key - 1]);
118
+                unset($input_array[$key + 1]);
119 119
                 //replace blank spaces by _ within the links. But to remove links at the end add a blank space
120
-                $all_links[]= Database::escape_string(str_replace(' ','_',$link)).' ';
120
+                $all_links[] = Database::escape_string(str_replace(' ', '_', $link)).' ';
121 121
             }
122 122
         }
123 123
         $output = implode($all_links);
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      **/
132 132
     public function detect_external_link($input)
133 133
     {
134
-        $exlink='href=';
135
-        $exlinkStyle='class="wiki_link_ext" href=';
136
-        $output=str_replace($exlink, $exlinkStyle, $input);
134
+        $exlink = 'href=';
135
+        $exlinkStyle = 'class="wiki_link_ext" href=';
136
+        $output = str_replace($exlink, $exlinkStyle, $input);
137 137
         return $output;
138 138
     }
139 139
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function detect_anchor_link($input)
145 145
     {
146 146
         $anchorlink = 'href="#';
147
-        $anchorlinkStyle='class="wiki_anchor_link" href="#';
147
+        $anchorlinkStyle = 'class="wiki_anchor_link" href="#';
148 148
         $output = str_replace($anchorlink, $anchorlinkStyle, $input);
149 149
 
150 150
         return $output;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      **/
170 170
     public function detect_ftp_link($input)
171 171
     {
172
-        $ftplink='href="ftp';
172
+        $ftplink = 'href="ftp';
173 173
         $ftplinkStyle = 'class="wiki_ftp_link" href="ftp';
174 174
         $output = str_replace($ftplink, $ftplinkStyle, $input);
175 175
 
@@ -214,21 +214,21 @@  discard block
 block discarded – undo
214 214
     {
215 215
         $groupId = api_get_group_id();
216 216
         //now doubles brackets
217
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
217
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
218 218
 
219 219
         foreach ($input_array as $key => $value) {
220 220
             //now doubles brackets
221
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND
222
-                $input_array[$key+1] == ']]'
221
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' AND
222
+                $input_array[$key + 1] == ']]'
223 223
             ) {
224 224
                 // now full wikilink
225
-                if (api_strpos($value, "|") !== false){
226
-                    $full_link_array=explode("|", $value);
227
-                    $link=trim(strip_tags($full_link_array[0]));
228
-                    $title=trim($full_link_array[1]);
225
+                if (api_strpos($value, "|") !== false) {
226
+                    $full_link_array = explode("|", $value);
227
+                    $link = trim(strip_tags($full_link_array[0]));
228
+                    $title = trim($full_link_array[1]);
229 229
                 } else {
230
-                    $link=trim(strip_tags($value));
231
-                    $title=trim($value);
230
+                    $link = trim(strip_tags($value));
231
+                    $title = trim($value);
232 232
                 }
233 233
 
234 234
                 //if wikilink is homepage
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
                 }
241 241
 
242 242
                 // note: checkreflink checks if the link is still free. If it is not used then it returns true, if it is used, then it returns false. Now the title may be different
243
-                if (self::checktitle(strtolower(str_replace(' ','_',$link)))) {
243
+                if (self::checktitle(strtolower(str_replace(' ', '_', $link)))) {
244 244
                     $link = api_html_entity_decode($link);
245
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
245
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
246 246
                 } else {
247
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ','_',$link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
247
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ', '_', $link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
248 248
                 }
249
-                unset($input_array[$key-1]);
250
-                unset($input_array[$key+1]);
249
+                unset($input_array[$key - 1]);
250
+                unset($input_array[$key + 1]);
251 251
             }
252 252
         }
253
-        $output = implode('',$input_array);
253
+        $output = implode('', $input_array);
254 254
         return $output;
255 255
     }
256 256
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
         // are not made here, but through the interce buttons
293 293
 
294 294
         // cleaning the variables
295
-        if (api_get_setting('htmlpurifier_wiki') == 'true'){
295
+        if (api_get_setting('htmlpurifier_wiki') == 'true') {
296 296
             //$purifier = new HTMLPurifier();
297 297
             $values['content'] = Security::remove_XSS($values['content']);
298 298
         }
299
-        $version = intval($values['version']) + 1 ;
299
+        $version = intval($values['version']) + 1;
300 300
         $linkTo = self::links_to($values['content']); //and check links content
301 301
 
302 302
         //cleaning config variables
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $_clean['startdate_assig'] = '0000-00-00 00:00:00';
320 320
         }
321 321
 
322
-        if (isset($values['initenddate']) && $values['initenddate']==1) {
322
+        if (isset($values['initenddate']) && $values['initenddate'] == 1) {
323 323
             $_clean['enddate_assig'] = $values['enddate_assig'];
324 324
         } else {
325 325
             $_clean['enddate_assig'] = '0000-00-00 00:00:00';
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         }
331 331
 
332 332
         if (!empty($values['max_text']) || !empty($values['max_version'])) {
333
-            $_clean['max_text']	= $values['max_text'];
333
+            $_clean['max_text'] = $values['max_text'];
334 334
             $_clean['max_version'] = $values['max_version'];
335 335
         }
336 336
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                 $groupId
380 380
             );
381 381
 
382
-            if ($values['page_id']== 0) {
382
+            if ($values['page_id'] == 0) {
383 383
                 $sql = 'UPDATE '.$tbl_wiki.' SET page_id="'.$id.'"
384 384
                         WHERE c_id = '.$course_id.' AND iid ="'.$id.'"';
385 385
                 Database::query($sql);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         $_course = $this->courseInfo;
464 464
         $r_user_id = api_get_user_id();
465 465
         $r_dtime = api_get_utc_datetime();
466
-        $r_version = $r_version+1;
466
+        $r_version = $r_version + 1;
467 467
         $r_comment = get_lang('RestoredFromVersion').': '.$c_version;
468 468
         $session_id = api_get_session_id();
469 469
         $course_id = api_get_course_int_id();
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
         // Unlike ordinary pages of pages of assignments.
569 569
         // Allow create a ordinary page although there is a assignment with the same name
570 570
         if ($_clean['assignment'] == 2 || $_clean['assignment'] == 1) {
571
-            $page = str_replace(' ','_',$values['title']."_uass".$assig_user_id);
571
+            $page = str_replace(' ', '_', $values['title']."_uass".$assig_user_id);
572 572
         } else {
573
-            $page = str_replace(' ','_',$values['title']);
573
+            $page = str_replace(' ', '_', $values['title']);
574 574
         }
575 575
         $_clean['reflink'] = $page;
576 576
         $_clean['title']   = trim($values['title']);
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
         $groupId = api_get_group_id();
608 608
 
609
-        $_clean['linksto'] = self::links_to($_clean['content']);	//check wikilinks
609
+        $_clean['linksto'] = self::links_to($_clean['content']); //check wikilinks
610 610
 
611 611
         // cleaning config variables
612 612
         $_clean['task'] = isset($values['task']) ? $values['task'] : '';
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
      */
723 723
     public function setForm($form, $row = array())
724 724
     {
725
-        $toolBar = api_is_allowed_to_edit(null,true)
725
+        $toolBar = api_is_allowed_to_edit(null, true)
726 726
             ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
727 727
             : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student');
728 728
 
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 
734 734
         $form->addElement('select', 'progress', get_lang('Progress'), $progress);
735 735
 
736
-        if ((api_is_allowed_to_edit(false,true) ||
736
+        if ((api_is_allowed_to_edit(false, true) ||
737 737
             api_is_platform_admin()) &&
738 738
             isset($row['reflink']) && $row['reflink'] != 'index'
739 739
         ) {
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
         if ($newtitle) {
874 874
             $pageMIX = $newtitle; //display the page after it is created
875 875
         } else {
876
-            $pageMIX = $page;//display current page
876
+            $pageMIX = $page; //display current page
877 877
         }
878 878
 
879 879
         $filter = null;
880 880
         if (isset($_GET['view']) && $_GET['view']) {
881 881
             $_clean['view'] = Database::escape_string($_GET['view']);
882
-            $filter =' AND w.id="'.$_clean['view'].'"';
882
+            $filter = ' AND w.id="'.$_clean['view'].'"';
883 883
         }
884 884
 
885 885
         // First, check page visibility in the first page version
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
         }
922 922
 
923 923
         // if both are empty and we are displaying the index page then we display the default text.
924
-        if ($row['content']=='' && $row['title']=='' && $page=='index') {
924
+        if ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
925 925
             if (api_is_allowed_to_edit(false, true) ||
926 926
                 api_is_platform_admin() ||
927 927
                 GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
928 928
             ) {
929 929
                 //Table structure for better export to pdf
930
-                $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
931
-                $default_table_for_content_End='</td></tr></table>';
930
+                $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
931
+                $default_table_for_content_End = '</td></tr></table>';
932 932
                 $content = $default_table_for_content_Start.
933 933
                     sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).
934 934
                     $default_table_for_content_End;
@@ -943,23 +943,23 @@  discard block
 block discarded – undo
943 943
 
944 944
         //assignment mode: identify page type
945 945
         $icon_assignment = null;
946
-        if ($row['assignment']==1) {
947
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
948
-        } elseif($row['assignment']==2) {
949
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
946
+        if ($row['assignment'] == 1) {
947
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
948
+        } elseif ($row['assignment'] == 2) {
949
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
950 950
         }
951 951
 
952 952
         //task mode
953 953
         $icon_task = null;
954 954
         if (!empty($row['task'])) {
955
-            $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
955
+            $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
956 956
         }
957 957
 
958 958
         // Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view
959 959
         if ($KeyVisibility == "1" ||
960 960
             api_is_allowed_to_edit(false, true) ||
961 961
             api_is_platform_admin() ||
962
-            ($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id']))
962
+            ($row['assignment'] == 2 && $KeyVisibility == "0" && (api_get_user_id() == $row['user_id']))
963 963
         ) {
964 964
             $actionsLeft = '';
965 965
 
@@ -984,13 +984,13 @@  discard block
 block discarded – undo
984 984
             $protect_page = null;
985 985
             $lock_unlock_protect = null;
986 986
             // page action: protecting (locking) the page
987
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
988
-                if (self::check_protect_page()==1) {
987
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
988
+                if (self::check_protect_page() == 1) {
989 989
                     $protect_page = Display::return_icon('lock.png', get_lang('PageLockedExtra'), '', ICON_SIZE_MEDIUM);
990
-                    $lock_unlock_protect='unlock';
990
+                    $lock_unlock_protect = 'unlock';
991 991
                 } else {
992 992
                     $protect_page = Display::return_icon('unlock.png', get_lang('PageUnlockedExtra'), '', ICON_SIZE_MEDIUM);
993
-                    $lock_unlock_protect='lock';
993
+                    $lock_unlock_protect = 'lock';
994 994
                 }
995 995
             }
996 996
 
@@ -1002,13 +1002,13 @@  discard block
 block discarded – undo
1002 1002
             $visibility_page = null;
1003 1003
             $lock_unlock_visibility = null;
1004 1004
             //page action: visibility
1005
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1005
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1006 1006
                 if (self::check_visibility_page() == 1) {
1007
-                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'),'', ICON_SIZE_MEDIUM);
1007
+                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'), '', ICON_SIZE_MEDIUM);
1008 1008
                     $lock_unlock_visibility = 'invisible';
1009 1009
 
1010 1010
                 } else {
1011
-                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'),'', ICON_SIZE_MEDIUM);
1011
+                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'), '', ICON_SIZE_MEDIUM);
1012 1012
                     $lock_unlock_visibility = 'visible';
1013 1013
                 }
1014 1014
             }
@@ -1020,11 +1020,11 @@  discard block
 block discarded – undo
1020 1020
 
1021 1021
             //page action: notification
1022 1022
             if (api_is_allowed_to_session_edit()) {
1023
-                if (self::check_notify_page($page)==1) {
1024
-                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_MEDIUM);
1023
+                if (self::check_notify_page($page) == 1) {
1024
+                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_MEDIUM);
1025 1025
                     $lock_unlock_notify_page = 'unlocknotify';
1026 1026
                 } else {
1027
-                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_MEDIUM);
1027
+                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_MEDIUM);
1028 1028
                     $lock_unlock_notify_page = 'locknotify';
1029 1029
                 }
1030 1030
             }
@@ -1036,33 +1036,33 @@  discard block
 block discarded – undo
1036 1036
                 ) {
1037 1037
                     // menu discuss page
1038 1038
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=discuss&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('discuss').'>'.
1039
-                        Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1039
+                        Display::return_icon('discuss.png', get_lang('DiscussThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1040 1040
                 }
1041 1041
 
1042 1042
                 //menu history
1043 1043
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=history&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('history').'>'.
1044
-                    Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>';
1044
+                    Display::return_icon('history.png', get_lang('ShowPageHistory'), '', ICON_SIZE_MEDIUM).'</a>';
1045 1045
                 //menu linkspages
1046 1046
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'action=links&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('links').'>'.
1047
-                    Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>';
1047
+                    Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_MEDIUM).'</a>';
1048 1048
 
1049 1049
                 //menu delete wikipage
1050
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1050
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1051 1051
                     $actionsRight .= '<a href="index.php?action=delete&'.api_get_cidreq().'&title='.api_htmlentities(urlencode($page)).'"'.self::is_active_navigation_tab('delete').'>'.
1052
-                        Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1052
+                        Display::return_icon('delete.png', get_lang('DeleteThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1053 1053
                 }
1054 1054
 
1055 1055
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=showpage&actionpage='.$lock_unlock_notify_page.'&title='.api_htmlentities(urlencode($page)).'">'.
1056 1056
                     $notify_page.'</a>';
1057 1057
 
1058 1058
                 // Page action: copy last version to doc area
1059
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1059
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1060 1060
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export2doc&wiki_id='.$row['id'].'">'.
1061 1061
                         Display::return_icon('export_to_documents.png', get_lang('ExportToDocArea'), '', ICON_SIZE_MEDIUM).'</a>';
1062 1062
                 }
1063 1063
 
1064 1064
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf&wiki_id='.$row['id'].'">'.
1065
-                    Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
1065
+                    Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
1066 1066
 
1067 1067
                 $unoconv = api_get_configuration_value('unoconv.binaries');
1068 1068
                 if ($unoconv) {
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
                     )
1119 1119
                 );
1120 1120
 
1121
-            $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress']*10).'%&nbsp;&nbsp;&nbsp;'.get_lang('Rating').': '.$row['score'].'&nbsp;&nbsp;&nbsp;'.get_lang('Words').': '.self::word_count($content).'</div>';
1121
+            $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress'] * 10).'%&nbsp;&nbsp;&nbsp;'.get_lang('Rating').': '.$row['score'].'&nbsp;&nbsp;&nbsp;'.get_lang('Words').': '.self::word_count($content).'</div>';
1122 1122
 
1123 1123
             echo Display::panel($pageWiki, $pageTitle, $footerWiki);
1124 1124
         } //end filter visibility
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 
1143 1143
         # strip all html tags
1144 1144
         $wc = strip_tags($document);
1145
-        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8');// TODO:test also old html_entity_decode(utf8_encode($wc))
1145
+        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8'); // TODO:test also old html_entity_decode(utf8_encode($wc))
1146 1146
 
1147 1147
         # remove 'words' that don't consist of alphanumerical characters or punctuation. And fix accents and some letters
1148 1148
         $pattern = "#[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@|á|é|í|ó|ú|à|è|ì|ò|ù|ä|ë|ï|ö|ü|Á|É|Í|Ó|Ú|À|È|Ò|Ù|Ä|Ë|Ï|Ö|Ü|â|ê|î|ô|û|Â|Ê|Î|Ô|Û|ñ|Ñ|ç|Ç)]+#";
@@ -1175,15 +1175,15 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
         $course_id = api_get_course_int_id();
1177 1177
 
1178
-        $sql='SELECT id FROM '.$tbl_wiki.'
1178
+        $sql = 'SELECT id FROM '.$tbl_wiki.'
1179 1179
               WHERE
1180 1180
                 c_id = '.$course_id.' AND
1181 1181
                 title="'.Database::escape_string($title).'" AND
1182 1182
                 '.$groupfilter.$condition_session.'
1183 1183
               ORDER BY id ASC';
1184
-        $result=Database::query($sql);
1185
-        $cant=Database::num_rows($result);
1186
-        if ($cant>0) {
1184
+        $result = Database::query($sql);
1185
+        $cant = Database::num_rows($result);
1186
+        if ($cant > 0) {
1187 1187
             return true;
1188 1188
         } else {
1189 1189
             return false;
@@ -1265,20 +1265,20 @@  discard block
 block discarded – undo
1265 1265
         $page = $this->page;
1266 1266
 
1267 1267
         $course_id = api_get_course_int_id();
1268
-        $sql='SELECT * FROM '.$tbl_wiki.'
1268
+        $sql = 'SELECT * FROM '.$tbl_wiki.'
1269 1269
               WHERE
1270 1270
                 c_id = '.$course_id.' AND
1271 1271
                 reflink="'.Database::escape_string($page).'" AND
1272 1272
                 '.$groupfilter.$condition_session.'
1273 1273
               ORDER BY id ASC';
1274 1274
 
1275
-        $result=Database::query($sql);
1276
-        $row=Database::fetch_array($result);
1275
+        $result = Database::query($sql);
1276
+        $row = Database::fetch_array($result);
1277 1277
         $status_editlock = $row['editlock'];
1278 1278
         $id = $row['id'];
1279 1279
 
1280 1280
         ///change status
1281
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1281
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1282 1282
             if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lock' && $status_editlock == 0) {
1283 1283
                 $status_editlock = 1;
1284 1284
             }
@@ -1290,13 +1290,13 @@  discard block
 block discarded – undo
1290 1290
                     WHERE c_id = '.$course_id.' AND id="'.$id.'"';
1291 1291
             Database::query($sql);
1292 1292
 
1293
-            $sql='SELECT * FROM '.$tbl_wiki.'
1293
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1294 1294
                   WHERE
1295 1295
                     c_id = '.$course_id.' AND
1296 1296
                     reflink="'.Database::escape_string($page).'" AND
1297 1297
                     '.$groupfilter.$condition_session.'
1298 1298
                   ORDER BY id ASC';
1299
-            $result=Database::query($sql);
1299
+            $result = Database::query($sql);
1300 1300
             $row = Database::fetch_array($result);
1301 1301
         }
1302 1302
 
@@ -1327,13 +1327,13 @@  discard block
 block discarded – undo
1327 1327
         $row = Database::fetch_array($result);
1328 1328
         $status_visibility = $row['visibility'];
1329 1329
         //change status
1330
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1331
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='visible' && $status_visibility==0) {
1332
-                $status_visibility=1;
1330
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1331
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'visible' && $status_visibility == 0) {
1332
+                $status_visibility = 1;
1333 1333
 
1334 1334
             }
1335
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='invisible' && $status_visibility==1) {
1336
-                $status_visibility=0;
1335
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'invisible' && $status_visibility == 1) {
1336
+                $status_visibility = 0;
1337 1337
             }
1338 1338
 
1339 1339
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility="'.Database::escape_string($status_visibility).'"
@@ -1350,12 +1350,12 @@  discard block
 block discarded – undo
1350 1350
                         reflink="'.Database::escape_string($page).'" AND
1351 1351
                         '.$groupfilter.$condition_session.'
1352 1352
                     ORDER BY id ASC';
1353
-            $result=Database::query($sql);
1353
+            $result = Database::query($sql);
1354 1354
             $row = Database::fetch_array($result);
1355 1355
         }
1356 1356
 
1357 1357
         if (empty($row['id'])) {
1358
-            $row['visibility']= 1;
1358
+            $row['visibility'] = 1;
1359 1359
         }
1360 1360
 
1361 1361
         //show status
@@ -1382,18 +1382,18 @@  discard block
 block discarded – undo
1382 1382
                     reflink="'.Database::escape_string($page).'" AND
1383 1383
                     '.$groupfilter.$condition_session.'
1384 1384
                 ORDER BY id ASC';
1385
-        $result=Database::query($sql);
1386
-        $row=Database::fetch_array($result);
1385
+        $result = Database::query($sql);
1386
+        $row = Database::fetch_array($result);
1387 1387
 
1388 1388
         $status_visibility_disc = $row['visibility_disc'];
1389 1389
 
1390 1390
         //change status
1391
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1392
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='showdisc' && $status_visibility_disc==0) {
1393
-                $status_visibility_disc=1;
1391
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1392
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'showdisc' && $status_visibility_disc == 0) {
1393
+                $status_visibility_disc = 1;
1394 1394
             }
1395
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='hidedisc' && $status_visibility_disc==1) {
1396
-                $status_visibility_disc=0;
1395
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'hidedisc' && $status_visibility_disc == 1) {
1396
+                $status_visibility_disc = 0;
1397 1397
             }
1398 1398
 
1399 1399
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'"
@@ -1441,14 +1441,14 @@  discard block
 block discarded – undo
1441 1441
         $result = Database::query($sql);
1442 1442
         $row = Database::fetch_array($result);
1443 1443
 
1444
-        $status_addlock_disc=$row['addlock_disc'];
1444
+        $status_addlock_disc = $row['addlock_disc'];
1445 1445
 
1446 1446
         //change status
1447 1447
         if (api_is_allowed_to_edit() || api_is_platform_admin()) {
1448
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockdisc' && $status_addlock_disc==0) {
1448
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockdisc' && $status_addlock_disc == 0) {
1449 1449
                 $status_addlock_disc = 1;
1450 1450
             }
1451
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockdisc' && $status_addlock_disc==1) {
1451
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockdisc' && $status_addlock_disc == 1) {
1452 1452
                 $status_addlock_disc = 0;
1453 1453
             }
1454 1454
 
@@ -1470,8 +1470,8 @@  discard block
 block discarded – undo
1470 1470
                         reflink="'.Database::escape_string($page).'" AND
1471 1471
                         '.$groupfilter.$condition_session.'
1472 1472
                     ORDER BY id ASC';
1473
-            $result=Database::query($sql);
1474
-            $row=Database::fetch_array($result);
1473
+            $result = Database::query($sql);
1474
+            $row = Database::fetch_array($result);
1475 1475
         }
1476 1476
 
1477 1477
         return $row['addlock_disc'];
@@ -1496,17 +1496,17 @@  discard block
 block discarded – undo
1496 1496
                     reflink="'.Database::escape_string($page).'" AND
1497 1497
                     '.$groupfilter.$condition_session.'
1498 1498
                 ORDER BY id ASC';
1499
-        $result=Database::query($sql);
1500
-        $row=Database::fetch_array($result);
1501
-        $status_ratinglock_disc=$row['ratinglock_disc'];
1499
+        $result = Database::query($sql);
1500
+        $row = Database::fetch_array($result);
1501
+        $status_ratinglock_disc = $row['ratinglock_disc'];
1502 1502
 
1503 1503
         //change status
1504
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1505
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockrating' && $status_ratinglock_disc==0) {
1506
-                $status_ratinglock_disc=1;
1504
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1505
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockrating' && $status_ratinglock_disc == 0) {
1506
+                $status_ratinglock_disc = 1;
1507 1507
             }
1508
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockrating' && $status_ratinglock_disc==1) {
1509
-                $status_ratinglock_disc=0;
1508
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockrating' && $status_ratinglock_disc == 1) {
1509
+                $status_ratinglock_disc = 0;
1510 1510
             }
1511 1511
 
1512 1512
             $sql = 'UPDATE '.$tbl_wiki.'
@@ -1522,14 +1522,14 @@  discard block
 block discarded – undo
1522 1522
             // these three lines remain necessary. They do that by changing the
1523 1523
             // page state is made when you press the button and not have to wait
1524 1524
             // to change his page
1525
-            $sql='SELECT * FROM '.$tbl_wiki.'
1525
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1526 1526
                   WHERE
1527 1527
                     c_id = '.$course_id.' AND
1528 1528
                     reflink="'.Database::escape_string($page).'" AND
1529 1529
                     '.$groupfilter.$condition_session.'
1530 1530
                   ORDER BY id ASC';
1531
-            $result=Database::query($sql);
1532
-            $row=Database::fetch_array($result);
1531
+            $result = Database::query($sql);
1532
+            $row = Database::fetch_array($result);
1533 1533
         }
1534 1534
 
1535 1535
         return $row['ratinglock_disc'];
@@ -1554,24 +1554,24 @@  discard block
 block discarded – undo
1554 1554
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1555 1555
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1556 1556
                 ORDER BY id ASC';
1557
-        $result=Database::query($sql);
1558
-        $row=Database::fetch_array($result);
1557
+        $result = Database::query($sql);
1558
+        $row = Database::fetch_array($result);
1559 1559
         $id = $row['id'];
1560
-        $sql='SELECT * FROM '.$tbl_wiki_mailcue.'
1560
+        $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1561 1561
               WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"';
1562
-        $result=Database::query($sql);
1563
-        $row=Database::fetch_array($result);
1562
+        $result = Database::query($sql);
1563
+        $row = Database::fetch_array($result);
1564 1564
 
1565 1565
         $idm = $row['id'];
1566 1566
 
1567 1567
         if (empty($idm)) {
1568
-            $status_notify=0;
1568
+            $status_notify = 0;
1569 1569
         } else {
1570
-            $status_notify=1;
1570
+            $status_notify = 1;
1571 1571
         }
1572 1572
 
1573 1573
         // Change status
1574
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) {
1574
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotify' && $status_notify == 0) {
1575 1575
             $sql = "SELECT id FROM $tbl_wiki_mailcue
1576 1576
                     WHERE c_id = $course_id AND id = $id AND user_id = $userId";
1577 1577
             $result = Database::query($sql);
@@ -1580,18 +1580,18 @@  discard block
 block discarded – undo
1580 1580
                 $exist = true;
1581 1581
             }
1582 1582
             if ($exist == false) {
1583
-                $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1583
+                $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1584 1584
                 ($course_id, '".$id."','".api_get_user_id()."','P','".$groupId."','".$session_id."')";
1585 1585
                 Database::query($sql);
1586 1586
             }
1587
-            $status_notify=1;
1587
+            $status_notify = 1;
1588 1588
         }
1589 1589
 
1590
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotify' && $status_notify==1) {
1590
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotify' && $status_notify == 1) {
1591 1591
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1592 1592
                     WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P" AND c_id = '.$course_id;
1593 1593
             Database::query($sql);
1594
-            $status_notify=0;
1594
+            $status_notify = 0;
1595 1595
         }
1596 1596
 
1597 1597
         return $status_notify;
@@ -1617,9 +1617,9 @@  discard block
 block discarded – undo
1617 1617
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1618 1618
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1619 1619
                 ORDER BY id ASC';
1620
-        $result=Database::query($sql);
1621
-        $row=Database::fetch_array($result);
1622
-        $id=$row['id'];
1620
+        $result = Database::query($sql);
1621
+        $row = Database::fetch_array($result);
1622
+        $id = $row['id'];
1623 1623
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1624 1624
                 WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
1625 1625
         $result = Database::query($sql);
@@ -1627,23 +1627,23 @@  discard block
 block discarded – undo
1627 1627
         $idm = $row['id'];
1628 1628
 
1629 1629
         if (empty($idm)) {
1630
-            $status_notify_disc=0;
1630
+            $status_notify_disc = 0;
1631 1631
         } else {
1632
-            $status_notify_disc=1;
1632
+            $status_notify_disc = 1;
1633 1633
         }
1634 1634
 
1635 1635
         //change status
1636
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifydisc' && $status_notify_disc==0) {
1637
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1636
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifydisc' && $status_notify_disc == 0) {
1637
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1638 1638
             ($course_id, '".$id."','".api_get_user_id()."','D','".$groupId."','".$session_id."')";
1639 1639
             Database::query($sql);
1640
-            $status_notify_disc=1;
1640
+            $status_notify_disc = 1;
1641 1641
         }
1642
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifydisc' && $status_notify_disc==1) {
1642
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotifydisc' && $status_notify_disc == 1) {
1643 1643
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1644 1644
                     WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D" AND c_id = '.$course_id;
1645 1645
             Database::query($sql);
1646
-            $status_notify_disc=0;
1646
+            $status_notify_disc = 0;
1647 1647
         }
1648 1648
 
1649 1649
         return $status_notify_disc;
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1659 1659
         $course_id = api_get_course_int_id();
1660 1660
         $groupId = api_get_group_id();
1661
-        $session_id=api_get_session_id();
1661
+        $session_id = api_get_session_id();
1662 1662
 
1663 1663
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1664 1664
                 WHERE
@@ -1667,31 +1667,31 @@  discard block
 block discarded – undo
1667 1667
                     type="F" AND
1668 1668
                     group_id="'.$groupId.'" AND
1669 1669
                     session_id="'.$session_id.'"';
1670
-        $result=Database::query($sql);
1671
-        $row=Database::fetch_array($result);
1670
+        $result = Database::query($sql);
1671
+        $row = Database::fetch_array($result);
1672 1672
 
1673
-        $idm=$row['user_id'];
1673
+        $idm = $row['user_id'];
1674 1674
 
1675 1675
         if (empty($idm)) {
1676
-            $status_notify_all=0;
1676
+            $status_notify_all = 0;
1677 1677
         } else {
1678
-            $status_notify_all=1;
1678
+            $status_notify_all = 1;
1679 1679
         }
1680 1680
 
1681 1681
         //change status
1682
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifyall' && $status_notify_all==0) {
1683
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1682
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifyall' && $status_notify_all == 0) {
1683
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1684 1684
             ($course_id, '".api_get_user_id()."','F','".$groupId."','".$session_id."')";
1685 1685
             Database::query($sql);
1686
-            $status_notify_all=1;
1686
+            $status_notify_all = 1;
1687 1687
         }
1688 1688
 
1689 1689
         if (isset($_GET['actionpage']) &&
1690 1690
             isset($_GET['actionpage']) &&
1691
-            $_GET['actionpage']  =='unlocknotifyall' &&
1691
+            $_GET['actionpage'] == 'unlocknotifyall' &&
1692 1692
             $status_notify_all == 1
1693 1693
         ) {
1694
-            $sql ='DELETE FROM '.$tbl_wiki_mailcue.'
1694
+            $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1695 1695
                    WHERE
1696 1696
                     c_id = '.$course_id.' AND
1697 1697
                     user_id="'.api_get_user_id().'" AND
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
                     session_id="'.$session_id.'" AND
1701 1701
                     c_id = '.$course_id;
1702 1702
             Database::query($sql);
1703
-            $status_notify_all=0;
1703
+            $status_notify_all = 0;
1704 1704
         }
1705 1705
 
1706 1706
         //show status
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
     /**
1711 1711
      * Sends pending e-mails
1712 1712
      */
1713
-    public function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
1713
+    public function check_emailcue($id_or_ref, $type, $lastime = '', $lastuser = '')
1714 1714
     {
1715 1715
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1716 1716
         $tbl_wiki = $this->tbl_wiki;
@@ -1718,14 +1718,14 @@  discard block
 block discarded – undo
1718 1718
         $groupfilter = $this->groupfilter;
1719 1719
         $_course = $this->courseInfo;
1720 1720
         $groupId = api_get_group_id();
1721
-        $session_id=api_get_session_id();
1721
+        $session_id = api_get_session_id();
1722 1722
         $course_id = api_get_course_int_id();
1723 1723
 
1724
-        $group_properties  = GroupManager :: get_group_properties($groupId);
1724
+        $group_properties = GroupManager :: get_group_properties($groupId);
1725 1725
         $group_name = $group_properties['name'];
1726 1726
         $allow_send_mail = false; //define the variable to below
1727 1727
         $email_assignment = null;
1728
-        if ($type=='P') {
1728
+        if ($type == 'P') {
1729 1729
             //if modifying a wiki page
1730 1730
             //first, current author and time
1731 1731
             //Who is the author?
@@ -1736,22 +1736,22 @@  discard block
 block discarded – undo
1736 1736
             $year = substr($lastime, 0, 4);
1737 1737
             $month = substr($lastime, 5, 2);
1738 1738
             $day = substr($lastime, 8, 2);
1739
-            $hours=substr($lastime, 11,2);
1740
-            $minutes=substr($lastime, 14,2);
1741
-            $seconds=substr($lastime, 17,2);
1742
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1739
+            $hours = substr($lastime, 11, 2);
1740
+            $minutes = substr($lastime, 14, 2);
1741
+            $seconds = substr($lastime, 17, 2);
1742
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1743 1743
 
1744 1744
             //second, extract data from first reg
1745 1745
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1746 1746
                     WHERE  c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.'
1747 1747
                     ORDER BY id ASC';
1748
-            $result=Database::query($sql);
1749
-            $row=Database::fetch_array($result);
1748
+            $result = Database::query($sql);
1749
+            $row = Database::fetch_array($result);
1750 1750
 
1751
-            $id=$row['id'];
1752
-            $email_page_name=$row['title'];
1753
-            if ($row['visibility']==1) {
1754
-                $allow_send_mail=true; //if visibility off - notify off
1751
+            $id = $row['id'];
1752
+            $email_page_name = $row['title'];
1753
+            if ($row['visibility'] == 1) {
1754
+                $allow_send_mail = true; //if visibility off - notify off
1755 1755
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1756 1756
                         WHERE
1757 1757
                             c_id = '.$course_id.' AND
@@ -1761,10 +1761,10 @@  discard block
 block discarded – undo
1761 1761
                             group_id="'.$groupId.'" AND
1762 1762
                             session_id="'.$session_id.'"';
1763 1763
                 //type: P=page, D=discuss, F=full.
1764
-                $result=Database::query($sql);
1765
-                $emailtext=get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1764
+                $result = Database::query($sql);
1765
+                $emailtext = get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1766 1766
             }
1767
-        } elseif ($type=='D') {
1767
+        } elseif ($type == 'D') {
1768 1768
             //if added a post to discuss
1769 1769
 
1770 1770
             //first, current author and time
@@ -1776,25 +1776,25 @@  discard block
 block discarded – undo
1776 1776
             $year = substr($lastime, 0, 4);
1777 1777
             $month = substr($lastime, 5, 2);
1778 1778
             $day = substr($lastime, 8, 2);
1779
-            $hours=substr($lastime, 11,2);
1780
-            $minutes=substr($lastime, 14,2);
1781
-            $seconds=substr($lastime, 17,2);
1782
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1779
+            $hours = substr($lastime, 11, 2);
1780
+            $minutes = substr($lastime, 14, 2);
1781
+            $seconds = substr($lastime, 17, 2);
1782
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1783 1783
 
1784 1784
             //second, extract data from first reg
1785 1785
 
1786
-            $id=$id_or_ref; //$id_or_ref is id from tblwiki
1786
+            $id = $id_or_ref; //$id_or_ref is id from tblwiki
1787 1787
 
1788 1788
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1789 1789
                     WHERE c_id = '.$course_id.' AND id="'.$id.'"
1790 1790
                     ORDER BY id ASC';
1791 1791
 
1792
-            $result=Database::query($sql);
1793
-            $row=Database::fetch_array($result);
1792
+            $result = Database::query($sql);
1793
+            $row = Database::fetch_array($result);
1794 1794
 
1795
-            $email_page_name=$row['title'];
1796
-            if ($row['visibility_disc']==1) {
1797
-                $allow_send_mail=true; //if visibility off - notify off
1795
+            $email_page_name = $row['title'];
1796
+            if ($row['visibility_disc'] == 1) {
1797
+                $allow_send_mail = true; //if visibility off - notify off
1798 1798
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1799 1799
                         WHERE
1800 1800
                             c_id = '.$course_id.' AND
@@ -1805,22 +1805,22 @@  discard block
 block discarded – undo
1805 1805
                             session_id="'.$session_id.'"';
1806 1806
                 //type: P=page, D=discuss, F=full
1807 1807
                 $result = Database::query($sql);
1808
-                $emailtext=get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1808
+                $emailtext = get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1809 1809
             }
1810
-        } elseif($type=='A') {
1810
+        } elseif ($type == 'A') {
1811 1811
             //for added pages
1812
-            $id=0; //for tbl_wiki_mailcue
1812
+            $id = 0; //for tbl_wiki_mailcue
1813 1813
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1814 1814
                     WHERE c_id = '.$course_id.'
1815 1815
                     ORDER BY id DESC'; //the added is always the last
1816 1816
 
1817
-            $result=Database::query($sql);
1818
-            $row=Database::fetch_array($result);
1819
-            $email_page_name=$row['title'];
1817
+            $result = Database::query($sql);
1818
+            $row = Database::fetch_array($result);
1819
+            $email_page_name = $row['title'];
1820 1820
 
1821 1821
             //Who is the author?
1822 1822
             $userinfo = api_get_user_info($row['user_id']);
1823
-            $email_user_author= get_lang('AddedBy').': '.$userinfo['complete_name'];
1823
+            $email_user_author = get_lang('AddedBy').': '.$userinfo['complete_name'];
1824 1824
 
1825 1825
             //When ?
1826 1826
             $year = substr($row['dtime'], 0, 4);
@@ -1829,33 +1829,33 @@  discard block
 block discarded – undo
1829 1829
             $hours = substr($row['dtime'], 11, 2);
1830 1830
             $minutes = substr($row['dtime'], 14, 2);
1831 1831
             $seconds = substr($row['dtime'], 17, 2);
1832
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1833
-
1834
-            if($row['assignment']==0) {
1835
-                $allow_send_mail=true;
1836
-            } elseif($row['assignment']==1) {
1837
-                $email_assignment=get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1838
-                $allow_send_mail=true;
1839
-            } elseif($row['assignment']==2) {
1840
-                $allow_send_mail=false; //Mode tasks: avoids notifications to all users about all users
1832
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1833
+
1834
+            if ($row['assignment'] == 0) {
1835
+                $allow_send_mail = true;
1836
+            } elseif ($row['assignment'] == 1) {
1837
+                $email_assignment = get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1838
+                $allow_send_mail = true;
1839
+            } elseif ($row['assignment'] == 2) {
1840
+                $allow_send_mail = false; //Mode tasks: avoids notifications to all users about all users
1841 1841
             }
1842 1842
 
1843 1843
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1844 1844
                     WHERE c_id = '.$course_id.' AND  id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
1845 1845
             //type: P=page, D=discuss, F=full
1846
-            $result=Database::query($sql);
1846
+            $result = Database::query($sql);
1847 1847
 
1848
-            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki');
1849
-        } elseif ($type=='E') {
1850
-            $id=0;
1851
-            $allow_send_mail=true;
1848
+            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '.get_lang('Wiki');
1849
+        } elseif ($type == 'E') {
1850
+            $id = 0;
1851
+            $allow_send_mail = true;
1852 1852
 
1853 1853
             //Who is the author?
1854
-            $userinfo = api_get_user_info(api_get_user_id());	//current user
1854
+            $userinfo = api_get_user_info(api_get_user_id()); //current user
1855 1855
             $email_user_author = get_lang('DeletedBy').': '.$userinfo['complete_name'];
1856 1856
             //When ?
1857
-            $today = date('r');		//current time
1858
-            $email_date_changes=$today;
1857
+            $today = date('r'); //current time
1858
+            $email_date_changes = $today;
1859 1859
 
1860 1860
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1861 1861
                     WHERE
@@ -1869,16 +1869,16 @@  discard block
 block discarded – undo
1869 1869
         ///make and send email
1870 1870
         if ($allow_send_mail) {
1871 1871
             while ($row = Database::fetch_array($result)) {
1872
-                $userinfo = api_get_user_info($row['user_id']);	//$row['user_id'] obtained from tbl_wiki_mailcue
1872
+                $userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue
1873 1873
                 $name_to = $userinfo['complete_name'];
1874 1874
                 $email_to = $userinfo['email'];
1875 1875
                 $sender_name = api_get_setting('emailAdministrator');
1876 1876
                 $sender_email = api_get_setting('emailAdministrator');
1877 1877
                 $email_subject = get_lang('EmailWikiChanges').' - '.$_course['official_code'];
1878 1878
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1879
-                if($session_id==0){
1879
+                if ($session_id == 0) {
1880 1880
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1881
-                }else{
1881
+                } else {
1882 1882
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1883 1883
                 }
1884 1884
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -1956,25 +1956,25 @@  discard block
 block discarded – undo
1956 1956
             $template);
1957 1957
 
1958 1958
         if (0 != $groupId) {
1959
-            $groupPart = '_group' . $groupId; // and add groupId to put the same document title in different groups
1960
-            $group_properties  = GroupManager :: get_group_properties($groupId);
1959
+            $groupPart = '_group'.$groupId; // and add groupId to put the same document title in different groups
1960
+            $group_properties = GroupManager :: get_group_properties($groupId);
1961 1961
             $groupPath = $group_properties['directory'];
1962 1962
         } else {
1963 1963
             $groupPart = '';
1964
-            $groupPath ='';
1964
+            $groupPath = '';
1965 1965
         }
1966 1966
 
1967
-        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path(). '/document'.$groupPath;
1968
-        $exportFile = api_replace_dangerous_char($wikiTitle) . $groupPart;
1967
+        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$groupPath;
1968
+        $exportFile = api_replace_dangerous_char($wikiTitle).$groupPart;
1969 1969
         $wikiContents = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $wikiContents));
1970 1970
         //TODO: put link instead of title
1971 1971
 
1972 1972
         $wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
1973 1973
 
1974 1974
         // replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents
1975
-        if (api_strpos($wikiContents,'../../courses/') !== false) {
1975
+        if (api_strpos($wikiContents, '../../courses/') !== false) {
1976 1976
             $web_course_path = api_get_path(WEB_COURSE_PATH);
1977
-            $wikiContents = str_replace('../../courses/',$web_course_path,$wikiContents);
1977
+            $wikiContents = str_replace('../../courses/', $web_course_path, $wikiContents);
1978 1978
         }
1979 1979
 
1980 1980
         $i = 1;
@@ -1983,8 +1983,8 @@  discard block
 block discarded – undo
1983 1983
             $i++;
1984 1984
         }
1985 1985
 
1986
-        $wikiFileName = $exportFile . '_' . $i . '.html';
1987
-        $exportPath = $exportDir . '/' . $wikiFileName;
1986
+        $wikiFileName = $exportFile.'_'.$i.'.html';
1987
+        $exportPath = $exportDir.'/'.$wikiFileName;
1988 1988
 
1989 1989
         file_put_contents($exportPath, $wikiContents);
1990 1990
         $doc_id = add_document(
@@ -2029,14 +2029,14 @@  discard block
 block discarded – undo
2029 2029
         $content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding());
2030 2030
 
2031 2031
         //clean wiki links
2032
-        $content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2032
+        $content_pdf = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2033 2033
         //TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links
2034 2034
 
2035 2035
         $title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding());
2036 2036
         $title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding());
2037 2037
         $content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding());
2038 2038
 
2039
-        $html='
2039
+        $html = '
2040 2040
         <!-- defines the headers/footers - this must occur before the headers/footers are set -->
2041 2041
 
2042 2042
         <!--mpdf
@@ -2091,9 +2091,9 @@  discard block
 block discarded – undo
2091 2091
         $session_id = $this->session_id;
2092 2092
         $groupId = api_get_group_id();
2093 2093
 
2094
-        if ($groupId==0) {
2094
+        if ($groupId == 0) {
2095 2095
             //extract course members
2096
-            if(!empty($session_id)) {
2096
+            if (!empty($session_id)) {
2097 2097
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id);
2098 2098
             } else {
2099 2099
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0);
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
2120 2120
         $name = $userinfo['complete_name']." - ".$username;
2121 2121
 
2122
-        $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '"  width="40" height="50" align="top" title="' . $name . '"  />';
2122
+        $photo = '<img src="'.$userinfo['avatar'].'" alt="'.$name.'"  width="40" height="50" align="top" title="'.$name.'"  />';
2123 2123
 
2124 2124
         // teacher assignment title
2125 2125
         $title_orig = $values['title'];
@@ -2147,24 +2147,24 @@  discard block
 block discarded – undo
2147 2147
                 $userPicture = UserManager::getUserPicture($assig_user_id);
2148 2148
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
2149 2149
                 $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
2150
-                $photo= '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2150
+                $photo = '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2151 2151
 
2152 2152
                 $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
2153 2153
                 $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
2154 2154
                 // student is tutor and member
2155 2155
 
2156 2156
                 if ($is_tutor_and_member) {
2157
-                    $status_in_group=get_lang('GroupTutorAndMember');
2157
+                    $status_in_group = get_lang('GroupTutorAndMember');
2158 2158
                 } else {
2159
-                    if($is_tutor_of_group) {
2160
-                        $status_in_group=get_lang('GroupTutor');
2159
+                    if ($is_tutor_of_group) {
2160
+                        $status_in_group = get_lang('GroupTutor');
2161 2161
                     } else {
2162
-                        $status_in_group=" "; //get_lang('GroupStandardMember')
2162
+                        $status_in_group = " "; //get_lang('GroupStandardMember')
2163 2163
                     }
2164 2164
                 }
2165 2165
 
2166
-                if ($assignment_type==1) {
2167
-                    $values['title']= $title_orig;
2166
+                if ($assignment_type == 1) {
2167
+                    $values['title'] = $title_orig;
2168 2168
                     $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
2169 2169
                     <table border="0">
2170 2170
                     <tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr>
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
                         ).
2181 2181
                         ' [['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>';
2182 2182
                     //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
2183
-                    $values['assignment']=2;
2183
+                    $values['assignment'] = 2;
2184 2184
                 }
2185 2185
                 $this->assig_user_id = $assig_user_id;
2186 2186
                 self::save_new_wiki($values);
@@ -2189,12 +2189,12 @@  discard block
 block discarded – undo
2189 2189
 
2190 2190
         foreach ($a_users_to_add as $o_user_to_add) {
2191 2191
             if ($o_user_to_add['user_id'] == $userId) {
2192
-                $assig_user_id=$o_user_to_add['user_id'];
2192
+                $assig_user_id = $o_user_to_add['user_id'];
2193 2193
                 if ($assignment_type == 1) {
2194
-                    $values['title']= $title_orig;
2195
-                    $values['comment']=get_lang('AssignmentDesc');
2194
+                    $values['title'] = $title_orig;
2195
+                    $values['comment'] = get_lang('AssignmentDesc');
2196 2196
                     sort($all_students_pages);
2197
-                    $values['content']=$content_orig_A.$content_orig_B.'<br/>
2197
+                    $values['content'] = $content_orig_A.$content_orig_B.'<br/>
2198 2198
                     <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
2199 2199
                     '.get_lang('AssignmentLinkstoStudentsPage').'
2200 2200
                     </div><br/>
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
                     <ol>'.implode($all_students_pages).'</ol>
2203 2203
                     </div>
2204 2204
                     <br/>';
2205
-                    $values['assignment']=1;
2205
+                    $values['assignment'] = 1;
2206 2206
                 }
2207 2207
                 $this->assig_user_id = $assig_user_id;
2208 2208
                 self::save_new_wiki($values);
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
      * @param   int     Whether to search the contents (1) or just the titles (0)
2217 2217
      * @param int
2218 2218
      */
2219
-    public function display_wiki_search_results($search_term, $search_content=0, $all_vers=0)
2219
+    public function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0)
2220 2220
     {
2221 2221
         $tbl_wiki = $this->tbl_wiki;
2222 2222
         $condition_session = $this->condition_session;
@@ -2228,9 +2228,9 @@  discard block
 block discarded – undo
2228 2228
         echo '</legend>';
2229 2229
 
2230 2230
         //only by professors when page is hidden
2231
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
2232
-            if ($all_vers=='1') {
2233
-                if ($search_content=='1') {
2231
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2232
+            if ($all_vers == '1') {
2233
+                if ($search_content == '1') {
2234 2234
                     $sql = "SELECT * FROM ".$tbl_wiki."
2235 2235
                             WHERE
2236 2236
                                 c_id = $course_id AND
@@ -2247,7 +2247,7 @@  discard block
 block discarded – undo
2247 2247
                     //search all pages and all versions
2248 2248
                 }
2249 2249
             } else {
2250
-                if ($search_content=='1') {
2250
+                if ($search_content == '1') {
2251 2251
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2252 2252
                             WHERE
2253 2253
                                 s1.c_id = $course_id AND
@@ -2298,7 +2298,7 @@  discard block
 block discarded – undo
2298 2298
                     //search all pages and all versions
2299 2299
                 }
2300 2300
             } else {
2301
-                if($search_content=='1') {
2301
+                if ($search_content == '1') {
2302 2302
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2303 2303
                             WHERE
2304 2304
                                 s1.c_id = $course_id AND
@@ -2346,17 +2346,17 @@  discard block
 block discarded – undo
2346 2346
                 $seconds = substr($obj->dtime, 17, 2);
2347 2347
 
2348 2348
                 //get type assignment icon
2349
-                if($obj->assignment==1) {
2350
-                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
2351
-                } elseif ($obj->assignment==2) {
2352
-                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
2353
-                } elseif ($obj->assignment==0) {
2349
+                if ($obj->assignment == 1) {
2350
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
2351
+                } elseif ($obj->assignment == 2) {
2352
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
2353
+                } elseif ($obj->assignment == 0) {
2354 2354
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
2355 2355
                 }
2356 2356
                 $row = array();
2357 2357
                 $row[] = $ShowAssignment;
2358 2358
 
2359
-                if($all_vers=='1') {
2359
+                if ($all_vers == '1') {
2360 2360
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.
2361 2361
                         api_htmlentities($obj->title).'</a>';
2362 2362
                 } else {
@@ -2367,21 +2367,21 @@  discard block
 block discarded – undo
2367 2367
                 $row[] = $obj->user_id != 0 ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')';
2368 2368
                 $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
2369 2369
 
2370
-                if ($all_vers=='1') {
2370
+                if ($all_vers == '1') {
2371 2371
                     $row[] = $obj->version;
2372 2372
                 } else {
2373 2373
                     $showdelete = '';
2374
-                    if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
2375
-                        $showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2376
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
2374
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2375
+                        $showdelete = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2376
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
2377 2377
                     }
2378 2378
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2379
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a>
2379
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a>
2380 2380
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2381
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a>
2381
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a>
2382 2382
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2383
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2384
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
2383
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2384
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
2385 2385
                 }
2386 2386
                 $rows[] = $row;
2387 2387
             }
@@ -2406,16 +2406,16 @@  discard block
 block discarded – undo
2406 2406
                     'all_vers' => $all_vers,
2407 2407
                 )
2408 2408
             );
2409
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
2410
-            $table->set_header(1,get_lang('Title'), true);
2409
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
2410
+            $table->set_header(1, get_lang('Title'), true);
2411 2411
             if ($all_vers == '1') {
2412
-                $table->set_header(2,get_lang('Author'), true);
2413
-                $table->set_header(3,get_lang('Date'), true);
2414
-                $table->set_header(4,get_lang('Version'), true);
2412
+                $table->set_header(2, get_lang('Author'), true);
2413
+                $table->set_header(3, get_lang('Date'), true);
2414
+                $table->set_header(4, get_lang('Version'), true);
2415 2415
             } else {
2416
-                $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
2417
-                $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
2418
-                $table->set_header(4,get_lang('Actions'), false, array ('style' => 'width:130px;'));
2416
+                $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
2417
+                $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
2418
+                $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;'));
2419 2419
             }
2420 2420
             $table->display();
2421 2421
         } else {
@@ -2428,14 +2428,14 @@  discard block
 block discarded – undo
2428 2428
      * @todo replace this function with the formvalidator datepicker
2429 2429
      *
2430 2430
      */
2431
-    public function draw_date_picker($prefix,$default='')
2431
+    public function draw_date_picker($prefix, $default = '')
2432 2432
     {
2433 2433
         if (empty($default)) {
2434 2434
             $default = date('Y-m-d H:i:s');
2435 2435
         }
2436 2436
         $parts = explode(' ', $default);
2437
-        list($d_year,$d_month,$d_day) = explode('-',$parts[0]);
2438
-        list($d_hour,$d_minute) = explode(':',$parts[1]);
2437
+        list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
2438
+        list($d_hour, $d_minute) = explode(':', $parts[1]);
2439 2439
 
2440 2440
         $month_list = array(
2441 2441
             1 => get_lang('JanuaryLong'),
@@ -2452,9 +2452,9 @@  discard block
 block discarded – undo
2452 2452
             12 => get_lang('DecemberLong'),
2453 2453
         );
2454 2454
 
2455
-        $minute = range(10,59);
2456
-        array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
2457
-        $date_form = self::make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day);
2455
+        $minute = range(10, 59);
2456
+        array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
2457
+        $date_form = self::make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day);
2458 2458
         $date_form .= self::make_select($prefix.'_month', $month_list, $d_month);
2459 2459
         $date_form .= self::make_select(
2460 2460
                 $prefix.'_year',
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
                 ),
2468 2468
                 $d_year
2469 2469
             ).'&nbsp;&nbsp;&nbsp;&nbsp;';
2470
-        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : ';
2470
+        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : ';
2471 2471
         $date_form .= self::make_select($prefix.'_minute', $minute, $d_minute);
2472 2472
 
2473 2473
         return $date_form;
@@ -2477,11 +2477,11 @@  discard block
 block discarded – undo
2477 2477
      * Draws an HTML form select with the given options
2478 2478
      *
2479 2479
      */
2480
-    public function make_select($name,$values,$checked='')
2480
+    public function make_select($name, $values, $checked = '')
2481 2481
     {
2482 2482
         $output = '<select name="'.$name.'" id="'.$name.'">';
2483
-        foreach($values as $key => $value) {
2484
-            $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
2483
+        foreach ($values as $key => $value) {
2484
+            $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2485 2485
         }
2486 2486
         $output .= '</select>';
2487 2487
         return $output;
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
      */
2506 2506
     public function two_digits($number)
2507 2507
     {
2508
-        $number = (int)$number;
2508
+        $number = (int) $number;
2509 2509
         return ($number < 10) ? '0'.$number : $number;
2510 2510
     }
2511 2511
 
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
                 WHERE c_id = '.$course_id.' AND id = '.$id.' ';
2524 2524
         $result = Database::query($sql);
2525 2525
         $data = array();
2526
-        while ($row=Database::fetch_array($result,'ASSOC'))   {
2526
+        while ($row = Database::fetch_array($result, 'ASSOC')) {
2527 2527
             $data = $row;
2528 2528
         }
2529 2529
         return $data;
@@ -2577,7 +2577,7 @@  discard block
 block discarded – undo
2577 2577
         $result = Database::query($sql);
2578 2578
         $data = array();
2579 2579
         if (Database::num_rows($result)) {
2580
-            $data = Database::fetch_array($result,'ASSOC');
2580
+            $data = Database::fetch_array($result, 'ASSOC');
2581 2581
         }
2582 2582
 
2583 2583
         return $data;
@@ -2671,9 +2671,9 @@  discard block
 block discarded – undo
2671 2671
         $result = self::getAllWiki();
2672 2672
         if (!empty($result)) {
2673 2673
             foreach ($result  as $is_editing_block) {
2674
-                $max_edit_time	= 1200; // 20 minutes
2675
-                $timestamp_edit	= strtotime($is_editing_block['time_edit']);
2676
-                $time_editing	= time()-$timestamp_edit;
2674
+                $max_edit_time = 1200; // 20 minutes
2675
+                $timestamp_edit = strtotime($is_editing_block['time_edit']);
2676
+                $time_editing = time() - $timestamp_edit;
2677 2677
 
2678 2678
                 // First prevent concurrent users and double version
2679 2679
                 if ($is_editing_block['is_editing'] == $userId) {
@@ -2682,7 +2682,7 @@  discard block
 block discarded – undo
2682 2682
                     unset($_SESSION['_version']);
2683 2683
                 }
2684 2684
                 // Second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
2685
-                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action!='edit')) {
2685
+                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action != 'edit')) {
2686 2686
                     self::updateWikiIsEditing($is_editing_block['is_editing']);
2687 2687
                 }
2688 2688
             }
@@ -2730,7 +2730,7 @@  discard block
 block discarded – undo
2730 2730
                 FROM ".$tbl_wiki."
2731 2731
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2732 2732
 
2733
-        $allpages=Database::query($sql);
2733
+        $allpages = Database::query($sql);
2734 2734
         while ($row = Database::fetch_array($allpages)) {
2735 2735
             $total_versions = $row['TOTAL_VERS'];
2736 2736
             $total_visits = intval($row['TOTAL_VISITS']);
@@ -2740,30 +2740,30 @@  discard block
 block discarded – undo
2740 2740
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2741 2741
         $allpages = Database::query($sql);
2742 2742
 
2743
-        while ($row=Database::fetch_array($allpages)) {
2743
+        while ($row = Database::fetch_array($allpages)) {
2744 2744
             $total_words = $total_words + self::word_count($row['content']);
2745
-            $total_links 			= $total_links+substr_count($row['content'], "href=");
2746
-            $total_links_anchors 	= $total_links_anchors+substr_count($row['content'], 'href="#');
2747
-            $total_links_mail		= $total_links_mail+substr_count($row['content'], 'href="mailto');
2748
-            $total_links_ftp 		= $total_links_ftp+substr_count($row['content'], 'href="ftp');
2749
-            $total_links_irc		= $total_links_irc+substr_count($row['content'], 'href="irc');
2750
-            $total_links_news 		= $total_links_news+substr_count($row['content'], 'href="news');
2751
-            $total_wlinks 			= $total_wlinks+substr_count($row['content'], "[[");
2752
-            $total_images 			= $total_images+substr_count($row['content'], "<img");
2745
+            $total_links = $total_links + substr_count($row['content'], "href=");
2746
+            $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#');
2747
+            $total_links_mail		= $total_links_mail + substr_count($row['content'], 'href="mailto');
2748
+            $total_links_ftp 		= $total_links_ftp + substr_count($row['content'], 'href="ftp');
2749
+            $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc');
2750
+            $total_links_news = $total_links_news + substr_count($row['content'], 'href="news');
2751
+            $total_wlinks 			= $total_wlinks + substr_count($row['content'], "[[");
2752
+            $total_images 			= $total_images + substr_count($row['content'], "<img");
2753 2753
             $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
2754
-            $total_flash			= $total_flash+substr_count($clean_total_flash, '.swf"');
2754
+            $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"');
2755 2755
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2756
-            $total_mp3				= $total_mp3+substr_count($row['content'], ".mp3");
2757
-            $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
2758
-            $total_flv				=	$total_flv_p/5;
2759
-            $total_youtube			= $total_youtube+substr_count($row['content'], "http://www.youtube.com");
2760
-            $total_multimedia		= $total_multimedia+substr_count($row['content'], "video/x-msvideo");
2761
-            $total_tables			= $total_tables+substr_count($row['content'], "<table");
2756
+            $total_mp3				= $total_mp3 + substr_count($row['content'], ".mp3");
2757
+            $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv");
2758
+            $total_flv				= $total_flv_p / 5;
2759
+            $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com");
2760
+            $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo");
2761
+            $total_tables = $total_tables + substr_count($row['content'], "<table");
2762 2762
         }
2763 2763
 
2764 2764
         //check only last version of all pages (current page)
2765 2765
 
2766
-        $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2766
+        $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2767 2767
                 FROM  '.$tbl_wiki.' s1
2768 2768
                 WHERE s1.c_id = '.$course_id.' AND id=(
2769 2769
                     SELECT MAX(s2.id)
@@ -2774,9 +2774,9 @@  discard block
 block discarded – undo
2774 2774
                         '.$groupfilter.' AND
2775 2775
                         session_id='.$session_id.')';
2776 2776
         $allpages = Database::query($sql);
2777
-        while ($row=Database::fetch_array($allpages)) {
2778
-            $total_pages	 		= $row['TOTAL_PAGES'];
2779
-            $total_visits_lv 		= intval($row['TOTAL_VISITS_LV']);
2777
+        while ($row = Database::fetch_array($allpages)) {
2778
+            $total_pages = $row['TOTAL_PAGES'];
2779
+            $total_visits_lv = intval($row['TOTAL_VISITS_LV']);
2780 2780
         }
2781 2781
 
2782 2782
         $total_words_lv = 0;
@@ -2808,29 +2808,29 @@  discard block
 block discarded – undo
2808 2808
                 )';
2809 2809
         $allpages = Database::query($sql);
2810 2810
 
2811
-        while ($row=Database::fetch_array($allpages)) {
2812
-            $total_words_lv 		= $total_words_lv+ self::word_count($row['content']);
2813
-            $total_links_lv 		= $total_links_lv+substr_count($row['content'], "href=");
2814
-            $total_links_anchors_lv	= $total_links_anchors_lv+substr_count($row['content'], 'href="#');
2815
-            $total_links_mail_lv 	= $total_links_mail_lv+substr_count($row['content'], 'href="mailto');
2816
-            $total_links_ftp_lv 	= $total_links_ftp_lv+substr_count($row['content'], 'href="ftp');
2817
-            $total_links_irc_lv 	= $total_links_irc_lv+substr_count($row['content'], 'href="irc');
2818
-            $total_links_news_lv 	= $total_links_news_lv+substr_count($row['content'], 'href="news');
2819
-            $total_wlinks_lv 		= $total_wlinks_lv+substr_count($row['content'], "[[");
2820
-            $total_images_lv 		= $total_images_lv+substr_count($row['content'], "<img");
2811
+        while ($row = Database::fetch_array($allpages)) {
2812
+            $total_words_lv 		= $total_words_lv + self::word_count($row['content']);
2813
+            $total_links_lv 		= $total_links_lv + substr_count($row['content'], "href=");
2814
+            $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#');
2815
+            $total_links_mail_lv 	= $total_links_mail_lv + substr_count($row['content'], 'href="mailto');
2816
+            $total_links_ftp_lv 	= $total_links_ftp_lv + substr_count($row['content'], 'href="ftp');
2817
+            $total_links_irc_lv 	= $total_links_irc_lv + substr_count($row['content'], 'href="irc');
2818
+            $total_links_news_lv 	= $total_links_news_lv + substr_count($row['content'], 'href="news');
2819
+            $total_wlinks_lv 		= $total_wlinks_lv + substr_count($row['content'], "[[");
2820
+            $total_images_lv 		= $total_images_lv + substr_count($row['content'], "<img");
2821 2821
             $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
2822
-            $total_flash_lv			= $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
2822
+            $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"');
2823 2823
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2824
-            $total_mp3_lv			= $total_mp3_lv+substr_count($row['content'], ".mp3");
2825
-            $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
2826
-            $total_flv_lv			= $total_flv_p_lv/5;
2827
-            $total_youtube_lv		= $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com");
2828
-            $total_multimedia_lv	= $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo");
2829
-            $total_tables_lv		= $total_tables_lv+substr_count($row['content'], "<table");
2824
+            $total_mp3_lv			= $total_mp3_lv + substr_count($row['content'], ".mp3");
2825
+            $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv");
2826
+            $total_flv_lv			= $total_flv_p_lv / 5;
2827
+            $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com");
2828
+            $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo");
2829
+            $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table");
2830 2830
         }
2831 2831
 
2832 2832
         //Total pages edited at this time
2833
-        $total_editing_now=0;
2833
+        $total_editing_now = 0;
2834 2834
         $sql = 'SELECT *, COUNT(*) AS TOTAL_EDITING_NOW
2835 2835
                 FROM  '.$tbl_wiki.' s1
2836 2836
                 WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND
@@ -2845,66 +2845,66 @@  discard block
 block discarded – undo
2845 2845
         )';
2846 2846
 
2847 2847
         // Can not use group by because the mark is set in the latest version
2848
-        $allpages=Database::query($sql);
2849
-        while ($row=Database::fetch_array($allpages)) {
2850
-            $total_editing_now	= $row['TOTAL_EDITING_NOW'];
2848
+        $allpages = Database::query($sql);
2849
+        while ($row = Database::fetch_array($allpages)) {
2850
+            $total_editing_now = $row['TOTAL_EDITING_NOW'];
2851 2851
         }
2852 2852
 
2853 2853
         // Total hidden pages
2854
-        $total_hidden=0;
2854
+        $total_hidden = 0;
2855 2855
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2856 2856
                 WHERE  c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
2857 2857
                 GROUP BY reflink';
2858 2858
         // or group by page_id. As the mark of hidden places it in all versions of the page, I can use group by to see the first
2859
-        $allpages=Database::query($sql);
2860
-        while ($row=Database::fetch_array($allpages)) {
2861
-            $total_hidden = $total_hidden+1;
2859
+        $allpages = Database::query($sql);
2860
+        while ($row = Database::fetch_array($allpages)) {
2861
+            $total_hidden = $total_hidden + 1;
2862 2862
         }
2863 2863
 
2864 2864
         //Total protect pages
2865
-        $total_protected=0;
2865
+        $total_protected = 0;
2866 2866
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2867 2867
                 WHERE  c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.'
2868 2868
                 GROUP BY reflink';
2869 2869
         // or group by page_id. As the mark of protected page is the first version of the page, I can use group by
2870 2870
 
2871
-        $allpages=Database::query($sql);
2872
-        while ($row=Database::fetch_array($allpages)) {
2873
-            $total_protected = $total_protected+1;
2871
+        $allpages = Database::query($sql);
2872
+        while ($row = Database::fetch_array($allpages)) {
2873
+            $total_protected = $total_protected + 1;
2874 2874
         }
2875 2875
 
2876 2876
         // Total empty versions.
2877
-        $total_empty_content=0;
2877
+        $total_empty_content = 0;
2878 2878
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2879 2879
                 WHERE
2880 2880
                     c_id = '.$course_id.' AND
2881 2881
                     content="" AND
2882 2882
                     '.$groupfilter.$condition_session.'';
2883 2883
         $allpages = Database::query($sql);
2884
-        while ($row=Database::fetch_array($allpages)) {
2885
-            $total_empty_content	= $total_empty_content+1;
2884
+        while ($row = Database::fetch_array($allpages)) {
2885
+            $total_empty_content = $total_empty_content + 1;
2886 2886
         }
2887 2887
 
2888 2888
         //Total empty pages (last version)
2889 2889
 
2890
-        $total_empty_content_lv=0;
2890
+        $total_empty_content_lv = 0;
2891 2891
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2892 2892
                 WHERE s1.c_id = '.$course_id.' AND content="" AND id=(
2893 2893
                 SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2894 2894
                 WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2895
-        $allpages=Database::query($sql);
2895
+        $allpages = Database::query($sql);
2896 2896
         while ($row = Database::fetch_array($allpages)) {
2897
-            $total_empty_content_lv	= $total_empty_content_lv+1;
2897
+            $total_empty_content_lv = $total_empty_content_lv + 1;
2898 2898
         }
2899 2899
 
2900 2900
         // Total locked discuss pages
2901
-        $total_lock_disc=0;
2901
+        $total_lock_disc = 0;
2902 2902
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2903 2903
                 WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.'
2904 2904
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2905
-        $allpages=Database::query($sql);
2905
+        $allpages = Database::query($sql);
2906 2906
         while ($row = Database::fetch_array($allpages)) {
2907
-            $total_lock_disc	= $total_lock_disc+1;
2907
+            $total_lock_disc = $total_lock_disc + 1;
2908 2908
         }
2909 2909
 
2910 2910
         // Total hidden discuss pages.
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
         //group by because mark lock in all vers, then always is ok
2916 2916
         $allpages = Database::query($sql);
2917 2917
         while ($row = Database::fetch_array($allpages)) {
2918
-            $total_hidden_disc	= $total_hidden_disc+1;
2918
+            $total_hidden_disc = $total_hidden_disc + 1;
2919 2919
         }
2920 2920
 
2921 2921
         //Total versions with any short comment by user or system
@@ -2923,44 +2923,44 @@  discard block
 block discarded – undo
2923 2923
         $total_comment_version = 0;
2924 2924
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2925 2925
                 WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.'';
2926
-        $allpages=Database::query($sql);
2926
+        $allpages = Database::query($sql);
2927 2927
         while ($row = Database::fetch_array($allpages)) {
2928
-            $total_comment_version	= $total_comment_version+1;
2928
+            $total_comment_version = $total_comment_version + 1;
2929 2929
         }
2930 2930
 
2931 2931
         // Total pages that can only be scored by teachers.
2932 2932
 
2933
-        $total_only_teachers_rating=0;
2933
+        $total_only_teachers_rating = 0;
2934 2934
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2935 2935
                 WHERE c_id = '.$course_id.' AND
2936 2936
                 ratinglock_disc = 0 AND
2937 2937
                 '.$groupfilter.$condition_session.'
2938 2938
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2939
-        $allpages=Database::query($sql);
2940
-        while ($row=Database::fetch_array($allpages)) {
2941
-            $total_only_teachers_rating	= $total_only_teachers_rating+1;
2939
+        $allpages = Database::query($sql);
2940
+        while ($row = Database::fetch_array($allpages)) {
2941
+            $total_only_teachers_rating = $total_only_teachers_rating + 1;
2942 2942
         }
2943 2943
 
2944 2944
         // Total pages scored by peers
2945 2945
         // put always this line alfter check num all pages and num pages rated by teachers
2946
-        $total_rating_by_peers=$total_pages-$total_only_teachers_rating;
2946
+        $total_rating_by_peers = $total_pages - $total_only_teachers_rating;
2947 2947
 
2948 2948
         //Total pages identified as standard task
2949 2949
 
2950
-        $total_task=0;
2951
-        $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2950
+        $total_task = 0;
2951
+        $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2952 2952
               WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
2953 2953
                '.$tbl_wiki_conf.'.task!="" AND
2954 2954
                '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
2955 2955
                 '.$tbl_wiki.'.'.$groupfilter.$condition_session;
2956 2956
         $allpages = Database::query($sql);
2957
-        while ($row=Database::fetch_array($allpages)) {
2958
-            $total_task=$total_task+1;
2957
+        while ($row = Database::fetch_array($allpages)) {
2958
+            $total_task = $total_task + 1;
2959 2959
         }
2960 2960
 
2961 2961
         //Total pages identified as teacher page (wiki portfolio mode - individual assignment)
2962 2962
 
2963
-        $total_teacher_assignment=0;
2963
+        $total_teacher_assignment = 0;
2964 2964
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2965 2965
                 WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=(
2966 2966
                     SELECT MAX(s2.id)
@@ -2970,20 +2970,20 @@  discard block
 block discarded – undo
2970 2970
         //mark all versions, but do not use group by reflink because y want the pages not versions
2971 2971
         $allpages = Database::query($sql);
2972 2972
         while ($row = Database::fetch_array($allpages)) {
2973
-            $total_teacher_assignment=$total_teacher_assignment+1;
2973
+            $total_teacher_assignment = $total_teacher_assignment + 1;
2974 2974
         }
2975 2975
 
2976 2976
         //Total pages identifies as student page (wiki portfolio mode - individual assignment)
2977 2977
 
2978
-        $total_student_assignment=0;
2978
+        $total_student_assignment = 0;
2979 2979
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2980 2980
                 WHERE s1.c_id = '.$course_id.' AND assignment=2 AND
2981 2981
                 id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2982 2982
                 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2983 2983
         //mark all versions, but do not use group by reflink because y want the pages not versions
2984
-        $allpages=Database::query($sql);
2985
-        while ($row=Database::fetch_array($allpages)) {
2986
-            $total_student_assignment = $total_student_assignment+1;
2984
+        $allpages = Database::query($sql);
2985
+        while ($row = Database::fetch_array($allpages)) {
2986
+            $total_student_assignment = $total_student_assignment + 1;
2987 2987
         }
2988 2988
 
2989 2989
         //Current Wiki status add new pages
@@ -2992,36 +2992,36 @@  discard block
 block discarded – undo
2992 2992
                 GROUP BY addlock';//group by because mark 0 in all vers, then always is ok
2993 2993
         $allpages = Database::query($sql);
2994 2994
         $wiki_add_lock = null;
2995
-        while ($row=Database::fetch_array($allpages)) {
2996
-            $wiki_add_lock=$row['addlock'];
2995
+        while ($row = Database::fetch_array($allpages)) {
2996
+            $wiki_add_lock = $row['addlock'];
2997 2997
         }
2998 2998
 
2999
-        if ($wiki_add_lock==1) {
3000
-            $status_add_new_pag=get_lang('Yes');
2999
+        if ($wiki_add_lock == 1) {
3000
+            $status_add_new_pag = get_lang('Yes');
3001 3001
         } else {
3002
-            $status_add_new_pag=get_lang('No');
3002
+            $status_add_new_pag = get_lang('No');
3003 3003
         }
3004 3004
 
3005 3005
         //Creation date of the oldest wiki page and version
3006 3006
 
3007
-        $first_wiki_date='0000-00-00 00:00:00';
3007
+        $first_wiki_date = '0000-00-00 00:00:00';
3008 3008
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3009 3009
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3010 3010
                 ORDER BY dtime ASC LIMIT 1';
3011
-        $allpages=Database::query($sql);
3012
-        while ($row=Database::fetch_array($allpages)) {
3013
-            $first_wiki_date=$row['dtime'];
3011
+        $allpages = Database::query($sql);
3012
+        while ($row = Database::fetch_array($allpages)) {
3013
+            $first_wiki_date = $row['dtime'];
3014 3014
         }
3015 3015
 
3016 3016
         // Date of publication of the latest wiki version.
3017 3017
 
3018
-        $last_wiki_date='0000-00-00 00:00:00';
3018
+        $last_wiki_date = '0000-00-00 00:00:00';
3019 3019
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3020 3020
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3021 3021
                 ORDER BY dtime DESC LIMIT 1';
3022
-        $allpages=Database::query($sql);
3023
-        while ($row=Database::fetch_array($allpages)) {
3024
-            $last_wiki_date=$row['dtime'];
3022
+        $allpages = Database::query($sql);
3023
+        while ($row = Database::fetch_array($allpages)) {
3024
+            $last_wiki_date = $row['dtime'];
3025 3025
         }
3026 3026
 
3027 3027
         // Average score of all wiki pages. (If a page has not scored zero rated)
@@ -3033,18 +3033,18 @@  discard block
 block discarded – undo
3033 3033
         // Do not use "count" because using "group by", would give a wrong value
3034 3034
         $allpages = Database::query($sql);
3035 3035
         $total_score = 0;
3036
-        while ($row=Database::fetch_array($allpages)) {
3037
-            $total_score = $total_score+$row['TOTAL_SCORE'];
3036
+        while ($row = Database::fetch_array($allpages)) {
3037
+            $total_score = $total_score + $row['TOTAL_SCORE'];
3038 3038
         }
3039 3039
 
3040 3040
         if (!empty($total_pages)) {
3041
-            $media_score = $total_score/$total_pages;
3041
+            $media_score = $total_score / $total_pages;
3042 3042
             //put always this line alfter check num all pages
3043 3043
         }
3044 3044
 
3045 3045
         // Average user progress in his pages.
3046 3046
 
3047
-        $media_progress=0;
3047
+        $media_progress = 0;
3048 3048
         $sql = 'SELECT  *, SUM(progress) AS TOTAL_PROGRESS
3049 3049
                 FROM  '.$tbl_wiki.' s1
3050 3050
                 WHERE s1.c_id = '.$course_id.' AND id=
@@ -3058,24 +3058,24 @@  discard block
 block discarded – undo
3058 3058
         // As the value is only the latest version I can not use group by
3059 3059
         $allpages = Database::query($sql);
3060 3060
         while ($row = Database::fetch_array($allpages)) {
3061
-            $total_progress	= $row['TOTAL_PROGRESS'];
3061
+            $total_progress = $row['TOTAL_PROGRESS'];
3062 3062
         }
3063 3063
 
3064 3064
         if (!empty($total_pages)) {
3065
-            $media_progress=$total_progress/$total_pages;
3065
+            $media_progress = $total_progress / $total_pages;
3066 3066
             //put always this line alfter check num all pages
3067 3067
         }
3068 3068
 
3069 3069
         //Total users that have participated in the Wiki
3070 3070
 
3071
-        $total_users=0;
3071
+        $total_users = 0;
3072 3072
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3073 3073
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3074 3074
                 GROUP BY user_id';
3075 3075
         //as the mark of user it in all versions of the page, I can use group by to see the first
3076
-        $allpages=Database::query($sql);
3077
-        while ($row=Database::fetch_array($allpages)) {
3078
-            $total_users = $total_users+1;
3076
+        $allpages = Database::query($sql);
3077
+        while ($row = Database::fetch_array($allpages)) {
3078
+            $total_users = $total_users + 1;
3079 3079
         }
3080 3080
 
3081 3081
         // Total of different IP addresses that have participated in the wiki
@@ -3083,9 +3083,9 @@  discard block
 block discarded – undo
3083 3083
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3084 3084
               WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3085 3085
               GROUP BY user_ip';
3086
-        $allpages=Database::query($sql);
3087
-        while ($row=Database::fetch_array($allpages)) {
3088
-            $total_ip	= $total_ip+1;
3086
+        $allpages = Database::query($sql);
3087
+        while ($row = Database::fetch_array($allpages)) {
3088
+            $total_ip = $total_ip + 1;
3089 3089
         }
3090 3090
 
3091 3091
         echo '<table class="data_table">';
@@ -3284,11 +3284,11 @@  discard block
 block discarded – undo
3284 3284
                 } else {
3285 3285
                     $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3286 3286
                 }
3287
-                $row[] ='<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
3287
+                $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
3288 3288
                 $rows[] = $row;
3289 3289
             }
3290 3290
 
3291
-            $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
3291
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'MostActiveUsersA_table', '', '', 'DESC');
3292 3292
             $table->set_additional_parameters(
3293 3293
                 array(
3294 3294
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -3297,8 +3297,8 @@  discard block
 block discarded – undo
3297 3297
                     'group_id' => Security::remove_XSS($_GET['group_id'])
3298 3298
                 )
3299 3299
             );
3300
-            $table->set_header(0,get_lang('Author'), true);
3301
-            $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
3300
+            $table->set_header(0, get_lang('Author'), true);
3301
+            $table->set_header(1, get_lang('Contributions'), true, array('style' => 'width:30px;'));
3302 3302
             $table->display();
3303 3303
         }
3304 3304
     }
@@ -3314,8 +3314,8 @@  discard block
 block discarded – undo
3314 3314
         $groupfilter = $this->groupfilter;
3315 3315
         $tbl_wiki_discuss = $this->tbl_wiki_discuss;
3316 3316
 
3317
-        if (api_get_session_id()!=0 &&
3318
-            api_is_allowed_to_session_edit(false,true)==false
3317
+        if (api_get_session_id() != 0 &&
3318
+            api_is_allowed_to_session_edit(false, true) == false
3319 3319
         ) {
3320 3320
             api_not_allowed();
3321 3321
         }
@@ -3378,9 +3378,9 @@  discard block
 block discarded – undo
3378 3378
         //mode assignment: previous to show  page type
3379 3379
         $icon_assignment = null;
3380 3380
         if ($row['assignment'] == 1) {
3381
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
3381
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
3382 3382
         } elseif ($row['assignment'] == 2) {
3383
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
3383
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
3384 3384
         }
3385 3385
 
3386 3386
         $countWPost = null;
@@ -3391,23 +3391,23 @@  discard block
 block discarded – undo
3391 3391
             // Show discussion to students if isn't hidden.
3392 3392
             // Show page to all teachers if is hidden.
3393 3393
             // Mode assignments: If is hidden, show pages to student only if student is the author
3394
-            if ($row['visibility_disc']==1 ||
3395
-                api_is_allowed_to_edit(false,true) ||
3394
+            if ($row['visibility_disc'] == 1 ||
3395
+                api_is_allowed_to_edit(false, true) ||
3396 3396
                 api_is_platform_admin() ||
3397
-                ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))
3397
+                ($row['assignment'] == 2 && $row['visibility_disc'] == 0 && (api_get_user_id() == $row['user_id']))
3398 3398
             ) {
3399 3399
                 echo '<div id="wikititle">';
3400 3400
 
3401 3401
                 // discussion action: protecting (locking) the discussion
3402 3402
                 $addlock_disc = null;
3403 3403
                 $lock_unlock_disc = null;
3404
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3404
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3405 3405
                     if (self::check_addlock_discuss() == 1) {
3406
-                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL);
3407
-                        $lock_unlock_disc ='unlockdisc';
3406
+                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'), '', ICON_SIZE_SMALL);
3407
+                        $lock_unlock_disc = 'unlockdisc';
3408 3408
                     } else {
3409
-                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL);
3410
-                        $lock_unlock_disc ='lockdisc';
3409
+                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'), '', ICON_SIZE_SMALL);
3410
+                        $lock_unlock_disc = 'lockdisc';
3411 3411
                     }
3412 3412
                 }
3413 3413
                 echo '<span style="float:right">';
@@ -3417,13 +3417,13 @@  discard block
 block discarded – undo
3417 3417
                 // discussion action: visibility.  Show discussion to students if isn't hidden. Show page to all teachers if is hidden.
3418 3418
                 $visibility_disc = null;
3419 3419
                 $hide_show_disc = null;
3420
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3421
-                    if (self::check_visibility_discuss()==1) {
3420
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3421
+                    if (self::check_visibility_discuss() == 1) {
3422 3422
                         /// TODO: 	Fix Mode assignments: If is hidden, show discussion to student only if student is the author
3423
-                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL);
3423
+                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'), '', ICON_SIZE_SMALL);
3424 3424
                         $hide_show_disc = 'hidedisc';
3425 3425
                     } else {
3426
-                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL);
3426
+                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'), '', ICON_SIZE_SMALL);
3427 3427
                         $hide_show_disc = 'showdisc';
3428 3428
                     }
3429 3429
                 }
@@ -3434,12 +3434,12 @@  discard block
 block discarded – undo
3434 3434
                 //discussion action: check add rating lock. Show/Hide list to rating for all student
3435 3435
                 $lock_unlock_rating_disc = null;
3436 3436
                 $ratinglock_disc = null;
3437
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3437
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3438 3438
                     if (self::check_ratinglock_discuss() == 1) {
3439
-                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3439
+                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3440 3440
                         $lock_unlock_rating_disc = 'unlockrating';
3441 3441
                     } else {
3442
-                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3442
+                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3443 3443
                         $lock_unlock_rating_disc = 'lockrating';
3444 3444
                     }
3445 3445
                 }
@@ -3450,11 +3450,11 @@  discard block
 block discarded – undo
3450 3450
 
3451 3451
                 //discussion action: email notification
3452 3452
                 if (self::check_notify_discuss($page) == 1) {
3453
-                    $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3454
-                    $lock_unlock_notify_disc='unlocknotifydisc';
3453
+                    $notify_disc = Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3454
+                    $lock_unlock_notify_disc = 'unlocknotifydisc';
3455 3455
                 } else {
3456
-                    $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3457
-                    $lock_unlock_notify_disc='locknotifydisc';
3456
+                    $notify_disc = Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3457
+                    $lock_unlock_notify_disc = 'locknotifydisc';
3458 3458
                 }
3459 3459
                 echo '<span style="float:right">';
3460 3460
                 echo '<a href="index.php?action=discuss&amp;actionpage='.$lock_unlock_notify_disc.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>';
@@ -3466,22 +3466,22 @@  discard block
 block discarded – undo
3466 3466
 
3467 3467
                 echo '</div>';
3468 3468
 
3469
-                if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3469
+                if ($row['addlock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3470 3470
                     //show comments but students can't add theirs
3471 3471
                     ?>
3472 3472
                     <form name="form1" method="post" action="">
3473 3473
                         <table>
3474 3474
                             <tr>
3475
-                                <td valign="top" ><?php echo get_lang('Comments');?>:</td>
3476
-                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?>
3475
+                                <td valign="top" ><?php echo get_lang('Comments'); ?>:</td>
3476
+                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">'; //prevent double post ?>
3477 3477
                                 <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
3478 3478
                             </tr>
3479 3479
                             <tr>
3480 3480
                                 <?php
3481 3481
                                 //check if rating is allowed
3482
-                                if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3482
+                                if ($row['ratinglock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3483 3483
                                     ?>
3484
-                                    <td><?php echo get_lang('Rating');?>: </td>
3484
+                                    <td><?php echo get_lang('Rating'); ?>: </td>
3485 3485
                                     <td valign="top"><select name="rating" id="rating">
3486 3486
                                             <option value="-" selected>-</option>
3487 3487
                                             <option value="0">0</option>
@@ -3498,7 +3498,7 @@  discard block
 block discarded – undo
3498 3498
                                         </select></td>
3499 3499
                                 <?php
3500 3500
                                 } else {
3501
-                                    echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically
3501
+                                    echo '<input type=hidden name="rating" value="-">'; // must pass a default value to avoid rate automatically
3502 3502
                                 }
3503 3503
                                 ?>
3504 3504
                             </tr>
@@ -3538,12 +3538,12 @@  discard block
 block discarded – undo
3538 3538
                 $sql = "SELECT * FROM $tbl_wiki_discuss
3539 3539
                         WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
3540 3540
                 $result3 = Database::query($sql);
3541
-                $countWPost_score= Database::num_rows($result3);
3541
+                $countWPost_score = Database::num_rows($result3);
3542 3542
 
3543
-                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;//
3543
+                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score; //
3544 3544
 
3545
-                if ($countWPost_score!=0) {
3546
-                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
3545
+                if ($countWPost_score != 0) {
3546
+                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score, 2).' / 10';
3547 3547
                 } else {
3548 3548
                     $avg_WPost_score = $countWPost_score;
3549 3549
                 }
@@ -3561,16 +3561,16 @@  discard block
 block discarded – undo
3561 3561
 
3562 3562
                 echo '<hr noshade size="1">';
3563 3563
 
3564
-                while ($row=Database::fetch_array($result)) {
3564
+                while ($row = Database::fetch_array($result)) {
3565 3565
                     $userinfo = api_get_user_info($row['userc_id']);
3566
-                    if (($userinfo['status'])=="5") {
3567
-                        $author_status=get_lang('Student');
3566
+                    if (($userinfo['status']) == "5") {
3567
+                        $author_status = get_lang('Student');
3568 3568
                     } else {
3569
-                        $author_status=get_lang('Teacher');
3569
+                        $author_status = get_lang('Teacher');
3570 3570
                     }
3571 3571
 
3572 3572
                     $name = $userinfo['complete_name'];
3573
-                    $author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3573
+                    $author_photo = '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3574 3574
 
3575 3575
                     //stars
3576 3576
                     $p_score = $row['p_score'];
@@ -3649,7 +3649,7 @@  discard block
 block discarded – undo
3649 3649
         }
3650 3650
         echo '</div>';
3651 3651
 
3652
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3652
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3653 3653
             $sql = 'SELECT  *
3654 3654
                     FROM  '.$tbl_wiki.' s1
3655 3655
         		    WHERE s1.c_id = '.$course_id.' AND id=(
@@ -3675,26 +3675,26 @@  discard block
 block discarded – undo
3675 3675
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
3676 3676
 
3677 3677
                 //get type assignment icon
3678
-                if ($obj->assignment==1) {
3679
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3680
-                } elseif ($obj->assignment==2) {
3681
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3682
-                } elseif ($obj->assignment==0) {
3678
+                if ($obj->assignment == 1) {
3679
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3680
+                } elseif ($obj->assignment == 2) {
3681
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3682
+                } elseif ($obj->assignment == 0) {
3683 3683
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
3684 3684
                 }
3685 3685
 
3686 3686
                 //get icon task
3687 3687
                 if (!empty($obj->task)) {
3688
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3688
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3689 3689
                 } else {
3690
-                    $icon_task= Display::return_icon('px_transparent.gif');
3690
+                    $icon_task = Display::return_icon('px_transparent.gif');
3691 3691
                 }
3692 3692
 
3693 3693
                 $row = array();
3694 3694
                 $row[] = $ShowAssignment.$icon_task;
3695 3695
                 $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">
3696 3696
                 '.api_htmlentities($obj->title).'</a>';
3697
-                if ($obj->user_id <>0) {
3697
+                if ($obj->user_id <> 0) {
3698 3698
                     $row[] = UserManager::getUserProfileLink($userinfo);
3699 3699
                 }
3700 3700
                 else {
@@ -3702,29 +3702,29 @@  discard block
 block discarded – undo
3702 3702
                 }
3703 3703
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
3704 3704
                 $showdelete = '';
3705
-                if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
3706
-                    $showdelete =' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3707
-                        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
3705
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3706
+                    $showdelete = ' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3707
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
3708 3708
                 }
3709
-                if (api_is_allowed_to_session_edit(false,true) ) {
3709
+                if (api_is_allowed_to_session_edit(false, true)) {
3710 3710
                     $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3711
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3712
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3713
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a>
3711
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3712
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3713
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a>
3714 3714
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3715
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
3715
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
3716 3716
                 }
3717 3717
                 $rows[] = $row;
3718 3718
             }
3719 3719
 
3720
-            $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
3721
-            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'group_id'=>Security::remove_XSS($_GET['group_id'])));
3722
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
3723
-            $table->set_header(1,get_lang('Title'), true);
3724
-            $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
3725
-            $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
3726
-            if (api_is_allowed_to_session_edit(false,true) ) {
3727
-                $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;'));
3720
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC');
3721
+            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']), 'action'=>Security::remove_XSS($action), 'group_id'=>Security::remove_XSS($_GET['group_id'])));
3722
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
3723
+            $table->set_header(1, get_lang('Title'), true);
3724
+            $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
3725
+            $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
3726
+            if (api_is_allowed_to_session_edit(false, true)) {
3727
+                $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;'));
3728 3728
             }
3729 3729
             $table->display();
3730 3730
         }
@@ -3744,13 +3744,13 @@  discard block
 block discarded – undo
3744 3744
         $groupfilter = $this->groupfilter;
3745 3745
         $tbl_wiki_conf = $this->tbl_wiki_conf;
3746 3746
 
3747
-        if (api_is_allowed_to_session_edit(false,true) ) {
3748
-            if (self::check_notify_all()==1) {
3749
-                $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3750
-                $lock_unlock_notify_all='unlocknotifyall';
3747
+        if (api_is_allowed_to_session_edit(false, true)) {
3748
+            if (self::check_notify_all() == 1) {
3749
+                $notify_all = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3750
+                $lock_unlock_notify_all = 'unlocknotifyall';
3751 3751
             } else {
3752
-                $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3753
-                $lock_unlock_notify_all='locknotifyall';
3752
+                $notify_all = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3753
+                $lock_unlock_notify_all = 'locknotifyall';
3754 3754
             }
3755 3755
         }
3756 3756
 
@@ -3758,7 +3758,7 @@  discard block
 block discarded – undo
3758 3758
         echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_all.'</a>';
3759 3759
         echo '</span>'.get_lang('RecentChanges').'</div>';
3760 3760
 
3761
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3761
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3762 3762
             $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
3763 3763
         		WHERE 	'.$tbl_wiki_conf.'.c_id= '.$course_id.' AND
3764 3764
         				'.$tbl_wiki.'.c_id= '.$course_id.' AND
@@ -3786,19 +3786,19 @@  discard block
 block discarded – undo
3786 3786
                 $userinfo = api_get_user_info($obj->user_id);
3787 3787
 
3788 3788
                 //get type assignment icon
3789
-                if ($obj->assignment==1) {
3790
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3791
-                } elseif ($obj->assignment==2) {
3792
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3793
-                } elseif ($obj->assignment==0) {
3794
-                    $ShowAssignment=Display::return_icon('px_transparent.gif');
3789
+                if ($obj->assignment == 1) {
3790
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3791
+                } elseif ($obj->assignment == 2) {
3792
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3793
+                } elseif ($obj->assignment == 0) {
3794
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
3795 3795
                 }
3796 3796
 
3797 3797
                 // Get icon task
3798 3798
                 if (!empty($obj->task)) {
3799
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3799
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3800 3800
                 } else {
3801
-                    $icon_task=Display::return_icon('px_transparent.gif');
3801
+                    $icon_task = Display::return_icon('px_transparent.gif');
3802 3802
                 }
3803 3803
 
3804 3804
                 $row = array();
@@ -3806,8 +3806,8 @@  discard block
 block discarded – undo
3806 3806
                 $row[] = $ShowAssignment.$icon_task;
3807 3807
                 $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&amp;view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
3808 3808
                     api_htmlentities($obj->title).'</a>';
3809
-                $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
3810
-                if ($obj->user_id <> 0 ) {
3809
+                $row[] = $obj->version > 1 ? get_lang('EditedBy') : get_lang('AddedBy');
3810
+                if ($obj->user_id <> 0) {
3811 3811
                     $row[] = UserManager::getUserProfileLink($userinfo);
3812 3812
                 } else {
3813 3813
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
@@ -3815,7 +3815,7 @@  discard block
 block discarded – undo
3815 3815
                 $rows[] = $row;
3816 3816
             }
3817 3817
 
3818
-            $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
3818
+            $table = new SortableTableFromArrayConfig($rows, 0, 10, 'RecentPages_table', '', '', 'DESC');
3819 3819
             $table->set_additional_parameters(
3820 3820
                 array(
3821 3821
                     'cidReq' =>api_get_course_id(),
@@ -3824,11 +3824,11 @@  discard block
 block discarded – undo
3824 3824
                     'group_id' => api_get_group_id()
3825 3825
                 )
3826 3826
             );
3827
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
3828
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
3829
-            $table->set_header(2,get_lang('Title'), true);
3830
-            $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
3831
-            $table->set_header(4,get_lang('Author'), true);
3827
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
3828
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
3829
+            $table->set_header(2, get_lang('Title'), true);
3830
+            $table->set_header(3, get_lang('Actions'), true, array('style' => 'width:80px;'));
3831
+            $table->set_header(4, get_lang('Author'), true);
3832 3832
             $table->display();
3833 3833
         }
3834 3834
     }
@@ -3860,17 +3860,17 @@  discard block
 block discarded – undo
3860 3860
 
3861 3861
             //get type assignment icon
3862 3862
             $ShowAssignment = '';
3863
-            if ($row['assignment']==1) {
3864
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3865
-            } elseif ($row['assignment']==2) {
3866
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3867
-            } elseif ($row['assignment']==0) {
3868
-                $ShowAssignment=Display::return_icon('px_transparent.gif');
3863
+            if ($row['assignment'] == 1) {
3864
+                $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3865
+            } elseif ($row['assignment'] == 2) {
3866
+                $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3867
+            } elseif ($row['assignment'] == 0) {
3868
+                $ShowAssignment = Display::return_icon('px_transparent.gif');
3869 3869
             }
3870 3870
 
3871 3871
             //fix Title to reflink (link Main Page)
3872
-            if ($page==get_lang('DefaultTitle')) {
3873
-                $page='index';
3872
+            if ($page == get_lang('DefaultTitle')) {
3873
+                $page = 'index';
3874 3874
             }
3875 3875
 
3876 3876
             echo '<div id="wikititle">';
@@ -3881,11 +3881,11 @@  discard block
 block discarded – undo
3881 3881
             //fix index to title Main page into linksto
3882 3882
 
3883 3883
             if ($page == 'index') {
3884
-                $page = str_replace(' ','_',get_lang('DefaultTitle'));
3884
+                $page = str_replace(' ', '_', get_lang('DefaultTitle'));
3885 3885
             }
3886 3886
 
3887 3887
             //table
3888
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3888
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3889 3889
                 //only by professors if page is hidden
3890 3890
                 $sql = "SELECT * FROM ".$tbl_wiki." s1
3891 3891
                         WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)."%' AND id=(
@@ -3912,25 +3912,25 @@  discard block
 block discarded – undo
3912 3912
                     //get time
3913 3913
                     $year 	 = substr($obj->dtime, 0, 4);
3914 3914
                     $month	 = substr($obj->dtime, 5, 2);
3915
-                    $day 	 = substr($obj->dtime, 8, 2);
3916
-                    $hours   = substr($obj->dtime, 11,2);
3917
-                    $minutes = substr($obj->dtime, 14,2);
3918
-                    $seconds = substr($obj->dtime, 17,2);
3915
+                    $day = substr($obj->dtime, 8, 2);
3916
+                    $hours   = substr($obj->dtime, 11, 2);
3917
+                    $minutes = substr($obj->dtime, 14, 2);
3918
+                    $seconds = substr($obj->dtime, 17, 2);
3919 3919
 
3920 3920
                     //get type assignment icon
3921
-                    if ($obj->assignment==1) {
3922
-                        $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3923
-                    } elseif ($obj->assignment==2) {
3924
-                        $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3925
-                    } elseif ($obj->assignment==0) {
3926
-                        $ShowAssignment=Display::return_icon('px_transparent.gif');
3921
+                    if ($obj->assignment == 1) {
3922
+                        $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3923
+                    } elseif ($obj->assignment == 2) {
3924
+                        $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3925
+                    } elseif ($obj->assignment == 0) {
3926
+                        $ShowAssignment = Display::return_icon('px_transparent.gif');
3927 3927
                     }
3928 3928
 
3929 3929
                     $row = array();
3930
-                    $row[] =$ShowAssignment;
3930
+                    $row[] = $ShowAssignment;
3931 3931
                     $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3932 3932
                         api_htmlentities($obj->title).'</a>';
3933
-                    if ($obj->user_id <>0) {
3933
+                    if ($obj->user_id <> 0) {
3934 3934
                         $row[] = UserManager::getUserProfileLink($userinfo);
3935 3935
                     }
3936 3936
                     else {
@@ -4039,7 +4039,7 @@  discard block
 block discarded – undo
4039 4039
             '&session_id='.$this->session_id.'&group_id='.$this->group_id.'">
4040 4040
             </a></div>';
4041 4041
 
4042
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4042
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4043 4043
             //only by professors if page is hidden
4044 4044
             $sql = 'SELECT * FROM '.$tbl_wiki.'
4045 4045
                     WHERE
@@ -4064,19 +4064,19 @@  discard block
 block discarded – undo
4064 4064
                 // Get time
4065 4065
                 $year 	 = substr($obj->dtime, 0, 4);
4066 4066
                 $month	 = substr($obj->dtime, 5, 2);
4067
-                $day 	 = substr($obj->dtime, 8, 2);
4068
-                $hours   = substr($obj->dtime, 11,2);
4069
-                $minutes = substr($obj->dtime, 14,2);
4070
-                $seconds = substr($obj->dtime, 17,2);
4067
+                $day = substr($obj->dtime, 8, 2);
4068
+                $hours   = substr($obj->dtime, 11, 2);
4069
+                $minutes = substr($obj->dtime, 14, 2);
4070
+                $seconds = substr($obj->dtime, 17, 2);
4071 4071
 
4072 4072
                 //get type assignment icon
4073 4073
                 $ShowAssignment = '';
4074
-                if ($obj->assignment==1) {
4075
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4076
-                } elseif ($obj->assignment==2) {
4077
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4078
-                } elseif ($obj->assignment==0) {
4079
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4074
+                if ($obj->assignment == 1) {
4075
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4076
+                } elseif ($obj->assignment == 2) {
4077
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4078
+                } elseif ($obj->assignment == 0) {
4079
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4080 4080
                 }
4081 4081
 
4082 4082
                 $row = array();
@@ -4092,7 +4092,7 @@  discard block
 block discarded – undo
4092 4092
 
4093 4093
             }
4094 4094
 
4095
-            $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
4095
+            $table = new SortableTableFromArrayConfig($rows, 2, 10, 'UsersContributions_table', '', '', 'ASC');
4096 4096
             $table->set_additional_parameters(
4097 4097
                 array(
4098 4098
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4102,13 +4102,13 @@  discard block
 block discarded – undo
4102 4102
                     'group_id' => intval($_GET['group_id']),
4103 4103
                 )
4104 4104
             );
4105
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
4106
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
4107
-            $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
4108
-            $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
4109
-            $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
4110
-            $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
4111
-            $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
4105
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
4106
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
4107
+            $table->set_header(2, get_lang('Title'), true, array('style' => 'width:200px;'));
4108
+            $table->set_header(3, get_lang('Version'), true, array('style' => 'width:30px;'));
4109
+            $table->set_header(4, get_lang('Comment'), true, array('style' => 'width:200px;'));
4110
+            $table->set_header(5, get_lang('Progress'), true, array('style' => 'width:30px;'));
4111
+            $table->set_header(6, get_lang('Rating'), true, array('style' => 'width:30px;'));
4112 4112
             $table->display();
4113 4113
         }
4114 4114
     }
@@ -4126,7 +4126,7 @@  discard block
 block discarded – undo
4126 4126
 
4127 4127
         echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
4128 4128
 
4129
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4129
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4130 4130
             $sql = 'SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'
4131 4131
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4132 4132
                     GROUP BY reflink';//TODO:check MAX and group by return last version
@@ -4144,12 +4144,12 @@  discard block
 block discarded – undo
4144 4144
             while ($obj = Database::fetch_object($allpages)) {
4145 4145
                 //get type assignment icon
4146 4146
                 $ShowAssignment = '';
4147
-                if ($obj->assignment==1) {
4148
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4149
-                } elseif ($obj->assignment==2) {
4150
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4151
-                } elseif ($obj->assignment==0) {
4152
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4147
+                if ($obj->assignment == 1) {
4148
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4149
+                } elseif ($obj->assignment == 2) {
4150
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4151
+                } elseif ($obj->assignment == 0) {
4152
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4153 4153
                 }
4154 4154
 
4155 4155
                 $row = array();
@@ -4177,9 +4177,9 @@  discard block
 block discarded – undo
4177 4177
                     'group_id' => intval($_GET['group_id']),
4178 4178
                 )
4179 4179
             );
4180
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4181
-            $table->set_header(1,get_lang('Title'), true);
4182
-            $table->set_header(2,get_lang('Changes'), true);
4180
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4181
+            $table->set_header(1, get_lang('Title'), true);
4182
+            $table->set_header(2, get_lang('Changes'), true);
4183 4183
             $table->display();
4184 4184
         }
4185 4185
     }
@@ -4204,7 +4204,7 @@  discard block
 block discarded – undo
4204 4204
         /* Only teachers and platform admin can edit the index page.
4205 4205
         Only teachers and platform admin can edit an assignment teacher*/
4206 4206
         if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) &&
4207
-            (!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
4207
+            (!api_is_allowed_to_edit(false, true) && $this->group_id == 0)
4208 4208
         ) {
4209 4209
             self::setMessage(
4210 4210
                 Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true)
@@ -4214,7 +4214,7 @@  discard block
 block discarded – undo
4214 4214
             // check if is a wiki group
4215 4215
             if ($current_row['group_id'] != 0) {
4216 4216
                 //Only teacher, platform admin and group members can edit a wiki group
4217
-                if (api_is_allowed_to_edit(false,true) ||
4217
+                if (api_is_allowed_to_edit(false, true) ||
4218 4218
                     api_is_platform_admin() ||
4219 4219
                     GroupManager :: is_user_in_group($userId, $this->group_id)
4220 4220
                 ) {
@@ -4232,9 +4232,9 @@  discard block
 block discarded – undo
4232 4232
             //$icon_assignment = null;
4233 4233
             if ($current_row['assignment'] == 1) {
4234 4234
                 self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
4235
-            } elseif($current_row['assignment']==2) {
4236
-                if (($userId == $current_row['user_id'])==false) {
4237
-                    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4235
+            } elseif ($current_row['assignment'] == 2) {
4236
+                if (($userId == $current_row['user_id']) == false) {
4237
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4238 4238
                         $PassEdit = true;
4239 4239
                     } else {
4240 4240
                         self::setMessage(Display::display_warning_message(get_lang('LockByTeacher'), false, true));
@@ -4248,11 +4248,11 @@  discard block
 block discarded – undo
4248 4248
             //show editor if edit is allowed
4249 4249
             if ($PassEdit) {
4250 4250
                 if ($current_row['editlock'] == 1 &&
4251
-                    (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)
4251
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4252 4252
                 ) {
4253 4253
                     self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
4254 4254
                 } else {
4255
-                    if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
4255
+                    if ($last_row['is_editing'] != 0 && $last_row['is_editing'] != $userId) {
4256 4256
                         // Checking for concurrent users
4257 4257
                         $timestamp_edit = strtotime($last_row['time_edit']);
4258 4258
                         $time_editing = time() - $timestamp_edit;
@@ -4261,7 +4261,7 @@  discard block
 block discarded – undo
4261 4261
                         $userinfo = api_get_user_info($last_row['is_editing']);
4262 4262
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'.
4263 4263
                             Display::tag('span', $userinfo['complete_name_with_username']).
4264
-                            get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
4264
+                            get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes');
4265 4265
                         self::setMessage(Display::display_normal_message($is_being_edited, false, true));
4266 4266
                     } else {
4267 4267
                         self::setMessage(Display::display_confirmation_message(
@@ -4369,9 +4369,9 @@  discard block
 block discarded – undo
4369 4369
                 GROUP BY reflink
4370 4370
                 ORDER BY reflink ASC';
4371 4371
         $allpages = Database::query($sql);
4372
-        while ($row=Database::fetch_array($allpages)) {
4373
-            if ($row['reflink']=='index') {
4374
-                $row['reflink']=str_replace(' ', '_', get_lang('DefaultTitle'));
4372
+        while ($row = Database::fetch_array($allpages)) {
4373
+            if ($row['reflink'] == 'index') {
4374
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4375 4375
             }
4376 4376
             $pages[] = $row['reflink'];
4377 4377
         }
@@ -4389,16 +4389,16 @@  discard block
 block discarded – undo
4389 4389
 
4390 4390
         $allpages = Database::query($sql);
4391 4391
 
4392
-        while ($row=Database::fetch_array($allpages)) {
4392
+        while ($row = Database::fetch_array($allpages)) {
4393 4393
             //remove self reference
4394
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
4394
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"]));
4395 4395
             $refs = explode(" ", trim($row["linksto"]));
4396 4396
 
4397 4397
             // Find linksto into reflink. If found ->page is linked
4398 4398
             foreach ($refs as $v) {
4399 4399
                 if (in_array($v, $pages)) {
4400
-                    if (trim($v)!="") {
4401
-                        $linked[]=$v;
4400
+                    if (trim($v) != "") {
4401
+                        $linked[] = $v;
4402 4402
                     }
4403 4403
                 }
4404 4404
             }
@@ -4410,12 +4410,12 @@  discard block
 block discarded – undo
4410 4410
         $rows = array();
4411 4411
         foreach ($linked as $linked_show) {
4412 4412
             $row = array();
4413
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_',' ',$linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
4414
-                str_replace('_',' ',$linked_show).'</a>';
4413
+            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_', ' ', $linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
4414
+                str_replace('_', ' ', $linked_show).'</a>';
4415 4415
             $rows[] = $row;
4416 4416
         }
4417 4417
 
4418
-        $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
4418
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'LinkedPages_table', '', '', 'DESC');
4419 4419
         $table->set_additional_parameters(
4420 4420
             array(
4421 4421
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4424,7 +4424,7 @@  discard block
 block discarded – undo
4424 4424
                 'group_id' => intval($_GET['group_id']),
4425 4425
             )
4426 4426
         );
4427
-        $table->set_header(0,get_lang('Title'), true);
4427
+        $table->set_header(0, get_lang('Title'), true);
4428 4428
         $table->display();
4429 4429
     }
4430 4430
 
@@ -4449,8 +4449,8 @@  discard block
 block discarded – undo
4449 4449
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4450 4450
                 GROUP BY reflink
4451 4451
                 ORDER BY reflink ASC';
4452
-        $allpages=Database::query($sql);
4453
-        while ($row=Database::fetch_array($allpages)) {
4452
+        $allpages = Database::query($sql);
4453
+        while ($row = Database::fetch_array($allpages)) {
4454 4454
             $pages[] = $row['reflink'];
4455 4455
         }
4456 4456
 
@@ -4465,14 +4465,14 @@  discard block
 block discarded – undo
4465 4465
                 )';
4466 4466
         $allpages = Database::query($sql);
4467 4467
         $array_refs_linked = array();
4468
-        while ($row=Database::fetch_array($allpages)) {
4469
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4468
+        while ($row = Database::fetch_array($allpages)) {
4469
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4470 4470
             $refs = explode(" ", trim($row["linksto"]));
4471
-            foreach ($refs as $ref_linked){
4472
-                if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
4473
-                    $ref_linked='index';
4471
+            foreach ($refs as $ref_linked) {
4472
+                if ($ref_linked == str_replace(' ', '_', get_lang('DefaultTitle'))) {
4473
+                    $ref_linked = 'index';
4474 4474
                 }
4475
-                $array_refs_linked[]= $ref_linked;
4475
+                $array_refs_linked[] = $ref_linked;
4476 4476
             }
4477 4477
         }
4478 4478
 
@@ -4494,20 +4494,20 @@  discard block
 block discarded – undo
4494 4494
 		                '.$groupfilter.$condition_session.' AND
4495 4495
 		                reflink="'.Database::escape_string($orphaned_show).'"
4496 4496
                     GROUP BY reflink';
4497
-            $allpages=Database::query($sql);
4498
-            while ($row=Database::fetch_array($allpages)) {
4499
-                $orphaned_title=$row['title'];
4500
-                $orphaned_visibility=$row['visibility'];
4501
-                if ($row['assignment']==1) {
4502
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
4503
-                } elseif ($row['assignment']==2) {
4504
-                    $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
4505
-                } elseif ($row['assignment']==0) {
4506
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4497
+            $allpages = Database::query($sql);
4498
+            while ($row = Database::fetch_array($allpages)) {
4499
+                $orphaned_title = $row['title'];
4500
+                $orphaned_visibility = $row['visibility'];
4501
+                if ($row['assignment'] == 1) {
4502
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', '', '', ICON_SIZE_SMALL);
4503
+                } elseif ($row['assignment'] == 2) {
4504
+                    $ShowAssignment = Display::return_icon('wiki_work.png', '', '', ICON_SIZE_SMALL);
4505
+                } elseif ($row['assignment'] == 0) {
4506
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4507 4507
                 }
4508 4508
             }
4509 4509
 
4510
-            if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() && $orphaned_visibility==0){
4510
+            if (!api_is_allowed_to_edit(false, true) || !api_is_platform_admin() && $orphaned_visibility == 0) {
4511 4511
                 continue;
4512 4512
             }
4513 4513
 
@@ -4519,7 +4519,7 @@  discard block
 block discarded – undo
4519 4519
             $rows[] = $row;
4520 4520
         }
4521 4521
 
4522
-        $table = new SortableTableFromArrayConfig($rows,1, 10, 'OrphanedPages_table','','','DESC');
4522
+        $table = new SortableTableFromArrayConfig($rows, 1, 10, 'OrphanedPages_table', '', '', 'DESC');
4523 4523
         $table->set_additional_parameters(
4524 4524
             array(
4525 4525
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4528,8 +4528,8 @@  discard block
 block discarded – undo
4528 4528
                 'group_id' => intval($_GET['group_id']),
4529 4529
             )
4530 4530
         );
4531
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4532
-        $table->set_header(1,get_lang('Title'), true);
4531
+        $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4532
+        $table->set_header(1, get_lang('Title'), true);
4533 4533
         $table->display();
4534 4534
     }
4535 4535
 
@@ -4551,11 +4551,11 @@  discard block
 block discarded – undo
4551 4551
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4552 4552
                 GROUP BY reflink
4553 4553
                 ORDER BY reflink ASC';
4554
-        $allpages=Database::query($sql);
4554
+        $allpages = Database::query($sql);
4555 4555
 
4556
-        while ($row=Database::fetch_array($allpages)) {
4557
-            if ($row['reflink']=='index'){
4558
-                $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
4556
+        while ($row = Database::fetch_array($allpages)) {
4557
+            if ($row['reflink'] == 'index') {
4558
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4559 4559
             }
4560 4560
             $pages[] = $row['reflink'];
4561 4561
         }
@@ -4569,31 +4569,31 @@  discard block
 block discarded – undo
4569 4569
 
4570 4570
         $allpages = Database::query($sql);
4571 4571
 
4572
-        while ($row=Database::fetch_array($allpages)) {
4572
+        while ($row = Database::fetch_array($allpages)) {
4573 4573
             $refs = explode(" ", trim($row["linksto"]));
4574 4574
             // Find linksto into reflink. If not found ->page is wanted
4575 4575
             foreach ($refs as $v) {
4576 4576
 
4577 4577
                 if (!in_array($v, $pages)) {
4578
-                    if (trim($v)!="") {
4579
-                        $wanted[]=$v;
4578
+                    if (trim($v) != "") {
4579
+                        $wanted[] = $v;
4580 4580
                     }
4581 4581
                 }
4582 4582
             }
4583 4583
         }
4584 4584
 
4585
-        $wanted = array_unique($wanted);//make a unique list
4585
+        $wanted = array_unique($wanted); //make a unique list
4586 4586
 
4587 4587
         //show table
4588 4588
         $rows = array();
4589 4589
         foreach ($wanted as $wanted_show) {
4590 4590
             $row = array();
4591 4591
             $wanted_show = Security::remove_XSS($wanted_show);
4592
-            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities
4592
+            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_', ' ', $wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_', ' ', $wanted_show).'</a>'; //meter un remove xss en lugar de htmlentities
4593 4593
             $rows[] = $row;
4594 4594
         }
4595 4595
 
4596
-        $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC');
4596
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'WantedPages_table', '', '', 'DESC');
4597 4597
         $table->set_additional_parameters(
4598 4598
             array(
4599 4599
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4602,7 +4602,7 @@  discard block
 block discarded – undo
4602 4602
                 'group_id' => intval($_GET['group_id']),
4603 4603
             )
4604 4604
         );
4605
-        $table->set_header(0,get_lang('Title'), true);
4605
+        $table->set_header(0, get_lang('Title'), true);
4606 4606
         $table->display();
4607 4607
     }
4608 4608
 
@@ -4619,7 +4619,7 @@  discard block
 block discarded – undo
4619 4619
 
4620 4620
         echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
4621 4621
 
4622
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4622
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4623 4623
             $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
4624 4624
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4625 4625
                     GROUP BY reflink';
@@ -4640,11 +4640,11 @@  discard block
 block discarded – undo
4640 4640
             while ($obj = Database::fetch_object($allpages)) {
4641 4641
                 //get type assignment icon
4642 4642
                 $ShowAssignment = '';
4643
-                if ($obj->assignment==1) {
4644
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4645
-                } elseif ($obj->assignment==2) {
4646
-                    $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4647
-                } elseif ($obj->assignment==0) {
4643
+                if ($obj->assignment == 1) {
4644
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4645
+                } elseif ($obj->assignment == 2) {
4646
+                    $ShowAssignment = $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4647
+                } elseif ($obj->assignment == 0) {
4648 4648
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
4649 4649
                 }
4650 4650
 
@@ -4673,7 +4673,7 @@  discard block
 block discarded – undo
4673 4673
                     'group_id' => intval($_GET['group_id']),
4674 4674
                 )
4675 4675
             );
4676
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4676
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4677 4677
             $table->set_header(1, get_lang('Title'), true);
4678 4678
             $table->set_header(2, get_lang('Visits'), true);
4679 4679
             $table->display();
@@ -4698,8 +4698,8 @@  discard block
 block discarded – undo
4698 4698
 
4699 4699
         if (api_is_allowed_to_session_edit(false, true) && api_is_allowed_to_edit()) {
4700 4700
             // menu add page
4701
-            $actionsLeft .= '<a href="index.php?cidReq=' . $_course['id'] . '&action=addnew&session_id=' . $session_id . '&group_id=' . $groupId . '"' . self::is_active_navigation_tab('addnew').'>'
4702
-            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM) . '</a>';
4701
+            $actionsLeft .= '<a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$groupId.'"'.self::is_active_navigation_tab('addnew').'>'
4702
+            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM).'</a>';
4703 4703
         }
4704 4704
 
4705 4705
         $lock_unlock_addnew = null;
@@ -4707,12 +4707,12 @@  discard block
 block discarded – undo
4707 4707
 
4708 4708
         if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4709 4709
             // page action: enable or disable the adding of new pages
4710
-            if (self::check_addnewpagelock()==0) {
4710
+            if (self::check_addnewpagelock() == 0) {
4711 4711
                 $protect_addnewpage = Display::return_icon('off.png', get_lang('AddOptionProtected'));
4712
-                $lock_unlock_addnew ='unlockaddnew';
4712
+                $lock_unlock_addnew = 'unlockaddnew';
4713 4713
             } else {
4714 4714
                 $protect_addnewpage = Display::return_icon('on.png', get_lang('AddOptionUnprotected'));
4715
-                $lock_unlock_addnew ='lockaddnew';
4715
+                $lock_unlock_addnew = 'lockaddnew';
4716 4716
             }
4717 4717
         }
4718 4718
 
@@ -4732,7 +4732,7 @@  discard block
 block discarded – undo
4732 4732
             get_lang('RecentChanges').'</a>';
4733 4733
 
4734 4734
 
4735
-        echo Display::toolbarAction('toolbar-wiki', array( 0 => $actionsLeft));
4735
+        echo Display::toolbarAction('toolbar-wiki', array(0 => $actionsLeft));
4736 4736
     }
4737 4737
 
4738 4738
     /**
@@ -4750,7 +4750,7 @@  discard block
 block discarded – undo
4750 4750
             return;
4751 4751
         }
4752 4752
 
4753
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4753
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4754 4754
             self::setMessage('<div id="wikititle">'.get_lang('DeletePageHistory').'</div>');
4755 4755
 
4756 4756
             if ($page == "index") {
@@ -4792,7 +4792,7 @@  discard block
 block discarded – undo
4792 4792
         $userId = api_get_user_id();
4793 4793
 
4794 4794
         if (api_get_session_id() != 0 &&
4795
-            api_is_allowed_to_session_edit(false,true) == false
4795
+            api_is_allowed_to_session_edit(false, true) == false
4796 4796
         ) {
4797 4797
             api_not_allowed();
4798 4798
         }
@@ -4815,12 +4815,12 @@  discard block
 block discarded – undo
4815 4815
                 Display::display_error_message(get_lang('MustSelectPage'), false, true)
4816 4816
             );
4817 4817
             return;
4818
-        } elseif ($row['content']=='' && $row['title']=='' && $page=='index') {
4818
+        } elseif ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
4819 4819
 
4820 4820
             // Table structure for better export to pdf
4821 4821
             $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
4822 4822
             $default_table_for_content_End = '</td></tr></table>';
4823
-            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4823
+            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4824 4824
             $title = get_lang('DefaultTitle');
4825 4825
             $page_id = 0;
4826 4826
         } else {
@@ -4845,7 +4845,7 @@  discard block
 block discarded – undo
4845 4845
             // Check if is a wiki group
4846 4846
             if (!empty($groupId)) {
4847 4847
                 //Only teacher, platform admin and group members can edit a wiki group
4848
-                if (api_is_allowed_to_edit(false,true) ||
4848
+                if (api_is_allowed_to_edit(false, true) ||
4849 4849
                     api_is_platform_admin() ||
4850 4850
                     GroupManager :: is_user_in_group($userId, $groupId)
4851 4851
                 ) {
@@ -4858,7 +4858,7 @@  discard block
 block discarded – undo
4858 4858
                     );
4859 4859
                 }
4860 4860
             } else {
4861
-                $PassEdit=true;
4861
+                $PassEdit = true;
4862 4862
             }
4863 4863
 
4864 4864
             $icon_assignment = null;
@@ -4868,10 +4868,10 @@  discard block
 block discarded – undo
4868 4868
                     Display::return_message(get_lang('EditAssignmentWarning'))
4869 4869
                 );
4870 4870
 
4871
-                $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4871
+                $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4872 4872
             } elseif ($row['assignment'] == 2) {
4873
-                $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
4874
-                if (($userId == $row['user_id'])==false) {
4873
+                $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
4874
+                if (($userId == $row['user_id']) == false) {
4875 4875
                     if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4876 4876
                         $PassEdit = true;
4877 4877
                     } else {
@@ -4891,7 +4891,7 @@  discard block
 block discarded – undo
4891 4891
             if ($PassEdit) {
4892 4892
                 //show editor if edit is allowed
4893 4893
                 if ($row['editlock'] == 1 &&
4894
-                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin()==false)
4894
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4895 4895
                 ) {
4896 4896
                     Display::addFlash(
4897 4897
                         Display::return_message(
@@ -4902,8 +4902,8 @@  discard block
 block discarded – undo
4902 4902
                     // Check tasks
4903 4903
 
4904 4904
                     if (!empty($row['startdate_assig']) &&
4905
-                        $row['startdate_assig']!='0000-00-00 00:00:00' &&
4906
-                        time()<strtotime($row['startdate_assig'])
4905
+                        $row['startdate_assig'] != '0000-00-00 00:00:00' &&
4906
+                        time() < strtotime($row['startdate_assig'])
4907 4907
                     ) {
4908 4908
                         $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
4909 4909
 
@@ -4920,10 +4920,10 @@  discard block
 block discarded – undo
4920 4920
                     }
4921 4921
 
4922 4922
                     if (!empty($row['enddate_assig']) &&
4923
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
4923
+                        $row['enddate_assig'] != '0000-00-00 00:00:00' &&
4924 4924
                         time() > strtotime($row['enddate_assig']) &&
4925
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
4926
-                        $row['delayedsubmit']==0
4925
+                        $row['enddate_assig'] != '0000-00-00 00:00:00' &&
4926
+                        $row['delayedsubmit'] == 0
4927 4927
                     ) {
4928 4928
                         $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
4929 4929
                         Display::addFlash(
@@ -4932,25 +4932,25 @@  discard block
 block discarded – undo
4932 4932
                                 'warning'
4933 4933
                             )
4934 4934
                         );
4935
-                        if (!api_is_allowed_to_edit(false,true)) {
4935
+                        if (!api_is_allowed_to_edit(false, true)) {
4936 4936
                             $this->redirectHome();
4937 4937
                         }
4938 4938
                     }
4939 4939
 
4940
-                    if (!empty($row['max_version']) && $row['version']>=$row['max_version']) {
4941
-                        $message=get_lang('HasReachedMaxiNumVersions');
4940
+                    if (!empty($row['max_version']) && $row['version'] >= $row['max_version']) {
4941
+                        $message = get_lang('HasReachedMaxiNumVersions');
4942 4942
                         Display::addFlash(
4943 4943
                             Display::return_message(
4944 4944
                                 $message,
4945 4945
                                 'warning'
4946 4946
                             )
4947 4947
                         );
4948
-                        if (!api_is_allowed_to_edit(false,true)) {
4948
+                        if (!api_is_allowed_to_edit(false, true)) {
4949 4949
                             $this->redirectHome();
4950 4950
                         }
4951 4951
                     }
4952 4952
 
4953
-                    if (!empty($row['max_text']) && $row['max_text']<=self::word_count($row['content'])) {
4953
+                    if (!empty($row['max_text']) && $row['max_text'] <= self::word_count($row['content'])) {
4954 4954
                         $message = get_lang('HasReachedMaxNumWords');
4955 4955
                         Display::addFlash(
4956 4956
                             Display::return_message(
@@ -4958,50 +4958,50 @@  discard block
 block discarded – undo
4958 4958
                                 'warning'
4959 4959
                             )
4960 4960
                         );
4961
-                        if (!api_is_allowed_to_edit(false,true)) {
4961
+                        if (!api_is_allowed_to_edit(false, true)) {
4962 4962
                             $this->redirectHome();
4963 4963
                         }
4964 4964
                     }
4965 4965
 
4966 4966
                     if (!empty($row['task'])) {
4967 4967
                         //previous change 0 by text
4968
-                        if ($row['startdate_assig']=='0000-00-00 00:00:00') {
4969
-                            $message_task_startdate  =get_lang('No');
4968
+                        if ($row['startdate_assig'] == '0000-00-00 00:00:00') {
4969
+                            $message_task_startdate = get_lang('No');
4970 4970
                         } else {
4971 4971
                             $message_task_startdate = api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
4972 4972
                         }
4973 4973
 
4974
-                        if ($row['enddate_assig']=='0000-00-00 00:00:00') {
4974
+                        if ($row['enddate_assig'] == '0000-00-00 00:00:00') {
4975 4975
                             $message_task_enddate = get_lang('No');
4976 4976
                         } else {
4977 4977
                             $message_task_enddate = api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
4978 4978
                         }
4979 4979
 
4980
-                        if ($row['delayedsubmit']==0) {
4981
-                            $message_task_delayedsubmit=get_lang('No');
4980
+                        if ($row['delayedsubmit'] == 0) {
4981
+                            $message_task_delayedsubmit = get_lang('No');
4982 4982
                         } else {
4983
-                            $message_task_delayedsubmit=get_lang('Yes');
4983
+                            $message_task_delayedsubmit = get_lang('Yes');
4984 4984
                         }
4985 4985
 
4986
-                        if ($row['max_version']==0) {
4987
-                            $message_task_max_version=get_lang('No');
4986
+                        if ($row['max_version'] == 0) {
4987
+                            $message_task_max_version = get_lang('No');
4988 4988
                         } else {
4989
-                            $message_task_max_version=$row['max_version'];
4989
+                            $message_task_max_version = $row['max_version'];
4990 4990
                         }
4991 4991
 
4992
-                        if ($row['max_text']==0) {
4993
-                            $message_task_max_text=get_lang('No');
4992
+                        if ($row['max_text'] == 0) {
4993
+                            $message_task_max_text = get_lang('No');
4994 4994
                         } else {
4995
-                            $message_task_max_text=$row['max_text'];
4995
+                            $message_task_max_text = $row['max_text'];
4996 4996
                         }
4997 4997
 
4998 4998
                         // Comp message
4999
-                        $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5000
-                        $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5001
-                        $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
5002
-                        $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5003
-                        $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5004
-                        $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
4999
+                        $message_task = '<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5000
+                        $message_task .= '<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5001
+                        $message_task .= '<p>'.get_lang('EndDate').': '.$message_task_enddate;
5002
+                        $message_task .= ' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5003
+                        $message_task .= '<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5004
+                        $message_task .= ' '.get_lang('NMaxWords').': '.$message_task_max_text;
5005 5005
                         // Display message
5006 5006
                         Display::addFlash(
5007 5007
                             Display::return_message(
@@ -5012,11 +5012,11 @@  discard block
 block discarded – undo
5012 5012
 
5013 5013
                     $feedback_message = '';
5014 5014
                     if ($row['progress'] == $row['fprogress1'] && !empty($row['fprogress1'])) {
5015
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5015
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5016 5016
                     } elseif ($row['progress'] == $row['fprogress2'] && !empty($row['fprogress2'])) {
5017
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5017
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5018 5018
                     } elseif ($row['progress'] == $row['fprogress3'] && !empty($row['fprogress3'])) {
5019
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5019
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5020 5020
                     }
5021 5021
 
5022 5022
                     if (!empty($feedback_message)) {
@@ -5041,14 +5041,14 @@  discard block
 block discarded – undo
5041 5041
                                 WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"';
5042 5042
                         Database::query($sql);
5043 5043
                     } elseif ($row['is_editing'] != $userId) {
5044
-                        $timestamp_edit=strtotime($row['time_edit']);
5044
+                        $timestamp_edit = strtotime($row['time_edit']);
5045 5045
                         $time_editing = time() - $timestamp_edit;
5046 5046
                         $max_edit_time = 1200; // 20 minutes
5047 5047
                         $rest_time = $max_edit_time - $time_editing;
5048 5048
 
5049 5049
                         $userinfo = api_get_user_info($row['is_editing']);
5050 5050
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).'
5051
-                            '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
5051
+                            '.get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes').'';
5052 5052
 
5053 5053
                         Display::addFlash(
5054 5054
                             Display::return_message(
@@ -5062,7 +5062,7 @@  discard block
 block discarded – undo
5062 5062
                     // Form.
5063 5063
                     $url = api_get_self().'?action=edit&title='.urlencode($page).'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'&'.api_get_cidreq();
5064 5064
                     $form = new FormValidator('wiki', 'post', $url);
5065
-                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;',3).api_htmlentities($title));
5065
+                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;', 3).api_htmlentities($title));
5066 5066
                     self::setForm($form, $row);
5067 5067
                     $form->addElement('hidden', 'title');
5068 5068
                     $form->addElement('button', 'SaveWikiChange', get_lang('Save'));
@@ -5085,7 +5085,7 @@  discard block
 block discarded – undo
5085 5085
                             );
5086 5086
                         } elseif (!self::double_post($_POST['wpost_id'])) {
5087 5087
                             //double post
5088
-                        } elseif ($_POST['version']!='' && $_SESSION['_version'] !=0 && $_POST['version'] != $_SESSION['_version']) {
5088
+                        } elseif ($_POST['version'] != '' && $_SESSION['_version'] != 0 && $_POST['version'] != $_SESSION['_version']) {
5089 5089
                             //prevent concurrent users and double version
5090 5090
                             Display::addFlash(
5091 5091
                                 Display::return_message(
@@ -5147,7 +5147,7 @@  discard block
 block discarded – undo
5147 5147
         $KeyAssignment = null;
5148 5148
         $KeyTitle = null;
5149 5149
         $KeyUserId = null;
5150
-        while ($row=Database::fetch_array($result)) {
5150
+        while ($row = Database::fetch_array($result)) {
5151 5151
             $KeyVisibility = $row['visibility'];
5152 5152
             $KeyAssignment = $row['assignment'];
5153 5153
             $KeyTitle = $row['title'];
@@ -5156,7 +5156,7 @@  discard block
 block discarded – undo
5156 5156
         $icon_assignment = null;
5157 5157
         if ($KeyAssignment == 1) {
5158 5158
             $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
5159
-        } elseif($KeyAssignment == 2) {
5159
+        } elseif ($KeyAssignment == 2) {
5160 5160
             $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
5161 5161
         }
5162 5162
 
@@ -5164,10 +5164,10 @@  discard block
 block discarded – undo
5164 5164
 
5165 5165
         //if the page is hidden and is a job only sees its author and professor
5166 5166
         if ($KeyVisibility == 1 ||
5167
-            api_is_allowed_to_edit(false,true) ||
5167
+            api_is_allowed_to_edit(false, true) ||
5168 5168
             api_is_platform_admin() ||
5169 5169
             (
5170
-                $KeyAssignment==2 && $KeyVisibility==0 &&
5170
+                $KeyAssignment == 2 && $KeyVisibility == 0 &&
5171 5171
                 ($userId == $KeyUserId)
5172 5172
             )
5173 5173
         ) {
@@ -5197,7 +5197,7 @@  discard block
 block discarded – undo
5197 5197
                     get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
5198 5198
                 echo '<br/><br/>';
5199 5199
 
5200
-                $counter=0;
5200
+                $counter = 0;
5201 5201
                 $total_versions = Database::num_rows($result);
5202 5202
 
5203 5203
                 while ($row = Database::fetch_array($result)) {
@@ -5205,10 +5205,10 @@  discard block
 block discarded – undo
5205 5205
                     $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
5206 5206
 
5207 5207
                     echo '<li style="margin-bottom: 5px;">';
5208
-                    ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
5209
-                    ($counter==0) ? $newchecked=' checked': $newchecked='';
5210
-                    ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
5211
-                    ($counter==1) ? $oldchecked=' checked':$oldchecked='';
5208
+                    ($counter == 0) ? $oldstyle = 'style="visibility: hidden;"' : $oldstyle = '';
5209
+                    ($counter == 0) ? $newchecked = ' checked' : $newchecked = '';
5210
+                    ($counter == $total_versions - 1) ? $newstyle = 'style="visibility: hidden;"' : $newstyle = '';
5211
+                    ($counter == 1) ? $oldchecked = ' checked' : $oldchecked = '';
5212 5212
                     echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
5213 5213
                     echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
5214 5214
                     echo '<a href="'.api_get_self().'?action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&amp;view='.$row['id'].'">';
@@ -5226,7 +5226,7 @@  discard block
 block discarded – undo
5226 5226
                     $comment = $row['comment'];
5227 5227
                     if (!empty($comment)) {
5228 5228
                         echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'], 0, 100));
5229
-                        if (api_strlen($row['comment'])>100) {
5229
+                        if (api_strlen($row['comment']) > 100) {
5230 5230
                             echo '... ';
5231 5231
                         }
5232 5232
                     } else {
@@ -5251,8 +5251,8 @@  discard block
 block discarded – undo
5251 5251
 
5252 5252
                 $sql_new = "SELECT * FROM $tbl_wiki
5253 5253
                             WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
5254
-                $result_new=Database::query($sql_new);
5255
-                $version_new=Database::fetch_array($result_new);
5254
+                $result_new = Database::query($sql_new);
5255
+                $version_new = Database::fetch_array($result_new);
5256 5256
                 $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
5257 5257
                 $oldContent = isset($version_old['content']) ? $version_old['content'] : null;
5258 5258
 
@@ -5279,9 +5279,9 @@  discard block
 block discarded – undo
5279 5279
 
5280 5280
 
5281 5281
                 if (isset($_POST['HistoryDifferences'])) {
5282
-                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words
5282
+                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line').'</table>'; // format_line mode is better for words
5283 5283
                     echo '<br />';
5284
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5284
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5285 5285
                     echo '<table><tr>';
5286 5286
                     echo  '<td>';
5287 5287
                     echo '</td><td>';
@@ -5300,7 +5300,7 @@  discard block
 block discarded – undo
5300 5300
                     $renderer = new Text_Diff_Renderer_inline();
5301 5301
                     echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
5302 5302
                     echo '<br />';
5303
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5303
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5304 5304
                     echo '<table><tr>';
5305 5305
                     echo  '<td>';
5306 5306
                     echo '</td><td>';
@@ -5348,7 +5348,7 @@  discard block
 block discarded – undo
5348 5348
         echo '<td style="vertical-align:top">';
5349 5349
         echo '<ul>';
5350 5350
         // Submenu Statistics
5351
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5351
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5352 5352
             echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>';
5353 5353
         }
5354 5354
         echo '      </ul>';
@@ -5421,7 +5421,7 @@  discard block
 block discarded – undo
5421 5421
                 break;
5422 5422
             case 'deletewiki':
5423 5423
                 $title = '<div class="actions">'.get_lang('DeleteWiki').'</div>';
5424
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5424
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5425 5425
                     $message = get_lang('ConfirmDeleteWiki');
5426 5426
                     $message .= '<p>
5427 5427
                         <a href="index.php?'.api_get_cidreq().'">'.get_lang('No').'</a>
@@ -5452,14 +5452,14 @@  discard block
 block discarded – undo
5452 5452
                 self::getLinks($page);
5453 5453
                 break;
5454 5454
             case 'addnew':
5455
-                if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
5455
+                if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
5456 5456
                     api_not_allowed();
5457 5457
                 }
5458 5458
                 echo '<div class="actions">'.get_lang('AddNew').'</div>';
5459 5459
                 echo '<br/>';
5460 5460
                 //first, check if page index was created. chektitle=false
5461 5461
                 if (self::checktitle('index')) {
5462
-                    if (api_is_allowed_to_edit(false,true) ||
5462
+                    if (api_is_allowed_to_edit(false, true) ||
5463 5463
                         api_is_platform_admin() ||
5464 5464
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
5465 5465
                     ) {
@@ -5467,10 +5467,10 @@  discard block
 block discarded – undo
5467 5467
                     } else {
5468 5468
                         self::setMessage(Display::display_normal_message(get_lang('WikiStandBy'), false, true));
5469 5469
                     }
5470
-                } elseif (self::check_addnewpagelock()==0 && (api_is_allowed_to_edit(false, true)==false || api_is_platform_admin()==false)) {
5470
+                } elseif (self::check_addnewpagelock() == 0 && (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)) {
5471 5471
                     self::setMessage(Display::display_error_message(get_lang('AddPagesLocked'), false, true));
5472 5472
                 } else {
5473
-                    if (api_is_allowed_to_edit(false,true) ||
5473
+                    if (api_is_allowed_to_edit(false, true) ||
5474 5474
                         api_is_platform_admin() ||
5475 5475
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
5476 5476
                         $_GET['group_id'] == 0
Please login to merge, or discard this patch.
Braces   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1879 1879
                 if($session_id==0){
1880 1880
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1881
-                }else{
1881
+                } else{
1882 1882
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1883 1883
                 }
1884 1884
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -2261,8 +2261,7 @@  discard block
 block discarded – undo
2261 2261
                                         s1.reflink = s2.reflink AND
2262 2262
                                         ".$groupfilter.$condition_session.")";
2263 2263
                     // warning don't use group by reflink because don't return the last version
2264
-                }
2265
-                else {
2264
+                } else {
2266 2265
                     $sql = " SELECT * FROM ".$tbl_wiki." s1
2267 2266
                             WHERE
2268 2267
                                 s1.c_id = $course_id AND
@@ -3696,8 +3695,7 @@  discard block
 block discarded – undo
3696 3695
                 '.api_htmlentities($obj->title).'</a>';
3697 3696
                 if ($obj->user_id <>0) {
3698 3697
                     $row[] = UserManager::getUserProfileLink($userinfo);
3699
-                }
3700
-                else {
3698
+                } else {
3701 3699
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
3702 3700
                 }
3703 3701
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
@@ -3932,8 +3930,7 @@  discard block
 block discarded – undo
3932 3930
                         api_htmlentities($obj->title).'</a>';
3933 3931
                     if ($obj->user_id <>0) {
3934 3932
                         $row[] = UserManager::getUserProfileLink($userinfo);
3935
-                    }
3936
-                    else {
3933
+                    } else {
3937 3934
                         $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3938 3935
                     }
3939 3936
                     $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
Please login to merge, or discard this patch.
main/work/downloadfolder.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
  * @param array $arr1 first array
213 213
  * @param array $arr2 second array
214 214
  *
215
- * @return array difference between the two arrays
215
+ * @return string difference between the two arrays
216 216
  */
217 217
 function diff($arr1, $arr2)
218 218
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 if (api_is_allowed_to_edit() || api_is_coach()) {
64 64
     //Search for all files that are not deleted => visibility != 2
65
-   $sql = "SELECT DISTINCT
65
+    $sql = "SELECT DISTINCT
66 66
                 url,
67 67
                 title,
68 68
                 description,
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 $work_id = $_GET['id'];
11 11
 require_once '../inc/global.inc.php';
12
-$current_course_tool  = TOOL_STUDENTPUBLICATION;
12
+$current_course_tool = TOOL_STUDENTPUBLICATION;
13 13
 $_course = api_get_course_info();
14 14
 
15 15
 // Protection
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 if (!empty($files)) {
179 179
     $fileName = api_replace_dangerous_char($work_data['title']);
180 180
     // Logging
181
-    Event::event_download($fileName .'.zip (folder)');
181
+    Event::event_download($fileName.'.zip (folder)');
182 182
 
183 183
     //start download of created file
184
-    $name = $fileName .'.zip';
184
+    $name = $fileName.'.zip';
185 185
     if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
186 186
         DocumentManager::file_send_for_download($temp_zip_file, true, $name);
187 187
         @unlink($temp_zip_file);
Please login to merge, or discard this patch.
main/work/upload_corrections.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use ChamiloSession as Session;
5 4
 use Symfony\Component\Finder\Finder;
6 5
 
7 6
 require_once '../inc/global.inc.php';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Symfony\Component\Finder\Finder;
6 6
 
7 7
 require_once '../inc/global.inc.php';
8
-$current_course_tool  = TOOL_STUDENTPUBLICATION;
8
+$current_course_tool = TOOL_STUDENTPUBLICATION;
9 9
 
10 10
 api_protect_course_script(true);
11 11
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $zip = new PclZip($_FILES['file']['tmp_name']);
71 71
 
72 72
         // Check the zip content (real size and file extension)
73
-        $zipFileList = (array)$zip->listContent();
73
+        $zipFileList = (array) $zip->listContent();
74 74
 
75 75
         $realSize = 0;
76 76
         foreach ($zipFileList as & $this_content) {
Please login to merge, or discard this patch.