Test Setup Failed
Push — master ( a0e228...8ccadc )
by Angel Fernando Quiroz
158:51 queued 93:10
created
main/auth/external_login/facebook.inc.php 2 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -18,14 +18,8 @@
 block discarded – undo
18 18
 use Facebook\FacebookSession;
19 19
 use Facebook\FacebookRedirectLoginHelper;
20 20
 use Facebook\FacebookRequest;
21
-use Facebook\FacebookResponse;
22 21
 use Facebook\FacebookSDKException;
23 22
 use Facebook\FacebookRequestException;
24
-use Facebook\FacebookAuthorizationException;
25
-use Facebook\GraphObject;
26
-use Facebook\Entities\AccessToken;
27
-use Facebook\HttpClients\FacebookCurlHttpClient;
28
-use Facebook\HttpClients\FacebookHttpable;
29 23
 
30 24
 require_once dirname(__FILE__) . '/functions.inc.php';
31 25
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * Please edit the facebook.conf.php file to adapt it to your fb application parameter
12 12
  */
13 13
 
14
-require_once dirname(__FILE__) . '/../../inc/global.inc.php';
15
-require_once dirname(__FILE__) . '/facebook.init.php';
16
-require_once dirname(__FILE__) . '/facebook-php-sdk/autoload.php';
14
+require_once dirname(__FILE__).'/../../inc/global.inc.php';
15
+require_once dirname(__FILE__).'/facebook.init.php';
16
+require_once dirname(__FILE__).'/facebook-php-sdk/autoload.php';
17 17
 
18 18
 use Facebook\FacebookSession;
19 19
 use Facebook\FacebookRedirectLoginHelper;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 use Facebook\HttpClients\FacebookCurlHttpClient;
28 28
 use Facebook\HttpClients\FacebookHttpable;
29 29
 
30
-require_once dirname(__FILE__) . '/functions.inc.php';
30
+require_once dirname(__FILE__).'/functions.inc.php';
31 31
 
32 32
 // dont rename $facebook_config to $facebookConfig otherwise get a "Facebook\\FacebookSDKException"
33 33
 FacebookSession::setDefaultApplication($facebook_config['appId'], $facebook_config['secret']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $locale = $graphObject->getProperty('locale');
58 58
             $language = facebookPluginGetLanguage($locale);
59 59
             if (!$language) {
60
-                $language='en_US';
60
+                $language = 'en_US';
61 61
             }
62 62
 
63 63
             //Checks if user already exists in chamilo
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                     $_user['user_id'] = $chamilo_uid;
86 86
                     $_user['uidReset'] = true;
87 87
                     $_SESSION['_user'] = $_user;
88
-                    header('Location:' . api_get_path(WEB_PATH));
88
+                    header('Location:'.api_get_path(WEB_PATH));
89 89
                     exit();
90 90
                 } else {
91 91
                     return false;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 $_user['user_id'] = $chamilo_uid;
99 99
                 $_user['uidReset'] = true;
100 100
                 $_SESSION['_user'] = $_user;
101
-                header('Location:' . api_get_path(WEB_PATH));
101
+                header('Location:'.api_get_path(WEB_PATH));
102 102
                 exit();
103 103
             }
104 104
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 {
118 118
     global $facebook_config;
119 119
     $helper = new FacebookRedirectLoginHelper($facebook_config['return_url']);
120
-    $loginUrl =   $helper->getLoginUrl(
120
+    $loginUrl = $helper->getLoginUrl(
121 121
         array('scope' => 'email')
122 122
     );
123 123
 
Please login to merge, or discard this patch.
main/inc/lib/export.lib.inc.php 2 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -3,14 +3,8 @@
 block discarded – undo
3 3
 
4 4
 use Ddeboer\DataImport\Writer\ExcelWriter;
5 5
 use Ddeboer\DataImport\Writer\CsvWriter;
6
-use Ddeboer\DataImport\Workflow;
7
-
8
-use Ddeboer\DataImport\Reader\CsvReader;
9
-use Ddeboer\DataImport\Reader\ArrayReader;
10
-use Ddeboer\DataImport\Writer\ArrayWriter;
11 6
 use Chamilo\CoreBundle\Component\Editor\Connector;
12 7
 use Chamilo\CoreBundle\Component\Filesystem\Data;
13
-use ChamiloSession as Session;
14 8
 use MediaAlchemyst\Alchemyst;
15 9
 use MediaAlchemyst\DriversContainer;
16 10
 use Neutron\TemporaryFilesystem\Manager;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $writer->setStream(fopen($filePath, 'w'));
51 51
 
52 52
         foreach ($data as $item) {
53
-            $item = is_array($item) ? $item : (array)$item;
53
+            $item = is_array($item) ? $item : (array) $item;
54 54
             $writer->writeItem($item);
55 55
         }
56 56
         $writer->finish();
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         }
101 101
         foreach ($data as $row) {
102 102
             $string = implode("</td><td>", $row);
103
-            $string = '<tr><td>' . $string . '</td></tr>';
103
+            $string = '<tr><td>'.$string.'</td></tr>';
104 104
             if ($encoding != 'utf-8') {
105 105
                 $string = api_convert_encoding($string, $encoding, $systemEncoding);
106 106
             }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             fwrite($handle, '<'.$wrapper_tagname.'>');
175 175
         }
176 176
         $s = self::_export_complex_table_xml_helper($data);
177
-        fwrite($handle,$s);
177
+        fwrite($handle, $s);
178 178
         if (!is_null($wrapper_tagname)) {
179 179
             fwrite($handle, '</'.$wrapper_tagname.'>'."\n");
180 180
         }
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
         }
197 197
         $string = '';
198 198
         foreach ($data as $row) {
199
-            $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>';
199
+            $string .= "\n".str_repeat("\t", $level).'<'.$row['name'].'>';
200 200
             if (is_array($row['value'])) {
201
-            	$string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n";
202
-                $string .= str_repeat("\t",$level).'</'.$row['name'].'>';
201
+            	$string .= self::_export_complex_table_xml_helper($row['value'], $level + 1)."\n";
202
+                $string .= str_repeat("\t", $level).'</'.$row['name'].'>';
203 203
             } else {
204 204
                 $string .= $row['value'];
205 205
                 $string .= '</'.$row['name'].'>';
Please login to merge, or discard this patch.
main/webservices/access_url.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
5
-use Chamilo\UserBundle\Entity\User;
6
-
7 4
 /**
8 5
  * @package chamilo.webservices
9 6
  */
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     }
76 76
 
77 77
     if ($debug) {
78
-        error_log("checkip " . intval($check_ip));
78
+        error_log("checkip ".intval($check_ip));
79 79
     }
80 80
 
81 81
     if ($check_ip) {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     '',
132 132
     'SOAP-ENC:Array',
133 133
     array(),
134
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:portalItem[]')),'tns:portalItem'
134
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:portalItem[]')), 'tns:portalItem'
135 135
 );
136 136
 
137 137
 $server->wsdl->addComplexType(
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 );
147 147
 
148 148
 // Register the method to expose
149
-$server->register('WSGetPortals',                   // method name
150
-    array('getPortals' => 'tns:getPortals'),    // input parameters
151
-    array('return' => 'tns:portalList'),                    // output parameters
152
-    'urn:WSAccessUrl',                               // namespace
153
-    'urn:WSAccessUrl#WSGetPortals',              // soapaction
154
-    'rpc',                                              // style
155
-    'encoded',                                          // use
149
+$server->register('WSGetPortals', // method name
150
+    array('getPortals' => 'tns:getPortals'), // input parameters
151
+    array('return' => 'tns:portalList'), // output parameters
152
+    'urn:WSAccessUrl', // namespace
153
+    'urn:WSAccessUrl#WSGetPortals', // soapaction
154
+    'rpc', // style
155
+    'encoded', // use
156 156
     'This service adds a user to portal'               // documentation
157 157
 );
158 158
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 );
194 194
 
195 195
 // Register the method to expose
196
-$server->register('WSAddUserToPortal',                   // method name
197
-    array('addUserToPortal' => 'tns:AddUserToPortal'),    // input parameters
198
-    array('return' => 'xsd:string'),                    // output parameters
199
-    'urn:WSAccessUrl',                               // namespace
200
-    'urn:WSAccessUrl#WSAddUserToPortal',              // soapaction
201
-    'rpc',                                              // style
202
-    'encoded',                                          // use
196
+$server->register('WSAddUserToPortal', // method name
197
+    array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters
198
+    array('return' => 'xsd:string'), // output parameters
199
+    'urn:WSAccessUrl', // namespace
200
+    'urn:WSAccessUrl#WSAddUserToPortal', // soapaction
201
+    'rpc', // style
202
+    'encoded', // use
203 203
     'This service adds a user to portal'               // documentation
204 204
 );
205 205
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 }
225 225
 
226 226
 // Register the method to expose
227
-$server->register('WSRemoveUserFromPortal',                      // method name
228
-    array('removeUserFromPortal' => 'tns:AddUserToPortal'),  // input parameters
229
-    array('return' => 'xsd:string'),                            // output parameters
230
-    'urn:WSAccessUrl',                                       // namespace
231
-    'urn:WSAccessUrl#WSRemoveUserFromPortal',                 // soapaction
232
-    'rpc',                                                      // style
233
-    'encoded',                                                  // use
227
+$server->register('WSRemoveUserFromPortal', // method name
228
+    array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters
229
+    array('return' => 'xsd:string'), // output parameters
230
+    'urn:WSAccessUrl', // namespace
231
+    'urn:WSAccessUrl#WSRemoveUserFromPortal', // soapaction
232
+    'rpc', // style
233
+    'encoded', // use
234 234
     'This service remove a user from a portal'                  // documentation
235 235
 );
236 236
 
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 );
268 268
 
269 269
 // Register the method to expose
270
-$server->register('WSGetPortalListFromUser',                      // method name
271
-    array('getPortalListFromUser' => 'tns:getPortalListFromUser'),  // input parameters
272
-    array('return' => 'tns:portalList'),                            // output parameters
273
-    'urn:WSAccessUrl',                                       // namespace
274
-    'urn:WSAccessUrl#WSGetPortalListFromUser',                 // soapaction
275
-    'rpc',                                                      // style
276
-    'encoded',                                                  // use
270
+$server->register('WSGetPortalListFromUser', // method name
271
+    array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters
272
+    array('return' => 'tns:portalList'), // output parameters
273
+    'urn:WSAccessUrl', // namespace
274
+    'urn:WSAccessUrl#WSGetPortalListFromUser', // soapaction
275
+    'rpc', // style
276
+    'encoded', // use
277 277
     'This service remove a user from a portal'                  // documentation
278 278
 );
279 279
 
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 );
312 312
 
313 313
 // Register the method to expose
314
-$server->register('WSGetPortalListFromCourse',                      // method name
315
-    array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'),  // input parameters
316
-    array('return' => 'tns:portalList'),                            // output parameters
317
-    'urn:WSAccessUrl',                                       // namespace
318
-    'urn:WSAccessUrl#getPortalListFromCourse',                 // soapaction
319
-    'rpc',                                                      // style
320
-    'encoded',                                                  // use
314
+$server->register('WSGetPortalListFromCourse', // method name
315
+    array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters
316
+    array('return' => 'tns:portalList'), // output parameters
317
+    'urn:WSAccessUrl', // namespace
318
+    'urn:WSAccessUrl#getPortalListFromCourse', // soapaction
319
+    'rpc', // style
320
+    'encoded', // use
321 321
     'This service remove a user from a portal'                  // documentation
322 322
 );
323 323
 
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 );
362 362
 
363 363
 // Register the method to expose
364
-$server->register('WSAddCourseToPortal',                   // method name
365
-    array('addCourseToPortal' => 'tns:addCourseToPortal'),    // input parameters
366
-    array('return' => 'xsd:string'),                    // output parameters
367
-    'urn:WSAccessUrl',                               // namespace
368
-    'urn:WSAccessUrl#WSAddCourseToPortal',              // soapaction
369
-    'rpc',                                              // style
370
-    'encoded',                                          // use
364
+$server->register('WSAddCourseToPortal', // method name
365
+    array('addCourseToPortal' => 'tns:addCourseToPortal'), // input parameters
366
+    array('return' => 'xsd:string'), // output parameters
367
+    'urn:WSAccessUrl', // namespace
368
+    'urn:WSAccessUrl#WSAddCourseToPortal', // soapaction
369
+    'rpc', // style
370
+    'encoded', // use
371 371
     'This service adds a course to portal'               // documentation
372 372
 );
373 373
 
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 }
395 395
 
396 396
 // Register the method to expose
397
-$server->register('WSRemoveCourseFromPortal',                      // method name
398
-    array('removeCourseFromPortal' => 'tns:addCourseToPortal'),  // input parameters
399
-    array('return' => 'xsd:string'),                            // output parameters
400
-    'urn:WSAccessUrl',                                       // namespace
401
-    'urn:WSAccessUrl#WSRemoveCourseFromPortal',                 // soapaction
402
-    'rpc',                                                      // style
403
-    'encoded',                                                  // use
397
+$server->register('WSRemoveCourseFromPortal', // method name
398
+    array('removeCourseFromPortal' => 'tns:addCourseToPortal'), // input parameters
399
+    array('return' => 'xsd:string'), // output parameters
400
+    'urn:WSAccessUrl', // namespace
401
+    'urn:WSAccessUrl#WSRemoveCourseFromPortal', // soapaction
402
+    'rpc', // style
403
+    'encoded', // use
404 404
     'This service remove a course from a portal'                  // documentation
405 405
 );
406 406
 
Please login to merge, or discard this patch.
main/wiki/wiki.inc.php 2 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   +647 added lines, -647 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&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&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&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&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
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
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('admin.administrator_email');
1876 1876
                 $sender_email = api_get_setting('admin.administrator_email');
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,23 +1956,23 @@  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,'../..'.api_get_path(REL_COURSE_PATH)) !== false) {
1975
+        if (api_strpos($wikiContents, '../..'.api_get_path(REL_COURSE_PATH)) !== false) {
1976 1976
             $web_course_path = api_get_path(WEB_COURSE_PATH);
1977 1977
             $wikiContents = str_replace('../..'.api_get_path(REL_COURSE_PATH), $web_course_path, $wikiContents);
1978 1978
         }
@@ -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(
@@ -2022,14 +2022,14 @@  discard block
 block discarded – undo
2022 2022
         $content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding());
2023 2023
 
2024 2024
         //clean wiki links
2025
-        $content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2025
+        $content_pdf = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2026 2026
         //TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links
2027 2027
 
2028 2028
         $title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding());
2029 2029
         $title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding());
2030 2030
         $content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding());
2031 2031
 
2032
-        $html='
2032
+        $html = '
2033 2033
         <!-- defines the headers/footers - this must occur before the headers/footers are set -->
2034 2034
 
2035 2035
         <!--mpdf
@@ -2087,9 +2087,9 @@  discard block
 block discarded – undo
2087 2087
         $session_id = $this->session_id;
2088 2088
         $groupId = api_get_group_id();
2089 2089
 
2090
-        if ($groupId==0) {
2090
+        if ($groupId == 0) {
2091 2091
             //extract course members
2092
-            if(!empty($session_id)) {
2092
+            if (!empty($session_id)) {
2093 2093
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id);
2094 2094
             } else {
2095 2095
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0);
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
2116 2116
         $name = $userinfo['complete_name']." - ".$username;
2117 2117
 
2118
-        $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '"  width="40" height="50" align="top" title="' . $name . '"  />';
2118
+        $photo = '<img src="'.$userinfo['avatar'].'" alt="'.$name.'"  width="40" height="50" align="top" title="'.$name.'"  />';
2119 2119
 
2120 2120
         // teacher assignment title
2121 2121
         $title_orig = $values['title'];
@@ -2143,24 +2143,24 @@  discard block
 block discarded – undo
2143 2143
                 $userPicture = UserManager::getUserPicture($assig_user_id);
2144 2144
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
2145 2145
                 $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
2146
-                $photo= '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2146
+                $photo = '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2147 2147
 
2148 2148
                 $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
2149 2149
                 $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
2150 2150
                 // student is tutor and member
2151 2151
 
2152 2152
                 if ($is_tutor_and_member) {
2153
-                    $status_in_group=get_lang('GroupTutorAndMember');
2153
+                    $status_in_group = get_lang('GroupTutorAndMember');
2154 2154
                 } else {
2155
-                    if($is_tutor_of_group) {
2156
-                        $status_in_group=get_lang('GroupTutor');
2155
+                    if ($is_tutor_of_group) {
2156
+                        $status_in_group = get_lang('GroupTutor');
2157 2157
                     } else {
2158
-                        $status_in_group=" "; //get_lang('GroupStandardMember')
2158
+                        $status_in_group = " "; //get_lang('GroupStandardMember')
2159 2159
                     }
2160 2160
                 }
2161 2161
 
2162
-                if ($assignment_type==1) {
2163
-                    $values['title']= $title_orig;
2162
+                if ($assignment_type == 1) {
2163
+                    $values['title'] = $title_orig;
2164 2164
                     $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
2165 2165
                     <table border="0">
2166 2166
                     <tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr>
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
                         ).
2177 2177
                         ' [['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>';
2178 2178
                     //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
2179
-                    $values['assignment']=2;
2179
+                    $values['assignment'] = 2;
2180 2180
                 }
2181 2181
                 $this->assig_user_id = $assig_user_id;
2182 2182
                 self::save_new_wiki($values);
@@ -2185,12 +2185,12 @@  discard block
 block discarded – undo
2185 2185
 
2186 2186
         foreach ($a_users_to_add as $o_user_to_add) {
2187 2187
             if ($o_user_to_add['user_id'] == $userId) {
2188
-                $assig_user_id=$o_user_to_add['user_id'];
2188
+                $assig_user_id = $o_user_to_add['user_id'];
2189 2189
                 if ($assignment_type == 1) {
2190
-                    $values['title']= $title_orig;
2191
-                    $values['comment']=get_lang('AssignmentDesc');
2190
+                    $values['title'] = $title_orig;
2191
+                    $values['comment'] = get_lang('AssignmentDesc');
2192 2192
                     sort($all_students_pages);
2193
-                    $values['content']=$content_orig_A.$content_orig_B.'<br/>
2193
+                    $values['content'] = $content_orig_A.$content_orig_B.'<br/>
2194 2194
                     <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
2195 2195
                     '.get_lang('AssignmentLinkstoStudentsPage').'
2196 2196
                     </div><br/>
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
                     <ol>'.implode($all_students_pages).'</ol>
2199 2199
                     </div>
2200 2200
                     <br/>';
2201
-                    $values['assignment']=1;
2201
+                    $values['assignment'] = 1;
2202 2202
                 }
2203 2203
                 $this->assig_user_id = $assig_user_id;
2204 2204
                 self::save_new_wiki($values);
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
      * @param   int     Whether to search the contents (1) or just the titles (0)
2213 2213
      * @param int
2214 2214
      */
2215
-    public function display_wiki_search_results($search_term, $search_content=0, $all_vers=0)
2215
+    public function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0)
2216 2216
     {
2217 2217
         $tbl_wiki = $this->tbl_wiki;
2218 2218
         $condition_session = $this->condition_session;
@@ -2224,9 +2224,9 @@  discard block
 block discarded – undo
2224 2224
         echo '</legend>';
2225 2225
 
2226 2226
         //only by professors when page is hidden
2227
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
2228
-            if ($all_vers=='1') {
2229
-                if ($search_content=='1') {
2227
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2228
+            if ($all_vers == '1') {
2229
+                if ($search_content == '1') {
2230 2230
                     $sql = "SELECT * FROM ".$tbl_wiki."
2231 2231
                             WHERE
2232 2232
                                 c_id = $course_id AND
@@ -2243,7 +2243,7 @@  discard block
 block discarded – undo
2243 2243
                     //search all pages and all versions
2244 2244
                 }
2245 2245
             } else {
2246
-                if ($search_content=='1') {
2246
+                if ($search_content == '1') {
2247 2247
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2248 2248
                             WHERE
2249 2249
                                 s1.c_id = $course_id AND
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
                     //search all pages and all versions
2295 2295
                 }
2296 2296
             } else {
2297
-                if($search_content=='1') {
2297
+                if ($search_content == '1') {
2298 2298
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2299 2299
                             WHERE
2300 2300
                                 s1.c_id = $course_id AND
@@ -2342,17 +2342,17 @@  discard block
 block discarded – undo
2342 2342
                 $seconds = substr($obj->dtime, 17, 2);
2343 2343
 
2344 2344
                 //get type assignment icon
2345
-                if($obj->assignment==1) {
2346
-                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
2347
-                } elseif ($obj->assignment==2) {
2348
-                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
2349
-                } elseif ($obj->assignment==0) {
2345
+                if ($obj->assignment == 1) {
2346
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
2347
+                } elseif ($obj->assignment == 2) {
2348
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
2349
+                } elseif ($obj->assignment == 0) {
2350 2350
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
2351 2351
                 }
2352 2352
                 $row = array();
2353 2353
                 $row[] = $ShowAssignment;
2354 2354
 
2355
-                if($all_vers=='1') {
2355
+                if ($all_vers == '1') {
2356 2356
                     $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'])).'">'.
2357 2357
                         api_htmlentities($obj->title).'</a>';
2358 2358
                 } else {
@@ -2363,21 +2363,21 @@  discard block
 block discarded – undo
2363 2363
                 $row[] = $obj->user_id != 0 ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')';
2364 2364
                 $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
2365 2365
 
2366
-                if ($all_vers=='1') {
2366
+                if ($all_vers == '1') {
2367 2367
                     $row[] = $obj->version;
2368 2368
                 } else {
2369 2369
                     $showdelete = '';
2370
-                    if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
2371
-                        $showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2372
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
2370
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2371
+                        $showdelete = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2372
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
2373 2373
                     }
2374 2374
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2375
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a>
2375
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a>
2376 2376
                         <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']).'">'.
2377
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a>
2377
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a>
2378 2378
                         <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']).'">'.
2379
-                        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']).'">'.
2380
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
2379
+                        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']).'">'.
2380
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
2381 2381
                 }
2382 2382
                 $rows[] = $row;
2383 2383
             }
@@ -2402,16 +2402,16 @@  discard block
 block discarded – undo
2402 2402
                     'all_vers' => $all_vers,
2403 2403
                 )
2404 2404
             );
2405
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
2406
-            $table->set_header(1,get_lang('Title'), true);
2405
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
2406
+            $table->set_header(1, get_lang('Title'), true);
2407 2407
             if ($all_vers == '1') {
2408
-                $table->set_header(2,get_lang('Author'), true);
2409
-                $table->set_header(3,get_lang('Date'), true);
2410
-                $table->set_header(4,get_lang('Version'), true);
2408
+                $table->set_header(2, get_lang('Author'), true);
2409
+                $table->set_header(3, get_lang('Date'), true);
2410
+                $table->set_header(4, get_lang('Version'), true);
2411 2411
             } else {
2412
-                $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
2413
-                $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
2414
-                $table->set_header(4,get_lang('Actions'), false, array ('style' => 'width:130px;'));
2412
+                $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
2413
+                $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
2414
+                $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;'));
2415 2415
             }
2416 2416
             $table->display();
2417 2417
         } else {
@@ -2424,14 +2424,14 @@  discard block
 block discarded – undo
2424 2424
      * @todo replace this function with the formvalidator datepicker
2425 2425
      *
2426 2426
      */
2427
-    public function draw_date_picker($prefix,$default='')
2427
+    public function draw_date_picker($prefix, $default = '')
2428 2428
     {
2429 2429
         if (empty($default)) {
2430 2430
             $default = date('Y-m-d H:i:s');
2431 2431
         }
2432 2432
         $parts = explode(' ', $default);
2433
-        list($d_year,$d_month,$d_day) = explode('-',$parts[0]);
2434
-        list($d_hour,$d_minute) = explode(':',$parts[1]);
2433
+        list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
2434
+        list($d_hour, $d_minute) = explode(':', $parts[1]);
2435 2435
 
2436 2436
         $month_list = array(
2437 2437
             1 => get_lang('JanuaryLong'),
@@ -2448,9 +2448,9 @@  discard block
 block discarded – undo
2448 2448
             12 => get_lang('DecemberLong'),
2449 2449
         );
2450 2450
 
2451
-        $minute = range(10,59);
2452
-        array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
2453
-        $date_form = self::make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day);
2451
+        $minute = range(10, 59);
2452
+        array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
2453
+        $date_form = self::make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day);
2454 2454
         $date_form .= self::make_select($prefix.'_month', $month_list, $d_month);
2455 2455
         $date_form .= self::make_select(
2456 2456
                 $prefix.'_year',
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
                 ),
2464 2464
                 $d_year
2465 2465
             ).'&nbsp;&nbsp;&nbsp;&nbsp;';
2466
-        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : ';
2466
+        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : ';
2467 2467
         $date_form .= self::make_select($prefix.'_minute', $minute, $d_minute);
2468 2468
 
2469 2469
         return $date_form;
@@ -2473,11 +2473,11 @@  discard block
 block discarded – undo
2473 2473
      * Draws an HTML form select with the given options
2474 2474
      *
2475 2475
      */
2476
-    public function make_select($name,$values,$checked='')
2476
+    public function make_select($name, $values, $checked = '')
2477 2477
     {
2478 2478
         $output = '<select name="'.$name.'" id="'.$name.'">';
2479
-        foreach($values as $key => $value) {
2480
-            $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
2479
+        foreach ($values as $key => $value) {
2480
+            $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2481 2481
         }
2482 2482
         $output .= '</select>';
2483 2483
         return $output;
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
      */
2502 2502
     public function two_digits($number)
2503 2503
     {
2504
-        $number = (int)$number;
2504
+        $number = (int) $number;
2505 2505
         return ($number < 10) ? '0'.$number : $number;
2506 2506
     }
2507 2507
 
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
                 WHERE c_id = '.$course_id.' AND id = '.$id.' ';
2520 2520
         $result = Database::query($sql);
2521 2521
         $data = array();
2522
-        while ($row=Database::fetch_array($result,'ASSOC'))   {
2522
+        while ($row = Database::fetch_array($result, 'ASSOC')) {
2523 2523
             $data = $row;
2524 2524
         }
2525 2525
         return $data;
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
         $result = Database::query($sql);
2574 2574
         $data = array();
2575 2575
         if (Database::num_rows($result)) {
2576
-            $data = Database::fetch_array($result,'ASSOC');
2576
+            $data = Database::fetch_array($result, 'ASSOC');
2577 2577
         }
2578 2578
 
2579 2579
         return $data;
@@ -2667,9 +2667,9 @@  discard block
 block discarded – undo
2667 2667
         $result = self::getAllWiki();
2668 2668
         if (!empty($result)) {
2669 2669
             foreach ($result  as $is_editing_block) {
2670
-                $max_edit_time	= 1200; // 20 minutes
2671
-                $timestamp_edit	= strtotime($is_editing_block['time_edit']);
2672
-                $time_editing	= time()-$timestamp_edit;
2670
+                $max_edit_time = 1200; // 20 minutes
2671
+                $timestamp_edit = strtotime($is_editing_block['time_edit']);
2672
+                $time_editing = time() - $timestamp_edit;
2673 2673
 
2674 2674
                 // First prevent concurrent users and double version
2675 2675
                 if ($is_editing_block['is_editing'] == $userId) {
@@ -2678,7 +2678,7 @@  discard block
 block discarded – undo
2678 2678
                     Session::erase('_version');
2679 2679
                 }
2680 2680
                 // Second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
2681
-                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action!='edit')) {
2681
+                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action != 'edit')) {
2682 2682
                     self::updateWikiIsEditing($is_editing_block['is_editing']);
2683 2683
                 }
2684 2684
             }
@@ -2726,7 +2726,7 @@  discard block
 block discarded – undo
2726 2726
                 FROM ".$tbl_wiki."
2727 2727
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2728 2728
 
2729
-        $allpages=Database::query($sql);
2729
+        $allpages = Database::query($sql);
2730 2730
         while ($row = Database::fetch_array($allpages)) {
2731 2731
             $total_versions = $row['TOTAL_VERS'];
2732 2732
             $total_visits = intval($row['TOTAL_VISITS']);
@@ -2736,30 +2736,30 @@  discard block
 block discarded – undo
2736 2736
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2737 2737
         $allpages = Database::query($sql);
2738 2738
 
2739
-        while ($row=Database::fetch_array($allpages)) {
2739
+        while ($row = Database::fetch_array($allpages)) {
2740 2740
             $total_words = $total_words + self::word_count($row['content']);
2741
-            $total_links 			= $total_links+substr_count($row['content'], "href=");
2742
-            $total_links_anchors 	= $total_links_anchors+substr_count($row['content'], 'href="#');
2743
-            $total_links_mail		= $total_links_mail+substr_count($row['content'], 'href="mailto');
2744
-            $total_links_ftp 		= $total_links_ftp+substr_count($row['content'], 'href="ftp');
2745
-            $total_links_irc		= $total_links_irc+substr_count($row['content'], 'href="irc');
2746
-            $total_links_news 		= $total_links_news+substr_count($row['content'], 'href="news');
2747
-            $total_wlinks 			= $total_wlinks+substr_count($row['content'], "[[");
2748
-            $total_images 			= $total_images+substr_count($row['content'], "<img");
2741
+            $total_links = $total_links + substr_count($row['content'], "href=");
2742
+            $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#');
2743
+            $total_links_mail		= $total_links_mail + substr_count($row['content'], 'href="mailto');
2744
+            $total_links_ftp 		= $total_links_ftp + substr_count($row['content'], 'href="ftp');
2745
+            $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc');
2746
+            $total_links_news = $total_links_news + substr_count($row['content'], 'href="news');
2747
+            $total_wlinks 			= $total_wlinks + substr_count($row['content'], "[[");
2748
+            $total_images 			= $total_images + substr_count($row['content'], "<img");
2749 2749
             $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
2750
-            $total_flash			= $total_flash+substr_count($clean_total_flash, '.swf"');
2750
+            $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"');
2751 2751
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2752
-            $total_mp3				= $total_mp3+substr_count($row['content'], ".mp3");
2753
-            $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
2754
-            $total_flv				=	$total_flv_p/5;
2755
-            $total_youtube			= $total_youtube+substr_count($row['content'], "http://www.youtube.com");
2756
-            $total_multimedia		= $total_multimedia+substr_count($row['content'], "video/x-msvideo");
2757
-            $total_tables			= $total_tables+substr_count($row['content'], "<table");
2752
+            $total_mp3				= $total_mp3 + substr_count($row['content'], ".mp3");
2753
+            $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv");
2754
+            $total_flv				= $total_flv_p / 5;
2755
+            $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com");
2756
+            $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo");
2757
+            $total_tables = $total_tables + substr_count($row['content'], "<table");
2758 2758
         }
2759 2759
 
2760 2760
         //check only last version of all pages (current page)
2761 2761
 
2762
-        $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2762
+        $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2763 2763
                 FROM  '.$tbl_wiki.' s1
2764 2764
                 WHERE s1.c_id = '.$course_id.' AND id=(
2765 2765
                     SELECT MAX(s2.id)
@@ -2770,9 +2770,9 @@  discard block
 block discarded – undo
2770 2770
                         '.$groupfilter.' AND
2771 2771
                         session_id='.$session_id.')';
2772 2772
         $allpages = Database::query($sql);
2773
-        while ($row=Database::fetch_array($allpages)) {
2774
-            $total_pages	 		= $row['TOTAL_PAGES'];
2775
-            $total_visits_lv 		= intval($row['TOTAL_VISITS_LV']);
2773
+        while ($row = Database::fetch_array($allpages)) {
2774
+            $total_pages = $row['TOTAL_PAGES'];
2775
+            $total_visits_lv = intval($row['TOTAL_VISITS_LV']);
2776 2776
         }
2777 2777
 
2778 2778
         $total_words_lv = 0;
@@ -2804,29 +2804,29 @@  discard block
 block discarded – undo
2804 2804
                 )';
2805 2805
         $allpages = Database::query($sql);
2806 2806
 
2807
-        while ($row=Database::fetch_array($allpages)) {
2808
-            $total_words_lv 		= $total_words_lv+ self::word_count($row['content']);
2809
-            $total_links_lv 		= $total_links_lv+substr_count($row['content'], "href=");
2810
-            $total_links_anchors_lv	= $total_links_anchors_lv+substr_count($row['content'], 'href="#');
2811
-            $total_links_mail_lv 	= $total_links_mail_lv+substr_count($row['content'], 'href="mailto');
2812
-            $total_links_ftp_lv 	= $total_links_ftp_lv+substr_count($row['content'], 'href="ftp');
2813
-            $total_links_irc_lv 	= $total_links_irc_lv+substr_count($row['content'], 'href="irc');
2814
-            $total_links_news_lv 	= $total_links_news_lv+substr_count($row['content'], 'href="news');
2815
-            $total_wlinks_lv 		= $total_wlinks_lv+substr_count($row['content'], "[[");
2816
-            $total_images_lv 		= $total_images_lv+substr_count($row['content'], "<img");
2807
+        while ($row = Database::fetch_array($allpages)) {
2808
+            $total_words_lv 		= $total_words_lv + self::word_count($row['content']);
2809
+            $total_links_lv 		= $total_links_lv + substr_count($row['content'], "href=");
2810
+            $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#');
2811
+            $total_links_mail_lv 	= $total_links_mail_lv + substr_count($row['content'], 'href="mailto');
2812
+            $total_links_ftp_lv 	= $total_links_ftp_lv + substr_count($row['content'], 'href="ftp');
2813
+            $total_links_irc_lv 	= $total_links_irc_lv + substr_count($row['content'], 'href="irc');
2814
+            $total_links_news_lv 	= $total_links_news_lv + substr_count($row['content'], 'href="news');
2815
+            $total_wlinks_lv 		= $total_wlinks_lv + substr_count($row['content'], "[[");
2816
+            $total_images_lv 		= $total_images_lv + substr_count($row['content'], "<img");
2817 2817
             $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
2818
-            $total_flash_lv			= $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
2818
+            $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"');
2819 2819
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2820
-            $total_mp3_lv			= $total_mp3_lv+substr_count($row['content'], ".mp3");
2821
-            $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
2822
-            $total_flv_lv			= $total_flv_p_lv/5;
2823
-            $total_youtube_lv		= $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com");
2824
-            $total_multimedia_lv	= $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo");
2825
-            $total_tables_lv		= $total_tables_lv+substr_count($row['content'], "<table");
2820
+            $total_mp3_lv			= $total_mp3_lv + substr_count($row['content'], ".mp3");
2821
+            $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv");
2822
+            $total_flv_lv			= $total_flv_p_lv / 5;
2823
+            $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com");
2824
+            $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo");
2825
+            $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table");
2826 2826
         }
2827 2827
 
2828 2828
         //Total pages edited at this time
2829
-        $total_editing_now=0;
2829
+        $total_editing_now = 0;
2830 2830
         $sql = 'SELECT *, COUNT(*) AS TOTAL_EDITING_NOW
2831 2831
                 FROM  '.$tbl_wiki.' s1
2832 2832
                 WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND
@@ -2841,66 +2841,66 @@  discard block
 block discarded – undo
2841 2841
         )';
2842 2842
 
2843 2843
         // Can not use group by because the mark is set in the latest version
2844
-        $allpages=Database::query($sql);
2845
-        while ($row=Database::fetch_array($allpages)) {
2846
-            $total_editing_now	= $row['TOTAL_EDITING_NOW'];
2844
+        $allpages = Database::query($sql);
2845
+        while ($row = Database::fetch_array($allpages)) {
2846
+            $total_editing_now = $row['TOTAL_EDITING_NOW'];
2847 2847
         }
2848 2848
 
2849 2849
         // Total hidden pages
2850
-        $total_hidden=0;
2850
+        $total_hidden = 0;
2851 2851
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2852 2852
                 WHERE  c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
2853 2853
                 GROUP BY reflink';
2854 2854
         // 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
2855
-        $allpages=Database::query($sql);
2856
-        while ($row=Database::fetch_array($allpages)) {
2857
-            $total_hidden = $total_hidden+1;
2855
+        $allpages = Database::query($sql);
2856
+        while ($row = Database::fetch_array($allpages)) {
2857
+            $total_hidden = $total_hidden + 1;
2858 2858
         }
2859 2859
 
2860 2860
         //Total protect pages
2861
-        $total_protected=0;
2861
+        $total_protected = 0;
2862 2862
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2863 2863
                 WHERE  c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.'
2864 2864
                 GROUP BY reflink';
2865 2865
         // or group by page_id. As the mark of protected page is the first version of the page, I can use group by
2866 2866
 
2867
-        $allpages=Database::query($sql);
2868
-        while ($row=Database::fetch_array($allpages)) {
2869
-            $total_protected = $total_protected+1;
2867
+        $allpages = Database::query($sql);
2868
+        while ($row = Database::fetch_array($allpages)) {
2869
+            $total_protected = $total_protected + 1;
2870 2870
         }
2871 2871
 
2872 2872
         // Total empty versions.
2873
-        $total_empty_content=0;
2873
+        $total_empty_content = 0;
2874 2874
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2875 2875
                 WHERE
2876 2876
                     c_id = '.$course_id.' AND
2877 2877
                     content="" AND
2878 2878
                     '.$groupfilter.$condition_session.'';
2879 2879
         $allpages = Database::query($sql);
2880
-        while ($row=Database::fetch_array($allpages)) {
2881
-            $total_empty_content	= $total_empty_content+1;
2880
+        while ($row = Database::fetch_array($allpages)) {
2881
+            $total_empty_content = $total_empty_content + 1;
2882 2882
         }
2883 2883
 
2884 2884
         //Total empty pages (last version)
2885 2885
 
2886
-        $total_empty_content_lv=0;
2886
+        $total_empty_content_lv = 0;
2887 2887
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2888 2888
                 WHERE s1.c_id = '.$course_id.' AND content="" AND id=(
2889 2889
                 SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2890 2890
                 WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2891
-        $allpages=Database::query($sql);
2891
+        $allpages = Database::query($sql);
2892 2892
         while ($row = Database::fetch_array($allpages)) {
2893
-            $total_empty_content_lv	= $total_empty_content_lv+1;
2893
+            $total_empty_content_lv = $total_empty_content_lv + 1;
2894 2894
         }
2895 2895
 
2896 2896
         // Total locked discuss pages
2897
-        $total_lock_disc=0;
2897
+        $total_lock_disc = 0;
2898 2898
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2899 2899
                 WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.'
2900 2900
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2901
-        $allpages=Database::query($sql);
2901
+        $allpages = Database::query($sql);
2902 2902
         while ($row = Database::fetch_array($allpages)) {
2903
-            $total_lock_disc	= $total_lock_disc+1;
2903
+            $total_lock_disc = $total_lock_disc + 1;
2904 2904
         }
2905 2905
 
2906 2906
         // Total hidden discuss pages.
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
         //group by because mark lock in all vers, then always is ok
2912 2912
         $allpages = Database::query($sql);
2913 2913
         while ($row = Database::fetch_array($allpages)) {
2914
-            $total_hidden_disc	= $total_hidden_disc+1;
2914
+            $total_hidden_disc = $total_hidden_disc + 1;
2915 2915
         }
2916 2916
 
2917 2917
         //Total versions with any short comment by user or system
@@ -2919,44 +2919,44 @@  discard block
 block discarded – undo
2919 2919
         $total_comment_version = 0;
2920 2920
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2921 2921
                 WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.'';
2922
-        $allpages=Database::query($sql);
2922
+        $allpages = Database::query($sql);
2923 2923
         while ($row = Database::fetch_array($allpages)) {
2924
-            $total_comment_version	= $total_comment_version+1;
2924
+            $total_comment_version = $total_comment_version + 1;
2925 2925
         }
2926 2926
 
2927 2927
         // Total pages that can only be scored by teachers.
2928 2928
 
2929
-        $total_only_teachers_rating=0;
2929
+        $total_only_teachers_rating = 0;
2930 2930
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2931 2931
                 WHERE c_id = '.$course_id.' AND
2932 2932
                 ratinglock_disc = 0 AND
2933 2933
                 '.$groupfilter.$condition_session.'
2934 2934
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2935
-        $allpages=Database::query($sql);
2936
-        while ($row=Database::fetch_array($allpages)) {
2937
-            $total_only_teachers_rating	= $total_only_teachers_rating+1;
2935
+        $allpages = Database::query($sql);
2936
+        while ($row = Database::fetch_array($allpages)) {
2937
+            $total_only_teachers_rating = $total_only_teachers_rating + 1;
2938 2938
         }
2939 2939
 
2940 2940
         // Total pages scored by peers
2941 2941
         // put always this line alfter check num all pages and num pages rated by teachers
2942
-        $total_rating_by_peers=$total_pages-$total_only_teachers_rating;
2942
+        $total_rating_by_peers = $total_pages - $total_only_teachers_rating;
2943 2943
 
2944 2944
         //Total pages identified as standard task
2945 2945
 
2946
-        $total_task=0;
2947
-        $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2946
+        $total_task = 0;
2947
+        $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2948 2948
               WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
2949 2949
                '.$tbl_wiki_conf.'.task!="" AND
2950 2950
                '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
2951 2951
                 '.$tbl_wiki.'.'.$groupfilter.$condition_session;
2952 2952
         $allpages = Database::query($sql);
2953
-        while ($row=Database::fetch_array($allpages)) {
2954
-            $total_task=$total_task+1;
2953
+        while ($row = Database::fetch_array($allpages)) {
2954
+            $total_task = $total_task + 1;
2955 2955
         }
2956 2956
 
2957 2957
         //Total pages identified as teacher page (wiki portfolio mode - individual assignment)
2958 2958
 
2959
-        $total_teacher_assignment=0;
2959
+        $total_teacher_assignment = 0;
2960 2960
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2961 2961
                 WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=(
2962 2962
                     SELECT MAX(s2.id)
@@ -2966,20 +2966,20 @@  discard block
 block discarded – undo
2966 2966
         //mark all versions, but do not use group by reflink because y want the pages not versions
2967 2967
         $allpages = Database::query($sql);
2968 2968
         while ($row = Database::fetch_array($allpages)) {
2969
-            $total_teacher_assignment=$total_teacher_assignment+1;
2969
+            $total_teacher_assignment = $total_teacher_assignment + 1;
2970 2970
         }
2971 2971
 
2972 2972
         //Total pages identifies as student page (wiki portfolio mode - individual assignment)
2973 2973
 
2974
-        $total_student_assignment=0;
2974
+        $total_student_assignment = 0;
2975 2975
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2976 2976
                 WHERE s1.c_id = '.$course_id.' AND assignment=2 AND
2977 2977
                 id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2978 2978
                 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2979 2979
         //mark all versions, but do not use group by reflink because y want the pages not versions
2980
-        $allpages=Database::query($sql);
2981
-        while ($row=Database::fetch_array($allpages)) {
2982
-            $total_student_assignment = $total_student_assignment+1;
2980
+        $allpages = Database::query($sql);
2981
+        while ($row = Database::fetch_array($allpages)) {
2982
+            $total_student_assignment = $total_student_assignment + 1;
2983 2983
         }
2984 2984
 
2985 2985
         //Current Wiki status add new pages
@@ -2988,36 +2988,36 @@  discard block
 block discarded – undo
2988 2988
                 GROUP BY addlock';//group by because mark 0 in all vers, then always is ok
2989 2989
         $allpages = Database::query($sql);
2990 2990
         $wiki_add_lock = null;
2991
-        while ($row=Database::fetch_array($allpages)) {
2992
-            $wiki_add_lock=$row['addlock'];
2991
+        while ($row = Database::fetch_array($allpages)) {
2992
+            $wiki_add_lock = $row['addlock'];
2993 2993
         }
2994 2994
 
2995
-        if ($wiki_add_lock==1) {
2996
-            $status_add_new_pag=get_lang('Yes');
2995
+        if ($wiki_add_lock == 1) {
2996
+            $status_add_new_pag = get_lang('Yes');
2997 2997
         } else {
2998
-            $status_add_new_pag=get_lang('No');
2998
+            $status_add_new_pag = get_lang('No');
2999 2999
         }
3000 3000
 
3001 3001
         //Creation date of the oldest wiki page and version
3002 3002
 
3003
-        $first_wiki_date='0000-00-00 00:00:00';
3003
+        $first_wiki_date = '0000-00-00 00:00:00';
3004 3004
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3005 3005
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3006 3006
                 ORDER BY dtime ASC LIMIT 1';
3007
-        $allpages=Database::query($sql);
3008
-        while ($row=Database::fetch_array($allpages)) {
3009
-            $first_wiki_date=$row['dtime'];
3007
+        $allpages = Database::query($sql);
3008
+        while ($row = Database::fetch_array($allpages)) {
3009
+            $first_wiki_date = $row['dtime'];
3010 3010
         }
3011 3011
 
3012 3012
         // Date of publication of the latest wiki version.
3013 3013
 
3014
-        $last_wiki_date='0000-00-00 00:00:00';
3014
+        $last_wiki_date = '0000-00-00 00:00:00';
3015 3015
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3016 3016
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3017 3017
                 ORDER BY dtime DESC LIMIT 1';
3018
-        $allpages=Database::query($sql);
3019
-        while ($row=Database::fetch_array($allpages)) {
3020
-            $last_wiki_date=$row['dtime'];
3018
+        $allpages = Database::query($sql);
3019
+        while ($row = Database::fetch_array($allpages)) {
3020
+            $last_wiki_date = $row['dtime'];
3021 3021
         }
3022 3022
 
3023 3023
         // Average score of all wiki pages. (If a page has not scored zero rated)
@@ -3029,18 +3029,18 @@  discard block
 block discarded – undo
3029 3029
         // Do not use "count" because using "group by", would give a wrong value
3030 3030
         $allpages = Database::query($sql);
3031 3031
         $total_score = 0;
3032
-        while ($row=Database::fetch_array($allpages)) {
3033
-            $total_score = $total_score+$row['TOTAL_SCORE'];
3032
+        while ($row = Database::fetch_array($allpages)) {
3033
+            $total_score = $total_score + $row['TOTAL_SCORE'];
3034 3034
         }
3035 3035
 
3036 3036
         if (!empty($total_pages)) {
3037
-            $media_score = $total_score/$total_pages;
3037
+            $media_score = $total_score / $total_pages;
3038 3038
             //put always this line alfter check num all pages
3039 3039
         }
3040 3040
 
3041 3041
         // Average user progress in his pages.
3042 3042
 
3043
-        $media_progress=0;
3043
+        $media_progress = 0;
3044 3044
         $sql = 'SELECT  *, SUM(progress) AS TOTAL_PROGRESS
3045 3045
                 FROM  '.$tbl_wiki.' s1
3046 3046
                 WHERE s1.c_id = '.$course_id.' AND id=
@@ -3054,24 +3054,24 @@  discard block
 block discarded – undo
3054 3054
         // As the value is only the latest version I can not use group by
3055 3055
         $allpages = Database::query($sql);
3056 3056
         while ($row = Database::fetch_array($allpages)) {
3057
-            $total_progress	= $row['TOTAL_PROGRESS'];
3057
+            $total_progress = $row['TOTAL_PROGRESS'];
3058 3058
         }
3059 3059
 
3060 3060
         if (!empty($total_pages)) {
3061
-            $media_progress=$total_progress/$total_pages;
3061
+            $media_progress = $total_progress / $total_pages;
3062 3062
             //put always this line alfter check num all pages
3063 3063
         }
3064 3064
 
3065 3065
         //Total users that have participated in the Wiki
3066 3066
 
3067
-        $total_users=0;
3067
+        $total_users = 0;
3068 3068
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3069 3069
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3070 3070
                 GROUP BY user_id';
3071 3071
         //as the mark of user it in all versions of the page, I can use group by to see the first
3072
-        $allpages=Database::query($sql);
3073
-        while ($row=Database::fetch_array($allpages)) {
3074
-            $total_users = $total_users+1;
3072
+        $allpages = Database::query($sql);
3073
+        while ($row = Database::fetch_array($allpages)) {
3074
+            $total_users = $total_users + 1;
3075 3075
         }
3076 3076
 
3077 3077
         // Total of different IP addresses that have participated in the wiki
@@ -3079,9 +3079,9 @@  discard block
 block discarded – undo
3079 3079
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3080 3080
               WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3081 3081
               GROUP BY user_ip';
3082
-        $allpages=Database::query($sql);
3083
-        while ($row=Database::fetch_array($allpages)) {
3084
-            $total_ip	= $total_ip+1;
3082
+        $allpages = Database::query($sql);
3083
+        while ($row = Database::fetch_array($allpages)) {
3084
+            $total_ip = $total_ip + 1;
3085 3085
         }
3086 3086
 
3087 3087
         echo '<table class="data_table">';
@@ -3280,11 +3280,11 @@  discard block
 block discarded – undo
3280 3280
                 } else {
3281 3281
                     $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3282 3282
                 }
3283
-                $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>';
3283
+                $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>';
3284 3284
                 $rows[] = $row;
3285 3285
             }
3286 3286
 
3287
-            $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
3287
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'MostActiveUsersA_table', '', '', 'DESC');
3288 3288
             $table->set_additional_parameters(
3289 3289
                 array(
3290 3290
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -3293,8 +3293,8 @@  discard block
 block discarded – undo
3293 3293
                     'group_id' => Security::remove_XSS($_GET['group_id'])
3294 3294
                 )
3295 3295
             );
3296
-            $table->set_header(0,get_lang('Author'), true);
3297
-            $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
3296
+            $table->set_header(0, get_lang('Author'), true);
3297
+            $table->set_header(1, get_lang('Contributions'), true, array('style' => 'width:30px;'));
3298 3298
             $table->display();
3299 3299
         }
3300 3300
     }
@@ -3310,8 +3310,8 @@  discard block
 block discarded – undo
3310 3310
         $groupfilter = $this->groupfilter;
3311 3311
         $tbl_wiki_discuss = $this->tbl_wiki_discuss;
3312 3312
 
3313
-        if (api_get_session_id()!=0 &&
3314
-            api_is_allowed_to_session_edit(false,true)==false
3313
+        if (api_get_session_id() != 0 &&
3314
+            api_is_allowed_to_session_edit(false, true) == false
3315 3315
         ) {
3316 3316
             api_not_allowed();
3317 3317
         }
@@ -3374,9 +3374,9 @@  discard block
 block discarded – undo
3374 3374
         //mode assignment: previous to show  page type
3375 3375
         $icon_assignment = null;
3376 3376
         if ($row['assignment'] == 1) {
3377
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
3377
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
3378 3378
         } elseif ($row['assignment'] == 2) {
3379
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
3379
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
3380 3380
         }
3381 3381
 
3382 3382
         $countWPost = null;
@@ -3387,23 +3387,23 @@  discard block
 block discarded – undo
3387 3387
             // Show discussion to students if isn't hidden.
3388 3388
             // Show page to all teachers if is hidden.
3389 3389
             // Mode assignments: If is hidden, show pages to student only if student is the author
3390
-            if ($row['visibility_disc']==1 ||
3391
-                api_is_allowed_to_edit(false,true) ||
3390
+            if ($row['visibility_disc'] == 1 ||
3391
+                api_is_allowed_to_edit(false, true) ||
3392 3392
                 api_is_platform_admin() ||
3393
-                ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))
3393
+                ($row['assignment'] == 2 && $row['visibility_disc'] == 0 && (api_get_user_id() == $row['user_id']))
3394 3394
             ) {
3395 3395
                 echo '<div id="wikititle">';
3396 3396
 
3397 3397
                 // discussion action: protecting (locking) the discussion
3398 3398
                 $addlock_disc = null;
3399 3399
                 $lock_unlock_disc = null;
3400
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3400
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3401 3401
                     if (self::check_addlock_discuss() == 1) {
3402
-                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL);
3403
-                        $lock_unlock_disc ='unlockdisc';
3402
+                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'), '', ICON_SIZE_SMALL);
3403
+                        $lock_unlock_disc = 'unlockdisc';
3404 3404
                     } else {
3405
-                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL);
3406
-                        $lock_unlock_disc ='lockdisc';
3405
+                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'), '', ICON_SIZE_SMALL);
3406
+                        $lock_unlock_disc = 'lockdisc';
3407 3407
                     }
3408 3408
                 }
3409 3409
                 echo '<span style="float:right">';
@@ -3414,13 +3414,13 @@  discard block
 block discarded – undo
3414 3414
                 // discussion action: visibility.  Show discussion to students if isn't hidden. Show page to all teachers if is hidden.
3415 3415
                 $visibility_disc = null;
3416 3416
                 $hide_show_disc = null;
3417
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3418
-                    if (self::check_visibility_discuss()==1) {
3417
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3418
+                    if (self::check_visibility_discuss() == 1) {
3419 3419
                         /// TODO: 	Fix Mode assignments: If is hidden, show discussion to student only if student is the author
3420
-                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL);
3420
+                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'), '', ICON_SIZE_SMALL);
3421 3421
                         $hide_show_disc = 'hidedisc';
3422 3422
                     } else {
3423
-                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL);
3423
+                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'), '', ICON_SIZE_SMALL);
3424 3424
                         $hide_show_disc = 'showdisc';
3425 3425
                     }
3426 3426
                 }
@@ -3431,12 +3431,12 @@  discard block
 block discarded – undo
3431 3431
                 //discussion action: check add rating lock. Show/Hide list to rating for all student
3432 3432
                 $lock_unlock_rating_disc = null;
3433 3433
                 $ratinglock_disc = null;
3434
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3434
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3435 3435
                     if (self::check_ratinglock_discuss() == 1) {
3436
-                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3436
+                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3437 3437
                         $lock_unlock_rating_disc = 'unlockrating';
3438 3438
                     } else {
3439
-                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3439
+                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3440 3440
                         $lock_unlock_rating_disc = 'lockrating';
3441 3441
                     }
3442 3442
                 }
@@ -3448,11 +3448,11 @@  discard block
 block discarded – undo
3448 3448
 
3449 3449
                 //discussion action: email notification
3450 3450
                 if (self::check_notify_discuss($page) == 1) {
3451
-                    $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3452
-                    $lock_unlock_notify_disc='unlocknotifydisc';
3451
+                    $notify_disc = Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3452
+                    $lock_unlock_notify_disc = 'unlocknotifydisc';
3453 3453
                 } else {
3454
-                    $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3455
-                    $lock_unlock_notify_disc='locknotifydisc';
3454
+                    $notify_disc = Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3455
+                    $lock_unlock_notify_disc = 'locknotifydisc';
3456 3456
                 }
3457 3457
                 echo '<span style="float:right">';
3458 3458
                 echo '<a href="index.php?'.api_get_cidreq().'&action=discuss&actionpage='.$lock_unlock_notify_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>';
@@ -3464,22 +3464,22 @@  discard block
 block discarded – undo
3464 3464
 
3465 3465
                 echo '</div>';
3466 3466
 
3467
-                if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3467
+                if ($row['addlock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3468 3468
                     //show comments but students can't add theirs
3469 3469
                     ?>
3470 3470
                     <form name="form1" method="post" action="">
3471 3471
                         <table>
3472 3472
                             <tr>
3473
-                                <td valign="top" ><?php echo get_lang('Comments');?>:</td>
3474
-                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?>
3473
+                                <td valign="top" ><?php echo get_lang('Comments'); ?>:</td>
3474
+                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">'; //prevent double post ?>
3475 3475
                                 <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
3476 3476
                             </tr>
3477 3477
                             <tr>
3478 3478
                                 <?php
3479 3479
                                 //check if rating is allowed
3480
-                                if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3480
+                                if ($row['ratinglock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3481 3481
                                     ?>
3482
-                                    <td><?php echo get_lang('Rating');?>: </td>
3482
+                                    <td><?php echo get_lang('Rating'); ?>: </td>
3483 3483
                                     <td valign="top"><select name="rating" id="rating">
3484 3484
                                             <option value="-" selected>-</option>
3485 3485
                                             <option value="0">0</option>
@@ -3496,7 +3496,7 @@  discard block
 block discarded – undo
3496 3496
                                         </select></td>
3497 3497
                                 <?php
3498 3498
                                 } else {
3499
-                                    echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically
3499
+                                    echo '<input type=hidden name="rating" value="-">'; // must pass a default value to avoid rate automatically
3500 3500
                                 }
3501 3501
                                 ?>
3502 3502
                             </tr>
@@ -3536,12 +3536,12 @@  discard block
 block discarded – undo
3536 3536
                 $sql = "SELECT * FROM $tbl_wiki_discuss
3537 3537
                         WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
3538 3538
                 $result3 = Database::query($sql);
3539
-                $countWPost_score= Database::num_rows($result3);
3539
+                $countWPost_score = Database::num_rows($result3);
3540 3540
 
3541
-                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;//
3541
+                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score; //
3542 3542
 
3543
-                if ($countWPost_score!=0) {
3544
-                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
3543
+                if ($countWPost_score != 0) {
3544
+                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score, 2).' / 10';
3545 3545
                 } else {
3546 3546
                     $avg_WPost_score = $countWPost_score;
3547 3547
                 }
@@ -3559,16 +3559,16 @@  discard block
 block discarded – undo
3559 3559
 
3560 3560
                 echo '<hr noshade size="1">';
3561 3561
 
3562
-                while ($row=Database::fetch_array($result)) {
3562
+                while ($row = Database::fetch_array($result)) {
3563 3563
                     $userinfo = api_get_user_info($row['userc_id']);
3564
-                    if (($userinfo['status'])=="5") {
3565
-                        $author_status=get_lang('Student');
3564
+                    if (($userinfo['status']) == "5") {
3565
+                        $author_status = get_lang('Student');
3566 3566
                     } else {
3567
-                        $author_status=get_lang('Teacher');
3567
+                        $author_status = get_lang('Teacher');
3568 3568
                     }
3569 3569
 
3570 3570
                     $name = $userinfo['complete_name'];
3571
-                    $author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3571
+                    $author_photo = '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3572 3572
 
3573 3573
                     //stars
3574 3574
                     $p_score = $row['p_score'];
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
         }
3648 3648
         echo '</div>';
3649 3649
 
3650
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3650
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3651 3651
             $sql = 'SELECT  *
3652 3652
                     FROM  '.$tbl_wiki.' s1
3653 3653
         		    WHERE s1.c_id = '.$course_id.' AND id=(
@@ -3673,26 +3673,26 @@  discard block
 block discarded – undo
3673 3673
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
3674 3674
 
3675 3675
                 //get type assignment icon
3676
-                if ($obj->assignment==1) {
3677
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3678
-                } elseif ($obj->assignment==2) {
3679
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3680
-                } elseif ($obj->assignment==0) {
3676
+                if ($obj->assignment == 1) {
3677
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3678
+                } elseif ($obj->assignment == 2) {
3679
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3680
+                } elseif ($obj->assignment == 0) {
3681 3681
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
3682 3682
                 }
3683 3683
 
3684 3684
                 //get icon task
3685 3685
                 if (!empty($obj->task)) {
3686
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3686
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3687 3687
                 } else {
3688
-                    $icon_task= Display::return_icon('px_transparent.gif');
3688
+                    $icon_task = Display::return_icon('px_transparent.gif');
3689 3689
                 }
3690 3690
 
3691 3691
                 $row = array();
3692 3692
                 $row[] = $ShowAssignment.$icon_task;
3693 3693
                 $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']).'">
3694 3694
                 '.api_htmlentities($obj->title).'</a>';
3695
-                if ($obj->user_id <>0) {
3695
+                if ($obj->user_id <> 0) {
3696 3696
                     $row[] = UserManager::getUserProfileLink($userinfo);
3697 3697
                 }
3698 3698
                 else {
@@ -3700,29 +3700,29 @@  discard block
 block discarded – undo
3700 3700
                 }
3701 3701
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
3702 3702
                 $showdelete = '';
3703
-                if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
3704
-                    $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']).'">'.
3705
-                        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
3703
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3704
+                    $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']).'">'.
3705
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
3706 3706
                 }
3707
-                if (api_is_allowed_to_session_edit(false,true) ) {
3707
+                if (api_is_allowed_to_session_edit(false, true)) {
3708 3708
                     $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']).'">'.
3709
-                        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']).'">'.
3710
-                        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']).'">'.
3711
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a>
3709
+                        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']).'">'.
3710
+                        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']).'">'.
3711
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a>
3712 3712
                         <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']).'">'.
3713
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
3713
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
3714 3714
                 }
3715 3715
                 $rows[] = $row;
3716 3716
             }
3717 3717
 
3718
-            $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
3719
-            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'group_id'=>Security::remove_XSS($_GET['group_id'])));
3720
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
3721
-            $table->set_header(1,get_lang('Title'), true);
3722
-            $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
3723
-            $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
3724
-            if (api_is_allowed_to_session_edit(false,true) ) {
3725
-                $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;'));
3718
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC');
3719
+            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']), 'action'=>Security::remove_XSS($action), 'group_id'=>Security::remove_XSS($_GET['group_id'])));
3720
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
3721
+            $table->set_header(1, get_lang('Title'), true);
3722
+            $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
3723
+            $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
3724
+            if (api_is_allowed_to_session_edit(false, true)) {
3725
+                $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;'));
3726 3726
             }
3727 3727
             $table->display();
3728 3728
         }
@@ -3742,13 +3742,13 @@  discard block
 block discarded – undo
3742 3742
         $groupfilter = $this->groupfilter;
3743 3743
         $tbl_wiki_conf = $this->tbl_wiki_conf;
3744 3744
 
3745
-        if (api_is_allowed_to_session_edit(false,true) ) {
3746
-            if (self::check_notify_all()==1) {
3747
-                $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3748
-                $lock_unlock_notify_all='unlocknotifyall';
3745
+        if (api_is_allowed_to_session_edit(false, true)) {
3746
+            if (self::check_notify_all() == 1) {
3747
+                $notify_all = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3748
+                $lock_unlock_notify_all = 'unlocknotifyall';
3749 3749
             } else {
3750
-                $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3751
-                $lock_unlock_notify_all='locknotifyall';
3750
+                $notify_all = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3751
+                $lock_unlock_notify_all = 'locknotifyall';
3752 3752
             }
3753 3753
         }
3754 3754
 
@@ -3757,7 +3757,7 @@  discard block
 block discarded – undo
3757 3757
             $notify_all.'</a>';
3758 3758
         echo '</span>'.get_lang('RecentChanges').'</div>';
3759 3759
 
3760
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3760
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3761 3761
             $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
3762 3762
         		WHERE 	'.$tbl_wiki_conf.'.c_id= '.$course_id.' AND
3763 3763
         				'.$tbl_wiki.'.c_id= '.$course_id.' AND
@@ -3785,19 +3785,19 @@  discard block
 block discarded – undo
3785 3785
                 $userinfo = api_get_user_info($obj->user_id);
3786 3786
 
3787 3787
                 //get type assignment icon
3788
-                if ($obj->assignment==1) {
3789
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3790
-                } elseif ($obj->assignment==2) {
3791
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3792
-                } elseif ($obj->assignment==0) {
3793
-                    $ShowAssignment=Display::return_icon('px_transparent.gif');
3788
+                if ($obj->assignment == 1) {
3789
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3790
+                } elseif ($obj->assignment == 2) {
3791
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3792
+                } elseif ($obj->assignment == 0) {
3793
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
3794 3794
                 }
3795 3795
 
3796 3796
                 // Get icon task
3797 3797
                 if (!empty($obj->task)) {
3798
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3798
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3799 3799
                 } else {
3800
-                    $icon_task=Display::return_icon('px_transparent.gif');
3800
+                    $icon_task = Display::return_icon('px_transparent.gif');
3801 3801
                 }
3802 3802
 
3803 3803
                 $row = array();
@@ -3805,8 +3805,8 @@  discard block
 block discarded – undo
3805 3805
                 $row[] = $ShowAssignment.$icon_task;
3806 3806
                 $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
3807 3807
                     api_htmlentities($obj->title).'</a>';
3808
-                $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
3809
-                if ($obj->user_id <> 0 ) {
3808
+                $row[] = $obj->version > 1 ? get_lang('EditedBy') : get_lang('AddedBy');
3809
+                if ($obj->user_id <> 0) {
3810 3810
                     $row[] = UserManager::getUserProfileLink($userinfo);
3811 3811
                 } else {
3812 3812
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
@@ -3814,7 +3814,7 @@  discard block
 block discarded – undo
3814 3814
                 $rows[] = $row;
3815 3815
             }
3816 3816
 
3817
-            $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
3817
+            $table = new SortableTableFromArrayConfig($rows, 0, 10, 'RecentPages_table', '', '', 'DESC');
3818 3818
             $table->set_additional_parameters(
3819 3819
                 array(
3820 3820
                     'cidReq' =>api_get_course_id(),
@@ -3823,11 +3823,11 @@  discard block
 block discarded – undo
3823 3823
                     'group_id' => api_get_group_id()
3824 3824
                 )
3825 3825
             );
3826
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
3827
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
3828
-            $table->set_header(2,get_lang('Title'), true);
3829
-            $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
3830
-            $table->set_header(4,get_lang('Author'), true);
3826
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
3827
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
3828
+            $table->set_header(2, get_lang('Title'), true);
3829
+            $table->set_header(3, get_lang('Actions'), true, array('style' => 'width:80px;'));
3830
+            $table->set_header(4, get_lang('Author'), true);
3831 3831
             $table->display();
3832 3832
         }
3833 3833
     }
@@ -3859,17 +3859,17 @@  discard block
 block discarded – undo
3859 3859
 
3860 3860
             //get type assignment icon
3861 3861
             $ShowAssignment = '';
3862
-            if ($row['assignment']==1) {
3863
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3864
-            } elseif ($row['assignment']==2) {
3865
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3866
-            } elseif ($row['assignment']==0) {
3867
-                $ShowAssignment=Display::return_icon('px_transparent.gif');
3862
+            if ($row['assignment'] == 1) {
3863
+                $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3864
+            } elseif ($row['assignment'] == 2) {
3865
+                $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3866
+            } elseif ($row['assignment'] == 0) {
3867
+                $ShowAssignment = Display::return_icon('px_transparent.gif');
3868 3868
             }
3869 3869
 
3870 3870
             //fix Title to reflink (link Main Page)
3871
-            if ($page==get_lang('DefaultTitle')) {
3872
-                $page='index';
3871
+            if ($page == get_lang('DefaultTitle')) {
3872
+                $page = 'index';
3873 3873
             }
3874 3874
 
3875 3875
             echo '<div id="wikititle">';
@@ -3880,11 +3880,11 @@  discard block
 block discarded – undo
3880 3880
             //fix index to title Main page into linksto
3881 3881
 
3882 3882
             if ($page == 'index') {
3883
-                $page = str_replace(' ','_',get_lang('DefaultTitle'));
3883
+                $page = str_replace(' ', '_', get_lang('DefaultTitle'));
3884 3884
             }
3885 3885
 
3886 3886
             //table
3887
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3887
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3888 3888
                 //only by professors if page is hidden
3889 3889
                 $sql = "SELECT * FROM ".$tbl_wiki." s1
3890 3890
                         WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)."%' AND id=(
@@ -3911,25 +3911,25 @@  discard block
 block discarded – undo
3911 3911
                     //get time
3912 3912
                     $year 	 = substr($obj->dtime, 0, 4);
3913 3913
                     $month	 = substr($obj->dtime, 5, 2);
3914
-                    $day 	 = substr($obj->dtime, 8, 2);
3915
-                    $hours   = substr($obj->dtime, 11,2);
3916
-                    $minutes = substr($obj->dtime, 14,2);
3917
-                    $seconds = substr($obj->dtime, 17,2);
3914
+                    $day = substr($obj->dtime, 8, 2);
3915
+                    $hours   = substr($obj->dtime, 11, 2);
3916
+                    $minutes = substr($obj->dtime, 14, 2);
3917
+                    $seconds = substr($obj->dtime, 17, 2);
3918 3918
 
3919 3919
                     //get type assignment icon
3920
-                    if ($obj->assignment==1) {
3921
-                        $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3922
-                    } elseif ($obj->assignment==2) {
3923
-                        $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3924
-                    } elseif ($obj->assignment==0) {
3925
-                        $ShowAssignment=Display::return_icon('px_transparent.gif');
3920
+                    if ($obj->assignment == 1) {
3921
+                        $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3922
+                    } elseif ($obj->assignment == 2) {
3923
+                        $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3924
+                    } elseif ($obj->assignment == 0) {
3925
+                        $ShowAssignment = Display::return_icon('px_transparent.gif');
3926 3926
                     }
3927 3927
 
3928 3928
                     $row = array();
3929
-                    $row[] =$ShowAssignment;
3929
+                    $row[] = $ShowAssignment;
3930 3930
                     $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']).'">'.
3931 3931
                         api_htmlentities($obj->title).'</a>';
3932
-                    if ($obj->user_id <>0) {
3932
+                    if ($obj->user_id <> 0) {
3933 3933
                         $row[] = UserManager::getUserProfileLink($userinfo);
3934 3934
                     }
3935 3935
                     else {
@@ -4038,7 +4038,7 @@  discard block
 block discarded – undo
4038 4038
             '&session_id='.$this->session_id.'&group_id='.$this->group_id.'">
4039 4039
             </a></div>';
4040 4040
 
4041
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4041
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4042 4042
             //only by professors if page is hidden
4043 4043
             $sql = 'SELECT * FROM '.$tbl_wiki.'
4044 4044
                     WHERE
@@ -4063,19 +4063,19 @@  discard block
 block discarded – undo
4063 4063
                 // Get time
4064 4064
                 $year 	 = substr($obj->dtime, 0, 4);
4065 4065
                 $month	 = substr($obj->dtime, 5, 2);
4066
-                $day 	 = substr($obj->dtime, 8, 2);
4067
-                $hours   = substr($obj->dtime, 11,2);
4068
-                $minutes = substr($obj->dtime, 14,2);
4069
-                $seconds = substr($obj->dtime, 17,2);
4066
+                $day = substr($obj->dtime, 8, 2);
4067
+                $hours   = substr($obj->dtime, 11, 2);
4068
+                $minutes = substr($obj->dtime, 14, 2);
4069
+                $seconds = substr($obj->dtime, 17, 2);
4070 4070
 
4071 4071
                 //get type assignment icon
4072 4072
                 $ShowAssignment = '';
4073
-                if ($obj->assignment==1) {
4074
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4075
-                } elseif ($obj->assignment==2) {
4076
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4077
-                } elseif ($obj->assignment==0) {
4078
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4073
+                if ($obj->assignment == 1) {
4074
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4075
+                } elseif ($obj->assignment == 2) {
4076
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4077
+                } elseif ($obj->assignment == 0) {
4078
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4079 4079
                 }
4080 4080
 
4081 4081
                 $row = array();
@@ -4091,7 +4091,7 @@  discard block
 block discarded – undo
4091 4091
 
4092 4092
             }
4093 4093
 
4094
-            $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
4094
+            $table = new SortableTableFromArrayConfig($rows, 2, 10, 'UsersContributions_table', '', '', 'ASC');
4095 4095
             $table->set_additional_parameters(
4096 4096
                 array(
4097 4097
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4101,13 +4101,13 @@  discard block
 block discarded – undo
4101 4101
                     'group_id' => intval($_GET['group_id']),
4102 4102
                 )
4103 4103
             );
4104
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
4105
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
4106
-            $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
4107
-            $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
4108
-            $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
4109
-            $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
4110
-            $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
4104
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
4105
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
4106
+            $table->set_header(2, get_lang('Title'), true, array('style' => 'width:200px;'));
4107
+            $table->set_header(3, get_lang('Version'), true, array('style' => 'width:30px;'));
4108
+            $table->set_header(4, get_lang('Comment'), true, array('style' => 'width:200px;'));
4109
+            $table->set_header(5, get_lang('Progress'), true, array('style' => 'width:30px;'));
4110
+            $table->set_header(6, get_lang('Rating'), true, array('style' => 'width:30px;'));
4111 4111
             $table->display();
4112 4112
         }
4113 4113
     }
@@ -4125,7 +4125,7 @@  discard block
 block discarded – undo
4125 4125
 
4126 4126
         echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
4127 4127
 
4128
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4128
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4129 4129
             $sql = 'SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'
4130 4130
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4131 4131
                     GROUP BY reflink';//TODO:check MAX and group by return last version
@@ -4143,12 +4143,12 @@  discard block
 block discarded – undo
4143 4143
             while ($obj = Database::fetch_object($allpages)) {
4144 4144
                 //get type assignment icon
4145 4145
                 $ShowAssignment = '';
4146
-                if ($obj->assignment==1) {
4147
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4148
-                } elseif ($obj->assignment==2) {
4149
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4150
-                } elseif ($obj->assignment==0) {
4151
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4146
+                if ($obj->assignment == 1) {
4147
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4148
+                } elseif ($obj->assignment == 2) {
4149
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4150
+                } elseif ($obj->assignment == 0) {
4151
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4152 4152
                 }
4153 4153
 
4154 4154
                 $row = array();
@@ -4176,9 +4176,9 @@  discard block
 block discarded – undo
4176 4176
                     'group_id' => intval($_GET['group_id']),
4177 4177
                 )
4178 4178
             );
4179
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4180
-            $table->set_header(1,get_lang('Title'), true);
4181
-            $table->set_header(2,get_lang('Changes'), true);
4179
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4180
+            $table->set_header(1, get_lang('Title'), true);
4181
+            $table->set_header(2, get_lang('Changes'), true);
4182 4182
             $table->display();
4183 4183
         }
4184 4184
     }
@@ -4203,7 +4203,7 @@  discard block
 block discarded – undo
4203 4203
         /* Only teachers and platform admin can edit the index page.
4204 4204
         Only teachers and platform admin can edit an assignment teacher*/
4205 4205
         if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) &&
4206
-            (!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
4206
+            (!api_is_allowed_to_edit(false, true) && $this->group_id == 0)
4207 4207
         ) {
4208 4208
             self::setMessage(
4209 4209
                 Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true)
@@ -4213,7 +4213,7 @@  discard block
 block discarded – undo
4213 4213
             // check if is a wiki group
4214 4214
             if ($current_row['group_id'] != 0) {
4215 4215
                 //Only teacher, platform admin and group members can edit a wiki group
4216
-                if (api_is_allowed_to_edit(false,true) ||
4216
+                if (api_is_allowed_to_edit(false, true) ||
4217 4217
                     api_is_platform_admin() ||
4218 4218
                     GroupManager :: is_user_in_group($userId, $this->group_id)
4219 4219
                 ) {
@@ -4231,9 +4231,9 @@  discard block
 block discarded – undo
4231 4231
             //$icon_assignment = null;
4232 4232
             if ($current_row['assignment'] == 1) {
4233 4233
                 self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
4234
-            } elseif($current_row['assignment']==2) {
4235
-                if (($userId == $current_row['user_id'])==false) {
4236
-                    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4234
+            } elseif ($current_row['assignment'] == 2) {
4235
+                if (($userId == $current_row['user_id']) == false) {
4236
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4237 4237
                         $PassEdit = true;
4238 4238
                     } else {
4239 4239
                         self::setMessage(Display::display_warning_message(get_lang('LockByTeacher'), false, true));
@@ -4247,11 +4247,11 @@  discard block
 block discarded – undo
4247 4247
             //show editor if edit is allowed
4248 4248
             if ($PassEdit) {
4249 4249
                 if ($current_row['editlock'] == 1 &&
4250
-                    (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)
4250
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4251 4251
                 ) {
4252 4252
                     self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
4253 4253
                 } else {
4254
-                    if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
4254
+                    if ($last_row['is_editing'] != 0 && $last_row['is_editing'] != $userId) {
4255 4255
                         // Checking for concurrent users
4256 4256
                         $timestamp_edit = strtotime($last_row['time_edit']);
4257 4257
                         $time_editing = time() - $timestamp_edit;
@@ -4260,7 +4260,7 @@  discard block
 block discarded – undo
4260 4260
                         $userinfo = api_get_user_info($last_row['is_editing']);
4261 4261
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'.
4262 4262
                             Display::tag('span', $userinfo['complete_name_with_username']).
4263
-                            get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
4263
+                            get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes');
4264 4264
                         self::setMessage(Display::display_normal_message($is_being_edited, false, true));
4265 4265
                     } else {
4266 4266
                         self::setMessage(Display::display_confirmation_message(
@@ -4368,9 +4368,9 @@  discard block
 block discarded – undo
4368 4368
                 GROUP BY reflink
4369 4369
                 ORDER BY reflink ASC';
4370 4370
         $allpages = Database::query($sql);
4371
-        while ($row=Database::fetch_array($allpages)) {
4372
-            if ($row['reflink']=='index') {
4373
-                $row['reflink']=str_replace(' ', '_', get_lang('DefaultTitle'));
4371
+        while ($row = Database::fetch_array($allpages)) {
4372
+            if ($row['reflink'] == 'index') {
4373
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4374 4374
             }
4375 4375
             $pages[] = $row['reflink'];
4376 4376
         }
@@ -4388,16 +4388,16 @@  discard block
 block discarded – undo
4388 4388
 
4389 4389
         $allpages = Database::query($sql);
4390 4390
 
4391
-        while ($row=Database::fetch_array($allpages)) {
4391
+        while ($row = Database::fetch_array($allpages)) {
4392 4392
             //remove self reference
4393
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
4393
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"]));
4394 4394
             $refs = explode(" ", trim($row["linksto"]));
4395 4395
 
4396 4396
             // Find linksto into reflink. If found ->page is linked
4397 4397
             foreach ($refs as $v) {
4398 4398
                 if (in_array($v, $pages)) {
4399
-                    if (trim($v)!="") {
4400
-                        $linked[]=$v;
4399
+                    if (trim($v) != "") {
4400
+                        $linked[] = $v;
4401 4401
                     }
4402 4402
                 }
4403 4403
             }
@@ -4409,12 +4409,12 @@  discard block
 block discarded – undo
4409 4409
         $rows = array();
4410 4410
         foreach ($linked as $linked_show) {
4411 4411
             $row = array();
4412
-            $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']).'">'.
4413
-                str_replace('_',' ',$linked_show).'</a>';
4412
+            $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']).'">'.
4413
+                str_replace('_', ' ', $linked_show).'</a>';
4414 4414
             $rows[] = $row;
4415 4415
         }
4416 4416
 
4417
-        $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
4417
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'LinkedPages_table', '', '', 'DESC');
4418 4418
         $table->set_additional_parameters(
4419 4419
             array(
4420 4420
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4423,7 +4423,7 @@  discard block
 block discarded – undo
4423 4423
                 'group_id' => intval($_GET['group_id']),
4424 4424
             )
4425 4425
         );
4426
-        $table->set_header(0,get_lang('Title'), true);
4426
+        $table->set_header(0, get_lang('Title'), true);
4427 4427
         $table->display();
4428 4428
     }
4429 4429
 
@@ -4448,8 +4448,8 @@  discard block
 block discarded – undo
4448 4448
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4449 4449
                 GROUP BY reflink
4450 4450
                 ORDER BY reflink ASC';
4451
-        $allpages=Database::query($sql);
4452
-        while ($row=Database::fetch_array($allpages)) {
4451
+        $allpages = Database::query($sql);
4452
+        while ($row = Database::fetch_array($allpages)) {
4453 4453
             $pages[] = $row['reflink'];
4454 4454
         }
4455 4455
 
@@ -4464,14 +4464,14 @@  discard block
 block discarded – undo
4464 4464
                 )';
4465 4465
         $allpages = Database::query($sql);
4466 4466
         $array_refs_linked = array();
4467
-        while ($row=Database::fetch_array($allpages)) {
4468
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4467
+        while ($row = Database::fetch_array($allpages)) {
4468
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4469 4469
             $refs = explode(" ", trim($row["linksto"]));
4470
-            foreach ($refs as $ref_linked){
4471
-                if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
4472
-                    $ref_linked='index';
4470
+            foreach ($refs as $ref_linked) {
4471
+                if ($ref_linked == str_replace(' ', '_', get_lang('DefaultTitle'))) {
4472
+                    $ref_linked = 'index';
4473 4473
                 }
4474
-                $array_refs_linked[]= $ref_linked;
4474
+                $array_refs_linked[] = $ref_linked;
4475 4475
             }
4476 4476
         }
4477 4477
 
@@ -4493,20 +4493,20 @@  discard block
 block discarded – undo
4493 4493
 		                '.$groupfilter.$condition_session.' AND
4494 4494
 		                reflink="'.Database::escape_string($orphaned_show).'"
4495 4495
                     GROUP BY reflink';
4496
-            $allpages=Database::query($sql);
4497
-            while ($row=Database::fetch_array($allpages)) {
4498
-                $orphaned_title=$row['title'];
4499
-                $orphaned_visibility=$row['visibility'];
4500
-                if ($row['assignment']==1) {
4501
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
4502
-                } elseif ($row['assignment']==2) {
4503
-                    $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
4504
-                } elseif ($row['assignment']==0) {
4505
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4496
+            $allpages = Database::query($sql);
4497
+            while ($row = Database::fetch_array($allpages)) {
4498
+                $orphaned_title = $row['title'];
4499
+                $orphaned_visibility = $row['visibility'];
4500
+                if ($row['assignment'] == 1) {
4501
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', '', '', ICON_SIZE_SMALL);
4502
+                } elseif ($row['assignment'] == 2) {
4503
+                    $ShowAssignment = Display::return_icon('wiki_work.png', '', '', ICON_SIZE_SMALL);
4504
+                } elseif ($row['assignment'] == 0) {
4505
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4506 4506
                 }
4507 4507
             }
4508 4508
 
4509
-            if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() && $orphaned_visibility==0){
4509
+            if (!api_is_allowed_to_edit(false, true) || !api_is_platform_admin() && $orphaned_visibility == 0) {
4510 4510
                 continue;
4511 4511
             }
4512 4512
 
@@ -4518,7 +4518,7 @@  discard block
 block discarded – undo
4518 4518
             $rows[] = $row;
4519 4519
         }
4520 4520
 
4521
-        $table = new SortableTableFromArrayConfig($rows,1, 10, 'OrphanedPages_table','','','DESC');
4521
+        $table = new SortableTableFromArrayConfig($rows, 1, 10, 'OrphanedPages_table', '', '', 'DESC');
4522 4522
         $table->set_additional_parameters(
4523 4523
             array(
4524 4524
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4527,8 +4527,8 @@  discard block
 block discarded – undo
4527 4527
                 'group_id' => intval($_GET['group_id']),
4528 4528
             )
4529 4529
         );
4530
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4531
-        $table->set_header(1,get_lang('Title'), true);
4530
+        $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4531
+        $table->set_header(1, get_lang('Title'), true);
4532 4532
         $table->display();
4533 4533
     }
4534 4534
 
@@ -4550,11 +4550,11 @@  discard block
 block discarded – undo
4550 4550
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4551 4551
                 GROUP BY reflink
4552 4552
                 ORDER BY reflink ASC';
4553
-        $allpages=Database::query($sql);
4553
+        $allpages = Database::query($sql);
4554 4554
 
4555
-        while ($row=Database::fetch_array($allpages)) {
4556
-            if ($row['reflink']=='index'){
4557
-                $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
4555
+        while ($row = Database::fetch_array($allpages)) {
4556
+            if ($row['reflink'] == 'index') {
4557
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4558 4558
             }
4559 4559
             $pages[] = $row['reflink'];
4560 4560
         }
@@ -4568,32 +4568,32 @@  discard block
 block discarded – undo
4568 4568
 
4569 4569
         $allpages = Database::query($sql);
4570 4570
 
4571
-        while ($row=Database::fetch_array($allpages)) {
4571
+        while ($row = Database::fetch_array($allpages)) {
4572 4572
             $refs = explode(" ", trim($row["linksto"]));
4573 4573
             // Find linksto into reflink. If not found ->page is wanted
4574 4574
             foreach ($refs as $v) {
4575 4575
 
4576 4576
                 if (!in_array($v, $pages)) {
4577
-                    if (trim($v)!="") {
4578
-                        $wanted[]=$v;
4577
+                    if (trim($v) != "") {
4578
+                        $wanted[] = $v;
4579 4579
                     }
4580 4580
                 }
4581 4581
             }
4582 4582
         }
4583 4583
 
4584
-        $wanted = array_unique($wanted);//make a unique list
4584
+        $wanted = array_unique($wanted); //make a unique list
4585 4585
 
4586 4586
         //show table
4587 4587
         $rows = array();
4588 4588
         foreach ($wanted as $wanted_show) {
4589 4589
             $row = array();
4590 4590
             $wanted_show = Security::remove_XSS($wanted_show);
4591
-            $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">'.
4592
-                str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities
4591
+            $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">'.
4592
+                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'));
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
                             );
5088 5088
                         } elseif (!self::double_post($_POST['wpost_id'])) {
5089 5089
                             //double post
5090
-                        } elseif ($_POST['version'] != '' && $versionSession !=0 && $_POST['version'] != $versionSession) {
5090
+                        } elseif ($_POST['version'] != '' && $versionSession != 0 && $_POST['version'] != $versionSession) {
5091 5091
                             //prevent concurrent users and double version
5092 5092
                             Display::addFlash(
5093 5093
                                 Display::return_message(
@@ -5150,7 +5150,7 @@  discard block
 block discarded – undo
5150 5150
         $KeyAssignment = null;
5151 5151
         $KeyTitle = null;
5152 5152
         $KeyUserId = null;
5153
-        while ($row=Database::fetch_array($result)) {
5153
+        while ($row = Database::fetch_array($result)) {
5154 5154
             $KeyVisibility = $row['visibility'];
5155 5155
             $KeyAssignment = $row['assignment'];
5156 5156
             $KeyTitle = $row['title'];
@@ -5159,7 +5159,7 @@  discard block
 block discarded – undo
5159 5159
         $icon_assignment = null;
5160 5160
         if ($KeyAssignment == 1) {
5161 5161
             $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
5162
-        } elseif($KeyAssignment == 2) {
5162
+        } elseif ($KeyAssignment == 2) {
5163 5163
             $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
5164 5164
         }
5165 5165
 
@@ -5167,10 +5167,10 @@  discard block
 block discarded – undo
5167 5167
 
5168 5168
         //if the page is hidden and is a job only sees its author and professor
5169 5169
         if ($KeyVisibility == 1 ||
5170
-            api_is_allowed_to_edit(false,true) ||
5170
+            api_is_allowed_to_edit(false, true) ||
5171 5171
             api_is_platform_admin() ||
5172 5172
             (
5173
-                $KeyAssignment==2 && $KeyVisibility==0 &&
5173
+                $KeyAssignment == 2 && $KeyVisibility == 0 &&
5174 5174
                 ($userId == $KeyUserId)
5175 5175
             )
5176 5176
         ) {
@@ -5200,7 +5200,7 @@  discard block
 block discarded – undo
5200 5200
                     get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
5201 5201
                 echo '<br/><br/>';
5202 5202
 
5203
-                $counter=0;
5203
+                $counter = 0;
5204 5204
                 $total_versions = Database::num_rows($result);
5205 5205
 
5206 5206
                 while ($row = Database::fetch_array($result)) {
@@ -5208,10 +5208,10 @@  discard block
 block discarded – undo
5208 5208
                     $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
5209 5209
 
5210 5210
                     echo '<li style="margin-bottom: 5px;">';
5211
-                    ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
5212
-                    ($counter==0) ? $newchecked=' checked': $newchecked='';
5213
-                    ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
5214
-                    ($counter==1) ? $oldchecked=' checked':$oldchecked='';
5211
+                    ($counter == 0) ? $oldstyle = 'style="visibility: hidden;"' : $oldstyle = '';
5212
+                    ($counter == 0) ? $newchecked = ' checked' : $newchecked = '';
5213
+                    ($counter == $total_versions - 1) ? $newstyle = 'style="visibility: hidden;"' : $newstyle = '';
5214
+                    ($counter == 1) ? $oldchecked = ' checked' : $oldchecked = '';
5215 5215
                     echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
5216 5216
                     echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
5217 5217
                     echo '<a href="'.api_get_self().'?action=showpage&title='.api_htmlentities(urlencode($page)).'&view='.$row['id'].'">';
@@ -5229,7 +5229,7 @@  discard block
 block discarded – undo
5229 5229
                     $comment = $row['comment'];
5230 5230
                     if (!empty($comment)) {
5231 5231
                         echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'], 0, 100));
5232
-                        if (api_strlen($row['comment'])>100) {
5232
+                        if (api_strlen($row['comment']) > 100) {
5233 5233
                             echo '... ';
5234 5234
                         }
5235 5235
                     } else {
@@ -5254,8 +5254,8 @@  discard block
 block discarded – undo
5254 5254
 
5255 5255
                 $sql_new = "SELECT * FROM $tbl_wiki
5256 5256
                             WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
5257
-                $result_new=Database::query($sql_new);
5258
-                $version_new=Database::fetch_array($result_new);
5257
+                $result_new = Database::query($sql_new);
5258
+                $version_new = Database::fetch_array($result_new);
5259 5259
                 $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
5260 5260
                 $oldContent = isset($version_old['content']) ? $version_old['content'] : null;
5261 5261
 
@@ -5282,9 +5282,9 @@  discard block
 block discarded – undo
5282 5282
 
5283 5283
 
5284 5284
                 if (isset($_POST['HistoryDifferences'])) {
5285
-                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words
5285
+                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line').'</table>'; // format_line mode is better for words
5286 5286
                     echo '<br />';
5287
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5287
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5288 5288
                     echo '<table><tr>';
5289 5289
                     echo  '<td>';
5290 5290
                     echo '</td><td>';
@@ -5303,7 +5303,7 @@  discard block
 block discarded – undo
5303 5303
                     $renderer = new Text_Diff_Renderer_inline();
5304 5304
                     echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
5305 5305
                     echo '<br />';
5306
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5306
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5307 5307
                     echo '<table><tr>';
5308 5308
                     echo  '<td>';
5309 5309
                     echo '</td><td>';
@@ -5351,7 +5351,7 @@  discard block
 block discarded – undo
5351 5351
         echo '<td style="vertical-align:top">';
5352 5352
         echo '<ul>';
5353 5353
         // Submenu Statistics
5354
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5354
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5355 5355
             echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>';
5356 5356
         }
5357 5357
         echo '      </ul>';
@@ -5424,7 +5424,7 @@  discard block
 block discarded – undo
5424 5424
                 break;
5425 5425
             case 'deletewiki':
5426 5426
                 $title = '<div class="actions">'.get_lang('DeleteWiki').'</div>';
5427
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5427
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5428 5428
                     $message = get_lang('ConfirmDeleteWiki');
5429 5429
                     $message .= '<p>
5430 5430
                         <a href="index.php?'.api_get_cidreq().'">'.get_lang('No').'</a>
@@ -5455,14 +5455,14 @@  discard block
 block discarded – undo
5455 5455
                 self::getLinks($page);
5456 5456
                 break;
5457 5457
             case 'addnew':
5458
-                if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
5458
+                if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
5459 5459
                     api_not_allowed();
5460 5460
                 }
5461 5461
                 echo '<div class="actions">'.get_lang('AddNew').'</div>';
5462 5462
                 echo '<br/>';
5463 5463
                 //first, check if page index was created. chektitle=false
5464 5464
                 if (self::checktitle('index')) {
5465
-                    if (api_is_allowed_to_edit(false,true) ||
5465
+                    if (api_is_allowed_to_edit(false, true) ||
5466 5466
                         api_is_platform_admin() ||
5467 5467
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
5468 5468
                     ) {
@@ -5470,10 +5470,10 @@  discard block
 block discarded – undo
5470 5470
                     } else {
5471 5471
                         self::setMessage(Display::display_normal_message(get_lang('WikiStandBy'), false, true));
5472 5472
                     }
5473
-                } elseif (self::check_addnewpagelock()==0 && (api_is_allowed_to_edit(false, true)==false || api_is_platform_admin()==false)) {
5473
+                } elseif (self::check_addnewpagelock() == 0 && (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)) {
5474 5474
                     self::setMessage(Display::display_error_message(get_lang('AddPagesLocked'), false, true));
5475 5475
                 } else {
5476
-                    if (api_is_allowed_to_edit(false,true) ||
5476
+                    if (api_is_allowed_to_edit(false, true) ||
5477 5477
                         api_is_platform_admin() ||
5478 5478
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
5479 5479
                         $_GET['group_id'] == 0
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.
src/Chamilo/CoreBundle/Component/Filesystem/Data.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Chamilo\UserBundle\Entity\User;
9 9
 use MediaAlchemyst\Alchemyst;
10 10
 use Sunra\PhpSimple\HtmlDomParser;
11
-use Symfony\Component\Console;
12 11
 use Symfony\Component\Console\Output\OutputInterface;
13 12
 use Symfony\Component\Filesystem\Filesystem;
14 13
 use Symfony\Component\Finder\Finder;
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/Listener/CourseListener.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,11 +3,9 @@
 block discarded – undo
3 3
 
4 4
 namespace Chamilo\CoreBundle\Entity\Listener;
5 5
 
6
-use Chamilo\CoreBundle\Entity\Tool;
7 6
 use Chamilo\CourseBundle\ToolChain;
8 7
 use Doctrine\ORM\Event\LifecycleEventArgs;
9 8
 use Chamilo\CoreBundle\Entity\Course;
10
-use Doctrine\ORM\Mapping as ORM;
11 9
 
12 10
 /**
13 11
  * Class CourseListener
Please login to merge, or discard this patch.
certificates/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     case 'export':
16 16
         $hideExportLink = api_get_setting('hide_certificate_export_link');
17 17
         $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
18
-        if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
18
+        if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) {
19 19
             api_not_allowed(true);
20 20
         }
21 21
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             $pageFormat = $pdfParams['orientation'] == 'landscape' ? 'A4-L' : 'A4';
37 37
 
38 38
             $userInfo = api_get_user_info($certificate->user_id);
39
-            $pdfName = api_replace_dangerous_char(get_lang('Certificate') . ' ' . $userInfo['username']);
39
+            $pdfName = api_replace_dangerous_char(get_lang('Certificate').' '.$userInfo['username']);
40 40
 
41 41
             $pdf = new PDF($pageFormat, $pdfParams['orientation'], $pdfParams);
42 42
             $pdf->html_to_pdf($certificatePathList, $pdfName, null, false, false);
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Component/Editor/TinyMce/TinyMce.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
      */
48 48
     public function editorReplace()
49 49
     {
50
-        $toolbar  = new Toolbar\Basic($this->urlGenerator, $this->toolbarSet, $this->config, 'TinyMce');
50
+        $toolbar = new Toolbar\Basic($this->urlGenerator, $this->toolbarSet, $this->config, 'TinyMce');
51 51
         $toolbar->setLanguage($this->getLocale());
52 52
         $config = $toolbar->getConfig();
53 53
         $config['selector'] = "#".$this->name;
Please login to merge, or discard this patch.