Completed
Push — 1.11.x ( d4cbce...fbf9a8 )
by José
48:27
created
main/wiki/wiki.inc.php 1 patch
Spacing   +631 added lines, -631 removed lines patch added patch discarded remove patch
@@ -99,25 +99,25 @@  discard block
 block discarded – undo
99 99
      **/
100 100
     public function links_to($input)
101 101
     {
102
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
102
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
103 103
         $all_links = array();
104 104
 
105 105
         foreach ($input_array as $key=>$value) {
106
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' &&
107
-                isset($input_array[$key+1]) && $input_array[$key+1] == ']]'
106
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' &&
107
+                isset($input_array[$key + 1]) && $input_array[$key + 1] == ']]'
108 108
             ) {
109 109
                 if (api_strpos($value, "|") !== false) {
110
-                    $full_link_array=explode("|", $value);
111
-                    $link=trim($full_link_array[0]);
112
-                    $title=trim($full_link_array[1]);
110
+                    $full_link_array = explode("|", $value);
111
+                    $link = trim($full_link_array[0]);
112
+                    $title = trim($full_link_array[1]);
113 113
                 } else {
114
-                    $link=trim($value);
115
-                    $title=trim($value);
114
+                    $link = trim($value);
115
+                    $title = trim($value);
116 116
                 }
117
-                unset($input_array[$key-1]);
118
-                unset($input_array[$key+1]);
117
+                unset($input_array[$key - 1]);
118
+                unset($input_array[$key + 1]);
119 119
                 //replace blank spaces by _ within the links. But to remove links at the end add a blank space
120
-                $all_links[]= Database::escape_string(str_replace(' ','_',$link)).' ';
120
+                $all_links[] = Database::escape_string(str_replace(' ', '_', $link)).' ';
121 121
             }
122 122
         }
123 123
         $output = implode($all_links);
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      **/
132 132
     public function detect_external_link($input)
133 133
     {
134
-        $exlink='href=';
135
-        $exlinkStyle='class="wiki_link_ext" href=';
136
-        $output=str_replace($exlink, $exlinkStyle, $input);
134
+        $exlink = 'href=';
135
+        $exlinkStyle = 'class="wiki_link_ext" href=';
136
+        $output = str_replace($exlink, $exlinkStyle, $input);
137 137
         return $output;
138 138
     }
139 139
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function detect_anchor_link($input)
145 145
     {
146 146
         $anchorlink = 'href="#';
147
-        $anchorlinkStyle='class="wiki_anchor_link" href="#';
147
+        $anchorlinkStyle = 'class="wiki_anchor_link" href="#';
148 148
         $output = str_replace($anchorlink, $anchorlinkStyle, $input);
149 149
 
150 150
         return $output;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      **/
170 170
     public function detect_ftp_link($input)
171 171
     {
172
-        $ftplink='href="ftp';
172
+        $ftplink = 'href="ftp';
173 173
         $ftplinkStyle = 'class="wiki_ftp_link" href="ftp';
174 174
         $output = str_replace($ftplink, $ftplinkStyle, $input);
175 175
 
@@ -214,21 +214,21 @@  discard block
 block discarded – undo
214 214
     {
215 215
         $groupId = api_get_group_id();
216 216
         //now doubles brackets
217
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
217
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
218 218
 
219 219
         foreach ($input_array as $key => $value) {
220 220
             //now doubles brackets
221
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND
222
-                $input_array[$key+1] == ']]'
221
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' AND
222
+                $input_array[$key + 1] == ']]'
223 223
             ) {
224 224
                 // now full wikilink
225
-                if (api_strpos($value, "|") !== false){
226
-                    $full_link_array=explode("|", $value);
227
-                    $link=trim(strip_tags($full_link_array[0]));
228
-                    $title=trim($full_link_array[1]);
225
+                if (api_strpos($value, "|") !== false) {
226
+                    $full_link_array = explode("|", $value);
227
+                    $link = trim(strip_tags($full_link_array[0]));
228
+                    $title = trim($full_link_array[1]);
229 229
                 } else {
230
-                    $link=trim(strip_tags($value));
231
-                    $title=trim($value);
230
+                    $link = trim(strip_tags($value));
231
+                    $title = trim($value);
232 232
                 }
233 233
 
234 234
                 //if wikilink is homepage
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
                 }
241 241
 
242 242
                 // note: checkreflink checks if the link is still free. If it is not used then it returns true, if it is used, then it returns false. Now the title may be different
243
-                if (self::checktitle(strtolower(str_replace(' ','_',$link)))) {
243
+                if (self::checktitle(strtolower(str_replace(' ', '_', $link)))) {
244 244
                     $link = api_html_entity_decode($link);
245
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
245
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
246 246
                 } else {
247
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ','_',$link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
247
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ', '_', $link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
248 248
                 }
249
-                unset($input_array[$key-1]);
250
-                unset($input_array[$key+1]);
249
+                unset($input_array[$key - 1]);
250
+                unset($input_array[$key + 1]);
251 251
             }
252 252
         }
253
-        $output = implode('',$input_array);
253
+        $output = implode('', $input_array);
254 254
         return $output;
255 255
     }
256 256
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
         // are not made here, but through the interce buttons
293 293
 
294 294
         // cleaning the variables
295
-        if (api_get_setting('htmlpurifier_wiki') == 'true'){
295
+        if (api_get_setting('htmlpurifier_wiki') == 'true') {
296 296
             //$purifier = new HTMLPurifier();
297 297
             $values['content'] = Security::remove_XSS($values['content']);
298 298
         }
299
-        $version = intval($values['version']) + 1 ;
299
+        $version = intval($values['version']) + 1;
300 300
         $linkTo = self::links_to($values['content']); //and check links content
301 301
 
302 302
         //cleaning config variables
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $_clean['startdate_assig'] = null;
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'] = null;
@@ -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
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                 $groupId
382 382
             );
383 383
 
384
-            if ($values['page_id']== 0) {
384
+            if ($values['page_id'] == 0) {
385 385
                 $sql = 'UPDATE '.$tbl_wiki.' SET page_id="'.$id.'"
386 386
                         WHERE c_id = '.$course_id.' AND iid ="'.$id.'"';
387 387
                 Database::query($sql);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $_course = $this->courseInfo;
466 466
         $r_user_id = api_get_user_id();
467 467
         $r_dtime = api_get_utc_datetime();
468
-        $r_version = $r_version+1;
468
+        $r_version = $r_version + 1;
469 469
         $r_comment = get_lang('RestoredFromVersion').': '.$c_version;
470 470
         $session_id = api_get_session_id();
471 471
         $course_id = api_get_course_int_id();
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
         // Unlike ordinary pages of pages of assignments.
571 571
         // Allow create a ordinary page although there is a assignment with the same name
572 572
         if ($_clean['assignment'] == 2 || $_clean['assignment'] == 1) {
573
-            $page = str_replace(' ','_',$values['title']."_uass".$assig_user_id);
573
+            $page = str_replace(' ', '_', $values['title']."_uass".$assig_user_id);
574 574
         } else {
575
-            $page = str_replace(' ','_',$values['title']);
575
+            $page = str_replace(' ', '_', $values['title']);
576 576
         }
577 577
         $_clean['reflink'] = $page;
578 578
         $_clean['title']   = trim($values['title']);
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 
609 609
         $groupId = api_get_group_id();
610 610
 
611
-        $_clean['linksto'] = self::links_to($_clean['content']);	//check wikilinks
611
+        $_clean['linksto'] = self::links_to($_clean['content']); //check wikilinks
612 612
 
613 613
         // cleaning config variables
614 614
         $_clean['task'] = isset($values['task']) ? $values['task'] : '';
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      */
725 725
     public function setForm($form, $row = array())
726 726
     {
727
-        $toolBar = api_is_allowed_to_edit(null,true)
727
+        $toolBar = api_is_allowed_to_edit(null, true)
728 728
             ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
729 729
             : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student');
730 730
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 
736 736
         $form->addElement('select', 'progress', get_lang('Progress'), $progress);
737 737
 
738
-        if ((api_is_allowed_to_edit(false,true) ||
738
+        if ((api_is_allowed_to_edit(false, true) ||
739 739
             api_is_platform_admin()) &&
740 740
             isset($row['reflink']) && $row['reflink'] != 'index'
741 741
         ) {
@@ -875,13 +875,13 @@  discard block
 block discarded – undo
875 875
         if ($newtitle) {
876 876
             $pageMIX = $newtitle; //display the page after it is created
877 877
         } else {
878
-            $pageMIX = $page;//display current page
878
+            $pageMIX = $page; //display current page
879 879
         }
880 880
 
881 881
         $filter = null;
882 882
         if (isset($_GET['view']) && $_GET['view']) {
883 883
             $_clean['view'] = Database::escape_string($_GET['view']);
884
-            $filter =' AND w.id="'.$_clean['view'].'"';
884
+            $filter = ' AND w.id="'.$_clean['view'].'"';
885 885
         }
886 886
 
887 887
         // First, check page visibility in the first page version
@@ -923,15 +923,15 @@  discard block
 block discarded – undo
923 923
         }
924 924
 
925 925
         // if both are empty and we are displaying the index page then we display the default text.
926
-        if ($row['content']=='' && $row['title']=='' && $page=='index') {
926
+        if ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
927 927
             if (api_is_allowed_to_edit(false, true) ||
928 928
                 api_is_platform_admin() ||
929 929
                 GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
930 930
                 api_is_allowed_in_course()
931 931
             ) {
932 932
                 //Table structure for better export to pdf
933
-                $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
934
-                $default_table_for_content_End='</td></tr></table>';
933
+                $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
934
+                $default_table_for_content_End = '</td></tr></table>';
935 935
                 $content = $default_table_for_content_Start.
936 936
                     sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).
937 937
                     $default_table_for_content_End;
@@ -946,23 +946,23 @@  discard block
 block discarded – undo
946 946
 
947 947
         //assignment mode: identify page type
948 948
         $icon_assignment = null;
949
-        if ($row['assignment']==1) {
950
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
951
-        } elseif($row['assignment']==2) {
952
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
949
+        if ($row['assignment'] == 1) {
950
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
951
+        } elseif ($row['assignment'] == 2) {
952
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
953 953
         }
954 954
 
955 955
         //task mode
956 956
         $icon_task = null;
957 957
         if (!empty($row['task'])) {
958
-            $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
958
+            $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
959 959
         }
960 960
 
961 961
         // Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view
962 962
         if ($KeyVisibility == "1" ||
963 963
             api_is_allowed_to_edit(false, true) ||
964 964
             api_is_platform_admin() ||
965
-            ($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id'])) ||
965
+            ($row['assignment'] == 2 && $KeyVisibility == "0" && (api_get_user_id() == $row['user_id'])) ||
966 966
             api_is_allowed_in_course()
967 967
         ) {
968 968
             $actionsLeft = '';
@@ -988,13 +988,13 @@  discard block
 block discarded – undo
988 988
             $protect_page = null;
989 989
             $lock_unlock_protect = null;
990 990
             // page action: protecting (locking) the page
991
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
992
-                if (self::check_protect_page()==1) {
991
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
992
+                if (self::check_protect_page() == 1) {
993 993
                     $protect_page = Display::return_icon('lock.png', get_lang('PageLockedExtra'), '', ICON_SIZE_MEDIUM);
994
-                    $lock_unlock_protect='unlock';
994
+                    $lock_unlock_protect = 'unlock';
995 995
                 } else {
996 996
                     $protect_page = Display::return_icon('unlock.png', get_lang('PageUnlockedExtra'), '', ICON_SIZE_MEDIUM);
997
-                    $lock_unlock_protect='lock';
997
+                    $lock_unlock_protect = 'lock';
998 998
                 }
999 999
             }
1000 1000
 
@@ -1006,13 +1006,13 @@  discard block
 block discarded – undo
1006 1006
             $visibility_page = null;
1007 1007
             $lock_unlock_visibility = null;
1008 1008
             //page action: visibility
1009
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1009
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1010 1010
                 if (self::check_visibility_page() == 1) {
1011
-                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'),'', ICON_SIZE_MEDIUM);
1011
+                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'), '', ICON_SIZE_MEDIUM);
1012 1012
                     $lock_unlock_visibility = 'invisible';
1013 1013
 
1014 1014
                 } else {
1015
-                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'),'', ICON_SIZE_MEDIUM);
1015
+                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'), '', ICON_SIZE_MEDIUM);
1016 1016
                     $lock_unlock_visibility = 'visible';
1017 1017
                 }
1018 1018
             }
@@ -1024,11 +1024,11 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
             //page action: notification
1026 1026
             if (api_is_allowed_to_session_edit()) {
1027
-                if (self::check_notify_page($page)==1) {
1028
-                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_MEDIUM);
1027
+                if (self::check_notify_page($page) == 1) {
1028
+                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_MEDIUM);
1029 1029
                     $lock_unlock_notify_page = 'unlocknotify';
1030 1030
                 } else {
1031
-                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_MEDIUM);
1031
+                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_MEDIUM);
1032 1032
                     $lock_unlock_notify_page = 'locknotify';
1033 1033
                 }
1034 1034
             }
@@ -1040,33 +1040,33 @@  discard block
 block discarded – undo
1040 1040
                 ) {
1041 1041
                     // menu discuss page
1042 1042
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=discuss&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('discuss').'>'.
1043
-                        Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1043
+                        Display::return_icon('discuss.png', get_lang('DiscussThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1044 1044
                 }
1045 1045
 
1046 1046
                 //menu history
1047 1047
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=history&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('history').'>'.
1048
-                    Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>';
1048
+                    Display::return_icon('history.png', get_lang('ShowPageHistory'), '', ICON_SIZE_MEDIUM).'</a>';
1049 1049
                 //menu linkspages
1050 1050
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'action=links&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('links').'>'.
1051
-                    Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>';
1051
+                    Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_MEDIUM).'</a>';
1052 1052
 
1053 1053
                 //menu delete wikipage
1054
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1054
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1055 1055
                     $actionsRight .= '<a href="index.php?action=delete&'.api_get_cidreq().'&title='.api_htmlentities(urlencode($page)).'"'.self::is_active_navigation_tab('delete').'>'.
1056
-                        Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1056
+                        Display::return_icon('delete.png', get_lang('DeleteThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1057 1057
                 }
1058 1058
 
1059 1059
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=showpage&actionpage='.$lock_unlock_notify_page.'&title='.api_htmlentities(urlencode($page)).'">'.
1060 1060
                     $notify_page.'</a>';
1061 1061
 
1062 1062
                 // Page action: copy last version to doc area
1063
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1063
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1064 1064
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export2doc&wiki_id='.$row['id'].'">'.
1065 1065
                         Display::return_icon('export_to_documents.png', get_lang('ExportToDocArea'), '', ICON_SIZE_MEDIUM).'</a>';
1066 1066
                 }
1067 1067
 
1068 1068
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf&wiki_id='.$row['id'].'">'.
1069
-                    Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
1069
+                    Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
1070 1070
 
1071 1071
                 $unoconv = api_get_configuration_value('unoconv.binaries');
1072 1072
                 if ($unoconv) {
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
                     )
1123 1123
                 );
1124 1124
 
1125
-            $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>';
1125
+            $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>';
1126 1126
 
1127 1127
             echo Display::panel($pageWiki, $pageTitle, $footerWiki);
1128 1128
         } //end filter visibility
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 
1147 1147
         # strip all html tags
1148 1148
         $wc = strip_tags($document);
1149
-        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8');// TODO:test also old html_entity_decode(utf8_encode($wc))
1149
+        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8'); // TODO:test also old html_entity_decode(utf8_encode($wc))
1150 1150
 
1151 1151
         # remove 'words' that don't consist of alphanumerical characters or punctuation. And fix accents and some letters
1152 1152
         $pattern = "#[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@|á|é|í|ó|ú|à|è|ì|ò|ù|ä|ë|ï|ö|ü|Á|É|Í|Ó|Ú|À|È|Ò|Ù|Ä|Ë|Ï|Ö|Ü|â|ê|î|ô|û|Â|Ê|Î|Ô|Û|ñ|Ñ|ç|Ç)]+#";
@@ -1179,15 +1179,15 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
         $course_id = api_get_course_int_id();
1181 1181
 
1182
-        $sql='SELECT id FROM '.$tbl_wiki.'
1182
+        $sql = 'SELECT id FROM '.$tbl_wiki.'
1183 1183
               WHERE
1184 1184
                 c_id = '.$course_id.' AND
1185 1185
                 title="'.Database::escape_string($title).'" AND
1186 1186
                 '.$groupfilter.$condition_session.'
1187 1187
               ORDER BY id ASC';
1188
-        $result=Database::query($sql);
1189
-        $cant=Database::num_rows($result);
1190
-        if ($cant>0) {
1188
+        $result = Database::query($sql);
1189
+        $cant = Database::num_rows($result);
1190
+        if ($cant > 0) {
1191 1191
             return true;
1192 1192
         } else {
1193 1193
             return false;
@@ -1269,20 +1269,20 @@  discard block
 block discarded – undo
1269 1269
         $page = $this->page;
1270 1270
 
1271 1271
         $course_id = api_get_course_int_id();
1272
-        $sql='SELECT * FROM '.$tbl_wiki.'
1272
+        $sql = 'SELECT * FROM '.$tbl_wiki.'
1273 1273
               WHERE
1274 1274
                 c_id = '.$course_id.' AND
1275 1275
                 reflink="'.Database::escape_string($page).'" AND
1276 1276
                 '.$groupfilter.$condition_session.'
1277 1277
               ORDER BY id ASC';
1278 1278
 
1279
-        $result=Database::query($sql);
1280
-        $row=Database::fetch_array($result);
1279
+        $result = Database::query($sql);
1280
+        $row = Database::fetch_array($result);
1281 1281
         $status_editlock = $row['editlock'];
1282 1282
         $id = $row['page_id'];
1283 1283
 
1284 1284
         ///change status
1285
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1285
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1286 1286
             if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lock' && $status_editlock == 0) {
1287 1287
                 $status_editlock = 1;
1288 1288
             }
@@ -1294,13 +1294,13 @@  discard block
 block discarded – undo
1294 1294
                     WHERE c_id = '.$course_id.' AND page_id="'.$id.'"';
1295 1295
             Database::query($sql);
1296 1296
 
1297
-            $sql='SELECT * FROM '.$tbl_wiki.'
1297
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1298 1298
                   WHERE
1299 1299
                     c_id = '.$course_id.' AND
1300 1300
                     reflink="'.Database::escape_string($page).'" AND
1301 1301
                     '.$groupfilter.$condition_session.'
1302 1302
                   ORDER BY id ASC';
1303
-            $result=Database::query($sql);
1303
+            $result = Database::query($sql);
1304 1304
             $row = Database::fetch_array($result);
1305 1305
         }
1306 1306
 
@@ -1331,13 +1331,13 @@  discard block
 block discarded – undo
1331 1331
         $row = Database::fetch_array($result);
1332 1332
         $status_visibility = $row['visibility'];
1333 1333
         //change status
1334
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1335
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='visible' && $status_visibility==0) {
1336
-                $status_visibility=1;
1334
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1335
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'visible' && $status_visibility == 0) {
1336
+                $status_visibility = 1;
1337 1337
 
1338 1338
             }
1339
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='invisible' && $status_visibility==1) {
1340
-                $status_visibility=0;
1339
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'invisible' && $status_visibility == 1) {
1340
+                $status_visibility = 0;
1341 1341
             }
1342 1342
 
1343 1343
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility="'.Database::escape_string($status_visibility).'"
@@ -1354,12 +1354,12 @@  discard block
 block discarded – undo
1354 1354
                         reflink="'.Database::escape_string($page).'" AND
1355 1355
                         '.$groupfilter.$condition_session.'
1356 1356
                     ORDER BY id ASC';
1357
-            $result=Database::query($sql);
1357
+            $result = Database::query($sql);
1358 1358
             $row = Database::fetch_array($result);
1359 1359
         }
1360 1360
 
1361 1361
         if (empty($row['id'])) {
1362
-            $row['visibility']= 1;
1362
+            $row['visibility'] = 1;
1363 1363
         }
1364 1364
 
1365 1365
         //show status
@@ -1386,18 +1386,18 @@  discard block
 block discarded – undo
1386 1386
                     reflink="'.Database::escape_string($page).'" AND
1387 1387
                     '.$groupfilter.$condition_session.'
1388 1388
                 ORDER BY id ASC';
1389
-        $result=Database::query($sql);
1390
-        $row=Database::fetch_array($result);
1389
+        $result = Database::query($sql);
1390
+        $row = Database::fetch_array($result);
1391 1391
 
1392 1392
         $status_visibility_disc = $row['visibility_disc'];
1393 1393
 
1394 1394
         //change status
1395
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1396
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='showdisc' && $status_visibility_disc==0) {
1397
-                $status_visibility_disc=1;
1395
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1396
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'showdisc' && $status_visibility_disc == 0) {
1397
+                $status_visibility_disc = 1;
1398 1398
             }
1399
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='hidedisc' && $status_visibility_disc==1) {
1400
-                $status_visibility_disc=0;
1399
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'hidedisc' && $status_visibility_disc == 1) {
1400
+                $status_visibility_disc = 0;
1401 1401
             }
1402 1402
 
1403 1403
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'"
@@ -1445,14 +1445,14 @@  discard block
 block discarded – undo
1445 1445
         $result = Database::query($sql);
1446 1446
         $row = Database::fetch_array($result);
1447 1447
 
1448
-        $status_addlock_disc=$row['addlock_disc'];
1448
+        $status_addlock_disc = $row['addlock_disc'];
1449 1449
 
1450 1450
         //change status
1451 1451
         if (api_is_allowed_to_edit() || api_is_platform_admin()) {
1452
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockdisc' && $status_addlock_disc==0) {
1452
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockdisc' && $status_addlock_disc == 0) {
1453 1453
                 $status_addlock_disc = 1;
1454 1454
             }
1455
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockdisc' && $status_addlock_disc==1) {
1455
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockdisc' && $status_addlock_disc == 1) {
1456 1456
                 $status_addlock_disc = 0;
1457 1457
             }
1458 1458
 
@@ -1474,8 +1474,8 @@  discard block
 block discarded – undo
1474 1474
                         reflink="'.Database::escape_string($page).'" AND
1475 1475
                         '.$groupfilter.$condition_session.'
1476 1476
                     ORDER BY id ASC';
1477
-            $result=Database::query($sql);
1478
-            $row=Database::fetch_array($result);
1477
+            $result = Database::query($sql);
1478
+            $row = Database::fetch_array($result);
1479 1479
         }
1480 1480
 
1481 1481
         return $row['addlock_disc'];
@@ -1500,17 +1500,17 @@  discard block
 block discarded – undo
1500 1500
                     reflink="'.Database::escape_string($page).'" AND
1501 1501
                     '.$groupfilter.$condition_session.'
1502 1502
                 ORDER BY id ASC';
1503
-        $result=Database::query($sql);
1504
-        $row=Database::fetch_array($result);
1505
-        $status_ratinglock_disc=$row['ratinglock_disc'];
1503
+        $result = Database::query($sql);
1504
+        $row = Database::fetch_array($result);
1505
+        $status_ratinglock_disc = $row['ratinglock_disc'];
1506 1506
 
1507 1507
         //change status
1508
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1509
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockrating' && $status_ratinglock_disc==0) {
1510
-                $status_ratinglock_disc=1;
1508
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1509
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockrating' && $status_ratinglock_disc == 0) {
1510
+                $status_ratinglock_disc = 1;
1511 1511
             }
1512
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockrating' && $status_ratinglock_disc==1) {
1513
-                $status_ratinglock_disc=0;
1512
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockrating' && $status_ratinglock_disc == 1) {
1513
+                $status_ratinglock_disc = 0;
1514 1514
             }
1515 1515
 
1516 1516
             $sql = 'UPDATE '.$tbl_wiki.'
@@ -1526,14 +1526,14 @@  discard block
 block discarded – undo
1526 1526
             // these three lines remain necessary. They do that by changing the
1527 1527
             // page state is made when you press the button and not have to wait
1528 1528
             // to change his page
1529
-            $sql='SELECT * FROM '.$tbl_wiki.'
1529
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1530 1530
                   WHERE
1531 1531
                     c_id = '.$course_id.' AND
1532 1532
                     reflink="'.Database::escape_string($page).'" AND
1533 1533
                     '.$groupfilter.$condition_session.'
1534 1534
                   ORDER BY id ASC';
1535
-            $result=Database::query($sql);
1536
-            $row=Database::fetch_array($result);
1535
+            $result = Database::query($sql);
1536
+            $row = Database::fetch_array($result);
1537 1537
         }
1538 1538
 
1539 1539
         return $row['ratinglock_disc'];
@@ -1558,24 +1558,24 @@  discard block
 block discarded – undo
1558 1558
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1559 1559
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1560 1560
                 ORDER BY id ASC';
1561
-        $result=Database::query($sql);
1562
-        $row=Database::fetch_array($result);
1561
+        $result = Database::query($sql);
1562
+        $row = Database::fetch_array($result);
1563 1563
         $id = $row['id'];
1564
-        $sql='SELECT * FROM '.$tbl_wiki_mailcue.'
1564
+        $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1565 1565
               WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"';
1566
-        $result=Database::query($sql);
1567
-        $row=Database::fetch_array($result);
1566
+        $result = Database::query($sql);
1567
+        $row = Database::fetch_array($result);
1568 1568
 
1569 1569
         $idm = $row['id'];
1570 1570
 
1571 1571
         if (empty($idm)) {
1572
-            $status_notify=0;
1572
+            $status_notify = 0;
1573 1573
         } else {
1574
-            $status_notify=1;
1574
+            $status_notify = 1;
1575 1575
         }
1576 1576
 
1577 1577
         // Change status
1578
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) {
1578
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotify' && $status_notify == 0) {
1579 1579
             $sql = "SELECT id FROM $tbl_wiki_mailcue
1580 1580
                     WHERE c_id = $course_id AND id = $id AND user_id = $userId";
1581 1581
             $result = Database::query($sql);
@@ -1584,18 +1584,18 @@  discard block
 block discarded – undo
1584 1584
                 $exist = true;
1585 1585
             }
1586 1586
             if ($exist == false) {
1587
-                $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1587
+                $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1588 1588
                 ($course_id, '".$id."','".api_get_user_id()."','P','".$groupId."','".$session_id."')";
1589 1589
                 Database::query($sql);
1590 1590
             }
1591
-            $status_notify=1;
1591
+            $status_notify = 1;
1592 1592
         }
1593 1593
 
1594
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotify' && $status_notify==1) {
1594
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotify' && $status_notify == 1) {
1595 1595
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1596 1596
                     WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P" AND c_id = '.$course_id;
1597 1597
             Database::query($sql);
1598
-            $status_notify=0;
1598
+            $status_notify = 0;
1599 1599
         }
1600 1600
 
1601 1601
         return $status_notify;
@@ -1621,9 +1621,9 @@  discard block
 block discarded – undo
1621 1621
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1622 1622
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1623 1623
                 ORDER BY id ASC';
1624
-        $result=Database::query($sql);
1625
-        $row=Database::fetch_array($result);
1626
-        $id=$row['id'];
1624
+        $result = Database::query($sql);
1625
+        $row = Database::fetch_array($result);
1626
+        $id = $row['id'];
1627 1627
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1628 1628
                 WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
1629 1629
         $result = Database::query($sql);
@@ -1631,23 +1631,23 @@  discard block
 block discarded – undo
1631 1631
         $idm = $row['id'];
1632 1632
 
1633 1633
         if (empty($idm)) {
1634
-            $status_notify_disc=0;
1634
+            $status_notify_disc = 0;
1635 1635
         } else {
1636
-            $status_notify_disc=1;
1636
+            $status_notify_disc = 1;
1637 1637
         }
1638 1638
 
1639 1639
         //change status
1640
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifydisc' && $status_notify_disc==0) {
1641
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1640
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifydisc' && $status_notify_disc == 0) {
1641
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1642 1642
             ($course_id, '".$id."','".api_get_user_id()."','D','".$groupId."','".$session_id."')";
1643 1643
             Database::query($sql);
1644
-            $status_notify_disc=1;
1644
+            $status_notify_disc = 1;
1645 1645
         }
1646
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifydisc' && $status_notify_disc==1) {
1646
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotifydisc' && $status_notify_disc == 1) {
1647 1647
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1648 1648
                     WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D" AND c_id = '.$course_id;
1649 1649
             Database::query($sql);
1650
-            $status_notify_disc=0;
1650
+            $status_notify_disc = 0;
1651 1651
         }
1652 1652
 
1653 1653
         return $status_notify_disc;
@@ -1662,7 +1662,7 @@  discard block
 block discarded – undo
1662 1662
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1663 1663
         $course_id = api_get_course_int_id();
1664 1664
         $groupId = api_get_group_id();
1665
-        $session_id=api_get_session_id();
1665
+        $session_id = api_get_session_id();
1666 1666
 
1667 1667
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1668 1668
                 WHERE
@@ -1671,31 +1671,31 @@  discard block
 block discarded – undo
1671 1671
                     type="F" AND
1672 1672
                     group_id="'.$groupId.'" AND
1673 1673
                     session_id="'.$session_id.'"';
1674
-        $result=Database::query($sql);
1675
-        $row=Database::fetch_array($result);
1674
+        $result = Database::query($sql);
1675
+        $row = Database::fetch_array($result);
1676 1676
 
1677
-        $idm=$row['user_id'];
1677
+        $idm = $row['user_id'];
1678 1678
 
1679 1679
         if (empty($idm)) {
1680
-            $status_notify_all=0;
1680
+            $status_notify_all = 0;
1681 1681
         } else {
1682
-            $status_notify_all=1;
1682
+            $status_notify_all = 1;
1683 1683
         }
1684 1684
 
1685 1685
         //change status
1686
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifyall' && $status_notify_all==0) {
1687
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1686
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifyall' && $status_notify_all == 0) {
1687
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1688 1688
             ($course_id, '".api_get_user_id()."','F','".$groupId."','".$session_id."')";
1689 1689
             Database::query($sql);
1690
-            $status_notify_all=1;
1690
+            $status_notify_all = 1;
1691 1691
         }
1692 1692
 
1693 1693
         if (isset($_GET['actionpage']) &&
1694 1694
             isset($_GET['actionpage']) &&
1695
-            $_GET['actionpage']  =='unlocknotifyall' &&
1695
+            $_GET['actionpage'] == 'unlocknotifyall' &&
1696 1696
             $status_notify_all == 1
1697 1697
         ) {
1698
-            $sql ='DELETE FROM '.$tbl_wiki_mailcue.'
1698
+            $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1699 1699
                    WHERE
1700 1700
                     c_id = '.$course_id.' AND
1701 1701
                     user_id="'.api_get_user_id().'" AND
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
                     session_id="'.$session_id.'" AND
1705 1705
                     c_id = '.$course_id;
1706 1706
             Database::query($sql);
1707
-            $status_notify_all=0;
1707
+            $status_notify_all = 0;
1708 1708
         }
1709 1709
 
1710 1710
         //show status
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
     /**
1715 1715
      * Sends pending e-mails
1716 1716
      */
1717
-    public function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
1717
+    public function check_emailcue($id_or_ref, $type, $lastime = '', $lastuser = '')
1718 1718
     {
1719 1719
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1720 1720
         $tbl_wiki = $this->tbl_wiki;
@@ -1722,14 +1722,14 @@  discard block
 block discarded – undo
1722 1722
         $groupfilter = $this->groupfilter;
1723 1723
         $_course = $this->courseInfo;
1724 1724
         $groupId = api_get_group_id();
1725
-        $session_id=api_get_session_id();
1725
+        $session_id = api_get_session_id();
1726 1726
         $course_id = api_get_course_int_id();
1727 1727
 
1728
-        $group_properties  = GroupManager :: get_group_properties($groupId);
1728
+        $group_properties = GroupManager :: get_group_properties($groupId);
1729 1729
         $group_name = $group_properties['name'];
1730 1730
         $allow_send_mail = false; //define the variable to below
1731 1731
         $email_assignment = null;
1732
-        if ($type=='P') {
1732
+        if ($type == 'P') {
1733 1733
             //if modifying a wiki page
1734 1734
             //first, current author and time
1735 1735
             //Who is the author?
@@ -1740,22 +1740,22 @@  discard block
 block discarded – undo
1740 1740
             $year = substr($lastime, 0, 4);
1741 1741
             $month = substr($lastime, 5, 2);
1742 1742
             $day = substr($lastime, 8, 2);
1743
-            $hours=substr($lastime, 11,2);
1744
-            $minutes=substr($lastime, 14,2);
1745
-            $seconds=substr($lastime, 17,2);
1746
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1743
+            $hours = substr($lastime, 11, 2);
1744
+            $minutes = substr($lastime, 14, 2);
1745
+            $seconds = substr($lastime, 17, 2);
1746
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1747 1747
 
1748 1748
             //second, extract data from first reg
1749 1749
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1750 1750
                     WHERE  c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.'
1751 1751
                     ORDER BY id ASC';
1752
-            $result=Database::query($sql);
1753
-            $row=Database::fetch_array($result);
1752
+            $result = Database::query($sql);
1753
+            $row = Database::fetch_array($result);
1754 1754
 
1755
-            $id=$row['id'];
1756
-            $email_page_name=$row['title'];
1757
-            if ($row['visibility']==1) {
1758
-                $allow_send_mail=true; //if visibility off - notify off
1755
+            $id = $row['id'];
1756
+            $email_page_name = $row['title'];
1757
+            if ($row['visibility'] == 1) {
1758
+                $allow_send_mail = true; //if visibility off - notify off
1759 1759
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1760 1760
                         WHERE
1761 1761
                             c_id = '.$course_id.' AND
@@ -1765,10 +1765,10 @@  discard block
 block discarded – undo
1765 1765
                             group_id="'.$groupId.'" AND
1766 1766
                             session_id="'.$session_id.'"';
1767 1767
                 //type: P=page, D=discuss, F=full.
1768
-                $result=Database::query($sql);
1769
-                $emailtext=get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1768
+                $result = Database::query($sql);
1769
+                $emailtext = get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1770 1770
             }
1771
-        } elseif ($type=='D') {
1771
+        } elseif ($type == 'D') {
1772 1772
             //if added a post to discuss
1773 1773
 
1774 1774
             //first, current author and time
@@ -1780,25 +1780,25 @@  discard block
 block discarded – undo
1780 1780
             $year = substr($lastime, 0, 4);
1781 1781
             $month = substr($lastime, 5, 2);
1782 1782
             $day = substr($lastime, 8, 2);
1783
-            $hours=substr($lastime, 11,2);
1784
-            $minutes=substr($lastime, 14,2);
1785
-            $seconds=substr($lastime, 17,2);
1786
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1783
+            $hours = substr($lastime, 11, 2);
1784
+            $minutes = substr($lastime, 14, 2);
1785
+            $seconds = substr($lastime, 17, 2);
1786
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1787 1787
 
1788 1788
             //second, extract data from first reg
1789 1789
 
1790
-            $id=$id_or_ref; //$id_or_ref is id from tblwiki
1790
+            $id = $id_or_ref; //$id_or_ref is id from tblwiki
1791 1791
 
1792 1792
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1793 1793
                     WHERE c_id = '.$course_id.' AND id="'.$id.'"
1794 1794
                     ORDER BY id ASC';
1795 1795
 
1796
-            $result=Database::query($sql);
1797
-            $row=Database::fetch_array($result);
1796
+            $result = Database::query($sql);
1797
+            $row = Database::fetch_array($result);
1798 1798
 
1799
-            $email_page_name=$row['title'];
1800
-            if ($row['visibility_disc']==1) {
1801
-                $allow_send_mail=true; //if visibility off - notify off
1799
+            $email_page_name = $row['title'];
1800
+            if ($row['visibility_disc'] == 1) {
1801
+                $allow_send_mail = true; //if visibility off - notify off
1802 1802
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1803 1803
                         WHERE
1804 1804
                             c_id = '.$course_id.' AND
@@ -1809,22 +1809,22 @@  discard block
 block discarded – undo
1809 1809
                             session_id="'.$session_id.'"';
1810 1810
                 //type: P=page, D=discuss, F=full
1811 1811
                 $result = Database::query($sql);
1812
-                $emailtext=get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1812
+                $emailtext = get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1813 1813
             }
1814
-        } elseif($type=='A') {
1814
+        } elseif ($type == 'A') {
1815 1815
             //for added pages
1816
-            $id=0; //for tbl_wiki_mailcue
1816
+            $id = 0; //for tbl_wiki_mailcue
1817 1817
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1818 1818
                     WHERE c_id = '.$course_id.'
1819 1819
                     ORDER BY id DESC'; //the added is always the last
1820 1820
 
1821
-            $result=Database::query($sql);
1822
-            $row=Database::fetch_array($result);
1823
-            $email_page_name=$row['title'];
1821
+            $result = Database::query($sql);
1822
+            $row = Database::fetch_array($result);
1823
+            $email_page_name = $row['title'];
1824 1824
 
1825 1825
             //Who is the author?
1826 1826
             $userinfo = api_get_user_info($row['user_id']);
1827
-            $email_user_author= get_lang('AddedBy').': '.$userinfo['complete_name'];
1827
+            $email_user_author = get_lang('AddedBy').': '.$userinfo['complete_name'];
1828 1828
 
1829 1829
             //When ?
1830 1830
             $year = substr($row['dtime'], 0, 4);
@@ -1833,33 +1833,33 @@  discard block
 block discarded – undo
1833 1833
             $hours = substr($row['dtime'], 11, 2);
1834 1834
             $minutes = substr($row['dtime'], 14, 2);
1835 1835
             $seconds = substr($row['dtime'], 17, 2);
1836
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1837
-
1838
-            if($row['assignment']==0) {
1839
-                $allow_send_mail=true;
1840
-            } elseif($row['assignment']==1) {
1841
-                $email_assignment=get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1842
-                $allow_send_mail=true;
1843
-            } elseif($row['assignment']==2) {
1844
-                $allow_send_mail=false; //Mode tasks: avoids notifications to all users about all users
1836
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1837
+
1838
+            if ($row['assignment'] == 0) {
1839
+                $allow_send_mail = true;
1840
+            } elseif ($row['assignment'] == 1) {
1841
+                $email_assignment = get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1842
+                $allow_send_mail = true;
1843
+            } elseif ($row['assignment'] == 2) {
1844
+                $allow_send_mail = false; //Mode tasks: avoids notifications to all users about all users
1845 1845
             }
1846 1846
 
1847 1847
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1848 1848
                     WHERE c_id = '.$course_id.' AND  id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
1849 1849
             //type: P=page, D=discuss, F=full
1850
-            $result=Database::query($sql);
1850
+            $result = Database::query($sql);
1851 1851
 
1852
-            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki');
1853
-        } elseif ($type=='E') {
1854
-            $id=0;
1855
-            $allow_send_mail=true;
1852
+            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '.get_lang('Wiki');
1853
+        } elseif ($type == 'E') {
1854
+            $id = 0;
1855
+            $allow_send_mail = true;
1856 1856
 
1857 1857
             //Who is the author?
1858
-            $userinfo = api_get_user_info(api_get_user_id());	//current user
1858
+            $userinfo = api_get_user_info(api_get_user_id()); //current user
1859 1859
             $email_user_author = get_lang('DeletedBy').': '.$userinfo['complete_name'];
1860 1860
             //When ?
1861
-            $today = date('r');		//current time
1862
-            $email_date_changes=$today;
1861
+            $today = date('r'); //current time
1862
+            $email_date_changes = $today;
1863 1863
 
1864 1864
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1865 1865
                     WHERE
@@ -1873,16 +1873,16 @@  discard block
 block discarded – undo
1873 1873
         ///make and send email
1874 1874
         if ($allow_send_mail) {
1875 1875
             while ($row = Database::fetch_array($result)) {
1876
-                $userinfo = api_get_user_info($row['user_id']);	//$row['user_id'] obtained from tbl_wiki_mailcue
1876
+                $userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue
1877 1877
                 $name_to = $userinfo['complete_name'];
1878 1878
                 $email_to = $userinfo['email'];
1879 1879
                 $sender_name = api_get_setting('emailAdministrator');
1880 1880
                 $sender_email = api_get_setting('emailAdministrator');
1881 1881
                 $email_subject = get_lang('EmailWikiChanges').' - '.$_course['official_code'];
1882 1882
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1883
-                if($session_id==0){
1883
+                if ($session_id == 0) {
1884 1884
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1885
-                }else{
1885
+                } else {
1886 1886
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1887 1887
                 }
1888 1888
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -1960,23 +1960,23 @@  discard block
 block discarded – undo
1960 1960
             $template);
1961 1961
 
1962 1962
         if (0 != $groupId) {
1963
-            $groupPart = '_group' . $groupId; // and add groupId to put the same document title in different groups
1964
-            $group_properties  = GroupManager :: get_group_properties($groupId);
1963
+            $groupPart = '_group'.$groupId; // and add groupId to put the same document title in different groups
1964
+            $group_properties = GroupManager :: get_group_properties($groupId);
1965 1965
             $groupPath = $group_properties['directory'];
1966 1966
         } else {
1967 1967
             $groupPart = '';
1968
-            $groupPath ='';
1968
+            $groupPath = '';
1969 1969
         }
1970 1970
 
1971
-        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path(). '/document'.$groupPath;
1972
-        $exportFile = api_replace_dangerous_char($wikiTitle) . $groupPart;
1971
+        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$groupPath;
1972
+        $exportFile = api_replace_dangerous_char($wikiTitle).$groupPart;
1973 1973
         $wikiContents = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $wikiContents));
1974 1974
         //TODO: put link instead of title
1975 1975
 
1976 1976
         $wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
1977 1977
 
1978 1978
         // replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents
1979
-        if (api_strpos($wikiContents,'../..'.api_get_path(REL_COURSE_PATH)) !== false) {
1979
+        if (api_strpos($wikiContents, '../..'.api_get_path(REL_COURSE_PATH)) !== false) {
1980 1980
             $web_course_path = api_get_path(WEB_COURSE_PATH);
1981 1981
             $wikiContents = str_replace('../..'.api_get_path(REL_COURSE_PATH), $web_course_path, $wikiContents);
1982 1982
         }
@@ -1987,8 +1987,8 @@  discard block
 block discarded – undo
1987 1987
             $i++;
1988 1988
         }
1989 1989
 
1990
-        $wikiFileName = $exportFile . '_' . $i . '.html';
1991
-        $exportPath = $exportDir . '/' . $wikiFileName;
1990
+        $wikiFileName = $exportFile.'_'.$i.'.html';
1991
+        $exportPath = $exportDir.'/'.$wikiFileName;
1992 1992
 
1993 1993
         file_put_contents($exportPath, $wikiContents);
1994 1994
         $doc_id = add_document(
@@ -2033,14 +2033,14 @@  discard block
 block discarded – undo
2033 2033
         $content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding());
2034 2034
 
2035 2035
         //clean wiki links
2036
-        $content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2036
+        $content_pdf = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2037 2037
         //TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links
2038 2038
 
2039 2039
         $title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding());
2040 2040
         $title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding());
2041 2041
         $content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding());
2042 2042
 
2043
-        $html='
2043
+        $html = '
2044 2044
         <!-- defines the headers/footers - this must occur before the headers/footers are set -->
2045 2045
 
2046 2046
         <!--mpdf
@@ -2095,9 +2095,9 @@  discard block
 block discarded – undo
2095 2095
         $session_id = $this->session_id;
2096 2096
         $groupId = api_get_group_id();
2097 2097
 
2098
-        if ($groupId==0) {
2098
+        if ($groupId == 0) {
2099 2099
             //extract course members
2100
-            if(!empty($session_id)) {
2100
+            if (!empty($session_id)) {
2101 2101
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id);
2102 2102
             } else {
2103 2103
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0);
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
2124 2124
         $name = $userinfo['complete_name']." - ".$username;
2125 2125
 
2126
-        $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '"  width="40" height="50" align="top" title="' . $name . '"  />';
2126
+        $photo = '<img src="'.$userinfo['avatar'].'" alt="'.$name.'"  width="40" height="50" align="top" title="'.$name.'"  />';
2127 2127
 
2128 2128
         // teacher assignment title
2129 2129
         $title_orig = $values['title'];
@@ -2151,24 +2151,24 @@  discard block
 block discarded – undo
2151 2151
                 $userPicture = UserManager::getUserPicture($assig_user_id);
2152 2152
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
2153 2153
                 $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
2154
-                $photo= '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2154
+                $photo = '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2155 2155
 
2156 2156
                 $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
2157 2157
                 $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
2158 2158
                 // student is tutor and member
2159 2159
 
2160 2160
                 if ($is_tutor_and_member) {
2161
-                    $status_in_group=get_lang('GroupTutorAndMember');
2161
+                    $status_in_group = get_lang('GroupTutorAndMember');
2162 2162
                 } else {
2163
-                    if($is_tutor_of_group) {
2164
-                        $status_in_group=get_lang('GroupTutor');
2163
+                    if ($is_tutor_of_group) {
2164
+                        $status_in_group = get_lang('GroupTutor');
2165 2165
                     } else {
2166
-                        $status_in_group=" "; //get_lang('GroupStandardMember')
2166
+                        $status_in_group = " "; //get_lang('GroupStandardMember')
2167 2167
                     }
2168 2168
                 }
2169 2169
 
2170
-                if ($assignment_type==1) {
2171
-                    $values['title']= $title_orig;
2170
+                if ($assignment_type == 1) {
2171
+                    $values['title'] = $title_orig;
2172 2172
                     $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
2173 2173
                     <table border="0">
2174 2174
                     <tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr>
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
                         ).
2185 2185
                         ' [['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>';
2186 2186
                     //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
2187
-                    $values['assignment']=2;
2187
+                    $values['assignment'] = 2;
2188 2188
                 }
2189 2189
                 $this->assig_user_id = $assig_user_id;
2190 2190
                 self::save_new_wiki($values);
@@ -2193,12 +2193,12 @@  discard block
 block discarded – undo
2193 2193
 
2194 2194
         foreach ($a_users_to_add as $o_user_to_add) {
2195 2195
             if ($o_user_to_add['user_id'] == $userId) {
2196
-                $assig_user_id=$o_user_to_add['user_id'];
2196
+                $assig_user_id = $o_user_to_add['user_id'];
2197 2197
                 if ($assignment_type == 1) {
2198
-                    $values['title']= $title_orig;
2199
-                    $values['comment']=get_lang('AssignmentDesc');
2198
+                    $values['title'] = $title_orig;
2199
+                    $values['comment'] = get_lang('AssignmentDesc');
2200 2200
                     sort($all_students_pages);
2201
-                    $values['content']=$content_orig_A.$content_orig_B.'<br/>
2201
+                    $values['content'] = $content_orig_A.$content_orig_B.'<br/>
2202 2202
                     <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
2203 2203
                     '.get_lang('AssignmentLinkstoStudentsPage').'
2204 2204
                     </div><br/>
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
                     <ol>'.implode($all_students_pages).'</ol>
2207 2207
                     </div>
2208 2208
                     <br/>';
2209
-                    $values['assignment']=1;
2209
+                    $values['assignment'] = 1;
2210 2210
                 }
2211 2211
                 $this->assig_user_id = $assig_user_id;
2212 2212
                 self::save_new_wiki($values);
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
      * @param   int     Whether to search the contents (1) or just the titles (0)
2221 2221
      * @param int
2222 2222
      */
2223
-    public function display_wiki_search_results($search_term, $search_content=0, $all_vers=0)
2223
+    public function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0)
2224 2224
     {
2225 2225
         $tbl_wiki = $this->tbl_wiki;
2226 2226
         $condition_session = $this->condition_session;
@@ -2232,9 +2232,9 @@  discard block
 block discarded – undo
2232 2232
         echo '</legend>';
2233 2233
 
2234 2234
         //only by professors when page is hidden
2235
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
2236
-            if ($all_vers=='1') {
2237
-                if ($search_content=='1') {
2235
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2236
+            if ($all_vers == '1') {
2237
+                if ($search_content == '1') {
2238 2238
                     $sql = "SELECT * FROM ".$tbl_wiki."
2239 2239
                             WHERE
2240 2240
                                 c_id = $course_id AND
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
                     //search all pages and all versions
2252 2252
                 }
2253 2253
             } else {
2254
-                if ($search_content=='1') {
2254
+                if ($search_content == '1') {
2255 2255
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2256 2256
                             WHERE
2257 2257
                                 s1.c_id = $course_id AND
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
                     //search all pages and all versions
2303 2303
                 }
2304 2304
             } else {
2305
-                if($search_content=='1') {
2305
+                if ($search_content == '1') {
2306 2306
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2307 2307
                             WHERE
2308 2308
                                 s1.c_id = $course_id AND
@@ -2350,17 +2350,17 @@  discard block
 block discarded – undo
2350 2350
                 $seconds = substr($obj->dtime, 17, 2);
2351 2351
 
2352 2352
                 //get type assignment icon
2353
-                if($obj->assignment==1) {
2354
-                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
2355
-                } elseif ($obj->assignment==2) {
2356
-                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
2357
-                } elseif ($obj->assignment==0) {
2353
+                if ($obj->assignment == 1) {
2354
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
2355
+                } elseif ($obj->assignment == 2) {
2356
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
2357
+                } elseif ($obj->assignment == 0) {
2358 2358
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
2359 2359
                 }
2360 2360
                 $row = array();
2361 2361
                 $row[] = $ShowAssignment;
2362 2362
 
2363
-                if($all_vers=='1') {
2363
+                if ($all_vers == '1') {
2364 2364
                     $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'])).'">'.
2365 2365
                         api_htmlentities($obj->title).'</a>';
2366 2366
                 } else {
@@ -2371,21 +2371,21 @@  discard block
 block discarded – undo
2371 2371
                 $row[] = ($obj->user_id != 0 && $userinfo !== false) ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')';
2372 2372
                 $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
2373 2373
 
2374
-                if ($all_vers=='1') {
2374
+                if ($all_vers == '1') {
2375 2375
                     $row[] = $obj->version;
2376 2376
                 } else {
2377 2377
                     $showdelete = '';
2378
-                    if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
2379
-                        $showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2380
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
2378
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2379
+                        $showdelete = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2380
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
2381 2381
                     }
2382 2382
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2383
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a>
2383
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a>
2384 2384
                         <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']).'">'.
2385
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a>
2385
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a>
2386 2386
                         <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']).'">'.
2387
-                        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']).'">'.
2388
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
2387
+                        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']).'">'.
2388
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
2389 2389
                 }
2390 2390
                 $rows[] = $row;
2391 2391
             }
@@ -2410,16 +2410,16 @@  discard block
 block discarded – undo
2410 2410
                     'all_vers' => $all_vers,
2411 2411
                 )
2412 2412
             );
2413
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
2414
-            $table->set_header(1,get_lang('Title'), true);
2413
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
2414
+            $table->set_header(1, get_lang('Title'), true);
2415 2415
             if ($all_vers == '1') {
2416
-                $table->set_header(2,get_lang('Author'), true);
2417
-                $table->set_header(3,get_lang('Date'), true);
2418
-                $table->set_header(4,get_lang('Version'), true);
2416
+                $table->set_header(2, get_lang('Author'), true);
2417
+                $table->set_header(3, get_lang('Date'), true);
2418
+                $table->set_header(4, get_lang('Version'), true);
2419 2419
             } else {
2420
-                $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
2421
-                $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
2422
-                $table->set_header(4,get_lang('Actions'), false, array ('style' => 'width:130px;'));
2420
+                $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
2421
+                $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
2422
+                $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;'));
2423 2423
             }
2424 2424
             $table->display();
2425 2425
         } else {
@@ -2432,14 +2432,14 @@  discard block
 block discarded – undo
2432 2432
      * @todo replace this function with the formvalidator datepicker
2433 2433
      *
2434 2434
      */
2435
-    public function draw_date_picker($prefix,$default='')
2435
+    public function draw_date_picker($prefix, $default = '')
2436 2436
     {
2437 2437
         if (empty($default)) {
2438 2438
             $default = date('Y-m-d H:i:s');
2439 2439
         }
2440 2440
         $parts = explode(' ', $default);
2441
-        list($d_year,$d_month,$d_day) = explode('-',$parts[0]);
2442
-        list($d_hour,$d_minute) = explode(':',$parts[1]);
2441
+        list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
2442
+        list($d_hour, $d_minute) = explode(':', $parts[1]);
2443 2443
 
2444 2444
         $month_list = array(
2445 2445
             1 => get_lang('JanuaryLong'),
@@ -2456,9 +2456,9 @@  discard block
 block discarded – undo
2456 2456
             12 => get_lang('DecemberLong'),
2457 2457
         );
2458 2458
 
2459
-        $minute = range(10,59);
2460
-        array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
2461
-        $date_form = self::make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day);
2459
+        $minute = range(10, 59);
2460
+        array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
2461
+        $date_form = self::make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day);
2462 2462
         $date_form .= self::make_select($prefix.'_month', $month_list, $d_month);
2463 2463
         $date_form .= self::make_select(
2464 2464
                 $prefix.'_year',
@@ -2471,7 +2471,7 @@  discard block
 block discarded – undo
2471 2471
                 ),
2472 2472
                 $d_year
2473 2473
             ).'&nbsp;&nbsp;&nbsp;&nbsp;';
2474
-        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : ';
2474
+        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : ';
2475 2475
         $date_form .= self::make_select($prefix.'_minute', $minute, $d_minute);
2476 2476
 
2477 2477
         return $date_form;
@@ -2481,11 +2481,11 @@  discard block
 block discarded – undo
2481 2481
      * Draws an HTML form select with the given options
2482 2482
      *
2483 2483
      */
2484
-    public function make_select($name,$values,$checked='')
2484
+    public function make_select($name, $values, $checked = '')
2485 2485
     {
2486 2486
         $output = '<select name="'.$name.'" id="'.$name.'">';
2487
-        foreach($values as $key => $value) {
2488
-            $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
2487
+        foreach ($values as $key => $value) {
2488
+            $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2489 2489
         }
2490 2490
         $output .= '</select>';
2491 2491
         return $output;
@@ -2509,7 +2509,7 @@  discard block
 block discarded – undo
2509 2509
      */
2510 2510
     public function two_digits($number)
2511 2511
     {
2512
-        $number = (int)$number;
2512
+        $number = (int) $number;
2513 2513
         return ($number < 10) ? '0'.$number : $number;
2514 2514
     }
2515 2515
 
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
                 WHERE c_id = '.$course_id.' AND id = '.$id.' ';
2531 2531
         $result = Database::query($sql);
2532 2532
         $data = array();
2533
-        while ($row=Database::fetch_array($result,'ASSOC'))   {
2533
+        while ($row = Database::fetch_array($result, 'ASSOC')) {
2534 2534
             $data = $row;
2535 2535
         }
2536 2536
         return $data;
@@ -2584,7 +2584,7 @@  discard block
 block discarded – undo
2584 2584
         $result = Database::query($sql);
2585 2585
         $data = array();
2586 2586
         if (Database::num_rows($result)) {
2587
-            $data = Database::fetch_array($result,'ASSOC');
2587
+            $data = Database::fetch_array($result, 'ASSOC');
2588 2588
         }
2589 2589
 
2590 2590
         return $data;
@@ -2678,9 +2678,9 @@  discard block
 block discarded – undo
2678 2678
         $result = self::getAllWiki();
2679 2679
         if (!empty($result)) {
2680 2680
             foreach ($result  as $is_editing_block) {
2681
-                $max_edit_time	= 1200; // 20 minutes
2682
-                $timestamp_edit	= strtotime($is_editing_block['time_edit']);
2683
-                $time_editing	= time()-$timestamp_edit;
2681
+                $max_edit_time = 1200; // 20 minutes
2682
+                $timestamp_edit = strtotime($is_editing_block['time_edit']);
2683
+                $time_editing = time() - $timestamp_edit;
2684 2684
 
2685 2685
                 // First prevent concurrent users and double version
2686 2686
                 if ($is_editing_block['is_editing'] == $userId) {
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
                     unset($_SESSION['_version']);
2690 2690
                 }
2691 2691
                 // Second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
2692
-                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action!='edit')) {
2692
+                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action != 'edit')) {
2693 2693
                     self::updateWikiIsEditing($is_editing_block['is_editing']);
2694 2694
                 }
2695 2695
             }
@@ -2737,7 +2737,7 @@  discard block
 block discarded – undo
2737 2737
                 FROM ".$tbl_wiki."
2738 2738
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2739 2739
 
2740
-        $allpages=Database::query($sql);
2740
+        $allpages = Database::query($sql);
2741 2741
         while ($row = Database::fetch_array($allpages)) {
2742 2742
             $total_versions = $row['TOTAL_VERS'];
2743 2743
             $total_visits = intval($row['TOTAL_VISITS']);
@@ -2747,30 +2747,30 @@  discard block
 block discarded – undo
2747 2747
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2748 2748
         $allpages = Database::query($sql);
2749 2749
 
2750
-        while ($row=Database::fetch_array($allpages)) {
2750
+        while ($row = Database::fetch_array($allpages)) {
2751 2751
             $total_words = $total_words + self::word_count($row['content']);
2752
-            $total_links 			= $total_links+substr_count($row['content'], "href=");
2753
-            $total_links_anchors 	= $total_links_anchors+substr_count($row['content'], 'href="#');
2754
-            $total_links_mail		= $total_links_mail+substr_count($row['content'], 'href="mailto');
2755
-            $total_links_ftp 		= $total_links_ftp+substr_count($row['content'], 'href="ftp');
2756
-            $total_links_irc		= $total_links_irc+substr_count($row['content'], 'href="irc');
2757
-            $total_links_news 		= $total_links_news+substr_count($row['content'], 'href="news');
2758
-            $total_wlinks 			= $total_wlinks+substr_count($row['content'], "[[");
2759
-            $total_images 			= $total_images+substr_count($row['content'], "<img");
2752
+            $total_links = $total_links + substr_count($row['content'], "href=");
2753
+            $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#');
2754
+            $total_links_mail		= $total_links_mail + substr_count($row['content'], 'href="mailto');
2755
+            $total_links_ftp 		= $total_links_ftp + substr_count($row['content'], 'href="ftp');
2756
+            $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc');
2757
+            $total_links_news = $total_links_news + substr_count($row['content'], 'href="news');
2758
+            $total_wlinks 			= $total_wlinks + substr_count($row['content'], "[[");
2759
+            $total_images 			= $total_images + substr_count($row['content'], "<img");
2760 2760
             $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
2761
-            $total_flash			= $total_flash+substr_count($clean_total_flash, '.swf"');
2761
+            $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"');
2762 2762
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2763
-            $total_mp3				= $total_mp3+substr_count($row['content'], ".mp3");
2764
-            $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
2765
-            $total_flv				=	$total_flv_p/5;
2766
-            $total_youtube			= $total_youtube+substr_count($row['content'], "http://www.youtube.com");
2767
-            $total_multimedia		= $total_multimedia+substr_count($row['content'], "video/x-msvideo");
2768
-            $total_tables			= $total_tables+substr_count($row['content'], "<table");
2763
+            $total_mp3				= $total_mp3 + substr_count($row['content'], ".mp3");
2764
+            $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv");
2765
+            $total_flv				= $total_flv_p / 5;
2766
+            $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com");
2767
+            $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo");
2768
+            $total_tables = $total_tables + substr_count($row['content'], "<table");
2769 2769
         }
2770 2770
 
2771 2771
         //check only last version of all pages (current page)
2772 2772
 
2773
-        $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2773
+        $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2774 2774
                 FROM  '.$tbl_wiki.' s1
2775 2775
                 WHERE s1.c_id = '.$course_id.' AND id=(
2776 2776
                     SELECT MAX(s2.id)
@@ -2781,9 +2781,9 @@  discard block
 block discarded – undo
2781 2781
                         '.$groupfilter.' AND
2782 2782
                         session_id='.$session_id.')';
2783 2783
         $allpages = Database::query($sql);
2784
-        while ($row=Database::fetch_array($allpages)) {
2785
-            $total_pages	 		= $row['TOTAL_PAGES'];
2786
-            $total_visits_lv 		= intval($row['TOTAL_VISITS_LV']);
2784
+        while ($row = Database::fetch_array($allpages)) {
2785
+            $total_pages = $row['TOTAL_PAGES'];
2786
+            $total_visits_lv = intval($row['TOTAL_VISITS_LV']);
2787 2787
         }
2788 2788
 
2789 2789
         $total_words_lv = 0;
@@ -2815,29 +2815,29 @@  discard block
 block discarded – undo
2815 2815
                 )';
2816 2816
         $allpages = Database::query($sql);
2817 2817
 
2818
-        while ($row=Database::fetch_array($allpages)) {
2819
-            $total_words_lv 		= $total_words_lv+ self::word_count($row['content']);
2820
-            $total_links_lv 		= $total_links_lv+substr_count($row['content'], "href=");
2821
-            $total_links_anchors_lv	= $total_links_anchors_lv+substr_count($row['content'], 'href="#');
2822
-            $total_links_mail_lv 	= $total_links_mail_lv+substr_count($row['content'], 'href="mailto');
2823
-            $total_links_ftp_lv 	= $total_links_ftp_lv+substr_count($row['content'], 'href="ftp');
2824
-            $total_links_irc_lv 	= $total_links_irc_lv+substr_count($row['content'], 'href="irc');
2825
-            $total_links_news_lv 	= $total_links_news_lv+substr_count($row['content'], 'href="news');
2826
-            $total_wlinks_lv 		= $total_wlinks_lv+substr_count($row['content'], "[[");
2827
-            $total_images_lv 		= $total_images_lv+substr_count($row['content'], "<img");
2818
+        while ($row = Database::fetch_array($allpages)) {
2819
+            $total_words_lv 		= $total_words_lv + self::word_count($row['content']);
2820
+            $total_links_lv 		= $total_links_lv + substr_count($row['content'], "href=");
2821
+            $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#');
2822
+            $total_links_mail_lv 	= $total_links_mail_lv + substr_count($row['content'], 'href="mailto');
2823
+            $total_links_ftp_lv 	= $total_links_ftp_lv + substr_count($row['content'], 'href="ftp');
2824
+            $total_links_irc_lv 	= $total_links_irc_lv + substr_count($row['content'], 'href="irc');
2825
+            $total_links_news_lv 	= $total_links_news_lv + substr_count($row['content'], 'href="news');
2826
+            $total_wlinks_lv 		= $total_wlinks_lv + substr_count($row['content'], "[[");
2827
+            $total_images_lv 		= $total_images_lv + substr_count($row['content'], "<img");
2828 2828
             $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
2829
-            $total_flash_lv			= $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
2829
+            $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"');
2830 2830
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2831
-            $total_mp3_lv			= $total_mp3_lv+substr_count($row['content'], ".mp3");
2832
-            $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
2833
-            $total_flv_lv			= $total_flv_p_lv/5;
2834
-            $total_youtube_lv		= $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com");
2835
-            $total_multimedia_lv	= $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo");
2836
-            $total_tables_lv		= $total_tables_lv+substr_count($row['content'], "<table");
2831
+            $total_mp3_lv			= $total_mp3_lv + substr_count($row['content'], ".mp3");
2832
+            $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv");
2833
+            $total_flv_lv			= $total_flv_p_lv / 5;
2834
+            $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com");
2835
+            $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo");
2836
+            $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table");
2837 2837
         }
2838 2838
 
2839 2839
         //Total pages edited at this time
2840
-        $total_editing_now=0;
2840
+        $total_editing_now = 0;
2841 2841
         $sql = 'SELECT *, COUNT(*) AS TOTAL_EDITING_NOW
2842 2842
                 FROM  '.$tbl_wiki.' s1
2843 2843
                 WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND
@@ -2852,66 +2852,66 @@  discard block
 block discarded – undo
2852 2852
         )';
2853 2853
 
2854 2854
         // Can not use group by because the mark is set in the latest version
2855
-        $allpages=Database::query($sql);
2856
-        while ($row=Database::fetch_array($allpages)) {
2857
-            $total_editing_now	= $row['TOTAL_EDITING_NOW'];
2855
+        $allpages = Database::query($sql);
2856
+        while ($row = Database::fetch_array($allpages)) {
2857
+            $total_editing_now = $row['TOTAL_EDITING_NOW'];
2858 2858
         }
2859 2859
 
2860 2860
         // Total hidden pages
2861
-        $total_hidden=0;
2861
+        $total_hidden = 0;
2862 2862
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2863 2863
                 WHERE  c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
2864 2864
                 GROUP BY reflink';
2865 2865
         // 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
2866
-        $allpages=Database::query($sql);
2867
-        while ($row=Database::fetch_array($allpages)) {
2868
-            $total_hidden = $total_hidden+1;
2866
+        $allpages = Database::query($sql);
2867
+        while ($row = Database::fetch_array($allpages)) {
2868
+            $total_hidden = $total_hidden + 1;
2869 2869
         }
2870 2870
 
2871 2871
         //Total protect pages
2872
-        $total_protected=0;
2872
+        $total_protected = 0;
2873 2873
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2874 2874
                 WHERE  c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.'
2875 2875
                 GROUP BY reflink';
2876 2876
         // or group by page_id. As the mark of protected page is the first version of the page, I can use group by
2877 2877
 
2878
-        $allpages=Database::query($sql);
2879
-        while ($row=Database::fetch_array($allpages)) {
2880
-            $total_protected = $total_protected+1;
2878
+        $allpages = Database::query($sql);
2879
+        while ($row = Database::fetch_array($allpages)) {
2880
+            $total_protected = $total_protected + 1;
2881 2881
         }
2882 2882
 
2883 2883
         // Total empty versions.
2884
-        $total_empty_content=0;
2884
+        $total_empty_content = 0;
2885 2885
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2886 2886
                 WHERE
2887 2887
                     c_id = '.$course_id.' AND
2888 2888
                     content="" AND
2889 2889
                     '.$groupfilter.$condition_session.'';
2890 2890
         $allpages = Database::query($sql);
2891
-        while ($row=Database::fetch_array($allpages)) {
2892
-            $total_empty_content	= $total_empty_content+1;
2891
+        while ($row = Database::fetch_array($allpages)) {
2892
+            $total_empty_content = $total_empty_content + 1;
2893 2893
         }
2894 2894
 
2895 2895
         //Total empty pages (last version)
2896 2896
 
2897
-        $total_empty_content_lv=0;
2897
+        $total_empty_content_lv = 0;
2898 2898
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2899 2899
                 WHERE s1.c_id = '.$course_id.' AND content="" AND id=(
2900 2900
                 SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2901 2901
                 WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2902
-        $allpages=Database::query($sql);
2902
+        $allpages = Database::query($sql);
2903 2903
         while ($row = Database::fetch_array($allpages)) {
2904
-            $total_empty_content_lv	= $total_empty_content_lv+1;
2904
+            $total_empty_content_lv = $total_empty_content_lv + 1;
2905 2905
         }
2906 2906
 
2907 2907
         // Total locked discuss pages
2908
-        $total_lock_disc=0;
2908
+        $total_lock_disc = 0;
2909 2909
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2910 2910
                 WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.'
2911 2911
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2912
-        $allpages=Database::query($sql);
2912
+        $allpages = Database::query($sql);
2913 2913
         while ($row = Database::fetch_array($allpages)) {
2914
-            $total_lock_disc	= $total_lock_disc+1;
2914
+            $total_lock_disc = $total_lock_disc + 1;
2915 2915
         }
2916 2916
 
2917 2917
         // Total hidden discuss pages.
@@ -2922,7 +2922,7 @@  discard block
 block discarded – undo
2922 2922
         //group by because mark lock in all vers, then always is ok
2923 2923
         $allpages = Database::query($sql);
2924 2924
         while ($row = Database::fetch_array($allpages)) {
2925
-            $total_hidden_disc	= $total_hidden_disc+1;
2925
+            $total_hidden_disc = $total_hidden_disc + 1;
2926 2926
         }
2927 2927
 
2928 2928
         //Total versions with any short comment by user or system
@@ -2930,44 +2930,44 @@  discard block
 block discarded – undo
2930 2930
         $total_comment_version = 0;
2931 2931
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2932 2932
                 WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.'';
2933
-        $allpages=Database::query($sql);
2933
+        $allpages = Database::query($sql);
2934 2934
         while ($row = Database::fetch_array($allpages)) {
2935
-            $total_comment_version	= $total_comment_version+1;
2935
+            $total_comment_version = $total_comment_version + 1;
2936 2936
         }
2937 2937
 
2938 2938
         // Total pages that can only be scored by teachers.
2939 2939
 
2940
-        $total_only_teachers_rating=0;
2940
+        $total_only_teachers_rating = 0;
2941 2941
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2942 2942
                 WHERE c_id = '.$course_id.' AND
2943 2943
                 ratinglock_disc = 0 AND
2944 2944
                 '.$groupfilter.$condition_session.'
2945 2945
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2946
-        $allpages=Database::query($sql);
2947
-        while ($row=Database::fetch_array($allpages)) {
2948
-            $total_only_teachers_rating	= $total_only_teachers_rating+1;
2946
+        $allpages = Database::query($sql);
2947
+        while ($row = Database::fetch_array($allpages)) {
2948
+            $total_only_teachers_rating = $total_only_teachers_rating + 1;
2949 2949
         }
2950 2950
 
2951 2951
         // Total pages scored by peers
2952 2952
         // put always this line alfter check num all pages and num pages rated by teachers
2953
-        $total_rating_by_peers=$total_pages-$total_only_teachers_rating;
2953
+        $total_rating_by_peers = $total_pages - $total_only_teachers_rating;
2954 2954
 
2955 2955
         //Total pages identified as standard task
2956 2956
 
2957
-        $total_task=0;
2958
-        $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2957
+        $total_task = 0;
2958
+        $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2959 2959
               WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
2960 2960
                '.$tbl_wiki_conf.'.task!="" AND
2961 2961
                '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
2962 2962
                 '.$tbl_wiki.'.'.$groupfilter.$condition_session;
2963 2963
         $allpages = Database::query($sql);
2964
-        while ($row=Database::fetch_array($allpages)) {
2965
-            $total_task=$total_task+1;
2964
+        while ($row = Database::fetch_array($allpages)) {
2965
+            $total_task = $total_task + 1;
2966 2966
         }
2967 2967
 
2968 2968
         //Total pages identified as teacher page (wiki portfolio mode - individual assignment)
2969 2969
 
2970
-        $total_teacher_assignment=0;
2970
+        $total_teacher_assignment = 0;
2971 2971
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2972 2972
                 WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=(
2973 2973
                     SELECT MAX(s2.id)
@@ -2977,20 +2977,20 @@  discard block
 block discarded – undo
2977 2977
         //mark all versions, but do not use group by reflink because y want the pages not versions
2978 2978
         $allpages = Database::query($sql);
2979 2979
         while ($row = Database::fetch_array($allpages)) {
2980
-            $total_teacher_assignment=$total_teacher_assignment+1;
2980
+            $total_teacher_assignment = $total_teacher_assignment + 1;
2981 2981
         }
2982 2982
 
2983 2983
         //Total pages identifies as student page (wiki portfolio mode - individual assignment)
2984 2984
 
2985
-        $total_student_assignment=0;
2985
+        $total_student_assignment = 0;
2986 2986
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2987 2987
                 WHERE s1.c_id = '.$course_id.' AND assignment=2 AND
2988 2988
                 id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2989 2989
                 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2990 2990
         //mark all versions, but do not use group by reflink because y want the pages not versions
2991
-        $allpages=Database::query($sql);
2992
-        while ($row=Database::fetch_array($allpages)) {
2993
-            $total_student_assignment = $total_student_assignment+1;
2991
+        $allpages = Database::query($sql);
2992
+        while ($row = Database::fetch_array($allpages)) {
2993
+            $total_student_assignment = $total_student_assignment + 1;
2994 2994
         }
2995 2995
 
2996 2996
         //Current Wiki status add new pages
@@ -2999,14 +2999,14 @@  discard block
 block discarded – undo
2999 2999
                 GROUP BY addlock';//group by because mark 0 in all vers, then always is ok
3000 3000
         $allpages = Database::query($sql);
3001 3001
         $wiki_add_lock = null;
3002
-        while ($row=Database::fetch_array($allpages)) {
3003
-            $wiki_add_lock=$row['addlock'];
3002
+        while ($row = Database::fetch_array($allpages)) {
3003
+            $wiki_add_lock = $row['addlock'];
3004 3004
         }
3005 3005
 
3006
-        if ($wiki_add_lock==1) {
3007
-            $status_add_new_pag=get_lang('Yes');
3006
+        if ($wiki_add_lock == 1) {
3007
+            $status_add_new_pag = get_lang('Yes');
3008 3008
         } else {
3009
-            $status_add_new_pag=get_lang('No');
3009
+            $status_add_new_pag = get_lang('No');
3010 3010
         }
3011 3011
 
3012 3012
         //Creation date of the oldest wiki page and version
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
                 ORDER BY dtime DESC 
3030 3030
                 LIMIT 1';
3031 3031
         $allpages = Database::query($sql);
3032
-        while ($row=Database::fetch_array($allpages)) {
3032
+        while ($row = Database::fetch_array($allpages)) {
3033 3033
             $last_wiki_date = $row['dtime'];
3034 3034
         }
3035 3035
 
@@ -3042,18 +3042,18 @@  discard block
 block discarded – undo
3042 3042
         // Do not use "count" because using "group by", would give a wrong value
3043 3043
         $allpages = Database::query($sql);
3044 3044
         $total_score = 0;
3045
-        while ($row=Database::fetch_array($allpages)) {
3046
-            $total_score = $total_score+$row['TOTAL_SCORE'];
3045
+        while ($row = Database::fetch_array($allpages)) {
3046
+            $total_score = $total_score + $row['TOTAL_SCORE'];
3047 3047
         }
3048 3048
 
3049 3049
         if (!empty($total_pages)) {
3050
-            $media_score = $total_score/$total_pages;
3050
+            $media_score = $total_score / $total_pages;
3051 3051
             //put always this line alfter check num all pages
3052 3052
         }
3053 3053
 
3054 3054
         // Average user progress in his pages.
3055 3055
 
3056
-        $media_progress=0;
3056
+        $media_progress = 0;
3057 3057
         $sql = 'SELECT  *, SUM(progress) AS TOTAL_PROGRESS
3058 3058
                 FROM  '.$tbl_wiki.' s1
3059 3059
                 WHERE s1.c_id = '.$course_id.' AND id=
@@ -3067,24 +3067,24 @@  discard block
 block discarded – undo
3067 3067
         // As the value is only the latest version I can not use group by
3068 3068
         $allpages = Database::query($sql);
3069 3069
         while ($row = Database::fetch_array($allpages)) {
3070
-            $total_progress	= $row['TOTAL_PROGRESS'];
3070
+            $total_progress = $row['TOTAL_PROGRESS'];
3071 3071
         }
3072 3072
 
3073 3073
         if (!empty($total_pages)) {
3074
-            $media_progress=$total_progress/$total_pages;
3074
+            $media_progress = $total_progress / $total_pages;
3075 3075
             //put always this line alfter check num all pages
3076 3076
         }
3077 3077
 
3078 3078
         //Total users that have participated in the Wiki
3079 3079
 
3080
-        $total_users=0;
3080
+        $total_users = 0;
3081 3081
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3082 3082
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3083 3083
                 GROUP BY user_id';
3084 3084
         //as the mark of user it in all versions of the page, I can use group by to see the first
3085
-        $allpages=Database::query($sql);
3086
-        while ($row=Database::fetch_array($allpages)) {
3087
-            $total_users = $total_users+1;
3085
+        $allpages = Database::query($sql);
3086
+        while ($row = Database::fetch_array($allpages)) {
3087
+            $total_users = $total_users + 1;
3088 3088
         }
3089 3089
 
3090 3090
         // Total of different IP addresses that have participated in the wiki
@@ -3092,9 +3092,9 @@  discard block
 block discarded – undo
3092 3092
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3093 3093
               WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3094 3094
               GROUP BY user_ip';
3095
-        $allpages=Database::query($sql);
3096
-        while ($row=Database::fetch_array($allpages)) {
3097
-            $total_ip	= $total_ip+1;
3095
+        $allpages = Database::query($sql);
3096
+        while ($row = Database::fetch_array($allpages)) {
3097
+            $total_ip = $total_ip + 1;
3098 3098
         }
3099 3099
 
3100 3100
         echo '<table class="data_table">';
@@ -3286,18 +3286,18 @@  discard block
 block discarded – undo
3286 3286
                 $userinfo = api_get_user_info($obj->user_id);
3287 3287
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
3288 3288
                 $row = array();
3289
-                if ($obj->user_id != 0  && $userinfo !== false) {
3289
+                if ($obj->user_id != 0 && $userinfo !== false) {
3290 3290
                     $row[] = UserManager::getUserProfileLink($userinfo).'
3291 3291
                             <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).
3292 3292
                         '&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'"></a>';
3293 3293
                 } else {
3294 3294
                     $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3295 3295
                 }
3296
-                $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>';
3296
+                $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>';
3297 3297
                 $rows[] = $row;
3298 3298
             }
3299 3299
 
3300
-            $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
3300
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'MostActiveUsersA_table', '', '', 'DESC');
3301 3301
             $table->set_additional_parameters(
3302 3302
                 array(
3303 3303
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -3306,8 +3306,8 @@  discard block
 block discarded – undo
3306 3306
                     'group_id' => Security::remove_XSS($_GET['group_id'])
3307 3307
                 )
3308 3308
             );
3309
-            $table->set_header(0,get_lang('Author'), true);
3310
-            $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
3309
+            $table->set_header(0, get_lang('Author'), true);
3310
+            $table->set_header(1, get_lang('Contributions'), true, array('style' => 'width:30px;'));
3311 3311
             $table->display();
3312 3312
         }
3313 3313
     }
@@ -3323,8 +3323,8 @@  discard block
 block discarded – undo
3323 3323
         $groupfilter = $this->groupfilter;
3324 3324
         $tbl_wiki_discuss = $this->tbl_wiki_discuss;
3325 3325
 
3326
-        if (api_get_session_id()!=0 &&
3327
-            api_is_allowed_to_session_edit(false,true)==false
3326
+        if (api_get_session_id() != 0 &&
3327
+            api_is_allowed_to_session_edit(false, true) == false
3328 3328
         ) {
3329 3329
             api_not_allowed();
3330 3330
         }
@@ -3387,9 +3387,9 @@  discard block
 block discarded – undo
3387 3387
         //mode assignment: previous to show  page type
3388 3388
         $icon_assignment = null;
3389 3389
         if ($row['assignment'] == 1) {
3390
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
3390
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
3391 3391
         } elseif ($row['assignment'] == 2) {
3392
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
3392
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
3393 3393
         }
3394 3394
 
3395 3395
         $countWPost = null;
@@ -3400,23 +3400,23 @@  discard block
 block discarded – undo
3400 3400
             // Show discussion to students if isn't hidden.
3401 3401
             // Show page to all teachers if is hidden.
3402 3402
             // Mode assignments: If is hidden, show pages to student only if student is the author
3403
-            if ($row['visibility_disc']==1 ||
3404
-                api_is_allowed_to_edit(false,true) ||
3403
+            if ($row['visibility_disc'] == 1 ||
3404
+                api_is_allowed_to_edit(false, true) ||
3405 3405
                 api_is_platform_admin() ||
3406
-                ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))
3406
+                ($row['assignment'] == 2 && $row['visibility_disc'] == 0 && (api_get_user_id() == $row['user_id']))
3407 3407
             ) {
3408 3408
                 echo '<div id="wikititle">';
3409 3409
 
3410 3410
                 // discussion action: protecting (locking) the discussion
3411 3411
                 $addlock_disc = null;
3412 3412
                 $lock_unlock_disc = null;
3413
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3413
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3414 3414
                     if (self::check_addlock_discuss() == 1) {
3415
-                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL);
3416
-                        $lock_unlock_disc ='unlockdisc';
3415
+                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'), '', ICON_SIZE_SMALL);
3416
+                        $lock_unlock_disc = 'unlockdisc';
3417 3417
                     } else {
3418
-                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL);
3419
-                        $lock_unlock_disc ='lockdisc';
3418
+                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'), '', ICON_SIZE_SMALL);
3419
+                        $lock_unlock_disc = 'lockdisc';
3420 3420
                     }
3421 3421
                 }
3422 3422
                 echo '<span style="float:right">';
@@ -3426,13 +3426,13 @@  discard block
 block discarded – undo
3426 3426
                 // discussion action: visibility.  Show discussion to students if isn't hidden. Show page to all teachers if is hidden.
3427 3427
                 $visibility_disc = null;
3428 3428
                 $hide_show_disc = null;
3429
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3430
-                    if (self::check_visibility_discuss()==1) {
3429
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3430
+                    if (self::check_visibility_discuss() == 1) {
3431 3431
                         /// TODO: 	Fix Mode assignments: If is hidden, show discussion to student only if student is the author
3432
-                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL);
3432
+                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'), '', ICON_SIZE_SMALL);
3433 3433
                         $hide_show_disc = 'hidedisc';
3434 3434
                     } else {
3435
-                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL);
3435
+                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'), '', ICON_SIZE_SMALL);
3436 3436
                         $hide_show_disc = 'showdisc';
3437 3437
                     }
3438 3438
                 }
@@ -3443,12 +3443,12 @@  discard block
 block discarded – undo
3443 3443
                 //discussion action: check add rating lock. Show/Hide list to rating for all student
3444 3444
                 $lock_unlock_rating_disc = null;
3445 3445
                 $ratinglock_disc = null;
3446
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3446
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3447 3447
                     if (self::check_ratinglock_discuss() == 1) {
3448
-                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3448
+                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3449 3449
                         $lock_unlock_rating_disc = 'unlockrating';
3450 3450
                     } else {
3451
-                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3451
+                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3452 3452
                         $lock_unlock_rating_disc = 'lockrating';
3453 3453
                     }
3454 3454
                 }
@@ -3459,11 +3459,11 @@  discard block
 block discarded – undo
3459 3459
 
3460 3460
                 //discussion action: email notification
3461 3461
                 if (self::check_notify_discuss($page) == 1) {
3462
-                    $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3463
-                    $lock_unlock_notify_disc='unlocknotifydisc';
3462
+                    $notify_disc = Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3463
+                    $lock_unlock_notify_disc = 'unlocknotifydisc';
3464 3464
                 } else {
3465
-                    $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3466
-                    $lock_unlock_notify_disc='locknotifydisc';
3465
+                    $notify_disc = Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3466
+                    $lock_unlock_notify_disc = 'locknotifydisc';
3467 3467
                 }
3468 3468
                 echo '<span style="float:right">';
3469 3469
                 echo '<a href="index.php?action=discuss&amp;actionpage='.$lock_unlock_notify_disc.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>';
@@ -3472,27 +3472,27 @@  discard block
 block discarded – undo
3472 3472
                 echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.api_htmlentities($row['title']);
3473 3473
 
3474 3474
                 if ($lastuserinfo !== false) {
3475
-                    echo ' (' . get_lang('MostRecentVersionBy') . ' ' . UserManager::getUserProfileLink($lastuserinfo) . ' ' . $lastversiondate . $countWPost . ')' . $avg_WPost_score . ' '; //TODO: read average score
3475
+                    echo ' ('.get_lang('MostRecentVersionBy').' '.UserManager::getUserProfileLink($lastuserinfo).' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score
3476 3476
                 }
3477 3477
 
3478 3478
                 echo '</div>';
3479 3479
 
3480
-                if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3480
+                if ($row['addlock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3481 3481
                     //show comments but students can't add theirs
3482 3482
                     ?>
3483 3483
                     <form name="form1" method="post" action="">
3484 3484
                         <table>
3485 3485
                             <tr>
3486
-                                <td valign="top" ><?php echo get_lang('Comments');?>:</td>
3487
-                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?>
3486
+                                <td valign="top" ><?php echo get_lang('Comments'); ?>:</td>
3487
+                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">'; //prevent double post ?>
3488 3488
                                 <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
3489 3489
                             </tr>
3490 3490
                             <tr>
3491 3491
                                 <?php
3492 3492
                                 //check if rating is allowed
3493
-                                if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3493
+                                if ($row['ratinglock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3494 3494
                                     ?>
3495
-                                    <td><?php echo get_lang('Rating');?>: </td>
3495
+                                    <td><?php echo get_lang('Rating'); ?>: </td>
3496 3496
                                     <td valign="top"><select name="rating" id="rating">
3497 3497
                                             <option value="-" selected>-</option>
3498 3498
                                             <option value="0">0</option>
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
                                         </select></td>
3510 3510
                                 <?php
3511 3511
                                 } else {
3512
-                                    echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically
3512
+                                    echo '<input type=hidden name="rating" value="-">'; // must pass a default value to avoid rate automatically
3513 3513
                                 }
3514 3514
                                 ?>
3515 3515
                             </tr>
@@ -3549,12 +3549,12 @@  discard block
 block discarded – undo
3549 3549
                 $sql = "SELECT * FROM $tbl_wiki_discuss
3550 3550
                         WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
3551 3551
                 $result3 = Database::query($sql);
3552
-                $countWPost_score= Database::num_rows($result3);
3552
+                $countWPost_score = Database::num_rows($result3);
3553 3553
 
3554
-                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;//
3554
+                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score; //
3555 3555
 
3556
-                if ($countWPost_score!=0) {
3557
-                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
3556
+                if ($countWPost_score != 0) {
3557
+                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score, 2).' / 10';
3558 3558
                 } else {
3559 3559
                     $avg_WPost_score = $countWPost_score;
3560 3560
                 }
@@ -3572,16 +3572,16 @@  discard block
 block discarded – undo
3572 3572
 
3573 3573
                 echo '<hr noshade size="1">';
3574 3574
 
3575
-                while ($row=Database::fetch_array($result)) {
3575
+                while ($row = Database::fetch_array($result)) {
3576 3576
                     $userinfo = api_get_user_info($row['userc_id']);
3577
-                    if (($userinfo['status'])=="5") {
3578
-                        $author_status=get_lang('Student');
3577
+                    if (($userinfo['status']) == "5") {
3578
+                        $author_status = get_lang('Student');
3579 3579
                     } else {
3580
-                        $author_status=get_lang('Teacher');
3580
+                        $author_status = get_lang('Teacher');
3581 3581
                     }
3582 3582
 
3583 3583
                     $name = $userinfo['complete_name'];
3584
-                    $author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3584
+                    $author_photo = '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3585 3585
 
3586 3586
                     //stars
3587 3587
                     $p_score = $row['p_score'];
@@ -3627,7 +3627,7 @@  discard block
 block discarded – undo
3627 3627
                     if ($userinfo !== false) {
3628 3628
                         $userProfile = UserManager::getUserProfileLink($userinfo);
3629 3629
                     }
3630
-                    echo '<td style=" color:#999999">' . $userProfile . ' (' . $author_status . ') '.
3630
+                    echo '<td style=" color:#999999">'.$userProfile.' ('.$author_status.') '.
3631 3631
                         api_get_local_time($row['dtime'], null, date_default_timezone_get()).
3632 3632
                         ' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
3633 3633
                     echo '</tr>';
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
         }
3665 3665
         echo '</div>';
3666 3666
 
3667
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3667
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3668 3668
             $sql = 'SELECT  *
3669 3669
                     FROM  '.$tbl_wiki.' s1
3670 3670
         		    WHERE s1.c_id = '.$course_id.' AND id=(
@@ -3690,11 +3690,11 @@  discard block
 block discarded – undo
3690 3690
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
3691 3691
 
3692 3692
                 //get type assignment icon
3693
-                if ($obj->assignment==1) {
3694
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3695
-                } elseif ($obj->assignment==2) {
3696
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3697
-                } elseif ($obj->assignment==0) {
3693
+                if ($obj->assignment == 1) {
3694
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3695
+                } elseif ($obj->assignment == 2) {
3696
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3697
+                } elseif ($obj->assignment == 0) {
3698 3698
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
3699 3699
                 }
3700 3700
 
@@ -3717,29 +3717,29 @@  discard block
 block discarded – undo
3717 3717
                 }
3718 3718
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
3719 3719
                 $showdelete = '';
3720
-                if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
3721
-                    $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']).'">'.
3722
-                        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
3720
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3721
+                    $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']).'">'.
3722
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
3723 3723
                 }
3724
-                if (api_is_allowed_to_session_edit(false,true) ) {
3724
+                if (api_is_allowed_to_session_edit(false, true)) {
3725 3725
                     $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']).'">'.
3726
-                        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']).'">'.
3727
-                        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']).'">'.
3728
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a>
3726
+                        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']).'">'.
3727
+                        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']).'">'.
3728
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a>
3729 3729
                         <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']).'">'.
3730
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
3730
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
3731 3731
                 }
3732 3732
                 $rows[] = $row;
3733 3733
             }
3734 3734
 
3735
-            $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
3736
-            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'group_id'=>Security::remove_XSS($_GET['group_id'])));
3737
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
3738
-            $table->set_header(1,get_lang('Title'), true);
3739
-            $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
3740
-            $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
3741
-            if (api_is_allowed_to_session_edit(false,true) ) {
3742
-                $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;'));
3735
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC');
3736
+            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']), 'action'=>Security::remove_XSS($action), 'group_id'=>Security::remove_XSS($_GET['group_id'])));
3737
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
3738
+            $table->set_header(1, get_lang('Title'), true);
3739
+            $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
3740
+            $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
3741
+            if (api_is_allowed_to_session_edit(false, true)) {
3742
+                $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;'));
3743 3743
             }
3744 3744
             $table->display();
3745 3745
         }
@@ -3759,13 +3759,13 @@  discard block
 block discarded – undo
3759 3759
         $groupfilter = $this->groupfilter;
3760 3760
         $tbl_wiki_conf = $this->tbl_wiki_conf;
3761 3761
 
3762
-        if (api_is_allowed_to_session_edit(false,true) ) {
3763
-            if (self::check_notify_all()==1) {
3764
-                $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3765
-                $lock_unlock_notify_all='unlocknotifyall';
3762
+        if (api_is_allowed_to_session_edit(false, true)) {
3763
+            if (self::check_notify_all() == 1) {
3764
+                $notify_all = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3765
+                $lock_unlock_notify_all = 'unlocknotifyall';
3766 3766
             } else {
3767
-                $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3768
-                $lock_unlock_notify_all='locknotifyall';
3767
+                $notify_all = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3768
+                $lock_unlock_notify_all = 'locknotifyall';
3769 3769
             }
3770 3770
         }
3771 3771
 
@@ -3773,7 +3773,7 @@  discard block
 block discarded – undo
3773 3773
         echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_all.'</a>';
3774 3774
         echo '</span>'.get_lang('RecentChanges').'</div>';
3775 3775
 
3776
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3776
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3777 3777
             $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
3778 3778
         		WHERE 	'.$tbl_wiki_conf.'.c_id= '.$course_id.' AND
3779 3779
         				'.$tbl_wiki.'.c_id= '.$course_id.' AND
@@ -3801,19 +3801,19 @@  discard block
 block discarded – undo
3801 3801
                 $userinfo = api_get_user_info($obj->user_id);
3802 3802
 
3803 3803
                 //get type assignment icon
3804
-                if ($obj->assignment==1) {
3805
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3806
-                } elseif ($obj->assignment==2) {
3807
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3808
-                } elseif ($obj->assignment==0) {
3809
-                    $ShowAssignment=Display::return_icon('px_transparent.gif');
3804
+                if ($obj->assignment == 1) {
3805
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3806
+                } elseif ($obj->assignment == 2) {
3807
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3808
+                } elseif ($obj->assignment == 0) {
3809
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
3810 3810
                 }
3811 3811
 
3812 3812
                 // Get icon task
3813 3813
                 if (!empty($obj->task)) {
3814
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3814
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3815 3815
                 } else {
3816
-                    $icon_task=Display::return_icon('px_transparent.gif');
3816
+                    $icon_task = Display::return_icon('px_transparent.gif');
3817 3817
                 }
3818 3818
 
3819 3819
                 $row = array();
@@ -3821,7 +3821,7 @@  discard block
 block discarded – undo
3821 3821
                 $row[] = $ShowAssignment.$icon_task;
3822 3822
                 $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&amp;view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
3823 3823
                     api_htmlentities($obj->title).'</a>';
3824
-                $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
3824
+                $row[] = $obj->version > 1 ? get_lang('EditedBy') : get_lang('AddedBy');
3825 3825
                 if ($userinfo !== false) {
3826 3826
                     $row[] = UserManager::getUserProfileLink($userinfo);
3827 3827
                 } else {
@@ -3830,7 +3830,7 @@  discard block
 block discarded – undo
3830 3830
                 $rows[] = $row;
3831 3831
             }
3832 3832
 
3833
-            $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
3833
+            $table = new SortableTableFromArrayConfig($rows, 0, 10, 'RecentPages_table', '', '', 'DESC');
3834 3834
             $table->set_additional_parameters(
3835 3835
                 array(
3836 3836
                     'cidReq' =>api_get_course_id(),
@@ -3839,11 +3839,11 @@  discard block
 block discarded – undo
3839 3839
                     'group_id' => api_get_group_id()
3840 3840
                 )
3841 3841
             );
3842
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
3843
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
3844
-            $table->set_header(2,get_lang('Title'), true);
3845
-            $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
3846
-            $table->set_header(4,get_lang('Author'), true);
3842
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
3843
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
3844
+            $table->set_header(2, get_lang('Title'), true);
3845
+            $table->set_header(3, get_lang('Actions'), true, array('style' => 'width:80px;'));
3846
+            $table->set_header(4, get_lang('Author'), true);
3847 3847
             $table->display();
3848 3848
         }
3849 3849
     }
@@ -3875,17 +3875,17 @@  discard block
 block discarded – undo
3875 3875
 
3876 3876
             //get type assignment icon
3877 3877
             $ShowAssignment = '';
3878
-            if ($row['assignment']==1) {
3879
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3880
-            } elseif ($row['assignment']==2) {
3881
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3882
-            } elseif ($row['assignment']==0) {
3883
-                $ShowAssignment=Display::return_icon('px_transparent.gif');
3878
+            if ($row['assignment'] == 1) {
3879
+                $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3880
+            } elseif ($row['assignment'] == 2) {
3881
+                $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3882
+            } elseif ($row['assignment'] == 0) {
3883
+                $ShowAssignment = Display::return_icon('px_transparent.gif');
3884 3884
             }
3885 3885
 
3886 3886
             //fix Title to reflink (link Main Page)
3887
-            if ($page==get_lang('DefaultTitle')) {
3888
-                $page='index';
3887
+            if ($page == get_lang('DefaultTitle')) {
3888
+                $page = 'index';
3889 3889
             }
3890 3890
 
3891 3891
             echo '<div id="wikititle">';
@@ -3896,11 +3896,11 @@  discard block
 block discarded – undo
3896 3896
             //fix index to title Main page into linksto
3897 3897
 
3898 3898
             if ($page == 'index') {
3899
-                $page = str_replace(' ','_',get_lang('DefaultTitle'));
3899
+                $page = str_replace(' ', '_', get_lang('DefaultTitle'));
3900 3900
             }
3901 3901
 
3902 3902
             //table
3903
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3903
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3904 3904
                 //only by professors if page is hidden
3905 3905
                 $sql = "SELECT * FROM ".$tbl_wiki." s1
3906 3906
                         WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)."%' AND id=(
@@ -3927,10 +3927,10 @@  discard block
 block discarded – undo
3927 3927
                     //get time
3928 3928
                     $year 	 = substr($obj->dtime, 0, 4);
3929 3929
                     $month	 = substr($obj->dtime, 5, 2);
3930
-                    $day 	 = substr($obj->dtime, 8, 2);
3931
-                    $hours   = substr($obj->dtime, 11,2);
3932
-                    $minutes = substr($obj->dtime, 14,2);
3933
-                    $seconds = substr($obj->dtime, 17,2);
3930
+                    $day = substr($obj->dtime, 8, 2);
3931
+                    $hours   = substr($obj->dtime, 11, 2);
3932
+                    $minutes = substr($obj->dtime, 14, 2);
3933
+                    $seconds = substr($obj->dtime, 17, 2);
3934 3934
 
3935 3935
                     //get type assignment icon
3936 3936
                     if ($obj->assignment == 1) {
@@ -3942,7 +3942,7 @@  discard block
 block discarded – undo
3942 3942
                     }
3943 3943
 
3944 3944
                     $row = array();
3945
-                    $row[] =$ShowAssignment;
3945
+                    $row[] = $ShowAssignment;
3946 3946
                     $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']).'">'.
3947 3947
                         api_htmlentities($obj->title).'</a>';
3948 3948
                     if ($userinfo !== false) {
@@ -4049,13 +4049,13 @@  discard block
 block discarded – undo
4049 4049
         $userId = intval($userId);
4050 4050
         $userinfo = api_get_user_info($userId);
4051 4051
         if ($userinfo !== false) {
4052
-            echo '<div class="actions">' . get_lang('UserContributions') . ': ' . UserManager::getUserProfileLink($userinfo) .
4053
-                '<a href="' . api_get_self() . '?cidReq=' . $_course['code'] . '&action=usercontrib&user_id=' . $userId .
4054
-                '&session_id=' . $this->session_id . '&group_id=' . $this->group_id . '">' .
4052
+            echo '<div class="actions">'.get_lang('UserContributions').': '.UserManager::getUserProfileLink($userinfo).
4053
+                '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.$userId.
4054
+                '&session_id='.$this->session_id.'&group_id='.$this->group_id.'">'.
4055 4055
                 '</a></div>';
4056 4056
         }
4057 4057
 
4058
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4058
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4059 4059
             //only by professors if page is hidden
4060 4060
             $sql = 'SELECT * FROM '.$tbl_wiki.'
4061 4061
                     WHERE
@@ -4080,19 +4080,19 @@  discard block
 block discarded – undo
4080 4080
                 // Get time
4081 4081
                 $year 	 = substr($obj->dtime, 0, 4);
4082 4082
                 $month	 = substr($obj->dtime, 5, 2);
4083
-                $day 	 = substr($obj->dtime, 8, 2);
4084
-                $hours   = substr($obj->dtime, 11,2);
4085
-                $minutes = substr($obj->dtime, 14,2);
4086
-                $seconds = substr($obj->dtime, 17,2);
4083
+                $day = substr($obj->dtime, 8, 2);
4084
+                $hours   = substr($obj->dtime, 11, 2);
4085
+                $minutes = substr($obj->dtime, 14, 2);
4086
+                $seconds = substr($obj->dtime, 17, 2);
4087 4087
 
4088 4088
                 //get type assignment icon
4089 4089
                 $ShowAssignment = '';
4090
-                if ($obj->assignment==1) {
4091
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4092
-                } elseif ($obj->assignment==2) {
4093
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4094
-                } elseif ($obj->assignment==0) {
4095
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4090
+                if ($obj->assignment == 1) {
4091
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4092
+                } elseif ($obj->assignment == 2) {
4093
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4094
+                } elseif ($obj->assignment == 0) {
4095
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4096 4096
                 }
4097 4097
 
4098 4098
                 $row = array();
@@ -4108,7 +4108,7 @@  discard block
 block discarded – undo
4108 4108
 
4109 4109
             }
4110 4110
 
4111
-            $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
4111
+            $table = new SortableTableFromArrayConfig($rows, 2, 10, 'UsersContributions_table', '', '', 'ASC');
4112 4112
             $table->set_additional_parameters(
4113 4113
                 array(
4114 4114
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4118,13 +4118,13 @@  discard block
 block discarded – undo
4118 4118
                     'group_id' => intval($_GET['group_id']),
4119 4119
                 )
4120 4120
             );
4121
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
4122
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
4123
-            $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
4124
-            $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
4125
-            $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
4126
-            $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
4127
-            $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
4121
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
4122
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
4123
+            $table->set_header(2, get_lang('Title'), true, array('style' => 'width:200px;'));
4124
+            $table->set_header(3, get_lang('Version'), true, array('style' => 'width:30px;'));
4125
+            $table->set_header(4, get_lang('Comment'), true, array('style' => 'width:200px;'));
4126
+            $table->set_header(5, get_lang('Progress'), true, array('style' => 'width:30px;'));
4127
+            $table->set_header(6, get_lang('Rating'), true, array('style' => 'width:30px;'));
4128 4128
             $table->display();
4129 4129
         }
4130 4130
     }
@@ -4142,7 +4142,7 @@  discard block
 block discarded – undo
4142 4142
 
4143 4143
         echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
4144 4144
 
4145
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4145
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4146 4146
             $sql = 'SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'
4147 4147
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4148 4148
                     GROUP BY reflink';//TODO:check MAX and group by return last version
@@ -4160,12 +4160,12 @@  discard block
 block discarded – undo
4160 4160
             while ($obj = Database::fetch_object($allpages)) {
4161 4161
                 //get type assignment icon
4162 4162
                 $ShowAssignment = '';
4163
-                if ($obj->assignment==1) {
4164
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4165
-                } elseif ($obj->assignment==2) {
4166
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4167
-                } elseif ($obj->assignment==0) {
4168
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4163
+                if ($obj->assignment == 1) {
4164
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4165
+                } elseif ($obj->assignment == 2) {
4166
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4167
+                } elseif ($obj->assignment == 0) {
4168
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4169 4169
                 }
4170 4170
 
4171 4171
                 $row = array();
@@ -4193,9 +4193,9 @@  discard block
 block discarded – undo
4193 4193
                     'group_id' => intval($_GET['group_id']),
4194 4194
                 )
4195 4195
             );
4196
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4197
-            $table->set_header(1,get_lang('Title'), true);
4198
-            $table->set_header(2,get_lang('Changes'), true);
4196
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4197
+            $table->set_header(1, get_lang('Title'), true);
4198
+            $table->set_header(2, get_lang('Changes'), true);
4199 4199
             $table->display();
4200 4200
         }
4201 4201
     }
@@ -4220,7 +4220,7 @@  discard block
 block discarded – undo
4220 4220
         /* Only teachers and platform admin can edit the index page.
4221 4221
         Only teachers and platform admin can edit an assignment teacher*/
4222 4222
         if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) &&
4223
-            (!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
4223
+            (!api_is_allowed_to_edit(false, true) && $this->group_id == 0)
4224 4224
         ) {
4225 4225
             self::setMessage(
4226 4226
                 Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true)
@@ -4230,7 +4230,7 @@  discard block
 block discarded – undo
4230 4230
             // check if is a wiki group
4231 4231
             if ($current_row['group_id'] != 0) {
4232 4232
                 //Only teacher, platform admin and group members can edit a wiki group
4233
-                if (api_is_allowed_to_edit(false,true) ||
4233
+                if (api_is_allowed_to_edit(false, true) ||
4234 4234
                     api_is_platform_admin() ||
4235 4235
                     GroupManager :: is_user_in_group($userId, $this->group_id) ||
4236 4236
                     api_is_allowed_in_course()
@@ -4249,9 +4249,9 @@  discard block
 block discarded – undo
4249 4249
             //$icon_assignment = null;
4250 4250
             if ($current_row['assignment'] == 1) {
4251 4251
                 self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
4252
-            } elseif($current_row['assignment']==2) {
4253
-                if (($userId == $current_row['user_id'])==false) {
4254
-                    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4252
+            } elseif ($current_row['assignment'] == 2) {
4253
+                if (($userId == $current_row['user_id']) == false) {
4254
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4255 4255
                         $PassEdit = true;
4256 4256
                     } else {
4257 4257
                         self::setMessage(Display::display_warning_message(get_lang('LockByTeacher'), false, true));
@@ -4265,11 +4265,11 @@  discard block
 block discarded – undo
4265 4265
             //show editor if edit is allowed
4266 4266
             if ($PassEdit) {
4267 4267
                 if ($current_row['editlock'] == 1 &&
4268
-                    (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)
4268
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4269 4269
                 ) {
4270 4270
                     self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
4271 4271
                 } else {
4272
-                    if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
4272
+                    if ($last_row['is_editing'] != 0 && $last_row['is_editing'] != $userId) {
4273 4273
                         // Checking for concurrent users
4274 4274
                         $timestamp_edit = strtotime($last_row['time_edit']);
4275 4275
                         $time_editing = time() - $timestamp_edit;
@@ -4278,7 +4278,7 @@  discard block
 block discarded – undo
4278 4278
                         $userinfo = api_get_user_info($last_row['is_editing']);
4279 4279
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'.
4280 4280
                             Display::tag('span', $userinfo['complete_name_with_username']).
4281
-                            get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
4281
+                            get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes');
4282 4282
                         self::setMessage(Display::display_normal_message($is_being_edited, false, true));
4283 4283
                     } else {
4284 4284
                         self::setMessage(Display::display_confirmation_message(
@@ -4386,9 +4386,9 @@  discard block
 block discarded – undo
4386 4386
                 GROUP BY reflink
4387 4387
                 ORDER BY reflink ASC';
4388 4388
         $allpages = Database::query($sql);
4389
-        while ($row=Database::fetch_array($allpages)) {
4390
-            if ($row['reflink']=='index') {
4391
-                $row['reflink']=str_replace(' ', '_', get_lang('DefaultTitle'));
4389
+        while ($row = Database::fetch_array($allpages)) {
4390
+            if ($row['reflink'] == 'index') {
4391
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4392 4392
             }
4393 4393
             $pages[] = $row['reflink'];
4394 4394
         }
@@ -4406,16 +4406,16 @@  discard block
 block discarded – undo
4406 4406
 
4407 4407
         $allpages = Database::query($sql);
4408 4408
 
4409
-        while ($row=Database::fetch_array($allpages)) {
4409
+        while ($row = Database::fetch_array($allpages)) {
4410 4410
             //remove self reference
4411
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
4411
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"]));
4412 4412
             $refs = explode(" ", trim($row["linksto"]));
4413 4413
 
4414 4414
             // Find linksto into reflink. If found ->page is linked
4415 4415
             foreach ($refs as $v) {
4416 4416
                 if (in_array($v, $pages)) {
4417
-                    if (trim($v)!="") {
4418
-                        $linked[]=$v;
4417
+                    if (trim($v) != "") {
4418
+                        $linked[] = $v;
4419 4419
                     }
4420 4420
                 }
4421 4421
             }
@@ -4427,12 +4427,12 @@  discard block
 block discarded – undo
4427 4427
         $rows = array();
4428 4428
         foreach ($linked as $linked_show) {
4429 4429
             $row = array();
4430
-            $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']).'">'.
4431
-                str_replace('_',' ',$linked_show).'</a>';
4430
+            $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']).'">'.
4431
+                str_replace('_', ' ', $linked_show).'</a>';
4432 4432
             $rows[] = $row;
4433 4433
         }
4434 4434
 
4435
-        $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
4435
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'LinkedPages_table', '', '', 'DESC');
4436 4436
         $table->set_additional_parameters(
4437 4437
             array(
4438 4438
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4441,7 +4441,7 @@  discard block
 block discarded – undo
4441 4441
                 'group_id' => intval($_GET['group_id']),
4442 4442
             )
4443 4443
         );
4444
-        $table->set_header(0,get_lang('Title'), true);
4444
+        $table->set_header(0, get_lang('Title'), true);
4445 4445
         $table->display();
4446 4446
     }
4447 4447
 
@@ -4466,8 +4466,8 @@  discard block
 block discarded – undo
4466 4466
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4467 4467
                 GROUP BY reflink
4468 4468
                 ORDER BY reflink ASC';
4469
-        $allpages=Database::query($sql);
4470
-        while ($row=Database::fetch_array($allpages)) {
4469
+        $allpages = Database::query($sql);
4470
+        while ($row = Database::fetch_array($allpages)) {
4471 4471
             $pages[] = $row['reflink'];
4472 4472
         }
4473 4473
 
@@ -4482,14 +4482,14 @@  discard block
 block discarded – undo
4482 4482
                 )';
4483 4483
         $allpages = Database::query($sql);
4484 4484
         $array_refs_linked = array();
4485
-        while ($row=Database::fetch_array($allpages)) {
4486
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4485
+        while ($row = Database::fetch_array($allpages)) {
4486
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4487 4487
             $refs = explode(" ", trim($row["linksto"]));
4488
-            foreach ($refs as $ref_linked){
4489
-                if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
4490
-                    $ref_linked='index';
4488
+            foreach ($refs as $ref_linked) {
4489
+                if ($ref_linked == str_replace(' ', '_', get_lang('DefaultTitle'))) {
4490
+                    $ref_linked = 'index';
4491 4491
                 }
4492
-                $array_refs_linked[]= $ref_linked;
4492
+                $array_refs_linked[] = $ref_linked;
4493 4493
             }
4494 4494
         }
4495 4495
 
@@ -4511,20 +4511,20 @@  discard block
 block discarded – undo
4511 4511
 		                '.$groupfilter.$condition_session.' AND
4512 4512
 		                reflink="'.Database::escape_string($orphaned_show).'"
4513 4513
                     GROUP BY reflink';
4514
-            $allpages=Database::query($sql);
4515
-            while ($row=Database::fetch_array($allpages)) {
4516
-                $orphaned_title=$row['title'];
4517
-                $orphaned_visibility=$row['visibility'];
4518
-                if ($row['assignment']==1) {
4519
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
4520
-                } elseif ($row['assignment']==2) {
4521
-                    $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
4522
-                } elseif ($row['assignment']==0) {
4523
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4514
+            $allpages = Database::query($sql);
4515
+            while ($row = Database::fetch_array($allpages)) {
4516
+                $orphaned_title = $row['title'];
4517
+                $orphaned_visibility = $row['visibility'];
4518
+                if ($row['assignment'] == 1) {
4519
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', '', '', ICON_SIZE_SMALL);
4520
+                } elseif ($row['assignment'] == 2) {
4521
+                    $ShowAssignment = Display::return_icon('wiki_work.png', '', '', ICON_SIZE_SMALL);
4522
+                } elseif ($row['assignment'] == 0) {
4523
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4524 4524
                 }
4525 4525
             }
4526 4526
 
4527
-            if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() && $orphaned_visibility==0){
4527
+            if (!api_is_allowed_to_edit(false, true) || !api_is_platform_admin() && $orphaned_visibility == 0) {
4528 4528
                 continue;
4529 4529
             }
4530 4530
 
@@ -4536,7 +4536,7 @@  discard block
 block discarded – undo
4536 4536
             $rows[] = $row;
4537 4537
         }
4538 4538
 
4539
-        $table = new SortableTableFromArrayConfig($rows,1, 10, 'OrphanedPages_table','','','DESC');
4539
+        $table = new SortableTableFromArrayConfig($rows, 1, 10, 'OrphanedPages_table', '', '', 'DESC');
4540 4540
         $table->set_additional_parameters(
4541 4541
             array(
4542 4542
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4545,8 +4545,8 @@  discard block
 block discarded – undo
4545 4545
                 'group_id' => intval($_GET['group_id']),
4546 4546
             )
4547 4547
         );
4548
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4549
-        $table->set_header(1,get_lang('Title'), true);
4548
+        $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4549
+        $table->set_header(1, get_lang('Title'), true);
4550 4550
         $table->display();
4551 4551
     }
4552 4552
 
@@ -4568,11 +4568,11 @@  discard block
 block discarded – undo
4568 4568
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4569 4569
                 GROUP BY reflink
4570 4570
                 ORDER BY reflink ASC';
4571
-        $allpages=Database::query($sql);
4571
+        $allpages = Database::query($sql);
4572 4572
 
4573
-        while ($row=Database::fetch_array($allpages)) {
4574
-            if ($row['reflink']=='index'){
4575
-                $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
4573
+        while ($row = Database::fetch_array($allpages)) {
4574
+            if ($row['reflink'] == 'index') {
4575
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4576 4576
             }
4577 4577
             $pages[] = $row['reflink'];
4578 4578
         }
@@ -4586,31 +4586,31 @@  discard block
 block discarded – undo
4586 4586
 
4587 4587
         $allpages = Database::query($sql);
4588 4588
 
4589
-        while ($row=Database::fetch_array($allpages)) {
4589
+        while ($row = Database::fetch_array($allpages)) {
4590 4590
             $refs = explode(" ", trim($row["linksto"]));
4591 4591
             // Find linksto into reflink. If not found ->page is wanted
4592 4592
             foreach ($refs as $v) {
4593 4593
 
4594 4594
                 if (!in_array($v, $pages)) {
4595
-                    if (trim($v)!="") {
4596
-                        $wanted[]=$v;
4595
+                    if (trim($v) != "") {
4596
+                        $wanted[] = $v;
4597 4597
                     }
4598 4598
                 }
4599 4599
             }
4600 4600
         }
4601 4601
 
4602
-        $wanted = array_unique($wanted);//make a unique list
4602
+        $wanted = array_unique($wanted); //make a unique list
4603 4603
 
4604 4604
         //show table
4605 4605
         $rows = array();
4606 4606
         foreach ($wanted as $wanted_show) {
4607 4607
             $row = array();
4608 4608
             $wanted_show = Security::remove_XSS($wanted_show);
4609
-            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities
4609
+            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_', ' ', $wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_', ' ', $wanted_show).'</a>'; //meter un remove xss en lugar de htmlentities
4610 4610
             $rows[] = $row;
4611 4611
         }
4612 4612
 
4613
-        $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC');
4613
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'WantedPages_table', '', '', 'DESC');
4614 4614
         $table->set_additional_parameters(
4615 4615
             array(
4616 4616
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4619,7 +4619,7 @@  discard block
 block discarded – undo
4619 4619
                 'group_id' => intval($_GET['group_id']),
4620 4620
             )
4621 4621
         );
4622
-        $table->set_header(0,get_lang('Title'), true);
4622
+        $table->set_header(0, get_lang('Title'), true);
4623 4623
         $table->display();
4624 4624
     }
4625 4625
 
@@ -4636,7 +4636,7 @@  discard block
 block discarded – undo
4636 4636
 
4637 4637
         echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
4638 4638
 
4639
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4639
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4640 4640
             $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
4641 4641
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4642 4642
                     GROUP BY reflink';
@@ -4657,11 +4657,11 @@  discard block
 block discarded – undo
4657 4657
             while ($obj = Database::fetch_object($allpages)) {
4658 4658
                 //get type assignment icon
4659 4659
                 $ShowAssignment = '';
4660
-                if ($obj->assignment==1) {
4661
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4662
-                } elseif ($obj->assignment==2) {
4663
-                    $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4664
-                } elseif ($obj->assignment==0) {
4660
+                if ($obj->assignment == 1) {
4661
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4662
+                } elseif ($obj->assignment == 2) {
4663
+                    $ShowAssignment = $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4664
+                } elseif ($obj->assignment == 0) {
4665 4665
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
4666 4666
                 }
4667 4667
 
@@ -4690,7 +4690,7 @@  discard block
 block discarded – undo
4690 4690
                     'group_id' => intval($_GET['group_id']),
4691 4691
                 )
4692 4692
             );
4693
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4693
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4694 4694
             $table->set_header(1, get_lang('Title'), true);
4695 4695
             $table->set_header(2, get_lang('Visits'), true);
4696 4696
             $table->display();
@@ -4715,8 +4715,8 @@  discard block
 block discarded – undo
4715 4715
 
4716 4716
         if (api_is_allowed_to_session_edit(false, true) && api_is_allowed_to_edit()) {
4717 4717
             // menu add page
4718
-            $actionsLeft .= '<a href="index.php?cidReq=' . $_course['id'] . '&action=addnew&session_id=' . $session_id . '&group_id=' . $groupId . '"' . self::is_active_navigation_tab('addnew').'>'
4719
-            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM) . '</a>';
4718
+            $actionsLeft .= '<a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$groupId.'"'.self::is_active_navigation_tab('addnew').'>'
4719
+            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM).'</a>';
4720 4720
         }
4721 4721
 
4722 4722
         $lock_unlock_addnew = null;
@@ -4724,12 +4724,12 @@  discard block
 block discarded – undo
4724 4724
 
4725 4725
         if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4726 4726
             // page action: enable or disable the adding of new pages
4727
-            if (self::check_addnewpagelock()==0) {
4727
+            if (self::check_addnewpagelock() == 0) {
4728 4728
                 $protect_addnewpage = Display::return_icon('off.png', get_lang('AddOptionProtected'));
4729
-                $lock_unlock_addnew ='unlockaddnew';
4729
+                $lock_unlock_addnew = 'unlockaddnew';
4730 4730
             } else {
4731 4731
                 $protect_addnewpage = Display::return_icon('on.png', get_lang('AddOptionUnprotected'));
4732
-                $lock_unlock_addnew ='lockaddnew';
4732
+                $lock_unlock_addnew = 'lockaddnew';
4733 4733
             }
4734 4734
         }
4735 4735
 
@@ -4749,7 +4749,7 @@  discard block
 block discarded – undo
4749 4749
             get_lang('RecentChanges').'</a>';
4750 4750
 
4751 4751
 
4752
-        echo Display::toolbarAction('toolbar-wiki', array( 0 => $actionsLeft));
4752
+        echo Display::toolbarAction('toolbar-wiki', array(0 => $actionsLeft));
4753 4753
     }
4754 4754
 
4755 4755
     /**
@@ -4767,7 +4767,7 @@  discard block
 block discarded – undo
4767 4767
             return;
4768 4768
         }
4769 4769
 
4770
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4770
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4771 4771
             self::setMessage('<div id="wikititle">'.get_lang('DeletePageHistory').'</div>');
4772 4772
 
4773 4773
             if ($page == "index") {
@@ -4809,7 +4809,7 @@  discard block
 block discarded – undo
4809 4809
         $userId = api_get_user_id();
4810 4810
 
4811 4811
         if (api_get_session_id() != 0 &&
4812
-            api_is_allowed_to_session_edit(false,true) == false
4812
+            api_is_allowed_to_session_edit(false, true) == false
4813 4813
         ) {
4814 4814
             api_not_allowed();
4815 4815
         }
@@ -4832,12 +4832,12 @@  discard block
 block discarded – undo
4832 4832
                 Display::display_error_message(get_lang('MustSelectPage'), false, true)
4833 4833
             );
4834 4834
             return;
4835
-        } elseif ($row['content']=='' && $row['title']=='' && $page=='index') {
4835
+        } elseif ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
4836 4836
 
4837 4837
             // Table structure for better export to pdf
4838 4838
             $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
4839 4839
             $default_table_for_content_End = '</td></tr></table>';
4840
-            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4840
+            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4841 4841
             $title = get_lang('DefaultTitle');
4842 4842
             $page_id = 0;
4843 4843
         } else {
@@ -4863,7 +4863,7 @@  discard block
 block discarded – undo
4863 4863
             // Check if is a wiki group
4864 4864
             if (!empty($groupId)) {
4865 4865
                 //Only teacher, platform admin and group members can edit a wiki group
4866
-                if (api_is_allowed_to_edit(false,true) ||
4866
+                if (api_is_allowed_to_edit(false, true) ||
4867 4867
                     api_is_platform_admin() ||
4868 4868
                     GroupManager :: is_user_in_group($userId, $groupId)
4869 4869
                 ) {
@@ -4876,7 +4876,7 @@  discard block
 block discarded – undo
4876 4876
                     );
4877 4877
                 }
4878 4878
             } else {
4879
-                $PassEdit=true;
4879
+                $PassEdit = true;
4880 4880
             }
4881 4881
 
4882 4882
             $icon_assignment = null;
@@ -4886,10 +4886,10 @@  discard block
 block discarded – undo
4886 4886
                     Display::return_message(get_lang('EditAssignmentWarning'))
4887 4887
                 );
4888 4888
 
4889
-                $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4889
+                $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4890 4890
             } elseif ($row['assignment'] == 2) {
4891
-                $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
4892
-                if (($userId == $row['user_id'])==false) {
4891
+                $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
4892
+                if (($userId == $row['user_id']) == false) {
4893 4893
                     if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4894 4894
                         $PassEdit = true;
4895 4895
                     } else {
@@ -4909,7 +4909,7 @@  discard block
 block discarded – undo
4909 4909
             if ($PassEdit) {
4910 4910
                 //show editor if edit is allowed <<<<<
4911 4911
                 if ($row['editlock'] == 1 &&
4912
-                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin()==false)
4912
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4913 4913
                 ) {
4914 4914
                     Display::addFlash(
4915 4915
                         Display::return_message(
@@ -4919,7 +4919,7 @@  discard block
 block discarded – undo
4919 4919
                 } else {
4920 4920
                     // Check tasks
4921 4921
 
4922
-                    if (!empty($row['startdate_assig']) &&  time() < api_strtotime($row['startdate_assig'])
4922
+                    if (!empty($row['startdate_assig']) && time() < api_strtotime($row['startdate_assig'])
4923 4923
                     ) {
4924 4924
                         $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig']);
4925 4925
 
@@ -4937,7 +4937,7 @@  discard block
 block discarded – undo
4937 4937
 
4938 4938
                     if (!empty($row['enddate_assig']) &&
4939 4939
                         time() > strtotime($row['enddate_assig']) &&
4940
-                        $row['delayedsubmit']==0
4940
+                        $row['delayedsubmit'] == 0
4941 4941
                     ) {
4942 4942
                         $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig']);
4943 4943
                         Display::addFlash(
@@ -4946,20 +4946,20 @@  discard block
 block discarded – undo
4946 4946
                                 'warning'
4947 4947
                             )
4948 4948
                         );
4949
-                        if (!api_is_allowed_to_edit(false,true)) {
4949
+                        if (!api_is_allowed_to_edit(false, true)) {
4950 4950
                             $this->redirectHome();
4951 4951
                         }
4952 4952
                     }
4953 4953
 
4954
-                    if (!empty($row['max_version']) && $row['version']>=$row['max_version']) {
4955
-                        $message=get_lang('HasReachedMaxiNumVersions');
4954
+                    if (!empty($row['max_version']) && $row['version'] >= $row['max_version']) {
4955
+                        $message = get_lang('HasReachedMaxiNumVersions');
4956 4956
                         Display::addFlash(
4957 4957
                             Display::return_message(
4958 4958
                                 $message,
4959 4959
                                 'warning'
4960 4960
                             )
4961 4961
                         );
4962
-                        if (!api_is_allowed_to_edit(false,true)) {
4962
+                        if (!api_is_allowed_to_edit(false, true)) {
4963 4963
                             $this->redirectHome();
4964 4964
                         }
4965 4965
                     }
@@ -4972,7 +4972,7 @@  discard block
 block discarded – undo
4972 4972
                                 'warning'
4973 4973
                             )
4974 4974
                         );
4975
-                        if (!api_is_allowed_to_edit(false,true)) {
4975
+                        if (!api_is_allowed_to_edit(false, true)) {
4976 4976
                             $this->redirectHome();
4977 4977
                         }
4978 4978
                     }
@@ -4980,7 +4980,7 @@  discard block
 block discarded – undo
4980 4980
                     if (!empty($row['task'])) {
4981 4981
                         //previous change 0 by text
4982 4982
                         if (!empty($row['startdate_assig'])) {
4983
-                            $message_task_startdate  =get_lang('No');
4983
+                            $message_task_startdate = get_lang('No');
4984 4984
                         } else {
4985 4985
                             $message_task_startdate = api_get_local_time($row['startdate_assig']);
4986 4986
                         }
@@ -4991,31 +4991,31 @@  discard block
 block discarded – undo
4991 4991
                             $message_task_enddate = api_get_local_time($row['enddate_assig']);
4992 4992
                         }
4993 4993
 
4994
-                        if ($row['delayedsubmit']==0) {
4995
-                            $message_task_delayedsubmit=get_lang('No');
4994
+                        if ($row['delayedsubmit'] == 0) {
4995
+                            $message_task_delayedsubmit = get_lang('No');
4996 4996
                         } else {
4997
-                            $message_task_delayedsubmit=get_lang('Yes');
4997
+                            $message_task_delayedsubmit = get_lang('Yes');
4998 4998
                         }
4999 4999
 
5000
-                        if ($row['max_version']==0) {
5001
-                            $message_task_max_version=get_lang('No');
5000
+                        if ($row['max_version'] == 0) {
5001
+                            $message_task_max_version = get_lang('No');
5002 5002
                         } else {
5003
-                            $message_task_max_version=$row['max_version'];
5003
+                            $message_task_max_version = $row['max_version'];
5004 5004
                         }
5005 5005
 
5006
-                        if ($row['max_text']==0) {
5007
-                            $message_task_max_text=get_lang('No');
5006
+                        if ($row['max_text'] == 0) {
5007
+                            $message_task_max_text = get_lang('No');
5008 5008
                         } else {
5009
-                            $message_task_max_text=$row['max_text'];
5009
+                            $message_task_max_text = $row['max_text'];
5010 5010
                         }
5011 5011
 
5012 5012
                         // Comp message
5013
-                        $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5014
-                        $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5015
-                        $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
5016
-                        $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5017
-                        $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5018
-                        $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
5013
+                        $message_task = '<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5014
+                        $message_task .= '<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5015
+                        $message_task .= '<p>'.get_lang('EndDate').': '.$message_task_enddate;
5016
+                        $message_task .= ' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5017
+                        $message_task .= '<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5018
+                        $message_task .= ' '.get_lang('NMaxWords').': '.$message_task_max_text;
5019 5019
                         // Display message
5020 5020
                         Display::addFlash(
5021 5021
                             Display::return_message(
@@ -5026,11 +5026,11 @@  discard block
 block discarded – undo
5026 5026
 
5027 5027
                     $feedback_message = '';
5028 5028
                     if ($row['progress'] == $row['fprogress1'] && !empty($row['fprogress1'])) {
5029
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5029
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5030 5030
                     } elseif ($row['progress'] == $row['fprogress2'] && !empty($row['fprogress2'])) {
5031
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5031
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5032 5032
                     } elseif ($row['progress'] == $row['fprogress3'] && !empty($row['fprogress3'])) {
5033
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5033
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5034 5034
                     }
5035 5035
 
5036 5036
                     if (!empty($feedback_message)) {
@@ -5055,15 +5055,15 @@  discard block
 block discarded – undo
5055 5055
                                 WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"';
5056 5056
                         Database::query($sql);
5057 5057
                     } elseif ($row['is_editing'] != $userId) {
5058
-                        $timestamp_edit=strtotime($row['time_edit']);
5058
+                        $timestamp_edit = strtotime($row['time_edit']);
5059 5059
                         $time_editing = time() - $timestamp_edit;
5060 5060
                         $max_edit_time = 1200; // 20 minutes
5061 5061
                         $rest_time = $max_edit_time - $time_editing;
5062 5062
 
5063 5063
                         $userinfo = api_get_user_info($row['is_editing']);
5064 5064
                         if ($userinfo !== false) {
5065
-                            $is_being_edited = get_lang('ThisPageisBeginEditedBy') . ' ' . UserManager::getUserProfileLink($userinfo) . '
5066
-                            ' . get_lang('ThisPageisBeginEditedTryLater') . ' ' . date("i", $rest_time) . ' ' . get_lang('MinMinutes') . '';
5065
+                            $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).'
5066
+                            ' . get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes').'';
5067 5067
                         }
5068 5068
 
5069 5069
                         Display::addFlash(
@@ -5080,7 +5080,7 @@  discard block
 block discarded – undo
5080 5080
                     // Form.
5081 5081
                     $url = api_get_self().'?action=edit&title='.urlencode($page).'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'&'.api_get_cidreq();
5082 5082
                     $form = new FormValidator('wiki', 'post', $url);
5083
-                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;',3).api_htmlentities($title));
5083
+                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;', 3).api_htmlentities($title));
5084 5084
                     self::setForm($form, $row);
5085 5085
                     $form->addElement('hidden', 'title');
5086 5086
                     $form->addElement('button', 'SaveWikiChange', get_lang('Save'));
@@ -5103,7 +5103,7 @@  discard block
 block discarded – undo
5103 5103
                             );
5104 5104
                         } elseif (!self::double_post($_POST['wpost_id'])) {
5105 5105
                             //double post
5106
-                        } elseif ($_POST['version']!='' && $_SESSION['_version'] !=0 && $_POST['version'] != $_SESSION['_version']) {
5106
+                        } elseif ($_POST['version'] != '' && $_SESSION['_version'] != 0 && $_POST['version'] != $_SESSION['_version']) {
5107 5107
                             //prevent concurrent users and double version
5108 5108
                             Display::addFlash(
5109 5109
                                 Display::return_message(
@@ -5165,7 +5165,7 @@  discard block
 block discarded – undo
5165 5165
         $KeyAssignment = null;
5166 5166
         $KeyTitle = null;
5167 5167
         $KeyUserId = null;
5168
-        while ($row=Database::fetch_array($result)) {
5168
+        while ($row = Database::fetch_array($result)) {
5169 5169
             $KeyVisibility = $row['visibility'];
5170 5170
             $KeyAssignment = $row['assignment'];
5171 5171
             $KeyTitle = $row['title'];
@@ -5174,7 +5174,7 @@  discard block
 block discarded – undo
5174 5174
         $icon_assignment = null;
5175 5175
         if ($KeyAssignment == 1) {
5176 5176
             $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
5177
-        } elseif($KeyAssignment == 2) {
5177
+        } elseif ($KeyAssignment == 2) {
5178 5178
             $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
5179 5179
         }
5180 5180
 
@@ -5182,10 +5182,10 @@  discard block
 block discarded – undo
5182 5182
 
5183 5183
         //if the page is hidden and is a job only sees its author and professor
5184 5184
         if ($KeyVisibility == 1 ||
5185
-            api_is_allowed_to_edit(false,true) ||
5185
+            api_is_allowed_to_edit(false, true) ||
5186 5186
             api_is_platform_admin() ||
5187 5187
             (
5188
-                $KeyAssignment==2 && $KeyVisibility==0 &&
5188
+                $KeyAssignment == 2 && $KeyVisibility == 0 &&
5189 5189
                 ($userId == $KeyUserId)
5190 5190
             )
5191 5191
         ) {
@@ -5215,7 +5215,7 @@  discard block
 block discarded – undo
5215 5215
                     get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
5216 5216
                 echo '<br/><br/>';
5217 5217
 
5218
-                $counter=0;
5218
+                $counter = 0;
5219 5219
                 $total_versions = Database::num_rows($result);
5220 5220
 
5221 5221
                 while ($row = Database::fetch_array($result)) {
@@ -5223,10 +5223,10 @@  discard block
 block discarded – undo
5223 5223
                     $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
5224 5224
 
5225 5225
                     echo '<li style="margin-bottom: 5px;">';
5226
-                    ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
5227
-                    ($counter==0) ? $newchecked=' checked': $newchecked='';
5228
-                    ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
5229
-                    ($counter==1) ? $oldchecked=' checked':$oldchecked='';
5226
+                    ($counter == 0) ? $oldstyle = 'style="visibility: hidden;"' : $oldstyle = '';
5227
+                    ($counter == 0) ? $newchecked = ' checked' : $newchecked = '';
5228
+                    ($counter == $total_versions - 1) ? $newstyle = 'style="visibility: hidden;"' : $newstyle = '';
5229
+                    ($counter == 1) ? $oldchecked = ' checked' : $oldchecked = '';
5230 5230
                     echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
5231 5231
                     echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
5232 5232
                     echo '<a href="'.api_get_self().'?action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&amp;view='.$row['id'].'">';
@@ -5246,8 +5246,8 @@  discard block
 block discarded – undo
5246 5246
                         $comment = api_substr($comment, 0, 100);
5247 5247
                         if ($comment !== false) {
5248 5248
                             $comment = api_htmlentities($comment);
5249
-                            echo get_lang('Comments').': ' . $comment;
5250
-                            if (api_strlen($row['comment'])>100) {
5249
+                            echo get_lang('Comments').': '.$comment;
5250
+                            if (api_strlen($row['comment']) > 100) {
5251 5251
                                 echo '... ';
5252 5252
                             }
5253 5253
                         }
@@ -5273,8 +5273,8 @@  discard block
 block discarded – undo
5273 5273
 
5274 5274
                 $sql_new = "SELECT * FROM $tbl_wiki
5275 5275
                             WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
5276
-                $result_new=Database::query($sql_new);
5277
-                $version_new=Database::fetch_array($result_new);
5276
+                $result_new = Database::query($sql_new);
5277
+                $version_new = Database::fetch_array($result_new);
5278 5278
                 $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
5279 5279
                 $oldContent = isset($version_old['content']) ? $version_old['content'] : null;
5280 5280
 
@@ -5301,9 +5301,9 @@  discard block
 block discarded – undo
5301 5301
 
5302 5302
 
5303 5303
                 if (isset($_POST['HistoryDifferences'])) {
5304
-                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words
5304
+                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line').'</table>'; // format_line mode is better for words
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>';
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
                     $renderer = new Text_Diff_Renderer_inline();
5323 5323
                     echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
5324 5324
                     echo '<br />';
5325
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5325
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5326 5326
                     echo '<table><tr>';
5327 5327
                     echo  '<td>';
5328 5328
                     echo '</td><td>';
@@ -5370,7 +5370,7 @@  discard block
 block discarded – undo
5370 5370
         echo '<td style="vertical-align:top">';
5371 5371
         echo '<ul>';
5372 5372
         // Submenu Statistics
5373
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5373
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5374 5374
             echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>';
5375 5375
         }
5376 5376
         echo '      </ul>';
@@ -5443,7 +5443,7 @@  discard block
 block discarded – undo
5443 5443
                 break;
5444 5444
             case 'deletewiki':
5445 5445
                 $title = '<div class="actions">'.get_lang('DeleteWiki').'</div>';
5446
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5446
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5447 5447
                     $message = get_lang('ConfirmDeleteWiki');
5448 5448
                     $message .= '<p>
5449 5449
                         <a href="index.php?'.api_get_cidreq().'">'.get_lang('No').'</a>
@@ -5474,14 +5474,14 @@  discard block
 block discarded – undo
5474 5474
                 self::getLinks($page);
5475 5475
                 break;
5476 5476
             case 'addnew':
5477
-                if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
5477
+                if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
5478 5478
                     api_not_allowed();
5479 5479
                 }
5480 5480
                 echo '<div class="actions">'.get_lang('AddNew').'</div>';
5481 5481
                 echo '<br/>';
5482 5482
                 //first, check if page index was created. chektitle=false
5483 5483
                 if (self::checktitle('index')) {
5484
-                    if (api_is_allowed_to_edit(false,true) ||
5484
+                    if (api_is_allowed_to_edit(false, true) ||
5485 5485
                         api_is_platform_admin() ||
5486 5486
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
5487 5487
                         api_is_allowed_in_course()
@@ -5490,10 +5490,10 @@  discard block
 block discarded – undo
5490 5490
                     } else {
5491 5491
                         self::setMessage(Display::display_normal_message(get_lang('WikiStandBy'), false, true));
5492 5492
                     }
5493
-                } elseif (self::check_addnewpagelock()==0 && (api_is_allowed_to_edit(false, true)==false || api_is_platform_admin()==false)) {
5493
+                } elseif (self::check_addnewpagelock() == 0 && (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)) {
5494 5494
                     self::setMessage(Display::display_error_message(get_lang('AddPagesLocked'), false, true));
5495 5495
                 } else {
5496
-                    if (api_is_allowed_to_edit(false,true) ||
5496
+                    if (api_is_allowed_to_edit(false, true) ||
5497 5497
                         api_is_platform_admin() ||
5498 5498
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
5499 5499
                         $_GET['group_id'] == 0
Please login to merge, or discard this patch.