Completed
Push — 1.10.x ( 31e1f2...3eec0c )
by Angel Fernando Quiroz
48:31
created
main/forum/forumfunction.inc.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
         var l = $(this);
64 64
         var id = l.closest("tr").attr("id");
65 65
         var filename = l.closest("tr").find(".attachFilename").html();
66
-        if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) {
66
+        if (confirm("' . get_lang('AreYouSureToDeleteJS').'", filename)) {
67 67
             $.ajax({
68 68
                 type: "POST",
69
-                url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'",
69
+                url: "'.api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId.'&forum='.$forumId.'",
70 70
                 dataType: "json",
71 71
                 success: function(data) {
72 72
                     if (data.error == false) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 function show_add_forumcategory_form($inputvalues = array(), $lp_id)
180 180
 {
181 181
     // Initialize the object.
182
-    $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq());
182
+    $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq());
183 183
     // hidden field if from learning path
184 184
 
185 185
     $form->addElement('hidden', 'lp_id', $lp_id);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 function show_add_forum_form($inputvalues = array(), $lp_id)
230 230
 {
231 231
     $_course = api_get_course_info();
232
-    $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq());
232
+    $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq());
233 233
 
234 234
     // The header for the form
235 235
     if (!empty($inputvalues)) {
@@ -971,24 +971,24 @@  discard block
 block discarded – undo
971 971
     $html = '';
972 972
     $id = Security::remove_XSS($id);
973 973
     if ($current_visibility_status == '1') {
974
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
974
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
975 975
         if (is_array($additional_url_parameters)) {
976 976
             foreach ($additional_url_parameters as $key => $value) {
977
-                $html .= $key . '=' . $value . '&';
977
+                $html .= $key.'='.$value.'&';
978 978
             }
979 979
         }
980
-        $html.='action=invisible&content='.$content.'&id='.$id.'">'.
980
+        $html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
981 981
             Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
982 982
     }
983 983
     if ($current_visibility_status == '0') {
984
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
984
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
985 985
         if (is_array($additional_url_parameters)) {
986 986
             foreach ($additional_url_parameters as $key => $value) {
987
-                $html .= $key . '=' . $value . '&';
987
+                $html .= $key.'='.$value.'&';
988 988
             }
989 989
         }
990
-        $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
991
-            Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
990
+        $html .= 'action=visible&content='.$content.'&id='.$id.'">'.
991
+            Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>';
992 992
     }
993 993
     return $html;
994 994
 }
@@ -1016,21 +1016,21 @@  discard block
 block discarded – undo
1016 1016
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1017 1017
         if (is_array($additional_url_parameters)) {
1018 1018
             foreach ($additional_url_parameters as $key => $value) {
1019
-                $html .= $key . '=' . $value . '&';
1019
+                $html .= $key.'='.$value.'&';
1020 1020
             }
1021 1021
         }
1022
-        $html.= 'action=unlock&content='.$content.'&id='.$id.'">'.
1022
+        $html .= 'action=unlock&content='.$content.'&id='.$id.'">'.
1023 1023
             Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
1024 1024
     }
1025 1025
     if ($current_lock_status == '0') {
1026 1026
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1027 1027
         if (is_array($additional_url_parameters)) {
1028 1028
             foreach ($additional_url_parameters as $key => $value) {
1029
-                $html .= $key . '=' . $value . '&';
1029
+                $html .= $key.'='.$value.'&';
1030 1030
             }
1031 1031
         }
1032
-        $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' .
1033
-            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
1032
+        $html .= 'action=lock&content='.$content.'&id='.$id.'">'.
1033
+            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>';
1034 1034
     }
1035 1035
     return $html;
1036 1036
 }
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
                     forum_categories.c_id = $course_id AND
1234 1234
                     item_properties.c_id = $course_id AND
1235 1235
                     forum_categories.cat_id=item_properties.ref AND
1236
-                    item_properties.tool='" . TOOL_FORUM_CATEGORY . "'
1236
+                    item_properties.tool='".TOOL_FORUM_CATEGORY."'
1237 1237
                 ORDER BY forum_categories.cat_order $sort_direction";
1238 1238
     }
1239 1239
     if ($content == 'forum') {
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
             FROM $table
1242 1242
             WHERE
1243 1243
                 c_id = $course_id AND
1244
-                forum_category='" . Database::escape_string($forum_category) . "'
1244
+                forum_category='".Database::escape_string($forum_category)."'
1245 1245
             ORDER BY forum_order $sort_direction";
1246 1246
     }
1247 1247
     // Finding the items that need to be switched.
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 {
1299 1299
     $current_visibility_status = intval($current_visibility_status);
1300 1300
     if ($current_visibility_status == 0) {
1301
-        $status='invisible';
1301
+        $status = 'invisible';
1302 1302
         return $status;
1303 1303
     }
1304 1304
 }
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 {
2206 2206
     $table_forums = Database :: get_course_table(TABLE_FORUM);
2207 2207
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
2208
-    $courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId);
2208
+    $courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId);
2209 2209
     $forum_id = intval($forum_id);
2210 2210
 
2211 2211
     $sql = "SELECT *
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
  */
2365 2365
 function store_thread($current_forum, $values, $courseInfo = array(), $showMessage = true)
2366 2366
 {
2367
-    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo ;
2367
+    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
2368 2368
     $_user = api_get_user_info();
2369 2369
     $course_id = $courseInfo['real_id'];
2370 2370
     $courseCode = $courseInfo['code'];
@@ -2608,11 +2608,11 @@  discard block
 block discarded – undo
2608 2608
     $form = new FormValidator(
2609 2609
         'thread',
2610 2610
         'post',
2611
-        api_get_self() . '?' . http_build_query([
2611
+        api_get_self().'?'.http_build_query([
2612 2612
             'forum' => $myForum,
2613 2613
             'gradebook' => $myGradebook,
2614 2614
             'thread' => $myThread,
2615
-        ]) . '&' . api_get_cidreq()
2615
+        ]).'&'.api_get_cidreq()
2616 2616
     );
2617 2617
 
2618 2618
     $form->addElement('header', get_lang('EditThread'));
@@ -2675,7 +2675,7 @@  discard block
 block discarded – undo
2675 2675
     $form->addElement('html', '</div>');
2676 2676
 
2677 2677
     if (!empty($formValues)) {
2678
-        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0 ;
2678
+        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0;
2679 2679
         $defaults['thread_title'] = prepare4display($formValues['threadTitle']);
2680 2680
         $defaults['thread_sticky'] = strval(intval($formValues['threadSticky']));
2681 2681
         $defaults['thread_peer_qualify'] = intval($formValues['threadPeerQualify']);
@@ -2747,13 +2747,13 @@  discard block
 block discarded – undo
2747 2747
     $form = new FormValidator(
2748 2748
         'thread',
2749 2749
         'post',
2750
-        api_get_self() . '?' . http_build_query([
2750
+        api_get_self().'?'.http_build_query([
2751 2751
             'forum' => intval($my_forum),
2752 2752
             'gradebook' => $my_gradebook,
2753 2753
             'thread' => intval($myThread),
2754 2754
             'post' => intval($my_post),
2755 2755
             'action' => $action,
2756
-        ]) . '&' . api_get_cidreq()
2756
+        ]).'&'.api_get_cidreq()
2757 2757
     );
2758 2758
     $form->setConstants(array('forum' => '5'));
2759 2759
 
@@ -3012,7 +3012,7 @@  discard block
 block discarded – undo
3012 3012
 
3013 3013
             if ($row[0] == 0) {
3014 3014
                 $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id)
3015
-                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float)$thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3015
+                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3016 3016
                 Database::query($sql);
3017 3017
 
3018 3018
                 $insertId = Database::insert_id();
@@ -4654,9 +4654,9 @@  discard block
 block discarded – undo
4654 4654
             continue;
4655 4655
         }
4656 4656
 
4657
-        $course_dir = $_course['path'] . '/upload/forum';
4657
+        $course_dir = $_course['path'].'/upload/forum';
4658 4658
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
4659
-        $updir = $sys_course_path . $course_dir;
4659
+        $updir = $sys_course_path.$course_dir;
4660 4660
 
4661 4661
         // Try to add an extension to the file if it hasn't one.
4662 4662
         $new_file_name = add_ext_on_mime(
@@ -4673,7 +4673,7 @@  discard block
 block discarded – undo
4673 4673
         }
4674 4674
 
4675 4675
         $new_file_name = uniqid('');
4676
-        $new_path = $updir . '/' . $new_file_name;
4676
+        $new_path = $updir.'/'.$new_file_name;
4677 4677
         $result = @move_uploaded_file($attachment['tmp_name'], $new_path);
4678 4678
         $safe_file_comment = Database::escape_string($file_comment);
4679 4679
         $safe_file_name = Database::escape_string($file_name);
@@ -4838,16 +4838,16 @@  discard block
 block discarded – undo
4838 4838
     $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
4839 4839
     $course_id = api_get_course_int_id();
4840 4840
 
4841
-    $cond = (!empty($id_attach)) ? " iid = " . (int) $id_attach . "" : " post_id = " . (int) $post_id . "";
4841
+    $cond = (!empty($id_attach)) ? " iid = ".(int) $id_attach."" : " post_id = ".(int) $post_id."";
4842 4842
     $sql = "SELECT path FROM $forum_table_attachment WHERE c_id = $course_id AND $cond";
4843 4843
     $res = Database::query($sql);
4844 4844
     $row = Database::fetch_array($res);
4845 4845
 
4846
-    $course_dir = $_course['path'] . '/upload/forum';
4846
+    $course_dir = $_course['path'].'/upload/forum';
4847 4847
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
4848
-    $updir = $sys_course_path . $course_dir;
4848
+    $updir = $sys_course_path.$course_dir;
4849 4849
     $my_path = isset($row['path']) ? $row['path'] : null;
4850
-    $file = $updir . '/' . $my_path;
4850
+    $file = $updir.'/'.$my_path;
4851 4851
     if (Security::check_abs_path($file, $updir)) {
4852 4852
         @unlink($file);
4853 4853
     }
@@ -5395,35 +5395,35 @@  discard block
 block discarded – undo
5395 5395
                         $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1);
5396 5396
                         $post_counter = count($post_list);
5397 5397
                         if (is_array($post_list) && count($post_list) > 0) {
5398
-                            $hand_forums.= '<div id="social-thread">';
5399
-                            $hand_forums.= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5400
-                            $hand_forums.= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5401
-                            $hand_forums.= '</div>';
5398
+                            $hand_forums .= '<div id="social-thread">';
5399
+                            $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5400
+                            $hand_forums .= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5401
+                            $hand_forums .= '</div>';
5402 5402
 
5403 5403
                             foreach ($post_list as $posts) {
5404
-                                $hand_forums.= '<div id="social-post">';
5405
-                                $hand_forums.= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5406
-                                $hand_forums.= '<br / >';
5407
-                                $hand_forums.= Security::remove_XSS($posts['post_text'], STUDENT);
5408
-                                $hand_forums.= '</div>';
5409
-                                $hand_forums.= '<br / >';
5404
+                                $hand_forums .= '<div id="social-post">';
5405
+                                $hand_forums .= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5406
+                                $hand_forums .= '<br / >';
5407
+                                $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT);
5408
+                                $hand_forums .= '</div>';
5409
+                                $hand_forums .= '<br / >';
5410 5410
                             }
5411 5411
                         }
5412 5412
                     }
5413 5413
                     $i++;
5414 5414
                 }
5415
-                $forum_results .='<div id="social-forum">';
5416
-                $forum_results .='<div class="clear"></div><br />';
5417
-                $forum_results .='<div id="social-forum-title">'.
5415
+                $forum_results .= '<div id="social-forum">';
5416
+                $forum_results .= '<div class="clear"></div><br />';
5417
+                $forum_results .= '<div id="social-forum-title">'.
5418 5418
                     Display::return_icon('forum.gif', get_lang('Forum')).'&nbsp;'.Security::remove_XSS($forum['forum_title'], STUDENT).
5419 5419
                     '<div style="float:right;margin-top:-35px">
5420 5420
                                         <a href="../forum/viewforum.php?cidReq='.$course_code.'&gidReq=&forum='.$forum['forum_id'].' " >'.get_lang('SeeForum').'</a>
5421 5421
                                     </div></div>';
5422
-                $forum_results .='<br / >';
5422
+                $forum_results .= '<br / >';
5423 5423
                 if ($post_counter > 0) {
5424
-                    $forum_results .=$hand_forums;
5424
+                    $forum_results .= $hand_forums;
5425 5425
                 }
5426
-                $forum_results .='</div>';
5426
+                $forum_results .= '</div>';
5427 5427
             }$j++;
5428 5428
         }
5429 5429
     }
@@ -5564,16 +5564,16 @@  discard block
 block discarded – undo
5564 5564
     $courseId = intval($courseId);
5565 5565
     if (empty($courseId)) {
5566 5566
         // $courseId can be null, use api method
5567
-        $courseId= api_get_course_int_id();
5567
+        $courseId = api_get_course_int_id();
5568 5568
     }
5569 5569
     /*
5570 5570
      * Check if Attachment ID and Course ID are greater than zero
5571 5571
      * and array of field values is not empty
5572 5572
      */
5573 5573
     if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) {
5574
-        foreach($array as $key => &$item) {
5574
+        foreach ($array as $key => &$item) {
5575 5575
             $item = Database::escape_string($item);
5576
-            $setString .= $key . ' = "' .$item . '", ';
5576
+            $setString .= $key.' = "'.$item.'", ';
5577 5577
         }
5578 5578
         // Delete last comma
5579 5579
         $setString = substr($setString, 0, strlen($setString) - 2);
@@ -5619,7 +5619,7 @@  discard block
 block discarded – undo
5619 5619
         return '';
5620 5620
     }
5621 5621
 
5622
-    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file';
5622
+    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId.'&postId='.$postId.'&a=upload_file';
5623 5623
 
5624 5624
     $multipleForm = new FormValidator('post');
5625 5625
     $multipleForm->addMultipleUpload($url);
@@ -5660,10 +5660,10 @@  discard block
 block discarded – undo
5660 5660
         foreach ($uploadedFiles as $k => $uploadedFile) {
5661 5661
             if (!empty($uploadedFile) && in_array($uploadedFile['id'], $attachIds)) {
5662 5662
                 // Buil html table including an input with attachmentID
5663
-                $fileDataContent .= '<tr id="' . $uploadedFile['id'] . '" ><td>' . $uploadedFile['name'] . '</td><td>' . $uploadedFile['size'] . '</td><td>&nbsp;' . $uploadedFile['result'] .
5664
-                    ' </td><td> <input style="width:90%;" type="text" value="' . $uploadedFile['comment'] . '" name="file_comments[]"> </td><td>' .
5665
-                    $uploadedFile['delete'] . '</td>' .
5666
-                    '<input type="hidden" value="' . $uploadedFile['id'] .'" name="file_ids[]">' . '</tr>';
5663
+                $fileDataContent .= '<tr id="'.$uploadedFile['id'].'" ><td>'.$uploadedFile['name'].'</td><td>'.$uploadedFile['size'].'</td><td>&nbsp;'.$uploadedFile['result'].
5664
+                    ' </td><td> <input style="width:90%;" type="text" value="'.$uploadedFile['comment'].'" name="file_comments[]"> </td><td>'.
5665
+                    $uploadedFile['delete'].'</td>'.
5666
+                    '<input type="hidden" value="'.$uploadedFile['id'].'" name="file_ids[]">'.'</tr>';
5667 5667
             } else {
5668 5668
                 /*
5669 5669
                  * If attachment data is empty, then delete it from $_SESSION
@@ -5676,7 +5676,7 @@  discard block
 block discarded – undo
5676 5676
     $style = empty($fileDataContent) ? 'display: none;' : '';
5677 5677
     // Forum attachment Ajax table
5678 5678
     $fileData = '
5679
-    <div class="control-group " style="'. $style . '">
5679
+    <div class="control-group " style="'. $style.'">
5680 5680
         <label class="control-label">'.get_lang('AttachmentList').'</label>
5681 5681
         <div class="controls">
5682 5682
             <table id="attachmentFileList" class="files data_table span10">
@@ -5748,7 +5748,7 @@  discard block
 block discarded – undo
5748 5748
             // name contains an URL to download attachment file and its filename
5749 5749
             $json['name'] = Display::url(
5750 5750
                 api_htmlentities($row['filename']),
5751
-                api_get_path(WEB_CODE_PATH) . 'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5751
+                api_get_path(WEB_CODE_PATH).'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5752 5752
                 array('target'=>'_blank', 'class' => 'attachFilename')
5753 5753
             );
5754 5754
             $json['id'] = $row['iid'];
@@ -5759,9 +5759,9 @@  discard block
 block discarded – undo
5759 5759
             if (!empty($row) && is_array($row)) {
5760 5760
                 // Set result as success and bring delete URL
5761 5761
                 $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
5762
-                $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId.'&id_attach=' . $row['iid'];
5762
+                $url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid'];
5763 5763
                 $json['delete'] = Display::url(
5764
-                    Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL),
5764
+                    Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL),
5765 5765
                     $url,
5766 5766
                     array('class' => 'deleteLink')
5767 5767
                 );
@@ -5850,7 +5850,7 @@  discard block
 block discarded – undo
5850 5850
                 WHERE c_id = $courseId AND post_id = $postId";
5851 5851
         $result = Database::query($sql);
5852 5852
         if ($result !== false && Database::num_rows($result) > 0) {
5853
-            while ($row = Database::fetch_array($result,'ASSOC')) {
5853
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
5854 5854
                 $array[] = $row['id'];
5855 5855
             }
5856 5856
         }
Please login to merge, or discard this patch.