Test Setup Failed
Push — master ( ebe8c6...ed4959 )
by Angel Fernando Quiroz
236:32 queued 180:26
created
main/inc/lib/AnnouncementEmail.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      *
18 18
      * @param int|array $course
19
-     * @param int|array $annoucement
19
+     * @param integer $announcement
20 20
      *
21 21
      * @return AnnouncementEmail
22 22
      */
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @param string $key
52 52
      *
53
-     * @return array
53
+     * @return string|null
54 54
      */
55 55
     public function course($key = '')
56 56
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@
 block discarded – undo
196 196
      *
197 197
      * @return array
198 198
      */
199
-    public function sender($key = '',  $userId = '')
199
+    public function sender($key = '', $userId = '')
200 200
     {
201 201
         $_user = api_get_user_info($userId);
202 202
 
Please login to merge, or discard this patch.
main/inc/lib/AnnouncementManager.php 3 patches
Doc Comments   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     }
19 19
 
20 20
     /**
21
-     * @return array
21
+     * @return string[]
22 22
      */
23 23
     public static function get_tags()
24 24
     {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param string    $course_code
41 41
      * @param int       $session_id
42 42
      *
43
-     * @return mixed
43
+     * @return string
44 44
      */
45 45
     public static function parse_content($userId, $content, $course_code, $session_id = 0)
46 46
     {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
      * @param array	    uploaded file $_FILES
350 350
      * @param string    Comment describing the attachment
351 351
      * @param bool  $sendToUsersInSession
352
-     * @return int      false on failure, ID of the announcement on success
352
+     * @return false|string      false on failure, ID of the announcement on success
353 353
      */
354 354
     public static function add_announcement(
355 355
         $emailTitle,
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
      * @param $to_users
461 461
      * @param array $file
462 462
      * @param string $file_comment
463
-     * @return bool|int
463
+     * @return false|string
464 464
      */
465 465
     public static function add_group_announcement(
466 466
         $emailTitle,
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 
700 700
     /**
701 701
      * @param int $insert_id
702
-     * @return bool
702
+     * @return false|null
703 703
      */
704 704
     public static function update_mail_sent($insert_id)
705 705
     {
@@ -719,6 +719,7 @@  discard block
 block discarded – undo
719 719
      * Gets all announcements from a user by course
720 720
      * @param	string course db
721 721
      * @param	int user id
722
+     * @param integer $user_id
722 723
      * @return	array html with the content and count of announcements or false otherwise
723 724
      */
724 725
     public static function get_all_annoucement_by_user_course($course_code, $user_id)
@@ -1184,6 +1185,7 @@  discard block
 block discarded – undo
1184 1185
      * has been sent to
1185 1186
      * @param    string  The tool (announcement, agenda, ...)
1186 1187
      * @param    int     ID of the element of the corresponding type
1188
+     * @param string $tool
1187 1189
      * @return   array   Array of users and groups to whom the element has been sent
1188 1190
      */
1189 1191
     public static function sent_to($tool, $id)
@@ -1308,6 +1310,8 @@  discard block
 block discarded – undo
1308 1310
      * @param int attach id
1309 1311
      * @param array uploaded file $_FILES
1310 1312
      * @param string file comment
1313
+     * @param integer $id_attach
1314
+     * @param string $file_comment
1311 1315
      * @return int
1312 1316
      */
1313 1317
     public static function edit_announcement_attachment_file($id_attach, $file, $file_comment)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1510,7 +1510,7 @@
 block discarded – undo
1510 1510
                             ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
1511 1511
                         ) ";
1512 1512
                     } else {
1513
-                       $cond_user_id = " AND (
1513
+                        $cond_user_id = " AND (
1514 1514
                             ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".api_get_group_id()."))
1515 1515
                         )";
1516 1516
                     }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
                             announcement.id = '$announcement_id' AND
217 217
                             toolitemproperties.tool='announcement' AND
218 218
                             (
219
-                                toolitemproperties.to_user_id='" . api_get_user_id() . "' OR
220
-                                toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list) . "') OR
219
+                                toolitemproperties.to_user_id='".api_get_user_id()."' OR
220
+                                toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list)."') OR
221 221
                                 toolitemproperties.to_group_id IS NULL
222 222
                             ) AND
223 223
                             toolitemproperties.visibility='1' AND
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
             $title = $result['title'];
247 247
             $content = $result['content'];
248 248
             $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">";
249
-            $html .= "<tr><td><h2>" . $title . "</h2></td></tr>";
249
+            $html .= "<tr><td><h2>".$title."</h2></td></tr>";
250 250
 
251 251
             if (api_is_allowed_to_edit(false, true) ||
252 252
                 (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
253 253
             ) {
254
-                $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $announcement_id . "\">" .
255
-                    Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
254
+                $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$announcement_id."\">".
255
+                    Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>";
256 256
                 if ($result['visibility'] == 1) {
257 257
                     $image_visibility = "visible";
258 258
                     $alt_visibility = get_lang('Hide');
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
                 }
263 263
                 global $stok;
264 264
 
265
-                $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . (!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '') . "&action=showhide&id=" . $announcement_id . "&sec_token=" . $stok . "\">" .
266
-                    Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
265
+                $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '')."&action=showhide&id=".$announcement_id."&sec_token=".$stok."\">".
266
+                    Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
267 267
 
268 268
                 if (api_is_allowed_to_edit(false, true)) {
269
-                    $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $announcement_id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" .
270
-                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) .
269
+                    $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$announcement_id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">".
270
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).
271 271
                         "</a>";
272 272
                 }
273 273
                 $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>";
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             $content = self::parse_content($result['to_user_id'], $content, api_get_course_id(), api_get_session_id());
277 277
 
278 278
             $html .= "<tr><td>$content</td></tr>";
279
-            $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG) . "</td></tr>";
279
+            $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG)."</td></tr>";
280 280
 
281 281
             // User or group icon
282 282
             $sent_to_icon = '';
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                 $sent_to_form = self::sent_to_form($sent_to);
289 289
                 $html .= Display::tag(
290 290
                     'td',
291
-                    get_lang('SentTo') . ' : ' . $sent_to_form,
291
+                    get_lang('SentTo').' : '.$sent_to_form,
292 292
                     array('class' => 'announcements_datum')
293 293
                 );
294 294
             }
@@ -298,15 +298,15 @@  discard block
 block discarded – undo
298 298
                 $html .= "<tr><td>";
299 299
                 $realname = $attachment_list['path'];
300 300
                 $user_filename = $attachment_list['filename'];
301
-                $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname;
301
+                $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname;
302 302
                 $html .= '<br/>';
303 303
                 $html .= Display::return_icon('attachment.gif', get_lang('Attachment'));
304
-                $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>';
305
-                $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>';
304
+                $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>';
305
+                $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
306 306
                 if (api_is_allowed_to_edit(false, true)) {
307 307
                     $html .= Display::url(
308 308
                         Display::return_icon('delete.png', get_lang('Delete'), '', 16),
309
-                        api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok
309
+                        api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok
310 310
                     );
311 311
                 }
312 312
                 $html .= '</td></tr>';
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         $order = 0;
335 335
         if (Database::num_rows($res_max)) {
336 336
             $row_max = Database::fetch_array($res_max);
337
-            $order = intval($row_max[0])+1;
337
+            $order = intval($row_max[0]) + 1;
338 338
         }
339 339
 
340 340
         return $order;
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
             $result = array();
755 755
             if ($num_rows > 0) {
756 756
                 while ($myrow = Database::fetch_array($rs)) {
757
-                    $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />';
758
-                    $content.= $myrow['content'];
757
+                    $content .= '<strong>'.$myrow['title'].'</strong><br /><br />';
758
+                    $content .= $myrow['content'];
759 759
                     $i++;
760 760
                 }
761 761
                 $result['content'] = $content;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
         echo "<table id=\"recipient_list\" >";
787 787
         echo '<tr>';
788 788
         echo '<td>';
789
-        echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>";
789
+        echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers')."</label>";
790 790
         echo "</td>";
791 791
         echo '</tr>';
792 792
         echo '<tr>';
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 
795 795
         // the form containing all the groups and all the users of the course
796 796
         echo '<td>';
797
-        echo "<strong>" . get_lang('Users') . "</strong><br />";
797
+        echo "<strong>".get_lang('Users')."</strong><br />";
798 798
 
799 799
         self::construct_not_selected_select_form($groupList, $userList, $to_already_selected);
800 800
         echo "</td>";
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         echo "<td>";
810 810
 
811 811
         // the form containing the selected groups and users
812
-        echo "<strong>" . get_lang('DestinationUsers') . "</strong><br />";
812
+        echo "<strong>".get_lang('DestinationUsers')."</strong><br />";
813 813
         self::construct_selected_select_form($groupList, $userList, $to_already_selected);
814 814
         echo "</td>";
815 815
         echo "</tr>";
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
         echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>";
828 828
         $group_users = GroupManager::getStudentsAndTutors($group_id);
829 829
         foreach ($group_users as $user) {
830
-            echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' .
831
-                api_get_person_name($user['firstname'], $user['lastname']) .
830
+            echo '<option value="'.$user['user_id'].'" title="'.sprintf(get_lang('LoginX'), $user['username']).'" >'.
831
+                api_get_person_name($user['firstname'], $user['lastname']).
832 832
                 '</option>';
833 833
         }
834 834
         echo '</select>';
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
         if (!empty($groupList)) {
867 867
             foreach ($groupList as $this_group) {
868 868
                 if (is_array($to_already_selected)) {
869
-                    if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) {
869
+                    if (!in_array("GROUP:".$this_group['id'], $to_already_selected)) {
870 870
                         // $to_already_selected is the array containing the groups (and users) that are already selected
871
-                        $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ;
872
-                        $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ;
873
-                        echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">",
874
-                        "G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label .
871
+                        $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser');
872
+                        $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled";
873
+                        echo "<option $user_disabled value=\"GROUP:".$this_group['id']."\">",
874
+                        "G: ", $this_group['name'], " - ".$this_group['userNb']." ".$user_label.
875 875
                             "</option>";
876 876
                     }
877 877
                 }
@@ -885,15 +885,15 @@  discard block
 block discarded – undo
885 885
         if (!empty($userList)) {
886 886
             foreach ($userList as $user) {
887 887
                 if (is_array($to_already_selected)) {
888
-                    if (!in_array("USER:" . $user['user_id'], $to_already_selected)) {
888
+                    if (!in_array("USER:".$user['user_id'], $to_already_selected)) {
889 889
                         // $to_already_selected is the array containing the users (and groups) that are already selected
890
-                        echo "<option value=\"USER:" . $user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $user['username']) . "'>",
890
+                        echo "<option value=\"USER:".$user['user_id']."\" title='".sprintf(get_lang('LoginX'), $user['username'])."'>",
891 891
                         "", api_get_person_name($user['firstname'], $user['lastname']),
892 892
                         "</option>";
893 893
 
894 894
                         if (isset($user['drh_list']) && !empty($user['drh_list'])) {
895 895
                             foreach ($user['drh_list'] as $drh) {
896
-                                echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'>&nbsp;&nbsp;&nbsp;&nbsp;",
896
+                                echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'>&nbsp;&nbsp;&nbsp;&nbsp;",
897 897
                                 "", api_get_person_name($drh['firstname'], $drh['lastname']),
898 898
                                 "</option>";
899 899
                             }
@@ -925,16 +925,16 @@  discard block
 block discarded – undo
925 925
             foreach ($to_already_selected as $groupuser) {
926 926
                 list($type, $id) = explode(":", $groupuser);
927 927
                 if ($type == "GROUP") {
928
-                    echo "<option value=\"" . $groupuser . "\">G: " . $ref_array_groups[$id]['name'] . "</option>";
928
+                    echo "<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>";
929 929
                 } else {
930 930
                     foreach ($ref_array_users as $key => $value) {
931 931
                         if ($value['user_id'] == $id) {
932
-                            echo "<option value=\"" . $groupuser . "\" title='" . sprintf(get_lang('LoginX'), $value['username']) . "'>" .
933
-                                api_get_person_name($value['firstname'], $value['lastname']) . "</option>";
932
+                            echo "<option value=\"".$groupuser."\" title='".sprintf(get_lang('LoginX'), $value['username'])."'>".
933
+                                api_get_person_name($value['firstname'], $value['lastname'])."</option>";
934 934
 
935 935
                             if (isset($value['drh_list']) && !empty($value['drh_list'])) {
936 936
                                 foreach ($value['drh_list'] as $drh) {
937
-                                    echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'>&nbsp;&nbsp;&nbsp;&nbsp;",
937
+                                    echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'>&nbsp;&nbsp;&nbsp;&nbsp;",
938 938
                                     "", api_get_person_name($drh['firstname'], $drh['lastname']),
939 939
                                     "</option>";
940 940
                                 }
@@ -950,17 +950,17 @@  discard block
 block discarded – undo
950 950
                 if (is_array($ref_array_groups)) {
951 951
                     foreach ($ref_array_groups as $this_group) {
952 952
                         //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
953
-                        if (!is_array($to_already_selected) || !in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected
954
-                            echo "<option value=\"GROUP:" . $this_group['id'] . "\">",
955
-                            "G: ", $this_group['name'], " &ndash; " . $this_group['userNb'] . " " . get_lang('Users') .
953
+                        if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected
954
+                            echo "<option value=\"GROUP:".$this_group['id']."\">",
955
+                            "G: ", $this_group['name'], " &ndash; ".$this_group['userNb']." ".get_lang('Users').
956 956
                                 "</option>";
957 957
                         }
958 958
                     }
959 959
                 }
960 960
                 // adding the individual users to the select form
961 961
                 foreach ($ref_array_users as $this_user) {
962
-                    if (!is_array($to_already_selected) || !in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected
963
-                        echo "<option value=\"USER:", $this_user['user_id'], "\"  title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>",
962
+                    if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected
963
+                        echo "<option value=\"USER:", $this_user['user_id'], "\"  title='".sprintf(get_lang('LoginX'), $this_user['username'])."'>",
964 964
                         "", api_get_person_name($this_user['firstname'], $this_user['lastname']),
965 965
                         "</option>";
966 966
                     }
@@ -1073,14 +1073,14 @@  discard block
 block discarded – undo
1073 1073
             switch ($to_group) {
1074 1074
                 // it was send to one specific user
1075 1075
                 case null:
1076
-                    $to[] = "USER:" . $row['to_user_id'];
1076
+                    $to[] = "USER:".$row['to_user_id'];
1077 1077
                     break;
1078 1078
                 // it was sent to everyone
1079 1079
                 case 0:
1080 1080
                     return "everyone";
1081 1081
                     break;
1082 1082
                 default:
1083
-                    $to[] = "GROUP:" . $row['to_group_id'];
1083
+                    $to[] = "GROUP:".$row['to_group_id'];
1084 1084
             }
1085 1085
         }
1086 1086
         return $to;
@@ -1161,10 +1161,10 @@  discard block
 block discarded – undo
1161 1161
                 $sent_to_array['groups'][0] !== 0
1162 1162
             ) {
1163 1163
                 $group_id = $sent_to_array['groups'][0];
1164
-                $output[] = "&nbsp;" . $group_names[$group_id]['name'];
1164
+                $output[] = "&nbsp;".$group_names[$group_id]['name'];
1165 1165
             }
1166 1166
             if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) {
1167
-                $output[] = "&nbsp;" . get_lang('Everybody');
1167
+                $output[] = "&nbsp;".get_lang('Everybody');
1168 1168
             }
1169 1169
         }
1170 1170
 
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 
1200 1200
         $sql = "SELECT to_group_id, to_user_id
1201 1201
                 FROM $tbl_item_property
1202
-                WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id;
1202
+                WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id;
1203 1203
         $result = Database::query($sql);
1204 1204
 
1205 1205
         while ($row = Database::fetch_array($result)) {
@@ -1238,8 +1238,8 @@  discard block
 block discarded – undo
1238 1238
         $announcement_id = intval($announcement_id);
1239 1239
         $course_id = api_get_course_int_id();
1240 1240
         $row = array();
1241
-        $sql = 'SELECT id, path, filename, comment FROM ' . $tbl_announcement_attachment . '
1242
-				WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcement_id . '';
1241
+        $sql = 'SELECT id, path, filename, comment FROM '.$tbl_announcement_attachment.'
1242
+				WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcement_id.'';
1243 1243
         $result = Database::query($sql);
1244 1244
         if (Database::num_rows($result) != 0) {
1245 1245
             $row = Database::fetch_array($result, 'ASSOC');
@@ -1264,9 +1264,9 @@  discard block
 block discarded – undo
1264 1264
 
1265 1265
         if (is_array($file) && $file['error'] == 0) {
1266 1266
             // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
1267
-            $courseDir = $_course['path'] . '/upload/announcements';
1267
+            $courseDir = $_course['path'].'/upload/announcements';
1268 1268
             $sys_course_path = api_get_path(SYS_COURSE_PATH);
1269
-            $updir = $sys_course_path . $courseDir;
1269
+            $updir = $sys_course_path.$courseDir;
1270 1270
 
1271 1271
             // Try to add an extension to the file if it hasn't one
1272 1272
             $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']);
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
                 Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
1279 1279
             } else {
1280 1280
                 $new_file_name = uniqid('');
1281
-                $new_path = $updir . '/' . $new_file_name;
1281
+                $new_path = $updir.'/'.$new_file_name;
1282 1282
                 move_uploaded_file($file['tmp_name'], $new_path);
1283 1283
 
1284 1284
                 $params = [
@@ -1319,9 +1319,9 @@  discard block
 block discarded – undo
1319 1319
 
1320 1320
         if (is_array($file) && $file['error'] == 0) {
1321 1321
             // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
1322
-            $courseDir = $_course['path'] . '/upload/announcements';
1322
+            $courseDir = $_course['path'].'/upload/announcements';
1323 1323
             $sys_course_path = api_get_path(SYS_COURSE_PATH);
1324
-            $updir = $sys_course_path . $courseDir;
1324
+            $updir = $sys_course_path.$courseDir;
1325 1325
 
1326 1326
             // Try to add an extension to the file if it hasn't one
1327 1327
             $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']);
@@ -1333,13 +1333,13 @@  discard block
 block discarded – undo
1333 1333
                 Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
1334 1334
             } else {
1335 1335
                 $new_file_name = uniqid('');
1336
-                $new_path = $updir . '/' . $new_file_name;
1336
+                $new_path = $updir.'/'.$new_file_name;
1337 1337
                 @move_uploaded_file($file['tmp_name'], $new_path);
1338 1338
                 $safe_file_comment = Database::escape_string($file_comment);
1339 1339
                 $safe_file_name = Database::escape_string($file_name);
1340 1340
                 $safe_new_file_name = Database::escape_string($new_file_name);
1341 1341
                 $id_attach = intval($id_attach);
1342
-                $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='" . intval($file['size']) . "'
1342
+                $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."'
1343 1343
 					 	WHERE c_id = $course_id AND id = '$id_attach'";
1344 1344
                 $result = Database::query($sql);
1345 1345
                 if ($result === false) {
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 
1442 1442
             //if (!empty($user_id)) {
1443 1443
             if (0) {
1444
-                if (is_array($group_memberships) && count($group_memberships) > 0 ) {
1444
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
1445 1445
                     $sql = "SELECT $select
1446 1446
                             FROM $tbl_announcement announcement, $tbl_item_property ip
1447 1447
                             WHERE
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
             }
1525 1525
         } else {
1526 1526
             // STUDENT
1527
-            if (is_array($group_memberships) && count($group_memberships)>0) {
1527
+            if (is_array($group_memberships) && count($group_memberships) > 0) {
1528 1528
                 if ($allowUserEditSetting && !api_is_anonymous()) {
1529 1529
                     if (api_get_group_id() == 0) {
1530 1530
                         // No group
@@ -1651,8 +1651,8 @@  discard block
 block discarded – undo
1651 1651
                 $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
1652 1652
 
1653 1653
                 $attachment_icon = '';
1654
-                if (count($attachment_list)>0) {
1655
-                    $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));
1654
+                if (count($attachment_list) > 0) {
1655
+                    $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment'));
1656 1656
                 }
1657 1657
 
1658 1658
                 /* TITLE */
@@ -1671,16 +1671,16 @@  discard block
 block discarded – undo
1671 1671
                     || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
1672 1672
                 ) {
1673 1673
                     $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">".
1674
-                        Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>";
1675
-                    if ($myrow['visibility']==1) {
1676
-                        $image_visibility="visible";
1677
-                        $alt_visibility=get_lang('Hide');
1674
+                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>";
1675
+                    if ($myrow['visibility'] == 1) {
1676
+                        $image_visibility = "visible";
1677
+                        $alt_visibility = get_lang('Hide');
1678 1678
                     } else {
1679
-                        $image_visibility="invisible";
1680
-                        $alt_visibility=get_lang('Visible');
1679
+                        $image_visibility = "invisible";
1680
+                        $alt_visibility = get_lang('Visible');
1681 1681
                     }
1682
-                    $modify_icons .=  "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
1683
-                        Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>";
1682
+                    $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
1683
+                        Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
1684 1684
 
1685 1685
                     // DISPLAY MOVE UP COMMAND only if it is not the top announcement
1686 1686
                     if ($iterator != 1) {
@@ -1695,12 +1695,12 @@  discard block
 block discarded – undo
1695 1695
                     } else {
1696 1696
                         $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
1697 1697
                     }
1698
-                    if (api_is_allowed_to_edit(false,true)) {
1699
-                        $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">".
1700
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).
1698
+                    if (api_is_allowed_to_edit(false, true)) {
1699
+                        $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">".
1700
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).
1701 1701
                             "</a>";
1702 1702
                     }
1703
-                    $iterator ++;
1703
+                    $iterator++;
1704 1704
                 } else {
1705 1705
                     $modify_icons = Display::url(
1706 1706
                         Display::return_icon('default.png'),
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
     public static function getNumberAnnouncements()
1731 1731
     {
1732 1732
         // Maximum title messages to display
1733
-        $maximum 	= '12';
1733
+        $maximum = '12';
1734 1734
         // Database Table Definitions
1735 1735
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
1736 1736
         $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         $userId = api_get_user_id();
1742 1742
         $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id');
1743 1743
 
1744
-        if (api_is_allowed_to_edit(false,true))  {
1744
+        if (api_is_allowed_to_edit(false, true)) {
1745 1745
             // check teacher status
1746 1746
             if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
1747 1747
 
@@ -1804,7 +1804,7 @@  discard block
 block discarded – undo
1804 1804
                 }
1805 1805
 
1806 1806
                 // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
1807
-                if (is_array($group_memberships) && count($group_memberships)>0) {
1807
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
1808 1808
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1809 1809
                     FROM $tbl_announcement announcement, $tbl_item_property ip
1810 1810
                     WHERE
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
                         }
1855 1855
 
1856 1856
                         // the user is not identiefied => show only the general announcements
1857
-                        $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1857
+                        $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1858 1858
                                 FROM $tbl_announcement announcement, $tbl_item_property ip
1859 1859
                                 WHERE
1860 1860
                                     announcement.c_id = $course_id AND
Please login to merge, or discard this patch.
main/inc/lib/app_view.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -18,6 +18,7 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * Constructor, init tool path for rendering
20 20
      * @param string  tool name (optional)
21
+     * @param string $template_path
21 22
      */
22 23
     public function __construct($toolname = '', $template_path=null)
23 24
     {
@@ -50,6 +51,7 @@  discard block
 block discarded – undo
50 51
     /**
51 52
      * Set layout view sent from a controller
52 53
      * @param string layout view
54
+     * @param string $layout
53 55
      */
54 56
     public function set_layout( $layout )
55 57
     {
@@ -59,6 +61,7 @@  discard block
 block discarded – undo
59 61
     /**
60 62
      * Set template view sent from a controller
61 63
      * @param string template view
64
+     * @param string $template
62 65
      */
63 66
     public function set_template($template)
64 67
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * Constructor, init tool path for rendering
20 20
      * @param string  tool name (optional)
21 21
      */
22
-    public function __construct($toolname = '', $template_path=null)
22
+    public function __construct($toolname = '', $template_path = null)
23 23
     {
24 24
         if (!empty($toolname)) {
25 25
             if (isset($template_path)) {
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             if (is_dir($path)) {
31 31
                 $this->tool_path = $path;
32 32
             } else {
33
-                throw new ViewException('View::__construct() $path directory does not exist ' . $path);
33
+                throw new ViewException('View::__construct() $path directory does not exist '.$path);
34 34
             }
35 35
         }
36 36
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function set_data($data)
43 43
     {
44 44
         if (!is_array($data)) {
45
-            throw new ViewException('View::set_data() $data must to be an array, you have sent a' . gettype( $data ));
45
+            throw new ViewException('View::set_data() $data must to be an array, you have sent a'.gettype($data));
46 46
         }
47 47
         $this->data = $data;
48 48
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * Set layout view sent from a controller
52 52
      * @param string layout view
53 53
      */
54
-    public function set_layout( $layout )
54
+    public function set_layout($layout)
55 55
     {
56 56
         $this->layout = $layout;
57 57
     }
Please login to merge, or discard this patch.
main/inc/lib/blog.lib.php 4 patches
Doc Comments   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -96,9 +96,7 @@  discard block
 block discarded – undo
96 96
 	/**
97 97
 	 * Creates a new blog in the given course
98 98
 	 * @author Toon Keppens
99
-	 * @param Integer $course_id Id
100 99
 	 * @param String $title
101
-	 * @param Text $description
102 100
 	 */
103 101
 	public static function create_blog($title, $subtitle)
104 102
 	{
@@ -186,9 +184,7 @@  discard block
 block discarded – undo
186 184
 	/**
187 185
 	 * Update title and subtitle of a blog in the given course
188 186
 	 * @author Toon Keppens
189
-	 * @param Integer $course_id Id
190 187
 	 * @param String $title
191
-	 * @param Text $description
192 188
 	 */
193 189
 	public static function edit_blog($blog_id, $title, $subtitle)
194 190
 	{
@@ -714,7 +710,6 @@  discard block
 block discarded – undo
714 710
 	/**
715 711
 	 * Deletes an assigned task from a blog
716 712
 	 * @param Integer $blog_id
717
-	 * @param Integer $assignment_id
718 713
 	 */
719 714
 	public static function delete_assigned_task($blog_id, $task_id, $user_id)
720 715
 	{
@@ -1126,9 +1121,7 @@  discard block
 block discarded – undo
1126 1121
 	 *
1127 1122
 	 * @param String $type
1128 1123
 	 * @param Integer $blog_id
1129
-	 * @param Integer $item_id
1130
-	 *
1131
-	 *@return String
1124
+	 * @param integer $post_id
1132 1125
 	 */
1133 1126
 	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1134 1127
 	{
@@ -2113,7 +2106,7 @@  discard block
 block discarded – undo
2113 2106
 	 *
2114 2107
 	 * @param Integer $blog_id
2115 2108
 	 *
2116
-	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2109
+	 * @return false|null Form with sortable table with users to unsubcribe from a blog.
2117 2110
 	 */
2118 2111
 	public static function display_form_user_unsubscribe ($blog_id)
2119 2112
 	{
@@ -2234,6 +2227,7 @@  discard block
 block discarded – undo
2234 2227
 	 * @author Toon Keppens
2235 2228
 	 *
2236 2229
 	 * @param Integer $blog_id
2230
+	 * @param integer $post_id
2237 2231
 	 */
2238 2232
 	public static function display_new_comment_form($blog_id, $post_id, $title)
2239 2233
 	{
@@ -2282,10 +2276,8 @@  discard block
 block discarded – undo
2282 2276
 	 * @author Patrick Cool
2283 2277
 	 * @author Toon Keppens
2284 2278
 	 *
2285
-	 * @param Array $blogitems an array containing all the blog items for the given month
2286 2279
 	 * @param Integer $month: the integer value of the month we are viewing
2287 2280
 	 * @param Integer $year: the 4-digit year indication e.g. 2005
2288
-	 * @param String $monthName: the language variable for the mont name
2289 2281
 	 *
2290 2282
 	 * @return html code
2291 2283
 	*/
@@ -2579,6 +2571,7 @@  discard block
 block discarded – undo
2579 2571
  * @param the blog's id
2580 2572
  * @param the post's id
2581 2573
  * @param the comment's id
2574
+ * @param integer $blog_id
2582 2575
  * @return array with the post info according the parameters
2583 2576
  * @author Julio Montoya Dokeos
2584 2577
  * @version avril 2008, dokeos 1.8.5
@@ -2620,6 +2613,9 @@  discard block
 block discarded – undo
2620 2613
  * @param the blog's id
2621 2614
  * @param the post's id
2622 2615
  * @param the comment's id
2616
+ * @param integer $blog_id
2617
+ * @param integer $post_id
2618
+ * @param integer $comment_id
2623 2619
  * @author Julio Montoya Dokeos
2624 2620
  * @version avril 2008, dokeos 1.8.5
2625 2621
  */
Please login to merge, or discard this patch.
Indentation   +1977 added lines, -1978 removed lines patch added patch discarded remove patch
@@ -6,115 +6,114 @@  discard block
 block discarded – undo
6 6
  *
7 7
  * Contains several functions dealing with displaying,
8 8
  * editing,... of a blog
9
-
10 9
  * @package chamilo.blogs
11 10
  * @author Toon Keppens <[email protected]>
12 11
  * @author Julio Montoya - Cleaning code
13 12
  */
14 13
 class Blog
15 14
 {
16
-	/**
17
-	 * Get the title of a blog
18
-	 * @author Toon Keppens
19
-	 *
20
-	 * @param int $blog_id
21
-	 *
22
-	 * @return String Blog Title
23
-	 */
24
-	public static function get_blog_title ($blog_id)
25
-	{
26
-	    $course_id = api_get_course_int_id();
27
-
28
-		if (is_numeric($blog_id)) {
29
-			// init
30
-			$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
31
-
32
-			$sql = "SELECT blog_name
15
+    /**
16
+     * Get the title of a blog
17
+     * @author Toon Keppens
18
+     *
19
+     * @param int $blog_id
20
+     *
21
+     * @return String Blog Title
22
+     */
23
+    public static function get_blog_title ($blog_id)
24
+    {
25
+        $course_id = api_get_course_int_id();
26
+
27
+        if (is_numeric($blog_id)) {
28
+            // init
29
+            $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
30
+
31
+            $sql = "SELECT blog_name
33 32
 					FROM " . $tbl_blogs . "
34 33
 					WHERE c_id = $course_id AND blog_id = " . intval($blog_id);
35 34
 
36
-			$result = Database::query($sql);
37
-			$blog = Database::fetch_array($result);
38
-			return stripslashes($blog['blog_name']);
39
-		}
40
-	}
41
-
42
-
43
-	/**
44
-	 * Get the description of a blog
45
-	 * @author Toon Keppens
46
-	 *
47
-	 * @param Integer $blog_id
48
-	 *
49
-	 * @return String Blog description
50
-	 */
51
-	public static function get_blog_subtitle($blog_id)
52
-	{
53
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
54
-	  	$course_id = api_get_course_int_id();
55
-		$sql = "SELECT blog_subtitle FROM $tbl_blogs
35
+            $result = Database::query($sql);
36
+            $blog = Database::fetch_array($result);
37
+            return stripslashes($blog['blog_name']);
38
+        }
39
+    }
40
+
41
+
42
+    /**
43
+     * Get the description of a blog
44
+     * @author Toon Keppens
45
+     *
46
+     * @param Integer $blog_id
47
+     *
48
+     * @return String Blog description
49
+     */
50
+    public static function get_blog_subtitle($blog_id)
51
+    {
52
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
53
+            $course_id = api_get_course_int_id();
54
+        $sql = "SELECT blog_subtitle FROM $tbl_blogs
56 55
 				WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'";
57
-		$result = Database::query($sql);
58
-		$blog = Database::fetch_array($result);
59
-
60
-		return stripslashes($blog['blog_subtitle']);
61
-	}
62
-
63
-	/**
64
-	 * Get the users of a blog
65
-	 * @author Toon Keppens
66
-	 *
67
-	 * @param Integer $blog_id
68
-	 *
69
-	 * @return Array Returns an array with [userid]=>[username]
70
-	 */
71
-	public static function get_blog_users($blog_id)
72
-	{
73
-		// Database table definitions
74
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
75
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
76
-
77
-		$course_id = api_get_course_int_id();
78
-
79
-		// Get blog members
80
-		$sql = "SELECT user.user_id, user.firstname, user.lastname
56
+        $result = Database::query($sql);
57
+        $blog = Database::fetch_array($result);
58
+
59
+        return stripslashes($blog['blog_subtitle']);
60
+    }
61
+
62
+    /**
63
+     * Get the users of a blog
64
+     * @author Toon Keppens
65
+     *
66
+     * @param Integer $blog_id
67
+     *
68
+     * @return Array Returns an array with [userid]=>[username]
69
+     */
70
+    public static function get_blog_users($blog_id)
71
+    {
72
+        // Database table definitions
73
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
74
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
75
+
76
+        $course_id = api_get_course_int_id();
77
+
78
+        // Get blog members
79
+        $sql = "SELECT user.user_id, user.firstname, user.lastname
81 80
 				FROM " . $tbl_blogs_rel_user . " blogs_rel_user
82 81
 				INNER JOIN " . $tbl_users . " user
83 82
 				ON blogs_rel_user.user_id = user.user_id
84 83
 				WHERE
85 84
 				    blogs_rel_user.c_id = $course_id AND
86 85
 					blogs_rel_user.blog_id = '" . (int)$blog_id."'";
87
-		$result = Database::query($sql);
88
-		$blog_members = array ();
89
-		while($user = Database::fetch_array($result)) {
90
-			$blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
91
-		}
92
-
93
-		return $blog_members;
94
-	}
95
-
96
-	/**
97
-	 * Creates a new blog in the given course
98
-	 * @author Toon Keppens
99
-	 * @param Integer $course_id Id
100
-	 * @param String $title
101
-	 * @param Text $description
102
-	 */
103
-	public static function create_blog($title, $subtitle)
104
-	{
105
-		$_user = api_get_user_info();
86
+        $result = Database::query($sql);
87
+        $blog_members = array ();
88
+        while($user = Database::fetch_array($result)) {
89
+            $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
90
+        }
91
+
92
+        return $blog_members;
93
+    }
94
+
95
+    /**
96
+     * Creates a new blog in the given course
97
+     * @author Toon Keppens
98
+     * @param Integer $course_id Id
99
+     * @param String $title
100
+     * @param Text $description
101
+     */
102
+    public static function create_blog($title, $subtitle)
103
+    {
104
+        $_user = api_get_user_info();
106 105
         $course_id = api_get_course_int_id();
107 106
 
108
-		$current_date=date('Y-m-d H:i:s',time());
109
-		$session_id = api_get_session_id();
110
-		// Tabel definitions
107
+        $current_date=date('Y-m-d H:i:s',time());
108
+        $session_id = api_get_session_id();
109
+        // Tabel definitions
111 110
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
112 111
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
113 112
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
114 113
         $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
115 114
 
116
-		//verified if exist blog
117
-		$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
115
+        //verified if exist blog
116
+        $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
118 117
 			  	WHERE
119 118
 			  	    c_id = '.$course_id.' AND
120 119
 			  	    blog_name="'.Database::escape_string($title).'" AND
@@ -123,9 +122,9 @@  discard block
 block discarded – undo
123 122
         $info_count = Database::result($res, 0, 0);
124 123
 
125 124
         if ($info_count == 0) {
126
-			// Create the blog
125
+            // Create the blog
127 126
             $params = [
128
-				'blog_id' => 0,
127
+                'blog_id' => 0,
129 128
                 'c_id' => $course_id,
130 129
                 'blog_name' => $title,
131 130
                 'blog_subtitle' =>  $subtitle,
@@ -133,14 +132,14 @@  discard block
 block discarded – undo
133 132
                 'visibility' => 1 ,
134 133
                 'session_id' => $session_id,
135 134
             ];
136
-			$this_blog_id = Database::insert($tbl_blogs, $params);
135
+            $this_blog_id = Database::insert($tbl_blogs, $params);
137 136
 
138
-			if ($this_blog_id > 0) {
137
+            if ($this_blog_id > 0) {
139 138
 
140 139
                 $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id";
141 140
                 Database::query($sql);
142 141
 
143
-				// insert into item_property
142
+                // insert into item_property
144 143
                 api_item_property_update(
145 144
                     api_get_course_info(),
146 145
                     TOOL_BLOGS,
@@ -148,12 +147,12 @@  discard block
 block discarded – undo
148 147
                     'BlogAdded',
149 148
                     api_get_user_id()
150 149
                 );
151
-			}
150
+            }
152 151
 
153
-			// Make first post. :)
152
+            // Make first post. :)
154 153
 
155 154
             $params = [
156
-				'post_id' => 0,
155
+                'post_id' => 0,
157 156
                 'c_id' => $course_id,
158 157
                 'title' => get_lang("Welcome"),
159 158
                 'full_text' => get_lang('FirstPostText'),
@@ -167,10 +166,10 @@  discard block
 block discarded – undo
167 166
                 Database::query($sql);
168 167
             }
169 168
 
170
-			// Put it on course homepage
171
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
169
+            // Put it on course homepage
170
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
172 171
 					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
173
-			Database::query($sql);
172
+            Database::query($sql);
174 173
 
175 174
             $toolId = Database::insert_id();
176 175
             if ($toolId) {
@@ -178,37 +177,37 @@  discard block
 block discarded – undo
178 177
                 Database::query($sql);
179 178
             }
180 179
 
181
-			// Subscribe the teacher to this blog
182
-			Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
183
-		}
184
-	}
185
-
186
-	/**
187
-	 * Update title and subtitle of a blog in the given course
188
-	 * @author Toon Keppens
189
-	 * @param Integer $course_id Id
190
-	 * @param String $title
191
-	 * @param Text $description
192
-	 */
193
-	public static function edit_blog($blog_id, $title, $subtitle)
194
-	{
195
-		// Table definitions
196
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
197
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
180
+            // Subscribe the teacher to this blog
181
+            Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
182
+        }
183
+    }
184
+
185
+    /**
186
+     * Update title and subtitle of a blog in the given course
187
+     * @author Toon Keppens
188
+     * @param Integer $course_id Id
189
+     * @param String $title
190
+     * @param Text $description
191
+     */
192
+    public static function edit_blog($blog_id, $title, $subtitle)
193
+    {
194
+        // Table definitions
195
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
196
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
198 197
 
199 198
         $course_id = api_get_course_int_id();
200 199
 
201
-		// Update the blog
202
-		$sql = "UPDATE $tbl_blogs SET
200
+        // Update the blog
201
+        $sql = "UPDATE $tbl_blogs SET
203 202
 		        blog_name = '".Database::escape_string($title)."',
204 203
 		        blog_subtitle = '".Database::escape_string($subtitle)."'
205 204
 		        WHERE
206 205
 		            c_id = $course_id AND
207 206
 		            blog_id ='".Database::escape_string((int)$blog_id)."'
208 207
                 LIMIT 1";
209
-		Database::query($sql);
208
+        Database::query($sql);
210 209
 
211
-		//update item_property (update)
210
+        //update item_property (update)
212 211
         api_item_property_update(
213 212
             api_get_course_info(),
214 213
             TOOL_BLOGS,
@@ -217,60 +216,60 @@  discard block
 block discarded – undo
217 216
             api_get_user_id()
218 217
         );
219 218
 
220
-		// Update course homepage link
221
-		$sql = "UPDATE $tbl_tool SET
219
+        // Update course homepage link
220
+        $sql = "UPDATE $tbl_tool SET
222 221
 		        name = '".Database::escape_string($title)."'
223 222
 		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
224
-		Database::query($sql);
225
-	}
226
-
227
-	/**
228
-	 * Deletes a blog and it's posts from the course database
229
-	 * @author Toon Keppens
230
-	 * @param Integer $blog_id
231
-	 */
232
-	public static function delete_blog($blog_id)
233
-	{
234
-		// Init
223
+        Database::query($sql);
224
+    }
225
+
226
+    /**
227
+     * Deletes a blog and it's posts from the course database
228
+     * @author Toon Keppens
229
+     * @param Integer $blog_id
230
+     */
231
+    public static function delete_blog($blog_id)
232
+    {
233
+        // Init
235 234
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
236 235
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
237 236
         $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS);
238 237
         $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
239 238
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
240 239
         $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
241
-		$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
240
+        $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
242 241
 
243 242
         $course_id = api_get_course_int_id();
244 243
         $blog_id = intval($blog_id);
245 244
 
246
-		// Delete posts from DB and the attachments
247
-		delete_all_blog_attachment($blog_id);
245
+        // Delete posts from DB and the attachments
246
+        delete_all_blog_attachment($blog_id);
248 247
 
249
-		//Delete comments
250
-		$sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
251
-   		Database::query($sql);
248
+        //Delete comments
249
+        $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
250
+            Database::query($sql);
252 251
 
253
-		// Delete posts
254
-   		$sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
255
-   		Database::query($sql);
252
+        // Delete posts
253
+            $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
254
+            Database::query($sql);
256 255
 
257
-		// Delete tasks
258
-		$sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
259
-		Database::query($sql);
256
+        // Delete tasks
257
+        $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
258
+        Database::query($sql);
260 259
 
261
-		// Delete ratings
262
-		$sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
263
-		Database::query($sql);
260
+        // Delete ratings
261
+        $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
262
+        Database::query($sql);
264 263
 
265
-		// Delete blog
266
-		$sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
267
-		Database::query($sql);
264
+        // Delete blog
265
+        $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
266
+        Database::query($sql);
268 267
 
269
-		// Delete from course homepage
270
-		$sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
271
-		Database::query($sql);
268
+        // Delete from course homepage
269
+        $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
270
+        Database::query($sql);
272 271
 
273
-		//update item_property (delete)
272
+        //update item_property (delete)
274 273
         api_item_property_update(
275 274
             api_get_course_info(),
276 275
             TOOL_BLOGS,
@@ -278,152 +277,152 @@  discard block
 block discarded – undo
278 277
             'delete',
279 278
             api_get_user_id()
280 279
         );
281
-	}
282
-
283
-	/**
284
-	 * Creates a new post in a given blog
285
-	 * @author Toon Keppens
286
-	 * @param String $title
287
-	 * @param String $full_text
288
-	 * @param Integer $blog_id
289
-	 */
290
-	public static function create_post($title, $full_text, $file_comment, $blog_id)
291
-	{
292
-		$_user = api_get_user_info();
293
-		$_course = api_get_course_info();
294
-		$course_id = $_course['real_id'];
295
-
296
-		$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
297
-		$upload_ok=true;
298
-		$has_attachment=false;
299
-		$current_date = api_get_utc_datetime();
300
-
301
-		if (!empty($_FILES['user_upload']['name'])) {
302
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
303
-			$has_attachment=true;
304
-		}
305
-
306
-		if ($upload_ok) {
307
-			// Table Definitions
308
-			$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
309
-
310
-			// Create the post
311
-			$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
280
+    }
281
+
282
+    /**
283
+     * Creates a new post in a given blog
284
+     * @author Toon Keppens
285
+     * @param String $title
286
+     * @param String $full_text
287
+     * @param Integer $blog_id
288
+     */
289
+    public static function create_post($title, $full_text, $file_comment, $blog_id)
290
+    {
291
+        $_user = api_get_user_info();
292
+        $_course = api_get_course_info();
293
+        $course_id = $_course['real_id'];
294
+
295
+        $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
296
+        $upload_ok=true;
297
+        $has_attachment=false;
298
+        $current_date = api_get_utc_datetime();
299
+
300
+        if (!empty($_FILES['user_upload']['name'])) {
301
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
302
+            $has_attachment=true;
303
+        }
304
+
305
+        if ($upload_ok) {
306
+            // Table Definitions
307
+            $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
308
+
309
+            // Create the post
310
+            $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
312 311
 					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
313 312
 
314
-			Database::query($sql);
315
-			$last_post_id = Database::insert_id();
313
+            Database::query($sql);
314
+            $last_post_id = Database::insert_id();
316 315
 
317 316
             if ($last_post_id) {
318 317
                 $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id";
319 318
                 Database::query($sql);
320 319
             }
321 320
 
322
-			if ($has_attachment) {
323
-				$courseDir   = $_course['path'].'/upload/blog';
324
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
325
-				$updir = $sys_course_path.$courseDir;
326
-
327
-				// Try to add an extension to the file if it hasn't one
328
-				$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
329
-
330
-				// user's file name
331
-				$file_name = $_FILES['user_upload']['name'];
332
-
333
-				if (!filter_extension($new_file_name)) {
334
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
335
-				} else {
336
-					$new_file_name = uniqid('');
337
-					$new_path = $updir.'/'.$new_file_name;
338
-					$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
339
-					$comment = Database::escape_string($file_comment);
340
-
341
-					// Storing the attachments if any
342
-					if ($result) {
343
-						$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
344
-							   "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."',  '".$blog_id."', '0' )";
345
-						Database::query($sql);
321
+            if ($has_attachment) {
322
+                $courseDir   = $_course['path'].'/upload/blog';
323
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
324
+                $updir = $sys_course_path.$courseDir;
325
+
326
+                // Try to add an extension to the file if it hasn't one
327
+                $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
328
+
329
+                // user's file name
330
+                $file_name = $_FILES['user_upload']['name'];
331
+
332
+                if (!filter_extension($new_file_name)) {
333
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
334
+                } else {
335
+                    $new_file_name = uniqid('');
336
+                    $new_path = $updir.'/'.$new_file_name;
337
+                    $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
338
+                    $comment = Database::escape_string($file_comment);
339
+
340
+                    // Storing the attachments if any
341
+                    if ($result) {
342
+                        $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
343
+                                "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."',  '".$blog_id."', '0' )";
344
+                        Database::query($sql);
346 345
                         $id = Database::insert_id();
347 346
                         if ($id) {
348 347
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
349 348
                             Database::query($sql);
350 349
                         }
351
-					}
352
-				}
353
-			}
354
-		} else {
355
-			Display::display_error_message(get_lang('UplNoFileUploaded'));
356
-		}
357
-	}
358
-
359
-	/**
360
-	 * Edits a post in a given blog
361
-	 * @author Toon Keppens
362
-	 * @param Integer $blog_id
363
-	 * @param String $title
364
-	 * @param String $full_text
365
-	 * @param Integer $blog_id
366
-	 */
367
-	public static function edit_post($post_id, $title, $full_text, $blog_id)
368
-	{
369
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
350
+                    }
351
+                }
352
+            }
353
+        } else {
354
+            Display::display_error_message(get_lang('UplNoFileUploaded'));
355
+        }
356
+    }
357
+
358
+    /**
359
+     * Edits a post in a given blog
360
+     * @author Toon Keppens
361
+     * @param Integer $blog_id
362
+     * @param String $title
363
+     * @param String $full_text
364
+     * @param Integer $blog_id
365
+     */
366
+    public static function edit_post($post_id, $title, $full_text, $blog_id)
367
+    {
368
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
370 369
         $course_id = api_get_course_int_id();
371 370
 
372
-		// Create the post
373
-		$sql = "UPDATE $tbl_blogs_posts SET
371
+        // Create the post
372
+        $sql = "UPDATE $tbl_blogs_posts SET
374 373
 		        title = '" . Database::escape_string($title)."',
375 374
 		        full_text = '" . Database::escape_string($full_text)."'
376 375
 		        WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."'
377 376
 		        LIMIT 1 ";
378
-		Database::query($sql);
379
-	}
380
-
381
-	/**
382
-	 * Deletes an article and it's comments
383
-	 * @author Toon Keppens
384
-	 * @param int $blog_id
385
-	 * @param int $post_id
386
-	 */
387
-	public static function delete_post($blog_id, $post_id)
388
-	{
389
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
390
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
391
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
377
+        Database::query($sql);
378
+    }
379
+
380
+    /**
381
+     * Deletes an article and it's comments
382
+     * @author Toon Keppens
383
+     * @param int $blog_id
384
+     * @param int $post_id
385
+     */
386
+    public static function delete_post($blog_id, $post_id)
387
+    {
388
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
389
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
390
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
392 391
 
393 392
         $course_id = api_get_course_int_id();
394 393
 
395
-		// Delete ratings on this comment
396
-		$sql = "DELETE FROM $tbl_blogs_rating
394
+        // Delete ratings on this comment
395
+        $sql = "DELETE FROM $tbl_blogs_rating
397 396
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'";
398
-		Database::query($sql);
397
+        Database::query($sql);
399 398
 
400
-		// Delete the post
401
-		$sql = "DELETE FROM $tbl_blogs_posts
399
+        // Delete the post
400
+        $sql = "DELETE FROM $tbl_blogs_posts
402 401
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."'";
403
-		Database::query($sql);
402
+        Database::query($sql);
404 403
 
405
-		// Delete the comments
406
-		$sql = "DELETE FROM $tbl_blogs_comments
404
+        // Delete the comments
405
+        $sql = "DELETE FROM $tbl_blogs_comments
407 406
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'";
408
-		Database::query($sql);
409
-
410
-		// Delete posts and attachments
411
-		delete_all_blog_attachment($blog_id,$post_id);
412
-	}
413
-
414
-	/**
415
-	 * Creates a comment on a post in a given blog
416
-	 * @author Toon Keppens
417
-	 * @param String $title
418
-	 * @param String $full_text
419
-	 * @param Integer $blog_id
420
-	 * @param Integer $post_id
421
-	 * @param Integer $parent_id
422
-	 */
423
-	public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
424
-	{
425
-		$_user = api_get_user_info();
426
-		$_course = api_get_course_info();
407
+        Database::query($sql);
408
+
409
+        // Delete posts and attachments
410
+        delete_all_blog_attachment($blog_id,$post_id);
411
+    }
412
+
413
+    /**
414
+     * Creates a comment on a post in a given blog
415
+     * @author Toon Keppens
416
+     * @param String $title
417
+     * @param String $full_text
418
+     * @param Integer $blog_id
419
+     * @param Integer $post_id
420
+     * @param Integer $parent_id
421
+     */
422
+    public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
423
+    {
424
+        $_user = api_get_user_info();
425
+        $_course = api_get_course_info();
427 426
         $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
428 427
 
429 428
         $upload_ok = true;
@@ -431,55 +430,55 @@  discard block
 block discarded – undo
431 430
         $current_date = api_get_utc_datetime();
432 431
         $course_id = api_get_course_int_id();
433 432
 
434
-		if (!empty($_FILES['user_upload']['name'])) {
435
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
436
-			$has_attachment=true;
437
-		}
433
+        if (!empty($_FILES['user_upload']['name'])) {
434
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
435
+            $has_attachment=true;
436
+        }
438 437
 
439
-		if ($upload_ok) {
440
-			// Table Definition
441
-			$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
438
+        if ($upload_ok) {
439
+            // Table Definition
440
+            $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
442 441
 
443
-			// Create the comment
444
-			$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
442
+            // Create the comment
443
+            $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
445 444
 					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
446
-			Database::query($sql);
445
+            Database::query($sql);
447 446
 
448
-			// Empty post values, or they are shown on the page again
449
-			$last_id = Database::insert_id();
447
+            // Empty post values, or they are shown on the page again
448
+            $last_id = Database::insert_id();
450 449
 
451 450
             if ($last_id) {
452 451
                 $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id";
453 452
                 Database::query($sql);
454 453
             }
455 454
 
456
-			if ($has_attachment) {
457
-				$courseDir   = $_course['path'].'/upload/blog';
458
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
459
-				$updir = $sys_course_path.$courseDir;
460
-
461
-				// Try to add an extension to the file if it hasn't one
462
-				$new_file_name = add_ext_on_mime(
463
-					stripslashes($_FILES['user_upload']['name']),
464
-					$_FILES['user_upload']['type']
465
-				);
466
-
467
-				// user's file name
468
-				$file_name =$_FILES['user_upload']['name'];
469
-
470
-				if (!filter_extension($new_file_name)) {
471
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
472
-				} else {
473
-					$new_file_name = uniqid('');
474
-					$new_path=$updir.'/'.$new_file_name;
475
-					$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
476
-					$comment = Database::escape_string($file_comment);
477
-
478
-					// Storing the attachments if any
479
-					if ($result) {
480
-						$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
481
-							 "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
482
-						Database::query($sql);
455
+            if ($has_attachment) {
456
+                $courseDir   = $_course['path'].'/upload/blog';
457
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
458
+                $updir = $sys_course_path.$courseDir;
459
+
460
+                // Try to add an extension to the file if it hasn't one
461
+                $new_file_name = add_ext_on_mime(
462
+                    stripslashes($_FILES['user_upload']['name']),
463
+                    $_FILES['user_upload']['type']
464
+                );
465
+
466
+                // user's file name
467
+                $file_name =$_FILES['user_upload']['name'];
468
+
469
+                if (!filter_extension($new_file_name)) {
470
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
471
+                } else {
472
+                    $new_file_name = uniqid('');
473
+                    $new_path=$updir.'/'.$new_file_name;
474
+                    $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
475
+                    $comment = Database::escape_string($file_comment);
476
+
477
+                    // Storing the attachments if any
478
+                    if ($result) {
479
+                        $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
480
+                                "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
481
+                        Database::query($sql);
483 482
 
484 483
                         $id = Database::insert_id();
485 484
 
@@ -487,92 +486,92 @@  discard block
 block discarded – undo
487 486
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
488 487
                             Database::query($sql);
489 488
                         }
490
-					}
491
-				}
492
-			}
493
-		}
494
-	}
495
-
496
-	/**
497
-	 * Deletes a comment from a blogpost
498
-	 * @author Toon Keppens
499
-	 * @param int $blog_id
500
-	 * @param int $comment_id
501
-	 */
502
-	public static function delete_comment($blog_id, $post_id, $comment_id)
503
-	{
504
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
505
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
506
-		$blog_id = intval($blog_id);
507
-		$post_id = intval($post_id);
508
-		$comment_id = intval($comment_id);
489
+                    }
490
+                }
491
+            }
492
+        }
493
+    }
494
+
495
+    /**
496
+     * Deletes a comment from a blogpost
497
+     * @author Toon Keppens
498
+     * @param int $blog_id
499
+     * @param int $comment_id
500
+     */
501
+    public static function delete_comment($blog_id, $post_id, $comment_id)
502
+    {
503
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
504
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
505
+        $blog_id = intval($blog_id);
506
+        $post_id = intval($post_id);
507
+        $comment_id = intval($comment_id);
509 508
         $course_id = api_get_course_int_id();
510 509
 
511
-		delete_all_blog_attachment($blog_id, $post_id, $comment_id);
510
+        delete_all_blog_attachment($blog_id, $post_id, $comment_id);
512 511
 
513
-		// Delete ratings on this comment
514
-		$sql = "DELETE FROM $tbl_blogs_rating
512
+        // Delete ratings on this comment
513
+        $sql = "DELETE FROM $tbl_blogs_rating
515 514
 				WHERE
516 515
 				    c_id = $course_id AND
517 516
 				    blog_id = '".$blog_id."' AND
518 517
 				    item_id = '".$comment_id."' AND
519 518
 				    rating_type = 'comment'";
520
-		Database::query($sql);
519
+        Database::query($sql);
521 520
 
522
-		// select comments that have the selected comment as their parent
523
-		$sql = "SELECT comment_id FROM $tbl_blogs_comments
521
+        // select comments that have the selected comment as their parent
522
+        $sql = "SELECT comment_id FROM $tbl_blogs_comments
524 523
 				WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'";
525
-		$result = Database::query($sql);
524
+        $result = Database::query($sql);
526 525
 
527
-		// Delete them recursively
528
-		while ($comment = Database::fetch_array($result)) {
529
-			Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
530
-		}
526
+        // Delete them recursively
527
+        while ($comment = Database::fetch_array($result)) {
528
+            Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
529
+        }
531 530
 
532
-		// Finally, delete the selected comment to
533
-		$sql = "DELETE FROM $tbl_blogs_comments
531
+        // Finally, delete the selected comment to
532
+        $sql = "DELETE FROM $tbl_blogs_comments
534 533
 				WHERE c_id = $course_id AND comment_id = '".$comment_id."'";
535
-		Database::query($sql);
536
-	}
537
-
538
-	/**
539
-	 * Creates a new task in a blog
540
-	 * @author Toon Keppens
541
-	 * @param Integer $blog_id
542
-	 * @param String $title
543
-	 * @param String $description
544
-	 * @param String $color
545
-	 */
546
-	public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
547
-	{
548
-		// Init
549
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
550
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
551
-
552
-		$course_id = api_get_course_int_id();
553
-
554
-		// Create the task
555
-		$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
534
+        Database::query($sql);
535
+    }
536
+
537
+    /**
538
+     * Creates a new task in a blog
539
+     * @author Toon Keppens
540
+     * @param Integer $blog_id
541
+     * @param String $title
542
+     * @param String $description
543
+     * @param String $color
544
+     */
545
+    public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
546
+    {
547
+        // Init
548
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
549
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
550
+
551
+        $course_id = api_get_course_int_id();
552
+
553
+        // Create the task
554
+        $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
556 555
 				VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
557
-		Database::query($sql);
556
+        Database::query($sql);
558 557
 
559
-		$task_id = Database::insert_id();
558
+        $task_id = Database::insert_id();
560 559
 
561 560
         if ($task_id) {
562 561
             $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id";
563 562
             Database::query($sql);
564 563
         }
565 564
 
566
-		$tool = 'BLOG_' . $blog_id;
565
+        $tool = 'BLOG_' . $blog_id;
567 566
 
568
-		if ($articleDelete == 'on') {
569
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
567
+        if ($articleDelete == 'on') {
568
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
570 569
 					'" . (int)$course_id . "',
571 570
 					'" . (int)$task_id . "',
572 571
 					'" . Database::escape_string($tool) . "',
573 572
 					'article_delete'
574 573
 				)";
575
-			Database::query($sql);
574
+            Database::query($sql);
576 575
 
577 576
             $id = Database::insert_id();
578 577
 
@@ -582,172 +581,172 @@  discard block
 block discarded – undo
582 581
             }
583 582
         }
584 583
 
585
-		if ($articleEdit == 'on') {
586
-			$sql = "
584
+        if ($articleEdit == 'on') {
585
+            $sql = "
587 586
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
588 587
 					'" . (int)$course_id . "',
589 588
 					'" . (int)$task_id . "',
590 589
 					'" . Database::escape_string($tool) . "',
591 590
 					'article_edit'
592 591
 				)";
593
-			Database::query($sql);
592
+            Database::query($sql);
594 593
             $id = Database::insert_id();
595 594
 
596 595
             if ($id) {
597 596
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
598 597
                 Database::query($sql);
599 598
             }
600
-		}
599
+        }
601 600
 
602
-		if ($commentsDelete == 'on') {
603
-			$sql = "
601
+        if ($commentsDelete == 'on') {
602
+            $sql = "
604 603
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
605 604
 					'" . (int)$course_id . "',
606 605
 					'" . (int)$task_id . "',
607 606
 					'" . Database::escape_string($tool) . "',
608 607
 					'article_comments_delete'
609 608
 				)";
610
-			Database::query($sql);
609
+            Database::query($sql);
611 610
             $id = Database::insert_id();
612 611
 
613 612
             if ($id) {
614 613
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
615 614
                 Database::query($sql);
616 615
             }
617
-		}
618
-	}
619
-
620
-	/**
621
-	 * Edit a task in a blog
622
-	 * @author Toon Keppens
623
-	 * @param Integer $task_id
624
-	 * @param String $title
625
-	 * @param String $description
626
-	 * @param String $color
627
-	 */
628
-	public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
629
-	{
630
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
631
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
616
+        }
617
+    }
618
+
619
+    /**
620
+     * Edit a task in a blog
621
+     * @author Toon Keppens
622
+     * @param Integer $task_id
623
+     * @param String $title
624
+     * @param String $description
625
+     * @param String $color
626
+     */
627
+    public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
628
+    {
629
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
630
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
632 631
 
633 632
         $course_id = api_get_course_int_id();
634 633
 
635
-		// Create the task
636
-		$sql = "UPDATE $tbl_blogs_tasks SET
634
+        // Create the task
635
+        $sql = "UPDATE $tbl_blogs_tasks SET
637 636
 					title = '".Database::escape_string($title)."',
638 637
 					description = '".Database::escape_string($description)."',
639 638
 					color = '".Database::escape_string($color)."'
640 639
 				WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1";
641
-		Database::query($sql);
640
+        Database::query($sql);
642 641
 
643
-		$tool = 'BLOG_' . $blog_id;
642
+        $tool = 'BLOG_' . $blog_id;
644 643
 
645
-		$sql = "DELETE FROM " . $tbl_tasks_permissions . "
644
+        $sql = "DELETE FROM " . $tbl_tasks_permissions . "
646 645
 				WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
647
-		Database::query($sql);
646
+        Database::query($sql);
648 647
 
649
-		if ($articleDelete == 'on') {
650
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
648
+        if ($articleDelete == 'on') {
649
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
651 650
 					'" . (int)$course_id . "',
652 651
 					'" . (int)$task_id . "',
653 652
 					'" . Database::escape_string($tool) . "',
654 653
 					'article_delete'
655 654
 				)";
656
-			Database::query($sql);
655
+            Database::query($sql);
657 656
             $id = Database::insert_id();
658 657
 
659 658
             if ($id) {
660 659
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
661 660
                 Database::query($sql);
662 661
             }
663
-		}
662
+        }
664 663
 
665
-		if ($articleEdit == 'on') {
666
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
664
+        if ($articleEdit == 'on') {
665
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
667 666
 					'" . (int)$course_id . "',
668 667
 					'" . (int)$task_id . "',
669 668
 					'" . Database::escape_string($tool) . "',
670 669
 					'article_edit'
671 670
 				)";
672
-			Database::query($sql);
671
+            Database::query($sql);
673 672
             $id = Database::insert_id();
674 673
 
675 674
             if ($id) {
676 675
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
677 676
                 Database::query($sql);
678 677
             }
679
-		}
678
+        }
680 679
 
681
-		if ($commentsDelete == 'on') {
682
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
680
+        if ($commentsDelete == 'on') {
681
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
683 682
 					'" . (int)$course_id . "',
684 683
 					'" . (int)$task_id . "',
685 684
 					'" . Database::escape_string($tool) . "',
686 685
 					'article_comments_delete'
687 686
 				)";
688
-			Database::query($sql);
687
+            Database::query($sql);
689 688
             $id = Database::insert_id();
690 689
 
691 690
             if ($id) {
692 691
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
693 692
                 Database::query($sql);
694 693
             }
695
-		}
696
-	}
697
-
698
-	/**
699
-	 * Deletes a task from a blog
700
-	 * @param Integer $blog_id
701
-	 * @param Integer $task_id
702
-	 */
703
-	public static function delete_task($blog_id, $task_id)
704
-	{
705
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
706
-		$course_id = api_get_course_int_id();
707
-
708
-		// Delete posts
709
-		$sql = "DELETE FROM $tbl_blogs_tasks
694
+        }
695
+    }
696
+
697
+    /**
698
+     * Deletes a task from a blog
699
+     * @param Integer $blog_id
700
+     * @param Integer $task_id
701
+     */
702
+    public static function delete_task($blog_id, $task_id)
703
+    {
704
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
705
+        $course_id = api_get_course_int_id();
706
+
707
+        // Delete posts
708
+        $sql = "DELETE FROM $tbl_blogs_tasks
710 709
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
711
-		Database::query($sql);
712
-	}
713
-
714
-	/**
715
-	 * Deletes an assigned task from a blog
716
-	 * @param Integer $blog_id
717
-	 * @param Integer $assignment_id
718
-	 */
719
-	public static function delete_assigned_task($blog_id, $task_id, $user_id)
720
-	{
721
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
710
+        Database::query($sql);
711
+    }
712
+
713
+    /**
714
+     * Deletes an assigned task from a blog
715
+     * @param Integer $blog_id
716
+     * @param Integer $assignment_id
717
+     */
718
+    public static function delete_assigned_task($blog_id, $task_id, $user_id)
719
+    {
720
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
722 721
         $course_id = api_get_course_int_id();
723 722
 
724
-		// Delete posts
725
-		$sql = "DELETE FROM $tbl_blogs_tasks_rel_user
723
+        // Delete posts
724
+        $sql = "DELETE FROM $tbl_blogs_tasks_rel_user
726 725
 				WHERE
727 726
 				    c_id = $course_id AND
728 727
 				    blog_id = '".(int)$blog_id."' AND
729 728
 				    task_id = '".(int)$task_id."' AND
730 729
 				    user_id = '".(int)$user_id."'";
731
-		Database::query($sql);
732
-	}
733
-
734
-	/**
735
-	 * Get personal task list
736
-	 * @author Toon Keppens
737
-	 * @return Returns an unsorted list (<ul></ul>) with the users' tasks
738
-	 */
739
-	public static function get_personal_task_list()
740
-	{
741
-		$_user = api_get_user_info();
742
-
743
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
744
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
745
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
746
-
747
-		$course_id = api_get_course_int_id();
748
-
749
-		if ($_user['user_id']) {
750
-			$sql = "SELECT task_rel_user.*, task.title, blog.blog_name
730
+        Database::query($sql);
731
+    }
732
+
733
+    /**
734
+     * Get personal task list
735
+     * @author Toon Keppens
736
+     * @return Returns an unsorted list (<ul></ul>) with the users' tasks
737
+     */
738
+    public static function get_personal_task_list()
739
+    {
740
+        $_user = api_get_user_info();
741
+
742
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
743
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
744
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
745
+
746
+        $course_id = api_get_course_int_id();
747
+
748
+        if ($_user['user_id']) {
749
+            $sql = "SELECT task_rel_user.*, task.title, blog.blog_name
751 750
                     FROM $tbl_blogs_tasks_rel_user task_rel_user
752 751
                     INNER JOIN $tbl_blogs_tasks task
753 752
                     ON task_rel_user.task_id = task.task_id
@@ -761,93 +760,93 @@  discard block
 block discarded – undo
761 760
                         task_rel_user.user_id = ".(int)$_user['user_id']."
762 761
                     ORDER BY target_date ASC";
763 762
 
764
-			$result = Database::query($sql);
763
+            $result = Database::query($sql);
765 764
 
766
-			if (Database::num_rows($result) > 0) {
767
-				echo '<ul>';
768
-				while ($mytask = Database::fetch_array($result)) {
769
-					echo '<li>
765
+            if (Database::num_rows($result) > 0) {
766
+                echo '<ul>';
767
+                while ($mytask = Database::fetch_array($result)) {
768
+                    echo '<li>
770 769
 							<a href="blog.php?'.api_get_cidreq(
771
-						).'action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes(
772
-							$mytask['task_id']
773
-						).'" title="[Blog: '.stripslashes(
774
-							$mytask['blog_name']
775
-						).'] '.get_lang('ExecuteThisTask').'">
770
+                        ).'action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes(
771
+                            $mytask['task_id']
772
+                        ).'" title="[Blog: '.stripslashes(
773
+                            $mytask['blog_name']
774
+                        ).'] '.get_lang('ExecuteThisTask').'">
776 775
 							'.stripslashes($mytask['title']).'</a>
777 776
 						</li>';
778
-				}
779
-				echo '<ul>';
780
-			} else {
781
-				echo get_lang('NoTasks');
782
-			}
783
-		} else {
784
-			echo get_lang('NoTasks');
785
-		}
786
-	}
787
-
788
-	/**
789
-	 * Changes the visibility of a blog
790
-	 * @author Toon Keppens
791
-	 * @param Integer $blog_id
792
-	 */
793
-	public static function change_blog_visibility($blog_id)
794
-	{
795
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
796
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
797
-		$course_id = api_get_course_int_id();
798
-
799
-		// Get blog properties
800
-		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
777
+                }
778
+                echo '<ul>';
779
+            } else {
780
+                echo get_lang('NoTasks');
781
+            }
782
+        } else {
783
+            echo get_lang('NoTasks');
784
+        }
785
+    }
786
+
787
+    /**
788
+     * Changes the visibility of a blog
789
+     * @author Toon Keppens
790
+     * @param Integer $blog_id
791
+     */
792
+    public static function change_blog_visibility($blog_id)
793
+    {
794
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
795
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
796
+        $course_id = api_get_course_int_id();
797
+
798
+        // Get blog properties
799
+        $sql = "SELECT blog_name, visibility FROM $tbl_blogs
801 800
 				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
802
-		$result = Database::query($sql);
803
-		$blog = Database::fetch_array($result);
804
-		$visibility = $blog['visibility'];
805
-		$title = $blog['blog_name'];
806
-
807
-		if ($visibility == 1) {
808
-			// Change visibility state, remove from course home.
809
-			$sql = "UPDATE $tbl_blogs SET visibility = '0'
801
+        $result = Database::query($sql);
802
+        $blog = Database::fetch_array($result);
803
+        $visibility = $blog['visibility'];
804
+        $title = $blog['blog_name'];
805
+
806
+        if ($visibility == 1) {
807
+            // Change visibility state, remove from course home.
808
+            $sql = "UPDATE $tbl_blogs SET visibility = '0'
810 809
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
811
-			Database::query($sql);
810
+            Database::query($sql);
812 811
 
813
-			$sql = "DELETE FROM $tbl_tool
812
+            $sql = "DELETE FROM $tbl_tool
814 813
 					WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1";
815
-			Database::query($sql);
816
-		} else {
817
-			// Change visibility state, add to course home.
818
-			$sql = "UPDATE $tbl_blogs SET visibility = '1'
814
+            Database::query($sql);
815
+        } else {
816
+            // Change visibility state, add to course home.
817
+            $sql = "UPDATE $tbl_blogs SET visibility = '1'
819 818
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
820
-			Database::query($sql);
819
+            Database::query($sql);
821 820
 
822
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
821
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
823 822
 					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
824
-			Database::query($sql);
823
+            Database::query($sql);
825 824
             $id = Database::insert_id();
826 825
 
827 826
             if ($id) {
828 827
                 $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id";
829 828
                 Database::query($sql);
830 829
             }
831
-		}
832
-	}
833
-
834
-	/**
835
-	 * Shows the posts of a blog
836
-	 * @author Toon Keppens
837
-	 *
838
-	 * @param Integer $blog_id
839
-	 */
840
-	public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
830
+        }
831
+    }
832
+
833
+    /**
834
+     * Shows the posts of a blog
835
+     * @author Toon Keppens
836
+     *
837
+     * @param Integer $blog_id
838
+     */
839
+    public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
841 840
     {
842
-		// Init
843
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
844
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
845
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
841
+        // Init
842
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
843
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
844
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
846 845
 
847
-		$course_id = api_get_course_int_id();
846
+        $course_id = api_get_course_int_id();
848 847
 
849
-		// Get posts and authors
850
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
848
+        // Get posts and authors
849
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
851 850
 		        FROM $tbl_blogs_posts post
852 851
                 INNER JOIN $tbl_users user
853 852
                 ON post.author_id = user.user_id
@@ -855,151 +854,151 @@  discard block
 block discarded – undo
855 854
 						post.c_id = $course_id AND
856 855
 						$filter
857 856
 				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
858
-		$result = Database::query($sql);
859
-
860
-		// Display
861
-		if(Database::num_rows($result) > 0) {
862
-		    $limit = 200;
863
-			while ($blog_post = Database::fetch_array($result)) {
864
-				// Get number of comments
865
-				$sql = "SELECT COUNT(1) as number_of_comments
857
+        $result = Database::query($sql);
858
+
859
+        // Display
860
+        if(Database::num_rows($result) > 0) {
861
+            $limit = 200;
862
+            while ($blog_post = Database::fetch_array($result)) {
863
+                // Get number of comments
864
+                $sql = "SELECT COUNT(1) as number_of_comments
866 865
 						FROM $tbl_blogs_comments
867 866
 						WHERE
868 867
 						    c_id = $course_id AND
869 868
 						    blog_id = '".(int)$blog_id."' AND
870 869
 						    post_id = '" . (int)$blog_post['post_id']."'";
871
-				$tmp = Database::query($sql);
872
-				$blog_post_comments = Database::fetch_array($tmp);
873
-
874
-				// Prepare data
875
-				$blog_post_id = $blog_post['post_id'];
876
-				$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
877
-				$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
878
-
879
-				// Create an introduction text (but keep FULL sentences)
880
-				$words = 0;
881
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
882
-				$words = strlen($blog_post_text);
883
-
884
-				if ($words >= $limit) {
885
-					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
886
-					$introduction_text = $blog_post_text_cut;
887
-				} else {
888
-				    $introduction_text = $blog_post_text;
889
-					$readMoreLink = '';
890
-				}
891
-
892
-				$introduction_text = stripslashes($introduction_text);
893
-
894
-				echo '<div class="blogpost">';
895
-				echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq(
896
-					).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
897
-						'ReadPost'
898
-					).'" >'.stripslashes($blog_post['title']).'</a></span>';
899
-				echo '<span class="blogpost_date"><a href="blog.php?'.api_get_cidreq(
900
-					).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
901
-						'ReadPost'
902
-					).'" >'.$blog_post_date.'</a></span>';
903
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
904
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
905
-
906
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
907
-
908
-				if (!empty($file_name_array)) {
909
-					echo '<br /><br />';
910
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
911
-					echo '<a href="download.php?'.api_get_cidreq().'&file=';
912
-					echo $file_name_array['path'];
913
-					echo ' "> '.$file_name_array['filename'].' </a><br />';
914
-					echo '</span>';
915
-				}
916
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
917
-				echo '<span class="blogpost_info">'.get_lang('Author').': '.
918
-					Display::tag(
919
-						'span',
920
-						api_get_person_name(
921
-							$blog_post['firstname'],
922
-							$blog_post['lastname']
923
-						),
924
-						array('title' => $username)
925
-					).
926
-					' - <a href="blog.php?'.api_get_cidreq(
927
-					).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
928
-						'ReadPost'
929
-					).'" >'.get_lang(
930
-						'Comments'
931
-					).': '.$blog_post_comments['number_of_comments'].'</a></span>';
932
-				echo '</div>';
933
-			}
934
-		} else {
935
-			if ($filter == '1=1') {
936
-				echo get_lang('NoArticles');
937
-			} else {
938
-				echo get_lang('NoArticleMatches');
939
-			}
940
-		}
870
+                $tmp = Database::query($sql);
871
+                $blog_post_comments = Database::fetch_array($tmp);
872
+
873
+                // Prepare data
874
+                $blog_post_id = $blog_post['post_id'];
875
+                $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
876
+                $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
877
+
878
+                // Create an introduction text (but keep FULL sentences)
879
+                $words = 0;
880
+                $blog_post_text_cut = cut($blog_post_text, $limit) ;
881
+                $words = strlen($blog_post_text);
882
+
883
+                if ($words >= $limit) {
884
+                    $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
885
+                    $introduction_text = $blog_post_text_cut;
886
+                } else {
887
+                    $introduction_text = $blog_post_text;
888
+                    $readMoreLink = '';
889
+                }
890
+
891
+                $introduction_text = stripslashes($introduction_text);
892
+
893
+                echo '<div class="blogpost">';
894
+                echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq(
895
+                    ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
896
+                        'ReadPost'
897
+                    ).'" >'.stripslashes($blog_post['title']).'</a></span>';
898
+                echo '<span class="blogpost_date"><a href="blog.php?'.api_get_cidreq(
899
+                    ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
900
+                        'ReadPost'
901
+                    ).'" >'.$blog_post_date.'</a></span>';
902
+                echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
903
+                echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
904
+
905
+                $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
906
+
907
+                if (!empty($file_name_array)) {
908
+                    echo '<br /><br />';
909
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
910
+                    echo '<a href="download.php?'.api_get_cidreq().'&file=';
911
+                    echo $file_name_array['path'];
912
+                    echo ' "> '.$file_name_array['filename'].' </a><br />';
913
+                    echo '</span>';
914
+                }
915
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
916
+                echo '<span class="blogpost_info">'.get_lang('Author').': '.
917
+                    Display::tag(
918
+                        'span',
919
+                        api_get_person_name(
920
+                            $blog_post['firstname'],
921
+                            $blog_post['lastname']
922
+                        ),
923
+                        array('title' => $username)
924
+                    ).
925
+                    ' - <a href="blog.php?'.api_get_cidreq(
926
+                    ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
927
+                        'ReadPost'
928
+                    ).'" >'.get_lang(
929
+                        'Comments'
930
+                    ).': '.$blog_post_comments['number_of_comments'].'</a></span>';
931
+                echo '</div>';
932
+            }
933
+        } else {
934
+            if ($filter == '1=1') {
935
+                echo get_lang('NoArticles');
936
+            } else {
937
+                echo get_lang('NoArticleMatches');
938
+            }
939
+        }
941 940
 }
942 941
 
943
-	/**
944
-	 * Display the search results
945
-	 *
946
-	 * @param Integer $blog_id
947
-	 * @param String $query_string
948
-	 */
949
-	public static function display_search_results ($blog_id, $query_string)
950
-	{
951
-		// Init
952
-		$query_string = Database::escape_string($query_string);
953
-		$query_string_parts = explode(' ',$query_string);
954
-		$query_string = array();
955
-		foreach ($query_string_parts as $query_part) {
956
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
957
-		}
958
-		$query_string = '('.implode('OR',$query_string) . ')';
959
-
960
-		// Display the posts
961
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
962
-		Blog::display_blog_posts($blog_id, $query_string);
963
-	}
964
-
965
-	/**
966
-	 * Display posts from a certain date
967
-	 *
968
-	 * @param Integer $blog_id
969
-	 * @param String $query_string
970
-	 */
971
-	public static function display_day_results($blog_id, $query_string)
972
-	{
973
-		$date_output = $query_string;
974
-		$date = explode('-',$query_string);
975
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
976
-
977
-		// Put date in correct output format
978
-		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
979
-
980
-		// Display the posts
981
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
982
-		Blog::display_blog_posts($blog_id, $query_string);
983
-	}
984
-
985
-	/**
986
-	 * Displays a post and his comments
987
-	 *
988
-	 * @param Integer $blog_id
989
-	 * @param Integer $post_id
990
-	 */
991
-	public static function display_post($blog_id, $post_id)
992
-	{
993
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
994
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
995
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
996
-
997
-		global $charset, $dateFormatLong;
998
-
999
-		$course_id = api_get_course_int_id();
1000
-
1001
-		// Get posts and author
1002
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
942
+    /**
943
+     * Display the search results
944
+     *
945
+     * @param Integer $blog_id
946
+     * @param String $query_string
947
+     */
948
+    public static function display_search_results ($blog_id, $query_string)
949
+    {
950
+        // Init
951
+        $query_string = Database::escape_string($query_string);
952
+        $query_string_parts = explode(' ',$query_string);
953
+        $query_string = array();
954
+        foreach ($query_string_parts as $query_part) {
955
+            $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
956
+        }
957
+        $query_string = '('.implode('OR',$query_string) . ')';
958
+
959
+        // Display the posts
960
+        echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
961
+        Blog::display_blog_posts($blog_id, $query_string);
962
+    }
963
+
964
+    /**
965
+     * Display posts from a certain date
966
+     *
967
+     * @param Integer $blog_id
968
+     * @param String $query_string
969
+     */
970
+    public static function display_day_results($blog_id, $query_string)
971
+    {
972
+        $date_output = $query_string;
973
+        $date = explode('-',$query_string);
974
+        $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
975
+
976
+        // Put date in correct output format
977
+        $date_output = api_format_date($date_output, DATE_FORMAT_LONG);
978
+
979
+        // Display the posts
980
+        echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
981
+        Blog::display_blog_posts($blog_id, $query_string);
982
+    }
983
+
984
+    /**
985
+     * Displays a post and his comments
986
+     *
987
+     * @param Integer $blog_id
988
+     * @param Integer $post_id
989
+     */
990
+    public static function display_post($blog_id, $post_id)
991
+    {
992
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
993
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
994
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
995
+
996
+        global $charset, $dateFormatLong;
997
+
998
+        $course_id = api_get_course_int_id();
999
+
1000
+        // Get posts and author
1001
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
1003 1002
 		        FROM $tbl_blogs_posts post
1004 1003
 					INNER JOIN $tbl_users user
1005 1004
 					ON post.author_id = user.user_id
@@ -1008,60 +1007,60 @@  discard block
 block discarded – undo
1008 1007
                     post.blog_id = '".(int)$blog_id."' AND
1009 1008
                     post.post_id = '".(int)$post_id."'
1010 1009
                 ORDER BY post_id DESC";
1011
-		$result = Database::query($sql);
1012
-		$blog_post = Database::fetch_array($result);
1010
+        $result = Database::query($sql);
1011
+        $blog_post = Database::fetch_array($result);
1013 1012
 
1014
-		// Get number of comments
1015
-		$sql = "SELECT COUNT(1) as number_of_comments
1013
+        // Get number of comments
1014
+        $sql = "SELECT COUNT(1) as number_of_comments
1016 1015
 		        FROM $tbl_blogs_comments
1017 1016
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
1018
-		$result = Database::query($sql);
1019
-		$blog_post_comments = Database::fetch_array($result);
1017
+        $result = Database::query($sql);
1018
+        $blog_post_comments = Database::fetch_array($result);
1020 1019
 
1021
-		// Prepare data
1022
-		$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
1023
-		$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
1024
-		$blog_post_actions = "";
1020
+        // Prepare data
1021
+        $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
1022
+        $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
1023
+        $blog_post_actions = "";
1025 1024
 
1026
-		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
1025
+        $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
1027 1026
 
1028
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
1029
-			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">';
1030
-			$blog_post_actions .=  Display::return_icon('edit.png');
1031
-			$blog_post_actions .= '</a>';
1027
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
1028
+            $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">';
1029
+            $blog_post_actions .=  Display::return_icon('edit.png');
1030
+            $blog_post_actions .= '</a>';
1032 1031
         }
1033 1032
 
1034
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
1035
-			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">';
1033
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
1034
+            $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">';
1036 1035
             $blog_post_actions .= Display::return_icon('delete.png');
1037 1036
             $blog_post_actions .= '</a>';
1038 1037
         }
1039 1038
 
1040
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1041
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1039
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1040
+            $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1042 1041
 
1043
-		$blog_post_text=stripslashes($blog_post_text);
1042
+        $blog_post_text=stripslashes($blog_post_text);
1044 1043
 
1045
-		// Display post
1046
-		echo '<div class="blogpost">';
1047
-		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1048
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1049
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1044
+        // Display post
1045
+        echo '<div class="blogpost">';
1046
+        echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1047
+        echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1048
+        echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1050 1049
 
1051
-		$file_name_array = get_blog_attachment($blog_id, $post_id);
1050
+        $file_name_array = get_blog_attachment($blog_id, $post_id);
1052 1051
 
1053 1052
         if (!empty($file_name_array)) {
1054
-			echo ' <br />';
1055
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1056
-			echo '<a href="download.php?'.api_get_cidreq().'&file=';
1057
-			echo $file_name_array['path'];
1058
-			echo ' "> '.$file_name_array['filename'].' </a>';
1059
-			echo '</span>';
1060
-			echo '<span class="attachment_comment">';
1061
-			echo $file_name_array['comment'];
1062
-			echo '</span>';
1063
-			echo '<br />';
1064
-		}
1053
+            echo ' <br />';
1054
+            echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1055
+            echo '<a href="download.php?'.api_get_cidreq().'&file=';
1056
+            echo $file_name_array['path'];
1057
+            echo ' "> '.$file_name_array['filename'].' </a>';
1058
+            echo '</span>';
1059
+            echo '<span class="attachment_comment">';
1060
+            echo $file_name_array['comment'];
1061
+            echo '</span>';
1062
+            echo '<br />';
1063
+        }
1065 1064
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1066 1065
         echo '<span class="blogpost_info">'.get_lang('Author').': '.
1067 1066
             Display::tag(
@@ -1080,57 +1079,57 @@  discard block
 block discarded – undo
1080 1079
                 $blog_id,
1081 1080
                 $post_id
1082 1081
             ).$rating_select.'</span>';
1083
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1084
-		echo '</div>';
1082
+        echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1083
+        echo '</div>';
1085 1084
 
1086
-		// Display comments if there are any
1085
+        // Display comments if there are any
1087 1086
         if ($blog_post_comments['number_of_comments'] > 0) {
1088
-			echo '<div class="comments">';
1089
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1090
-				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1091
-			echo '</div>';
1092
-		}
1093
-
1094
-		// Display comment form
1095
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1096
-			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1097
-		}
1098
-	}
1099
-
1100
-	/**
1101
-	 * Adds rating to a certain post or comment
1102
-	 * @author Toon Keppens
1103
-	 *
1104
-	 * @param String $type
1105
-	 * @param Integer $blog_id
1106
-	 * @param Integer $item_id
1107
-	 * @param Integer $rating
1108
-	 *
1109
-	 * @return Boolean success
1110
-	 */
1111
-	public static function add_rating($type, $blog_id, $item_id, $rating)
1112
-	{
1113
-		$_user = api_get_user_info();
1114
-
1115
-		// Init
1116
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1117
-		$course_id = api_get_course_int_id();
1118
-
1119
-		// Check if the user has already rated this post/comment
1120
-		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1087
+            echo '<div class="comments">';
1088
+                echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1089
+                Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1090
+            echo '</div>';
1091
+        }
1092
+
1093
+        // Display comment form
1094
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1095
+            Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1096
+        }
1097
+    }
1098
+
1099
+    /**
1100
+     * Adds rating to a certain post or comment
1101
+     * @author Toon Keppens
1102
+     *
1103
+     * @param String $type
1104
+     * @param Integer $blog_id
1105
+     * @param Integer $item_id
1106
+     * @param Integer $rating
1107
+     *
1108
+     * @return Boolean success
1109
+     */
1110
+    public static function add_rating($type, $blog_id, $item_id, $rating)
1111
+    {
1112
+        $_user = api_get_user_info();
1113
+
1114
+        // Init
1115
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1116
+        $course_id = api_get_course_int_id();
1117
+
1118
+        // Check if the user has already rated this post/comment
1119
+        $sql = "SELECT rating_id FROM $tbl_blogs_rating
1121 1120
                 WHERE
1122 1121
                     c_id = $course_id AND
1123 1122
                     blog_id = '".(int)$blog_id."' AND
1124 1123
                     item_id = '".(int)$item_id."' AND
1125 1124
                     rating_type = '".Database::escape_string($type)."' AND
1126 1125
                     user_id = '".(int)$_user['user_id']."'";
1127
-		$result = Database::query($sql);
1126
+        $result = Database::query($sql);
1128 1127
 
1129 1128
         // Add rating
1130
-		if (Database::num_rows($result) == 0) {
1131
-			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1129
+        if (Database::num_rows($result) == 0) {
1130
+            $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1132 1131
 					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1133
-			Database::query($sql);
1132
+            Database::query($sql);
1134 1133
 
1135 1134
             $id = Database::insert_id();
1136 1135
             if ($id) {
@@ -1138,113 +1137,113 @@  discard block
 block discarded – undo
1138 1137
                 Database::query($sql);
1139 1138
             }
1140 1139
 
1141
-			return true;
1140
+            return true;
1142 1141
         } else {
1143
-			return false;
1144
-		}
1145
-	}
1146
-
1147
-	/**
1148
-	 * Shows the rating of user
1149
-	 *
1150
-	 * @param String $type
1151
-	 * @param Integer $blog_id
1152
-	 * @param Integer $item_id
1153
-	 *
1154
-	 * @return array()
1155
-	 */
1156
-	public static function display_rating($type, $blog_id, $item_id)
1157
-	{
1158
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1159
-		$course_id = api_get_course_int_id();
1160
-
1161
-		// Calculate rating
1162
-		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1142
+            return false;
1143
+        }
1144
+    }
1145
+
1146
+    /**
1147
+     * Shows the rating of user
1148
+     *
1149
+     * @param String $type
1150
+     * @param Integer $blog_id
1151
+     * @param Integer $item_id
1152
+     *
1153
+     * @return array()
1154
+     */
1155
+    public static function display_rating($type, $blog_id, $item_id)
1156
+    {
1157
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1158
+        $course_id = api_get_course_int_id();
1159
+
1160
+        // Calculate rating
1161
+        $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1163 1162
 				WHERE
1164 1163
 				    c_id = $course_id AND
1165 1164
 				    blog_id = '".(int)$blog_id."' AND
1166 1165
 				    item_id = '".(int)$item_id."' AND
1167 1166
 				    rating_type = '".Database::escape_string($type)."' ";
1168
-		$result = Database::query($sql);
1169
-		$result = Database::fetch_array($result);
1170
-		return round($result['rating'], 2);
1171
-	}
1172
-
1173
-	/**
1174
-	 * Shows the rating form if not already rated by that user
1175
-	 * @author Toon Keppens
1176
-	 *
1177
-	 * @param String $type
1178
-	 * @param Integer $blog_id
1179
-	 * @param Integer $item_id
1180
-	 *
1181
-	 *@return String
1182
-	 */
1183
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1184
-	{
1185
-		$_user = api_get_user_info();
1186
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1167
+        $result = Database::query($sql);
1168
+        $result = Database::fetch_array($result);
1169
+        return round($result['rating'], 2);
1170
+    }
1171
+
1172
+    /**
1173
+     * Shows the rating form if not already rated by that user
1174
+     * @author Toon Keppens
1175
+     *
1176
+     * @param String $type
1177
+     * @param Integer $blog_id
1178
+     * @param Integer $item_id
1179
+     *
1180
+     *@return String
1181
+     */
1182
+    public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1183
+    {
1184
+        $_user = api_get_user_info();
1185
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1187 1186
         $course_id = api_get_course_int_id();
1188 1187
 
1189 1188
         if ($type == 'post') {
1190
-			// Check if the user has already rated this post
1191
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1189
+            // Check if the user has already rated this post
1190
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1192 1191
 					WHERE c_id = $course_id AND
1193 1192
 					blog_id = '".(int)$blog_id."'
1194 1193
 					AND item_id = '".(int)$post_id."'
1195 1194
 					AND rating_type = '".Database::escape_string($type)."'
1196 1195
 					AND user_id = '".(int)$_user['user_id']."'";
1197
-			$result = Database::query($sql);
1196
+            $result = Database::query($sql);
1198 1197
             // Add rating
1199 1198
             if (Database::num_rows($result) == 0) {
1200
-				return ' - '.get_lang(
1201
-					'RateThis'
1202
-				).': <form method="get" action="blog.php?'.api_get_cidreq(
1203
-				).'" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>';
1199
+                return ' - '.get_lang(
1200
+                    'RateThis'
1201
+                ).': <form method="get" action="blog.php?'.api_get_cidreq(
1202
+                ).'" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>';
1204 1203
             } else {
1205
-				return '';
1206
-			}
1207
-		}
1204
+                return '';
1205
+            }
1206
+        }
1208 1207
 
1209 1208
         if ($type = 'comment') {
1210
-			// Check if the user has already rated this comment
1211
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1209
+            // Check if the user has already rated this comment
1210
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1212 1211
 					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1213 1212
 					AND item_id = '".(int)$comment_id."'
1214 1213
 					AND rating_type = '".Database::escape_string($type)."'
1215 1214
 					AND user_id = '".(int)$_user['user_id']."'";
1216
-			$result = Database::query($sql);
1215
+            $result = Database::query($sql);
1217 1216
 
1218 1217
             if (Database::num_rows($result) == 0) {
1219
-				return ' - '.get_lang(
1220
-					'RateThis'
1221
-				).': <form method="get" action="blog.php?'.api_get_cidreq(
1222
-				).'" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>';
1218
+                return ' - '.get_lang(
1219
+                    'RateThis'
1220
+                ).': <form method="get" action="blog.php?'.api_get_cidreq(
1221
+                ).'" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>';
1223 1222
             } else {
1224
-				return '';
1225
-			}
1226
-		}
1227
-	}
1228
-
1229
-	/**
1230
-	 * This functions gets all replys to a post, threaded.
1231
-	 *
1232
-	 * @param Integer $current
1233
-	 * @param Integer $current_level
1234
-	 * @param Integer $blog_id
1235
-	 * @param Integer $post_id
1236
-	 */
1237
-	public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1238
-	{
1239
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1240
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1241
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1242
-		global $charset;
1243
-
1244
-		$course_id = api_get_course_int_id();
1245
-
1246
-		// Select top level comments
1247
-		$next_level = $current_level + 1;
1223
+                return '';
1224
+            }
1225
+        }
1226
+    }
1227
+
1228
+    /**
1229
+     * This functions gets all replys to a post, threaded.
1230
+     *
1231
+     * @param Integer $current
1232
+     * @param Integer $current_level
1233
+     * @param Integer $blog_id
1234
+     * @param Integer $post_id
1235
+     */
1236
+    public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1237
+    {
1238
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1239
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1240
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1241
+        global $charset;
1242
+
1243
+        $course_id = api_get_course_int_id();
1244
+
1245
+        // Select top level comments
1246
+        $next_level = $current_level + 1;
1248 1247
         $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color
1249 1248
                 FROM $tbl_blogs_comments comments
1250 1249
                 INNER JOIN $tbl_users user
@@ -1256,11 +1255,11 @@  discard block
 block discarded – undo
1256 1255
                     parent_comment_id = $current AND
1257 1256
                     comments.blog_id = '".(int)$blog_id."' AND
1258 1257
                     comments.post_id = '".(int)$post_id."'";
1259
-		$result = Database::query($sql);
1258
+        $result = Database::query($sql);
1260 1259
 
1261
-		while($comment = Database::fetch_array($result)) {
1262
-			// Select the children recursivly
1263
-			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1260
+        while($comment = Database::fetch_array($result)) {
1261
+            // Select the children recursivly
1262
+            $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1264 1263
 			        FROM $tbl_blogs_comments comments
1265 1264
 					INNER JOIN $tbl_users user
1266 1265
 					ON comments.author_id = user.user_id
@@ -1269,120 +1268,120 @@  discard block
 block discarded – undo
1269 1268
 						comment_id = $current
1270 1269
 						AND blog_id = '".(int)$blog_id."'
1271 1270
 						AND post_id = '".(int)$post_id."'";
1272
-			$tmp = Database::query($tmp);
1273
-			$tmp = Database::fetch_array($tmp);
1274
-			$parent_cat = $tmp['parent_comment_id'];
1275
-			$border_color = '';
1276
-
1277
-			// Prepare data
1278
-			$comment_text = make_clickable(stripslashes($comment['comment']));
1279
-			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1280
-			$blog_comment_actions = "";
1281
-		    if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) {
1282
-			$blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang(
1283
-				'DeleteThisComment'
1284
-			    ).'" onclick="javascript:if(!confirm(\''.addslashes(
1285
-				api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)
1286
-			    ).'\')) return false;">';
1287
-			$blog_comment_actions .= Display::return_icon('delete.png');
1288
-			$blog_comment_actions .= '</a>';
1289
-		    }
1290
-
1291
-		    if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) {
1292
-			$rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']);
1293
-		    }
1294
-
1295
-			if (!is_null($comment['task_id'])) {
1296
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1297
-			}
1298
-
1299
-			$comment_text = stripslashes($comment_text);
1300
-
1301
-			// Output...
1302
-			$margin = $current_level * 30;
1303
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1304
-			echo '<span class="blogpost_comment_title">
1271
+            $tmp = Database::query($tmp);
1272
+            $tmp = Database::fetch_array($tmp);
1273
+            $parent_cat = $tmp['parent_comment_id'];
1274
+            $border_color = '';
1275
+
1276
+            // Prepare data
1277
+            $comment_text = make_clickable(stripslashes($comment['comment']));
1278
+            $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1279
+            $blog_comment_actions = "";
1280
+            if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) {
1281
+            $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang(
1282
+                'DeleteThisComment'
1283
+                ).'" onclick="javascript:if(!confirm(\''.addslashes(
1284
+                api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)
1285
+                ).'\')) return false;">';
1286
+            $blog_comment_actions .= Display::return_icon('delete.png');
1287
+            $blog_comment_actions .= '</a>';
1288
+            }
1289
+
1290
+            if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) {
1291
+            $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']);
1292
+            }
1293
+
1294
+            if (!is_null($comment['task_id'])) {
1295
+                $border_color = ' border-left: 3px solid #' . $comment['color'];
1296
+            }
1297
+
1298
+            $comment_text = stripslashes($comment_text);
1299
+
1300
+            // Output...
1301
+            $margin = $current_level * 30;
1302
+            echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1303
+            echo '<span class="blogpost_comment_title">
1305 1304
 						<a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes(
1306
-					$comment['title']
1307
-				).'\'" title="'.get_lang(
1308
-					'ReplyToThisComment'
1309
-				).'" >'.stripslashes($comment['title']).'</a></span>';
1310
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1311
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1312
-
1313
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1314
-				if (!empty($file_name_array)) {
1315
-					echo '<br /><br />';
1316
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1317
-					echo '<a href="download.php?'.api_get_cidreq().'&file=';
1318
-					echo $file_name_array['path'];
1319
-					echo ' "> '.$file_name_array['filename'].' </a>';
1320
-					echo '<span class="attachment_comment">';
1321
-					echo $file_name_array['comment'];
1322
-					echo '</span><br />';
1323
-				}
1305
+                    $comment['title']
1306
+                ).'\'" title="'.get_lang(
1307
+                    'ReplyToThisComment'
1308
+                ).'" >'.stripslashes($comment['title']).'</a></span>';
1309
+                echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1310
+                echo '<span class="blogpost_text">' . $comment_text . '</span>';
1311
+
1312
+                $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1313
+                if (!empty($file_name_array)) {
1314
+                    echo '<br /><br />';
1315
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1316
+                    echo '<a href="download.php?'.api_get_cidreq().'&file=';
1317
+                    echo $file_name_array['path'];
1318
+                    echo ' "> '.$file_name_array['filename'].' </a>';
1319
+                    echo '<span class="attachment_comment">';
1320
+                    echo $file_name_array['comment'];
1321
+                    echo '</span><br />';
1322
+                }
1324 1323
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1325
-				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1326
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1327
-			echo '</div>';
1328
-
1329
-			// Go further down the tree.
1330
-			Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1331
-		}
1332
-	}
1333
-
1334
-	/**
1335
-	 * Displays the form to create a new post
1336
-	 * @author Toon Keppens
1337
-	 *
1338
-	 * @param Integer $blog_id
1339
-	 */
1340
-	public static function display_form_new_post($blog_id)
1341
-	{
1342
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1343
-			$form = new FormValidator(
1344
-				'add_post',
1345
-				'post',
1346
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1347
-				null,
1348
-				array('enctype' => 'multipart/form-data')
1349
-			);
1350
-			$form->addHidden('post_title_edited', 'false');
1351
-			$form->addHeader(get_lang('NewPost'));
1352
-			$form->addText('title', get_lang('Title'));
1353
-			$config = array();
1354
-			if (!api_is_allowed_to_edit()) {
1355
-				$config['ToolbarSet'] = 'ProjectStudent';
1356
-			} else {
1357
-				$config['ToolbarSet'] = 'Project';
1358
-			}
1359
-			$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1360
-			$form->addFile('user_upload', get_lang('AddAnAttachment'));
1361
-			$form->addTextarea('post_file_comment', get_lang('FileComment'));
1362
-			$form->addHidden('new_post_submit', 'true');
1363
-			$form->addButton('save', get_lang('Save'));
1364
-
1365
-			$form->display();
1366
-		} else {
1367
-			api_not_allowed();
1368
-		}
1369
-	}
1370
-
1371
-	/**
1372
-	 * Displays the form to edit a post
1373
-	 * @author Toon Keppens
1374
-	 *
1375
-	 * @param Integer $blog_id
1376
-	 */
1377
-	public static function display_form_edit_post($blog_id, $post_id)
1378
-	{
1379
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1380
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1381
-
1382
-		$course_id = api_get_course_int_id();
1383
-
1384
-		// Get posts and author
1385
-		$sql = "SELECT post.*, user.lastname, user.firstname
1324
+                echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1325
+                echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1326
+            echo '</div>';
1327
+
1328
+            // Go further down the tree.
1329
+            Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1330
+        }
1331
+    }
1332
+
1333
+    /**
1334
+     * Displays the form to create a new post
1335
+     * @author Toon Keppens
1336
+     *
1337
+     * @param Integer $blog_id
1338
+     */
1339
+    public static function display_form_new_post($blog_id)
1340
+    {
1341
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1342
+            $form = new FormValidator(
1343
+                'add_post',
1344
+                'post',
1345
+                api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1346
+                null,
1347
+                array('enctype' => 'multipart/form-data')
1348
+            );
1349
+            $form->addHidden('post_title_edited', 'false');
1350
+            $form->addHeader(get_lang('NewPost'));
1351
+            $form->addText('title', get_lang('Title'));
1352
+            $config = array();
1353
+            if (!api_is_allowed_to_edit()) {
1354
+                $config['ToolbarSet'] = 'ProjectStudent';
1355
+            } else {
1356
+                $config['ToolbarSet'] = 'Project';
1357
+            }
1358
+            $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1359
+            $form->addFile('user_upload', get_lang('AddAnAttachment'));
1360
+            $form->addTextarea('post_file_comment', get_lang('FileComment'));
1361
+            $form->addHidden('new_post_submit', 'true');
1362
+            $form->addButton('save', get_lang('Save'));
1363
+
1364
+            $form->display();
1365
+        } else {
1366
+            api_not_allowed();
1367
+        }
1368
+    }
1369
+
1370
+    /**
1371
+     * Displays the form to edit a post
1372
+     * @author Toon Keppens
1373
+     *
1374
+     * @param Integer $blog_id
1375
+     */
1376
+    public static function display_form_edit_post($blog_id, $post_id)
1377
+    {
1378
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1379
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1380
+
1381
+        $course_id = api_get_course_int_id();
1382
+
1383
+        // Get posts and author
1384
+        $sql = "SELECT post.*, user.lastname, user.firstname
1386 1385
 				FROM $tbl_blogs_posts post
1387 1386
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1388 1387
 				WHERE
@@ -1390,79 +1389,79 @@  discard block
 block discarded – undo
1390 1389
 				post.blog_id 		= '".(int)$blog_id ."'
1391 1390
 				AND post.post_id	= '".(int)$post_id."'
1392 1391
 				ORDER BY post_id DESC";
1393
-		$result = Database::query($sql);
1394
-		$blog_post = Database::fetch_array($result);
1395
-
1396
-		// Form
1397
-		$form = new FormValidator(
1398
-			'edit_post',
1399
-			'post',
1400
-			api_get_path(WEB_CODE_PATH).'blog/blog.php?'.api_get_cidreq(
1401
-			).'&action=edit_post&post_id='.intval(
1402
-				$_GET['post_id']
1403
-			).'&blog_id='.intval($blog_id).'&article_id='.intval(
1404
-				$_GET['article_id']
1405
-			).'&task_id='.intval($_GET['task_id'])
1406
-		);
1407
-
1408
-		$form->addHeader(get_lang('EditPost'));
1409
-		$form->addText('title', get_lang('Title'));
1410
-
1411
-		if (!api_is_allowed_to_edit()) {
1412
-			$config['ToolbarSet'] = 'ProjectStudent';
1413
-		} else {
1414
-			$config['ToolbarSet'] = 'Project';
1415
-		}
1416
-		$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1417
-
1418
-		$form->addHidden('action', '');
1419
-		$form->addHidden('edit_post_submit', 'true');
1420
-		$form->addHidden('post_id', intval($_GET['post_id']));
1421
-		$form->addButton('save', get_lang('Save'));
1422
-		$form->setDefaults($blog_post);
1423
-		$form->display();
1424
-	}
1425
-
1426
-	/**
1427
-	 * Displays a list of tasks in this blog
1428
-	 * @author Toon Keppens
1429
-	 *
1430
-	 * @param Integer $blog_id
1431
-	 */
1432
-	public static function display_task_list($blog_id)
1392
+        $result = Database::query($sql);
1393
+        $blog_post = Database::fetch_array($result);
1394
+
1395
+        // Form
1396
+        $form = new FormValidator(
1397
+            'edit_post',
1398
+            'post',
1399
+            api_get_path(WEB_CODE_PATH).'blog/blog.php?'.api_get_cidreq(
1400
+            ).'&action=edit_post&post_id='.intval(
1401
+                $_GET['post_id']
1402
+            ).'&blog_id='.intval($blog_id).'&article_id='.intval(
1403
+                $_GET['article_id']
1404
+            ).'&task_id='.intval($_GET['task_id'])
1405
+        );
1406
+
1407
+        $form->addHeader(get_lang('EditPost'));
1408
+        $form->addText('title', get_lang('Title'));
1409
+
1410
+        if (!api_is_allowed_to_edit()) {
1411
+            $config['ToolbarSet'] = 'ProjectStudent';
1412
+        } else {
1413
+            $config['ToolbarSet'] = 'Project';
1414
+        }
1415
+        $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1416
+
1417
+        $form->addHidden('action', '');
1418
+        $form->addHidden('edit_post_submit', 'true');
1419
+        $form->addHidden('post_id', intval($_GET['post_id']));
1420
+        $form->addButton('save', get_lang('Save'));
1421
+        $form->setDefaults($blog_post);
1422
+        $form->display();
1423
+    }
1424
+
1425
+    /**
1426
+     * Displays a list of tasks in this blog
1427
+     * @author Toon Keppens
1428
+     *
1429
+     * @param Integer $blog_id
1430
+     */
1431
+    public static function display_task_list($blog_id)
1433 1432
     {
1434
-		global $charset;
1433
+        global $charset;
1435 1434
         $course_id = api_get_course_int_id();
1436 1435
 
1437
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1438
-			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1439
-			$counter = 0;
1440
-			global $color2;
1436
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1437
+            $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1438
+            $counter = 0;
1439
+            global $color2;
1441 1440
 
1442
-			echo '<div class="actions">';
1443
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">';
1441
+            echo '<div class="actions">';
1442
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">';
1444 1443
             echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks'));
1445 1444
             echo get_lang('AddTasks') . '</a> ';
1446
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">';
1445
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">';
1447 1446
             echo Display::return_icon('blog_task.gif', get_lang('AssignTasks'));
1448 1447
             echo get_lang('AssignTasks') . '</a>';
1449
-			?>
1448
+            ?>
1450 1449
 				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>">
1451 1450
                     <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1452 1451
 			<?php
1453
-			echo '</div>';
1452
+            echo '</div>';
1454 1453
 
1455
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1456
-			echo "<table class=\"data_table\">";
1457
-			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1458
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1459
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1460
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1461
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1462
-				"</tr>\n";
1454
+            echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1455
+            echo "<table class=\"data_table\">";
1456
+            echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1457
+                        "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1458
+                        "<th><b>",get_lang('Description'),"</b></th>\n",
1459
+                        "<th><b>",get_lang('Color'),"</b></th>\n",
1460
+                        "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1461
+                "</tr>\n";
1463 1462
 
1464 1463
 
1465
-			$sql = " SELECT
1464
+            $sql = " SELECT
1466 1465
                         blog_id,
1467 1466
                         task_id,
1468 1467
                         blog_id,
@@ -1473,22 +1472,22 @@  discard block
 block discarded – undo
1473 1472
                     FROM " . $tbl_blogs_tasks . "
1474 1473
                     WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1475 1474
                     ORDER BY system_task, title";
1476
-			$result = Database::query($sql);
1477
-
1478
-
1479
-			while($task = Database::fetch_array($result)) {
1480
-				$counter++;
1481
-				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1482
-				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1483
-				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1484
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1485
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1486
-
1487
-				echo	'<tr class="' . $css_class . '" valign="top">',
1488
-                         '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1489
-                         '<td>' . Security::remove_XSS($task['description']) . '</td>',
1490
-                         '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1491
-                         '<td width="50">',
1475
+            $result = Database::query($sql);
1476
+
1477
+
1478
+            while($task = Database::fetch_array($result)) {
1479
+                $counter++;
1480
+                $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1481
+                $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1482
+                $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1483
+                $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1484
+                $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1485
+
1486
+                echo	'<tr class="' . $css_class . '" valign="top">',
1487
+                            '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1488
+                            '<td>' . Security::remove_XSS($task['description']) . '</td>',
1489
+                            '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1490
+                            '<td width="50">',
1492 1491
                             '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1493 1492
                             '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1494 1493
                             "</a>\n",
@@ -1496,41 +1495,41 @@  discard block
 block discarded – undo
1496 1495
                             $delete_confirm,
1497 1496
                             '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1498 1497
                             "</a>\n",
1499
-                         '</td>',
1498
+                            '</td>',
1500 1499
                     '</tr>';
1501
-			}
1502
-			echo "</table>";
1503
-		}
1504
-	}
1505
-
1506
-	/**
1507
-	 * Displays a list of tasks assigned to a user in this blog
1508
-	 * @author Toon Keppens
1509
-	 *
1510
-	 * @param Integer $blog_id
1511
-	 */
1512
-	public static function display_assigned_task_list ($blog_id)
1500
+            }
1501
+            echo "</table>";
1502
+        }
1503
+    }
1504
+
1505
+    /**
1506
+     * Displays a list of tasks assigned to a user in this blog
1507
+     * @author Toon Keppens
1508
+     *
1509
+     * @param Integer $blog_id
1510
+     */
1511
+    public static function display_assigned_task_list ($blog_id)
1513 1512
     {
1514
-		// Init
1515
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1516
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1517
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1518
-		$counter = 0;
1519
-		global $charset,$color2;
1520
-
1521
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1522
-		echo "<table class=\"data_table\">";
1523
-		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1524
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1525
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1526
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1527
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1528
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1529
-			"</tr>";
1530
-
1531
-		$course_id = api_get_course_int_id();
1532
-
1533
-		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1513
+        // Init
1514
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1515
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1516
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1517
+        $counter = 0;
1518
+        global $charset,$color2;
1519
+
1520
+        echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1521
+        echo "<table class=\"data_table\">";
1522
+        echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1523
+                    "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1524
+                    "<th><b>",get_lang('Task'),"</b></th>\n",
1525
+                    "<th><b>",get_lang('Description'),"</b></th>\n",
1526
+                    "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1527
+                    "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1528
+            "</tr>";
1529
+
1530
+        $course_id = api_get_course_int_id();
1531
+
1532
+        $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1534 1533
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
1535 1534
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
1536 1535
 				INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
@@ -1539,45 +1538,45 @@  discard block
 block discarded – undo
1539 1538
 					task.c_id = $course_id AND
1540 1539
 					task_rel_user.blog_id = '".(int)$blog_id."'
1541 1540
 				ORDER BY target_date ASC";
1542
-		$result = Database::query($sql);
1541
+        $result = Database::query($sql);
1543 1542
 
1544
-		while ($assignment = Database::fetch_array($result)) {
1545
-			$counter++;
1546
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1547
-			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1548
-			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1549
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1550
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1543
+        while ($assignment = Database::fetch_array($result)) {
1544
+            $counter++;
1545
+            $css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1546
+            $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1547
+            $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1548
+            $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1549
+            $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1551 1550
 
1552 1551
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1553 1552
 
1554
-			echo	'<tr class="' . $css_class . '" valign="top">',
1555
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1556
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1557
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1558
-						 '<td>' . $assignment['target_date'] . '</td>',
1559
-						 '<td width="50">',
1560
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1561
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1562
-							"</a>\n",
1563
-							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1564
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1565
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1566
-							"</a>\n",
1567
-						 '</td>',
1568
-					'</tr>';
1569
-		}
1570
-		echo "</table>";
1571
-	}
1572
-
1573
-	/**
1574
-	 * Displays new task form
1575
-	 * @author Toon Keppens
1576
-	 *
1577
-	 */
1578
-	public static function display_new_task_form ($blog_id)
1579
-	{
1580
-		// Init
1553
+            echo	'<tr class="' . $css_class . '" valign="top">',
1554
+                            '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1555
+                            '<td>'.stripslashes($assignment['title']) . '</td>',
1556
+                            '<td>'.stripslashes($assignment['description']) . '</td>',
1557
+                            '<td>' . $assignment['target_date'] . '</td>',
1558
+                            '<td width="50">',
1559
+                                '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1560
+                            '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1561
+                            "</a>\n",
1562
+                            '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1563
+                            'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1564
+                            '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1565
+                            "</a>\n",
1566
+                            '</td>',
1567
+                    '</tr>';
1568
+        }
1569
+        echo "</table>";
1570
+    }
1571
+
1572
+    /**
1573
+     * Displays new task form
1574
+     * @author Toon Keppens
1575
+     *
1576
+     */
1577
+    public static function display_new_task_form ($blog_id)
1578
+    {
1579
+        // Init
1581 1580
         $colors = array(
1582 1581
             'FFFFFF',
1583 1582
             'FFFF99',
@@ -1596,15 +1595,15 @@  discard block
 block discarded – undo
1596 1595
             '000000'
1597 1596
         );
1598 1597
 
1599
-		// form
1600
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq(
1601
-			).'">';
1598
+        // form
1599
+        echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq(
1600
+            ).'">';
1602 1601
 
1603
-		// form title
1604
-		echo '<legend>'.get_lang('AddTask').'</legend>';
1602
+        // form title
1603
+        echo '<legend>'.get_lang('AddTask').'</legend>';
1605 1604
 
1606
-		// task title
1607
-		echo '	<div class="control-group">
1605
+        // task title
1606
+        echo '	<div class="control-group">
1608 1607
 					<label class="control-label">
1609 1608
 						<span class="form_required">*</span>' . get_lang('Title') . '
1610 1609
 					</label>
@@ -1613,8 +1612,8 @@  discard block
 block discarded – undo
1613 1612
 					</div>
1614 1613
 				</div>';
1615 1614
 
1616
-		// task comment
1617
-		echo '	<div class="control-group">
1615
+        // task comment
1616
+        echo '	<div class="control-group">
1618 1617
 					<label class="control-label">
1619 1618
 						' . get_lang('Description') . '
1620 1619
 					</label>
@@ -1623,8 +1622,8 @@  discard block
 block discarded – undo
1623 1622
 					</div>
1624 1623
 				</div>';
1625 1624
 
1626
-		// task management
1627
-		echo '	<div class="control-group">
1625
+        // task management
1626
+        echo '	<div class="control-group">
1628 1627
 					<label class="control-label">
1629 1628
 						' . get_lang('TaskManager') . '
1630 1629
 					</label>
@@ -1645,12 +1644,12 @@  discard block
 block discarded – undo
1645 1644
                         echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1646 1645
                     echo '</tr>';
1647 1646
                 echo '</table>';
1648
-		echo '		</div>
1647
+        echo '		</div>
1649 1648
 				</div>';
1650 1649
 
1651 1650
 
1652
-		// task color
1653
-		echo '	<div class="control-group">
1651
+        // task color
1652
+        echo '	<div class="control-group">
1654 1653
 					<label class="control-label">
1655 1654
 						' . get_lang('Color') . '
1656 1655
 					</label>
@@ -1661,124 +1660,124 @@  discard block
 block discarded – undo
1661 1660
                     echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1662 1661
                 }
1663 1662
         echo '</select>';
1664
-		echo '		</div>
1663
+        echo '		</div>
1665 1664
 				</div>';
1666 1665
 
1667
-		// submit
1668
-		echo '	<div class="control-group">
1666
+        // submit
1667
+        echo '	<div class="control-group">
1669 1668
 					<div class="controls">
1670 1669
 							<input type="hidden" name="action" value="" />
1671 1670
 							<input type="hidden" name="new_task_submit" value="true" />
1672 1671
 						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1673 1672
 					</div>
1674 1673
 				</div>';
1675
-		echo '</form>';
1674
+        echo '</form>';
1676 1675
 
1677
-		echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1678
-	}
1676
+        echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1677
+    }
1679 1678
 
1680 1679
 
1681
-	/**
1682
-	 * Displays edit task form
1683
-	 * @author Toon Keppens
1684
-	 *
1685
-	 */
1686
-	public static function display_edit_task_form ($blog_id, $task_id) {
1687
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1680
+    /**
1681
+     * Displays edit task form
1682
+     * @author Toon Keppens
1683
+     *
1684
+     */
1685
+    public static function display_edit_task_form ($blog_id, $task_id) {
1686
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1688 1687
         $course_id = api_get_course_int_id();
1689 1688
 
1690
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1689
+        $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1691 1690
 
1692
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks
1691
+        $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks
1693 1692
 				WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1694
-		$result = Database::query($sql);
1695
-		$task = Database::fetch_array($result);
1693
+        $result = Database::query($sql);
1694
+        $task = Database::fetch_array($result);
1696 1695
 
1697
-		// Display
1698
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq(
1699
-			).'">
1696
+        // Display
1697
+        echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq(
1698
+            ).'">
1700 1699
 				<legend>'.get_lang('EditTask').'</legend>
1701 1700
 				<table width="100%" border="0" cellspacing="2">
1702 1701
 					<tr>
1703 1702
 				   <td align="right">'.get_lang('Title').':&nbsp;&nbsp;</td>
1704 1703
 				   <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS(
1705
-				$task['title']
1706
-			).'" /></td>
1704
+                $task['title']
1705
+            ).'" /></td>
1707 1706
 					</tr>
1708 1707
 					<tr>
1709 1708
 				   <td align="right">'.get_lang('Description').':&nbsp;&nbsp;</td>
1710 1709
 				   <td><textarea name="task_description" cols="45">'.Security::remove_XSS(
1711
-				$task['description']
1712
-			).'</textarea></td>
1710
+                $task['description']
1711
+            ).'</textarea></td>
1713 1712
 					</tr>';
1714 1713
 
1715
-		/* edit by Kevin Van Den Haute ([email protected]) */
1716
-		$tbl_tasks_permissions = Database::get_course_table(
1717
-			TABLE_BLOGS_TASKS_PERMISSIONS
1718
-		);
1714
+        /* edit by Kevin Van Den Haute ([email protected]) */
1715
+        $tbl_tasks_permissions = Database::get_course_table(
1716
+            TABLE_BLOGS_TASKS_PERMISSIONS
1717
+        );
1719 1718
 
1720
-		$sql = " SELECT id, action FROM ".$tbl_tasks_permissions."
1719
+        $sql = " SELECT id, action FROM ".$tbl_tasks_permissions."
1721 1720
 							 WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1722
-		$result = Database::query($sql);
1723
-
1724
-		$arrPermissions = array();
1725
-
1726
-		while ($row = Database::fetch_array($result)) {
1727
-			$arrPermissions[] = $row['action'];
1728
-		}
1729
-
1730
-		echo '<tr>';
1731
-		echo '<td style="text-align:right; vertical-align:top;">'.get_lang(
1732
-				'TaskManager'
1733
-			).':&nbsp;&nbsp;</td>';
1734
-		echo '<td>';
1735
-		echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1736
-		echo '<tr>';
1737
-		echo '<th colspan="2" style="width:223px;">'.get_lang(
1738
-				'ArticleManager'
1739
-			).'</th>';
1740
-		echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1741
-		echo '</tr>';
1742
-		echo '<tr>';
1743
-		echo '<th style="width:111px;"><label for="articleDelete">'.get_lang(
1744
-				'Delete'
1745
-			).'</label></th>';
1746
-		echo '<th style="width:112px;"><label for="articleEdit">'.get_lang(
1747
-				'Edit'
1748
-			).'</label></th>';
1749
-		echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang(
1750
-				'Delete'
1751
-			).'</label></th>';
1752
-		echo '</tr>';
1753
-		echo '<tr>';
1754
-		echo '<td style="text-align:center;"><input '.((in_array(
1755
-				'article_delete',
1756
-				$arrPermissions
1757
-			)) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1758
-		echo '<td style="text-align:center;"><input '.((in_array(
1759
-				'article_edit',
1760
-				$arrPermissions
1761
-			)) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1762
-		echo '<td style="text-align:center;"><input '.((in_array(
1763
-				'article_comments_delete',
1764
-				$arrPermissions
1765
-			)) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1766
-		echo '</tr>';
1767
-		echo '</table>';
1768
-		echo '</td>';
1769
-		echo '</tr>';
1770
-		/* end of edit */
1771
-
1772
-		echo '<tr>
1721
+        $result = Database::query($sql);
1722
+
1723
+        $arrPermissions = array();
1724
+
1725
+        while ($row = Database::fetch_array($result)) {
1726
+            $arrPermissions[] = $row['action'];
1727
+        }
1728
+
1729
+        echo '<tr>';
1730
+        echo '<td style="text-align:right; vertical-align:top;">'.get_lang(
1731
+                'TaskManager'
1732
+            ).':&nbsp;&nbsp;</td>';
1733
+        echo '<td>';
1734
+        echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1735
+        echo '<tr>';
1736
+        echo '<th colspan="2" style="width:223px;">'.get_lang(
1737
+                'ArticleManager'
1738
+            ).'</th>';
1739
+        echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1740
+        echo '</tr>';
1741
+        echo '<tr>';
1742
+        echo '<th style="width:111px;"><label for="articleDelete">'.get_lang(
1743
+                'Delete'
1744
+            ).'</label></th>';
1745
+        echo '<th style="width:112px;"><label for="articleEdit">'.get_lang(
1746
+                'Edit'
1747
+            ).'</label></th>';
1748
+        echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang(
1749
+                'Delete'
1750
+            ).'</label></th>';
1751
+        echo '</tr>';
1752
+        echo '<tr>';
1753
+        echo '<td style="text-align:center;"><input '.((in_array(
1754
+                'article_delete',
1755
+                $arrPermissions
1756
+            )) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1757
+        echo '<td style="text-align:center;"><input '.((in_array(
1758
+                'article_edit',
1759
+                $arrPermissions
1760
+            )) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1761
+        echo '<td style="text-align:center;"><input '.((in_array(
1762
+                'article_comments_delete',
1763
+                $arrPermissions
1764
+            )) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1765
+        echo '</tr>';
1766
+        echo '</table>';
1767
+        echo '</td>';
1768
+        echo '</tr>';
1769
+        /* end of edit */
1770
+
1771
+        echo '<tr>
1773 1772
 				   <td align="right">'.get_lang('Color').':&nbsp;&nbsp;</td>
1774 1773
 				   <td>
1775 1774
 					<select name="task_color" id="color" style="width: 150px; background-color: #'.$task['color'].'" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
1776
-		foreach ($colors as $color) {
1777
-			$selected = ($color == $task['color']) ? ' selected' : '';
1778
-			$style = 'style="background-color: #'.$color.'"';
1779
-			echo '<option value="'.$color.'" '.$style.' '.$selected.' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1780
-		}
1781
-		echo '			   </select>
1775
+        foreach ($colors as $color) {
1776
+            $selected = ($color == $task['color']) ? ' selected' : '';
1777
+            $style = 'style="background-color: #'.$color.'"';
1778
+            echo '<option value="'.$color.'" '.$style.' '.$selected.' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1779
+        }
1780
+        echo '			   </select>
1782 1781
 					  </td>
1783 1782
 					</tr>
1784 1783
 					<tr>
@@ -1788,39 +1787,39 @@  discard block
 block discarded – undo
1788 1787
 						<input type="hidden" name="task_id" value="'.$task['task_id'].'" />
1789 1788
 						<input type="hidden" name="blog_id" value="'.$task['blog_id'].'" />
1790 1789
 						<button class="save" type="submit" name="Submit">'.get_lang(
1791
-				'Save'
1792
-			).'</button></td>
1790
+                'Save'
1791
+            ).'</button></td>
1793 1792
 					</tr>
1794 1793
 				</table>
1795 1794
 			</form>';
1796
-	}
1797
-
1798
-	/**
1799
-	 * @param $blog_id
1800
-	 * @return FormValidator
1801
-	 */
1802
-	public static function getTaskForm($blog_id)
1803
-	{
1804
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1805
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1806
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1807
-		$course_id = api_get_course_int_id();
1808
-
1809
-		// Get users in this blog / make select list of it
1810
-		$sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1795
+    }
1796
+
1797
+    /**
1798
+     * @param $blog_id
1799
+     * @return FormValidator
1800
+     */
1801
+    public static function getTaskForm($blog_id)
1802
+    {
1803
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1804
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1805
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1806
+        $course_id = api_get_course_int_id();
1807
+
1808
+        // Get users in this blog / make select list of it
1809
+        $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1811 1810
 				FROM $tbl_users user
1812 1811
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1813 1812
 				ON user.user_id = blogs_rel_user.user_id
1814 1813
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1815
-		$result = Database::query($sql);
1814
+        $result = Database::query($sql);
1816 1815
 
1817
-		$options = array();
1818
-		while ($user = Database::fetch_array($result)) {
1819
-			$options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1820
-		}
1816
+        $options = array();
1817
+        while ($user = Database::fetch_array($result)) {
1818
+            $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1819
+        }
1821 1820
 
1822
-		// Get tasks in this blog / make select list of it
1823
-		$sql = "
1821
+        // Get tasks in this blog / make select list of it
1822
+        $sql = "
1824 1823
 			SELECT
1825 1824
 				blog_id,
1826 1825
 				task_id,
@@ -1832,96 +1831,96 @@  discard block
 block discarded – undo
1832 1831
 			FROM $tbl_blogs_tasks
1833 1832
 			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1834 1833
 			ORDER BY system_task, title";
1835
-		$result = Database::query($sql);
1836
-
1837
-		$taskOptions = array();
1838
-		while ($task = Database::fetch_array($result)) {
1839
-			$taskOptions[$task['task_id']] = stripslashes($task['title']);
1840
-		}
1841
-
1842
-		$form = new FormValidator(
1843
-			'assign_task',
1844
-			'post',
1845
-			api_get_path(WEB_CODE_PATH).
1846
-			'blog/blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq()
1847
-		);
1848
-
1849
-		$form->addHeader(get_lang('AssignTask'));
1850
-		$form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1851
-		$form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1852
-		$form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1853
-
1854
-		$form->addHidden('action', '');
1855
-		$form->addButtonSave(get_lang('Ok'));
1856
-
1857
-		return $form;
1858
-	}
1859
-
1860
-	/**
1861
-	 * Displays assign task form
1862
-	 * @author Toon Keppens
1863
-	 *
1864
-	 */
1865
-	public static function display_assign_task_form($blog_id)
1866
-	{
1867
-		$form = self::getTaskForm($blog_id);
1868
-		$form->addHidden('assign_task_submit', 'true');
1869
-		$form->display();
1870
-		echo '<div style="clear: both; margin-bottom:10px;"></div>';
1871
-	}
1872
-
1873
-	/**
1874
-	 * Displays assign task form
1875
-	 * @author Toon Keppens
1876
-	 *
1877
-	 */
1878
-	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1879
-	{
1880
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1881
-
1882
-		$course_id = api_get_course_int_id();
1883
-
1884
-		// Get assignd date;
1885
-		$sql = "
1834
+        $result = Database::query($sql);
1835
+
1836
+        $taskOptions = array();
1837
+        while ($task = Database::fetch_array($result)) {
1838
+            $taskOptions[$task['task_id']] = stripslashes($task['title']);
1839
+        }
1840
+
1841
+        $form = new FormValidator(
1842
+            'assign_task',
1843
+            'post',
1844
+            api_get_path(WEB_CODE_PATH).
1845
+            'blog/blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq()
1846
+        );
1847
+
1848
+        $form->addHeader(get_lang('AssignTask'));
1849
+        $form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1850
+        $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1851
+        $form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1852
+
1853
+        $form->addHidden('action', '');
1854
+        $form->addButtonSave(get_lang('Ok'));
1855
+
1856
+        return $form;
1857
+    }
1858
+
1859
+    /**
1860
+     * Displays assign task form
1861
+     * @author Toon Keppens
1862
+     *
1863
+     */
1864
+    public static function display_assign_task_form($blog_id)
1865
+    {
1866
+        $form = self::getTaskForm($blog_id);
1867
+        $form->addHidden('assign_task_submit', 'true');
1868
+        $form->display();
1869
+        echo '<div style="clear: both; margin-bottom:10px;"></div>';
1870
+    }
1871
+
1872
+    /**
1873
+     * Displays assign task form
1874
+     * @author Toon Keppens
1875
+     *
1876
+     */
1877
+    public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1878
+    {
1879
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1880
+
1881
+        $course_id = api_get_course_int_id();
1882
+
1883
+        // Get assignd date;
1884
+        $sql = "
1886 1885
 			SELECT target_date
1887 1886
 			FROM $tbl_blogs_tasks_rel_user
1888 1887
 			WHERE c_id = $course_id AND
1889 1888
 			      blog_id = '".(int)$blog_id."' AND
1890 1889
 			      user_id = '".(int)$user_id."' AND
1891 1890
 			      task_id = '".(int)$task_id."'";
1892
-		$result = Database::query($sql);
1893
-		$row = Database::fetch_assoc($result);
1894
-
1895
-		$date = $row['target_date'];
1896
-
1897
-		$defaults = [
1898
-			'task_user_id' => $user_id,
1899
-			'task_task_id' => $task_id,
1900
-			'task_day' => $date
1901
-		];
1902
-		$form = self::getTaskForm($blog_id);
1903
-		$form->addHidden('old_task_id', $task_id);
1904
-		$form->addHidden('old_user_id', $user_id);
1905
-		$form->addHidden('old_target_date', $date);
1906
-		$form->addHidden('assign_task_edit_submit', 'true');
1907
-		$form->setDefaults($defaults);
1908
-		$form->display();
1909
-	}
1910
-
1911
-	/**
1912
-	 * Assigns a task to a user in a blog
1913
-	 *
1914
-	 * @param Integer $blog_id
1915
-	 * @param Integer $user_id
1916
-	 * @param Integer $task_id
1917
-	 * @param Date $target_date
1918
-	 */
1919
-	public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1920
-	{
1921
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1922
-		$course_id = api_get_course_int_id();
1923
-
1924
-		$sql = "
1891
+        $result = Database::query($sql);
1892
+        $row = Database::fetch_assoc($result);
1893
+
1894
+        $date = $row['target_date'];
1895
+
1896
+        $defaults = [
1897
+            'task_user_id' => $user_id,
1898
+            'task_task_id' => $task_id,
1899
+            'task_day' => $date
1900
+        ];
1901
+        $form = self::getTaskForm($blog_id);
1902
+        $form->addHidden('old_task_id', $task_id);
1903
+        $form->addHidden('old_user_id', $user_id);
1904
+        $form->addHidden('old_target_date', $date);
1905
+        $form->addHidden('assign_task_edit_submit', 'true');
1906
+        $form->setDefaults($defaults);
1907
+        $form->display();
1908
+    }
1909
+
1910
+    /**
1911
+     * Assigns a task to a user in a blog
1912
+     *
1913
+     * @param Integer $blog_id
1914
+     * @param Integer $user_id
1915
+     * @param Integer $task_id
1916
+     * @param Date $target_date
1917
+     */
1918
+    public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1919
+    {
1920
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1921
+        $course_id = api_get_course_int_id();
1922
+
1923
+        $sql = "
1925 1924
 			SELECT COUNT(*) as 'number'
1926 1925
 			FROM " . $tbl_blogs_tasks_rel_user . "
1927 1926
 			WHERE c_id = $course_id AND
@@ -1930,11 +1929,11 @@  discard block
 block discarded – undo
1930 1929
 			AND	task_id = " . (int)$task_id . "
1931 1930
 		";
1932 1931
 
1933
-		$result = Database::query($sql);
1934
-		$row = Database::fetch_assoc($result);
1932
+        $result = Database::query($sql);
1933
+        $row = Database::fetch_assoc($result);
1935 1934
 
1936
-		if ($row['number'] == 0) {
1937
-			$sql = "
1935
+        if ($row['number'] == 0) {
1936
+            $sql = "
1938 1937
 				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1939 1938
 					c_id,
1940 1939
 					blog_id,
@@ -1949,9 +1948,9 @@  discard block
 block discarded – undo
1949 1948
 					'" . Database::escape_string($target_date) . "'
1950 1949
 				)";
1951 1950
 
1952
-			Database::query($sql);
1953
-		}
1954
-	}
1951
+            Database::query($sql);
1952
+        }
1953
+    }
1955 1954
 
1956 1955
     /**
1957 1956
      * @param $blog_id
@@ -1971,11 +1970,11 @@  discard block
 block discarded – undo
1971 1970
         $old_task_id,
1972 1971
         $old_target_date
1973 1972
     ) {
1974
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1973
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1975 1974
 
1976
-		$course_id = api_get_course_int_id();
1975
+        $course_id = api_get_course_int_id();
1977 1976
 
1978
-		$sql = "SELECT COUNT(*) as 'number'
1977
+        $sql = "SELECT COUNT(*) as 'number'
1979 1978
                 FROM " . $tbl_blogs_tasks_rel_user . "
1980 1979
                 WHERE
1981 1980
                     c_id = $course_id AND
@@ -1984,11 +1983,11 @@  discard block
 block discarded – undo
1984 1983
                     task_id = " . (int)$task_id . "
1985 1984
             ";
1986 1985
 
1987
-		$result = Database::query($sql);
1988
-		$row = Database::fetch_assoc($result);
1986
+        $result = Database::query($sql);
1987
+        $row = Database::fetch_assoc($result);
1989 1988
 
1990
-		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1991
-			$sql = "
1989
+        if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1990
+            $sql = "
1992 1991
 				UPDATE " . $tbl_blogs_tasks_rel_user . "
1993 1992
 				SET
1994 1993
 					user_id = " . (int)$user_id . ",
@@ -2001,90 +2000,90 @@  discard block
 block discarded – undo
2001 2000
 					task_id = " . (int)$old_task_id . " AND
2002 2001
 					target_date = '" . Database::escape_string($old_target_date) . "'
2003 2002
 			";
2004
-			Database::query($sql);
2005
-		}
2006
-	}
2007
-
2008
-	/**
2009
-	 * Displays a list with posts a user can select to execute his task.
2010
-	 *
2011
-	 * @param Integer $blog_id
2012
-	 * @param unknown_type $task_id
2013
-	 */
2014
-	public static function display_select_task_post($blog_id, $task_id)
2003
+            Database::query($sql);
2004
+        }
2005
+    }
2006
+
2007
+    /**
2008
+     * Displays a list with posts a user can select to execute his task.
2009
+     *
2010
+     * @param Integer $blog_id
2011
+     * @param unknown_type $task_id
2012
+     */
2013
+    public static function display_select_task_post($blog_id, $task_id)
2015 2014
     {
2016
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2017
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2018
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2019
-		$course_id = api_get_course_int_id();
2015
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2016
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2017
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2018
+        $course_id = api_get_course_int_id();
2020 2019
 
2021 2020
 
2022
-		$sql = "SELECT title, description FROM $tbl_blogs_tasks
2021
+        $sql = "SELECT title, description FROM $tbl_blogs_tasks
2023 2022
 				WHERE task_id = '".(int)$task_id."'
2024 2023
 				AND c_id = $course_id";
2025
-		$result = Database::query($sql);
2026
-		$row = Database::fetch_assoc($result);
2027
-		// Get posts and authors
2028
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
2024
+        $result = Database::query($sql);
2025
+        $row = Database::fetch_assoc($result);
2026
+        // Get posts and authors
2027
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
2029 2028
 				FROM $tbl_blogs_posts post
2030 2029
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
2031 2030
 				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
2032 2031
 				ORDER BY post_id DESC
2033 2032
 				LIMIT 0, 100";
2034
-		$result = Database::query($sql);
2035
-
2036
-		// Display
2037
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
2038
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
2039
-
2040
-		if (Database::num_rows($result) > 0) {
2041
-			while($blog_post = Database::fetch_array($result)) {
2042
-			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
2043
-				echo '<a href="blog.php?'.api_get_cidreq(
2044
-					).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.
2045
-					stripslashes($blog_post['title']).'</a>, '.get_lang(
2046
-						'WrittenBy'
2047
-					).' '.
2048
-					stripslashes(
2049
-						Display::tag(
2050
-							'span',
2051
-							api_get_person_name(
2052
-								$blog_post['firstname'],
2053
-								$blog_post['lastname']
2054
-							),
2055
-							array('title' => $username)
2056
-						)
2057
-					).'<br />';
2058
-			}
2033
+        $result = Database::query($sql);
2034
+
2035
+        // Display
2036
+        echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
2037
+        echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
2038
+
2039
+        if (Database::num_rows($result) > 0) {
2040
+            while($blog_post = Database::fetch_array($result)) {
2041
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
2042
+                echo '<a href="blog.php?'.api_get_cidreq(
2043
+                    ).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.
2044
+                    stripslashes($blog_post['title']).'</a>, '.get_lang(
2045
+                        'WrittenBy'
2046
+                    ).' '.
2047
+                    stripslashes(
2048
+                        Display::tag(
2049
+                            'span',
2050
+                            api_get_person_name(
2051
+                                $blog_post['firstname'],
2052
+                                $blog_post['lastname']
2053
+                            ),
2054
+                            array('title' => $username)
2055
+                        )
2056
+                    ).'<br />';
2057
+            }
2059 2058
         } else {
2060 2059
             echo get_lang('NoArticles');
2061 2060
         }
2062
-	}
2063
-
2064
-	/**
2065
-	 * Subscribes a user to a given blog
2066
-	 * @author Toon Keppens
2067
-	 *
2068
-	 * @param Integer $blog_id
2069
-	 * @param Integer $user_id
2070
-	 */
2071
-	public static function set_user_subscribed($blog_id, $user_id)
2061
+    }
2062
+
2063
+    /**
2064
+     * Subscribes a user to a given blog
2065
+     * @author Toon Keppens
2066
+     *
2067
+     * @param Integer $blog_id
2068
+     * @param Integer $user_id
2069
+     */
2070
+    public static function set_user_subscribed($blog_id, $user_id)
2072 2071
     {
2073
-		// Init
2074
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2075
-		$tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
2072
+        // Init
2073
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2074
+        $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
2076 2075
 
2077
-		$course_id = api_get_course_int_id();
2076
+        $course_id = api_get_course_int_id();
2078 2077
 
2079
-		// Subscribe the user
2080
-		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
2078
+        // Subscribe the user
2079
+        $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
2081 2080
 		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
2082
-		Database::query($sql);
2081
+        Database::query($sql);
2083 2082
 
2084
-		// Give this user basic rights
2085
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2083
+        // Give this user basic rights
2084
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2086 2085
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
2087
-		Database::query($sql);
2086
+        Database::query($sql);
2088 2087
 
2089 2088
         $id = Database::insert_id();
2090 2089
         if ($id) {
@@ -2092,9 +2091,9 @@  discard block
 block discarded – undo
2092 2091
             Database::query($sql);
2093 2092
         }
2094 2093
 
2095
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2094
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2096 2095
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
2097
-		Database::query($sql);
2096
+        Database::query($sql);
2098 2097
 
2099 2098
         $id = Database::insert_id();
2100 2099
         if ($id) {
@@ -2102,202 +2101,202 @@  discard block
 block discarded – undo
2102 2101
             Database::query($sql);
2103 2102
         }
2104 2103
 
2105
-	}
2104
+    }
2106 2105
 
2107
-	/**
2108
-	 * Unsubscribe a user from a given blog
2109
-	 * @author Toon Keppens
2110
-	 *
2111
-	 * @param Integer $blog_id
2112
-	 * @param Integer $user_id
2113
-	 */
2114
-	public static function set_user_unsubscribed($blog_id, $user_id)
2106
+    /**
2107
+     * Unsubscribe a user from a given blog
2108
+     * @author Toon Keppens
2109
+     *
2110
+     * @param Integer $blog_id
2111
+     * @param Integer $user_id
2112
+     */
2113
+    public static function set_user_unsubscribed($blog_id, $user_id)
2115 2114
     {
2116
-		// Init
2115
+        // Init
2117 2116
         $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2118 2117
         $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
2119 2118
 
2120
-		// Unsubscribe the user
2121
-		$sql = "DELETE FROM $tbl_blogs_rel_user
2119
+        // Unsubscribe the user
2120
+        $sql = "DELETE FROM $tbl_blogs_rel_user
2122 2121
 		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
2123
-		Database::query($sql);
2122
+        Database::query($sql);
2124 2123
 
2125
-		// Remove this user's permissions.
2126
-		$sql = "DELETE FROM $tbl_user_permissions
2124
+        // Remove this user's permissions.
2125
+        $sql = "DELETE FROM $tbl_user_permissions
2127 2126
 		        WHERE user_id = '".(int)$user_id."'";
2128
-		Database::query($sql);
2129
-	}
2130
-
2131
-	/**
2132
-	 * Displays the form to register users in a blog (in a course)
2133
-	 * The listed users are users subcribed in the course.
2134
-	 * @author Toon Keppens
2135
-	 *
2136
-	 * @param Integer $blog_id
2137
-	 *
2138
-	 * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2139
-	 */
2140
-	public static function display_form_user_subscribe($blog_id)
2141
-	{
2142
-		$_course = api_get_course_info();
2143
-		$is_western_name_order = api_is_western_name_order();
2144
-		$session_id = api_get_session_id();
2145
-		$course_id = $_course['real_id'];
2146
-
2147
-		$currentCourse = $_course['code'];
2148
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2149
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2150
-
2151
-		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2152
-
2153
-		$properties["width"] = "100%";
2154
-
2155
-		// Get blog members' id.
2156
-		$sql = "SELECT user.user_id FROM $tbl_users user
2127
+        Database::query($sql);
2128
+    }
2129
+
2130
+    /**
2131
+     * Displays the form to register users in a blog (in a course)
2132
+     * The listed users are users subcribed in the course.
2133
+     * @author Toon Keppens
2134
+     *
2135
+     * @param Integer $blog_id
2136
+     *
2137
+     * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2138
+     */
2139
+    public static function display_form_user_subscribe($blog_id)
2140
+    {
2141
+        $_course = api_get_course_info();
2142
+        $is_western_name_order = api_is_western_name_order();
2143
+        $session_id = api_get_session_id();
2144
+        $course_id = $_course['real_id'];
2145
+
2146
+        $currentCourse = $_course['code'];
2147
+        $tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2148
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2149
+
2150
+        echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2151
+
2152
+        $properties["width"] = "100%";
2153
+
2154
+        // Get blog members' id.
2155
+        $sql = "SELECT user.user_id FROM $tbl_users user
2157 2156
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2158 2157
 				ON user.user_id = blogs_rel_user.user_id
2159 2158
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'";
2160
-		$result = Database::query($sql);
2161
-
2162
-		$blog_member_ids = array();
2163
-		while($user = Database::fetch_array($result)) {
2164
-			$blog_member_ids[] = $user['user_id'];
2165
-		}
2166
-
2167
-		// Set table headers
2168
-		$column_header[] = array ('', false, '');
2169
-		if ($is_western_name_order) {
2170
-			$column_header[] = array(get_lang('FirstName'), true, '');
2171
-			$column_header[] = array(get_lang('LastName'), true, '');
2172
-		} else {
2173
-			$column_header[] = array(get_lang('LastName'), true, '');
2174
-			$column_header[] = array(get_lang('FirstName'), true, '');
2175
-		}
2176
-		$column_header[] = array(get_lang('Email'), false, '');
2177
-		$column_header[] = array(get_lang('Register'), false, '');
2159
+        $result = Database::query($sql);
2160
+
2161
+        $blog_member_ids = array();
2162
+        while($user = Database::fetch_array($result)) {
2163
+            $blog_member_ids[] = $user['user_id'];
2164
+        }
2165
+
2166
+        // Set table headers
2167
+        $column_header[] = array ('', false, '');
2168
+        if ($is_western_name_order) {
2169
+            $column_header[] = array(get_lang('FirstName'), true, '');
2170
+            $column_header[] = array(get_lang('LastName'), true, '');
2171
+        } else {
2172
+            $column_header[] = array(get_lang('LastName'), true, '');
2173
+            $column_header[] = array(get_lang('FirstName'), true, '');
2174
+        }
2175
+        $column_header[] = array(get_lang('Email'), false, '');
2176
+        $column_header[] = array(get_lang('Register'), false, '');
2178 2177
 
2179 2178
         $student_list = CourseManager:: get_student_list_from_course_code(
2180 2179
             $currentCourse,
2181 2180
             false,
2182 2181
             $session_id
2183 2182
         );
2184
-		$user_data = array();
2185
-
2186
-		// Add users that are not in this blog to the list.
2187
-		foreach ($student_list as $key=>$user) {
2188
-			if(isset($user['id_user'])) {
2189
-				$user['user_id'] = $user['id_user'];
2190
-			}
2191
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2192
-				$a_infosUser = api_get_user_info($user['user_id']);
2193
-				$row = array ();
2194
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2195
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2196
-				if ($is_western_name_order) {
2197
-					$row[] = $a_infosUser["firstname"];
2198
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2199
-				} else {
2200
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2201
-					$row[] = $a_infosUser["firstname"];
2202
-				}
2203
-				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2204
-
2205
-				//Link to register users
2206
-				$currentUserId = api_get_user_id();
2207
-				if ($a_infosUser["user_id"] != $currentUserId) {
2208
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2209
-				} else {
2210
-					$row[] = '';
2211
-				}
2212
-				$user_data[] = $row;
2213
-			}
2214
-		}
2215
-
2216
-		// Display
2217
-		$query_vars['action'] = 'manage_members';
2218
-		$query_vars['blog_id'] = $blog_id;
2219
-		echo '<form method="post" action="blog.php?'.api_get_cidreq(
2220
-			).'&action=manage_members&blog_id='.$blog_id.'">';
2221
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2222
-			$link = '';
2223
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2224
-			$link .= "blog_id=$blog_id&";
2225
-
2226
-		echo '<a href="blog.php?'.api_get_cidreq(
2227
-			).'&'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - ';
2228
-		echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2229
-				'UnSelectAll'
2230
-			).'</a> ';
2231
-			echo get_lang('WithSelected') . ' : ';
2232
-			echo '<select name="action">';
2233
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2234
-			echo '</select>';
2235
-			echo '<input type="hidden" name="register" value="true" />';
2236
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2237
-		echo '</form>';
2238
-	}
2239
-
2240
-	/**
2241
-	 * Displays the form to register users in a blog (in a course)
2242
-	 * The listed users are users subcribed in the course.
2243
-	 * @author Toon Keppens
2244
-	 *
2245
-	 * @param Integer $blog_id
2246
-	 *
2247
-	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2248
-	 */
2249
-	public static function display_form_user_unsubscribe ($blog_id)
2250
-	{
2251
-		$_user = api_get_user_info();
2252
-		$is_western_name_order = api_is_western_name_order();
2253
-
2254
-		// Init
2255
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2256
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2257
-
2258
-		echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2259
-
2260
-		$properties["width"] = "100%";
2261
-		//table column titles
2262
-		$column_header[] = array ('', false, '');
2263
-		if ($is_western_name_order) {
2264
-			$column_header[] = array (get_lang('FirstName'), true, '');
2265
-			$column_header[] = array (get_lang('LastName'), true, '');
2266
-		} else {
2267
-			$column_header[] = array (get_lang('LastName'), true, '');
2268
-			$column_header[] = array (get_lang('FirstName'), true, '');
2269
-		}
2270
-		$column_header[] = array (get_lang('Email'), false, '');
2271
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2272
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2273
-
2274
-		$course_id = api_get_course_int_id();
2275
-
2276
-		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2183
+        $user_data = array();
2184
+
2185
+        // Add users that are not in this blog to the list.
2186
+        foreach ($student_list as $key=>$user) {
2187
+            if(isset($user['id_user'])) {
2188
+                $user['user_id'] = $user['id_user'];
2189
+            }
2190
+            if(!in_array($user['user_id'],$blog_member_ids)) {
2191
+                $a_infosUser = api_get_user_info($user['user_id']);
2192
+                $row = array ();
2193
+                $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2194
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2195
+                if ($is_western_name_order) {
2196
+                    $row[] = $a_infosUser["firstname"];
2197
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2198
+                } else {
2199
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2200
+                    $row[] = $a_infosUser["firstname"];
2201
+                }
2202
+                $row[] = Display::icon_mailto_link($a_infosUser["email"]);
2203
+
2204
+                //Link to register users
2205
+                $currentUserId = api_get_user_id();
2206
+                if ($a_infosUser["user_id"] != $currentUserId) {
2207
+                    $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2208
+                } else {
2209
+                    $row[] = '';
2210
+                }
2211
+                $user_data[] = $row;
2212
+            }
2213
+        }
2214
+
2215
+        // Display
2216
+        $query_vars['action'] = 'manage_members';
2217
+        $query_vars['blog_id'] = $blog_id;
2218
+        echo '<form method="post" action="blog.php?'.api_get_cidreq(
2219
+            ).'&action=manage_members&blog_id='.$blog_id.'">';
2220
+            Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2221
+            $link = '';
2222
+            $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2223
+            $link .= "blog_id=$blog_id&";
2224
+
2225
+        echo '<a href="blog.php?'.api_get_cidreq(
2226
+            ).'&'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - ';
2227
+        echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2228
+                'UnSelectAll'
2229
+            ).'</a> ';
2230
+            echo get_lang('WithSelected') . ' : ';
2231
+            echo '<select name="action">';
2232
+            echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2233
+            echo '</select>';
2234
+            echo '<input type="hidden" name="register" value="true" />';
2235
+            echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2236
+        echo '</form>';
2237
+    }
2238
+
2239
+    /**
2240
+     * Displays the form to register users in a blog (in a course)
2241
+     * The listed users are users subcribed in the course.
2242
+     * @author Toon Keppens
2243
+     *
2244
+     * @param Integer $blog_id
2245
+     *
2246
+     * @return Html Form with sortable table with users to unsubcribe from a blog.
2247
+     */
2248
+    public static function display_form_user_unsubscribe ($blog_id)
2249
+    {
2250
+        $_user = api_get_user_info();
2251
+        $is_western_name_order = api_is_western_name_order();
2252
+
2253
+        // Init
2254
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2255
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2256
+
2257
+        echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2258
+
2259
+        $properties["width"] = "100%";
2260
+        //table column titles
2261
+        $column_header[] = array ('', false, '');
2262
+        if ($is_western_name_order) {
2263
+            $column_header[] = array (get_lang('FirstName'), true, '');
2264
+            $column_header[] = array (get_lang('LastName'), true, '');
2265
+        } else {
2266
+            $column_header[] = array (get_lang('LastName'), true, '');
2267
+            $column_header[] = array (get_lang('FirstName'), true, '');
2268
+        }
2269
+        $column_header[] = array (get_lang('Email'), false, '');
2270
+        $column_header[] = array (get_lang('TaskManager'), true, '');
2271
+        $column_header[] = array (get_lang('UnRegister'), false, '');
2272
+
2273
+        $course_id = api_get_course_int_id();
2274
+
2275
+        $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2277 2276
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2278 2277
                 ON user.user_id = blogs_rel_user.user_id
2279 2278
                 WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2280 2279
 
2281
-		if (!($sql_result = Database::query($sql))) {
2282
-			return false;
2283
-		}
2284
-
2285
-		$user_data = array ();
2286
-
2287
-		while ($myrow = Database::fetch_array($sql_result)) {
2288
-			$row = array ();
2289
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2290
-			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2291
-			if ($is_western_name_order) {
2292
-				$row[] = $myrow["firstname"];
2293
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2294
-			} else {
2295
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2296
-				$row[] = $myrow["firstname"];
2297
-			}
2298
-			$row[] = Display::icon_mailto_link($myrow["email"]);
2299
-
2300
-			$sql = "SELECT bt.title task
2280
+        if (!($sql_result = Database::query($sql))) {
2281
+            return false;
2282
+        }
2283
+
2284
+        $user_data = array ();
2285
+
2286
+        while ($myrow = Database::fetch_array($sql_result)) {
2287
+            $row = array ();
2288
+            $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2289
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2290
+            if ($is_western_name_order) {
2291
+                $row[] = $myrow["firstname"];
2292
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2293
+            } else {
2294
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2295
+                $row[] = $myrow["firstname"];
2296
+            }
2297
+            $row[] = Display::icon_mailto_link($myrow["email"]);
2298
+
2299
+            $sql = "SELECT bt.title task
2301 2300
 					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2302 2301
 					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2303 2302
 					ON btu.task_id = bt.task_id
@@ -2305,166 +2304,166 @@  discard block
 block discarded – undo
2305 2304
 							bt.c_id 	= $course_id  AND
2306 2305
 							btu.blog_id = $blog_id AND
2307 2306
 							btu.user_id = " . $myrow['user_id'];
2308
-			$sql_res = Database::query($sql);
2309
-
2310
-			$task = '';
2311
-
2312
-			while($r = Database::fetch_array($sql_res)) {
2313
-				$task .= stripslashes($r['task']) . ', ';
2314
-			}
2315
-			//echo $task;
2316
-			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2317
-			$row[] = $task;
2318
-			//Link to register users
2319
-
2320
-			if ($myrow["user_id"] != $_user['user_id']) {
2321
-				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2322
-			} else {
2323
-				$row[] = '';
2324
-			}
2325
-
2326
-			$user_data[] = $row;
2327
-		}
2328
-
2329
-		$query_vars['action'] = 'manage_members';
2330
-		$query_vars['blog_id'] = $blog_id;
2331
-		echo '<form method="post" action="blog.php?'.api_get_cidreq(
2332
-			).'&action=manage_members&blog_id='.$blog_id.'">';
2333
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2334
-		$link = '';
2335
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2336
-		$link .= "blog_id=$blog_id&";
2337
-
2338
-		echo '<a href="blog.php?'.api_get_cidreq(
2339
-			).'&'.$link.'selectall=unsubscribe">'.get_lang(
2340
-				'SelectAll'
2341
-			).'</a> - ';
2342
-		echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2343
-				'UnSelectAll'
2344
-			).'</a> ';
2345
-		echo get_lang('WithSelected') . ' : ';
2346
-		echo '<select name="action">';
2347
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2348
-		echo '</select>';
2349
-		echo '<input type="hidden" name="unregister" value="true" />';
2350
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2351
-		echo '</form>';
2352
-	}
2353
-
2354
-	/**
2355
-	 * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2356
-	 * The blog admin can thus select what a certain user can do in the current blog
2357
-	 *
2358
-	 * @param Integer $blog_id
2359
-	 */
2360
-	public static function display_form_user_rights ($blog_id)
2307
+            $sql_res = Database::query($sql);
2308
+
2309
+            $task = '';
2310
+
2311
+            while($r = Database::fetch_array($sql_res)) {
2312
+                $task .= stripslashes($r['task']) . ', ';
2313
+            }
2314
+            //echo $task;
2315
+            $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2316
+            $row[] = $task;
2317
+            //Link to register users
2318
+
2319
+            if ($myrow["user_id"] != $_user['user_id']) {
2320
+                $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2321
+            } else {
2322
+                $row[] = '';
2323
+            }
2324
+
2325
+            $user_data[] = $row;
2326
+        }
2327
+
2328
+        $query_vars['action'] = 'manage_members';
2329
+        $query_vars['blog_id'] = $blog_id;
2330
+        echo '<form method="post" action="blog.php?'.api_get_cidreq(
2331
+            ).'&action=manage_members&blog_id='.$blog_id.'">';
2332
+        Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2333
+        $link = '';
2334
+        $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2335
+        $link .= "blog_id=$blog_id&";
2336
+
2337
+        echo '<a href="blog.php?'.api_get_cidreq(
2338
+            ).'&'.$link.'selectall=unsubscribe">'.get_lang(
2339
+                'SelectAll'
2340
+            ).'</a> - ';
2341
+        echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2342
+                'UnSelectAll'
2343
+            ).'</a> ';
2344
+        echo get_lang('WithSelected') . ' : ';
2345
+        echo '<select name="action">';
2346
+        echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2347
+        echo '</select>';
2348
+        echo '<input type="hidden" name="unregister" value="true" />';
2349
+        echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2350
+        echo '</form>';
2351
+    }
2352
+
2353
+    /**
2354
+     * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2355
+     * The blog admin can thus select what a certain user can do in the current blog
2356
+     *
2357
+     * @param Integer $blog_id
2358
+     */
2359
+    public static function display_form_user_rights ($blog_id)
2360
+    {
2361
+        echo '<legend>'.get_lang('RightsManager').'</legend>';
2362
+        echo '<br />';
2363
+
2364
+        // Integration of patricks permissions system.
2365
+        require_once api_get_path(SYS_CODE_PATH).'blog/permissions/blog_permissions.inc.php';
2366
+    }
2367
+
2368
+    /**
2369
+     * Displays the form to create a new post
2370
+     * @author Toon Keppens
2371
+     *
2372
+     * @param Integer $blog_id
2373
+     */
2374
+    public static function display_new_comment_form($blog_id, $post_id, $title)
2375
+    {
2376
+        $form = new FormValidator(
2377
+            'add_post',
2378
+            'post',
2379
+            api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2380
+            null,
2381
+            array('enctype' => 'multipart/form-data')
2382
+        );
2383
+
2384
+        $header = get_lang('AddNewComment');
2385
+        if (isset($_GET['task_id'])) {
2386
+            $header = get_lang('ExecuteThisTask');
2387
+        }
2388
+        $form->addHeader($header);
2389
+        $form->addText('title', get_lang('Title'));
2390
+
2391
+        $config = array();
2392
+        if (!api_is_allowed_to_edit()) {
2393
+            $config['ToolbarSet'] = 'ProjectComment';
2394
+        } else {
2395
+            $config['ToolbarSet'] = 'ProjectCommentStudent';
2396
+        }
2397
+        $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2398
+        $form->addFile('user_upload', get_lang('AddAnAttachment'));
2399
+
2400
+        $form->addTextarea('post_file_comment', get_lang('FileComment'));
2401
+
2402
+        $form->addHidden('action', null);
2403
+        $form->addHidden('comment_parent_id', 0);
2404
+
2405
+        if (isset($_GET['task_id'])) {
2406
+            $form->addHidden('new_task_execution_submit', 'true');
2407
+            $form->addHidden('task_id', intval($_GET['task_id']));
2408
+        } else {
2409
+            $form->addHidden('new_comment_submit', 'true');
2410
+        }
2411
+        $form->addButton('save', get_lang('Save'));
2412
+        $form->display();
2413
+    }
2414
+
2415
+
2416
+    /**
2417
+     * show the calender of the given month
2418
+     * @author Patrick Cool
2419
+     * @author Toon Keppens
2420
+     *
2421
+     * @param Array $blogitems an array containing all the blog items for the given month
2422
+     * @param Integer $month: the integer value of the month we are viewing
2423
+     * @param Integer $year: the 4-digit year indication e.g. 2005
2424
+     * @param String $monthName: the language variable for the mont name
2425
+     *
2426
+     * @return html code
2427
+     */
2428
+    public static function display_minimonthcalendar($month, $year, $blog_id)
2361 2429
     {
2362
-		echo '<legend>'.get_lang('RightsManager').'</legend>';
2363
-		echo '<br />';
2364
-
2365
-		// Integration of patricks permissions system.
2366
-		require_once api_get_path(SYS_CODE_PATH).'blog/permissions/blog_permissions.inc.php';
2367
-	}
2368
-
2369
-	/**
2370
-	 * Displays the form to create a new post
2371
-	 * @author Toon Keppens
2372
-	 *
2373
-	 * @param Integer $blog_id
2374
-	 */
2375
-	public static function display_new_comment_form($blog_id, $post_id, $title)
2376
-	{
2377
-		$form = new FormValidator(
2378
-			'add_post',
2379
-			'post',
2380
-			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2381
-			null,
2382
-			array('enctype' => 'multipart/form-data')
2383
-		);
2384
-
2385
-		$header = get_lang('AddNewComment');
2386
-		if (isset($_GET['task_id'])) {
2387
-			$header = get_lang('ExecuteThisTask');
2388
-		}
2389
-		$form->addHeader($header);
2390
-		$form->addText('title', get_lang('Title'));
2391
-
2392
-		$config = array();
2393
-		if (!api_is_allowed_to_edit()) {
2394
-			$config['ToolbarSet'] = 'ProjectComment';
2395
-		} else {
2396
-			$config['ToolbarSet'] = 'ProjectCommentStudent';
2397
-		}
2398
-		$form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2399
-		$form->addFile('user_upload', get_lang('AddAnAttachment'));
2400
-
2401
-		$form->addTextarea('post_file_comment', get_lang('FileComment'));
2402
-
2403
-		$form->addHidden('action', null);
2404
-		$form->addHidden('comment_parent_id', 0);
2405
-
2406
-		if (isset($_GET['task_id'])) {
2407
-			$form->addHidden('new_task_execution_submit', 'true');
2408
-			$form->addHidden('task_id', intval($_GET['task_id']));
2409
-		} else {
2410
-			$form->addHidden('new_comment_submit', 'true');
2411
-		}
2412
-		$form->addButton('save', get_lang('Save'));
2413
-		$form->display();
2414
-	}
2415
-
2416
-
2417
-	/**
2418
-	 * show the calender of the given month
2419
-	 * @author Patrick Cool
2420
-	 * @author Toon Keppens
2421
-	 *
2422
-	 * @param Array $blogitems an array containing all the blog items for the given month
2423
-	 * @param Integer $month: the integer value of the month we are viewing
2424
-	 * @param Integer $year: the 4-digit year indication e.g. 2005
2425
-	 * @param String $monthName: the language variable for the mont name
2426
-	 *
2427
-	 * @return html code
2428
-	*/
2429
-	public static function display_minimonthcalendar($month, $year, $blog_id)
2430
-	{
2431
-		// Init
2432
-		$_user = api_get_user_info();
2433
-		global $DaysShort;
2434
-		global $MonthsLong;
2435
-
2436
-		$posts = array();
2437
-		$tasks = array();
2438
-
2439
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2440
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2441
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2442
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2443
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2444
-
2445
-		$course_id = api_get_course_int_id();
2446
-
2447
-		//Handle leap year
2448
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2449
-
2450
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2451
-			$numberofdays[2] = 29;
2452
-
2453
-		//Get the first day of the month
2454
-		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2455
-		$monthName = $MonthsLong[$month-1];
2456
-
2457
-		//Start the week on monday
2458
-		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2459
-		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2460
-		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2461
-		$backwardsURL = api_get_self()."?".api_get_cidreq(
2462
-			)."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
2463
-		$forewardsURL = api_get_self()."?".api_get_cidreq(
2464
-			)."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
2465
-
2466
-		// Get posts for this month
2467
-		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2430
+        // Init
2431
+        $_user = api_get_user_info();
2432
+        global $DaysShort;
2433
+        global $MonthsLong;
2434
+
2435
+        $posts = array();
2436
+        $tasks = array();
2437
+
2438
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2439
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2440
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2441
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2442
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2443
+
2444
+        $course_id = api_get_course_int_id();
2445
+
2446
+        //Handle leap year
2447
+        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2448
+
2449
+        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2450
+            $numberofdays[2] = 29;
2451
+
2452
+        //Get the first day of the month
2453
+        $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2454
+        $monthName = $MonthsLong[$month-1];
2455
+
2456
+        //Start the week on monday
2457
+        $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2458
+        $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2459
+        $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2460
+        $backwardsURL = api_get_self()."?".api_get_cidreq(
2461
+            )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
2462
+        $forewardsURL = api_get_self()."?".api_get_cidreq(
2463
+            )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
2464
+
2465
+        // Get posts for this month
2466
+        $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2468 2467
 				FROM $tbl_blogs_posts post
2469 2468
 				INNER JOIN $tbl_users user
2470 2469
 				ON post.author_id = user.user_id
@@ -2474,20 +2473,20 @@  discard block
 block discarded – undo
2474 2473
 					MONTH(date_creation) = '".(int)$month."' AND
2475 2474
 					YEAR(date_creation) = '".(int)$year."'
2476 2475
 				ORDER BY date_creation";
2477
-		$result = Database::query($sql);
2478
-
2479
-		// We will create an array of days on which there are posts.
2480
-		if( Database::num_rows($result) > 0) {
2481
-			while($blog_post = Database::fetch_array($result)) {
2482
-				// If the day of this post is not yet in the array, add it.
2483
-				if (!in_array($blog_post['post_day'], $posts))
2484
-					$posts[] = $blog_post['post_day'];
2485
-			}
2486
-		}
2487
-
2488
-		// Get tasks for this month
2489
-		if ($_user['user_id']) {
2490
-			$sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2476
+        $result = Database::query($sql);
2477
+
2478
+        // We will create an array of days on which there are posts.
2479
+        if( Database::num_rows($result) > 0) {
2480
+            while($blog_post = Database::fetch_array($result)) {
2481
+                // If the day of this post is not yet in the array, add it.
2482
+                if (!in_array($blog_post['post_day'], $posts))
2483
+                    $posts[] = $blog_post['post_day'];
2484
+            }
2485
+        }
2486
+
2487
+        // Get tasks for this month
2488
+        if ($_user['user_id']) {
2489
+            $sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2491 2490
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
2492 2491
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
2493 2492
 				INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
@@ -2499,99 +2498,99 @@  discard block
 block discarded – undo
2499 2498
 					MONTH(target_date) = '".(int)$month."' AND
2500 2499
 					YEAR(target_date) = '".(int)$year."'
2501 2500
 				ORDER BY target_date ASC";
2502
-			$result = Database::query($sql);
2503
-
2504
-			if (Database::num_rows($result) > 0) {
2505
-				while ($mytask = Database::fetch_array($result)) {
2506
-					$tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2507
-					$tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2508
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2509
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2510
-					$tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2511
-				}
2512
-			}
2513
-		}
2514
-
2515
-		echo 	'<table id="smallcalendar" class="table table-responsive">',
2516
-				"<tr id=\"title\">\n",
2517
-				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2518
-				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2519
-				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2520
-
2521
-		echo "<tr>\n";
2522
-
2523
-		for($ii = 1; $ii < 8; $ii ++)
2524
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2525
-
2526
-		echo "</tr>";
2527
-
2528
-		$curday = -1;
2529
-		$today = getdate();
2530
-
2531
-		while ($curday <= $numberofdays[$month]) {
2532
-			echo "<tr>";
2533
-			for ($ii = 0; $ii < 7; $ii ++) {
2534
-				if (($curday == -1) && ($ii == $startdayofweek))
2535
-					$curday = 1;
2536
-
2537
-			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2538
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2539
-					$dayheader = "$curday";
2540
-
2541
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2542
-						$dayheader = "$curday";
2543
-						$class = "class=\"days_today\"";
2544
-					}
2545
-
2546
-					echo "<td " . $class.">";
2547
-
2548
-					// If there are posts on this day, create a filter link.
2549
-					if(in_array($curday, $posts))
2550
-						echo '<a href="blog.php?'.api_get_cidreq(
2551
-							).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang(
2552
-								'ViewPostsOfThisDay'
2553
-							).'">'.
2554
-							$curday.'</a>';
2555
-					else
2556
-						echo $dayheader;
2557
-
2558
-					if (count($tasks) > 0) {
2559
-						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2560
-							// Add tasks to calendar
2561
-							foreach ($tasks[$curday] as $task) {
2562
-								echo '<a href="blog.php?'.api_get_cidreq(
2563
-									).'&action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes(
2564
-										$task['task_id']
2565
-									).'" title="'.$task['title'].' : '.get_lang(
2566
-										'InBlog'
2567
-									).' : '.$task['blog_name'].' - '.get_lang(
2568
-										'ExecuteThisTask'
2569
-									).'">
2501
+            $result = Database::query($sql);
2502
+
2503
+            if (Database::num_rows($result) > 0) {
2504
+                while ($mytask = Database::fetch_array($result)) {
2505
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2506
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2507
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2508
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2509
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2510
+                }
2511
+            }
2512
+        }
2513
+
2514
+        echo 	'<table id="smallcalendar" class="table table-responsive">',
2515
+                "<tr id=\"title\">\n",
2516
+                "<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2517
+                "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2518
+                "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2519
+
2520
+        echo "<tr>\n";
2521
+
2522
+        for($ii = 1; $ii < 8; $ii ++)
2523
+            echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2524
+
2525
+        echo "</tr>";
2526
+
2527
+        $curday = -1;
2528
+        $today = getdate();
2529
+
2530
+        while ($curday <= $numberofdays[$month]) {
2531
+            echo "<tr>";
2532
+            for ($ii = 0; $ii < 7; $ii ++) {
2533
+                if (($curday == -1) && ($ii == $startdayofweek))
2534
+                    $curday = 1;
2535
+
2536
+                    if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2537
+                    $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2538
+                    $dayheader = "$curday";
2539
+
2540
+                    if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2541
+                        $dayheader = "$curday";
2542
+                        $class = "class=\"days_today\"";
2543
+                    }
2544
+
2545
+                    echo "<td " . $class.">";
2546
+
2547
+                    // If there are posts on this day, create a filter link.
2548
+                    if(in_array($curday, $posts))
2549
+                        echo '<a href="blog.php?'.api_get_cidreq(
2550
+                            ).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang(
2551
+                                'ViewPostsOfThisDay'
2552
+                            ).'">'.
2553
+                            $curday.'</a>';
2554
+                    else
2555
+                        echo $dayheader;
2556
+
2557
+                    if (count($tasks) > 0) {
2558
+                        if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2559
+                            // Add tasks to calendar
2560
+                            foreach ($tasks[$curday] as $task) {
2561
+                                echo '<a href="blog.php?'.api_get_cidreq(
2562
+                                    ).'&action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes(
2563
+                                        $task['task_id']
2564
+                                    ).'" title="'.$task['title'].' : '.get_lang(
2565
+                                        'InBlog'
2566
+                                    ).' : '.$task['blog_name'].' - '.get_lang(
2567
+                                        'ExecuteThisTask'
2568
+                                    ).'">
2570 2569
 								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2571
-							}
2572
-						}
2573
-					}
2574
-
2575
-					echo "</td>";
2576
-					$curday ++;
2577
-				} else
2578
-					echo "<td>&nbsp;</td>";
2579
-			}
2580
-			echo "</tr>";
2581
-		}
2582
-		echo "</table>";
2583
-	}
2584
-
2585
-	/**
2586
-	 * Blog admin | Display the form to add a new blog.
2587
-	 *
2588
-	 */
2589
-	public static function display_new_blog_form()
2590
-	{
2591
-		$form = new FormValidator(
2592
-			'add_blog',
2593
-			'post',
2594
-			'blog_admin.php?action=add&'.api_get_cidreq());
2570
+                            }
2571
+                        }
2572
+                    }
2573
+
2574
+                    echo "</td>";
2575
+                    $curday ++;
2576
+                } else
2577
+                    echo "<td>&nbsp;</td>";
2578
+            }
2579
+            echo "</tr>";
2580
+        }
2581
+        echo "</table>";
2582
+    }
2583
+
2584
+    /**
2585
+     * Blog admin | Display the form to add a new blog.
2586
+     *
2587
+     */
2588
+    public static function display_new_blog_form()
2589
+    {
2590
+        $form = new FormValidator(
2591
+            'add_blog',
2592
+            'post',
2593
+            'blog_admin.php?action=add&'.api_get_cidreq());
2595 2594
         $form->addElement('header', get_lang('AddBlog'));
2596 2595
         $form->addElement('text', 'blog_name', get_lang('Title'));
2597 2596
         $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle'));
@@ -2600,42 +2599,42 @@  discard block
 block discarded – undo
2600 2599
         $form->addButtonSave(get_lang('SaveProject'));
2601 2600
 
2602 2601
         $defaults = array(
2603
-			'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2604
-        	'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2605
-		);
2602
+            'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2603
+            'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2604
+        );
2606 2605
         $form->setDefaults($defaults);
2607 2606
         $form->display();
2608
-	}
2609
-
2610
-	/**
2611
-	 * Blog admin | Display the form to edit a blog.
2612
-	 *
2613
-	 */
2614
-	public static function display_edit_blog_form($blog_id)
2615
-	{
2616
-	    $course_id = api_get_course_int_id();
2617
-		$blog_id= intval($blog_id);
2618
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2619
-
2620
-		$sql = "SELECT blog_id, blog_name, blog_subtitle
2607
+    }
2608
+
2609
+    /**
2610
+     * Blog admin | Display the form to edit a blog.
2611
+     *
2612
+     */
2613
+    public static function display_edit_blog_form($blog_id)
2614
+    {
2615
+        $course_id = api_get_course_int_id();
2616
+        $blog_id= intval($blog_id);
2617
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2618
+
2619
+        $sql = "SELECT blog_id, blog_name, blog_subtitle
2621 2620
 		        FROM $tbl_blogs
2622 2621
 		        WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
2623
-		$result = Database::query($sql);
2624
-		$blog = Database::fetch_array($result);
2625
-
2626
-		// the form contained errors but we do not want to lose the changes the user already did
2627
-		if ($_POST) {
2628
-			$blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2629
-			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2630
-		}
2631
-
2632
-		$form = new FormValidator(
2633
-			'edit_blog',
2634
-			'post',
2635
-			'blog_admin.php?action=edit&blog_id='.intval(
2636
-				$_GET['blog_id']
2637
-			).'&'.api_get_cidreq()
2638
-		);
2622
+        $result = Database::query($sql);
2623
+        $blog = Database::fetch_array($result);
2624
+
2625
+        // the form contained errors but we do not want to lose the changes the user already did
2626
+        if ($_POST) {
2627
+            $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2628
+            $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2629
+        }
2630
+
2631
+        $form = new FormValidator(
2632
+            'edit_blog',
2633
+            'post',
2634
+            'blog_admin.php?action=edit&blog_id='.intval(
2635
+                $_GET['blog_id']
2636
+            ).'&'.api_get_cidreq()
2637
+        );
2639 2638
         $form->addElement('header', get_lang('EditBlog'));
2640 2639
         $form->addElement('text', 'blog_name', get_lang('Title'));
2641 2640
         $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle'));
@@ -2649,82 +2648,82 @@  discard block
 block discarded – undo
2649 2648
         $defaults['blog_subtitle'] = $blog['blog_subtitle'];
2650 2649
         $form->setDefaults($defaults);
2651 2650
         $form->display();
2652
-	}
2651
+    }
2653 2652
 
2654
-	/**
2655
-	 * Blog admin | Returns table with blogs in this course
2656
-	 */
2657
-	public static function display_blog_list()
2653
+    /**
2654
+     * Blog admin | Returns table with blogs in this course
2655
+     */
2656
+    public static function display_blog_list()
2658 2657
     {
2659
-		global $charset;
2660
-		$_user = api_get_user_info();
2658
+        global $charset;
2659
+        $_user = api_get_user_info();
2661 2660
         $course_id = api_get_course_int_id();
2662 2661
 
2663
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2662
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2664 2663
 
2665
-		//condition for the session
2666
-		$session_id = api_get_session_id();
2667
-		$condition_session = api_get_session_condition($session_id, false);
2664
+        //condition for the session
2665
+        $session_id = api_get_session_id();
2666
+        $condition_session = api_get_session_condition($session_id, false);
2668 2667
 
2669
-		$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2668
+        $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2670 2669
 				FROM $tbl_blogs WHERE c_id = $course_id
2671 2670
 				ORDER BY date_creation DESC";
2672
-		$result = Database::query($sql);
2673
-		$list_info = array();
2674
-		if (Database::num_rows($result)) {
2675
-			while ($row_project=Database::fetch_row($result)) {
2676
-				$list_info[]=$row_project;
2677
-			}
2678
-		}
2679
-
2680
-		$list_content_blog = array();
2681
-		$list_body_blog = array();
2682
-
2683
-		if (is_array($list_info)) {
2684
-			foreach ($list_info as $key => $info_log) {
2685
-				// Validation when belongs to a session
2686
-				$session_img = api_get_session_image($info_log[4], $_user['status']);
2687
-
2688
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2689
-				$title = $info_log[0];
2671
+        $result = Database::query($sql);
2672
+        $list_info = array();
2673
+        if (Database::num_rows($result)) {
2674
+            while ($row_project=Database::fetch_row($result)) {
2675
+                $list_info[]=$row_project;
2676
+            }
2677
+        }
2678
+
2679
+        $list_content_blog = array();
2680
+        $list_body_blog = array();
2681
+
2682
+        if (is_array($list_info)) {
2683
+            foreach ($list_info as $key => $info_log) {
2684
+                // Validation when belongs to a session
2685
+                $session_img = api_get_session_image($info_log[4], $_user['status']);
2686
+
2687
+                $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2688
+                $title = $info_log[0];
2690 2689
                         $image = Display::return_icon('blog.png', $title);
2691
-    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2690
+                $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2692 2691
 
2693
-				$list_body_blog[] = $list_name;
2694
-				$list_body_blog[] = $info_log[1];
2692
+                $list_body_blog[] = $list_name;
2693
+                $list_body_blog[] = $info_log[1];
2695 2694
 
2696
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2697
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2698
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2695
+                $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2696
+                $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2697
+                    $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2699 2698
                                 $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2700 2699
 
2701
-				$my_image.= "</a>\n";
2702
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2703
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2700
+                $my_image.= "</a>\n";
2701
+                $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2702
+                $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2704 2703
                                 $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2705 2704
 
2706
-				$my_image.= "</a>\n";
2707
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2705
+                $my_image.= "</a>\n";
2706
+                $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2708 2707
                                 $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2709 2708
 
2710
-				$my_image.= "</a>\n";
2709
+                $my_image.= "</a>\n";
2711 2710
 
2712
-				$list_body_blog[]=$my_image;
2711
+                $list_body_blog[]=$my_image;
2713 2712
 
2714
-				$list_content_blog[]=$list_body_blog;
2715
-				$list_body_blog = array();
2713
+                $list_content_blog[]=$list_body_blog;
2714
+                $list_body_blog = array();
2716 2715
 
2717
-			}
2718
-			$parameters='';
2719
-			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2720
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2721
-			//$table->set_additional_parameters($parameters);
2722
-			$table->set_header(0, get_lang('Title'));
2723
-			$table->set_header(1, get_lang('SubTitle'));
2724
-			$table->set_header(2, get_lang('Modify'));
2725
-			$table->display();
2726
-		}
2727
-	}
2716
+            }
2717
+            $parameters='';
2718
+            //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2719
+            $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2720
+            //$table->set_additional_parameters($parameters);
2721
+            $table->set_header(0, get_lang('Title'));
2722
+            $table->set_header(1, get_lang('SubTitle'));
2723
+            $table->set_header(2, get_lang('Modify'));
2724
+            $table->display();
2725
+        }
2726
+    }
2728 2727
 }
2729 2728
 
2730 2729
 /**
@@ -2744,34 +2743,34 @@  discard block
 block discarded – undo
2744 2743
  */
2745 2744
 function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2746 2745
 {
2747
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2748
-
2749
-	$blog_id = intval($blog_id);
2750
-	$comment_id = intval($comment_id);
2751
-	$post_id = intval($post_id);
2752
-	$row=array();
2753
-	$where='';
2754
-	if (!empty ($post_id) && is_numeric($post_id)) {
2755
-		$where.=' AND post_id ="'.$post_id.'" ';
2756
-	}
2757
-
2758
-	if (!empty ($comment_id) && is_numeric($comment_id)) {
2759
-		if (!empty ($post_id)) {
2760
-			$where.= ' AND ';
2761
-		}
2762
-		$where.=' comment_id ="'.$comment_id.'" ';
2763
-	}
2746
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2747
+
2748
+    $blog_id = intval($blog_id);
2749
+    $comment_id = intval($comment_id);
2750
+    $post_id = intval($post_id);
2751
+    $row=array();
2752
+    $where='';
2753
+    if (!empty ($post_id) && is_numeric($post_id)) {
2754
+        $where.=' AND post_id ="'.$post_id.'" ';
2755
+    }
2756
+
2757
+    if (!empty ($comment_id) && is_numeric($comment_id)) {
2758
+        if (!empty ($post_id)) {
2759
+            $where.= ' AND ';
2760
+        }
2761
+        $where.=' comment_id ="'.$comment_id.'" ';
2762
+    }
2764 2763
 
2765 2764
     $course_id = api_get_course_int_id();
2766 2765
 
2767
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2766
+    $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2768 2767
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2769 2768
 
2770
-	$result=Database::query($sql);
2771
-	if (Database::num_rows($result)!=0) {
2772
-		$row=Database::fetch_array($result);
2773
-	}
2774
-	return $row;
2769
+    $result=Database::query($sql);
2770
+    if (Database::num_rows($result)!=0) {
2771
+        $row=Database::fetch_array($result);
2772
+    }
2773
+    return $row;
2775 2774
 }
2776 2775
 
2777 2776
 /**
@@ -2785,16 +2784,16 @@  discard block
 block discarded – undo
2785 2784
 
2786 2785
 function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2787 2786
 {
2788
-	$_course = api_get_course_info();
2789
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2790
-	$blog_id = intval($blog_id);
2791
-	$comment_id = intval($comment_id);
2792
-	$post_id = intval($post_id);
2787
+    $_course = api_get_course_info();
2788
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2789
+    $blog_id = intval($blog_id);
2790
+    $comment_id = intval($comment_id);
2791
+    $post_id = intval($post_id);
2793 2792
 
2794 2793
     $course_id = api_get_course_int_id();
2795
-	$where = null;
2794
+    $where = null;
2796 2795
 
2797
-	// delete files in DB
2796
+    // delete files in DB
2798 2797
     if (!empty ($post_id) && is_numeric($post_id)) {
2799 2798
         $where .= ' AND post_id ="'.$post_id.'" ';
2800 2799
     }
@@ -2806,25 +2805,25 @@  discard block
 block discarded – undo
2806 2805
         $where .= ' comment_id ="'.$comment_id.'" ';
2807 2806
     }
2808 2807
 
2809
-	// delete all files in directory
2810
-	$courseDir   = $_course['path'].'/upload/blog';
2811
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2812
-	$updir = $sys_course_path.$courseDir;
2808
+    // delete all files in directory
2809
+    $courseDir   = $_course['path'].'/upload/blog';
2810
+    $sys_course_path = api_get_path(SYS_COURSE_PATH);
2811
+    $updir = $sys_course_path.$courseDir;
2813 2812
 
2814
-	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2813
+    $sql = 'SELECT path FROM '.$blog_table_attachment.'
2815 2814
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2816
-	$result=Database::query($sql);
2817
-
2818
-	while ($row=Database::fetch_row($result)) {
2819
-		$file=$updir.'/'.$row[0];
2820
-		if (Security::check_abs_path($file,$updir) )
2821
-		{
2822
-			@ unlink($file);
2823
-		}
2824
-	}
2825
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2815
+    $result=Database::query($sql);
2816
+
2817
+    while ($row=Database::fetch_row($result)) {
2818
+        $file=$updir.'/'.$row[0];
2819
+        if (Security::check_abs_path($file,$updir) )
2820
+        {
2821
+            @ unlink($file);
2822
+        }
2823
+    }
2824
+    $sql = 'DELETE FROM '. $blog_table_attachment.'
2826 2825
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2827
-	Database::query($sql);
2826
+    Database::query($sql);
2828 2827
 }
2829 2828
 
2830 2829
 /**
@@ -2834,12 +2833,12 @@  discard block
 block discarded – undo
2834 2833
  */
2835 2834
 function get_blog_post_from_user($course_code, $user_id)
2836 2835
 {
2837
-	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2838
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2839
-	$course_info 	= api_get_course_info($course_code);
2840
-	$course_id 		= $course_info['real_id'];
2836
+    $tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2837
+    $tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2838
+    $course_info 	= api_get_course_info($course_code);
2839
+    $course_id 		= $course_info['real_id'];
2841 2840
 
2842
-	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2841
+    $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2843 2842
 			FROM $tbl_blogs blog
2844 2843
 			INNER JOIN  $tbl_blog_post post
2845 2844
 			ON (blog.blog_id = post.blog_id)
@@ -2848,23 +2847,23 @@  discard block
 block discarded – undo
2848 2847
 				post.c_id = $course_id AND
2849 2848
 				author_id =  $user_id AND visibility = 1
2850 2849
 			ORDER BY post.date_creation DESC ";
2851
-	$result = Database::query($sql);
2852
-	$return_data = '';
2853
-
2854
-	if (Database::num_rows($result)!=0) {
2855
-		while ($row=Database::fetch_array($result)) {
2856
-			$return_data.=  '<div class="clear"></div><br />';
2857
-			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.
2858
-				Display::return_icon('blog_article.png', get_lang('BlogPosts')).
2859
-				' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2850
+    $result = Database::query($sql);
2851
+    $return_data = '';
2852
+
2853
+    if (Database::num_rows($result)!=0) {
2854
+        while ($row=Database::fetch_array($result)) {
2855
+            $return_data.=  '<div class="clear"></div><br />';
2856
+            $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.
2857
+                Display::return_icon('blog_article.png', get_lang('BlogPosts')).
2858
+                ' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2860 2859
 			<a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq(
2861
-				).' " >'.get_lang('SeeBlog').'</a></div></div>';
2862
-			$return_data.=  '<br / >';
2863
-			$return_data.= $row['full_text'];
2864
-			$return_data.= '<br /><br />';
2865
-		}
2866
-	}
2867
-	return $return_data;
2860
+                ).' " >'.get_lang('SeeBlog').'</a></div></div>';
2861
+            $return_data.=  '<br / >';
2862
+            $return_data.= $row['full_text'];
2863
+            $return_data.= '<br /><br />';
2864
+        }
2865
+    }
2866
+    return $return_data;
2868 2867
 }
2869 2868
 
2870 2869
 /**
@@ -2881,7 +2880,7 @@  discard block
 block discarded – undo
2881 2880
     $course_info = api_get_course_info($course_code);
2882 2881
     $course_id = $course_info['real_id'];
2883 2882
 
2884
-	$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2883
+    $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2885 2884
 			FROM $tbl_blogs blog INNER JOIN  $tbl_blog_comment comment
2886 2885
 			ON (blog.blog_id = comment.blog_id)
2887 2886
 			WHERE 	blog.c_id = $course_id AND
@@ -2889,20 +2888,20 @@  discard block
 block discarded – undo
2889 2888
 					author_id =  $user_id AND
2890 2889
 					visibility = 1
2891 2890
 			ORDER BY blog_name";
2892
-	$result = Database::query($sql);
2893
-	$return_data = '';
2894
-	if (Database::num_rows($result)!=0) {
2895
-		while ($row=Database::fetch_array($result)) {
2896
-			$return_data.=  '<div class="clear"></div><br />';
2897
-			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2891
+    $result = Database::query($sql);
2892
+    $return_data = '';
2893
+    if (Database::num_rows($result)!=0) {
2894
+        while ($row=Database::fetch_array($result)) {
2895
+            $return_data.=  '<div class="clear"></div><br />';
2896
+            $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2898 2897
 			<a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq(
2899
-				).' " >'.get_lang('SeeBlog').'</a></div></div>';
2900
-			$return_data.=  '<br / >';
2901
-			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2902
-			$return_data.=  $row['comment'];
2903
-			$return_data.=  '<br />';
2904
-		}
2905
-	}
2906
-	return $return_data;
2898
+                ).' " >'.get_lang('SeeBlog').'</a></div></div>';
2899
+            $return_data.=  '<br / >';
2900
+            //$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2901
+            $return_data.=  $row['comment'];
2902
+            $return_data.=  '<br />';
2903
+        }
2904
+    }
2905
+    return $return_data;
2907 2906
 }
2908 2907
 
Please login to merge, or discard this patch.
Spacing   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return String Blog Title
23 23
 	 */
24
-	public static function get_blog_title ($blog_id)
24
+	public static function get_blog_title($blog_id)
25 25
 	{
26 26
 	    $course_id = api_get_course_int_id();
27 27
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 			$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
31 31
 
32 32
 			$sql = "SELECT blog_name
33
-					FROM " . $tbl_blogs . "
34
-					WHERE c_id = $course_id AND blog_id = " . intval($blog_id);
33
+					FROM " . $tbl_blogs."
34
+					WHERE c_id = $course_id AND blog_id = ".intval($blog_id);
35 35
 
36 36
 			$result = Database::query($sql);
37 37
 			$blog = Database::fetch_array($result);
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// Get blog members
80 80
 		$sql = "SELECT user.user_id, user.firstname, user.lastname
81
-				FROM " . $tbl_blogs_rel_user . " blogs_rel_user
82
-				INNER JOIN " . $tbl_users . " user
81
+				FROM " . $tbl_blogs_rel_user." blogs_rel_user
82
+				INNER JOIN " . $tbl_users." user
83 83
 				ON blogs_rel_user.user_id = user.user_id
84 84
 				WHERE
85 85
 				    blogs_rel_user.c_id = $course_id AND
86
-					blogs_rel_user.blog_id = '" . (int)$blog_id."'";
86
+					blogs_rel_user.blog_id = '".(int) $blog_id."'";
87 87
 		$result = Database::query($sql);
88
-		$blog_members = array ();
89
-		while($user = Database::fetch_array($result)) {
88
+		$blog_members = array();
89
+		while ($user = Database::fetch_array($result)) {
90 90
 			$blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
91 91
 		}
92 92
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$_user = api_get_user_info();
106 106
         $course_id = api_get_course_int_id();
107 107
 
108
-		$current_date=date('Y-m-d H:i:s',time());
108
+		$current_date = date('Y-m-d H:i:s', time());
109 109
 		$session_id = api_get_session_id();
110 110
 		// Tabel definitions
111 111
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                 'blog_name' => $title,
131 131
                 'blog_subtitle' =>  $subtitle,
132 132
                 'date_creation' => $current_date,
133
-                'visibility' => 1 ,
133
+                'visibility' => 1,
134 134
                 'session_id' => $session_id,
135 135
             ];
136 136
 			$this_blog_id = Database::insert($tbl_blogs, $params);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 			// Put it on course homepage
171 171
 			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
172
-					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
172
+					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int) $this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
173 173
 			Database::query($sql);
174 174
 
175 175
             $toolId = Database::insert_id();
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		        blog_subtitle = '".Database::escape_string($subtitle)."'
205 205
 		        WHERE
206 206
 		            c_id = $course_id AND
207
-		            blog_id ='".Database::escape_string((int)$blog_id)."'
207
+		            blog_id ='".Database::escape_string((int) $blog_id)."'
208 208
                 LIMIT 1";
209 209
 		Database::query($sql);
210 210
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		// Update course homepage link
221 221
 		$sql = "UPDATE $tbl_tool SET
222 222
 		        name = '".Database::escape_string($title)."'
223
-		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
223
+		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int) $blog_id."' LIMIT 1";
224 224
 		Database::query($sql);
225 225
 	}
226 226
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		Database::query($sql);
264 264
 
265 265
 		// Delete blog
266
-		$sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
266
+		$sql = "DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
267 267
 		Database::query($sql);
268 268
 
269 269
 		// Delete from course homepage
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 		$course_id = $_course['real_id'];
295 295
 
296 296
 		$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
297
-		$upload_ok=true;
298
-		$has_attachment=false;
297
+		$upload_ok = true;
298
+		$has_attachment = false;
299 299
 		$current_date = api_get_utc_datetime();
300 300
 
301 301
 		if (!empty($_FILES['user_upload']['name'])) {
302 302
 			$upload_ok = process_uploaded_file($_FILES['user_upload']);
303
-			$has_attachment=true;
303
+			$has_attachment = true;
304 304
 		}
305 305
 
306 306
 		if ($upload_ok) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 			// Create the post
311 311
 			$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
312
-					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
312
+					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int) $blog_id."', '".(int) $_user['user_id']."');";
313 313
 
314 314
 			Database::query($sql);
315 315
 			$last_post_id = Database::insert_id();
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             }
321 321
 
322 322
 			if ($has_attachment) {
323
-				$courseDir   = $_course['path'].'/upload/blog';
323
+				$courseDir = $_course['path'].'/upload/blog';
324 324
 				$sys_course_path = api_get_path(SYS_COURSE_PATH);
325 325
 				$updir = $sys_course_path.$courseDir;
326 326
 
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 
372 372
 		// Create the post
373 373
 		$sql = "UPDATE $tbl_blogs_posts SET
374
-		        title = '" . Database::escape_string($title)."',
374
+		        title = '".Database::escape_string($title)."',
375 375
 		        full_text = '" . Database::escape_string($full_text)."'
376
-		        WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."'
376
+		        WHERE c_id = $course_id AND post_id ='".(int) $post_id."' AND blog_id ='".(int) $blog_id."'
377 377
 		        LIMIT 1 ";
378 378
 		Database::query($sql);
379 379
 	}
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 
395 395
 		// Delete ratings on this comment
396 396
 		$sql = "DELETE FROM $tbl_blogs_rating
397
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'";
397
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND item_id = '".(int) $post_id."' AND rating_type = 'post'";
398 398
 		Database::query($sql);
399 399
 
400 400
 		// Delete the post
401 401
 		$sql = "DELETE FROM $tbl_blogs_posts
402
-				WHERE c_id = $course_id AND post_id = '".(int)$post_id."'";
402
+				WHERE c_id = $course_id AND post_id = '".(int) $post_id."'";
403 403
 		Database::query($sql);
404 404
 
405 405
 		// Delete the comments
406 406
 		$sql = "DELETE FROM $tbl_blogs_comments
407
-				WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'";
407
+				WHERE c_id = $course_id AND post_id = '".(int) $post_id."' AND blog_id = '".(int) $blog_id."'";
408 408
 		Database::query($sql);
409 409
 
410 410
 		// Delete posts and attachments
411
-		delete_all_blog_attachment($blog_id,$post_id);
411
+		delete_all_blog_attachment($blog_id, $post_id);
412 412
 	}
413 413
 
414 414
 	/**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	{
425 425
 		$_user = api_get_user_info();
426 426
 		$_course = api_get_course_info();
427
-        $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
427
+        $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
428 428
 
429 429
         $upload_ok = true;
430 430
         $has_attachment = false;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 		if (!empty($_FILES['user_upload']['name'])) {
435 435
 			$upload_ok = process_uploaded_file($_FILES['user_upload']);
436
-			$has_attachment=true;
436
+			$has_attachment = true;
437 437
 		}
438 438
 
439 439
 		if ($upload_ok) {
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 
443 443
 			// Create the comment
444 444
 			$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
445
-					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
445
+					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int) $_user['user_id']."','".$current_date."', '".(int) $blog_id."', '".(int) $post_id."', '".(int) $parent_id."', '".(int) $task_id."')";
446 446
 			Database::query($sql);
447 447
 
448 448
 			// Empty post values, or they are shown on the page again
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             }
455 455
 
456 456
 			if ($has_attachment) {
457
-				$courseDir   = $_course['path'].'/upload/blog';
457
+				$courseDir = $_course['path'].'/upload/blog';
458 458
 				$sys_course_path = api_get_path(SYS_COURSE_PATH);
459 459
 				$updir = $sys_course_path.$courseDir;
460 460
 
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 				);
466 466
 
467 467
 				// user's file name
468
-				$file_name =$_FILES['user_upload']['name'];
468
+				$file_name = $_FILES['user_upload']['name'];
469 469
 
470 470
 				if (!filter_extension($new_file_name)) {
471 471
 					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
472 472
 				} else {
473 473
 					$new_file_name = uniqid('');
474
-					$new_path=$updir.'/'.$new_file_name;
475
-					$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
474
+					$new_path = $updir.'/'.$new_file_name;
475
+					$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
476 476
 					$comment = Database::escape_string($file_comment);
477 477
 
478 478
 					// Storing the attachments if any
479 479
 					if ($result) {
480
-						$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
480
+						$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
481 481
 							 "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
482 482
 						Database::query($sql);
483 483
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 		// Delete them recursively
528 528
 		while ($comment = Database::fetch_array($result)) {
529
-			Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
529
+			Blog::delete_comment($blog_id, $post_id, $comment['comment_id']);
530 530
 		}
531 531
 
532 532
 		// Finally, delete the selected comment to
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
 		// Create the task
555 555
 		$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
556
-				VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
556
+				VALUES ($course_id , '".(int) $blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');";
557 557
 		Database::query($sql);
558 558
 
559 559
 		$task_id = Database::insert_id();
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
             Database::query($sql);
564 564
         }
565 565
 
566
-		$tool = 'BLOG_' . $blog_id;
566
+		$tool = 'BLOG_'.$blog_id;
567 567
 
568 568
 		if ($articleDelete == 'on') {
569
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
570
-					'" . (int)$course_id . "',
571
-					'" . (int)$task_id . "',
572
-					'" . Database::escape_string($tool) . "',
569
+			$sql = " INSERT INTO ".$tbl_tasks_permissions." ( c_id,  task_id, tool, action) VALUES (
570
+					'" . (int) $course_id."',
571
+					'" . (int) $task_id."',
572
+					'" . Database::escape_string($tool)."',
573 573
 					'article_delete'
574 574
 				)";
575 575
 			Database::query($sql);
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 
585 585
 		if ($articleEdit == 'on') {
586 586
 			$sql = "
587
-				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
588
-					'" . (int)$course_id . "',
589
-					'" . (int)$task_id . "',
590
-					'" . Database::escape_string($tool) . "',
587
+				INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES (
588
+					'" . (int) $course_id."',
589
+					'" . (int) $task_id."',
590
+					'" . Database::escape_string($tool)."',
591 591
 					'article_edit'
592 592
 				)";
593 593
 			Database::query($sql);
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
 
602 602
 		if ($commentsDelete == 'on') {
603 603
 			$sql = "
604
-				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
605
-					'" . (int)$course_id . "',
606
-					'" . (int)$task_id . "',
607
-					'" . Database::escape_string($tool) . "',
604
+				INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES (
605
+					'" . (int) $course_id."',
606
+					'" . (int) $task_id."',
607
+					'" . Database::escape_string($tool)."',
608 608
 					'article_comments_delete'
609 609
 				)";
610 610
 			Database::query($sql);
@@ -637,20 +637,20 @@  discard block
 block discarded – undo
637 637
 					title = '".Database::escape_string($title)."',
638 638
 					description = '".Database::escape_string($description)."',
639 639
 					color = '".Database::escape_string($color)."'
640
-				WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1";
640
+				WHERE c_id = $course_id AND task_id ='".(int) $task_id."' LIMIT 1";
641 641
 		Database::query($sql);
642 642
 
643
-		$tool = 'BLOG_' . $blog_id;
643
+		$tool = 'BLOG_'.$blog_id;
644 644
 
645
-		$sql = "DELETE FROM " . $tbl_tasks_permissions . "
646
-				WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
645
+		$sql = "DELETE FROM ".$tbl_tasks_permissions."
646
+				WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
647 647
 		Database::query($sql);
648 648
 
649 649
 		if ($articleDelete == 'on') {
650
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
651
-					'" . (int)$course_id . "',
652
-					'" . (int)$task_id . "',
653
-					'" . Database::escape_string($tool) . "',
650
+			$sql = "INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES (
651
+					'" . (int) $course_id."',
652
+					'" . (int) $task_id."',
653
+					'" . Database::escape_string($tool)."',
654 654
 					'article_delete'
655 655
 				)";
656 656
 			Database::query($sql);
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 		}
664 664
 
665 665
 		if ($articleEdit == 'on') {
666
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
667
-					'" . (int)$course_id . "',
668
-					'" . (int)$task_id . "',
669
-					'" . Database::escape_string($tool) . "',
666
+			$sql = "INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES (
667
+					'" . (int) $course_id."',
668
+					'" . (int) $task_id."',
669
+					'" . Database::escape_string($tool)."',
670 670
 					'article_edit'
671 671
 				)";
672 672
 			Database::query($sql);
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
 		}
680 680
 
681 681
 		if ($commentsDelete == 'on') {
682
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
683
-					'" . (int)$course_id . "',
684
-					'" . (int)$task_id . "',
685
-					'" . Database::escape_string($tool) . "',
682
+			$sql = " INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES (
683
+					'" . (int) $course_id."',
684
+					'" . (int) $task_id."',
685
+					'" . Database::escape_string($tool)."',
686 686
 					'article_comments_delete'
687 687
 				)";
688 688
 			Database::query($sql);
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 
708 708
 		// Delete posts
709 709
 		$sql = "DELETE FROM $tbl_blogs_tasks
710
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
710
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND task_id = '".(int) $task_id."'";
711 711
 		Database::query($sql);
712 712
 	}
713 713
 
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 		$sql = "DELETE FROM $tbl_blogs_tasks_rel_user
726 726
 				WHERE
727 727
 				    c_id = $course_id AND
728
-				    blog_id = '".(int)$blog_id."' AND
729
-				    task_id = '".(int)$task_id."' AND
730
-				    user_id = '".(int)$user_id."'";
728
+				    blog_id = '".(int) $blog_id."' AND
729
+				    task_id = '".(int) $task_id."' AND
730
+				    user_id = '".(int) $user_id."'";
731 731
 		Database::query($sql);
732 732
 	}
733 733
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		$_user = api_get_user_info();
742 742
 
743 743
 		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
744
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
744
+		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
745 745
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
746 746
 
747 747
 		$course_id = api_get_course_int_id();
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
                         task.c_id = $course_id AND
759 759
                         blog.c_id = $course_id AND
760 760
                         task_rel_user.c_id = $course_id AND
761
-                        task_rel_user.user_id = ".(int)$_user['user_id']."
761
+                        task_rel_user.user_id = ".(int) $_user['user_id']."
762 762
                     ORDER BY target_date ASC";
763 763
 
764 764
 			$result = Database::query($sql);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 
799 799
 		// Get blog properties
800 800
 		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
801
-				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
801
+				WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'";
802 802
 		$result = Database::query($sql);
803 803
 		$blog = Database::fetch_array($result);
804 804
 		$visibility = $blog['visibility'];
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 		if ($visibility == 1) {
808 808
 			// Change visibility state, remove from course home.
809 809
 			$sql = "UPDATE $tbl_blogs SET visibility = '0'
810
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
810
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
811 811
 			Database::query($sql);
812 812
 
813 813
 			$sql = "DELETE FROM $tbl_tool
@@ -816,11 +816,11 @@  discard block
 block discarded – undo
816 816
 		} else {
817 817
 			// Change visibility state, add to course home.
818 818
 			$sql = "UPDATE $tbl_blogs SET visibility = '1'
819
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
819
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
820 820
 			Database::query($sql);
821 821
 
822 822
 			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
823
-					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
823
+					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
824 824
 			Database::query($sql);
825 825
             $id = Database::insert_id();
826 826
 
@@ -851,14 +851,14 @@  discard block
 block discarded – undo
851 851
 		        FROM $tbl_blogs_posts post
852 852
                 INNER JOIN $tbl_users user
853 853
                 ON post.author_id = user.user_id
854
-				WHERE 	post.blog_id = '".(int)$blog_id."' AND
854
+				WHERE 	post.blog_id = '".(int) $blog_id."' AND
855 855
 						post.c_id = $course_id AND
856 856
 						$filter
857
-				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
857
+				ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts;
858 858
 		$result = Database::query($sql);
859 859
 
860 860
 		// Display
861
-		if(Database::num_rows($result) > 0) {
861
+		if (Database::num_rows($result) > 0) {
862 862
 		    $limit = 200;
863 863
 			while ($blog_post = Database::fetch_array($result)) {
864 864
 				// Get number of comments
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 						FROM $tbl_blogs_comments
867 867
 						WHERE
868 868
 						    c_id = $course_id AND
869
-						    blog_id = '".(int)$blog_id."' AND
870
-						    post_id = '" . (int)$blog_post['post_id']."'";
869
+						    blog_id = '".(int) $blog_id."' AND
870
+						    post_id = '" . (int) $blog_post['post_id']."'";
871 871
 				$tmp = Database::query($sql);
872 872
 				$blog_post_comments = Database::fetch_array($tmp);
873 873
 
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
 
879 879
 				// Create an introduction text (but keep FULL sentences)
880 880
 				$words = 0;
881
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
881
+				$blog_post_text_cut = cut($blog_post_text, $limit);
882 882
 				$words = strlen($blog_post_text);
883 883
 
884 884
 				if ($words >= $limit) {
885
-					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
885
+					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_'.$blog_post_id.'\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_'.$blog_post_id.'\').style.display=\'none\'">'.get_lang('ReadMore').'</div>';
886 886
 					$introduction_text = $blog_post_text_cut;
887 887
 				} else {
888 888
 				    $introduction_text = $blog_post_text;
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 					).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang(
901 901
 						'ReadPost'
902 902
 					).'" >'.$blog_post_date.'</a></span>';
903
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
904
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
903
+				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>';
904
+				echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>';
905 905
 
906
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
906
+				$file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0);
907 907
 
908 908
 				if (!empty($file_name_array)) {
909 909
 					echo '<br /><br />';
910
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
910
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
911 911
 					echo '<a href="download.php?'.api_get_cidreq().'&file=';
912 912
 					echo $file_name_array['path'];
913 913
 					echo ' "> '.$file_name_array['filename'].' </a><br />';
@@ -946,19 +946,19 @@  discard block
 block discarded – undo
946 946
 	 * @param Integer $blog_id
947 947
 	 * @param String $query_string
948 948
 	 */
949
-	public static function display_search_results ($blog_id, $query_string)
949
+	public static function display_search_results($blog_id, $query_string)
950 950
 	{
951 951
 		// Init
952 952
 		$query_string = Database::escape_string($query_string);
953
-		$query_string_parts = explode(' ',$query_string);
953
+		$query_string_parts = explode(' ', $query_string);
954 954
 		$query_string = array();
955 955
 		foreach ($query_string_parts as $query_part) {
956
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
956
+			$query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' ";
957 957
 		}
958
-		$query_string = '('.implode('OR',$query_string) . ')';
958
+		$query_string = '('.implode('OR', $query_string).')';
959 959
 
960 960
 		// Display the posts
961
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
961
+		echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>';
962 962
 		Blog::display_blog_posts($blog_id, $query_string);
963 963
 	}
964 964
 
@@ -971,14 +971,14 @@  discard block
 block discarded – undo
971 971
 	public static function display_day_results($blog_id, $query_string)
972 972
 	{
973 973
 		$date_output = $query_string;
974
-		$date = explode('-',$query_string);
975
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
974
+		$date = explode('-', $query_string);
975
+		$query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]);
976 976
 
977 977
 		// Put date in correct output format
978 978
 		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
979 979
 
980 980
 		// Display the posts
981
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
981
+		echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>';
982 982
 		Blog::display_blog_posts($blog_id, $query_string);
983 983
 	}
984 984
 
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 					ON post.author_id = user.user_id
1006 1006
                 WHERE
1007 1007
                     post.c_id = $course_id AND
1008
-                    post.blog_id = '".(int)$blog_id."' AND
1009
-                    post.post_id = '".(int)$post_id."'
1008
+                    post.blog_id = '".(int) $blog_id."' AND
1009
+                    post.post_id = '".(int) $post_id."'
1010 1010
                 ORDER BY post_id DESC";
1011 1011
 		$result = Database::query($sql);
1012 1012
 		$blog_post = Database::fetch_array($result);
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 		// Get number of comments
1015 1015
 		$sql = "SELECT COUNT(1) as number_of_comments
1016 1016
 		        FROM $tbl_blogs_comments
1017
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
1017
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'";
1018 1018
 		$result = Database::query($sql);
1019 1019
 		$blog_post_comments = Database::fetch_array($result);
1020 1020
 
@@ -1025,34 +1025,34 @@  discard block
 block discarded – undo
1025 1025
 
1026 1026
 		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
1027 1027
 
1028
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
1029
-			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">';
1030
-			$blog_post_actions .=  Display::return_icon('edit.png');
1028
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) {
1029
+			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('EditThisPost').'">';
1030
+			$blog_post_actions .= Display::return_icon('edit.png');
1031 1031
 			$blog_post_actions .= '</a>';
1032 1032
         }
1033 1033
 
1034
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
1035
-			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">';
1034
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) {
1035
+			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('DeleteThisArticle').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;">';
1036 1036
             $blog_post_actions .= Display::return_icon('delete.png');
1037 1037
             $blog_post_actions .= '</a>';
1038 1038
         }
1039 1039
 
1040
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1041
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1040
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_rate'))
1041
+			$rating_select = Blog::display_rating_form('post', $blog_id, $post_id);
1042 1042
 
1043
-		$blog_post_text=stripslashes($blog_post_text);
1043
+		$blog_post_text = stripslashes($blog_post_text);
1044 1044
 
1045 1045
 		// Display post
1046 1046
 		echo '<div class="blogpost">';
1047
-		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1048
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1049
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1047
+		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>';
1048
+		echo '<span class="blogpost_date">'.$blog_post_date.'</span>';
1049
+		echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />';
1050 1050
 
1051 1051
 		$file_name_array = get_blog_attachment($blog_id, $post_id);
1052 1052
 
1053 1053
         if (!empty($file_name_array)) {
1054 1054
 			echo ' <br />';
1055
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1055
+			echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1056 1056
 			echo '<a href="download.php?'.api_get_cidreq().'&file=';
1057 1057
 			echo $file_name_array['path'];
1058 1058
 			echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1080,19 +1080,19 @@  discard block
 block discarded – undo
1080 1080
                 $blog_id,
1081 1081
                 $post_id
1082 1082
             ).$rating_select.'</span>';
1083
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1083
+		echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>';
1084 1084
 		echo '</div>';
1085 1085
 
1086 1086
 		// Display comments if there are any
1087 1087
         if ($blog_post_comments['number_of_comments'] > 0) {
1088 1088
 			echo '<div class="comments">';
1089
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1089
+				echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />';
1090 1090
 				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1091 1091
 			echo '</div>';
1092 1092
 		}
1093 1093
 
1094 1094
 		// Display comment form
1095
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1095
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) {
1096 1096
 			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1097 1097
 		}
1098 1098
 	}
@@ -1120,16 +1120,16 @@  discard block
 block discarded – undo
1120 1120
 		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1121 1121
                 WHERE
1122 1122
                     c_id = $course_id AND
1123
-                    blog_id = '".(int)$blog_id."' AND
1124
-                    item_id = '".(int)$item_id."' AND
1123
+                    blog_id = '".(int) $blog_id."' AND
1124
+                    item_id = '".(int) $item_id."' AND
1125 1125
                     rating_type = '".Database::escape_string($type)."' AND
1126
-                    user_id = '".(int)$_user['user_id']."'";
1126
+                    user_id = '".(int) $_user['user_id']."'";
1127 1127
 		$result = Database::query($sql);
1128 1128
 
1129 1129
         // Add rating
1130 1130
 		if (Database::num_rows($result) == 0) {
1131 1131
 			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1132
-					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1132
+					VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')";
1133 1133
 			Database::query($sql);
1134 1134
 
1135 1135
             $id = Database::insert_id();
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1163 1163
 				WHERE
1164 1164
 				    c_id = $course_id AND
1165
-				    blog_id = '".(int)$blog_id."' AND
1166
-				    item_id = '".(int)$item_id."' AND
1165
+				    blog_id = '".(int) $blog_id."' AND
1166
+				    item_id = '".(int) $item_id."' AND
1167 1167
 				    rating_type = '".Database::escape_string($type)."' ";
1168 1168
 		$result = Database::query($sql);
1169 1169
 		$result = Database::fetch_array($result);
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 	 *
1181 1181
 	 *@return String
1182 1182
 	 */
1183
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1183
+	public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL)
1184 1184
 	{
1185 1185
 		$_user = api_get_user_info();
1186 1186
 		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
@@ -1190,10 +1190,10 @@  discard block
 block discarded – undo
1190 1190
 			// Check if the user has already rated this post
1191 1191
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1192 1192
 					WHERE c_id = $course_id AND
1193
-					blog_id = '".(int)$blog_id."'
1194
-					AND item_id = '".(int)$post_id."'
1193
+					blog_id = '".(int) $blog_id."'
1194
+					AND item_id = '".(int) $post_id."'
1195 1195
 					AND rating_type = '".Database::escape_string($type)."'
1196
-					AND user_id = '".(int)$_user['user_id']."'";
1196
+					AND user_id = '".(int) $_user['user_id']."'";
1197 1197
 			$result = Database::query($sql);
1198 1198
             // Add rating
1199 1199
             if (Database::num_rows($result) == 0) {
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
         if ($type = 'comment') {
1210 1210
 			// Check if the user has already rated this comment
1211 1211
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1212
-					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1213
-					AND item_id = '".(int)$comment_id."'
1212
+					WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."'
1213
+					AND item_id = '".(int) $comment_id."'
1214 1214
 					AND rating_type = '".Database::escape_string($type)."'
1215
-					AND user_id = '".(int)$_user['user_id']."'";
1215
+					AND user_id = '".(int) $_user['user_id']."'";
1216 1216
 			$result = Database::query($sql);
1217 1217
 
1218 1218
             if (Database::num_rows($result) == 0) {
@@ -1254,11 +1254,11 @@  discard block
 block discarded – undo
1254 1254
                 WHERE
1255 1255
                     comments.c_id = $course_id AND
1256 1256
                     parent_comment_id = $current AND
1257
-                    comments.blog_id = '".(int)$blog_id."' AND
1258
-                    comments.post_id = '".(int)$post_id."'";
1257
+                    comments.blog_id = '".(int) $blog_id."' AND
1258
+                    comments.post_id = '".(int) $post_id."'";
1259 1259
 		$result = Database::query($sql);
1260 1260
 
1261
-		while($comment = Database::fetch_array($result)) {
1261
+		while ($comment = Database::fetch_array($result)) {
1262 1262
 			// Select the children recursivly
1263 1263
 			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1264 1264
 			        FROM $tbl_blogs_comments comments
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 					WHERE
1268 1268
 						comments.c_id = $course_id AND
1269 1269
 						comment_id = $current
1270
-						AND blog_id = '".(int)$blog_id."'
1271
-						AND post_id = '".(int)$post_id."'";
1270
+						AND blog_id = '".(int) $blog_id."'
1271
+						AND post_id = '".(int) $post_id."'";
1272 1272
 			$tmp = Database::query($tmp);
1273 1273
 			$tmp = Database::fetch_array($tmp);
1274 1274
 			$parent_cat = $tmp['parent_comment_id'];
@@ -1293,27 +1293,27 @@  discard block
 block discarded – undo
1293 1293
 		    }
1294 1294
 
1295 1295
 			if (!is_null($comment['task_id'])) {
1296
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1296
+				$border_color = ' border-left: 3px solid #'.$comment['color'];
1297 1297
 			}
1298 1298
 
1299 1299
 			$comment_text = stripslashes($comment_text);
1300 1300
 
1301 1301
 			// Output...
1302 1302
 			$margin = $current_level * 30;
1303
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1303
+			echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">';
1304 1304
 			echo '<span class="blogpost_comment_title">
1305 1305
 						<a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes(
1306 1306
 					$comment['title']
1307 1307
 				).'\'" title="'.get_lang(
1308 1308
 					'ReplyToThisComment'
1309 1309
 				).'" >'.stripslashes($comment['title']).'</a></span>';
1310
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1311
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1310
+				echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>';
1311
+				echo '<span class="blogpost_text">'.$comment_text.'</span>';
1312 1312
 
1313
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1313
+				$file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']);
1314 1314
 				if (!empty($file_name_array)) {
1315 1315
 					echo '<br /><br />';
1316
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1316
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1317 1317
 					echo '<a href="download.php?'.api_get_cidreq().'&file=';
1318 1318
 					echo $file_name_array['path'];
1319 1319
 					echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 				}
1324 1324
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1325 1325
 				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1326
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1326
+				echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>';
1327 1327
 			echo '</div>';
1328 1328
 
1329 1329
 			// Go further down the tree.
@@ -1339,11 +1339,11 @@  discard block
 block discarded – undo
1339 1339
 	 */
1340 1340
 	public static function display_form_new_post($blog_id)
1341 1341
 	{
1342
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1342
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1343 1343
 			$form = new FormValidator(
1344 1344
 				'add_post',
1345 1345
 				'post',
1346
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1346
+				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(),
1347 1347
 				null,
1348 1348
 				array('enctype' => 'multipart/form-data')
1349 1349
 			);
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1388 1388
 				WHERE
1389 1389
 				post.c_id 			= $course_id AND
1390
-				post.blog_id 		= '".(int)$blog_id ."'
1391
-				AND post.post_id	= '".(int)$post_id."'
1390
+				post.blog_id 		= '".(int) $blog_id."'
1391
+				AND post.post_id	= '".(int) $post_id."'
1392 1392
 				ORDER BY post_id DESC";
1393 1393
 		$result = Database::query($sql);
1394 1394
 		$blog_post = Database::fetch_array($result);
@@ -1434,31 +1434,31 @@  discard block
 block discarded – undo
1434 1434
 		global $charset;
1435 1435
         $course_id = api_get_course_int_id();
1436 1436
 
1437
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1437
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1438 1438
 			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1439 1439
 			$counter = 0;
1440 1440
 			global $color2;
1441 1441
 
1442 1442
 			echo '<div class="actions">';
1443
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">';
1443
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=add">';
1444 1444
             echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks'));
1445
-            echo get_lang('AddTasks') . '</a> ';
1446
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">';
1445
+            echo get_lang('AddTasks').'</a> ';
1446
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=assign">';
1447 1447
             echo Display::return_icon('blog_task.gif', get_lang('AssignTasks'));
1448
-            echo get_lang('AssignTasks') . '</a>';
1448
+            echo get_lang('AssignTasks').'</a>';
1449 1449
 			?>
1450 1450
 				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>">
1451
-                    <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1451
+                    <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a>
1452 1452
 			<?php
1453 1453
 			echo '</div>';
1454 1454
 
1455
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1455
+			echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />';
1456 1456
 			echo "<table class=\"data_table\">";
1457 1457
 			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1458
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1459
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1460
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1461
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1458
+					 "<th width='240'><b>", get_lang('Title'), "</b></th>\n",
1459
+					 "<th><b>", get_lang('Description'), "</b></th>\n",
1460
+					 "<th><b>", get_lang('Color'), "</b></th>\n",
1461
+					 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1462 1462
 				"</tr>\n";
1463 1463
 
1464 1464
 
@@ -1470,31 +1470,31 @@  discard block
 block discarded – undo
1470 1470
                         description,
1471 1471
                         color,
1472 1472
                         system_task
1473
-                    FROM " . $tbl_blogs_tasks . "
1474
-                    WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1473
+                    FROM " . $tbl_blogs_tasks."
1474
+                    WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1475 1475
                     ORDER BY system_task, title";
1476 1476
 			$result = Database::query($sql);
1477 1477
 
1478 1478
 
1479
-			while($task = Database::fetch_array($result)) {
1479
+			while ($task = Database::fetch_array($result)) {
1480 1480
 				$counter++;
1481 1481
 				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1482 1482
 				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1483 1483
 				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1484
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1485
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1484
+				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id'];
1485
+				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1486 1486
 
1487
-				echo	'<tr class="' . $css_class . '" valign="top">',
1488
-                         '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1489
-                         '<td>' . Security::remove_XSS($task['description']) . '</td>',
1490
-                         '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1487
+				echo	'<tr class="'.$css_class.'" valign="top">',
1488
+                         '<td width="240">'.Security::remove_XSS($task['title']).'</td>',
1489
+                         '<td>'.Security::remove_XSS($task['description']).'</td>',
1490
+                         '<td><span style="background-color: #'.$task['color'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1491 1491
                          '<td width="50">',
1492
-                            '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1493
-                            '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1492
+                            '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">',
1493
+                            '<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1494 1494
                             "</a>\n",
1495
-                            '<a href="' . $delete_link . '"',
1495
+                            '<a href="'.$delete_link.'"',
1496 1496
                             $delete_confirm,
1497
-                            '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1497
+                            '><img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1498 1498
                             "</a>\n",
1499 1499
                          '</td>',
1500 1500
                     '</tr>';
@@ -1509,23 +1509,23 @@  discard block
 block discarded – undo
1509 1509
 	 *
1510 1510
 	 * @param Integer $blog_id
1511 1511
 	 */
1512
-	public static function display_assigned_task_list ($blog_id)
1512
+	public static function display_assigned_task_list($blog_id)
1513 1513
     {
1514 1514
 		// Init
1515 1515
 		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1516 1516
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1517 1517
 		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1518 1518
 		$counter = 0;
1519
-		global $charset,$color2;
1519
+		global $charset, $color2;
1520 1520
 
1521
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1521
+		echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />';
1522 1522
 		echo "<table class=\"data_table\">";
1523 1523
 		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1524
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1525
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1526
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1527
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1528
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1524
+				 "<th width='240'><b>", get_lang('Member'), "</b></th>\n",
1525
+				 "<th><b>", get_lang('Task'), "</b></th>\n",
1526
+				 "<th><b>", get_lang('Description'), "</b></th>\n",
1527
+				 "<th><b>", get_lang('TargetDate'), "</b></th>\n",
1528
+				 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1529 1529
 			"</tr>";
1530 1530
 
1531 1531
 		$course_id = api_get_course_int_id();
@@ -1537,32 +1537,32 @@  discard block
 block discarded – undo
1537 1537
 				WHERE
1538 1538
 				    task_rel_user.c_id = $course_id AND
1539 1539
 					task.c_id = $course_id AND
1540
-					task_rel_user.blog_id = '".(int)$blog_id."'
1540
+					task_rel_user.blog_id = '".(int) $blog_id."'
1541 1541
 				ORDER BY target_date ASC";
1542 1542
 		$result = Database::query($sql);
1543 1543
 
1544 1544
 		while ($assignment = Database::fetch_array($result)) {
1545 1545
 			$counter++;
1546
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1546
+			$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1547 1547
 			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1548 1548
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1549
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1550
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1549
+			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id'];
1550
+			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1551 1551
 
1552 1552
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1553 1553
 
1554
-			echo	'<tr class="' . $css_class . '" valign="top">',
1555
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1556
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1557
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1558
-						 '<td>' . $assignment['target_date'] . '</td>',
1554
+			echo	'<tr class="'.$css_class.'" valign="top">',
1555
+						 '<td width="240">'.Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)).'</td>',
1556
+						 '<td>'.stripslashes($assignment['title']).'</td>',
1557
+						 '<td>'.stripslashes($assignment['description']).'</td>',
1558
+						 '<td>'.$assignment['target_date'].'</td>',
1559 1559
 						 '<td width="50">',
1560
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1561
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1560
+						 	'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">',
1561
+							'<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1562 1562
 							"</a>\n",
1563
-							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1564
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1565
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1563
+							'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ',
1564
+							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"',
1565
+							'<img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1566 1566
 							"</a>\n",
1567 1567
 						 '</td>',
1568 1568
 					'</tr>';
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
 	 * @author Toon Keppens
1576 1576
 	 *
1577 1577
 	 */
1578
-	public static function display_new_task_form ($blog_id)
1578
+	public static function display_new_task_form($blog_id)
1579 1579
 	{
1580 1580
 		// Init
1581 1581
         $colors = array(
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 		// task title
1607 1607
 		echo '	<div class="control-group">
1608 1608
 					<label class="control-label">
1609
-						<span class="form_required">*</span>' . get_lang('Title') . '
1609
+						<span class="form_required">*</span>' . get_lang('Title').'
1610 1610
 					</label>
1611 1611
 					<div class="controls">
1612 1612
 						<input name="task_name" type="text" size="70" />
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 		// task comment
1617 1617
 		echo '	<div class="control-group">
1618 1618
 					<label class="control-label">
1619
-						' . get_lang('Description') . '
1619
+						' . get_lang('Description').'
1620 1620
 					</label>
1621 1621
 					<div class="controls">
1622 1622
 						<textarea name="task_description" cols="45"></textarea>
@@ -1626,18 +1626,18 @@  discard block
 block discarded – undo
1626 1626
 		// task management
1627 1627
 		echo '	<div class="control-group">
1628 1628
 					<label class="control-label">
1629
-						' . get_lang('TaskManager') . '
1629
+						' . get_lang('TaskManager').'
1630 1630
 					</label>
1631 1631
 					<div class="controls">';
1632 1632
                 echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1633 1633
                     echo '<tr>';
1634
-                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1635
-                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1634
+                        echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>';
1635
+                        echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1636 1636
                     echo '</tr>';
1637 1637
                     echo '<tr>';
1638
-                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1639
-                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1640
-                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1638
+                        echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>';
1639
+                        echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>';
1640
+                        echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>';
1641 1641
                     echo '</tr>';
1642 1642
                     echo '<tr>';
1643 1643
                         echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
@@ -1652,13 +1652,13 @@  discard block
 block discarded – undo
1652 1652
 		// task color
1653 1653
 		echo '	<div class="control-group">
1654 1654
 					<label class="control-label">
1655
-						' . get_lang('Color') . '
1655
+						' . get_lang('Color').'
1656 1656
 					</label>
1657 1657
 					<div class="controls">';
1658 1658
         echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
1659 1659
                 foreach ($colors as $color) {
1660
-                    $style = 'style="background-color: #' . $color . '"';
1661
-                    echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1660
+                    $style = 'style="background-color: #'.$color.'"';
1661
+                    echo '<option value="'.$color.'" '.$style.'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1662 1662
                 }
1663 1663
         echo '</select>';
1664 1664
 		echo '		</div>
@@ -1669,7 +1669,7 @@  discard block
 block discarded – undo
1669 1669
 					<div class="controls">
1670 1670
 							<input type="hidden" name="action" value="" />
1671 1671
 							<input type="hidden" name="new_task_submit" value="true" />
1672
-						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1672
+						<button class="save" type="submit" name="Submit">' . get_lang('Save').'</button>
1673 1673
 					</div>
1674 1674
 				</div>';
1675 1675
 		echo '</form>';
@@ -1683,14 +1683,14 @@  discard block
 block discarded – undo
1683 1683
 	 * @author Toon Keppens
1684 1684
 	 *
1685 1685
 	 */
1686
-	public static function display_edit_task_form ($blog_id, $task_id) {
1686
+	public static function display_edit_task_form($blog_id, $task_id) {
1687 1687
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1688 1688
         $course_id = api_get_course_int_id();
1689 1689
 
1690
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1690
+		$colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000');
1691 1691
 
1692 1692
 		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks
1693
-				WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1693
+				WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1694 1694
 		$result = Database::query($sql);
1695 1695
 		$task = Database::fetch_array($result);
1696 1696
 
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
 		);
1719 1719
 
1720 1720
 		$sql = " SELECT id, action FROM ".$tbl_tasks_permissions."
1721
-							 WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1721
+							 WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1722 1722
 		$result = Database::query($sql);
1723 1723
 
1724 1724
 		$arrPermissions = array();
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 				FROM $tbl_users user
1812 1812
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1813 1813
 				ON user.user_id = blogs_rel_user.user_id
1814
-				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1814
+				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'";
1815 1815
 		$result = Database::query($sql);
1816 1816
 
1817 1817
 		$options = array();
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 				color,
1831 1831
 				system_task
1832 1832
 			FROM $tbl_blogs_tasks
1833
-			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1833
+			WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1834 1834
 			ORDER BY system_task, title";
1835 1835
 		$result = Database::query($sql);
1836 1836
 
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
 	 */
1878 1878
 	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1879 1879
 	{
1880
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1880
+		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1881 1881
 
1882 1882
 		$course_id = api_get_course_int_id();
1883 1883
 
@@ -1886,9 +1886,9 @@  discard block
 block discarded – undo
1886 1886
 			SELECT target_date
1887 1887
 			FROM $tbl_blogs_tasks_rel_user
1888 1888
 			WHERE c_id = $course_id AND
1889
-			      blog_id = '".(int)$blog_id."' AND
1890
-			      user_id = '".(int)$user_id."' AND
1891
-			      task_id = '".(int)$task_id."'";
1889
+			      blog_id = '".(int) $blog_id."' AND
1890
+			      user_id = '".(int) $user_id."' AND
1891
+			      task_id = '".(int) $task_id."'";
1892 1892
 		$result = Database::query($sql);
1893 1893
 		$row = Database::fetch_assoc($result);
1894 1894
 
@@ -1923,11 +1923,11 @@  discard block
 block discarded – undo
1923 1923
 
1924 1924
 		$sql = "
1925 1925
 			SELECT COUNT(*) as 'number'
1926
-			FROM " . $tbl_blogs_tasks_rel_user . "
1926
+			FROM " . $tbl_blogs_tasks_rel_user."
1927 1927
 			WHERE c_id = $course_id AND
1928
-			blog_id = " . (int)$blog_id . "
1929
-			AND	user_id = " . (int)$user_id . "
1930
-			AND	task_id = " . (int)$task_id . "
1928
+			blog_id = ".(int) $blog_id."
1929
+			AND	user_id = " . (int) $user_id."
1930
+			AND	task_id = " . (int) $task_id."
1931 1931
 		";
1932 1932
 
1933 1933
 		$result = Database::query($sql);
@@ -1935,18 +1935,18 @@  discard block
 block discarded – undo
1935 1935
 
1936 1936
 		if ($row['number'] == 0) {
1937 1937
 			$sql = "
1938
-				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1938
+				INSERT INTO " . $tbl_blogs_tasks_rel_user." (
1939 1939
 					c_id,
1940 1940
 					blog_id,
1941 1941
 					user_id,
1942 1942
 					task_id,
1943 1943
 					target_date
1944 1944
 				) VALUES (
1945
-					'" . (int)$course_id . "',
1946
-					'" . (int)$blog_id . "',
1947
-					'" . (int)$user_id . "',
1948
-					'" . (int)$task_id . "',
1949
-					'" . Database::escape_string($target_date) . "'
1945
+					'" . (int) $course_id."',
1946
+					'" . (int) $blog_id."',
1947
+					'" . (int) $user_id."',
1948
+					'" . (int) $task_id."',
1949
+					'" . Database::escape_string($target_date)."'
1950 1950
 				)";
1951 1951
 
1952 1952
 			Database::query($sql);
@@ -1976,12 +1976,12 @@  discard block
 block discarded – undo
1976 1976
 		$course_id = api_get_course_int_id();
1977 1977
 
1978 1978
 		$sql = "SELECT COUNT(*) as 'number'
1979
-                FROM " . $tbl_blogs_tasks_rel_user . "
1979
+                FROM " . $tbl_blogs_tasks_rel_user."
1980 1980
                 WHERE
1981 1981
                     c_id = $course_id AND
1982
-                    blog_id = " . (int)$blog_id . " AND
1983
-                    user_id = " . (int)$user_id . " AND
1984
-                    task_id = " . (int)$task_id . "
1982
+                    blog_id = ".(int) $blog_id." AND
1983
+                    user_id = " . (int) $user_id." AND
1984
+                    task_id = " . (int) $task_id."
1985 1985
             ";
1986 1986
 
1987 1987
 		$result = Database::query($sql);
@@ -1989,17 +1989,17 @@  discard block
 block discarded – undo
1989 1989
 
1990 1990
 		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1991 1991
 			$sql = "
1992
-				UPDATE " . $tbl_blogs_tasks_rel_user . "
1992
+				UPDATE " . $tbl_blogs_tasks_rel_user."
1993 1993
 				SET
1994
-					user_id = " . (int)$user_id . ",
1995
-					task_id = " . (int)$task_id . ",
1996
-					target_date = '" . Database::escape_string($target_date) . "'
1994
+					user_id = " . (int) $user_id.",
1995
+					task_id = " . (int) $task_id.",
1996
+					target_date = '" . Database::escape_string($target_date)."'
1997 1997
 				WHERE
1998 1998
 					c_id = $course_id AND
1999
-					blog_id = " . (int)$blog_id . " AND
2000
-					user_id = " . (int)$old_user_id . " AND
2001
-					task_id = " . (int)$old_task_id . " AND
2002
-					target_date = '" . Database::escape_string($old_target_date) . "'
1999
+					blog_id = ".(int) $blog_id." AND
2000
+					user_id = " . (int) $old_user_id." AND
2001
+					task_id = " . (int) $old_task_id." AND
2002
+					target_date = '" . Database::escape_string($old_target_date)."'
2003 2003
 			";
2004 2004
 			Database::query($sql);
2005 2005
 		}
@@ -2020,7 +2020,7 @@  discard block
 block discarded – undo
2020 2020
 
2021 2021
 
2022 2022
 		$sql = "SELECT title, description FROM $tbl_blogs_tasks
2023
-				WHERE task_id = '".(int)$task_id."'
2023
+				WHERE task_id = '".(int) $task_id."'
2024 2024
 				AND c_id = $course_id";
2025 2025
 		$result = Database::query($sql);
2026 2026
 		$row = Database::fetch_assoc($result);
@@ -2028,17 +2028,17 @@  discard block
 block discarded – undo
2028 2028
 		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
2029 2029
 				FROM $tbl_blogs_posts post
2030 2030
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
2031
-				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
2031
+				WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id
2032 2032
 				ORDER BY post_id DESC
2033 2033
 				LIMIT 0, 100";
2034 2034
 		$result = Database::query($sql);
2035 2035
 
2036 2036
 		// Display
2037
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
2038
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
2037
+		echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>';
2038
+		echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>';
2039 2039
 
2040 2040
 		if (Database::num_rows($result) > 0) {
2041
-			while($blog_post = Database::fetch_array($result)) {
2041
+			while ($blog_post = Database::fetch_array($result)) {
2042 2042
 			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
2043 2043
 				echo '<a href="blog.php?'.api_get_cidreq(
2044 2044
 					).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.
@@ -2078,12 +2078,12 @@  discard block
 block discarded – undo
2078 2078
 
2079 2079
 		// Subscribe the user
2080 2080
 		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
2081
-		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
2081
+		        VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');";
2082 2082
 		Database::query($sql);
2083 2083
 
2084 2084
 		// Give this user basic rights
2085 2085
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2086
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
2086
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')";
2087 2087
 		Database::query($sql);
2088 2088
 
2089 2089
         $id = Database::insert_id();
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
         }
2094 2094
 
2095 2095
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
2096
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
2096
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')";
2097 2097
 		Database::query($sql);
2098 2098
 
2099 2099
         $id = Database::insert_id();
@@ -2119,12 +2119,12 @@  discard block
 block discarded – undo
2119 2119
 
2120 2120
 		// Unsubscribe the user
2121 2121
 		$sql = "DELETE FROM $tbl_blogs_rel_user
2122
-		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
2122
+		        WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'";
2123 2123
 		Database::query($sql);
2124 2124
 
2125 2125
 		// Remove this user's permissions.
2126 2126
 		$sql = "DELETE FROM $tbl_user_permissions
2127
-		        WHERE user_id = '".(int)$user_id."'";
2127
+		        WHERE user_id = '".(int) $user_id."'";
2128 2128
 		Database::query($sql);
2129 2129
 	}
2130 2130
 
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
 		$course_id = $_course['real_id'];
2146 2146
 
2147 2147
 		$currentCourse = $_course['code'];
2148
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2148
+		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2149 2149
 		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2150 2150
 
2151 2151
 		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
@@ -2160,12 +2160,12 @@  discard block
 block discarded – undo
2160 2160
 		$result = Database::query($sql);
2161 2161
 
2162 2162
 		$blog_member_ids = array();
2163
-		while($user = Database::fetch_array($result)) {
2163
+		while ($user = Database::fetch_array($result)) {
2164 2164
 			$blog_member_ids[] = $user['user_id'];
2165 2165
 		}
2166 2166
 
2167 2167
 		// Set table headers
2168
-		$column_header[] = array ('', false, '');
2168
+		$column_header[] = array('', false, '');
2169 2169
 		if ($is_western_name_order) {
2170 2170
 			$column_header[] = array(get_lang('FirstName'), true, '');
2171 2171
 			$column_header[] = array(get_lang('LastName'), true, '');
@@ -2185,13 +2185,13 @@  discard block
 block discarded – undo
2185 2185
 
2186 2186
 		// Add users that are not in this blog to the list.
2187 2187
 		foreach ($student_list as $key=>$user) {
2188
-			if(isset($user['id_user'])) {
2188
+			if (isset($user['id_user'])) {
2189 2189
 				$user['user_id'] = $user['id_user'];
2190 2190
 			}
2191
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2191
+			if (!in_array($user['user_id'], $blog_member_ids)) {
2192 2192
 				$a_infosUser = api_get_user_info($user['user_id']);
2193
-				$row = array ();
2194
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2193
+				$row = array();
2194
+				$row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>';
2195 2195
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2196 2196
 				if ($is_western_name_order) {
2197 2197
 					$row[] = $a_infosUser["firstname"];
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 				//Link to register users
2206 2206
 				$currentUserId = api_get_user_id();
2207 2207
 				if ($a_infosUser["user_id"] != $currentUserId) {
2208
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2208
+					$row[] = "<a class=\"btn btn-primary \" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=".$a_infosUser["user_id"]."\">".get_lang('Register')."</a>";
2209 2209
 				} else {
2210 2210
 					$row[] = '';
2211 2211
 				}
@@ -2218,9 +2218,9 @@  discard block
 block discarded – undo
2218 2218
 		$query_vars['blog_id'] = $blog_id;
2219 2219
 		echo '<form method="post" action="blog.php?'.api_get_cidreq(
2220 2220
 			).'&action=manage_members&blog_id='.$blog_id.'">';
2221
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2221
+			Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2222 2222
 			$link = '';
2223
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2223
+			$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2224 2224
 			$link .= "blog_id=$blog_id&";
2225 2225
 
2226 2226
 		echo '<a href="blog.php?'.api_get_cidreq(
@@ -2228,12 +2228,12 @@  discard block
 block discarded – undo
2228 2228
 		echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2229 2229
 				'UnSelectAll'
2230 2230
 			).'</a> ';
2231
-			echo get_lang('WithSelected') . ' : ';
2231
+			echo get_lang('WithSelected').' : ';
2232 2232
 			echo '<select name="action">';
2233
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2233
+			echo '<option value="select_subscribe">'.get_lang('Register').'</option>';
2234 2234
 			echo '</select>';
2235 2235
 			echo '<input type="hidden" name="register" value="true" />';
2236
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2236
+			echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2237 2237
 		echo '</form>';
2238 2238
 	}
2239 2239
 
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
 	 *
2247 2247
 	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2248 2248
 	 */
2249
-	public static function display_form_user_unsubscribe ($blog_id)
2249
+	public static function display_form_user_unsubscribe($blog_id)
2250 2250
 	{
2251 2251
 		$_user = api_get_user_info();
2252 2252
 		$is_western_name_order = api_is_western_name_order();
@@ -2259,34 +2259,34 @@  discard block
 block discarded – undo
2259 2259
 
2260 2260
 		$properties["width"] = "100%";
2261 2261
 		//table column titles
2262
-		$column_header[] = array ('', false, '');
2262
+		$column_header[] = array('', false, '');
2263 2263
 		if ($is_western_name_order) {
2264
-			$column_header[] = array (get_lang('FirstName'), true, '');
2265
-			$column_header[] = array (get_lang('LastName'), true, '');
2264
+			$column_header[] = array(get_lang('FirstName'), true, '');
2265
+			$column_header[] = array(get_lang('LastName'), true, '');
2266 2266
 		} else {
2267
-			$column_header[] = array (get_lang('LastName'), true, '');
2268
-			$column_header[] = array (get_lang('FirstName'), true, '');
2267
+			$column_header[] = array(get_lang('LastName'), true, '');
2268
+			$column_header[] = array(get_lang('FirstName'), true, '');
2269 2269
 		}
2270
-		$column_header[] = array (get_lang('Email'), false, '');
2271
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2272
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2270
+		$column_header[] = array(get_lang('Email'), false, '');
2271
+		$column_header[] = array(get_lang('TaskManager'), true, '');
2272
+		$column_header[] = array(get_lang('UnRegister'), false, '');
2273 2273
 
2274 2274
 		$course_id = api_get_course_int_id();
2275 2275
 
2276 2276
 		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2277 2277
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2278 2278
                 ON user.user_id = blogs_rel_user.user_id
2279
-                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2279
+                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int) $blog_id."'";
2280 2280
 
2281 2281
 		if (!($sql_result = Database::query($sql))) {
2282 2282
 			return false;
2283 2283
 		}
2284 2284
 
2285
-		$user_data = array ();
2285
+		$user_data = array();
2286 2286
 
2287 2287
 		while ($myrow = Database::fetch_array($sql_result)) {
2288
-			$row = array ();
2289
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2288
+			$row = array();
2289
+			$row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>';
2290 2290
 			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2291 2291
 			if ($is_western_name_order) {
2292 2292
 				$row[] = $myrow["firstname"];
@@ -2298,19 +2298,19 @@  discard block
 block discarded – undo
2298 2298
 			$row[] = Display::icon_mailto_link($myrow["email"]);
2299 2299
 
2300 2300
 			$sql = "SELECT bt.title task
2301
-					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2302
-					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2301
+					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu
2302
+					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt
2303 2303
 					ON btu.task_id = bt.task_id
2304 2304
 					WHERE 	btu.c_id 	= $course_id  AND
2305 2305
 							bt.c_id 	= $course_id  AND
2306 2306
 							btu.blog_id = $blog_id AND
2307
-							btu.user_id = " . $myrow['user_id'];
2307
+							btu.user_id = ".$myrow['user_id'];
2308 2308
 			$sql_res = Database::query($sql);
2309 2309
 
2310 2310
 			$task = '';
2311 2311
 
2312
-			while($r = Database::fetch_array($sql_res)) {
2313
-				$task .= stripslashes($r['task']) . ', ';
2312
+			while ($r = Database::fetch_array($sql_res)) {
2313
+				$task .= stripslashes($r['task']).', ';
2314 2314
 			}
2315 2315
 			//echo $task;
2316 2316
 			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 			//Link to register users
2319 2319
 
2320 2320
 			if ($myrow["user_id"] != $_user['user_id']) {
2321
-				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2321
+				$row[] = "<a class=\"btn btn-primary\" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=".$myrow['user_id']."\">".get_lang('UnRegister')."</a>";
2322 2322
 			} else {
2323 2323
 				$row[] = '';
2324 2324
 			}
@@ -2330,9 +2330,9 @@  discard block
 block discarded – undo
2330 2330
 		$query_vars['blog_id'] = $blog_id;
2331 2331
 		echo '<form method="post" action="blog.php?'.api_get_cidreq(
2332 2332
 			).'&action=manage_members&blog_id='.$blog_id.'">';
2333
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2333
+		Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2334 2334
 		$link = '';
2335
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2335
+		$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2336 2336
 		$link .= "blog_id=$blog_id&";
2337 2337
 
2338 2338
 		echo '<a href="blog.php?'.api_get_cidreq(
@@ -2342,12 +2342,12 @@  discard block
 block discarded – undo
2342 2342
 		echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang(
2343 2343
 				'UnSelectAll'
2344 2344
 			).'</a> ';
2345
-		echo get_lang('WithSelected') . ' : ';
2345
+		echo get_lang('WithSelected').' : ';
2346 2346
 		echo '<select name="action">';
2347
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2347
+		echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>';
2348 2348
 		echo '</select>';
2349 2349
 		echo '<input type="hidden" name="unregister" value="true" />';
2350
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2350
+		echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2351 2351
 		echo '</form>';
2352 2352
 	}
2353 2353
 
@@ -2357,7 +2357,7 @@  discard block
 block discarded – undo
2357 2357
 	 *
2358 2358
 	 * @param Integer $blog_id
2359 2359
 	 */
2360
-	public static function display_form_user_rights ($blog_id)
2360
+	public static function display_form_user_rights($blog_id)
2361 2361
     {
2362 2362
 		echo '<legend>'.get_lang('RightsManager').'</legend>';
2363 2363
 		echo '<br />';
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 		$form = new FormValidator(
2378 2378
 			'add_post',
2379 2379
 			'post',
2380
-			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2380
+			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=".intval($blog_id)."&post_id=".intval($post_id)."&".api_get_cidreq(),
2381 2381
 			null,
2382 2382
 			array('enctype' => 'multipart/form-data')
2383 2383
 		);
@@ -2445,14 +2445,14 @@  discard block
 block discarded – undo
2445 2445
 		$course_id = api_get_course_int_id();
2446 2446
 
2447 2447
 		//Handle leap year
2448
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2448
+		$numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2449 2449
 
2450
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2450
+		if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2451 2451
 			$numberofdays[2] = 29;
2452 2452
 
2453 2453
 		//Get the first day of the month
2454 2454
 		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2455
-		$monthName = $MonthsLong[$month-1];
2455
+		$monthName = $MonthsLong[$month - 1];
2456 2456
 
2457 2457
 		//Start the week on monday
2458 2458
 		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
@@ -2470,15 +2470,15 @@  discard block
 block discarded – undo
2470 2470
 				ON post.author_id = user.user_id
2471 2471
 				WHERE
2472 2472
 					post.c_id = $course_id AND
2473
-					post.blog_id = '".(int)$blog_id."' AND
2474
-					MONTH(date_creation) = '".(int)$month."' AND
2475
-					YEAR(date_creation) = '".(int)$year."'
2473
+					post.blog_id = '".(int) $blog_id."' AND
2474
+					MONTH(date_creation) = '".(int) $month."' AND
2475
+					YEAR(date_creation) = '".(int) $year."'
2476 2476
 				ORDER BY date_creation";
2477 2477
 		$result = Database::query($sql);
2478 2478
 
2479 2479
 		// We will create an array of days on which there are posts.
2480
-		if( Database::num_rows($result) > 0) {
2481
-			while($blog_post = Database::fetch_array($result)) {
2480
+		if (Database::num_rows($result) > 0) {
2481
+			while ($blog_post = Database::fetch_array($result)) {
2482 2482
 				// If the day of this post is not yet in the array, add it.
2483 2483
 				if (!in_array($blog_post['post_day'], $posts))
2484 2484
 					$posts[] = $blog_post['post_day'];
@@ -2495,9 +2495,9 @@  discard block
 block discarded – undo
2495 2495
 					task_rel_user.c_id = $course_id AND
2496 2496
 					task.c_id = $course_id AND
2497 2497
 					blog.c_id = $course_id AND
2498
-					task_rel_user.user_id = '".(int)$_user['user_id']."' AND
2499
-					MONTH(target_date) = '".(int)$month."' AND
2500
-					YEAR(target_date) = '".(int)$year."'
2498
+					task_rel_user.user_id = '".(int) $_user['user_id']."' AND
2499
+					MONTH(target_date) = '".(int) $month."' AND
2500
+					YEAR(target_date) = '".(int) $year."'
2501 2501
 				ORDER BY target_date ASC";
2502 2502
 			$result = Database::query($sql);
2503 2503
 
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
 
2521 2521
 		echo "<tr>\n";
2522 2522
 
2523
-		for($ii = 1; $ii < 8; $ii ++)
2523
+		for ($ii = 1; $ii < 8; $ii++)
2524 2524
 			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2525 2525
 
2526 2526
 		echo "</tr>";
@@ -2530,23 +2530,23 @@  discard block
 block discarded – undo
2530 2530
 
2531 2531
 		while ($curday <= $numberofdays[$month]) {
2532 2532
 			echo "<tr>";
2533
-			for ($ii = 0; $ii < 7; $ii ++) {
2533
+			for ($ii = 0; $ii < 7; $ii++) {
2534 2534
 				if (($curday == -1) && ($ii == $startdayofweek))
2535 2535
 					$curday = 1;
2536 2536
 
2537 2537
 			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2538
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2538
+					$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
2539 2539
 					$dayheader = "$curday";
2540 2540
 
2541
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2541
+					if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2542 2542
 						$dayheader = "$curday";
2543 2543
 						$class = "class=\"days_today\"";
2544 2544
 					}
2545 2545
 
2546
-					echo "<td " . $class.">";
2546
+					echo "<td ".$class.">";
2547 2547
 
2548 2548
 					// If there are posts on this day, create a filter link.
2549
-					if(in_array($curday, $posts))
2549
+					if (in_array($curday, $posts))
2550 2550
 						echo '<a href="blog.php?'.api_get_cidreq(
2551 2551
 							).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang(
2552 2552
 								'ViewPostsOfThisDay'
@@ -2567,13 +2567,13 @@  discard block
 block discarded – undo
2567 2567
 									).' : '.$task['blog_name'].' - '.get_lang(
2568 2568
 										'ExecuteThisTask'
2569 2569
 									).'">
2570
-								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2570
+								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask').'" /></a>';
2571 2571
 							}
2572 2572
 						}
2573 2573
 					}
2574 2574
 
2575 2575
 					echo "</td>";
2576
-					$curday ++;
2576
+					$curday++;
2577 2577
 				} else
2578 2578
 					echo "<td>&nbsp;</td>";
2579 2579
 			}
@@ -2614,7 +2614,7 @@  discard block
 block discarded – undo
2614 2614
 	public static function display_edit_blog_form($blog_id)
2615 2615
 	{
2616 2616
 	    $course_id = api_get_course_int_id();
2617
-		$blog_id= intval($blog_id);
2617
+		$blog_id = intval($blog_id);
2618 2618
 		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2619 2619
 
2620 2620
 		$sql = "SELECT blog_id, blog_name, blog_subtitle
@@ -2672,8 +2672,8 @@  discard block
 block discarded – undo
2672 2672
 		$result = Database::query($sql);
2673 2673
 		$list_info = array();
2674 2674
 		if (Database::num_rows($result)) {
2675
-			while ($row_project=Database::fetch_row($result)) {
2676
-				$list_info[]=$row_project;
2675
+			while ($row_project = Database::fetch_row($result)) {
2676
+				$list_info[] = $row_project;
2677 2677
 			}
2678 2678
 		}
2679 2679
 
@@ -2685,39 +2685,39 @@  discard block
 block discarded – undo
2685 2685
 				// Validation when belongs to a session
2686 2686
 				$session_img = api_get_session_image($info_log[4], $_user['status']);
2687 2687
 
2688
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2688
+				$url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq();
2689 2689
 				$title = $info_log[0];
2690 2690
                         $image = Display::return_icon('blog.png', $title);
2691
-    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2691
+    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">'.$image.'</a></div><a href="'.$url_start_blog.'">'.$title.'</a>'.$session_img;
2692 2692
 
2693 2693
 				$list_body_blog[] = $list_name;
2694 2694
 				$list_body_blog[] = $info_log[1];
2695 2695
 
2696
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2697
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2698
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2699
-                                $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2696
+				$visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible';
2697
+				$visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible';
2698
+			 	$my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">';
2699
+                                $my_image .= Display::return_icon('edit.png', get_lang('EditBlog'));
2700 2700
 
2701
-				$my_image.= "</a>\n";
2702
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2703
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2704
-                                $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2701
+				$my_image .= "</a>\n";
2702
+				$my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" ';
2703
+				$my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >';
2704
+                                $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2705 2705
 
2706
-				$my_image.= "</a>\n";
2707
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2708
-                                $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2706
+				$my_image .= "</a>\n";
2707
+				$my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">';
2708
+                                $my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info));
2709 2709
 
2710
-				$my_image.= "</a>\n";
2710
+				$my_image .= "</a>\n";
2711 2711
 
2712
-				$list_body_blog[]=$my_image;
2712
+				$list_body_blog[] = $my_image;
2713 2713
 
2714
-				$list_content_blog[]=$list_body_blog;
2714
+				$list_content_blog[] = $list_body_blog;
2715 2715
 				$list_body_blog = array();
2716 2716
 
2717 2717
 			}
2718
-			$parameters='';
2718
+			$parameters = '';
2719 2719
 			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2720
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2720
+			$table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project');
2721 2721
 			//$table->set_additional_parameters($parameters);
2722 2722
 			$table->set_header(0, get_lang('Title'));
2723 2723
 			$table->set_header(1, get_lang('SubTitle'));
@@ -2742,34 +2742,34 @@  discard block
 block discarded – undo
2742 2742
  * @author Julio Montoya Dokeos
2743 2743
  * @version avril 2008, dokeos 1.8.5
2744 2744
  */
2745
-function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2745
+function get_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2746 2746
 {
2747 2747
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2748 2748
 
2749 2749
 	$blog_id = intval($blog_id);
2750 2750
 	$comment_id = intval($comment_id);
2751 2751
 	$post_id = intval($post_id);
2752
-	$row=array();
2753
-	$where='';
2752
+	$row = array();
2753
+	$where = '';
2754 2754
 	if (!empty ($post_id) && is_numeric($post_id)) {
2755
-		$where.=' AND post_id ="'.$post_id.'" ';
2755
+		$where .= ' AND post_id ="'.$post_id.'" ';
2756 2756
 	}
2757 2757
 
2758 2758
 	if (!empty ($comment_id) && is_numeric($comment_id)) {
2759 2759
 		if (!empty ($post_id)) {
2760
-			$where.= ' AND ';
2760
+			$where .= ' AND ';
2761 2761
 		}
2762
-		$where.=' comment_id ="'.$comment_id.'" ';
2762
+		$where .= ' comment_id ="'.$comment_id.'" ';
2763 2763
 	}
2764 2764
 
2765 2765
     $course_id = api_get_course_int_id();
2766 2766
 
2767
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2767
+	$sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.'
2768 2768
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2769 2769
 
2770
-	$result=Database::query($sql);
2771
-	if (Database::num_rows($result)!=0) {
2772
-		$row=Database::fetch_array($result);
2770
+	$result = Database::query($sql);
2771
+	if (Database::num_rows($result) != 0) {
2772
+		$row = Database::fetch_array($result);
2773 2773
 	}
2774 2774
 	return $row;
2775 2775
 }
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
  * @version avril 2008, dokeos 1.8.5
2784 2784
  */
2785 2785
 
2786
-function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2786
+function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2787 2787
 {
2788 2788
 	$_course = api_get_course_info();
2789 2789
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
@@ -2807,22 +2807,22 @@  discard block
 block discarded – undo
2807 2807
     }
2808 2808
 
2809 2809
 	// delete all files in directory
2810
-	$courseDir   = $_course['path'].'/upload/blog';
2810
+	$courseDir = $_course['path'].'/upload/blog';
2811 2811
 	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2812 2812
 	$updir = $sys_course_path.$courseDir;
2813 2813
 
2814 2814
 	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2815 2815
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2816
-	$result=Database::query($sql);
2816
+	$result = Database::query($sql);
2817 2817
 
2818
-	while ($row=Database::fetch_row($result)) {
2819
-		$file=$updir.'/'.$row[0];
2820
-		if (Security::check_abs_path($file,$updir) )
2818
+	while ($row = Database::fetch_row($result)) {
2819
+		$file = $updir.'/'.$row[0];
2820
+		if (Security::check_abs_path($file, $updir))
2821 2821
 		{
2822 2822
 			@ unlink($file);
2823 2823
 		}
2824 2824
 	}
2825
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2825
+	$sql = 'DELETE FROM '.$blog_table_attachment.'
2826 2826
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2827 2827
 	Database::query($sql);
2828 2828
 }
@@ -2835,8 +2835,8 @@  discard block
 block discarded – undo
2835 2835
 function get_blog_post_from_user($course_code, $user_id)
2836 2836
 {
2837 2837
 	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2838
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2839
-	$course_info 	= api_get_course_info($course_code);
2838
+	$tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS);
2839
+	$course_info = api_get_course_info($course_code);
2840 2840
 	$course_id 		= $course_info['real_id'];
2841 2841
 
2842 2842
 	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
@@ -2851,17 +2851,17 @@  discard block
 block discarded – undo
2851 2851
 	$result = Database::query($sql);
2852 2852
 	$return_data = '';
2853 2853
 
2854
-	if (Database::num_rows($result)!=0) {
2855
-		while ($row=Database::fetch_array($result)) {
2856
-			$return_data.=  '<div class="clear"></div><br />';
2854
+	if (Database::num_rows($result) != 0) {
2855
+		while ($row = Database::fetch_array($result)) {
2856
+			$return_data .= '<div class="clear"></div><br />';
2857 2857
 			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.
2858 2858
 				Display::return_icon('blog_article.png', get_lang('BlogPosts')).
2859 2859
 				' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2860 2860
 			<a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq(
2861 2861
 				).' " >'.get_lang('SeeBlog').'</a></div></div>';
2862
-			$return_data.=  '<br / >';
2863
-			$return_data.= $row['full_text'];
2864
-			$return_data.= '<br /><br />';
2862
+			$return_data .= '<br / >';
2863
+			$return_data .= $row['full_text'];
2864
+			$return_data .= '<br /><br />';
2865 2865
 		}
2866 2866
 	}
2867 2867
 	return $return_data;
@@ -2891,16 +2891,16 @@  discard block
 block discarded – undo
2891 2891
 			ORDER BY blog_name";
2892 2892
 	$result = Database::query($sql);
2893 2893
 	$return_data = '';
2894
-	if (Database::num_rows($result)!=0) {
2895
-		while ($row=Database::fetch_array($result)) {
2896
-			$return_data.=  '<div class="clear"></div><br />';
2894
+	if (Database::num_rows($result) != 0) {
2895
+		while ($row = Database::fetch_array($result)) {
2896
+			$return_data .= '<div class="clear"></div><br />';
2897 2897
 			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px">
2898 2898
 			<a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq(
2899 2899
 				).' " >'.get_lang('SeeBlog').'</a></div></div>';
2900
-			$return_data.=  '<br / >';
2900
+			$return_data .= '<br / >';
2901 2901
 			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2902
-			$return_data.=  $row['comment'];
2903
-			$return_data.=  '<br />';
2902
+			$return_data .= $row['comment'];
2903
+			$return_data .= '<br />';
2904 2904
 		}
2905 2905
 	}
2906 2906
 	return $return_data;
Please login to merge, or discard this patch.
Braces   +23 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1037,8 +1037,9 @@  discard block
 block discarded – undo
1037 1037
             $blog_post_actions .= '</a>';
1038 1038
         }
1039 1039
 
1040
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1041
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1040
+		if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) {
1041
+					$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1042
+		}
1042 1043
 
1043 1044
 		$blog_post_text=stripslashes($blog_post_text);
1044 1045
 
@@ -2447,8 +2448,9 @@  discard block
 block discarded – undo
2447 2448
 		//Handle leap year
2448 2449
 		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2449 2450
 
2450
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2451
-			$numberofdays[2] = 29;
2451
+		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) {
2452
+					$numberofdays[2] = 29;
2453
+		}
2452 2454
 
2453 2455
 		//Get the first day of the month
2454 2456
 		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
@@ -2480,8 +2482,9 @@  discard block
 block discarded – undo
2480 2482
 		if( Database::num_rows($result) > 0) {
2481 2483
 			while($blog_post = Database::fetch_array($result)) {
2482 2484
 				// If the day of this post is not yet in the array, add it.
2483
-				if (!in_array($blog_post['post_day'], $posts))
2484
-					$posts[] = $blog_post['post_day'];
2485
+				if (!in_array($blog_post['post_day'], $posts)) {
2486
+									$posts[] = $blog_post['post_day'];
2487
+				}
2485 2488
 			}
2486 2489
 		}
2487 2490
 
@@ -2520,8 +2523,9 @@  discard block
 block discarded – undo
2520 2523
 
2521 2524
 		echo "<tr>\n";
2522 2525
 
2523
-		for($ii = 1; $ii < 8; $ii ++)
2524
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2526
+		for($ii = 1; $ii < 8; $ii ++) {
2527
+					echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2528
+		}
2525 2529
 
2526 2530
 		echo "</tr>";
2527 2531
 
@@ -2531,8 +2535,9 @@  discard block
 block discarded – undo
2531 2535
 		while ($curday <= $numberofdays[$month]) {
2532 2536
 			echo "<tr>";
2533 2537
 			for ($ii = 0; $ii < 7; $ii ++) {
2534
-				if (($curday == -1) && ($ii == $startdayofweek))
2535
-					$curday = 1;
2538
+				if (($curday == -1) && ($ii == $startdayofweek)) {
2539
+									$curday = 1;
2540
+				}
2536 2541
 
2537 2542
 			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2538 2543
 					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
@@ -2546,14 +2551,15 @@  discard block
 block discarded – undo
2546 2551
 					echo "<td " . $class.">";
2547 2552
 
2548 2553
 					// If there are posts on this day, create a filter link.
2549
-					if(in_array($curday, $posts))
2550
-						echo '<a href="blog.php?'.api_get_cidreq(
2554
+					if(in_array($curday, $posts)) {
2555
+											echo '<a href="blog.php?'.api_get_cidreq(
2551 2556
 							).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang(
2552 2557
 								'ViewPostsOfThisDay'
2553 2558
 							).'">'.
2554 2559
 							$curday.'</a>';
2555
-					else
2556
-						echo $dayheader;
2560
+					} else {
2561
+											echo $dayheader;
2562
+					}
2557 2563
 
2558 2564
 					if (count($tasks) > 0) {
2559 2565
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
@@ -2574,8 +2580,9 @@  discard block
 block discarded – undo
2574 2580
 
2575 2581
 					echo "</td>";
2576 2582
 					$curday ++;
2577
-				} else
2578
-					echo "<td>&nbsp;</td>";
2583
+				} else {
2584
+									echo "<td>&nbsp;</td>";
2585
+				}
2579 2586
 			}
2580 2587
 			echo "</tr>";
2581 2588
 		}
Please login to merge, or discard this patch.
main/inc/lib/browser/Browser.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     /**
160 160
      * Set the name of the browser
161
-     * @param $browser string The name of the Browser
161
+     * @param string $browser string The name of the Browser
162 162
      */
163 163
     public function setBrowser($browser)
164 164
     {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
     /**
268 268
      * Set the browser to be from AOL
269
-     * @param $isAol
269
+     * @param boolean $isAol
270 270
      */
271 271
     public function setAol($isAol)
272 272
     {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     }
257 257
 
258 258
     /**
259
-    * Is the browser from facebook?
260
-    * @return boolean True if the browser is from facebook otherwise false
261
-    */
259
+     * Is the browser from facebook?
260
+     * @return boolean True if the browser is from facebook otherwise false
261
+     */
262 262
     public function isFacebook() 
263 263
     { 
264 264
         return $this->_is_facebook;
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
             }
592 592
             return true;
593 593
         } // Test for versions > IE 10
594
-		else if(stripos($this->_agent, 'trident') !== false) {
595
-			$this->setBrowser(self::BROWSER_IE);
596
-			$result = explode('rv:', $this->_agent);
597
-			$this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
598
-			$this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent);
599
-		} // Test for Pocket IE
594
+        else if(stripos($this->_agent, 'trident') !== false) {
595
+            $this->setBrowser(self::BROWSER_IE);
596
+            $result = explode('rv:', $this->_agent);
597
+            $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
598
+            $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent);
599
+        } // Test for Pocket IE
600 600
         else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) {
601 601
             $aresult = explode(' ', stristr($this->_agent, 'mspie'));
602 602
             $this->setPlatform(self::PLATFORM_WINDOWS_CE);
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
      */
346 346
     public function __toString()
347 347
     {
348
-        return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" .
349
-        "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" .
350
-        "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" .
348
+        return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n".
349
+        "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n".
350
+        "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n".
351 351
         "<strong>Platform:</strong> {$this->getPlatform()}<br/>";
352 352
     }
353 353
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
             $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie'));
586 586
             $this->setBrowser(self::BROWSER_IE);
587 587
             $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
588
-            if(stripos($this->_agent, 'IEMobile') !== false) {
588
+            if (stripos($this->_agent, 'IEMobile') !== false) {
589 589
                 $this->setBrowser(self::BROWSER_POCKET_IE);
590 590
                 $this->setMobile(true);
591 591
             }
592 592
             return true;
593 593
         } // Test for versions > IE 10
594
-		else if(stripos($this->_agent, 'trident') !== false) {
594
+		else if (stripos($this->_agent, 'trident') !== false) {
595 595
 			$this->setBrowser(self::BROWSER_IE);
596 596
 			$result = explode('rv:', $this->_agent);
597 597
 			$this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
     protected function checkFacebookExternalHit()
1014 1014
     {
1015
-        if(stristr($this->_agent,'FacebookExternalHit'))
1015
+        if (stristr($this->_agent, 'FacebookExternalHit'))
1016 1016
         {
1017 1017
             $this->setRobot(true);
1018 1018
             $this->setFacebook(true);
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
      */
1028 1028
     protected function checkForFacebookIos()
1029 1029
     {
1030
-        if(stristr($this->_agent,'FBIOS'))
1030
+        if (stristr($this->_agent, 'FBIOS'))
1031 1031
         {
1032 1032
             $this->setFacebook(true);
1033 1033
             return true;
@@ -1041,10 +1041,10 @@  discard block
 block discarded – undo
1041 1041
      */
1042 1042
     protected function getSafariVersionOnIos() 
1043 1043
     {
1044
-        $aresult = explode('/',stristr($this->_agent,'Version'));
1045
-        if( isset($aresult[1]) ) 
1044
+        $aresult = explode('/', stristr($this->_agent, 'Version'));
1045
+        if (isset($aresult[1])) 
1046 1046
         {
1047
-            $aversion = explode(' ',$aresult[1]);
1047
+            $aversion = explode(' ', $aresult[1]);
1048 1048
             $this->setVersion($aversion[0]);
1049 1049
             return true;
1050 1050
         }
@@ -1057,10 +1057,10 @@  discard block
 block discarded – undo
1057 1057
      */
1058 1058
     protected function getChromeVersionOnIos() 
1059 1059
     {
1060
-        $aresult = explode('/',stristr($this->_agent,'CriOS'));
1061
-        if( isset($aresult[1]) ) 
1060
+        $aresult = explode('/', stristr($this->_agent, 'CriOS'));
1061
+        if (isset($aresult[1])) 
1062 1062
         {
1063
-            $aversion = explode(' ',$aresult[1]);
1063
+            $aversion = explode(' ', $aresult[1]);
1064 1064
             $this->setVersion($aversion[0]);
1065 1065
             $this->setBrowser(self::BROWSER_CHROME);
1066 1066
             return true;
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
      * @return boolean True if the browser is iPhone otherwise false
1074 1074
      */
1075 1075
     protected function checkBrowseriPhone() {
1076
-        if( stripos($this->_agent,'iPhone') !== false ) {
1076
+        if (stripos($this->_agent, 'iPhone') !== false) {
1077 1077
             $this->setVersion(self::VERSION_UNKNOWN);
1078 1078
             $this->setBrowser(self::BROWSER_IPHONE);
1079 1079
             $this->getSafariVersionOnIos();
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
      * @return boolean True if the browser is iPad otherwise false
1091 1091
      */
1092 1092
     protected function checkBrowseriPad() {
1093
-        if( stripos($this->_agent,'iPad') !== false ) {
1093
+        if (stripos($this->_agent, 'iPad') !== false) {
1094 1094
             $this->setVersion(self::VERSION_UNKNOWN);
1095 1095
             $this->setBrowser(self::BROWSER_IPAD);
1096 1096
             $this->getSafariVersionOnIos();
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
      * @return boolean True if the browser is iPod otherwise false
1108 1108
      */
1109 1109
     protected function checkBrowseriPod() {
1110
-        if( stripos($this->_agent,'iPod') !== false ) {
1110
+        if (stripos($this->_agent, 'iPod') !== false) {
1111 1111
             $this->setVersion(self::VERSION_UNKNOWN);
1112 1112
             $this->setBrowser(self::BROWSER_IPOD);
1113 1113
             $this->getSafariVersionOnIos();
Please login to merge, or discard this patch.
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1152,68 +1152,52 @@
 block discarded – undo
1152 1152
         if (stripos($this->_agent, 'windows') !== false) 
1153 1153
         {
1154 1154
             $this->_platform = self::PLATFORM_WINDOWS;
1155
-        } 
1156
-        else if (stripos($this->_agent, 'iPad') !== false) 
1155
+        } else if (stripos($this->_agent, 'iPad') !== false) 
1157 1156
         {
1158 1157
             $this->_platform = self::PLATFORM_IPAD;
1159
-        } 
1160
-        else if (stripos($this->_agent, 'iPod') !== false) 
1158
+        } else if (stripos($this->_agent, 'iPod') !== false) 
1161 1159
         {
1162 1160
             $this->_platform = self::PLATFORM_IPOD;
1163
-        } 
1164
-        else if (stripos($this->_agent, 'iPhone') !== false) 
1161
+        } else if (stripos($this->_agent, 'iPhone') !== false) 
1165 1162
         {
1166 1163
             $this->_platform = self::PLATFORM_IPHONE;
1167
-        } 
1168
-        elseif (stripos($this->_agent, 'mac') !== false) 
1164
+        } elseif (stripos($this->_agent, 'mac') !== false) 
1169 1165
         {
1170 1166
             $this->_platform = self::PLATFORM_APPLE;
1171
-        } 
1172
-        elseif (stripos($this->_agent, 'android') !== false) 
1167
+        } elseif (stripos($this->_agent, 'android') !== false) 
1173 1168
         {
1174 1169
             $this->_platform = self::PLATFORM_ANDROID;
1175
-        } 
1176
-        elseif (stripos($this->_agent, 'linux') !== false) 
1170
+        } elseif (stripos($this->_agent, 'linux') !== false) 
1177 1171
         {
1178 1172
             $this->_platform = self::PLATFORM_LINUX;
1179
-        } 
1180
-        else if (stripos($this->_agent, 'Nokia') !== false) 
1173
+        } else if (stripos($this->_agent, 'Nokia') !== false) 
1181 1174
         {
1182 1175
             $this->_platform = self::PLATFORM_NOKIA;
1183
-        } 
1184
-        else if (stripos($this->_agent, 'BlackBerry') !== false) 
1176
+        } else if (stripos($this->_agent, 'BlackBerry') !== false) 
1185 1177
         {
1186 1178
             $this->_platform = self::PLATFORM_BLACKBERRY;
1187
-        } 
1188
-        elseif (stripos($this->_agent, 'FreeBSD') !== false) 
1179
+        } elseif (stripos($this->_agent, 'FreeBSD') !== false) 
1189 1180
         {
1190 1181
             $this->_platform = self::PLATFORM_FREEBSD;
1191
-        } 
1192
-        elseif (stripos($this->_agent, 'OpenBSD') !== false) 
1182
+        } elseif (stripos($this->_agent, 'OpenBSD') !== false) 
1193 1183
         {
1194 1184
             $this->_platform = self::PLATFORM_OPENBSD;
1195
-        } 
1196
-        elseif (stripos($this->_agent, 'NetBSD') !== false) 
1185
+        } elseif (stripos($this->_agent, 'NetBSD') !== false) 
1197 1186
         {
1198 1187
             $this->_platform = self::PLATFORM_NETBSD;
1199
-        } 
1200
-        elseif (stripos($this->_agent, 'OpenSolaris') !== false) 
1188
+        } elseif (stripos($this->_agent, 'OpenSolaris') !== false) 
1201 1189
         {
1202 1190
             $this->_platform = self::PLATFORM_OPENSOLARIS;
1203
-        } 
1204
-        elseif (stripos($this->_agent, 'SunOS') !== false) 
1191
+        } elseif (stripos($this->_agent, 'SunOS') !== false) 
1205 1192
         {
1206 1193
             $this->_platform = self::PLATFORM_SUNOS;
1207
-        } 
1208
-        elseif (stripos($this->_agent, 'OS\/2') !== false) 
1194
+        } elseif (stripos($this->_agent, 'OS\/2') !== false) 
1209 1195
         {
1210 1196
             $this->_platform = self::PLATFORM_OS2;
1211
-        } 
1212
-        elseif (stripos($this->_agent, 'BeOS') !== false) 
1197
+        } elseif (stripos($this->_agent, 'BeOS') !== false) 
1213 1198
         {
1214 1199
             $this->_platform = self::PLATFORM_BEOS;
1215
-        } 
1216
-        elseif (stripos($this->_agent, 'win') !== false) 
1200
+        } elseif (stripos($this->_agent, 'win') !== false) 
1217 1201
         {
1218 1202
             $this->_platform = self::PLATFORM_WINDOWS;
1219 1203
         }
Please login to merge, or discard this patch.
main/inc/lib/chat.lib.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -41,6 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
     * Set user chat status
43 43
     * @param int 0 if disconnected, 1 if connected
44
+    * @param integer $status
44 45
      *
45 46
     * @return void
46 47
     */
@@ -164,6 +165,7 @@  discard block
 block discarded – undo
164 165
     /**
165 166
      * Saves into session the fact that a chat window exists with the given user
166 167
      * @param int The ID of the user with whom the current user is chatting
168
+     * @param integer $user_id
167 169
      * @return void
168 170
      */
169 171
     public function save_window($user_id)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $to_user_id,
187 187
         $message,
188 188
         $printResult = true,
189
-        $sanitize =  true
189
+        $sanitize = true
190 190
     )
191 191
     {
192 192
         $user_friend_relation = SocialManager::get_relation_between_contacts(
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 $messagesan = $message;
207 207
             }
208 208
 
209
-            error_log(print_r($sanitize) . '----' . $messagesan);
209
+            error_log(print_r($sanitize).'----'.$messagesan);
210 210
 
211 211
             if (!isset($_SESSION['chatHistory'][$to_user_id])) {
212 212
                 $_SESSION['chatHistory'][$to_user_id] = array();
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public static function disableChat()
291 291
     {
292
-        if (!empty($_SESSION['disable_chat'])){
292
+        if (!empty($_SESSION['disable_chat'])) {
293 293
             $status = $_SESSION['disable_chat'];
294
-            if ($status == true){
294
+            if ($status == true) {
295 295
                 $_SESSION['disable_chat'] = null;
296 296
                 return true;
297 297
             }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     /**
47
-    * Set user chat status
48
-    * @param int 0 if disconnected, 1 if connected
47
+     * Set user chat status
48
+     * @param int 0 if disconnected, 1 if connected
49 49
      *
50
-    * @return void
51
-    */
50
+     * @return void
51
+     */
52 52
     public function setUserStatus($status)
53 53
     {
54 54
         UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status);
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     /**
152
-    * Returns an array of messages inside a chat session with a specific user
153
-    * @param int The ID of the user with whom the current user is chatting
154
-    * @return array Messages list
155
-    */
152
+     * Returns an array of messages inside a chat session with a specific user
153
+     * @param int The ID of the user with whom the current user is chatting
154
+     * @return array Messages list
155
+     */
156 156
     public function box_session($user_id)
157 157
     {
158 158
         $items = array();
Please login to merge, or discard this patch.
main/inc/lib/course_description.lib.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * Get all data by description and session id,
96 96
      * first you must set session_id property with the object CourseDescription
97 97
      * @param    int  $description_type Description type
98
-     * @param   string $course_code Course code (optional)
98
+     * @param   string $courseId Course code (optional)
99 99
      * @param    int $session_id Session id (optional)
100 100
      * @return array    List of fields from the descriptions found of the given type
101 101
      */
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
     /**
361 361
      * Get description titles by default
362
-     * @return array
362
+     * @return string[]
363 363
      */
364 364
     public function get_default_description_title()
365 365
     {
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
     /**
380 380
      * Get description titles editable by default
381
-     * @return array
381
+     * @return boolean[]
382 382
      */
383 383
     public function get_default_description_title_editable()
384 384
     {
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 
398 398
     /**
399 399
      * Get description icons by default
400
-     * @return array
400
+     * @return string[]
401 401
      */
402 402
     public function get_default_description_icon()
403 403
     {
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 
418 418
     /**
419 419
      * Get questions by default for help
420
-     * @return array
420
+     * @return string[]
421 421
      */
422 422
     public function get_default_question()
423 423
     {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 
437 437
     /**
438 438
      * Get informations by default for help
439
-     * @return array
439
+     * @return string[]
440 440
      */
441 441
     public function get_default_information()
442 442
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         $sql = "SELECT MAX(description_type) as MAX
178 178
                 FROM $tbl_course_description
179
-		        WHERE c_id = $course_id AND session_id='" . $this->session_id . "'";
179
+		        WHERE c_id = $course_id AND session_id='".$this->session_id."'";
180 180
         $rs = Database::query($sql);
181 181
         $max = Database::fetch_array($rs);
182 182
         $description_type = $max['MAX'] + 1;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             'session_id' => $this->session_id
212 212
         ];
213 213
 
214
-        $last_id  = Database::insert($table, $params);
214
+        $last_id = Database::insert($table, $params);
215 215
 
216 216
         if ($last_id > 0) {
217 217
             $sql = "UPDATE $table SET id = iid WHERE iid = $last_id";
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
         $sql = "DELETE FROM $tbl_course_description
320 320
 			 	WHERE
321 321
 			 	    c_id = $course_id AND
322
-			 	    id = '" . intval($this->id) . "' AND
323
-			 	    session_id = '" . intval($this->session_id) . "'";
322
+			 	    id = '".intval($this->id)."' AND
323
+			 	    session_id = '" . intval($this->session_id)."'";
324 324
         $result = Database::query($sql);
325 325
         $affected_rows = Database::affected_rows($result);
326 326
         if ($this->id > 0) {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         $course_id = api_get_course_int_id();
350 350
 
351 351
         $sql = "SELECT id FROM $tbl_course_description
352
-		        WHERE c_id = $course_id AND description_type = '" . intval($description_type) . "'";
352
+		        WHERE c_id = $course_id AND description_type = '".intval($description_type)."'";
353 353
         $rs = Database::query($sql);
354 354
         $row = Database::fetch_array($rs);
355 355
         $description_id = $row['id'];
Please login to merge, or discard this patch.
main/inc/lib/dashboard.lib.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -493,6 +493,7 @@
 block discarded – undo
493 493
 	 * This function update extra user blocks data after closing a dashboard block
494 494
 	 * @param int 		User id
495 495
 	 * @param string	plugin path
496
+	 * @param integer $user_id
496 497
 	 * @return bool
497 498
 	 */
498 499
 	public static function close_user_block($user_id, $path)
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -380,7 +380,9 @@
 block discarded – undo
380 380
 					// check if user is allowed to see the block
381 381
 					if (method_exists($obj_block, 'is_block_visible_for_user')) {
382 382
 						$is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
383
-						if (!$is_block_visible_for_user) continue;
383
+						if (!$is_block_visible_for_user) {
384
+						    continue;
385
+						}
384 386
 					}
385 387
 
386 388
 					echo '<tr>';
Please login to merge, or discard this patch.
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -249,286 +249,286 @@
 block discarded – undo
249 249
         return $affected_rows;
250 250
     }
251 251
 
252
-	/**
253
-	 * Get all plugins path inside dashboard directory
254
-	 * @return array name plugins directories
255
-	 */
256
-	public static function getPossibleDashboardPluginsPath()
252
+    /**
253
+     * Get all plugins path inside dashboard directory
254
+     * @return array name plugins directories
255
+     */
256
+    public static function getPossibleDashboardPluginsPath()
257 257
     {
258
-		// get all plugins path inside plugin directory
259
-		/* We scan the plugin directory. Each folder is a potential plugin. */
260
-		$possiblePlugins = array();
261
-		$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
262
-		$handle = @opendir($dashboard_pluginpath);
263
-		while (false !== ($file = readdir($handle))) {
264
-			if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) {
265
-				$possiblePlugins[] = $file;
266
-			}
267
-		}
268
-		@closedir($handle);
269
-
270
-		return $possiblePlugins;
271
-	}
272
-
273
-	/**
274
-	 * Get all blocks data without plugin directory
275
-	 * @return array Block data
276
-	 */
277
-	public static function get_block_data_without_plugin()
258
+        // get all plugins path inside plugin directory
259
+        /* We scan the plugin directory. Each folder is a potential plugin. */
260
+        $possiblePlugins = array();
261
+        $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
262
+        $handle = @opendir($dashboard_pluginpath);
263
+        while (false !== ($file = readdir($handle))) {
264
+            if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) {
265
+                $possiblePlugins[] = $file;
266
+            }
267
+        }
268
+        @closedir($handle);
269
+
270
+        return $possiblePlugins;
271
+    }
272
+
273
+    /**
274
+     * Get all blocks data without plugin directory
275
+     * @return array Block data
276
+     */
277
+    public static function get_block_data_without_plugin()
278 278
     {
279
-		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
280
-		$possibleplugins = self::getPossibleDashboardPluginsPath();
281
-
282
-		// We check if plugin exists inside directory for updating active field
283
-		$sql = "SELECT * FROM $tbl_block";
284
-		$rs = Database::query($sql);
285
-		if (Database::num_rows($rs) > 0){
286
-			while ($row = Database::fetch_array($rs)) {
287
-				$path = $row['path'];
288
-				if (!in_array($row['path'],$possibleplugins)) {
289
-					$active = 0;
290
-				} else {
291
-					$active = 1;
292
-				}
293
-				// update active
294
-				$upd = "UPDATE $tbl_block SET active = '$active'
279
+        $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
280
+        $possibleplugins = self::getPossibleDashboardPluginsPath();
281
+
282
+        // We check if plugin exists inside directory for updating active field
283
+        $sql = "SELECT * FROM $tbl_block";
284
+        $rs = Database::query($sql);
285
+        if (Database::num_rows($rs) > 0){
286
+            while ($row = Database::fetch_array($rs)) {
287
+                $path = $row['path'];
288
+                if (!in_array($row['path'],$possibleplugins)) {
289
+                    $active = 0;
290
+                } else {
291
+                    $active = 1;
292
+                }
293
+                // update active
294
+                $upd = "UPDATE $tbl_block SET active = '$active'
295 295
 				        WHERE path = '".$row['path']."'";
296
-				Database::query($upd);
297
-			}
298
-		}
299
-
300
-		// get disabled block data
301
-		$block_data = array();
302
-		$sql = "SELECT * FROM $tbl_block WHERE active = 0";
303
-		$rs_block = Database::query($sql);
304
-		if (Database::num_rows($rs_block) > 0) {
305
-			while ($row_block = Database::fetch_array($rs_block)) {
306
-				$block_data[] = $row_block;
307
-			}
308
-		}
309
-
310
-		return $block_data;
311
-
312
-	}
313
-
314
-	/**
315
-	 * get data about enabled dashboard block (stored insise block table)
316
-	 * @param  string	plugin path
317
-	 * @return array 	data
318
-	 */
319
-	public static function get_enabled_dashboard_blocks($path = '')
296
+                Database::query($upd);
297
+            }
298
+        }
299
+
300
+        // get disabled block data
301
+        $block_data = array();
302
+        $sql = "SELECT * FROM $tbl_block WHERE active = 0";
303
+        $rs_block = Database::query($sql);
304
+        if (Database::num_rows($rs_block) > 0) {
305
+            while ($row_block = Database::fetch_array($rs_block)) {
306
+                $block_data[] = $row_block;
307
+            }
308
+        }
309
+
310
+        return $block_data;
311
+
312
+    }
313
+
314
+    /**
315
+     * get data about enabled dashboard block (stored insise block table)
316
+     * @param  string	plugin path
317
+     * @return array 	data
318
+     */
319
+    public static function get_enabled_dashboard_blocks($path = '')
320 320
     {
321
-		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
322
-		$condition_path = '';
323
-		if (!empty($path)) {
324
-			$path = Database::escape_string($path);
325
-			$condition_path = ' AND path = "'.$path.'" ';
326
-		}
327
-
328
-		$sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path ";
329
-		$rs  = Database::query($sql);
330
-		$block_data = array();
331
-		if (Database::num_rows($rs) > 0) {
332
-			while ($row = Database::fetch_array($rs)) {
333
-				$block_data[$row['path']] = $row;
334
-			}
335
-		}
336
-		return $block_data;
337
-	}
338
-
339
-	/**
340
-	 * display user dashboard list
341
-	 * @param int  User id
342
-	 * @return void
343
-	 */
344
-	public static function display_user_dashboard_list($user_id)
321
+        $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
322
+        $condition_path = '';
323
+        if (!empty($path)) {
324
+            $path = Database::escape_string($path);
325
+            $condition_path = ' AND path = "'.$path.'" ';
326
+        }
327
+
328
+        $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path ";
329
+        $rs  = Database::query($sql);
330
+        $block_data = array();
331
+        if (Database::num_rows($rs) > 0) {
332
+            while ($row = Database::fetch_array($rs)) {
333
+                $block_data[$row['path']] = $row;
334
+            }
335
+        }
336
+        return $block_data;
337
+    }
338
+
339
+    /**
340
+     * display user dashboard list
341
+     * @param int  User id
342
+     * @return void
343
+     */
344
+    public static function display_user_dashboard_list($user_id)
345 345
     {
346
-		$enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
347
-		$user_block_data = self::get_user_block_data($user_id);
348
-
349
-		if (count($enabled_dashboard_plugins) > 0) {
350
-			echo '<div style="margin-top:20px">';
351
-			echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />';
352
-			echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
353
-			echo '<table class="data_table">';
354
-			echo '<tr>';
355
-			echo '<th width="5%">';
356
-			echo get_lang('Enabled');
357
-			echo '</th>';
358
-			echo '<th width="30%">';
359
-			echo get_lang('Name');
360
-			echo '</th>';
361
-			echo '<th width="40%">';
362
-			echo get_lang('Description');
363
-			echo '</th>';
364
-			echo '<th>';
365
-			echo get_lang('ColumnPosition');
366
-			echo '</th>';
367
-			echo '</tr>';
368
-
369
-			// We display all enabled plugins and the checkboxes
370
-			foreach ($enabled_dashboard_plugins as $block) {
371
-
372
-				$path = $block['path'];
373
-				$controller_class = $block['controller'];
374
-				$filename_controller = $path.'.class.php';
375
-				$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
376
-				require_once $dashboard_plugin_path.$filename_controller;
377
-				if (class_exists($controller_class)) {
378
-					$obj_block = new $controller_class($user_id);
379
-
380
-					// check if user is allowed to see the block
381
-					if (method_exists($obj_block, 'is_block_visible_for_user')) {
382
-						$is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
383
-						if (!$is_block_visible_for_user) continue;
384
-					}
385
-
386
-					echo '<tr>';
387
-					// checkboxes
388
-					self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
389
-					echo '<td>'.$block['name'].'</td>';
390
-					echo '<td>'.$block['description'].'</td>';
391
-					echo '<td>
346
+        $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
347
+        $user_block_data = self::get_user_block_data($user_id);
348
+
349
+        if (count($enabled_dashboard_plugins) > 0) {
350
+            echo '<div style="margin-top:20px">';
351
+            echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />';
352
+            echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
353
+            echo '<table class="data_table">';
354
+            echo '<tr>';
355
+            echo '<th width="5%">';
356
+            echo get_lang('Enabled');
357
+            echo '</th>';
358
+            echo '<th width="30%">';
359
+            echo get_lang('Name');
360
+            echo '</th>';
361
+            echo '<th width="40%">';
362
+            echo get_lang('Description');
363
+            echo '</th>';
364
+            echo '<th>';
365
+            echo get_lang('ColumnPosition');
366
+            echo '</th>';
367
+            echo '</tr>';
368
+
369
+            // We display all enabled plugins and the checkboxes
370
+            foreach ($enabled_dashboard_plugins as $block) {
371
+
372
+                $path = $block['path'];
373
+                $controller_class = $block['controller'];
374
+                $filename_controller = $path.'.class.php';
375
+                $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
376
+                require_once $dashboard_plugin_path.$filename_controller;
377
+                if (class_exists($controller_class)) {
378
+                    $obj_block = new $controller_class($user_id);
379
+
380
+                    // check if user is allowed to see the block
381
+                    if (method_exists($obj_block, 'is_block_visible_for_user')) {
382
+                        $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
383
+                        if (!$is_block_visible_for_user) continue;
384
+                    }
385
+
386
+                    echo '<tr>';
387
+                    // checkboxes
388
+                    self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
389
+                    echo '<td>'.$block['name'].'</td>';
390
+                    echo '<td>'.$block['description'].'</td>';
391
+                    echo '<td>
392 392
                             <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']">
393 393
                             <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option>
394 394
                             <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option>
395 395
                             </select>
396 396
                           </td>';
397
-					echo '</tr>';
398
-				} else {
399
-					echo Display::tag('tr',  Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
400
-				}
401
-			}
402
-
403
-			echo '</table>';
404
-			echo '<div class="row"><div class="col-md-12">';
405
-			echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '.
397
+                    echo '</tr>';
398
+                } else {
399
+                    echo Display::tag('tr',  Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
400
+                }
401
+            }
402
+
403
+            echo '</table>';
404
+            echo '<div class="row"><div class="col-md-12">';
405
+            echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '.
406 406
                 get_lang('EnableDashboardBlock').'</button></form>';
407
-			echo '</div></div>';
408
-		} else {
409
-			echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>';
410
-			if (api_is_platform_admin()) {
411
-				echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'.
407
+            echo '</div></div>';
408
+        } else {
409
+            echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>';
410
+            if (api_is_platform_admin()) {
411
+                echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'.
412 412
                     get_lang('ConfigureDashboardPlugin').'</a>';
413
-			}
414
-		}
415
-	}
416
-
417
-	/**
418
-	 * display checkboxes for user dashboard list
419
-	 * @param int 	User id
420
-	 * @param int	Block id
421
-	 * @return void
422
-	 */
423
-	public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
424
-
425
-		$user_id = intval($user_id);
426
-		$user_block_data = self::get_user_block_data($user_id);
427
-		$enabled_blocks_id = array_keys($user_block_data);
428
-
429
-		$checked = '';
430
-		if (in_array($block_id, $enabled_blocks_id)) {
431
-			$checked = "checked";
432
-		}
433
-
434
-		echo "<td align=\"center\">";
435
-		echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>';
436
-		echo "</td>";
437
-	}
438
-
439
-	/**
440
-	 * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
441
-	 * @param int User id
442
-	 * @param array selected blocks
443
-	 * @param array columns position
444
-	 * @return bool
445
-	 */
446
-	public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
447
-		$selected_blocks_id  = array();
448
-		if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
449
-			$selected_blocks_id = array_keys($enabled_blocks);
450
-		}
451
-
452
-		// build data for storing inside extra user field
453
-		$fname = 'dashboard';
454
-		$fvalue = array();
455
-		foreach ($selected_blocks_id as $block_id) {
456
-			$fvalue[] = $block_id.':'.$columns[$block_id];
457
-		}
413
+            }
414
+        }
415
+    }
416
+
417
+    /**
418
+     * display checkboxes for user dashboard list
419
+     * @param int 	User id
420
+     * @param int	Block id
421
+     * @return void
422
+     */
423
+    public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
424
+
425
+        $user_id = intval($user_id);
426
+        $user_block_data = self::get_user_block_data($user_id);
427
+        $enabled_blocks_id = array_keys($user_block_data);
428
+
429
+        $checked = '';
430
+        if (in_array($block_id, $enabled_blocks_id)) {
431
+            $checked = "checked";
432
+        }
433
+
434
+        echo "<td align=\"center\">";
435
+        echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>';
436
+        echo "</td>";
437
+    }
438
+
439
+    /**
440
+     * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
441
+     * @param int User id
442
+     * @param array selected blocks
443
+     * @param array columns position
444
+     * @return bool
445
+     */
446
+    public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
447
+        $selected_blocks_id  = array();
448
+        if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
449
+            $selected_blocks_id = array_keys($enabled_blocks);
450
+        }
451
+
452
+        // build data for storing inside extra user field
453
+        $fname = 'dashboard';
454
+        $fvalue = array();
455
+        foreach ($selected_blocks_id as $block_id) {
456
+            $fvalue[] = $block_id.':'.$columns[$block_id];
457
+        }
458 458
         $upd_extra_field = UserManager::update_extra_field_value(
459 459
             $user_id,
460 460
             $fname,
461 461
             $fvalue
462 462
         );
463 463
 
464
-		return $upd_extra_field;
464
+        return $upd_extra_field;
465 465
 
466
-	}
466
+    }
467 467
 
468
-	/**
469
-	 * This function get user block data (block id with its number of column) from extra user data
470
-	 * @param int  		User id
471
-	 * @return array  	data (block_id,column)
472
-	 */
473
-	public static function get_user_block_data($user_id)
468
+    /**
469
+     * This function get user block data (block id with its number of column) from extra user data
470
+     * @param int  		User id
471
+     * @return array  	data (block_id,column)
472
+     */
473
+    public static function get_user_block_data($user_id)
474 474
     {
475
-		$user_id = intval($user_id);
476
-		$field_variable = 'dashboard';
477
-		$extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
475
+        $user_id = intval($user_id);
476
+        $field_variable = 'dashboard';
477
+        $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
478 478
 
479
-		if (isset($extra_user_data[$field_variable])) {
479
+        if (isset($extra_user_data[$field_variable])) {
480 480
             $extra_user_data = explode(';', $extra_user_data[$field_variable]);
481 481
         }
482 482
 
483
-		$data = array();
484
-		foreach ($extra_user_data as $extra) {
485
-			$split_extra = explode(':',$extra);
486
-			if (!empty($split_extra)) {
487
-				$block_id = $split_extra[0];
488
-				$column = isset($split_extra[1]) ? $split_extra[1] : null;
489
-				$data[$block_id] = array('block_id' => $block_id, 'column' => $column);
490
-			}
491
-		}
492
-
493
-		return $data;
494
-	}
495
-
496
-	/**
497
-	 * This function update extra user blocks data after closing a dashboard block
498
-	 * @param int 		User id
499
-	 * @param string	plugin path
500
-	 * @return bool
501
-	 */
502
-	public static function close_user_block($user_id, $path)
483
+        $data = array();
484
+        foreach ($extra_user_data as $extra) {
485
+            $split_extra = explode(':',$extra);
486
+            if (!empty($split_extra)) {
487
+                $block_id = $split_extra[0];
488
+                $column = isset($split_extra[1]) ? $split_extra[1] : null;
489
+                $data[$block_id] = array('block_id' => $block_id, 'column' => $column);
490
+            }
491
+        }
492
+
493
+        return $data;
494
+    }
495
+
496
+    /**
497
+     * This function update extra user blocks data after closing a dashboard block
498
+     * @param int 		User id
499
+     * @param string	plugin path
500
+     * @return bool
501
+     */
502
+    public static function close_user_block($user_id, $path)
503 503
     {
504
-		$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
505
-		$user_block_data = self::get_user_block_data($user_id);
506
-
507
-		foreach ($enabled_dashboard_blocks as $enabled_block) {
508
-			unset($user_block_data[$enabled_block['id']]);
509
-		}
510
-
511
-		// get columns and blocks id for updating extra user data
512
-		$columns = array();
513
-		$user_blocks_id = array();
514
-		foreach ($user_block_data as $data) {
515
-			$user_blocks_id[$data['block_id']] = true;
516
-			$columns[$data['block_id']] = $data['column'];
517
-		}
518
-
519
-		// update extra user blocks data
520
-		$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
521
-
522
-		return $upd_extra_field;
523
-	}
524
-
525
-	/**
526
-	 * get links for styles from dashboard plugins
527
-	 * @return string   links
528
-	 */
529
-	public static function get_links_for_styles_from_dashboard_plugins() {
530
-
531
-		return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
532
-	}
504
+        $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
505
+        $user_block_data = self::get_user_block_data($user_id);
506
+
507
+        foreach ($enabled_dashboard_blocks as $enabled_block) {
508
+            unset($user_block_data[$enabled_block['id']]);
509
+        }
510
+
511
+        // get columns and blocks id for updating extra user data
512
+        $columns = array();
513
+        $user_blocks_id = array();
514
+        foreach ($user_block_data as $data) {
515
+            $user_blocks_id[$data['block_id']] = true;
516
+            $columns[$data['block_id']] = $data['column'];
517
+        }
518
+
519
+        // update extra user blocks data
520
+        $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
521
+
522
+        return $upd_extra_field;
523
+    }
524
+
525
+    /**
526
+     * get links for styles from dashboard plugins
527
+     * @return string   links
528
+     */
529
+    public static function get_links_for_styles_from_dashboard_plugins() {
530
+
531
+        return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
532
+    }
533 533
 
534 534
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
                 echo '<tr>';
54 54
                 self::display_dashboard_plugin_checkboxes($testplugin);
55
-                for ($i = 0 ; $i < count($table_cols); $i++) {
55
+                for ($i = 0; $i < count($table_cols); $i++) {
56 56
                     if (isset($plugin_info[strtolower($table_cols[$i])])) {
57 57
                         echo '<td>';
58 58
                         echo $plugin_info[$table_cols[$i]];
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     echo Display::tag(
68 68
                         'tr',
69 69
                         Display::tag('td',
70
-                            get_lang('CheckFilePermissions') . ' ' . Security::remove_XSS($plugin_info_file),
70
+                            get_lang('CheckFilePermissions').' '.Security::remove_XSS($plugin_info_file),
71 71
                             array('colspan' => '3'))
72 72
                     );
73 73
                 }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             foreach ($disabled_blocks_data as $disabled_block) {
80 80
                 echo '<tr style="background-color:#eee">';
81 81
                 echo '<td><center><input type="checkbox" name="disabled_block" value="true" checked disabled /></center>';
82
-                for ($j = 0 ; $j < count($table_cols); $j++) {
82
+                for ($j = 0; $j < count($table_cols); $j++) {
83 83
                     if (isset($disabled_block[strtolower($table_cols[$j])])) {
84 84
                         if ($j == 2) {
85 85
                             echo '<td>';
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
             }
190 190
             // clean from block data
191 191
             if (!empty($not_selected_blocks_id)) {
192
-                $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")";
192
+                $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")";
193 193
                 $rs_check = Database::query($sql_check);
194 194
                 if (Database::num_rows($rs_check) > 0) {
195
-                    $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")";
195
+                    $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")";
196 196
                     Database::query($del);
197 197
                 }
198 198
             }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                         $affected_rows = Database::affected_rows($result);
213 213
                     } else {
214 214
                         // insert
215
-                        $plugin_info_file = $dashboard_pluginpath . $testplugin . "/$testplugin.info";
215
+                        $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info";
216 216
                         $plugin_info = array();
217 217
                         if (file_exists($plugin_info_file)) {
218 218
                             $plugin_info = parse_info_file($plugin_info_file);
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 		// We check if plugin exists inside directory for updating active field
283 283
 		$sql = "SELECT * FROM $tbl_block";
284 284
 		$rs = Database::query($sql);
285
-		if (Database::num_rows($rs) > 0){
285
+		if (Database::num_rows($rs) > 0) {
286 286
 			while ($row = Database::fetch_array($rs)) {
287 287
 				$path = $row['path'];
288
-				if (!in_array($row['path'],$possibleplugins)) {
288
+				if (!in_array($row['path'], $possibleplugins)) {
289 289
 					$active = 0;
290 290
 				} else {
291 291
 					$active = 1;
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 					echo '<td>'.$block['description'].'</td>';
391 391
 					echo '<td>
392 392
                             <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']">
393
-                            <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option>
394
-                            <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option>
393
+                            <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 1 ? 'selected' : '').' >1</option>
394
+                            <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 2 ? 'selected' : '').' >2</option>
395 395
                             </select>
396 396
                           </td>';
397 397
 					echo '</tr>';
398 398
 				} else {
399
-					echo Display::tag('tr',  Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
399
+					echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
400 400
 				}
401 401
 			}
402 402
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 
483 483
 		$data = array();
484 484
 		foreach ($extra_user_data as $extra) {
485
-			$split_extra = explode(':',$extra);
485
+			$split_extra = explode(':', $extra);
486 486
 			if (!empty($split_extra)) {
487 487
 				$block_id = $split_extra[0];
488 488
 				$column = isset($split_extra[1]) ? $split_extra[1] : null;
Please login to merge, or discard this patch.
main/inc/lib/database.lib.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @param string $table
68 68
      *
69
-     * @return mixed
69
+     * @return string
70 70
      */
71 71
     public static function get_main_table($table)
72 72
     {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
     /**
267 267
      * Frees all the memory associated with the provided result identifier.
268
-     * @return bool     Returns TRUE on success or FALSE on failure.
268
+     * @return boolean|null     Returns TRUE on success or FALSE on failure.
269 269
      * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets.
270 270
      * Anyway, all associated result memory is automatically freed at the end of the script's execution.
271 271
      */
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      * @param array     $attributes
382 382
      * @param bool      $show_query
383 383
      *
384
-     * @return bool|int
384
+     * @return false|string
385 385
      */
386 386
     public static function insert($table_name, $attributes, $show_query = false)
387 387
     {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -19 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public static function getUTCDateTimeTypeClass()
117 117
     {
118
-        return isset(self::$utcDateTimeClass) ? self::$utcDateTimeClass :
119
-        'Application\DoctrineExtensions\DBAL\Types\UTCDateTimeType';
118
+        return isset(self::$utcDateTimeClass) ? self::$utcDateTimeClass : 'Application\DoctrineExtensions\DBAL\Types\UTCDateTimeType';
120 119
     }
121 120
 
122 121
     /**
@@ -393,7 +392,7 @@  discard block
 block discarded – undo
393 392
 
394 393
         if (!empty($params)) {
395 394
             $sql = 'INSERT INTO '.$table_name.' ('.implode(',', $params).')
396
-                    VALUES (:'.implode(', :' ,$params).')';
395
+                    VALUES (:'.implode(', :', $params).')';
397 396
 
398 397
             $statement = self::getManager()->getConnection()->prepare($sql);
399 398
             $result = $statement->execute($attributes);
@@ -434,7 +433,7 @@  discard block
 block discarded – undo
434 433
             foreach ($attributes as $key => $value) {
435 434
                 $update_sql .= "$key = :$key ";
436 435
                 if ($count < count($attributes)) {
437
-                    $update_sql.=', ';
436
+                    $update_sql .= ', ';
438 437
                 }
439 438
                 $count++;
440 439
             }
@@ -481,7 +480,7 @@  discard block
 block discarded – undo
481 480
             if ($columns == '*') {
482 481
                 $clean_columns = '*';
483 482
             } else {
484
-                $clean_columns = (string)$columns;
483
+                $clean_columns = (string) $columns;
485 484
             }
486 485
         }
487 486
 
@@ -527,9 +526,9 @@  discard block
 block discarded – undo
527 526
                     foreach ($condition_data as $condition => $value_array) {
528 527
                         if (is_array($value_array)) {
529 528
                             $clean_values = array();
530
-                            foreach($value_array as $item) {
529
+                            foreach ($value_array as $item) {
531 530
                                 $item = Database::escape_string($item);
532
-                                $clean_values[]= $item;
531
+                                $clean_values[] = $item;
533 532
                             }
534 533
                         } else {
535 534
                             $value_array = Database::escape_string($value_array);
@@ -537,23 +536,23 @@  discard block
 block discarded – undo
537 536
                         }
538 537
 
539 538
                         if (!empty($condition) && $clean_values != '') {
540
-                            $condition = str_replace('%',"'@percentage@'", $condition); //replace "%"
541
-                            $condition = str_replace("'?'","%s", $condition);
542
-                            $condition = str_replace("?","%s", $condition);
539
+                            $condition = str_replace('%', "'@percentage@'", $condition); //replace "%"
540
+                            $condition = str_replace("'?'", "%s", $condition);
541
+                            $condition = str_replace("?", "%s", $condition);
543 542
 
544
-                            $condition = str_replace("@%s@","@-@", $condition);
545
-                            $condition = str_replace("%s","'%s'", $condition);
546
-                            $condition = str_replace("@-@","@%s@", $condition);
543
+                            $condition = str_replace("@%s@", "@-@", $condition);
544
+                            $condition = str_replace("%s", "'%s'", $condition);
545
+                            $condition = str_replace("@-@", "@%s@", $condition);
547 546
 
548 547
                             // Treat conditions as string
549 548
                             $condition = vsprintf($condition, $clean_values);
550
-                            $condition = str_replace('@percentage@','%', $condition); //replace "%"
549
+                            $condition = str_replace('@percentage@', '%', $condition); //replace "%"
551 550
                             $where_return .= $condition;
552 551
                         }
553 552
                     }
554 553
 
555 554
                     if (!empty($where_return)) {
556
-                        $return_value = " WHERE $where_return" ;
555
+                        $return_value = " WHERE $where_return";
557 556
                     }
558 557
                     break;
559 558
                 case 'order':
@@ -565,7 +564,7 @@  discard block
 block discarded – undo
565 564
                         $new_order_array = explode(',', $order_array);
566 565
                         $temp_value = array();
567 566
 
568
-                        foreach($new_order_array as $element) {
567
+                        foreach ($new_order_array as $element) {
569 568
                             $element = explode(' ', $element);
570 569
                             $element = array_filter($element);
571 570
                             $element = array_values($element);
@@ -576,10 +575,10 @@  discard block
 block discarded – undo
576 575
                                 if (in_array($element[1], array('desc', 'asc'))) {
577 576
                                     $order = $element[1];
578 577
                                 }
579
-                                $temp_value[]= $element[0].' '.$order.' ';
578
+                                $temp_value[] = $element[0].' '.$order.' ';
580 579
                             } else {
581 580
                                 //by default DESC
582
-                                $temp_value[]= $element[0].' DESC ';
581
+                                $temp_value[] = $element[0].' DESC ';
583 582
                             }
584 583
                         }
585 584
                         if (!empty($temp_value)) {
@@ -594,7 +593,7 @@  discard block
 block discarded – undo
594 593
                     if (!empty($limit_array)) {
595 594
                         if (count($limit_array) > 1) {
596 595
                             $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]);
597
-                        }  else {
596
+                        } else {
598 597
                             $return_value .= ' LIMIT '.intval($limit_array[0]);
599 598
                         }
600 599
                     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -594,7 +594,7 @@
 block discarded – undo
594 594
                     if (!empty($limit_array)) {
595 595
                         if (count($limit_array) > 1) {
596 596
                             $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]);
597
-                        }  else {
597
+                        } else {
598 598
                             $return_value .= ' LIMIT '.intval($limit_array[0]);
599 599
                         }
600 600
                     }
Please login to merge, or discard this patch.