Passed
Push — 1.10.x ( 08890a...2189d7 )
by Yannick
116:38 queued 75:46
created
main/inc/lib/add_many_session_to_category_functions.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      * Search for a session based on a given search string
18 18
      * @param string A search string
19 19
      * @param string A search box type (single or anything else)
20
-     * @return string XajaxResponse
20
+     * @return xajaxResponse XajaxResponse
21 21
      * @assert () !== ''
22 22
      * @assert ('abc','single') !== ''
23 23
      */
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Definition of the AddManySessionToCategoryFunctions class
5
- * @package chamilo.library
6
- */
4
+     * Definition of the AddManySessionToCategoryFunctions class
5
+     * @package chamilo.library
6
+     */
7 7
 /**
8
- * Requires
9
- */
8
+     * Requires
9
+     */
10 10
 require_once ('xajax/xajax.inc.php');
11 11
 /**
12
- * AddManySessionToCategoryFunctions class
13
- */
12
+     * AddManySessionToCategoryFunctions class
13
+     */
14 14
 class AddManySessionToCategoryFunctions
15 15
 {
16 16
     /**
@@ -24,28 +24,28 @@  discard block
 block discarded – undo
24 24
     function search_courses($needle,$type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27
-		$xajax_response = new xajaxResponse();
28
-		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
30
-			// xajax send utf8 datas... datas in db can be non-utf8 datas
31
-			$charset = api_get_system_encoding();
32
-			$needle = api_convert_encoding($needle, $charset, 'utf-8');
33
-			$needle = Database::escape_string($needle);
27
+        $xajax_response = new xajaxResponse();
28
+        $return = '';
29
+        if(!empty($needle) && !empty($type)) {
30
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
31
+            $charset = api_get_system_encoding();
32
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
33
+            $needle = Database::escape_string($needle);
34 34
 
35
-			$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
35
+            $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
36 36
 
37
-			$rs = Database::query($sql);
38
-			$course_list = array();
37
+            $rs = Database::query($sql);
38
+            $course_list = array();
39 39
 
40
-			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
42
-				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
-			}
45
-			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
-		}
48
-		$_SESSION['course_list'] = $course_list;
49
-		return $xajax_response;
50
-	}
40
+            $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
+            while($course = Database :: fetch_array($rs)) {
42
+                $course_list[] = $course['id'];
43
+                $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
+            }
45
+            $return .= '</select>';
46
+            $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
+        }
48
+        $_SESSION['course_list'] = $course_list;
49
+        return $xajax_response;
50
+    }
51 51
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
      * @assert () !== ''
22 22
      * @assert ('abc','single') !== ''
23 23
      */
24
-    function search_courses($needle,$type)
24
+    function search_courses($needle, $type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27 27
 		$xajax_response = new xajaxResponse();
28 28
 		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
29
+		if (!empty($needle) && !empty($type)) {
30 30
 			// xajax send utf8 datas... datas in db can be non-utf8 datas
31 31
 			$charset = api_get_system_encoding();
32 32
 			$needle = api_convert_encoding($needle, $charset, 'utf-8');
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 			$course_list = array();
39 39
 
40 40
 			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
41
+			while ($course = Database :: fetch_array($rs)) {
42 42
 				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
43
+				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>';
44 44
 			}
45 45
 			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
46
+			$xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
47 47
 		}
48 48
 		$_SESSION['course_list'] = $course_list;
49 49
 		return $xajax_response;
Please login to merge, or discard this patch.
main/inc/lib/agenda.lib.php 3 patches
Doc Comments   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -554,13 +554,12 @@  discard block
 block discarded – undo
554 554
      * @param string $title
555 555
      * @param string $content
556 556
      * @param array $usersToSend
557
-     * @param int $editRepeatType
558 557
      * @param array $attachmentArray
559 558
      * @param string $attachmentComment
560 559
      * @param string $comment
561 560
      * @param string $color
562 561
      *
563
-     * @return bool
562
+     * @return null|false
564 563
      */
565 564
     public function editEvent(
566 565
         $id,
@@ -1292,6 +1291,7 @@  discard block
 block discarded – undo
1292 1291
      *
1293 1292
      * @param int $eventId
1294 1293
      * @param int $courseId
1294
+     * @param integer $sessionId
1295 1295
      * @paraù int $sessionId
1296 1296
      *
1297 1297
      * @return array
@@ -2284,6 +2284,7 @@  discard block
 block discarded – undo
2284 2284
      * @param array $fileUserUpload ($_FILES['user_upload'])
2285 2285
      * @param string comment about file
2286 2286
      * @param array $courseInfo
2287
+     * @param string $comment
2287 2288
      * @return string
2288 2289
      */
2289 2290
     public function addAttachment($eventId, $fileUserUpload, $comment, $courseInfo)
@@ -2403,6 +2404,7 @@  discard block
 block discarded – undo
2403 2404
      * Adds x weeks to a UNIX timestamp
2404 2405
      * @param   int     The timestamp
2405 2406
      * @param   int     The number of weeks to add
2407
+     * @param integer $timestamp
2406 2408
      * @return  int     The new timestamp
2407 2409
      */
2408 2410
     function addWeek($timestamp, $num = 1)
@@ -2414,6 +2416,7 @@  discard block
 block discarded – undo
2414 2416
      * Adds x months to a UNIX timestamp
2415 2417
      * @param   int     The timestamp
2416 2418
      * @param   int     The number of years to add
2419
+     * @param integer $timestamp
2417 2420
      * @return  int     The new timestamp
2418 2421
      */
2419 2422
     function addMonth($timestamp, $num = 1)
@@ -2432,6 +2435,7 @@  discard block
 block discarded – undo
2432 2435
      * Adds x years to a UNIX timestamp
2433 2436
      * @param   int     The timestamp
2434 2437
      * @param   int     The number of years to add
2438
+     * @param integer $timestamp
2435 2439
      * @return  int     The new timestamp
2436 2440
      */
2437 2441
     function addYear($timestamp, $num = 1)
@@ -2631,7 +2635,7 @@  discard block
 block discarded – undo
2631 2635
     /**
2632 2636
      * @param array $courseInfo
2633 2637
      * @param $file
2634
-     * @return array|bool|string
2638
+     * @return false|string
2635 2639
      */
2636 2640
     public function importEventFile($courseInfo, $file)
2637 2641
     {
@@ -2744,7 +2748,7 @@  discard block
 block discarded – undo
2744 2748
 
2745 2749
     /**
2746 2750
      * Parse filter turns USER:12 to ['users' => [12])] or G:1 ['groups' => [1]]
2747
-     * @param $filter
2751
+     * @param integer $filter
2748 2752
      * @return array
2749 2753
      */
2750 2754
     public function parseAgendaFilter($filter)
@@ -3259,6 +3263,7 @@  discard block
 block discarded – undo
3259 3263
      * @param	int		user ID of the user
3260 3264
      * @param	string	Optional start date in datetime format (if no start date is given, uses today)
3261 3265
      * @param	string	Optional end date in datetime format (if no date is given, uses one year from now)
3266
+     * @param integer $user_id
3262 3267
      * @return	array	Array of events ordered by start date, in
3263 3268
      * [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format,
3264 3269
      * where datestart and dateend are in yyyyMMddhhmmss format.
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1483,12 +1483,12 @@  discard block
 block discarded – undo
1483 1483
             }
1484 1484
 
1485 1485
             if (empty($session_id)) {
1486
-                $sessionCondition =  "
1486
+                $sessionCondition = "
1487 1487
                 (
1488 1488
                     agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0)
1489 1489
                 ) ";
1490 1490
             } else {
1491
-                $sessionCondition =  "
1491
+                $sessionCondition = "
1492 1492
                 (
1493 1493
                     agenda.session_id = $session_id AND
1494 1494
                     ip.session_id = $session_id
@@ -1527,13 +1527,13 @@  discard block
 block discarded – undo
1527 1527
             }
1528 1528
 
1529 1529
             if (empty($session_id)) {
1530
-                $sessionCondition =  "
1530
+                $sessionCondition = "
1531 1531
                 (
1532 1532
                     agenda.session_id = 0 AND
1533 1533
                     (ip.session_id IS NULL OR ip.session_id = 0)
1534 1534
                 ) ";
1535 1535
             } else {
1536
-                $sessionCondition =  "
1536
+                $sessionCondition = "
1537 1537
                 (
1538 1538
                     agenda.session_id = $session_id AND
1539 1539
                     ip.session_id = $session_id
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1586 1586
                 $event = array();
1587 1587
                 $event['id'] = 'course_'.$row['id'];
1588
-                $event['unique_id']  = $row['iid'];
1588
+                $event['unique_id'] = $row['iid'];
1589 1589
                 // To avoid doubles
1590 1590
                 if (in_array($event['unique_id'], $eventsAdded)) {
1591 1591
                     continue;
@@ -2663,8 +2663,8 @@  discard block
 block discarded – undo
2663 2663
 
2664 2664
                 $startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e'));
2665 2665
                 $endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e'));
2666
-                $title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8');
2667
-                $description = api_convert_encoding((string)$event->description, $charset, 'UTF-8');
2666
+                $title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8');
2667
+                $description = api_convert_encoding((string) $event->description, $charset, 'UTF-8');
2668 2668
 
2669 2669
                 $id = $this->addEvent(
2670 2670
                     $startDateTime,
@@ -2806,7 +2806,7 @@  discard block
 block discarded – undo
2806 2806
 							ORDER BY start_date ";
2807 2807
             } else {
2808 2808
                 // if the user is not an administrator of that course
2809
-                if (is_array($group_memberships) && count($group_memberships)>0) {
2809
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
2810 2810
                     $sqlquery = "SELECT	agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
2811 2811
 								FROM ".$TABLEAGENDA." agenda,
2812 2812
 									".$TABLE_ITEMPROPERTY." ip
@@ -2836,14 +2836,14 @@  discard block
 block discarded – undo
2836 2836
                 $agendaday = -1;
2837 2837
                 if ($item['start_date'] != '0000-00-00 00:00:00') {
2838 2838
                     $item['start_date'] = api_get_local_time($item['start_date']);
2839
-                    $item['start_date_tms']  = api_strtotime($item['start_date']);
2839
+                    $item['start_date_tms'] = api_strtotime($item['start_date']);
2840 2840
                     $agendaday = date("j", $item['start_date_tms']);
2841 2841
                 }
2842 2842
                 if ($item['end_date'] != '0000-00-00 00:00:00') {
2843 2843
                     $item['end_date'] = api_get_local_time($item['end_date']);
2844 2844
                 }
2845 2845
 
2846
-                $url  = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2846
+                $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2847 2847
 
2848 2848
                 $item['url'] = $url;
2849 2849
                 $item['course_name'] = $array_course_info['title'];
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
         }
2856 2856
 
2857 2857
         // sorting by hour for every day
2858
-        $agendaitems = array ();
2858
+        $agendaitems = array();
2859 2859
         while (list ($agendaday, $tmpitems) = each($items)) {
2860
-            if(!isset($agendaitems[$agendaday])) {
2860
+            if (!isset($agendaitems[$agendaday])) {
2861 2861
                 $agendaitems[$agendaday] = '';
2862 2862
             }
2863 2863
             sort($tmpitems);
@@ -3031,9 +3031,9 @@  discard block
 block discarded – undo
3031 3031
             $end_year = $start_end_day_of_week['end']['year'];
3032 3032
             // in sql statements you have to use year-month-day for date calculations
3033 3033
             $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
3034
-            $start_filter  = api_get_utc_datetime($start_filter);
3034
+            $start_filter = api_get_utc_datetime($start_filter);
3035 3035
             $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
3036
-            $end_filter  = api_get_utc_datetime($end_filter);
3036
+            $end_filter = api_get_utc_datetime($end_filter);
3037 3037
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3038 3038
         }
3039 3039
         // 3. creating the SQL statement for getting the personal agenda items in DAY view
@@ -3041,18 +3041,18 @@  discard block
 block discarded – undo
3041 3041
             // we are in day view
3042 3042
             // we could use mysql date() function but this is only available from 4.1 and higher
3043 3043
             $start_filter = $year."-".$month."-".$day." 00:00:00";
3044
-            $start_filter  = api_get_utc_datetime($start_filter);
3044
+            $start_filter = api_get_utc_datetime($start_filter);
3045 3045
             $end_filter = $year."-".$month."-".$day." 23:59:59";
3046
-            $end_filter  = api_get_utc_datetime($end_filter);
3046
+            $end_filter = api_get_utc_datetime($end_filter);
3047 3047
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3048 3048
         }
3049 3049
 
3050 3050
         $result = Database::query($sql);
3051 3051
         while ($item = Database::fetch_array($result, 'ASSOC')) {
3052 3052
 
3053
-            $time_minute 	= api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3054
-            $item['date']   = api_get_local_time($item['date']);
3055
-            $item['start_date_tms']  = api_strtotime($item['date']);
3053
+            $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3054
+            $item['date'] = api_get_local_time($item['date']);
3055
+            $item['start_date_tms'] = api_strtotime($item['date']);
3056 3056
             $item['content'] = $item['text'];
3057 3057
 
3058 3058
             // we break the date field in the database into a date and a time part
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
             $second = $agendatime[2];
3073 3073
 
3074 3074
             if ($type == 'month_view') {
3075
-                $item['calendar_type']  = 'personal';
3075
+                $item['calendar_type'] = 'personal';
3076 3076
                 $item['start_date']  	= $item['date'];
3077 3077
                 $agendaitems[$day][] 	= $item;
3078 3078
                 continue;
@@ -3097,7 +3097,7 @@  discard block
 block discarded – undo
3097 3097
                 // this is the array construction for the DAY view
3098 3098
                 $halfhour = 2 * $agendatime['0'];
3099 3099
                 if ($agendatime['1'] >= '30') {
3100
-                    $halfhour = $halfhour +1;
3100
+                    $halfhour = $halfhour + 1;
3101 3101
                 }
3102 3102
 
3103 3103
                 //Display events by list
@@ -3121,25 +3121,25 @@  discard block
 block discarded – undo
3121 3121
     {
3122 3122
         global $DaysShort, $course_path;
3123 3123
         //Handle leap year
3124
-        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3124
+        $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3125 3125
         if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
3126 3126
             $numberofdays[2] = 29;
3127 3127
         //Get the first day of the month
3128 3128
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
3129 3129
         //Start the week on monday
3130 3130
         $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
3131
-        $g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:'');
3131
+        $g_cc = (isset($_GET['courseCode']) ? $_GET['courseCode'] : '');
3132 3132
 
3133
-        $prev_icon = Display::return_icon('action_prev.png',get_lang('Previous'));
3134
-        $next_icon = Display::return_icon('action_next.png',get_lang('Next'));
3133
+        $prev_icon = Display::return_icon('action_prev.png', get_lang('Previous'));
3134
+        $next_icon = Display::return_icon('action_next.png', get_lang('Next'));
3135 3135
 
3136
-        $next_month = ($month == 1 ? 12 : $month -1);
3137
-        $prev_month = ($month == 12 ? 1 : $month +1);
3136
+        $next_month = ($month == 1 ? 12 : $month - 1);
3137
+        $prev_month = ($month == 12 ? 1 : $month + 1);
3138 3138
 
3139
-        $next_year = ($month == 1 ? $year -1 : $year);
3140
-        $prev_year = ($month == 12 ? $year +1 : $year);
3139
+        $next_year = ($month == 1 ? $year - 1 : $year);
3140
+        $prev_year = ($month == 12 ? $year + 1 : $year);
3141 3141
 
3142
-        if ($show_content)  {
3142
+        if ($show_content) {
3143 3143
             $back_url = Display::url($prev_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year);
3144 3144
             $next_url = Display::url($next_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year);
3145 3145
         } else {
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
         echo '</tr>';
3156 3156
 
3157 3157
         echo '<tr>';
3158
-        for ($ii = 1; $ii < 8; $ii ++) {
3158
+        for ($ii = 1; $ii < 8; $ii++) {
3159 3159
             echo '<td class="weekdays">'.$DaysShort[$ii % 7].'</td>';
3160 3160
         }
3161 3161
         echo '</tr>';
@@ -3164,7 +3164,7 @@  discard block
 block discarded – undo
3164 3164
         $today = getdate();
3165 3165
         while ($curday <= $numberofdays[$month]) {
3166 3166
             echo "<tr>";
3167
-            for ($ii = 0; $ii < 7; $ii ++) {
3167
+            for ($ii = 0; $ii < 7; $ii++) {
3168 3168
                 if (($curday == -1) && ($ii == $startdayofweek)) {
3169 3169
                     $curday = 1;
3170 3170
                 }
@@ -3178,21 +3178,21 @@  discard block
 block discarded – undo
3178 3178
                     echo "<td ".$class.">".$dayheader;
3179 3179
 
3180 3180
                     if (!empty($agendaitems[$curday])) {
3181
-                        $items =  $agendaitems[$curday];
3182
-                        $items =  msort($items, 'start_date_tms');
3181
+                        $items = $agendaitems[$curday];
3182
+                        $items = msort($items, 'start_date_tms');
3183 3183
 
3184
-                        foreach($items  as $value) {
3184
+                        foreach ($items  as $value) {
3185 3185
                             $value['title'] = Security::remove_XSS($value['title']);
3186 3186
                             $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);
3187 3187
                             $end_time = '';
3188 3188
 
3189 3189
                             if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') {
3190
-                                $end_time    = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3190
+                                $end_time = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3191 3191
                             }
3192 3192
                             $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i>&nbsp;'.$end_time;
3193 3193
                             $time = '<i>'.$start_time.'</i>';
3194 3194
 
3195
-                            switch($value['calendar_type']) {
3195
+                            switch ($value['calendar_type']) {
3196 3196
                                 case 'personal':
3197 3197
                                     $bg_color = '#D0E7F4';
3198 3198
                                     $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL);
@@ -3244,7 +3244,7 @@  discard block
 block discarded – undo
3244 3244
                         }
3245 3245
                     }
3246 3246
                     echo "</td>";
3247
-                    $curday ++;
3247
+                    $curday++;
3248 3248
                 } else {
3249 3249
                     echo "<td></td>";
3250 3250
                 }
@@ -3264,18 +3264,18 @@  discard block
 block discarded – undo
3264 3264
      * where datestart and dateend are in yyyyMMddhhmmss format.
3265 3265
      * @TODO Implement really personal events (from user DB) and global events (from main DB)
3266 3266
      */
3267
-    public static function get_personal_agenda_items_between_dates($user_id, $date_start='', $date_end='')
3267
+    public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '')
3268 3268
     {
3269
-        $items = array ();
3269
+        $items = array();
3270 3270
         if ($user_id != strval(intval($user_id))) { return $items; }
3271
-        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s');}
3272
-        if (empty($date_end))   { $date_end = date('Y-m-d H:i:s',mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1));}
3271
+        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s'); }
3272
+        if (empty($date_end)) { $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); }
3273 3273
         $expr = '/\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}/';
3274
-        if(!preg_match($expr,$date_start)) { return $items; }
3275
-        if(!preg_match($expr,$date_end)) { return $items; }
3274
+        if (!preg_match($expr, $date_start)) { return $items; }
3275
+        if (!preg_match($expr, $date_end)) { return $items; }
3276 3276
 
3277 3277
         // get agenda-items for every course
3278
-        $courses = api_get_user_courses($user_id,false);
3278
+        $courses = api_get_user_courses($user_id, false);
3279 3279
         foreach ($courses as $id => $course) {
3280 3280
             $c = api_get_course_info_by_id($course['real_id']);
3281 3281
             //databases of the courses
@@ -3299,9 +3299,9 @@  discard block
 block discarded – undo
3299 3299
                     " ORDER BY start_date ";
3300 3300
             } else {
3301 3301
                 // if the user is not an administrator of that course, then...
3302
-                if (is_array($group_memberships) && count($group_memberships)>0)
3302
+                if (is_array($group_memberships) && count($group_memberships) > 0)
3303 3303
                 {
3304
-                    $sqlquery = "SELECT " .
3304
+                    $sqlquery = "SELECT ".
3305 3305
                         "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref ".
3306 3306
                         " FROM ".$t_a." agenda, ".
3307 3307
                         $t_ip." ip ".
@@ -3329,13 +3329,13 @@  discard block
 block discarded – undo
3329 3329
 
3330 3330
             $result = Database::query($sqlquery);
3331 3331
             while ($item = Database::fetch_array($result)) {
3332
-                $agendaday = date("j",strtotime($item['start_date']));
3333
-                $month = date("n",strtotime($item['start_date']));
3334
-                $year = date("Y",strtotime($item['start_date']));
3332
+                $agendaday = date("j", strtotime($item['start_date']));
3333
+                $month = date("n", strtotime($item['start_date']));
3334
+                $year = date("Y", strtotime($item['start_date']));
3335 3335
                 $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
3336
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']);
3336
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']);
3337 3337
                 $start_date = $year.$month.$day.$hour.$min;
3338
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']);
3338
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']);
3339 3339
                 $end_date = $year.$month.$day.$hour.$min;
3340 3340
 
3341 3341
                 $items[] = array(
@@ -3364,7 +3364,7 @@  discard block
 block discarded – undo
3364 3364
         $user = api_get_user_id();
3365 3365
         $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE id=".$id." AND user = ".$user;
3366 3366
         $result = Database::query($sql);
3367
-        if(Database::num_rows($result)==1) {
3367
+        if (Database::num_rows($result) == 1) {
3368 3368
             $item = Database::fetch_array($result);
3369 3369
         } else {
3370 3370
             $item = null;
@@ -3386,9 +3386,9 @@  discard block
 block discarded – undo
3386 3386
         // step 2: we which day this is (0=sunday, 1=monday, ...)
3387 3387
         $number_day_in_week = date('w', $random_day_in_week);
3388 3388
         // step 3: we calculate the timestamp of the monday of the week we are in
3389
-        $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60);
3389
+        $start_timestamp = $random_day_in_week - (($number_day_in_week - 1) * 24 * 60 * 60);
3390 3390
         // step 4: we calculate the timestamp of the sunday of the week we are in
3391
-        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600;
3391
+        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week + 1) * 24 * 60 * 60) - 3600;
3392 3392
         // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year
3393 3393
         $start_day = date('j', $start_timestamp);
3394 3394
         $start_month = date('n', $start_timestamp);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3122,8 +3122,9 @@
 block discarded – undo
3122 3122
         global $DaysShort, $course_path;
3123 3123
         //Handle leap year
3124 3124
         $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3125
-        if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
3126
-            $numberofdays[2] = 29;
3125
+        if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) {
3126
+                    $numberofdays[2] = 29;
3127
+        }
3127 3128
         //Get the first day of the month
3128 3129
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
3129 3130
         //Start the week on monday
Please login to merge, or discard this patch.
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   +83 added lines, -83 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) {
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 
1408 1408
             //if (!empty($user_id)) {
1409 1409
             if (0) {
1410
-                if (is_array($group_memberships) && count($group_memberships) > 0 ) {
1410
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
1411 1411
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
1412 1412
                             FROM $tbl_announcement announcement, $tbl_item_property ip
1413 1413
                             WHERE
@@ -1456,8 +1456,8 @@  discard block
 block discarded – undo
1456 1456
                 // A.3 you are a course admin without any group or user filter
1457 1457
                 // A.3.a you are a course admin without user or group filter but WITH studentview
1458 1458
                 // => see all the messages of all the users and groups without editing possibilities
1459
-                if (isset($isStudentView) and $isStudentView=="true") {
1460
-                    $sql="SELECT
1459
+                if (isset($isStudentView) and $isStudentView == "true") {
1460
+                    $sql = "SELECT
1461 1461
                         announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
1462 1462
                         FROM $tbl_announcement announcement, $tbl_item_property ip
1463 1463
                         WHERE
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
             }
1488 1488
         } else {
1489 1489
             // STUDENT
1490
-            if (is_array($group_memberships) && count($group_memberships)>0) {
1490
+            if (is_array($group_memberships) && count($group_memberships) > 0) {
1491 1491
                 if ($allowUserEditSetting && !api_is_anonymous()) {
1492 1492
 
1493 1493
                     if (api_get_group_id() == 0) {
@@ -1591,12 +1591,12 @@  discard block
 block discarded – undo
1591 1591
                 (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
1592 1592
             ) {
1593 1593
                 $html .= '<div id="no-data-view">';
1594
-                $html .= '<h3>' . get_lang('Announcements') . '</h3>';
1594
+                $html .= '<h3>'.get_lang('Announcements').'</h3>';
1595 1595
                 $html .= Display::return_icon('valves.png', '', array(), 64);
1596 1596
                 $html .= '<div class="controls">';
1597 1597
                 $html .= Display::url(
1598 1598
                     get_lang('AddAnnouncement'),
1599
-                    api_get_self() . "?" . api_get_cidreq() . "&action=add",
1599
+                    api_get_self()."?".api_get_cidreq()."&action=add",
1600 1600
                     array('class' => 'btn btn-primary')
1601 1601
                 );
1602 1602
                 $html .= '</div>';
@@ -1613,9 +1613,9 @@  discard block
 block discarded – undo
1613 1613
 
1614 1614
         $html .= '<table width="100%" class="data_table announcements-list">';
1615 1615
         $ths = Display::tag('th', get_lang('Title'));
1616
-        $ths .= Display::tag('th', get_lang('By') );
1617
-        $ths .= Display::tag('th', get_lang('LastUpdateDate') );
1618
-        if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() &&
1616
+        $ths .= Display::tag('th', get_lang('By'));
1617
+        $ths .= Display::tag('th', get_lang('LastUpdateDate'));
1618
+        if (api_is_allowed_to_edit(false, true) OR (api_is_course_coach() &&
1619 1619
             api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']))
1620 1620
             OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
1621 1621
             $ths .= Display::tag('th', get_lang('Modify'));
@@ -1637,7 +1637,7 @@  discard block
 block discarded – undo
1637 1637
 
1638 1638
                 // the styles
1639 1639
                 if ($myrow['visibility'] == '0') {
1640
-                    $style='invisible';
1640
+                    $style = 'invisible';
1641 1641
                 } else {
1642 1642
                     $style = '';
1643 1643
                 }
@@ -1648,8 +1648,8 @@  discard block
 block discarded – undo
1648 1648
                 $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
1649 1649
 
1650 1650
                 $attachment_icon = '';
1651
-                if (count($attachment_list)>0) {
1652
-                    $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));
1651
+                if (count($attachment_list) > 0) {
1652
+                    $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment'));
1653 1653
                 }
1654 1654
 
1655 1655
                 /* TITLE */
@@ -1664,22 +1664,22 @@  discard block
 block discarded – undo
1664 1664
 
1665 1665
                 // we can edit if : we are the teacher OR the element belongs to
1666 1666
                 // the session we are coaching OR the option to allow users to edit is on
1667
-                if (api_is_allowed_to_edit(false,true) OR
1667
+                if (api_is_allowed_to_edit(false, true) OR
1668 1668
                     (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']))
1669 1669
                     OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
1670 1670
                 ) {
1671 1671
 
1672 1672
                     $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">".
1673
-                        Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>";
1674
-                    if ($myrow['visibility']==1) {
1675
-                        $image_visibility="visible";
1676
-                        $alt_visibility=get_lang('Hide');
1673
+                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>";
1674
+                    if ($myrow['visibility'] == 1) {
1675
+                        $image_visibility = "visible";
1676
+                        $alt_visibility = get_lang('Hide');
1677 1677
                     } else {
1678
-                        $image_visibility="invisible";
1679
-                        $alt_visibility=get_lang('Visible');
1678
+                        $image_visibility = "invisible";
1679
+                        $alt_visibility = get_lang('Visible');
1680 1680
                     }
1681
-                    $modify_icons .=  "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
1682
-                        Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>";
1681
+                    $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
1682
+                        Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
1683 1683
 
1684 1684
                     // DISPLAY MOVE UP COMMAND only if it is not the top announcement
1685 1685
                     if ($iterator != 1) {
@@ -1694,12 +1694,12 @@  discard block
 block discarded – undo
1694 1694
                     } else {
1695 1695
                         $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
1696 1696
                     }
1697
-                    if (api_is_allowed_to_edit(false,true)) {
1698
-                        $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&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;\">".
1699
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).
1697
+                    if (api_is_allowed_to_edit(false, true)) {
1698
+                        $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&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;\">".
1699
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).
1700 1700
                             "</a>";
1701 1701
                     }
1702
-                    $iterator ++;
1702
+                    $iterator++;
1703 1703
                     $html .= Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions'));
1704 1704
                 }
1705 1705
                 $html .= "</tr>";
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
     public static function getNumberAnnouncements()
1718 1718
     {
1719 1719
         // Maximum title messages to display
1720
-        $maximum 	= '12';
1720
+        $maximum = '12';
1721 1721
         // Database Table Definitions
1722 1722
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
1723 1723
         $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
         $userId = api_get_user_id();
1729 1729
         $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id');
1730 1730
 
1731
-        if (api_is_allowed_to_edit(false,true))  {
1731
+        if (api_is_allowed_to_edit(false, true)) {
1732 1732
             // check teacher status
1733 1733
             if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
1734 1734
 
@@ -1791,7 +1791,7 @@  discard block
 block discarded – undo
1791 1791
                 }
1792 1792
 
1793 1793
                 // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
1794
-                if (is_array($group_memberships) && count($group_memberships)>0) {
1794
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
1795 1795
                     $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1796 1796
                     FROM $tbl_announcement announcement, $tbl_item_property ip
1797 1797
                     WHERE
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
                         }
1842 1842
 
1843 1843
                         // the user is not identiefied => show only the general announcements
1844
-                        $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1844
+                        $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
1845 1845
                                 FROM $tbl_announcement announcement, $tbl_item_property ip
1846 1846
                                 WHERE
1847 1847
                                     announcement.c_id = $course_id AND
Please login to merge, or discard this patch.
main/inc/lib/api.lib.php 4 patches
Doc Comments   +53 added lines, -25 removed lines patch added patch discarded remove patch
@@ -575,7 +575,6 @@  discard block
 block discarded – undo
575 575
  * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
576 576
  *
577 577
  * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
578
- * @param string $type              The requested path type (a defined constant), see the examples.
579 578
  * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
580 579
  * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
581 580
  * @return string                   The requested path or the converted path.
@@ -1070,7 +1069,7 @@  discard block
 block discarded – undo
1070 1069
  * Checks the RFC 3986 syntax of a given URL.
1071 1070
  * @param string $url       The URL to be checked.
1072 1071
  * @param bool $absolute    Whether the URL is absolute (beginning with a scheme such as "http:").
1073
- * @return bool             Returns the URL if it is valid, FALSE otherwise.
1072
+ * @return string|false             Returns the URL if it is valid, FALSE otherwise.
1074 1073
  * This function is an adaptation from the function valid_url(), Drupal CMS.
1075 1074
  * @link http://drupal.org
1076 1075
  * Note: The built-in function filter_var($urs, FILTER_VALIDATE_URL) has a bug for some versions of PHP.
@@ -1650,6 +1649,7 @@  discard block
 block discarded – undo
1650 1649
  * Gets a course setting from the current course_setting table. Try always using integer values.
1651 1650
  * @param string    The name of the setting we want from the table
1652 1651
  * @param string    Optional: course code
1652
+ * @param string $setting_name
1653 1653
  * @return mixed    The value of that setting in that table. Return -1 if not found.
1654 1654
  */
1655 1655
 function api_get_course_setting($setting_name, $course_code = null)
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 /**
1961 1961
  * Checks a password to see wether it is OK to use.
1962 1962
  * @param string $password
1963
- * @return true if the password is acceptable, false otherwise
1963
+ * @return boolean if the password is acceptable, false otherwise
1964 1964
  * Notes about what a password "OK to use" is:
1965 1965
  * 1. The password should be at least 5 characters long.
1966 1966
  * 2. Only English letters (uppercase or lowercase, it doesn't matter) and digits are allowed.
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
      * @author Hugues Peeters <[email protected]>
2133 2133
      * @param  string $failure_type - the type of failure
2134 2134
      * @global array  $api_failureList
2135
-     * @return bolean false to stay consistent with the main script
2135
+     * @return boolean false to stay consistent with the main script
2136 2136
      */
2137 2137
     static function set_failure($failure_type) {
2138 2138
         global $api_failureList;
@@ -3199,8 +3199,8 @@  discard block
 block discarded – undo
3199 3199
 
3200 3200
 /**
3201 3201
 * Checks whether the user is allowed in a specific tool for a specific action
3202
-* @param $tool the tool we are checking if the user has a certain permission
3203
-* @param $action the action we are checking (add, edit, delete, move, visibility)
3202
+* @param string $tool the tool we are checking if the user has a certain permission
3203
+* @param string $action the action we are checking (add, edit, delete, move, visibility)
3204 3204
 * @author Patrick Cool <[email protected]>, Ghent University
3205 3205
 * @author Julio Montoya
3206 3206
 * @version 1.0
@@ -3499,7 +3499,7 @@  discard block
 block discarded – undo
3499 3499
 /**
3500 3500
  * Gets a UNIX timestamp from a database (MySQL) datetime format string
3501 3501
  * @param $last_post_datetime standard output date in a sql query
3502
- * @return unix timestamp
3502
+ * @return integer timestamp
3503 3503
  * @author Toon Van Hoecke <[email protected]>
3504 3504
  * @version October 2003
3505 3505
  * @desc convert sql date to unix timestamp
@@ -3532,6 +3532,9 @@  discard block
 block discarded – undo
3532 3532
  * @param string    Tool (learnpath, document, etc)
3533 3533
  * @param int       The item ID in the given tool
3534 3534
  * @param int       The session ID (optional)
3535
+ * @param string $tool
3536
+ * @param integer $user_id
3537
+ * @param string $type
3535 3538
  * @return int      -1 on error, 0 if invisible, 1 if visible
3536 3539
  */
3537 3540
 function api_get_item_visibility(
@@ -3600,7 +3603,7 @@  discard block
 block discarded – undo
3600 3603
  * @param int $userId
3601 3604
  * @param int $groupId
3602 3605
  * @param int $sessionId
3603
- * @return void
3606
+ * @return false|null
3604 3607
  */
3605 3608
 function api_item_property_delete(
3606 3609
     $courseInfo,
@@ -3655,7 +3658,7 @@  discard block
 block discarded – undo
3655 3658
  * @param array $_course array with course properties
3656 3659
  * @param string $tool tool id, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
3657 3660
  * @param int $item_id id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
3658
- * @param string $lastedit_type add or update action
3661
+ * @param string $last_edit_type add or update action
3659 3662
  * (1) message to be translated (in trad4all) : e.g. DocumentAdded, DocumentUpdated;
3660 3663
  * (2) "delete"
3661 3664
  * (3) "visible"
@@ -3938,6 +3941,8 @@  discard block
 block discarded – undo
3938 3941
  * @param string    tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
3939 3942
  * @param int       id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
3940 3943
  * @param int $session_id
3944
+ * @param string $tool
3945
+ * @param string $course_code
3941 3946
  * @return array All fields from c_item_property (all rows found) or empty array
3942 3947
  */
3943 3948
 function api_get_item_property_by_tool($tool, $course_code, $session_id = null)
@@ -4107,6 +4112,7 @@  discard block
 block discarded – undo
4107 4112
  * @param string    tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
4108 4113
  * @param int       id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
4109 4114
  * @param int $session_id
4115
+ * @param string $tool
4110 4116
  * @return array Array with all fields from c_item_property, empty array if not found or false if course could not be found
4111 4117
  */
4112 4118
 function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0)
@@ -4192,7 +4198,7 @@  discard block
 block discarded – undo
4192 4198
  * Displays a form (drop down menu) so the user can select his/her preferred language.
4193 4199
  * The form works with or without javascript
4194 4200
  * @param  boolean Hide form if only one language available (defaults to false = show the box anyway)
4195
- * @return void Display the box directly
4201
+ * @return null|string Display the box directly
4196 4202
  */
4197 4203
 function api_display_language_form($hide_if_no_choice = false)
4198 4204
 {
@@ -4470,6 +4476,7 @@  discard block
 block discarded – undo
4470 4476
  * and also when a user subscribes to courses (the new course is added at the end of the main category
4471 4477
  * @author Patrick Cool <[email protected]>, Ghent University
4472 4478
  * @param int $user_course_category: the id of the user_course_category
4479
+ * @param integer $user_id
4473 4480
  * @return int the value of the highest sort of the user_course_category
4474 4481
  */
4475 4482
 function api_max_sort_value($user_course_category, $user_id)
@@ -4679,6 +4686,8 @@  discard block
 block discarded – undo
4679 4686
  * @param the dest folder
4680 4687
  * @param an array of excluded file_name (without extension)
4681 4688
  * @param copied_files the returned array of copied files
4689
+ * @param string $source
4690
+ * @param string $dest
4682 4691
  */
4683 4692
 function copyr($source, $dest, $exclude = array(), $copied_files = array()) {
4684 4693
     if (empty($dest)) { return false; }
@@ -4718,6 +4727,11 @@  discard block
 block discarded – undo
4718 4727
 }
4719 4728
 
4720 4729
 // TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here.
4730
+/**
4731
+ * @param string $pathname
4732
+ * @param string $base_path_document
4733
+ * @param integer $session_id
4734
+ */
4721 4735
 function copy_folder_course_session(
4722 4736
     $pathname,
4723 4737
     $base_path_document,
@@ -4803,6 +4817,9 @@  discard block
 block discarded – undo
4803 4817
 }
4804 4818
 
4805 4819
 // TODO: chmodr() is a better name. Some corrections are needed. Documentation header to be added here.
4820
+/**
4821
+ * @param string $path
4822
+ */
4806 4823
 function api_chmod_R($path, $filemode) {
4807 4824
     if (!is_dir($path)) {
4808 4825
         return chmod($path, $filemode);
@@ -4885,7 +4902,7 @@  discard block
 block discarded – undo
4885 4902
  *   version = VERSION
4886 4903
  * @endverbatim
4887 4904
  * </code>
4888
- * @param $filename
4905
+ * @param string $filename
4889 4906
  *   The file we are parsing. Accepts file with relative or absolute path.
4890 4907
  * @return
4891 4908
  *   The info array.
@@ -4977,7 +4994,7 @@  discard block
 block discarded – undo
4977 4994
 /**
4978 4995
  * Checks whether status given in parameter exists in the platform
4979 4996
  * @param mixed the status (can be either int either string)
4980
- * @return true if the status exists, else returns false
4997
+ * @return boolean if the status exists, else returns false
4981 4998
  */
4982 4999
 function api_status_exists($status_asked) {
4983 5000
     global $_status_list;
@@ -4999,7 +5016,7 @@  discard block
 block discarded – undo
4999 5016
 
5000 5017
 /**
5001 5018
  * Gets the status langvars list
5002
- * @return array the list of status with their translations
5019
+ * @return string[] the list of status with their translations
5003 5020
  */
5004 5021
 function api_get_status_langvars() {
5005 5022
     return array(
@@ -5075,6 +5092,7 @@  discard block
 block discarded – undo
5075 5092
  * @param string    The sub-variable if any (in most cases, this will remain null)
5076 5093
  * @param string    The category if any (in most cases, this will remain null)
5077 5094
  * @param int       The access_url for which this parameter is valid
5095
+ * @param string $cat
5078 5096
  */
5079 5097
 function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url = 1)
5080 5098
 {
@@ -5172,6 +5190,8 @@  discard block
 block discarded – undo
5172 5190
  * @param string    Value
5173 5191
  * @param int       Access URL. Optional. Defaults to 1
5174 5192
  * @param array     Optional array of filters on field type
5193
+ * @param string $category
5194
+ * @param string $value
5175 5195
  */
5176 5196
 function api_set_settings_category($category, $value = null, $access_url = 1, $fieldtype = array())
5177 5197
 {
@@ -5418,6 +5438,10 @@  discard block
 block discarded – undo
5418 5438
  * @param string    The subkey text
5419 5439
  * @param int       The access_url for which this parameter is valid
5420 5440
  * @param int       The changeability of this setting for non-master urls
5441
+ * @param string $val
5442
+ * @param string $var
5443
+ * @param string $sk
5444
+ * @param string $c
5421 5445
  * @return boolean  true on success, false on failure
5422 5446
  */
5423 5447
 function api_add_setting($val, $var, $sk = null, $type = 'textfield', $c = null, $title = '', $com = '', $sc = null, $skt = null, $a = 1, $v = 0) {
@@ -5683,6 +5707,7 @@  discard block
 block discarded – undo
5683 5707
  * @param String the tool of the element
5684 5708
  * @param int the element id in database
5685 5709
  * @param int the session_id to compare with element session id
5710
+ * @param string $tool
5686 5711
  * @return boolean true if the element is in the session, false else
5687 5712
  */
5688 5713
 function api_is_element_in_the_session($tool, $element_id, $session_id = null) {
@@ -5728,8 +5753,6 @@  discard block
 block discarded – undo
5728 5753
  * Replaces "forbidden" characters in a filename string.
5729 5754
  *
5730 5755
  * @param string $filename
5731
- * @param int $length
5732
- * @param bool $file_name
5733 5756
  *
5734 5757
  * @return string
5735 5758
  */
@@ -5965,6 +5988,7 @@  discard block
 block discarded – undo
5965 5988
  * @link http://php.net/manual/en/function.getimagesize.php
5966 5989
  * @link http://www.dokeos.com/forum/viewtopic.php?t=12345
5967 5990
  * @link http://www.dokeos.com/forum/viewtopic.php?t=16355
5991
+ * @return integer
5968 5992
  */
5969 5993
 function api_getimagesize($path) {
5970 5994
     $image = new Image($path);
@@ -6125,6 +6149,7 @@  discard block
 block discarded – undo
6125 6149
  * with his user id and the access_url_id=1
6126 6150
  *
6127 6151
  * @author Julio Montoya
6152
+ * @param integer $user_id
6128 6153
  */
6129 6154
 function api_is_global_platform_admin($user_id = null)
6130 6155
 {
@@ -6186,7 +6211,7 @@  discard block
 block discarded – undo
6186 6211
  * @param int $admin_id_to_check
6187 6212
  * @param int  $my_user_id
6188 6213
  * @param bool $allow_session_admin
6189
- * @return bool
6214
+ * @return boolean|null
6190 6215
  */
6191 6216
 function api_protect_super_admin($admin_id_to_check, $my_user_id = null, $allow_session_admin = false)
6192 6217
 {
@@ -6428,6 +6453,7 @@  discard block
 block discarded – undo
6428 6453
 
6429 6454
 /**
6430 6455
  * Returns the <link> HTML tag
6456
+ * @param string $file
6431 6457
  */
6432 6458
 function api_get_css($file, $media = 'screen') {
6433 6459
     return '<link href="'.$file.'" rel="stylesheet" media="'.$media.'" type="text/css" />'."\n";
@@ -6555,7 +6581,8 @@  discard block
 block discarded – undo
6555 6581
  * This function relies on api_get_course_info()
6556 6582
  * @param   string  The course code - optional (takes it from session if not given)
6557 6583
  * @param   int     The session id  - optional (takes it from session if not given)
6558
- * @return  mixed   The URL of the course or null if something does not work
6584
+ * @param integer $session_id
6585
+ * @return  string|null   The URL of the course or null if something does not work
6559 6586
  * @author  Julio Montoya <[email protected]>
6560 6587
  */
6561 6588
 function api_get_course_url($course_code = null, $session_id = null)
@@ -6670,7 +6697,7 @@  discard block
 block discarded – undo
6670 6697
  * @param int       LINK_EXERCISE, LINK_STUDENTPUBLICATION, LINK_LEARNPATH LINK_FORUM_THREAD, LINK_ATTENDANCE
6671 6698
  * see gradebook/lib/be/linkfactory
6672 6699
  * @param string    course code
6673
- * @return boolean
6700
+ * @return false|null
6674 6701
  */
6675 6702
 function api_block_course_item_locked_by_gradebook($item_id, $link_type, $course_code = null) {
6676 6703
     if (api_is_platform_admin()) {
@@ -6711,7 +6738,7 @@  discard block
 block discarded – undo
6711 6738
 /**
6712 6739
  * Returns an array of global configuration settings which should be ignored
6713 6740
  * when printing the configuration settings screens
6714
- * @return array Array of strings, each identifying one of the excluded settings
6741
+ * @return string[] Array of strings, each identifying one of the excluded settings
6715 6742
  */
6716 6743
 function api_get_locked_settings() {
6717 6744
     return array(
@@ -6754,7 +6781,7 @@  discard block
 block discarded – undo
6754 6781
  * false if he isn't. If the user ID is given and is an integer, then the same
6755 6782
  * ID is simply returned
6756 6783
  * @param  integer User ID
6757
- * @return mixed Integer User ID is logged in, or false otherwise
6784
+ * @return boolean Integer User ID is logged in, or false otherwise
6758 6785
  */
6759 6786
 function api_user_is_login($user_id = null) {
6760 6787
     $user_id = empty($user_id) ? api_get_user_id() : intval($user_id);
@@ -6789,6 +6816,7 @@  discard block
 block discarded – undo
6789 6816
  * Checks whether an IP is included inside an IP range
6790 6817
  * @param string IP address
6791 6818
  * @param string IP range
6819
+ * @param string $ip
6792 6820
  * @return bool True if IP is in the range, false otherwise
6793 6821
  * @author claudiu at cnixs dot com  on http://www.php.net/manual/fr/ref.network.php#55230
6794 6822
  * @author Yannick Warnier for improvements and managment of multiple ranges
@@ -7172,6 +7200,7 @@  discard block
 block discarded – undo
7172 7200
 /**
7173 7201
  * Tries to set memory limit, if authorized and new limit is higher than current
7174 7202
  * @param string New memory limit
7203
+ * @param string $mem
7175 7204
  * @return bool True on success, false on failure or current is higher than suggested
7176 7205
  * @assert (null) === false
7177 7206
  * @assert (-1) === false
@@ -7228,7 +7257,6 @@  discard block
 block discarded – undo
7228 7257
 
7229 7258
 /**
7230 7259
  * Finds all the information about a user from username instead of user id
7231
- * @param string $username
7232 7260
  *
7233 7261
  * @return array $user_info user_id, lastname, firstname, username, email, ...
7234 7262
  * @author Yannick Warnier <[email protected]>
@@ -7250,7 +7278,6 @@  discard block
 block discarded – undo
7250 7278
 
7251 7279
 /**
7252 7280
  *
7253
- * @param string $inputId the jquery id example: #password
7254 7281
  *
7255 7282
  * @return string
7256 7283
  */
@@ -7375,6 +7402,7 @@  discard block
 block discarded – undo
7375 7402
 /**
7376 7403
  * Remove tags from HTML anf return the $in_number_char first non-HTML char
7377 7404
  * Postfix the text with "..." if it has been truncated.
7405
+ * @param integer $in_number_char
7378 7406
  * @return string
7379 7407
  * @author hubert borderiou
7380 7408
  */
@@ -7419,7 +7447,7 @@  discard block
 block discarded – undo
7419 7447
 /**
7420 7448
  * @param string $tool
7421 7449
  * @param string $setting
7422
- * @param mixed $defaultValue
7450
+ * @param integer $defaultValue
7423 7451
  * @return string
7424 7452
  */
7425 7453
 function api_get_default_tool_setting($tool, $setting, $defaultValue)
@@ -7544,7 +7572,7 @@  discard block
 block discarded – undo
7544 7572
 }
7545 7573
 
7546 7574
 /**
7547
- * @return true if course_code for direct course access after login is set
7575
+ * @return boolean if course_code for direct course access after login is set
7548 7576
  */
7549 7577
 function exist_firstpage_parameter()
7550 7578
 {
@@ -7836,7 +7864,7 @@  discard block
 block discarded – undo
7836 7864
  * @param array     data file (path and filename)
7837 7865
  * @param array     data to attach a file (optional)
7838 7866
  * @param bool      True for attaching a embedded file inside content html (optional)
7839
- * @return          returns true if mail was sent
7867
+ * @return          integer true if mail was sent
7840 7868
  * @see             class.phpmailer.php
7841 7869
  */
7842 7870
 function api_mail_html(
Please login to merge, or discard this patch.
Indentation   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -610,7 +610,6 @@  discard block
 block discarded – undo
610 610
  * The other configuration parameters have not been changed.
611 611
  *
612 612
  * This is how we can get most used paths, for common purpose:
613
-
614 613
  * api_get_path(REL_PATH)                       /chamilo/
615 614
  * api_get_path(REL_COURSE_PATH)                /chamilo/courses/
616 615
  * api_get_path(REL_CODE_PATH)                  /chamilo/main/
@@ -1789,7 +1788,6 @@  discard block
 block discarded – undo
1789 1788
 
1790 1789
 /**
1791 1790
  * Returns the current course info array.
1792
-
1793 1791
  * Now if the course_code is given, the returned array gives info about that
1794 1792
  * particular course, not specially the current one.
1795 1793
  * @param int $id Numeric ID of the course
@@ -2723,7 +2721,7 @@  discard block
 block discarded – undo
2723 2721
         switch ($session_user_status) {
2724 2722
             case 0:
2725 2723
                 $session_status['status'] = 'student';
2726
-               break;
2724
+                break;
2727 2725
             case 2:
2728 2726
                 $session_status['status'] = 'coach';
2729 2727
             break;
@@ -6475,7 +6473,7 @@  discard block
 block discarded – undo
6475 6473
 function api_get_jquery_ui_js($include_jqgrid = false) {
6476 6474
     $libraries = array();
6477 6475
     if ($include_jqgrid) {
6478
-       $libraries[]='jqgrid';
6476
+        $libraries[]='jqgrid';
6479 6477
     }
6480 6478
     return api_get_jquery_libraries_js($libraries);
6481 6479
 }
@@ -6683,10 +6681,10 @@  discard block
 block discarded – undo
6683 6681
     }
6684 6682
 }
6685 6683
 /**
6686
- * Checks the PHP version installed is enough to run Chamilo
6687
- * @param string Include path (used to load the error page)
6688
- * @return void
6689
- */
6684
+     * Checks the PHP version installed is enough to run Chamilo
6685
+     * @param string Include path (used to load the error page)
6686
+     * @return void
6687
+     */
6690 6688
 function api_check_php_version($my_inc_path = null) {
6691 6689
     if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6692 6690
         $global_error_code = 1;
@@ -6699,9 +6697,9 @@  discard block
 block discarded – undo
6699 6697
     }
6700 6698
 }
6701 6699
 /**
6702
- * Checks whether the Archive directory is present and writeable. If not,
6703
- * prints a warning message.
6704
- */
6700
+     * Checks whether the Archive directory is present and writeable. If not,
6701
+     * prints a warning message.
6702
+     */
6705 6703
 function api_check_archive_dir() {
6706 6704
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6707 6705
         $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
@@ -6709,10 +6707,10 @@  discard block
 block discarded – undo
6709 6707
     }
6710 6708
 }
6711 6709
 /**
6712
- * Returns an array of global configuration settings which should be ignored
6713
- * when printing the configuration settings screens
6714
- * @return array Array of strings, each identifying one of the excluded settings
6715
- */
6710
+     * Returns an array of global configuration settings which should be ignored
6711
+     * when printing the configuration settings screens
6712
+     * @return array Array of strings, each identifying one of the excluded settings
6713
+     */
6716 6714
 function api_get_locked_settings() {
6717 6715
     return array(
6718 6716
         'server_type',
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1819,7 +1819,9 @@  discard block
 block discarded – undo
1819 1819
     }
1820 1820
 
1821 1821
     global $_course;
1822
-    if ($_course == '-1') $_course = array();
1822
+    if ($_course == '-1') {
1823
+        $_course = array();
1824
+    }
1823 1825
     return $_course;
1824 1826
 }
1825 1827
 
@@ -4315,17 +4317,20 @@  discard block
 block discarded – undo
4315 4317
     switch ($lang_type) {
4316 4318
         case 'platform_lang':
4317 4319
             $temp_lang = api_get_setting('platformLanguage');
4318
-            if (!empty($temp_lang))
4319
-                $return = $temp_lang;
4320
+            if (!empty($temp_lang)) {
4321
+                            $return = $temp_lang;
4322
+            }
4320 4323
             break;
4321 4324
         case 'user_profil_lang':
4322 4325
             $_user = api_get_user_info();
4323
-            if (isset($_user['language']) && !empty($_user['language']))
4324
-                $return = $_user['language'];
4326
+            if (isset($_user['language']) && !empty($_user['language'])) {
4327
+                            $return = $_user['language'];
4328
+            }
4325 4329
             break;
4326 4330
         case 'user_selected_lang':
4327
-            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
4328
-                $return = $_SESSION['user_language_choice'];
4331
+            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
4332
+                            $return = $_SESSION['user_language_choice'];
4333
+            }
4329 4334
             break;
4330 4335
         case 'course_lang':
4331 4336
             global $_course;
@@ -4343,8 +4348,9 @@  discard block
 block discarded – undo
4343 4348
                 }
4344 4349
             }
4345 4350
             $_course = api_get_course_info($cidReq);
4346
-            if (isset($_course['language']) && !empty($_course['language']))
4347
-                $return = $_course['language'];
4351
+            if (isset($_course['language']) && !empty($_course['language'])) {
4352
+                            $return = $_course['language'];
4353
+            }
4348 4354
             break;
4349 4355
         default:
4350 4356
             $return = false;
@@ -5604,8 +5610,7 @@  discard block
 block discarded – undo
5604 5610
             $is_courseAdmin = false;
5605 5611
             $is_courseCoach = true;
5606 5612
             $is_sessionAdmin = false;
5607
-        }
5608
-        elseif ($row[0]['session_admin_id'] == $userid) {
5613
+        } elseif ($row[0]['session_admin_id'] == $userid) {
5609 5614
             $is_courseMember = false;
5610 5615
             $is_courseTutor = false;
5611 5616
             $is_courseAdmin = false;
@@ -5885,7 +5890,9 @@  discard block
 block discarded – undo
5885 5890
 
5886 5891
     if (!empty($course_code)) {
5887 5892
         if (isset($_SESSION['_course']['sysCode'])) {
5888
-            if ($course_code != $_SESSION['_course']['sysCode']) return false;
5893
+            if ($course_code != $_SESSION['_course']['sysCode']) {
5894
+                return false;
5895
+            }
5889 5896
         } else {
5890 5897
             return false;
5891 5898
         }
@@ -5942,8 +5949,7 @@  discard block
 block discarded – undo
5942 5949
     elseif (isset($_ENV['OS'])) {
5943 5950
         // Sometimes $_ENV['OS'] may not be present (bugs?)
5944 5951
         $os = $_ENV['OS'];
5945
-    }
5946
-    elseif (defined('PHP_OS')) {
5952
+    } elseif (defined('PHP_OS')) {
5947 5953
         // PHP_OS means on which OS PHP was compiled, this is why
5948 5954
         // using PHP_OS is the last choice for detection.
5949 5955
         $os = PHP_OS;
@@ -6007,12 +6013,10 @@  discard block
 block discarded – undo
6007 6013
     if ($delta_width > $delta_height) {
6008 6014
         $result['width'] = ceil($image_width * $resize_factor_height);
6009 6015
         $result['height'] = ceil($image_height * $resize_factor_height);
6010
-    }
6011
-    elseif ($delta_width < $delta_height) {
6016
+    } elseif ($delta_width < $delta_height) {
6012 6017
         $result['width'] = ceil($image_width * $resize_factor_width);
6013 6018
         $result['height'] = ceil($image_height * $resize_factor_width);
6014
-    }
6015
-    else {
6019
+    } else {
6016 6020
         $result['width'] = ceil($target_width);
6017 6021
         $result['height'] = ceil($target_height);
6018 6022
     }
@@ -6781,7 +6785,9 @@  discard block
 block discarded – undo
6781 6785
         }
6782 6786
         $ip = trim($ip1);
6783 6787
     }
6784
-    if (!empty($debug)) error_log('Real IP: '.$ip);
6788
+    if (!empty($debug)) {
6789
+        error_log('Real IP: '.$ip);
6790
+    }
6785 6791
     return $ip;
6786 6792
 }
6787 6793
 
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 define('PLATFORM_ADMIN', 11);
40 40
 define('SESSION_COURSE_COACH', 12);
41 41
 define('SESSION_GENERAL_COACH', 13);
42
-define('COURSE_STUDENT', 14);   //student subscribed in a course
43
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
42
+define('COURSE_STUDENT', 14); //student subscribed in a course
43
+define('SESSION_STUDENT', 15); //student subscribed in a session course
44 44
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
45 45
 define('STUDENT_BOSS', 17); // student is boss
46 46
 define('INVITEE', 20);
47 47
 
48 48
 // Table of status
49
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
50
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
51
-$_status_list[DRH] = 'drh';            // 4
52
-$_status_list[STUDENT] = 'user';           // 5
53
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
54
-$_status_list[INVITEE] = 'invited';        // 20
49
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
50
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
51
+$_status_list[DRH] = 'drh'; // 4
52
+$_status_list[STUDENT] = 'user'; // 5
53
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
54
+$_status_list[INVITEE] = 'invited'; // 20
55 55
 
56 56
 // COURSE VISIBILITY CONSTANTS
57 57
 /** only visible for course admin */
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 define('IS_WINDOWS_OS', api_is_windows_os());
265 265
 
266 266
 // Checks for installed optional php-extensions.
267
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
268
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
269
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
267
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
268
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
269
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
270 270
 
271 271
 // Patterns for processing paths.                                   // Examples:
272
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
273
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
274
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
272
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
273
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
274
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
275 275
 
276 276
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
277 277
 define('WEB_PATH', 'WEB_PATH');
@@ -375,19 +375,19 @@  discard block
 block discarded – undo
375 375
 define('LINK_HOTPOTATOES', 9);
376 376
 
377 377
 // Score display types constants
378
-define('SCORE_DIV', 1);    // X / Y
379
-define('SCORE_PERCENT', 2);    // XX %
380
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
381
-define('SCORE_AVERAGE', 4);    // XX %
382
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
383
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
384
-define('SCORE_SIMPLE', 7);    // X
385
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
386
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
387
-define('SCORE_CUSTOM', 10);    // Good!
388
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
389
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
390
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
378
+define('SCORE_DIV', 1); // X / Y
379
+define('SCORE_PERCENT', 2); // XX %
380
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
381
+define('SCORE_AVERAGE', 4); // XX %
382
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
383
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
384
+define('SCORE_SIMPLE', 7); // X
385
+define('SCORE_IGNORE_SPLIT', 8); //  ??
386
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
387
+define('SCORE_CUSTOM', 10); // Good!
388
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
389
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
390
+define('SCORE_ONLY_SCORE', 13); // X - Good!
391 391
 
392 392
 define('SCORE_BOTH', 1);
393 393
 define('SCORE_ONLY_DEFAULT', 2);
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 define('TIMELINE_STATUS_INACTIVE', '2');
556 556
 
557 557
 // Event email template class
558
-define ('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
559
-define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
558
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
559
+define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
560 560
 
561 561
 // Course home
562 562
 define('SHORTCUTS_HORIZONTAL', 0);
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
     // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
734 734
     if ($path_type == WEB_PATH) {
735
-        if (isset($_configuration['access_url']) &&  $_configuration['access_url'] != 1) {
735
+        if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
736 736
             //we look into the DB the function api_get_access_url
737 737
             $url_info = api_get_access_url($_configuration['access_url']);
738 738
             $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
                     : 'localhost')));
763 763
                 if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':')
764 764
                     && (($server_protocol == 'http'
765
-                    && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) {
766
-                    $server_name .= ":" . $_SERVER['SERVER_PORT'];
765
+                    && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) {
766
+                    $server_name .= ":".$_SERVER['SERVER_PORT'];
767 767
                 }
768 768
                 $root_web = $server_protocol.'://'.$server_name.$root_rel;
769 769
                 $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
                 $sys_course_code =
938 938
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
939 939
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
940
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
940
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
941 941
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
942 942
             }
943 943
         }
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
 {
982 982
     global $_configuration;
983 983
     $web_root = api_get_path(WEB_PATH);
984
-    $ext = substr($web_path,strrpos($web_path,'.'));
984
+    $ext = substr($web_path, strrpos($web_path, '.'));
985 985
     if (isset($ext[2])) { // faster version of strlen to check if len>2
986 986
         // Check for CDN definitions
987 987
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
988 988
             foreach ($_configuration['cdn'] as $host => $exts) {
989
-                if (in_array($ext,$exts)) {
989
+                if (in_array($ext, $exts)) {
990 990
                     //Use host as defined in $_configuration['cdn'], without
991 991
                     // trailing slash
992
-                    return str_replace($web_root,$host.'/',$web_path);
992
+                    return str_replace($web_root, $host.'/', $web_path);
993 993
                 }
994 994
             }
995 995
         }
@@ -1438,10 +1438,10 @@  discard block
 block discarded – undo
1438 1438
 
1439 1439
     if (isset($user['email'])) {
1440 1440
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1441
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1441
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1442 1442
     } else {
1443 1443
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1444
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1444
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1445 1445
     }
1446 1446
     $user_id = intval($user['user_id']);
1447 1447
     // Maintain the user_id index for backwards compatibility
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
         foreach ($param_list1 as $key => $enreg) {
1919 1919
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1920 1920
         }
1921
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1921
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1922 1922
         foreach ($param_list2 as $enreg) {
1923 1923
             $enreg = explode('=', $enreg);
1924 1924
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
         $length = 2;
1949 1949
     }
1950 1950
     $password = '';
1951
-    for ($i = 0; $i < $length; $i ++) {
1951
+    for ($i = 0; $i < $length; $i++) {
1952 1952
         $password .= $characters[rand() % strlen($characters)];
1953 1953
     }
1954 1954
     return $password;
@@ -1975,10 +1975,10 @@  discard block
 block discarded – undo
1975 1975
     $digits = 0;
1976 1976
     $consequent_characters = 0;
1977 1977
     $previous_character_code = 0;
1978
-    for ($i = 0; $i < $password_length; $i ++) {
1978
+    for ($i = 0; $i < $password_length; $i++) {
1979 1979
         $current_character_code = api_ord(api_substr($password, $i, 1));
1980 1980
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
1981
-            $consequent_characters ++;
1981
+            $consequent_characters++;
1982 1982
             if ($consequent_characters == 3) {
1983 1983
                 return false;
1984 1984
             }
@@ -1986,9 +1986,9 @@  discard block
 block discarded – undo
1986 1986
             $consequent_characters = 1;
1987 1987
         }
1988 1988
         if ($current_character_code >= 97 && $current_character_code <= 122) {
1989
-            $letters ++;
1989
+            $letters++;
1990 1990
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
1991
-            $digits ++;
1991
+            $digits++;
1992 1992
         } else {
1993 1993
             return false;
1994 1994
         }
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
         if (empty($session_id)) { return null; }
2185 2185
     }
2186 2186
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2187
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2187
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2188 2188
     $r = Database::query($s);
2189 2189
     $c = Database::num_rows($r);
2190 2190
     if ($c > 0) {
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
         $sql = "SELECT * FROM $tbl_session WHERE id = $session_id";
2210 2210
         $result = Database::query($sql);
2211 2211
 
2212
-        if (Database::num_rows($result)>0) {
2212
+        if (Database::num_rows($result) > 0) {
2213 2213
             $data = Database::fetch_array($result, 'ASSOC');
2214 2214
         }
2215 2215
     }
@@ -2369,9 +2369,9 @@  discard block
 block discarded – undo
2369 2369
  */
2370 2370
 function api_get_session_image($session_id, $status_id)
2371 2371
 {
2372
-    $session_id = (int)$session_id;
2372
+    $session_id = (int) $session_id;
2373 2373
     $session_img = '';
2374
-    if ((int)$status_id != 5) { //check whether is not a student
2374
+    if ((int) $status_id != 5) { //check whether is not a student
2375 2375
         if ($session_id > 0) {
2376 2376
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2377 2377
                 'star.png',
@@ -2486,7 +2486,7 @@  discard block
 block discarded – undo
2486 2486
         $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
2487 2487
         if (file_exists($filename)) {
2488 2488
             $value = file_get_contents($filename);
2489
-            return $value ;
2489
+            return $value;
2490 2490
         } else {
2491 2491
             return '';
2492 2492
         }
@@ -2495,7 +2495,7 @@  discard block
 block discarded – undo
2495 2495
         $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
2496 2496
         if (file_exists($filename)) {
2497 2497
             $value = file_get_contents($filename);
2498
-            return $value ;
2498
+            return $value;
2499 2499
         } else {
2500 2500
             return '';
2501 2501
         }
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
     }
2690 2690
     $group_id   = api_get_group_id();
2691 2691
     $course_id  = api_get_course_int_id();
2692
-    $course_code= api_get_course_id();
2692
+    $course_code = api_get_course_id();
2693 2693
     $session_id = api_get_session_id();
2694 2694
 
2695 2695
     //Group (in course)
@@ -2697,7 +2697,7 @@  discard block
 block discarded – undo
2697 2697
         $group_status = array();
2698 2698
         $is_subscribed = GroupManager::is_subscribed($user_id, $group_id);
2699 2699
         if ($is_subscribed) {
2700
-            $group_status = array('id'=> $group_id , 'status' => 'student');
2700
+            $group_status = array('id'=> $group_id, 'status' => 'student');
2701 2701
             $is_tutor = GroupManager::is_tutor_of_group($user_id, $group_id);
2702 2702
             if ($is_tutor) {
2703 2703
                 $group_status['status'] = 'tutor';
@@ -2731,7 +2731,7 @@  discard block
 block discarded – undo
2731 2731
         }
2732 2732
         $status['session'] = $session_status;
2733 2733
 
2734
-    } elseif($course_id) {
2734
+    } elseif ($course_id) {
2735 2735
         //Course
2736 2736
         $course_status = array();
2737 2737
         if ($course_id) {
@@ -2739,7 +2739,7 @@  discard block
 block discarded – undo
2739 2739
 
2740 2740
             if ($user_course_status) {
2741 2741
                 $course_status = array('id'=> $course_id);
2742
-                switch($user_course_status) {
2742
+                switch ($user_course_status) {
2743 2743
                     case 1;
2744 2744
                         $course_status['status'] = 'teacher';
2745 2745
                     break;
@@ -2769,7 +2769,7 @@  discard block
 block discarded – undo
2769 2769
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2770 2770
 {
2771 2771
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2772
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2772
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2773 2773
 
2774 2774
     $user_id = intval($user_id);
2775 2775
     $session_id = intval($session_id);
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
                 ORDER BY access_start_date, access_end_date, name";
2844 2844
         $result = Database::query($sql);
2845 2845
         if (!empty($sessionIsCoach)) {
2846
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2846
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2847 2847
         } else {
2848 2848
             $sessionIsCoach = Database::store_result($result);
2849 2849
         }
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
             return '';
3021 3021
         }
3022 3022
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
3023
-        $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
3023
+        $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
3024 3024
         //showinframes doesn't handle student view anyway...
3025 3025
         //return '';
3026 3026
         $is_framed = true;
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
         }
3420 3420
         $content .= '<div class="well_login">';
3421 3421
         $content .= $form->return_form();
3422
-        $content .='</div>';
3422
+        $content .= '</div>';
3423 3423
         if (api_is_cas_activated()) {
3424 3424
             $content .= "</div>";
3425 3425
         }
@@ -3438,7 +3438,7 @@  discard block
 block discarded – undo
3438 3438
         exit;
3439 3439
     }
3440 3440
 
3441
-    if ($user_id !=0 && !api_is_anonymous()) {
3441
+    if ($user_id != 0 && !api_is_anonymous()) {
3442 3442
         $tpl->display_one_col_template();
3443 3443
         exit;
3444 3444
     }
@@ -3469,7 +3469,7 @@  discard block
 block discarded – undo
3469 3469
         }
3470 3470
         $msg .= '<div class="well">';
3471 3471
         $msg .= $form->return_form();
3472
-        $msg .='</div>';
3472
+        $msg .= '</div>';
3473 3473
         if (api_is_cas_activated()) {
3474 3474
             $msg .= "</div>";
3475 3475
         }
@@ -3505,7 +3505,7 @@  discard block
 block discarded – undo
3505 3505
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3506 3506
     list ($year, $month, $day) = explode('-', $last_post_date);
3507 3507
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3508
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3508
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3509 3509
 }
3510 3510
 
3511 3511
 /**
@@ -3956,7 +3956,7 @@  discard block
 block discarded – undo
3956 3956
                 c_id = $course_id AND
3957 3957
                 tool = '$tool'
3958 3958
                 $session_condition ";
3959
-    $rs  = Database::query($sql);
3959
+    $rs = Database::query($sql);
3960 3960
     $list = array();
3961 3961
     if (Database::num_rows($rs) > 0) {
3962 3962
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -4036,7 +4036,7 @@  discard block
 block discarded – undo
4036 4036
                 tool = '$tool' AND
4037 4037
                 ref = $ref
4038 4038
                 $sessionCondition";
4039
-    $rs  = Database::query($sql);
4039
+    $rs = Database::query($sql);
4040 4040
     $item_property_id = '';
4041 4041
     if (Database::num_rows($rs) > 0) {
4042 4042
         $row = Database::fetch_array($rs);
@@ -4094,7 +4094,7 @@  discard block
 block discarded – undo
4094 4094
             WHERE item_property_id = $item_property_id AND course_id = $course_id
4095 4095
             ORDER BY lastedit_date DESC";
4096 4096
     $result = Database::query($sql);
4097
-    $result = Database::store_result($result,'ASSOC');
4097
+    $result = Database::store_result($result, 'ASSOC');
4098 4098
     return $result;
4099 4099
 }
4100 4100
 
@@ -4137,7 +4137,7 @@  discard block
 block discarded – undo
4137 4137
     $rs  = Database::query($sql);
4138 4138
     $row = array();
4139 4139
     if (Database::num_rows($rs) > 0) {
4140
-        $row = Database::fetch_array($rs,'ASSOC');
4140
+        $row = Database::fetch_array($rs, 'ASSOC');
4141 4141
     }
4142 4142
 
4143 4143
     return $row;
@@ -4172,7 +4172,7 @@  discard block
 block discarded – undo
4172 4172
     $languages  = $language_list['name'];
4173 4173
     $folder     = $language_list['folder'];
4174 4174
 
4175
-    $ret .= '<select name="' . $name . '" id="language_chosen">';
4175
+    $ret .= '<select name="'.$name.'" id="language_chosen">';
4176 4176
     foreach ($languages as $key => $value) {
4177 4177
         if ($folder[$key] == $default) {
4178 4178
             $selected = ' selected="selected"';
@@ -4225,8 +4225,8 @@  discard block
 block discarded – undo
4225 4225
     //-->
4226 4226
     </script>';
4227 4227
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4228
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4229
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4228
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4229
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4230 4230
 
4231 4231
     foreach ($original_languages as $key => $value) {
4232 4232
         if ($folder[$key] == $user_selected_language) {
@@ -4234,13 +4234,13 @@  discard block
 block discarded – undo
4234 4234
         } else {
4235 4235
             $option_end = '>';
4236 4236
         }
4237
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4237
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4238 4238
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4239
-        $html .=  $value.'</option>';
4239
+        $html .= $value.'</option>';
4240 4240
     }
4241
-    $html .=  '</select>';
4242
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4243
-    $html .=  '</form>';
4241
+    $html .= '</select>';
4242
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4243
+    $html .= '</form>';
4244 4244
     return $html;
4245 4245
 }
4246 4246
 
@@ -4357,7 +4357,7 @@  discard block
 block discarded – undo
4357 4357
     $rs = Database::query($sql);
4358 4358
     $language_info = array();
4359 4359
     if (Database::num_rows($rs)) {
4360
-        $language_info = Database::fetch_array($rs,'ASSOC');
4360
+        $language_info = Database::fetch_array($rs, 'ASSOC');
4361 4361
     }
4362 4362
     return $language_info;
4363 4363
 }
@@ -4435,7 +4435,7 @@  discard block
 block discarded – undo
4435 4435
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4436 4436
  */
4437 4437
 function api_get_themes() {
4438
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4438
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4439 4439
     $list_dir = array();
4440 4440
     $list_name = array();
4441 4441
 
@@ -4626,7 +4626,7 @@  discard block
 block discarded – undo
4626 4626
     if (is_file($dirname) || is_link($dirname)) {
4627 4627
         $res = unlink($dirname);
4628 4628
         if ($res === false) {
4629
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4629
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4630 4630
         }
4631 4631
         return $res;
4632 4632
     }
@@ -4663,7 +4663,7 @@  discard block
 block discarded – undo
4663 4663
     if ($delete_only_content_in_folder == false) {
4664 4664
         $res = rmdir($dirname);
4665 4665
         if ($res === false) {
4666
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4666
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4667 4667
         }
4668 4668
     }
4669 4669
     return $res;
@@ -4741,7 +4741,7 @@  discard block
 block discarded – undo
4741 4741
 
4742 4742
     $course_id = $course_info['real_id'];
4743 4743
 
4744
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4744
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4745 4745
 
4746 4746
     $new_pathname = $base_path_document;
4747 4747
     $path = '';
@@ -4759,7 +4759,7 @@  discard block
 block discarded – undo
4759 4759
                         path = '$path' AND
4760 4760
                         filetype = 'folder' AND
4761 4761
                         session_id = '$session_id'";
4762
-            $rs1  = Database::query($sql);
4762
+            $rs1 = Database::query($sql);
4763 4763
             $num_rows = Database::num_rows($rs1);
4764 4764
 
4765 4765
             if ($num_rows == 0) {
@@ -4916,7 +4916,7 @@  discard block
 block discarded – undo
4916 4916
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4917 4917
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4918 4918
             }
4919
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4919
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4920 4920
 
4921 4921
             // Parse array syntax.
4922 4922
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4956,7 +4956,7 @@  discard block
 block discarded – undo
4956 4956
  */
4957 4957
 function api_get_version() {
4958 4958
     global $_configuration;
4959
-    return (string)$_configuration['system_version'];
4959
+    return (string) $_configuration['system_version'];
4960 4960
 }
4961 4961
 
4962 4962
 /**
@@ -5082,7 +5082,7 @@  discard block
 block discarded – undo
5082 5082
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5083 5083
     $var = Database::escape_string($var);
5084 5084
     $value = Database::escape_string($value);
5085
-    $access_url = (int)$access_url;
5085
+    $access_url = (int) $access_url;
5086 5086
     if (empty($access_url)) { $access_url = 1; }
5087 5087
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
5088 5088
     if (!empty($subvar)) {
@@ -5104,7 +5104,7 @@  discard block
 block discarded – undo
5104 5104
         // Found item for this access_url.
5105 5105
         $row = Database::fetch_array($res);
5106 5106
         $sql = "UPDATE $t_settings SET selected_value = '$value'
5107
-                WHERE id = ".$row['id'] ;
5107
+                WHERE id = ".$row['id'];
5108 5108
         Database::query($sql);
5109 5109
     } else {
5110 5110
         // Item not found for this access_url, we have to check if it exist with access_url = 1
@@ -5125,11 +5125,11 @@  discard block
 block discarded – undo
5125 5125
                 $row = Database::fetch_array($res);
5126 5126
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5127 5127
                         VALUES
5128
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5129
-                        "'".$row['type']."','".$row['category']."'," .
5130
-                        "'$value','".$row['title']."'," .
5131
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5132
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5128
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5129
+                        "'".$row['type']."','".$row['category']."',".
5130
+                        "'$value','".$row['title']."',".
5131
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5132
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5133 5133
                 Database::query($insert);
5134 5134
             } else { // Such a setting does not exist.
5135 5135
                 error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
@@ -5149,16 +5149,16 @@  discard block
 block discarded – undo
5149 5149
                 if ($row['access_url_changeable'] == 1) {
5150 5150
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5151 5151
                             ('".$row['variable']."',".
5152
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5153
-                            "'".$row['type']."','".$row['category']."'," .
5154
-                            "'$value','".$row['title']."'," .
5152
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5153
+                            "'".$row['type']."','".$row['category']."',".
5154
+                            "'$value','".$row['title']."',".
5155 5155
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5156
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5156
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5157 5157
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5158 5158
                     Database::query($insert);
5159 5159
                 }
5160 5160
             } else { // Such a setting does not exist.
5161
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
5161
+                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ', 0);
5162 5162
             }
5163 5163
         }
5164 5164
     }
@@ -5184,10 +5184,10 @@  discard block
 block discarded – undo
5184 5184
         $value = Database::escape_string($value);
5185 5185
         $sql = "UPDATE $t_s SET selected_value = '$value'
5186 5186
                 WHERE category = '$category' AND access_url = $access_url";
5187
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5187
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5188 5188
             $sql .= " AND ( ";
5189 5189
             $i = 0;
5190
-            foreach ($fieldtype as $type){
5190
+            foreach ($fieldtype as $type) {
5191 5191
                 if ($i > 0) {
5192 5192
                     $sql .= ' OR ';
5193 5193
                 }
@@ -5202,10 +5202,10 @@  discard block
 block discarded – undo
5202 5202
     } else {
5203 5203
         $sql = "UPDATE $t_s SET selected_value = NULL
5204 5204
                 WHERE category = '$category' AND access_url = $access_url";
5205
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5205
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5206 5206
             $sql .= " AND ( ";
5207 5207
             $i = 0;
5208
-            foreach ($fieldtype as $type){
5208
+            foreach ($fieldtype as $type) {
5209 5209
                 if ($i > 0) {
5210 5210
                     $sql .= ' OR ';
5211 5211
                 }
@@ -5350,7 +5350,7 @@  discard block
 block discarded – undo
5350 5350
 function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
5351 5351
     $access_url = (int) $access_url;
5352 5352
     $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5353
-    $list = "'".implode("','",$exceptions)."'";
5353
+    $list = "'".implode("','", $exceptions)."'";
5354 5354
     $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL ";
5355 5355
     if ($list != "'',''" && $list != "''" && !empty($list)) {
5356 5356
         $sql .= " AND category NOT IN ($list) ";
@@ -5446,12 +5446,12 @@  discard block
 block discarded – undo
5446 5446
 
5447 5447
     // Item not found for this access_url, we have to check if the whole thing is missing
5448 5448
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5449
-    $insert = "INSERT INTO $t_settings " .
5450
-                "(variable,selected_value," .
5451
-                "type,category," .
5452
-                "subkey,title," .
5453
-                "comment,scope," .
5454
-                "subkeytext,access_url,access_url_changeable)" .
5449
+    $insert = "INSERT INTO $t_settings ".
5450
+                "(variable,selected_value,".
5451
+                "type,category,".
5452
+                "subkey,title,".
5453
+                "comment,scope,".
5454
+                "subkeytext,access_url,access_url_changeable)".
5455 5455
                 " VALUES ('$var','$val',";
5456 5456
     if (isset($type)) {
5457 5457
         $type = Database::escape_string($type);
@@ -5617,7 +5617,7 @@  discard block
 block discarded – undo
5617 5617
             $result = Database::query($sql);
5618 5618
 
5619 5619
             //if ($row = Database::fetch_array($result)) {
5620
-            if (Database::num_rows($result) > 0 ) {
5620
+            if (Database::num_rows($result) > 0) {
5621 5621
                 $is_courseMember = true;
5622 5622
                 $is_courseTutor = true;
5623 5623
                 $is_courseCoach = true;
@@ -5838,8 +5838,8 @@  discard block
 block discarded – undo
5838 5838
 {
5839 5839
     $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
5840 5840
     if (!empty($user_id) && !empty($courseId)) {
5841
-        $user_id        = intval($user_id);
5842
-        $courseId    = intval($courseId);
5841
+        $user_id = intval($user_id);
5842
+        $courseId = intval($courseId);
5843 5843
         $sql = 'SELECT status
5844 5844
                 FROM '.$tbl_rel_course_user.'
5845 5845
                 WHERE user_id='.$user_id.' AND c_id = '.$courseId;
@@ -5945,7 +5945,7 @@  discard block
 block discarded – undo
5945 5945
     } else {
5946 5946
         return false;
5947 5947
     }
5948
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5948
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5949 5949
 }
5950 5950
 
5951 5951
 /**
@@ -6470,7 +6470,7 @@  discard block
 block discarded – undo
6470 6470
 function api_get_jquery_ui_js($include_jqgrid = false) {
6471 6471
     $libraries = array();
6472 6472
     if ($include_jqgrid) {
6473
-       $libraries[]='jqgrid';
6473
+       $libraries[] = 'jqgrid';
6474 6474
     }
6475 6475
     return api_get_jquery_libraries_js($libraries);
6476 6476
 }
@@ -6494,12 +6494,12 @@  discard block
 block discarded – undo
6494 6494
 
6495 6495
     //jqgrid js and css
6496 6496
     if (in_array('jqgrid', $libraries)) {
6497
-        $languaje   = 'en';
6497
+        $languaje = 'en';
6498 6498
         $platform_isocode = strtolower(api_get_language_isocode());
6499 6499
 
6500 6500
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6501 6501
         $jqgrid_langs = array(
6502
-            'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua'
6502
+            'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua'
6503 6503
         );
6504 6504
 
6505 6505
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6530,7 +6530,7 @@  discard block
 block discarded – undo
6530 6530
 
6531 6531
     // jquery datepicker
6532 6532
     if (in_array('datepicker', $libraries)) {
6533
-        $languaje   = 'en-GB';
6533
+        $languaje = 'en-GB';
6534 6534
         $platform_isocode = strtolower(api_get_language_isocode());
6535 6535
 
6536 6536
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6632,7 +6632,7 @@  discard block
 block discarded – undo
6632 6632
         $clean_url = str_replace('/', '-', $clean_url);
6633 6633
         $clean_url .= '/';
6634 6634
 
6635
-        $home = 'app/home/' . $clean_url;
6635
+        $home = 'app/home/'.$clean_url;
6636 6636
 
6637 6637
     }
6638 6638
 
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
  * @return void
6694 6694
  */
6695 6695
 function api_check_php_version($my_inc_path = null) {
6696
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6696
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6697 6697
         $global_error_code = 1;
6698 6698
         // Incorrect PHP version
6699 6699
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6709,7 +6709,7 @@  discard block
 block discarded – undo
6709 6709
  */
6710 6710
 function api_check_archive_dir() {
6711 6711
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6712
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6712
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6713 6713
         api_not_allowed(true, $message);
6714 6714
     }
6715 6715
 }
@@ -6774,7 +6774,7 @@  discard block
 block discarded – undo
6774 6774
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6775 6775
  * @version CEV CHANGE 24APR2012
6776 6776
  */
6777
-function api_get_real_ip(){
6777
+function api_get_real_ip() {
6778 6778
     // Guess the IP if behind a reverse proxy
6779 6779
     global $debug;
6780 6780
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6799,23 +6799,23 @@  discard block
 block discarded – undo
6799 6799
  * @author Yannick Warnier for improvements and managment of multiple ranges
6800 6800
  * @todo check for IPv6 support
6801 6801
  */
6802
-function api_check_ip_in_range($ip,$range)
6802
+function api_check_ip_in_range($ip, $range)
6803 6803
 {
6804 6804
     if (empty($ip) or empty($range)) {
6805 6805
         return false;
6806 6806
     }
6807
-    $ip_ip = ip2long ($ip);
6807
+    $ip_ip = ip2long($ip);
6808 6808
     // divide range param into array of elements
6809
-    if (strpos($range,',')!==false) {
6810
-        $ranges = explode(',',$range);
6809
+    if (strpos($range, ',') !== false) {
6810
+        $ranges = explode(',', $range);
6811 6811
     } else {
6812 6812
         $ranges = array($range);
6813 6813
     }
6814 6814
     foreach ($ranges as $range) {
6815 6815
         $range = trim($range);
6816 6816
         if (empty($range)) { continue; }
6817
-        if (strpos($range,'/')===false) {
6818
-            if (strcmp($ip,$range)===0) {
6817
+        if (strpos($range, '/') === false) {
6818
+            if (strcmp($ip, $range) === 0) {
6819 6819
                 return true; // there is a direct IP match, return OK
6820 6820
             }
6821 6821
             continue; //otherwise, get to the next range
@@ -6823,7 +6823,7 @@  discard block
 block discarded – undo
6823 6823
         // the range contains a "/", so analyse completely
6824 6824
         list ($net, $mask) = explode("/", $range);
6825 6825
 
6826
-        $ip_net = ip2long ($net);
6826
+        $ip_net = ip2long($net);
6827 6827
         // mask binary magic
6828 6828
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6829 6829
 
@@ -7183,14 +7183,14 @@  discard block
 block discarded – undo
7183 7183
  * @assert (0) === true
7184 7184
  * @assert ('1G') === true
7185 7185
  */
7186
-function api_set_memory_limit($mem){
7186
+function api_set_memory_limit($mem) {
7187 7187
     //if ini_set() not available, this function is useless
7188 7188
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7189 7189
         return false;
7190 7190
     }
7191 7191
 
7192 7192
     $memory_limit = ini_get('memory_limit');
7193
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7193
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7194 7194
         ini_set('memory_limit', $mem);
7195 7195
         return true;
7196 7196
     }
@@ -7207,21 +7207,21 @@  discard block
 block discarded – undo
7207 7207
  * @assert ('1m')  === 1048576
7208 7208
  * @assert ('100k') === 102400
7209 7209
  */
7210
-function api_get_bytes_memory_limit($mem){
7211
-    $size = strtolower(substr($mem,-1));
7210
+function api_get_bytes_memory_limit($mem) {
7211
+    $size = strtolower(substr($mem, -1));
7212 7212
 
7213 7213
     switch ($size) {
7214 7214
         case 't':
7215
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7215
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7216 7216
             break;
7217 7217
         case 'g':
7218
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7218
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7219 7219
             break;
7220 7220
         case 'm':
7221
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7221
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7222 7222
             break;
7223 7223
         case 'k':
7224
-            $mem = intval(substr($mem,0,-1))*1024;
7224
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7225 7225
             break;
7226 7226
         default:
7227 7227
             // we assume it's integer only
@@ -7276,7 +7276,7 @@  discard block
 block discarded – undo
7276 7276
         get_lang('PasswordVeryStrong'),
7277 7277
     );
7278 7278
     $js = api_get_js('strength/strength.js');
7279
-    $js .=  "<script>
7279
+    $js .= "<script>
7280 7280
 
7281 7281
     var verdicts = ['".implode("','", $verdicts)."'];
7282 7282
     var errorMessages = {
@@ -7332,7 +7332,7 @@  discard block
 block discarded – undo
7332 7332
         return false;
7333 7333
     }
7334 7334
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7335
-    $time = time() + $minutesToBlock*60;
7335
+    $time = time() + $minutesToBlock * 60;
7336 7336
     UserManager::update_extra_field_value(
7337 7337
         $userInfo['user_id'],
7338 7338
         'captcha_blocked_until_date',
@@ -7405,7 +7405,7 @@  discard block
 block discarded – undo
7405 7405
         $out_res = str_replace('"', "''", $out_res);
7406 7406
     }
7407 7407
     // avoid text stuck together when tags are removed, adding a space after >
7408
-    $out_res = str_replace (">", "> ", $out_res);
7408
+    $out_res = str_replace(">", "> ", $out_res);
7409 7409
     $out_res = strip_tags($out_res);
7410 7410
 
7411 7411
     return $out_res;
@@ -7515,12 +7515,12 @@  discard block
 block discarded – undo
7515 7515
 {
7516 7516
     // Clean query
7517 7517
     $bt = debug_backtrace();
7518
-    $caller = array_shift($bt);;
7518
+    $caller = array_shift($bt); ;
7519 7519
     if ($dump == 1) {
7520 7520
         $string = print_r($string, 1);
7521 7521
     } else {
7522 7522
         $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string);
7523
-        $string = str_replace('    ',' ', $string);
7523
+        $string = str_replace('    ', ' ', $string);
7524 7524
     }
7525 7525
 
7526 7526
     error_log("-------------------------------------");
@@ -7630,7 +7630,7 @@  discard block
 block discarded – undo
7630 7630
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7631 7631
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7632 7632
         if (isset($hostingParams[$limitName])) {
7633
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7633
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7634 7634
         }
7635 7635
         api_mail_html(null, $email, $subject, $body);
7636 7636
     }
@@ -7758,7 +7758,7 @@  discard block
 block discarded – undo
7758 7758
  */
7759 7759
 function api_set_site_use_cookie_warning_cookie()
7760 7760
 {
7761
-    setcookie("ChamiloUsesCookies", "ok", time()+31556926);
7761
+    setcookie("ChamiloUsesCookies", "ok", time() + 31556926);
7762 7762
 }
7763 7763
 
7764 7764
 /**
@@ -7806,10 +7806,10 @@  discard block
 block discarded – undo
7806 7806
         return false;
7807 7807
     }
7808 7808
 
7809
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7809
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7810 7810
 
7811 7811
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7812
-        $fp = fopen($fullPath . '/index.html', 'w');
7812
+        $fp = fopen($fullPath.'/index.html', 'w');
7813 7813
 
7814 7814
         if ($fp) {
7815 7815
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -8051,13 +8051,13 @@  discard block
 block discarded – undo
8051 8051
  * @param int $key key to find to compare
8052 8052
  *
8053 8053
  */
8054
-function api_unique_multidim_array($array, $key){
8054
+function api_unique_multidim_array($array, $key) {
8055 8055
     $temp_array = array();
8056 8056
     $i = 0;
8057 8057
     $key_array = array();
8058 8058
 
8059
-    foreach($array as $val){
8060
-        if(!in_array($val[$key],$key_array)){
8059
+    foreach ($array as $val) {
8060
+        if (!in_array($val[$key], $key_array)) {
8061 8061
             $key_array[$i] = $val[$key];
8062 8062
             $temp_array[$i] = $val;
8063 8063
         }
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/banner.lib.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -147,6 +147,9 @@  discard block
 block discarded – undo
147 147
     return $customTabs;
148 148
 }
149 149
 
150
+/**
151
+ * @param string $theme
152
+ */
150 153
 function return_logo($theme)
151 154
 {
152 155
     $_course = api_get_course_info();
@@ -497,6 +500,9 @@  discard block
 block discarded – undo
497 500
     return $menu;
498 501
 }
499 502
 
503
+/**
504
+ * @param string $nameTools
505
+ */
500 506
 function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
501 507
 {
502 508
     $session_id = api_get_session_id();
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     $navigation['mycourses']['key'] = 'my-course';
40 40
 
41 41
     // My Profile
42
-    $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
42
+    $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
43 43
     $navigation['myprofile']['title'] = get_lang('ModifyProfile');
44 44
     $navigation['myprofile']['key'] = 'profile';
45 45
 	// Link to my agenda
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 	// Gradebook
51 51
 	if (api_get_setting('gradebook_enable') == 'true') {
52
-        $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
52
+        $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
53 53
         $navigation['mygradebook']['title'] = get_lang('MyGradebook');
54 54
         $navigation['mygradebook']['key'] = 'gradebook';
55 55
 	}
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 	// Reporting
58 58
 	if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
59 59
         // Link to my space
60
-        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':'');
60
+        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh() ? 'session.php' : '');
61 61
         $navigation['session_my_space']['title'] = get_lang('MySpace');
62 62
         $navigation['session_my_space']['key'] = 'my-space';
63 63
     } else if (api_is_student_boss()) {
64
-        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH) . 'mySpace/student.php';
64
+        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/student.php';
65 65
         $navigation['session_my_space']['title'] = get_lang('MySpace');
66 66
         $navigation['session_my_space']['key'] = 'my-space';
67 67
     } else {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
 	// Social
83
-	if (api_get_setting('allow_social_tool')=='true') {
83
+	if (api_get_setting('allow_social_tool') == 'true') {
84 84
         $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
85 85
         $navigation['social']['title'] = get_lang('SocialNetwork');
86 86
         $navigation['social']['key'] = 'social-network';
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
         'class' => 'img-responsive',
160 160
     );
161 161
     $testServer = api_get_setting('server_type');
162
-    if ($testServer == 'test' && is_file($logoBase . 'svg')) {
163
-        $logo = $logoBase . 'svg';
162
+    if ($testServer == 'test' && is_file($logoBase.'svg')) {
163
+        $logo = $logoBase.'svg';
164 164
         $attributes['width'] = '245';
165 165
         $attributes['height'] = '68';
166 166
         $image_url = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.svg';
167 167
     } else {
168
-        $logo = $logoBase . 'png';
168
+        $logo = $logoBase.'png';
169 169
         $image_url = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png';
170 170
     }
171 171
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     $_course = api_get_course_info();
208 208
     $course_id = 0;
209 209
     if (!empty($_course)) {
210
-        $course_id  = $_course['code'];
210
+        $course_id = $_course['code'];
211 211
     }
212 212
 
213 213
     $user_id = api_get_user_id();
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         if (api_get_setting('gradebook_enable') == 'true') {
305 305
             if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
306 306
                 $navigation['mygradebook'] = $possible_tabs['mygradebook'];
307
-            } else{
307
+            } else {
308 308
                 $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
309 309
             }
310 310
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             if (api_get_setting('allow_social_tool') == 'true') {
330 330
                 $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
331 331
             }
332
-        } else{
332
+        } else {
333 333
             $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
334 334
         }
335 335
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
339 339
                 $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
340 340
             }
341
-        } else{
341
+        } else {
342 342
             $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
343 343
         }
344 344
 
@@ -429,32 +429,32 @@  discard block
 block discarded – undo
429 429
     $home_top = '';
430 430
 
431 431
     if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
432
-        $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
432
+        $home_top = @(string) file_get_contents($homep.$menutabs.'_'.$lang.$ext);
433 433
     } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
434
-        $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
434
+        $home_top = @(string) file_get_contents($homep.$menutabs.$lang.$ext);
435 435
     } else {
436 436
         //$errorMsg = get_lang('HomePageFilesNotReadable');
437 437
     }
438 438
 
439 439
     $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
440 440
 
441
-    $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
441
+    $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
442 442
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
443 443
 
444 444
     $open_mtloggedin = '';
445 445
     if (api_get_user_id() && !api_is_anonymous()) {
446 446
         if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
447
-            $home_top = @(string)file_get_contents($homep.$mtloggedin.'_'.$lang.$ext);
447
+            $home_top = @(string) file_get_contents($homep.$mtloggedin.'_'.$lang.$ext);
448 448
             $home_top = str_replace('::private', '', $home_top);
449 449
         } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
450
-            $home_top = @(string)file_get_contents($homep.$mtloggedin.$lang.$ext);
450
+            $home_top = @(string) file_get_contents($homep.$mtloggedin.$lang.$ext);
451 451
             $home_top = str_replace('::private', '', $home_top);
452 452
         } else {
453 453
             //$errorMsg = get_lang('HomePageFilesNotReadable');
454 454
         }
455 455
 
456 456
         $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
457
-        $open_mtloggedin = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
457
+        $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
458 458
         $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin)));
459 459
     }
460 460
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     if (!empty($open) OR !empty($open_mtloggedin)) {
464 464
         if (strpos($open.$open_mtloggedin, 'show_menu') === false) {
465 465
             if (api_is_anonymous()) {
466
-                $navigation[SECTION_CAMPUS]  = null;
466
+                $navigation[SECTION_CAMPUS] = null;
467 467
             }
468 468
         } else {
469 469
             if (api_get_user_id() && !api_is_anonymous()) {
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     if (count($navigation) > 0 || !empty($lis)) {
478 478
         $pre_lis = '';
479 479
         foreach ($navigation as $section => $navigation_info) {
480
-            $key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:'');
480
+            $key = (!empty($navigation_info['key']) ? 'tab-'.$navigation_info['key'] : '');
481 481
             if (isset($GLOBALS['this_section'])) {
482 482
                 $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active '.$key.'" ' : ' class="'.$key.'"';
483 483
             } else {
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 
522 522
     if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
523 523
 
524
-        $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
524
+        $navigation_item['url'] = $web_course_path.$_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
525 525
         $_course['name'] = api_htmlentities($_course['name']);
526 526
         $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB);
527 527
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
                 $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
537 537
                 break;
538 538
             default:
539
-                if (api_get_session_id() != -1 ) {
539
+                if (api_get_session_id() != -1) {
540 540
                     $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
541 541
                 } else {
542 542
                     $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name']).' '.$course_title;
@@ -570,22 +570,22 @@  discard block
 block discarded – undo
570 570
             // titles for shared folders
571 571
             if ($breadcrumb_step['name'] == 'shared_folder') {
572 572
                 $navigation_item['title'] = get_lang('UserFolders');
573
-            } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
573
+            } elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
574 574
                 $navigation_item['title'] = get_lang('UserFolders');
575
-            } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
575
+            } elseif (strstr($breadcrumb_step['name'], 'sf_user_')) {
576 576
                 $userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8));
577 577
                 $navigation_item['title'] = $userinfo['complete_name'];
578
-            } elseif($breadcrumb_step['name'] == 'chat_files') {
578
+            } elseif ($breadcrumb_step['name'] == 'chat_files') {
579 579
                 $navigation_item['title'] = get_lang('ChatFiles');
580
-            } elseif($breadcrumb_step['name'] == 'images') {
580
+            } elseif ($breadcrumb_step['name'] == 'images') {
581 581
                 $navigation_item['title'] = get_lang('Images');
582
-            } elseif($breadcrumb_step['name'] == 'video') {
582
+            } elseif ($breadcrumb_step['name'] == 'video') {
583 583
                 $navigation_item['title'] = get_lang('Video');
584
-            } elseif($breadcrumb_step['name'] == 'audio') {
584
+            } elseif ($breadcrumb_step['name'] == 'audio') {
585 585
                 $navigation_item['title'] = get_lang('Audio');
586
-            } elseif($breadcrumb_step['name'] == 'flash') {
586
+            } elseif ($breadcrumb_step['name'] == 'flash') {
587 587
                 $navigation_item['title'] = get_lang('Flash');
588
-            } elseif($breadcrumb_step['name'] == 'gallery') {
588
+            } elseif ($breadcrumb_step['name'] == 'gallery') {
589 589
                 $navigation_item['title'] = get_lang('Gallery');
590 590
             }
591 591
             // Fixes breadcrumb title now we applied the Security::remove_XSS and
@@ -652,35 +652,35 @@  discard block
 block discarded – undo
652 652
         if (!empty($final_navigation)) {
653 653
             // $home_link.= '<span class="divider">/</span>';
654 654
             if (!empty($home_link)) {
655
-                $lis.= Display::tag('li', $home_link);
655
+                $lis .= Display::tag('li', $home_link);
656 656
             }
657 657
 
658 658
             foreach ($final_navigation as $bread) {
659 659
                 $bread_check = trim(strip_tags($bread));
660 660
                 if (!empty($bread_check)) {
661
-                    if ($final_navigation_count-1 > $i) {
661
+                    if ($final_navigation_count - 1 > $i) {
662 662
                         $bread .= '';
663 663
                     }
664
-                    $lis.= Display::tag('li', $bread,array('class'=>'active'));
664
+                    $lis .= Display::tag('li', $bread, array('class'=>'active'));
665 665
                     $i++;
666 666
                 }
667 667
             }
668 668
         } else {
669 669
             if (!empty($home_link)) {
670
-                $lis.= Display::tag('li', $home_link);
670
+                $lis .= Display::tag('li', $home_link);
671 671
             }
672 672
         }
673 673
 
674 674
         // View as student/teacher link
675 675
         $view = null;
676 676
         if (!empty($view_as_student_link)) {
677
-            $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right'));
677
+            $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link', 'class' => 'pull-right'));
678 678
         }
679 679
 
680 680
         if (!empty($navigation_right)) {
681
-            foreach($navigation_right as $item){
681
+            foreach ($navigation_right as $item) {
682 682
                 $extra_class = isset($item['class']) ? $item['class'] : null;
683
-                $lis.= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right'));
683
+                $lis .= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right'));
684 684
             }
685 685
         }
686 686
 
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Code
5
- * @todo use globals or parameters or add this file in the template
6
- * @package chamilo.include
7
- */
4
+     * Code
5
+     * @todo use globals or parameters or add this file in the template
6
+     * @package chamilo.include
7
+     */
8 8
 
9 9
 /**
10 10
  * Determines the possible tabs (=sections) that are available.
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
     $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
43 43
     $navigation['myprofile']['title'] = get_lang('ModifyProfile');
44 44
     $navigation['myprofile']['key'] = 'profile';
45
-	// Link to my agenda
45
+    // Link to my agenda
46 46
     $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal';
47 47
     $navigation['myagenda']['title'] = get_lang('MyAgenda');
48 48
     $navigation['myagenda']['key'] = 'agenda';
49 49
 
50
-	// Gradebook
51
-	if (api_get_setting('gradebook_enable') == 'true') {
50
+    // Gradebook
51
+    if (api_get_setting('gradebook_enable') == 'true') {
52 52
         $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
53 53
         $navigation['mygradebook']['title'] = get_lang('MyGradebook');
54 54
         $navigation['mygradebook']['key'] = 'gradebook';
55
-	}
55
+    }
56 56
 
57
-	// Reporting
58
-	if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
57
+    // Reporting
58
+    if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
59 59
         // Link to my space
60 60
         $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':'');
61 61
         $navigation['session_my_space']['title'] = get_lang('MySpace');
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         $navigation['session_my_progress']['key'] = 'my-progress';
80 80
     }
81 81
 
82
-	// Social
83
-	if (api_get_setting('allow_social_tool')=='true') {
82
+    // Social
83
+    if (api_get_setting('allow_social_tool')=='true') {
84 84
         $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
85 85
         $navigation['social']['title'] = get_lang('SocialNetwork');
86 86
         $navigation['social']['key'] = 'social-network';
87
-	}
87
+    }
88 88
 
89
-	// Dashboard
90
-	if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
89
+    // Dashboard
90
+    if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
91 91
         $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
92 92
         $navigation['dashboard']['title'] = get_lang('Dashboard');
93 93
         $navigation['dashboard']['key'] = 'dashboard';
94
-	}
94
+    }
95 95
 
96
-	// Reports
96
+    // Reports
97 97
     /*
98 98
 	if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
99 99
         $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
     }
117 117
     // End Custom Tabs
118 118
 
119
-	// Platform administration
120
-	if (api_is_platform_admin(true)) {
119
+    // Platform administration
120
+    if (api_is_platform_admin(true)) {
121 121
         $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
122 122
         $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
123 123
         $navigation['platform_admin']['key'] = 'admin';
124
-	}
124
+    }
125 125
 
126
-	return $navigation;
126
+    return $navigation;
127 127
 }
128 128
 
129 129
 /**
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-		// Reports
354
+        // Reports
355 355
         if (!empty($possible_tabs['reports'])) {
356 356
             if (api_get_setting('show_tabs', 'reports') == 'true') {
357 357
                 if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
     $menu = null;
494 494
     if (!empty($lis)) {
495
-         $menu .= $lis;
495
+            $menu .= $lis;
496 496
     }
497 497
     return $menu;
498 498
 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         $navigation_item_my_courses['title'] = get_lang('MyCourses');
549 549
         $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
550 550
         $navigation[] = $navigation_item_my_courses;
551
-        */
551
+         */
552 552
         $navigation[] = $navigation_item;
553 553
     }
554 554
 
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   +1845 added lines, -1846 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,85 +760,85 @@  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);
765
-
766
-			if (Database::num_rows($result) > 0) {
767
-				echo '<ul>';
768
-				while ($mytask = Database::fetch_array($result)) {
769
-					echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
770
-				}
771
-				echo '<ul>';
772
-			} else {
773
-				echo get_lang('NoTasks');
774
-			}
775
-		} else {
776
-			echo get_lang('NoTasks');
777
-		}
778
-	}
779
-
780
-	/**
781
-	 * Changes the visibility of a blog
782
-	 * @author Toon Keppens
783
-	 * @param Integer $blog_id
784
-	 */
785
-	public static function change_blog_visibility($blog_id)
786
-	{
787
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
788
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
789
-		$course_id = api_get_course_int_id();
790
-
791
-		// Get blog properties
792
-		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
763
+            $result = Database::query($sql);
764
+
765
+            if (Database::num_rows($result) > 0) {
766
+                echo '<ul>';
767
+                while ($mytask = Database::fetch_array($result)) {
768
+                    echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
769
+                }
770
+                echo '<ul>';
771
+            } else {
772
+                echo get_lang('NoTasks');
773
+            }
774
+        } else {
775
+            echo get_lang('NoTasks');
776
+        }
777
+    }
778
+
779
+    /**
780
+     * Changes the visibility of a blog
781
+     * @author Toon Keppens
782
+     * @param Integer $blog_id
783
+     */
784
+    public static function change_blog_visibility($blog_id)
785
+    {
786
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
787
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
788
+        $course_id = api_get_course_int_id();
789
+
790
+        // Get blog properties
791
+        $sql = "SELECT blog_name, visibility FROM $tbl_blogs
793 792
 				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
794
-		$result = Database::query($sql);
795
-		$blog = Database::fetch_array($result);
796
-		$visibility = $blog['visibility'];
797
-		$title = $blog['blog_name'];
798
-
799
-		if ($visibility == 1) {
800
-			// Change visibility state, remove from course home.
801
-			$sql = "UPDATE $tbl_blogs SET visibility = '0'
793
+        $result = Database::query($sql);
794
+        $blog = Database::fetch_array($result);
795
+        $visibility = $blog['visibility'];
796
+        $title = $blog['blog_name'];
797
+
798
+        if ($visibility == 1) {
799
+            // Change visibility state, remove from course home.
800
+            $sql = "UPDATE $tbl_blogs SET visibility = '0'
802 801
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
803
-			Database::query($sql);
802
+            Database::query($sql);
804 803
 
805
-			$sql = "DELETE FROM $tbl_tool
804
+            $sql = "DELETE FROM $tbl_tool
806 805
 					WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1";
807
-			Database::query($sql);
808
-		} else {
809
-			// Change visibility state, add to course home.
810
-			$sql = "UPDATE $tbl_blogs SET visibility = '1'
806
+            Database::query($sql);
807
+        } else {
808
+            // Change visibility state, add to course home.
809
+            $sql = "UPDATE $tbl_blogs SET visibility = '1'
811 810
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
812
-			Database::query($sql);
811
+            Database::query($sql);
813 812
 
814
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
813
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
815 814
 					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
816
-			Database::query($sql);
815
+            Database::query($sql);
817 816
             $id = Database::insert_id();
818 817
 
819 818
             if ($id) {
820 819
                 $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id";
821 820
                 Database::query($sql);
822 821
             }
823
-		}
824
-	}
825
-
826
-	/**
827
-	 * Shows the posts of a blog
828
-	 * @author Toon Keppens
829
-	 *
830
-	 * @param Integer $blog_id
831
-	 */
832
-	public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
822
+        }
823
+    }
824
+
825
+    /**
826
+     * Shows the posts of a blog
827
+     * @author Toon Keppens
828
+     *
829
+     * @param Integer $blog_id
830
+     */
831
+    public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
833 832
     {
834
-		// Init
835
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
836
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
837
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
833
+        // Init
834
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
835
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
836
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
838 837
 
839
-		$course_id = api_get_course_int_id();
838
+        $course_id = api_get_course_int_id();
840 839
 
841
-		// Get posts and authors
842
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
840
+        // Get posts and authors
841
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
843 842
 		        FROM $tbl_blogs_posts post
844 843
                 INNER JOIN $tbl_users user
845 844
                 ON post.author_id = user.user_id
@@ -847,131 +846,131 @@  discard block
 block discarded – undo
847 846
 						post.c_id = $course_id AND
848 847
 						$filter
849 848
 				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
850
-		$result = Database::query($sql);
851
-
852
-		// Display
853
-		if(Database::num_rows($result) > 0) {
854
-		    $limit = 200;
855
-			while ($blog_post = Database::fetch_array($result)) {
856
-				// Get number of comments
857
-				$sql = "SELECT COUNT(1) as number_of_comments
849
+        $result = Database::query($sql);
850
+
851
+        // Display
852
+        if(Database::num_rows($result) > 0) {
853
+            $limit = 200;
854
+            while ($blog_post = Database::fetch_array($result)) {
855
+                // Get number of comments
856
+                $sql = "SELECT COUNT(1) as number_of_comments
858 857
 						FROM $tbl_blogs_comments
859 858
 						WHERE
860 859
 						    c_id = $course_id AND
861 860
 						    blog_id = '".(int)$blog_id."' AND
862 861
 						    post_id = '" . (int)$blog_post['post_id']."'";
863
-				$tmp = Database::query($sql);
864
-				$blog_post_comments = Database::fetch_array($tmp);
865
-
866
-				// Prepare data
867
-				$blog_post_id = $blog_post['post_id'];
868
-				$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
869
-				$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
870
-
871
-				// Create an introduction text (but keep FULL sentences)
872
-				$words = 0;
873
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
874
-				$words = strlen($blog_post_text);
875
-
876
-				if ($words >= $limit) {
877
-					$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>';
878
-					$introduction_text = $blog_post_text_cut;
879
-				} else {
880
-				    $introduction_text = $blog_post_text;
881
-					$readMoreLink = '';
882
-				}
883
-
884
-				$introduction_text = stripslashes($introduction_text);
885
-
886
-				echo '<div class="blogpost">';
887
-				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
888
-				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
889
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
890
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
891
-
892
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
893
-
894
-				if (!empty($file_name_array)) {
895
-					echo '<br /><br />';
896
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
897
-					echo '<a href="download.php?file=';
898
-					echo $file_name_array['path'];
899
-					echo ' "> '.$file_name_array['filename'].' </a><br />';
900
-					echo '</span>';
901
-				}
902
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
903
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
904
-				echo '</div>';
905
-			}
906
-		} else {
907
-			if($filter == '1=1') {
908
-				echo get_lang('NoArticles');
909
-			} else {
910
-				echo get_lang('NoArticleMatches');
911
-			}
912
-		}
862
+                $tmp = Database::query($sql);
863
+                $blog_post_comments = Database::fetch_array($tmp);
864
+
865
+                // Prepare data
866
+                $blog_post_id = $blog_post['post_id'];
867
+                $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
868
+                $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
869
+
870
+                // Create an introduction text (but keep FULL sentences)
871
+                $words = 0;
872
+                $blog_post_text_cut = cut($blog_post_text, $limit) ;
873
+                $words = strlen($blog_post_text);
874
+
875
+                if ($words >= $limit) {
876
+                    $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>';
877
+                    $introduction_text = $blog_post_text_cut;
878
+                } else {
879
+                    $introduction_text = $blog_post_text;
880
+                    $readMoreLink = '';
881
+                }
882
+
883
+                $introduction_text = stripslashes($introduction_text);
884
+
885
+                echo '<div class="blogpost">';
886
+                echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
887
+                echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
888
+                echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
889
+                echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
890
+
891
+                $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
892
+
893
+                if (!empty($file_name_array)) {
894
+                    echo '<br /><br />';
895
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
896
+                    echo '<a href="download.php?file=';
897
+                    echo $file_name_array['path'];
898
+                    echo ' "> '.$file_name_array['filename'].' </a><br />';
899
+                    echo '</span>';
900
+                }
901
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
902
+                echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
903
+                echo '</div>';
904
+            }
905
+        } else {
906
+            if($filter == '1=1') {
907
+                echo get_lang('NoArticles');
908
+            } else {
909
+                echo get_lang('NoArticleMatches');
910
+            }
911
+        }
913 912
 }
914 913
 
915
-	/**
916
-	 * Display the search results
917
-	 *
918
-	 * @param Integer $blog_id
919
-	 * @param String $query_string
920
-	 */
921
-	public static function display_search_results ($blog_id, $query_string)
922
-	{
923
-		// Init
924
-		$query_string = Database::escape_string($query_string);
925
-		$query_string_parts = explode(' ',$query_string);
926
-		$query_string = array();
927
-		foreach ($query_string_parts as $query_part) {
928
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
929
-		}
930
-		$query_string = '('.implode('OR',$query_string) . ')';
931
-
932
-		// Display the posts
933
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
934
-		Blog::display_blog_posts($blog_id, $query_string);
935
-	}
936
-
937
-	/**
938
-	 * Display posts from a certain date
939
-	 *
940
-	 * @param Integer $blog_id
941
-	 * @param String $query_string
942
-	 */
943
-	public static function display_day_results($blog_id, $query_string)
944
-	{
945
-		$date_output = $query_string;
946
-		$date = explode('-',$query_string);
947
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
948
-
949
-		// Put date in correct output format
950
-		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
951
-
952
-		// Display the posts
953
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
954
-		Blog::display_blog_posts($blog_id, $query_string);
955
-	}
956
-
957
-	/**
958
-	 * Displays a post and his comments
959
-	 *
960
-	 * @param Integer $blog_id
961
-	 * @param Integer $post_id
962
-	 */
963
-	public static function display_post($blog_id, $post_id)
964
-	{
965
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
966
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
967
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
968
-
969
-		global $charset, $dateFormatLong;
970
-
971
-		$course_id = api_get_course_int_id();
972
-
973
-		// Get posts and author
974
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
914
+    /**
915
+     * Display the search results
916
+     *
917
+     * @param Integer $blog_id
918
+     * @param String $query_string
919
+     */
920
+    public static function display_search_results ($blog_id, $query_string)
921
+    {
922
+        // Init
923
+        $query_string = Database::escape_string($query_string);
924
+        $query_string_parts = explode(' ',$query_string);
925
+        $query_string = array();
926
+        foreach ($query_string_parts as $query_part) {
927
+            $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
928
+        }
929
+        $query_string = '('.implode('OR',$query_string) . ')';
930
+
931
+        // Display the posts
932
+        echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
933
+        Blog::display_blog_posts($blog_id, $query_string);
934
+    }
935
+
936
+    /**
937
+     * Display posts from a certain date
938
+     *
939
+     * @param Integer $blog_id
940
+     * @param String $query_string
941
+     */
942
+    public static function display_day_results($blog_id, $query_string)
943
+    {
944
+        $date_output = $query_string;
945
+        $date = explode('-',$query_string);
946
+        $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
947
+
948
+        // Put date in correct output format
949
+        $date_output = api_format_date($date_output, DATE_FORMAT_LONG);
950
+
951
+        // Display the posts
952
+        echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
953
+        Blog::display_blog_posts($blog_id, $query_string);
954
+    }
955
+
956
+    /**
957
+     * Displays a post and his comments
958
+     *
959
+     * @param Integer $blog_id
960
+     * @param Integer $post_id
961
+     */
962
+    public static function display_post($blog_id, $post_id)
963
+    {
964
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
965
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
966
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
967
+
968
+        global $charset, $dateFormatLong;
969
+
970
+        $course_id = api_get_course_int_id();
971
+
972
+        // Get posts and author
973
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
975 974
 		        FROM $tbl_blogs_posts post
976 975
 					INNER JOIN $tbl_users user
977 976
 					ON post.author_id = user.user_id
@@ -980,107 +979,107 @@  discard block
 block discarded – undo
980 979
                     post.blog_id = '".(int)$blog_id."' AND
981 980
                     post.post_id = '".(int)$post_id."'
982 981
                 ORDER BY post_id DESC";
983
-		$result = Database::query($sql);
984
-		$blog_post = Database::fetch_array($result);
982
+        $result = Database::query($sql);
983
+        $blog_post = Database::fetch_array($result);
985 984
 
986
-		// Get number of comments
987
-		$sql = "SELECT COUNT(1) as number_of_comments
985
+        // Get number of comments
986
+        $sql = "SELECT COUNT(1) as number_of_comments
988 987
 		        FROM $tbl_blogs_comments
989 988
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
990
-		$result = Database::query($sql);
991
-		$blog_post_comments = Database::fetch_array($result);
989
+        $result = Database::query($sql);
990
+        $blog_post_comments = Database::fetch_array($result);
992 991
 
993
-		// Prepare data
994
-		$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
995
-		$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
996
-		$blog_post_actions = "";
992
+        // Prepare data
993
+        $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
994
+        $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
995
+        $blog_post_actions = "";
997 996
 
998
-		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
997
+        $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
999 998
 
1000
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1001
-			$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') . '"><img src="../img/edit.gif" /></a>';
999
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1000
+            $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') . '"><img src="../img/edit.gif" /></a>';
1002 1001
 
1003
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1004
-			$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;"><img src="../img/delete.gif" border="0" /></a>';
1002
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1003
+            $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;"><img src="../img/delete.gif" border="0" /></a>';
1005 1004
 
1006
-		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1007
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1005
+        if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1006
+            $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1008 1007
 
1009
-		$blog_post_text=stripslashes($blog_post_text);
1008
+        $blog_post_text=stripslashes($blog_post_text);
1010 1009
 
1011
-		// Display post
1012
-		echo '<div class="blogpost">';
1013
-		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>';
1014
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1015
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1010
+        // Display post
1011
+        echo '<div class="blogpost">';
1012
+        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>';
1013
+        echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1014
+        echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1016 1015
 
1017
-		$file_name_array = get_blog_attachment($blog_id, $post_id);
1016
+        $file_name_array = get_blog_attachment($blog_id, $post_id);
1018 1017
 
1019 1018
         if (!empty($file_name_array)) {
1020
-			echo ' <br />';
1021
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1022
-			echo '<a href="download.php?file=';
1023
-			echo $file_name_array['path'];
1024
-			echo ' "> '.$file_name_array['filename'].' </a>';
1025
-			echo '</span>';
1026
-			echo '<span class="attachment_comment">';
1027
-			echo $file_name_array['comment'];
1028
-			echo '</span>';
1029
-			echo '<br />';
1030
-		}
1019
+            echo ' <br />';
1020
+            echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1021
+            echo '<a href="download.php?file=';
1022
+            echo $file_name_array['path'];
1023
+            echo ' "> '.$file_name_array['filename'].' </a>';
1024
+            echo '</span>';
1025
+            echo '<span class="attachment_comment">';
1026
+            echo $file_name_array['comment'];
1027
+            echo '</span>';
1028
+            echo '<br />';
1029
+        }
1031 1030
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1032
-		echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1033
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1034
-		echo '</div>';
1035
-
1036
-		// Display comments if there are any
1037
-		if($blog_post_comments['number_of_comments'] > 0) {
1038
-			echo '<div class="comments">';
1039
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1040
-				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1041
-			echo '</div>';
1042
-		}
1043
-
1044
-		// Display comment form
1045
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1046
-			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1047
-		}
1048
-	}
1049
-
1050
-	/**
1051
-	 * Adds rating to a certain post or comment
1052
-	 * @author Toon Keppens
1053
-	 *
1054
-	 * @param String $type
1055
-	 * @param Integer $blog_id
1056
-	 * @param Integer $item_id
1057
-	 * @param Integer $rating
1058
-	 *
1059
-	 * @return Boolean success
1060
-	 */
1061
-	public static function add_rating($type, $blog_id, $item_id, $rating)
1062
-	{
1063
-		$_user = api_get_user_info();
1064
-
1065
-		// Init
1066
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1067
-		$course_id = api_get_course_int_id();
1068
-
1069
-		// Check if the user has already rated this post/comment
1070
-		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1031
+        echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1032
+        echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1033
+        echo '</div>';
1034
+
1035
+        // Display comments if there are any
1036
+        if($blog_post_comments['number_of_comments'] > 0) {
1037
+            echo '<div class="comments">';
1038
+                echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1039
+                Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1040
+            echo '</div>';
1041
+        }
1042
+
1043
+        // Display comment form
1044
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1045
+            Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1046
+        }
1047
+    }
1048
+
1049
+    /**
1050
+     * Adds rating to a certain post or comment
1051
+     * @author Toon Keppens
1052
+     *
1053
+     * @param String $type
1054
+     * @param Integer $blog_id
1055
+     * @param Integer $item_id
1056
+     * @param Integer $rating
1057
+     *
1058
+     * @return Boolean success
1059
+     */
1060
+    public static function add_rating($type, $blog_id, $item_id, $rating)
1061
+    {
1062
+        $_user = api_get_user_info();
1063
+
1064
+        // Init
1065
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1066
+        $course_id = api_get_course_int_id();
1067
+
1068
+        // Check if the user has already rated this post/comment
1069
+        $sql = "SELECT rating_id FROM $tbl_blogs_rating
1071 1070
                 WHERE
1072 1071
                     c_id = $course_id AND
1073 1072
                     blog_id = '".(int)$blog_id."' AND
1074 1073
                     item_id = '".(int)$item_id."' AND
1075 1074
                     rating_type = '".Database::escape_string($type)."' AND
1076 1075
                     user_id = '".(int)$_user['user_id']."'";
1077
-		$result = Database::query($sql);
1076
+        $result = Database::query($sql);
1078 1077
 
1079 1078
         // Add rating
1080
-		if (Database::num_rows($result) == 0) {
1081
-			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1079
+        if (Database::num_rows($result) == 0) {
1080
+            $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1082 1081
 					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1083
-			Database::query($sql);
1082
+            Database::query($sql);
1084 1083
 
1085 1084
             $id = Database::insert_id();
1086 1085
             if ($id) {
@@ -1088,107 +1087,107 @@  discard block
 block discarded – undo
1088 1087
                 Database::query($sql);
1089 1088
             }
1090 1089
 
1091
-			return true;
1090
+            return true;
1092 1091
         } else {
1093
-			return false;
1094
-		}
1095
-	}
1096
-
1097
-	/**
1098
-	 * Shows the rating of user
1099
-	 *
1100
-	 * @param String $type
1101
-	 * @param Integer $blog_id
1102
-	 * @param Integer $item_id
1103
-	 *
1104
-	 * @return array()
1105
-	 */
1106
-	public static function display_rating($type, $blog_id, $item_id)
1107
-	{
1108
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1109
-		$course_id = api_get_course_int_id();
1110
-
1111
-		// Calculate rating
1112
-		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1092
+            return false;
1093
+        }
1094
+    }
1095
+
1096
+    /**
1097
+     * Shows the rating of user
1098
+     *
1099
+     * @param String $type
1100
+     * @param Integer $blog_id
1101
+     * @param Integer $item_id
1102
+     *
1103
+     * @return array()
1104
+     */
1105
+    public static function display_rating($type, $blog_id, $item_id)
1106
+    {
1107
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1108
+        $course_id = api_get_course_int_id();
1109
+
1110
+        // Calculate rating
1111
+        $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1113 1112
 				WHERE
1114 1113
 				    c_id = $course_id AND
1115 1114
 				    blog_id = '".(int)$blog_id."' AND
1116 1115
 				    item_id = '".(int)$item_id."' AND
1117 1116
 				    rating_type = '".Database::escape_string($type)."' ";
1118
-		$result = Database::query($sql);
1119
-		$result = Database::fetch_array($result);
1120
-		return round($result['rating'], 2);
1121
-	}
1122
-
1123
-	/**
1124
-	 * Shows the rating form if not already rated by that user
1125
-	 * @author Toon Keppens
1126
-	 *
1127
-	 * @param String $type
1128
-	 * @param Integer $blog_id
1129
-	 * @param Integer $item_id
1130
-	 *
1131
-	 *@return String
1132
-	 */
1133
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1134
-	{
1135
-		$_user = api_get_user_info();
1136
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1117
+        $result = Database::query($sql);
1118
+        $result = Database::fetch_array($result);
1119
+        return round($result['rating'], 2);
1120
+    }
1121
+
1122
+    /**
1123
+     * Shows the rating form if not already rated by that user
1124
+     * @author Toon Keppens
1125
+     *
1126
+     * @param String $type
1127
+     * @param Integer $blog_id
1128
+     * @param Integer $item_id
1129
+     *
1130
+     *@return String
1131
+     */
1132
+    public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1133
+    {
1134
+        $_user = api_get_user_info();
1135
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1137 1136
         $course_id = api_get_course_int_id();
1138 1137
 
1139 1138
         if ($type == 'post') {
1140
-			// Check if the user has already rated this post
1141
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1139
+            // Check if the user has already rated this post
1140
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1142 1141
 					WHERE c_id = $course_id AND
1143 1142
 					blog_id = '".(int)$blog_id."'
1144 1143
 					AND item_id = '".(int)$post_id."'
1145 1144
 					AND rating_type = '".Database::escape_string($type)."'
1146 1145
 					AND user_id = '".(int)$_user['user_id']."'";
1147
-			$result = Database::query($sql);
1146
+            $result = Database::query($sql);
1148 1147
             // Add rating
1149 1148
             if (Database::num_rows($result) == 0) {
1150
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1149
+                return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1151 1150
             } else {
1152
-				return '';
1153
-			}
1154
-		}
1151
+                return '';
1152
+            }
1153
+        }
1155 1154
 
1156 1155
         if ($type = 'comment') {
1157
-			// Check if the user has already rated this comment
1158
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1156
+            // Check if the user has already rated this comment
1157
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1159 1158
 					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1160 1159
 					AND item_id = '".(int)$comment_id."'
1161 1160
 					AND rating_type = '".Database::escape_string($type)."'
1162 1161
 					AND user_id = '".(int)$_user['user_id']."'";
1163
-			$result = Database::query($sql);
1162
+            $result = Database::query($sql);
1164 1163
 
1165 1164
             if (Database::num_rows($result) == 0) {
1166
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1165
+                return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1167 1166
             } else {
1168
-				return '';
1169
-			}
1170
-		}
1171
-	}
1172
-
1173
-	/**
1174
-	 * This functions gets all replys to a post, threaded.
1175
-	 *
1176
-	 * @param Integer $current
1177
-	 * @param Integer $current_level
1178
-	 * @param Integer $blog_id
1179
-	 * @param Integer $post_id
1180
-	 */
1181
-	public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1182
-	{
1183
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1184
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1185
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1186
-		global $charset;
1187
-
1188
-		$course_id = api_get_course_int_id();
1189
-
1190
-		// Select top level comments
1191
-		$next_level = $current_level + 1;
1167
+                return '';
1168
+            }
1169
+        }
1170
+    }
1171
+
1172
+    /**
1173
+     * This functions gets all replys to a post, threaded.
1174
+     *
1175
+     * @param Integer $current
1176
+     * @param Integer $current_level
1177
+     * @param Integer $blog_id
1178
+     * @param Integer $post_id
1179
+     */
1180
+    public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1181
+    {
1182
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1183
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1184
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1185
+        global $charset;
1186
+
1187
+        $course_id = api_get_course_int_id();
1188
+
1189
+        // Select top level comments
1190
+        $next_level = $current_level + 1;
1192 1191
         $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color
1193 1192
                 FROM $tbl_blogs_comments comments
1194 1193
                 INNER JOIN $tbl_users user
@@ -1200,11 +1199,11 @@  discard block
 block discarded – undo
1200 1199
                     parent_comment_id = $current AND
1201 1200
                     comments.blog_id = '".(int)$blog_id."' AND
1202 1201
                     comments.post_id = '".(int)$post_id."'";
1203
-		$result = Database::query($sql);
1202
+        $result = Database::query($sql);
1204 1203
 
1205
-		while($comment = Database::fetch_array($result)) {
1206
-			// Select the children recursivly
1207
-			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1204
+        while($comment = Database::fetch_array($result)) {
1205
+            // Select the children recursivly
1206
+            $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1208 1207
 			        FROM $tbl_blogs_comments comments
1209 1208
 					INNER JOIN $tbl_users user
1210 1209
 					ON comments.author_id = user.user_id
@@ -1213,104 +1212,104 @@  discard block
 block discarded – undo
1213 1212
 						comment_id = $current
1214 1213
 						AND blog_id = '".(int)$blog_id."'
1215 1214
 						AND post_id = '".(int)$post_id."'";
1216
-			$tmp = Database::query($tmp);
1217
-			$tmp = Database::fetch_array($tmp);
1218
-			$parent_cat = $tmp['parent_comment_id'];
1219
-			$border_color = '';
1220
-
1221
-			// Prepare data
1222
-			$comment_text = make_clickable(stripslashes($comment['comment']));
1223
-			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1224
-			$blog_comment_actions = "";
1225
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1227
-
1228
-			if (!is_null($comment['task_id'])) {
1229
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1230
-			}
1231
-
1232
-			$comment_text = stripslashes($comment_text);
1233
-
1234
-			// Output...
1235
-			$margin = $current_level * 30;
1236
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1237
-				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1238
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1239
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1240
-
1241
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1242
-				if (!empty($file_name_array)) {
1243
-					echo '<br /><br />';
1244
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1245
-					echo '<a href="download.php?file=';
1246
-					echo $file_name_array['path'];
1247
-					echo ' "> '.$file_name_array['filename'].' </a>';
1248
-					echo '<span class="attachment_comment">';
1249
-					echo $file_name_array['comment'];
1250
-					echo '</span><br />';
1251
-				}
1215
+            $tmp = Database::query($tmp);
1216
+            $tmp = Database::fetch_array($tmp);
1217
+            $parent_cat = $tmp['parent_comment_id'];
1218
+            $border_color = '';
1219
+
1220
+            // Prepare data
1221
+            $comment_text = make_clickable(stripslashes($comment['comment']));
1222
+            $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1223
+            $blog_comment_actions = "";
1224
+            if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1225
+            if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1226
+
1227
+            if (!is_null($comment['task_id'])) {
1228
+                $border_color = ' border-left: 3px solid #' . $comment['color'];
1229
+            }
1230
+
1231
+            $comment_text = stripslashes($comment_text);
1232
+
1233
+            // Output...
1234
+            $margin = $current_level * 30;
1235
+            echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1236
+                echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1237
+                echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1238
+                echo '<span class="blogpost_text">' . $comment_text . '</span>';
1239
+
1240
+                $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1241
+                if (!empty($file_name_array)) {
1242
+                    echo '<br /><br />';
1243
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1244
+                    echo '<a href="download.php?file=';
1245
+                    echo $file_name_array['path'];
1246
+                    echo ' "> '.$file_name_array['filename'].' </a>';
1247
+                    echo '<span class="attachment_comment">';
1248
+                    echo $file_name_array['comment'];
1249
+                    echo '</span><br />';
1250
+                }
1252 1251
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1253
-				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>';
1254
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1255
-			echo '</div>';
1256
-
1257
-			// Go further down the tree.
1258
-			Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1259
-		}
1260
-	}
1261
-
1262
-	/**
1263
-	 * Displays the form to create a new post
1264
-	 * @author Toon Keppens
1265
-	 *
1266
-	 * @param Integer $blog_id
1267
-	 */
1268
-	public static function display_form_new_post($blog_id)
1269
-	{
1270
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1271
-			$form = new FormValidator(
1272
-				'add_post',
1273
-				'post',
1274
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1275
-				null,
1276
-				array('enctype' => 'multipart/form-data')
1277
-			);
1278
-			$form->addHidden('post_title_edited', 'false');
1279
-			$form->addHeader(get_lang('NewPost'));
1280
-			$form->addText('title', get_lang('Title'));
1281
-			$config = array();
1282
-			if (!api_is_allowed_to_edit()) {
1283
-				$config['ToolbarSet'] = 'ProjectStudent';
1284
-			} else {
1285
-				$config['ToolbarSet'] = 'Project';
1286
-			}
1287
-			$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1288
-			$form->addFile('user_upload', get_lang('AddAnAttachment'));
1289
-			$form->addTextarea('post_file_comment', get_lang('FileComment'));
1290
-			$form->addHidden('new_post_submit', 'true');
1291
-			$form->addButton('save', get_lang('Save'));
1292
-
1293
-			$form->display();
1294
-		} else {
1295
-			api_not_allowed();
1296
-		}
1297
-	}
1298
-
1299
-	/**
1300
-	 * Displays the form to edit a post
1301
-	 * @author Toon Keppens
1302
-	 *
1303
-	 * @param Integer $blog_id
1304
-	 */
1305
-	public static function display_form_edit_post($blog_id, $post_id)
1306
-	{
1307
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1308
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1309
-
1310
-		$course_id = api_get_course_int_id();
1311
-
1312
-		// Get posts and author
1313
-		$sql = "SELECT post.*, user.lastname, user.firstname
1252
+                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>';
1253
+                echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1254
+            echo '</div>';
1255
+
1256
+            // Go further down the tree.
1257
+            Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1258
+        }
1259
+    }
1260
+
1261
+    /**
1262
+     * Displays the form to create a new post
1263
+     * @author Toon Keppens
1264
+     *
1265
+     * @param Integer $blog_id
1266
+     */
1267
+    public static function display_form_new_post($blog_id)
1268
+    {
1269
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1270
+            $form = new FormValidator(
1271
+                'add_post',
1272
+                'post',
1273
+                api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1274
+                null,
1275
+                array('enctype' => 'multipart/form-data')
1276
+            );
1277
+            $form->addHidden('post_title_edited', 'false');
1278
+            $form->addHeader(get_lang('NewPost'));
1279
+            $form->addText('title', get_lang('Title'));
1280
+            $config = array();
1281
+            if (!api_is_allowed_to_edit()) {
1282
+                $config['ToolbarSet'] = 'ProjectStudent';
1283
+            } else {
1284
+                $config['ToolbarSet'] = 'Project';
1285
+            }
1286
+            $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1287
+            $form->addFile('user_upload', get_lang('AddAnAttachment'));
1288
+            $form->addTextarea('post_file_comment', get_lang('FileComment'));
1289
+            $form->addHidden('new_post_submit', 'true');
1290
+            $form->addButton('save', get_lang('Save'));
1291
+
1292
+            $form->display();
1293
+        } else {
1294
+            api_not_allowed();
1295
+        }
1296
+    }
1297
+
1298
+    /**
1299
+     * Displays the form to edit a post
1300
+     * @author Toon Keppens
1301
+     *
1302
+     * @param Integer $blog_id
1303
+     */
1304
+    public static function display_form_edit_post($blog_id, $post_id)
1305
+    {
1306
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1307
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1308
+
1309
+        $course_id = api_get_course_int_id();
1310
+
1311
+        // Get posts and author
1312
+        $sql = "SELECT post.*, user.lastname, user.firstname
1314 1313
 				FROM $tbl_blogs_posts post
1315 1314
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1316 1315
 				WHERE
@@ -1318,69 +1317,69 @@  discard block
 block discarded – undo
1318 1317
 				post.blog_id 		= '".(int)$blog_id ."'
1319 1318
 				AND post.post_id	= '".(int)$post_id."'
1320 1319
 				ORDER BY post_id DESC";
1321
-		$result = Database::query($sql);
1322
-		$blog_post = Database::fetch_array($result);
1323
-
1324
-		// Form
1325
-		$form = new FormValidator(
1326
-			'edit_post',
1327
-			'post',
1328
-			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1329
-		);
1330
-
1331
-		$form->addHeader(get_lang('EditPost'));
1332
-		$form->addText('title', get_lang('Title'));
1333
-
1334
-		if (!api_is_allowed_to_edit()) {
1335
-			$config['ToolbarSet'] = 'ProjectStudent';
1336
-		} else {
1337
-			$config['ToolbarSet'] = 'Project';
1338
-		}
1339
-		$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1340
-
1341
-		$form->addHidden('action', '');
1342
-		$form->addHidden('edit_post_submit', 'true');
1343
-		$form->addHidden('post_id', intval($_GET['post_id']));
1344
-		$form->addButton('save', get_lang('Save'));
1345
-		$form->setDefaults($blog_post);
1346
-		$form->display();
1347
-	}
1348
-
1349
-	/**
1350
-	 * Displays a list of tasks in this blog
1351
-	 * @author Toon Keppens
1352
-	 *
1353
-	 * @param Integer $blog_id
1354
-	 */
1355
-	public static function display_task_list($blog_id)
1320
+        $result = Database::query($sql);
1321
+        $blog_post = Database::fetch_array($result);
1322
+
1323
+        // Form
1324
+        $form = new FormValidator(
1325
+            'edit_post',
1326
+            'post',
1327
+            api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1328
+        );
1329
+
1330
+        $form->addHeader(get_lang('EditPost'));
1331
+        $form->addText('title', get_lang('Title'));
1332
+
1333
+        if (!api_is_allowed_to_edit()) {
1334
+            $config['ToolbarSet'] = 'ProjectStudent';
1335
+        } else {
1336
+            $config['ToolbarSet'] = 'Project';
1337
+        }
1338
+        $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1339
+
1340
+        $form->addHidden('action', '');
1341
+        $form->addHidden('edit_post_submit', 'true');
1342
+        $form->addHidden('post_id', intval($_GET['post_id']));
1343
+        $form->addButton('save', get_lang('Save'));
1344
+        $form->setDefaults($blog_post);
1345
+        $form->display();
1346
+    }
1347
+
1348
+    /**
1349
+     * Displays a list of tasks in this blog
1350
+     * @author Toon Keppens
1351
+     *
1352
+     * @param Integer $blog_id
1353
+     */
1354
+    public static function display_task_list($blog_id)
1356 1355
     {
1357
-		global $charset;
1356
+        global $charset;
1358 1357
         $course_id = api_get_course_int_id();
1359 1358
 
1360
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1361
-			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1362
-			$counter = 0;
1363
-			global $color2;
1359
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1360
+            $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1361
+            $counter = 0;
1362
+            global $color2;
1364 1363
 
1365
-			echo '<div class="actions">';
1366
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1367
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1368
-			?>
1364
+            echo '<div class="actions">';
1365
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1366
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1367
+            ?>
1369 1368
 				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1370 1369
 			<?php
1371
-			echo '</div>';
1370
+            echo '</div>';
1372 1371
 
1373
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1374
-			echo "<table class=\"data_table\">";
1375
-			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1376
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1377
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1378
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1379
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1380
-				"</tr>\n";
1372
+            echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1373
+            echo "<table class=\"data_table\">";
1374
+            echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1375
+                        "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1376
+                        "<th><b>",get_lang('Description'),"</b></th>\n",
1377
+                        "<th><b>",get_lang('Color'),"</b></th>\n",
1378
+                        "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1379
+                "</tr>\n";
1381 1380
 
1382 1381
 
1383
-			$sql = " SELECT
1382
+            $sql = " SELECT
1384 1383
                         blog_id,
1385 1384
                         task_id,
1386 1385
                         blog_id,
@@ -1391,64 +1390,64 @@  discard block
 block discarded – undo
1391 1390
                     FROM " . $tbl_blogs_tasks . "
1392 1391
                     WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1393 1392
                     ORDER BY system_task, title";
1394
-			$result = Database::query($sql);
1395
-
1396
-
1397
-			while($task = Database::fetch_array($result)) {
1398
-				$counter++;
1399
-				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1400
-				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1401
-				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1402
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1403
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1404
-
1405
-				echo	'<tr class="' . $css_class . '" valign="top">',
1406
-							 '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1407
-							 '<td>' . Security::remove_XSS($task['description']) . '</td>',
1408
-							 '<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>',
1409
-							 '<td width="50">',
1410
-							 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1411
-								'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1412
-								"</a>\n",
1413
-								'<a href="' . $delete_link . '"',
1414
-								$delete_confirm,
1415
-								'><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1416
-								"</a>\n",
1417
-							 '</td>',
1418
-						'</tr>';
1419
-			}
1420
-			echo "</table>";
1421
-		}
1422
-	}
1423
-
1424
-	/**
1425
-	 * Displays a list of tasks assigned to a user in this blog
1426
-	 * @author Toon Keppens
1427
-	 *
1428
-	 * @param Integer $blog_id
1429
-	 */
1430
-	public static function display_assigned_task_list ($blog_id)
1393
+            $result = Database::query($sql);
1394
+
1395
+
1396
+            while($task = Database::fetch_array($result)) {
1397
+                $counter++;
1398
+                $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1399
+                $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1400
+                $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1401
+                $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1402
+                $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1403
+
1404
+                echo	'<tr class="' . $css_class . '" valign="top">',
1405
+                                '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1406
+                                '<td>' . Security::remove_XSS($task['description']) . '</td>',
1407
+                                '<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>',
1408
+                                '<td width="50">',
1409
+                                    '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1410
+                                '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1411
+                                "</a>\n",
1412
+                                '<a href="' . $delete_link . '"',
1413
+                                $delete_confirm,
1414
+                                '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1415
+                                "</a>\n",
1416
+                                '</td>',
1417
+                        '</tr>';
1418
+            }
1419
+            echo "</table>";
1420
+        }
1421
+    }
1422
+
1423
+    /**
1424
+     * Displays a list of tasks assigned to a user in this blog
1425
+     * @author Toon Keppens
1426
+     *
1427
+     * @param Integer $blog_id
1428
+     */
1429
+    public static function display_assigned_task_list ($blog_id)
1431 1430
     {
1432
-		// Init
1433
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1434
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1435
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1436
-		$counter = 0;
1437
-		global $charset,$color2;
1438
-
1439
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1440
-		echo "<table class=\"data_table\">";
1441
-		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1442
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1443
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1444
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1445
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1446
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1447
-			"</tr>";
1448
-
1449
-		$course_id = api_get_course_int_id();
1450
-
1451
-		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1431
+        // Init
1432
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1433
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1434
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1435
+        $counter = 0;
1436
+        global $charset,$color2;
1437
+
1438
+        echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1439
+        echo "<table class=\"data_table\">";
1440
+        echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1441
+                    "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1442
+                    "<th><b>",get_lang('Task'),"</b></th>\n",
1443
+                    "<th><b>",get_lang('Description'),"</b></th>\n",
1444
+                    "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1445
+                    "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1446
+            "</tr>";
1447
+
1448
+        $course_id = api_get_course_int_id();
1449
+
1450
+        $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1452 1451
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
1453 1452
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
1454 1453
 				INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
@@ -1457,45 +1456,45 @@  discard block
 block discarded – undo
1457 1456
 					task.c_id = $course_id AND
1458 1457
 					task_rel_user.blog_id = '".(int)$blog_id."'
1459 1458
 				ORDER BY target_date ASC";
1460
-		$result = Database::query($sql);
1459
+        $result = Database::query($sql);
1461 1460
 
1462
-		while ($assignment = Database::fetch_array($result)) {
1463
-			$counter++;
1464
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1465
-			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1466
-			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1467
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1468
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1461
+        while ($assignment = Database::fetch_array($result)) {
1462
+            $counter++;
1463
+            $css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1464
+            $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1465
+            $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1466
+            $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1467
+            $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1469 1468
 
1470 1469
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1471 1470
 
1472
-			echo	'<tr class="' . $css_class . '" valign="top">',
1473
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1474
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1475
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1476
-						 '<td>' . $assignment['target_date'] . '</td>',
1477
-						 '<td width="50">',
1478
-						 	'<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'] . '">',
1479
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1480
-							"</a>\n",
1481
-							'<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'] . '" ',
1482
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1483
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1484
-							"</a>\n",
1485
-						 '</td>',
1486
-					'</tr>';
1487
-		}
1488
-		echo "</table>";
1489
-	}
1490
-
1491
-	/**
1492
-	 * Displays new task form
1493
-	 * @author Toon Keppens
1494
-	 *
1495
-	 */
1496
-	public static function display_new_task_form ($blog_id)
1497
-	{
1498
-		// Init
1471
+            echo	'<tr class="' . $css_class . '" valign="top">',
1472
+                            '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1473
+                            '<td>'.stripslashes($assignment['title']) . '</td>',
1474
+                            '<td>'.stripslashes($assignment['description']) . '</td>',
1475
+                            '<td>' . $assignment['target_date'] . '</td>',
1476
+                            '<td width="50">',
1477
+                                '<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'] . '">',
1478
+                            '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1479
+                            "</a>\n",
1480
+                            '<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'] . '" ',
1481
+                            'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1482
+                            '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1483
+                            "</a>\n",
1484
+                            '</td>',
1485
+                    '</tr>';
1486
+        }
1487
+        echo "</table>";
1488
+    }
1489
+
1490
+    /**
1491
+     * Displays new task form
1492
+     * @author Toon Keppens
1493
+     *
1494
+     */
1495
+    public static function display_new_task_form ($blog_id)
1496
+    {
1497
+        // Init
1499 1498
         $colors = array(
1500 1499
             'FFFFFF',
1501 1500
             'FFFF99',
@@ -1514,14 +1513,14 @@  discard block
 block discarded – undo
1514 1513
             '000000'
1515 1514
         );
1516 1515
 
1517
-		// form
1518
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1516
+        // form
1517
+        echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1519 1518
 
1520
-		// form title
1521
-		echo '<legend>'.get_lang('AddTask').'</legend>';
1519
+        // form title
1520
+        echo '<legend>'.get_lang('AddTask').'</legend>';
1522 1521
 
1523
-		// task title
1524
-		echo '	<div class="control-group">
1522
+        // task title
1523
+        echo '	<div class="control-group">
1525 1524
 					<label class="control-label">
1526 1525
 						<span class="form_required">*</span>' . get_lang('Title') . '
1527 1526
 					</label>
@@ -1530,8 +1529,8 @@  discard block
 block discarded – undo
1530 1529
 					</div>
1531 1530
 				</div>';
1532 1531
 
1533
-		// task comment
1534
-		echo '	<div class="control-group">
1532
+        // task comment
1533
+        echo '	<div class="control-group">
1535 1534
 					<label class="control-label">
1536 1535
 						' . get_lang('Description') . '
1537 1536
 					</label>
@@ -1540,8 +1539,8 @@  discard block
 block discarded – undo
1540 1539
 					</div>
1541 1540
 				</div>';
1542 1541
 
1543
-		// task management
1544
-		echo '	<div class="control-group">
1542
+        // task management
1543
+        echo '	<div class="control-group">
1545 1544
 					<label class="control-label">
1546 1545
 						' . get_lang('TaskManager') . '
1547 1546
 					</label>
@@ -1562,12 +1561,12 @@  discard block
 block discarded – undo
1562 1561
                         echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1563 1562
                     echo '</tr>';
1564 1563
                 echo '</table>';
1565
-		echo '		</div>
1564
+        echo '		</div>
1566 1565
 				</div>';
1567 1566
 
1568 1567
 
1569
-		// task color
1570
-		echo '	<div class="control-group">
1568
+        // task color
1569
+        echo '	<div class="control-group">
1571 1570
 					<label class="control-label">
1572 1571
 						' . get_lang('Color') . '
1573 1572
 					</label>
@@ -1578,40 +1577,40 @@  discard block
 block discarded – undo
1578 1577
                     echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1579 1578
                 }
1580 1579
         echo '</select>';
1581
-		echo '		</div>
1580
+        echo '		</div>
1582 1581
 				</div>';
1583 1582
 
1584
-		// submit
1585
-		echo '	<div class="control-group">
1583
+        // submit
1584
+        echo '	<div class="control-group">
1586 1585
 					<div class="controls">
1587 1586
 							<input type="hidden" name="action" value="" />
1588 1587
 							<input type="hidden" name="new_task_submit" value="true" />
1589 1588
 						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1590 1589
 					</div>
1591 1590
 				</div>';
1592
-		echo '</form>';
1591
+        echo '</form>';
1593 1592
 
1594
-		echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1595
-	}
1593
+        echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1594
+    }
1596 1595
 
1597 1596
 
1598
-	/**
1599
-	 * Displays edit task form
1600
-	 * @author Toon Keppens
1601
-	 *
1602
-	 */
1603
-	public static function display_edit_task_form ($blog_id, $task_id) {
1604
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1597
+    /**
1598
+     * Displays edit task form
1599
+     * @author Toon Keppens
1600
+     *
1601
+     */
1602
+    public static function display_edit_task_form ($blog_id, $task_id) {
1603
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1605 1604
         $course_id = api_get_course_int_id();
1606 1605
 
1607
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1606
+        $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1608 1607
 
1609
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1610
-		$result = Database::query($sql);
1611
-		$task = Database::fetch_array($result);
1608
+        $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1609
+        $result = Database::query($sql);
1610
+        $task = Database::fetch_array($result);
1612 1611
 
1613
-		// Display
1614
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1612
+        // Display
1613
+        echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1615 1614
 					<legend>' . get_lang('EditTask') . '</legend>
1616 1615
 					<table width="100%" border="0" cellspacing="2">
1617 1616
 						<tr>
@@ -1623,42 +1622,42 @@  discard block
 block discarded – undo
1623 1622
 					   <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td>
1624 1623
 						</tr>';
1625 1624
 
1626
-						/* edit by Kevin Van Den Haute ([email protected]) */
1627
-						$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1625
+                        /* edit by Kevin Van Den Haute ([email protected]) */
1626
+                        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1628 1627
 
1629
-						$sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1628
+                        $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1630 1629
 							     WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
1631
-						$result = Database::query($sql);
1632
-
1633
-						$arrPermissions = array();
1634
-
1635
-						while ($row = Database::fetch_array($result))
1636
-							$arrPermissions[] = $row['action'];
1637
-
1638
-						    echo '<tr>';
1639
-							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1640
-							echo '<td>';
1641
-								echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1642
-									echo '<tr>';
1643
-										echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1644
-										echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1645
-									echo '</tr>';
1646
-									echo '<tr>';
1647
-										echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1648
-										echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1649
-										echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1650
-									echo '</tr>';
1651
-									echo '<tr>';
1652
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1655
-									echo '</tr>';
1656
-								echo '</table>';
1657
-							echo '</td>';
1658
-						echo '</tr>';
1659
-						/* end of edit */
1660
-
1661
-						echo '<tr>
1630
+                        $result = Database::query($sql);
1631
+
1632
+                        $arrPermissions = array();
1633
+
1634
+                        while ($row = Database::fetch_array($result))
1635
+                            $arrPermissions[] = $row['action'];
1636
+
1637
+                            echo '<tr>';
1638
+                            echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1639
+                            echo '<td>';
1640
+                                echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1641
+                                    echo '<tr>';
1642
+                                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1643
+                                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1644
+                                    echo '</tr>';
1645
+                                    echo '<tr>';
1646
+                                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1647
+                                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1648
+                                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1649
+                                    echo '</tr>';
1650
+                                    echo '<tr>';
1651
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1652
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1653
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1654
+                                    echo '</tr>';
1655
+                                echo '</table>';
1656
+                            echo '</td>';
1657
+                        echo '</tr>';
1658
+                        /* end of edit */
1659
+
1660
+                        echo '<tr>
1662 1661
 					   <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
1663 1662
 					   <td>
1664 1663
 					   	<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">';
@@ -1667,7 +1666,7 @@  discard block
 block discarded – undo
1667 1666
                                 $style = 'style="background-color: #' . $color . '"';
1668 1667
                                 echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1669 1668
                             }
1670
-		echo '			   </select>
1669
+        echo '			   </select>
1671 1670
 						  </td>
1672 1671
 						</tr>
1673 1672
 						<tr>
@@ -1680,34 +1679,34 @@  discard block
 block discarded – undo
1680 1679
 						</tr>
1681 1680
 					</table>
1682 1681
 				</form>';
1683
-	}
1684
-
1685
-	/**
1686
-	 * @param $blog_id
1687
-	 * @return FormValidator
1688
-	 */
1689
-	public static function getTaskForm($blog_id)
1690
-	{
1691
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1692
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1693
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1694
-		$course_id = api_get_course_int_id();
1695
-
1696
-		// Get users in this blog / make select list of it
1697
-		$sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1682
+    }
1683
+
1684
+    /**
1685
+     * @param $blog_id
1686
+     * @return FormValidator
1687
+     */
1688
+    public static function getTaskForm($blog_id)
1689
+    {
1690
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1691
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1692
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1693
+        $course_id = api_get_course_int_id();
1694
+
1695
+        // Get users in this blog / make select list of it
1696
+        $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1698 1697
 				FROM $tbl_users user
1699 1698
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1700 1699
 				ON user.user_id = blogs_rel_user.user_id
1701 1700
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1702
-		$result = Database::query($sql);
1701
+        $result = Database::query($sql);
1703 1702
 
1704
-		$options = array();
1705
-		while ($user = Database::fetch_array($result)) {
1706
-			$options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1707
-		}
1703
+        $options = array();
1704
+        while ($user = Database::fetch_array($result)) {
1705
+            $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1706
+        }
1708 1707
 
1709
-		// Get tasks in this blog / make select list of it
1710
-		$sql = "
1708
+        // Get tasks in this blog / make select list of it
1709
+        $sql = "
1711 1710
 			SELECT
1712 1711
 				blog_id,
1713 1712
 				task_id,
@@ -1719,97 +1718,97 @@  discard block
 block discarded – undo
1719 1718
 			FROM $tbl_blogs_tasks
1720 1719
 			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1721 1720
 			ORDER BY system_task, title";
1722
-		$result = Database::query($sql);
1723
-
1724
-		$taskOptions = array();
1725
-		while ($task = Database::fetch_array($result)) {
1726
-			$taskOptions[$task['task_id']] = stripslashes($task['title']);
1727
-		}
1728
-
1729
-		$form = new FormValidator(
1730
-			'assign_task',
1731
-			'post',
1732
-			api_get_path(
1733
-				WEB_CODE_PATH
1734
-			).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1735
-		);
1736
-
1737
-		$form->addHeader(get_lang('AssignTask'));
1738
-		$form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1739
-		$form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1740
-		$form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1741
-
1742
-		$form->addHidden('action', '');
1743
-		$form->addButtonSave(get_lang('Ok'));
1744
-
1745
-		return $form;
1746
-	}
1747
-
1748
-	/**
1749
-	 * Displays assign task form
1750
-	 * @author Toon Keppens
1751
-	 *
1752
-	 */
1753
-	public static function display_assign_task_form($blog_id)
1754
-	{
1755
-		$form = self::getTaskForm($blog_id);
1756
-		$form->addHidden('assign_task_submit', 'true');
1757
-		$form->display();
1758
-		echo '<div style="clear: both; margin-bottom:10px;"></div>';
1759
-	}
1760
-
1761
-	/**
1762
-	 * Displays assign task form
1763
-	 * @author Toon Keppens
1764
-	 *
1765
-	 */
1766
-	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1767
-	{
1768
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1769
-
1770
-		$course_id = api_get_course_int_id();
1771
-
1772
-		// Get assignd date;
1773
-		$sql = "
1721
+        $result = Database::query($sql);
1722
+
1723
+        $taskOptions = array();
1724
+        while ($task = Database::fetch_array($result)) {
1725
+            $taskOptions[$task['task_id']] = stripslashes($task['title']);
1726
+        }
1727
+
1728
+        $form = new FormValidator(
1729
+            'assign_task',
1730
+            'post',
1731
+            api_get_path(
1732
+                WEB_CODE_PATH
1733
+            ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1734
+        );
1735
+
1736
+        $form->addHeader(get_lang('AssignTask'));
1737
+        $form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1738
+        $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1739
+        $form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1740
+
1741
+        $form->addHidden('action', '');
1742
+        $form->addButtonSave(get_lang('Ok'));
1743
+
1744
+        return $form;
1745
+    }
1746
+
1747
+    /**
1748
+     * Displays assign task form
1749
+     * @author Toon Keppens
1750
+     *
1751
+     */
1752
+    public static function display_assign_task_form($blog_id)
1753
+    {
1754
+        $form = self::getTaskForm($blog_id);
1755
+        $form->addHidden('assign_task_submit', 'true');
1756
+        $form->display();
1757
+        echo '<div style="clear: both; margin-bottom:10px;"></div>';
1758
+    }
1759
+
1760
+    /**
1761
+     * Displays assign task form
1762
+     * @author Toon Keppens
1763
+     *
1764
+     */
1765
+    public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1766
+    {
1767
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1768
+
1769
+        $course_id = api_get_course_int_id();
1770
+
1771
+        // Get assignd date;
1772
+        $sql = "
1774 1773
 			SELECT target_date
1775 1774
 			FROM $tbl_blogs_tasks_rel_user
1776 1775
 			WHERE c_id = $course_id AND
1777 1776
 			      blog_id = '".(int)$blog_id."' AND
1778 1777
 			      user_id = '".(int)$user_id."' AND
1779 1778
 			      task_id = '".(int)$task_id."'";
1780
-		$result = Database::query($sql);
1781
-		$row = Database::fetch_assoc($result);
1782
-
1783
-		$date = $row['target_date'];
1784
-
1785
-		$defaults = [
1786
-			'task_user_id' => $user_id,
1787
-			'task_task_id' => $task_id,
1788
-			'task_day' => $date
1789
-		];
1790
-		$form = self::getTaskForm($blog_id);
1791
-		$form->addHidden('old_task_id', $task_id);
1792
-		$form->addHidden('old_user_id', $user_id);
1793
-		$form->addHidden('old_target_date', $date);
1794
-		$form->addHidden('assign_task_edit_submit', 'true');
1795
-		$form->setDefaults($defaults);
1796
-		$form->display();
1797
-	}
1798
-
1799
-	/**
1800
-	 * Assigns a task to a user in a blog
1801
-	 *
1802
-	 * @param Integer $blog_id
1803
-	 * @param Integer $user_id
1804
-	 * @param Integer $task_id
1805
-	 * @param Date $target_date
1806
-	 */
1807
-	public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1808
-	{
1809
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1810
-		$course_id = api_get_course_int_id();
1811
-
1812
-		$sql = "
1779
+        $result = Database::query($sql);
1780
+        $row = Database::fetch_assoc($result);
1781
+
1782
+        $date = $row['target_date'];
1783
+
1784
+        $defaults = [
1785
+            'task_user_id' => $user_id,
1786
+            'task_task_id' => $task_id,
1787
+            'task_day' => $date
1788
+        ];
1789
+        $form = self::getTaskForm($blog_id);
1790
+        $form->addHidden('old_task_id', $task_id);
1791
+        $form->addHidden('old_user_id', $user_id);
1792
+        $form->addHidden('old_target_date', $date);
1793
+        $form->addHidden('assign_task_edit_submit', 'true');
1794
+        $form->setDefaults($defaults);
1795
+        $form->display();
1796
+    }
1797
+
1798
+    /**
1799
+     * Assigns a task to a user in a blog
1800
+     *
1801
+     * @param Integer $blog_id
1802
+     * @param Integer $user_id
1803
+     * @param Integer $task_id
1804
+     * @param Date $target_date
1805
+     */
1806
+    public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1807
+    {
1808
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1809
+        $course_id = api_get_course_int_id();
1810
+
1811
+        $sql = "
1813 1812
 			SELECT COUNT(*) as 'number'
1814 1813
 			FROM " . $tbl_blogs_tasks_rel_user . "
1815 1814
 			WHERE c_id = $course_id AND
@@ -1818,11 +1817,11 @@  discard block
 block discarded – undo
1818 1817
 			AND	task_id = " . (int)$task_id . "
1819 1818
 		";
1820 1819
 
1821
-		$result = Database::query($sql);
1822
-		$row = Database::fetch_assoc($result);
1820
+        $result = Database::query($sql);
1821
+        $row = Database::fetch_assoc($result);
1823 1822
 
1824
-		if ($row['number'] == 0) {
1825
-			$sql = "
1823
+        if ($row['number'] == 0) {
1824
+            $sql = "
1826 1825
 				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1827 1826
 					c_id,
1828 1827
 					blog_id,
@@ -1837,9 +1836,9 @@  discard block
 block discarded – undo
1837 1836
 					'" . Database::escape_string($target_date) . "'
1838 1837
 				)";
1839 1838
 
1840
-			Database::query($sql);
1841
-		}
1842
-	}
1839
+            Database::query($sql);
1840
+        }
1841
+    }
1843 1842
 
1844 1843
     /**
1845 1844
      * @param $blog_id
@@ -1859,11 +1858,11 @@  discard block
 block discarded – undo
1859 1858
         $old_task_id,
1860 1859
         $old_target_date
1861 1860
     ) {
1862
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1861
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1863 1862
 
1864
-		$course_id = api_get_course_int_id();
1863
+        $course_id = api_get_course_int_id();
1865 1864
 
1866
-		$sql = "SELECT COUNT(*) as 'number'
1865
+        $sql = "SELECT COUNT(*) as 'number'
1867 1866
                 FROM " . $tbl_blogs_tasks_rel_user . "
1868 1867
                 WHERE
1869 1868
                     c_id = $course_id AND
@@ -1872,11 +1871,11 @@  discard block
 block discarded – undo
1872 1871
                     task_id = " . (int)$task_id . "
1873 1872
             ";
1874 1873
 
1875
-		$result = Database::query($sql);
1876
-		$row = Database::fetch_assoc($result);
1874
+        $result = Database::query($sql);
1875
+        $row = Database::fetch_assoc($result);
1877 1876
 
1878
-		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1879
-			$sql = "
1877
+        if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1878
+            $sql = "
1880 1879
 				UPDATE " . $tbl_blogs_tasks_rel_user . "
1881 1880
 				SET
1882 1881
 					user_id = " . (int)$user_id . ",
@@ -1889,76 +1888,76 @@  discard block
 block discarded – undo
1889 1888
 					task_id = " . (int)$old_task_id . " AND
1890 1889
 					target_date = '" . Database::escape_string($old_target_date) . "'
1891 1890
 			";
1892
-			Database::query($sql);
1893
-		}
1894
-	}
1895
-
1896
-	/**
1897
-	 * Displays a list with posts a user can select to execute his task.
1898
-	 *
1899
-	 * @param Integer $blog_id
1900
-	 * @param unknown_type $task_id
1901
-	 */
1902
-	public static function display_select_task_post($blog_id, $task_id)
1891
+            Database::query($sql);
1892
+        }
1893
+    }
1894
+
1895
+    /**
1896
+     * Displays a list with posts a user can select to execute his task.
1897
+     *
1898
+     * @param Integer $blog_id
1899
+     * @param unknown_type $task_id
1900
+     */
1901
+    public static function display_select_task_post($blog_id, $task_id)
1903 1902
     {
1904
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1905
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1906
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1907
-		$course_id = api_get_course_int_id();
1903
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1904
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1905
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1906
+        $course_id = api_get_course_int_id();
1908 1907
 
1909 1908
 
1910
-		$sql = "SELECT title, description FROM $tbl_blogs_tasks
1909
+        $sql = "SELECT title, description FROM $tbl_blogs_tasks
1911 1910
 				WHERE task_id = '".(int)$task_id."'
1912 1911
 				AND c_id = $course_id";
1913
-		$result = Database::query($sql);
1914
-		$row = Database::fetch_assoc($result);
1915
-		// Get posts and authors
1916
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
1912
+        $result = Database::query($sql);
1913
+        $row = Database::fetch_assoc($result);
1914
+        // Get posts and authors
1915
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
1917 1916
 				FROM $tbl_blogs_posts post
1918 1917
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1919 1918
 				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
1920 1919
 				ORDER BY post_id DESC
1921 1920
 				LIMIT 0, 100";
1922
-		$result = Database::query($sql);
1921
+        $result = Database::query($sql);
1923 1922
 
1924
-		// Display
1925
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1926
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1923
+        // Display
1924
+        echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1925
+        echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1927 1926
 
1928
-		if (Database::num_rows($result) > 0) {
1929
-			while($blog_post = Database::fetch_array($result)) {
1930
-			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1931
-				echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1932
-			}
1927
+        if (Database::num_rows($result) > 0) {
1928
+            while($blog_post = Database::fetch_array($result)) {
1929
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1930
+                echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1931
+            }
1933 1932
         } else {
1934 1933
             echo get_lang('NoArticles');
1935 1934
         }
1936
-	}
1937
-
1938
-	/**
1939
-	 * Subscribes a user to a given blog
1940
-	 * @author Toon Keppens
1941
-	 *
1942
-	 * @param Integer $blog_id
1943
-	 * @param Integer $user_id
1944
-	 */
1945
-	public static function set_user_subscribed($blog_id, $user_id)
1935
+    }
1936
+
1937
+    /**
1938
+     * Subscribes a user to a given blog
1939
+     * @author Toon Keppens
1940
+     *
1941
+     * @param Integer $blog_id
1942
+     * @param Integer $user_id
1943
+     */
1944
+    public static function set_user_subscribed($blog_id, $user_id)
1946 1945
     {
1947
-		// Init
1948
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1949
-		$tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1946
+        // Init
1947
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1948
+        $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1950 1949
 
1951
-		$course_id = api_get_course_int_id();
1950
+        $course_id = api_get_course_int_id();
1952 1951
 
1953
-		// Subscribe the user
1954
-		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1952
+        // Subscribe the user
1953
+        $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1955 1954
 		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
1956
-		Database::query($sql);
1955
+        Database::query($sql);
1957 1956
 
1958
-		// Give this user basic rights
1959
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1957
+        // Give this user basic rights
1958
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1960 1959
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
1961
-		Database::query($sql);
1960
+        Database::query($sql);
1962 1961
 
1963 1962
         $id = Database::insert_id();
1964 1963
         if ($id) {
@@ -1966,9 +1965,9 @@  discard block
 block discarded – undo
1966 1965
             Database::query($sql);
1967 1966
         }
1968 1967
 
1969
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1968
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1970 1969
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
1971
-		Database::query($sql);
1970
+        Database::query($sql);
1972 1971
 
1973 1972
         $id = Database::insert_id();
1974 1973
         if ($id) {
@@ -1976,197 +1975,197 @@  discard block
 block discarded – undo
1976 1975
             Database::query($sql);
1977 1976
         }
1978 1977
 
1979
-	}
1978
+    }
1980 1979
 
1981
-	/**
1982
-	 * Unsubscribe a user from a given blog
1983
-	 * @author Toon Keppens
1984
-	 *
1985
-	 * @param Integer $blog_id
1986
-	 * @param Integer $user_id
1987
-	 */
1988
-	public static function set_user_unsubscribed($blog_id, $user_id)
1980
+    /**
1981
+     * Unsubscribe a user from a given blog
1982
+     * @author Toon Keppens
1983
+     *
1984
+     * @param Integer $blog_id
1985
+     * @param Integer $user_id
1986
+     */
1987
+    public static function set_user_unsubscribed($blog_id, $user_id)
1989 1988
     {
1990
-		// Init
1989
+        // Init
1991 1990
         $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1992 1991
         $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1993 1992
 
1994
-		// Unsubscribe the user
1995
-		$sql = "DELETE FROM $tbl_blogs_rel_user
1993
+        // Unsubscribe the user
1994
+        $sql = "DELETE FROM $tbl_blogs_rel_user
1996 1995
 		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
1997
-		Database::query($sql);
1996
+        Database::query($sql);
1998 1997
 
1999
-		// Remove this user's permissions.
2000
-		$sql = "DELETE FROM $tbl_user_permissions
1998
+        // Remove this user's permissions.
1999
+        $sql = "DELETE FROM $tbl_user_permissions
2001 2000
 		        WHERE user_id = '".(int)$user_id."'";
2002
-		Database::query($sql);
2003
-	}
2004
-
2005
-	/**
2006
-	 * Displays the form to register users in a blog (in a course)
2007
-	 * The listed users are users subcribed in the course.
2008
-	 * @author Toon Keppens
2009
-	 *
2010
-	 * @param Integer $blog_id
2011
-	 *
2012
-	 * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2013
-	 */
2014
-	public static function display_form_user_subscribe($blog_id)
2015
-	{
2016
-		$_course = api_get_course_info();
2017
-		$is_western_name_order = api_is_western_name_order();
2018
-		$session_id = api_get_session_id();
2019
-		$course_id = $_course['real_id'];
2020
-
2021
-		$currentCourse = $_course['code'];
2022
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2023
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2024
-
2025
-		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2026
-
2027
-		$properties["width"] = "100%";
2028
-
2029
-		// Get blog members' id.
2030
-		$sql = "SELECT user.user_id FROM $tbl_users user
2001
+        Database::query($sql);
2002
+    }
2003
+
2004
+    /**
2005
+     * Displays the form to register users in a blog (in a course)
2006
+     * The listed users are users subcribed in the course.
2007
+     * @author Toon Keppens
2008
+     *
2009
+     * @param Integer $blog_id
2010
+     *
2011
+     * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2012
+     */
2013
+    public static function display_form_user_subscribe($blog_id)
2014
+    {
2015
+        $_course = api_get_course_info();
2016
+        $is_western_name_order = api_is_western_name_order();
2017
+        $session_id = api_get_session_id();
2018
+        $course_id = $_course['real_id'];
2019
+
2020
+        $currentCourse = $_course['code'];
2021
+        $tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2022
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2023
+
2024
+        echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2025
+
2026
+        $properties["width"] = "100%";
2027
+
2028
+        // Get blog members' id.
2029
+        $sql = "SELECT user.user_id FROM $tbl_users user
2031 2030
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2032 2031
 				ON user.user_id = blogs_rel_user.user_id
2033 2032
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'";
2034
-		$result = Database::query($sql);
2035
-
2036
-		$blog_member_ids = array();
2037
-		while($user = Database::fetch_array($result)) {
2038
-			$blog_member_ids[] = $user['user_id'];
2039
-		}
2040
-
2041
-		// Set table headers
2042
-		$column_header[] = array ('', false, '');
2043
-		if ($is_western_name_order) {
2044
-			$column_header[] = array(get_lang('FirstName'), true, '');
2045
-			$column_header[] = array(get_lang('LastName'), true, '');
2046
-		} else {
2047
-			$column_header[] = array(get_lang('LastName'), true, '');
2048
-			$column_header[] = array(get_lang('FirstName'), true, '');
2049
-		}
2050
-		$column_header[] = array(get_lang('Email'), false, '');
2051
-		$column_header[] = array(get_lang('Register'), false, '');
2033
+        $result = Database::query($sql);
2034
+
2035
+        $blog_member_ids = array();
2036
+        while($user = Database::fetch_array($result)) {
2037
+            $blog_member_ids[] = $user['user_id'];
2038
+        }
2039
+
2040
+        // Set table headers
2041
+        $column_header[] = array ('', false, '');
2042
+        if ($is_western_name_order) {
2043
+            $column_header[] = array(get_lang('FirstName'), true, '');
2044
+            $column_header[] = array(get_lang('LastName'), true, '');
2045
+        } else {
2046
+            $column_header[] = array(get_lang('LastName'), true, '');
2047
+            $column_header[] = array(get_lang('FirstName'), true, '');
2048
+        }
2049
+        $column_header[] = array(get_lang('Email'), false, '');
2050
+        $column_header[] = array(get_lang('Register'), false, '');
2052 2051
 
2053 2052
         $student_list = CourseManager:: get_student_list_from_course_code(
2054 2053
             $currentCourse,
2055 2054
             false,
2056 2055
             $session_id
2057 2056
         );
2058
-		$user_data = array();
2059
-
2060
-		// Add users that are not in this blog to the list.
2061
-		foreach ($student_list as $key=>$user) {
2062
-			if(isset($user['id_user'])) {
2063
-				$user['user_id'] = $user['id_user'];
2064
-			}
2065
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2066
-				$a_infosUser = api_get_user_info($user['user_id']);
2067
-				$row = array ();
2068
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2069
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2070
-				if ($is_western_name_order) {
2071
-					$row[] = $a_infosUser["firstname"];
2072
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2073
-				} else {
2074
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2075
-					$row[] = $a_infosUser["firstname"];
2076
-				}
2077
-				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2078
-
2079
-				//Link to register users
2080
-				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2081
-					$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>";
2082
-				} else {
2083
-					$row[] = '';
2084
-				}
2085
-				$user_data[] = $row;
2086
-			}
2087
-		}
2088
-
2089
-		// Display
2090
-		$query_vars['action'] = 'manage_members';
2091
-		$query_vars['blog_id'] = $blog_id;
2092
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2093
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2094
-			$link = '';
2095
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2096
-			$link .= "blog_id=$blog_id&";
2097
-
2098
-			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2099
-			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2100
-			echo get_lang('WithSelected') . ' : ';
2101
-			echo '<select name="action">';
2102
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2103
-			echo '</select>';
2104
-			echo '<input type="hidden" name="register" value="true" />';
2105
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2106
-		echo '</form>';
2107
-	}
2108
-
2109
-	/**
2110
-	 * Displays the form to register users in a blog (in a course)
2111
-	 * The listed users are users subcribed in the course.
2112
-	 * @author Toon Keppens
2113
-	 *
2114
-	 * @param Integer $blog_id
2115
-	 *
2116
-	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2117
-	 */
2118
-	public static function display_form_user_unsubscribe ($blog_id)
2119
-	{
2120
-		$_user = api_get_user_info();
2121
-		$is_western_name_order = api_is_western_name_order();
2122
-
2123
-		// Init
2124
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2125
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2126
-
2127
-		echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2128
-
2129
-		$properties["width"] = "100%";
2130
-		//table column titles
2131
-		$column_header[] = array ('', false, '');
2132
-		if ($is_western_name_order) {
2133
-			$column_header[] = array (get_lang('FirstName'), true, '');
2134
-			$column_header[] = array (get_lang('LastName'), true, '');
2135
-		} else {
2136
-			$column_header[] = array (get_lang('LastName'), true, '');
2137
-			$column_header[] = array (get_lang('FirstName'), true, '');
2138
-		}
2139
-		$column_header[] = array (get_lang('Email'), false, '');
2140
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2141
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2142
-
2143
-		$course_id = api_get_course_int_id();
2144
-
2145
-		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2057
+        $user_data = array();
2058
+
2059
+        // Add users that are not in this blog to the list.
2060
+        foreach ($student_list as $key=>$user) {
2061
+            if(isset($user['id_user'])) {
2062
+                $user['user_id'] = $user['id_user'];
2063
+            }
2064
+            if(!in_array($user['user_id'],$blog_member_ids)) {
2065
+                $a_infosUser = api_get_user_info($user['user_id']);
2066
+                $row = array ();
2067
+                $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2068
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2069
+                if ($is_western_name_order) {
2070
+                    $row[] = $a_infosUser["firstname"];
2071
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2072
+                } else {
2073
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2074
+                    $row[] = $a_infosUser["firstname"];
2075
+                }
2076
+                $row[] = Display::icon_mailto_link($a_infosUser["email"]);
2077
+
2078
+                //Link to register users
2079
+                if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2080
+                    $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>";
2081
+                } else {
2082
+                    $row[] = '';
2083
+                }
2084
+                $user_data[] = $row;
2085
+            }
2086
+        }
2087
+
2088
+        // Display
2089
+        $query_vars['action'] = 'manage_members';
2090
+        $query_vars['blog_id'] = $blog_id;
2091
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2092
+            Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2093
+            $link = '';
2094
+            $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2095
+            $link .= "blog_id=$blog_id&";
2096
+
2097
+            echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2098
+            echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2099
+            echo get_lang('WithSelected') . ' : ';
2100
+            echo '<select name="action">';
2101
+            echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2102
+            echo '</select>';
2103
+            echo '<input type="hidden" name="register" value="true" />';
2104
+            echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2105
+        echo '</form>';
2106
+    }
2107
+
2108
+    /**
2109
+     * Displays the form to register users in a blog (in a course)
2110
+     * The listed users are users subcribed in the course.
2111
+     * @author Toon Keppens
2112
+     *
2113
+     * @param Integer $blog_id
2114
+     *
2115
+     * @return Html Form with sortable table with users to unsubcribe from a blog.
2116
+     */
2117
+    public static function display_form_user_unsubscribe ($blog_id)
2118
+    {
2119
+        $_user = api_get_user_info();
2120
+        $is_western_name_order = api_is_western_name_order();
2121
+
2122
+        // Init
2123
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2124
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2125
+
2126
+        echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2127
+
2128
+        $properties["width"] = "100%";
2129
+        //table column titles
2130
+        $column_header[] = array ('', false, '');
2131
+        if ($is_western_name_order) {
2132
+            $column_header[] = array (get_lang('FirstName'), true, '');
2133
+            $column_header[] = array (get_lang('LastName'), true, '');
2134
+        } else {
2135
+            $column_header[] = array (get_lang('LastName'), true, '');
2136
+            $column_header[] = array (get_lang('FirstName'), true, '');
2137
+        }
2138
+        $column_header[] = array (get_lang('Email'), false, '');
2139
+        $column_header[] = array (get_lang('TaskManager'), true, '');
2140
+        $column_header[] = array (get_lang('UnRegister'), false, '');
2141
+
2142
+        $course_id = api_get_course_int_id();
2143
+
2144
+        $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2146 2145
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2147 2146
                 ON user.user_id = blogs_rel_user.user_id
2148 2147
                 WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2149 2148
 
2150
-		if (!($sql_result = Database::query($sql))) {
2151
-			return false;
2152
-		}
2153
-
2154
-		$user_data = array ();
2155
-
2156
-		while ($myrow = Database::fetch_array($sql_result)) {
2157
-			$row = array ();
2158
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2159
-			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2160
-			if ($is_western_name_order) {
2161
-				$row[] = $myrow["firstname"];
2162
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2163
-			} else {
2164
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2165
-				$row[] = $myrow["firstname"];
2166
-			}
2167
-			$row[] = Display::icon_mailto_link($myrow["email"]);
2168
-
2169
-			$sql = "SELECT bt.title task
2149
+        if (!($sql_result = Database::query($sql))) {
2150
+            return false;
2151
+        }
2152
+
2153
+        $user_data = array ();
2154
+
2155
+        while ($myrow = Database::fetch_array($sql_result)) {
2156
+            $row = array ();
2157
+            $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2158
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2159
+            if ($is_western_name_order) {
2160
+                $row[] = $myrow["firstname"];
2161
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2162
+            } else {
2163
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2164
+                $row[] = $myrow["firstname"];
2165
+            }
2166
+            $row[] = Display::icon_mailto_link($myrow["email"]);
2167
+
2168
+            $sql = "SELECT bt.title task
2170 2169
 					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2171 2170
 					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2172 2171
 					ON btu.task_id = bt.task_id
@@ -2174,158 +2173,158 @@  discard block
 block discarded – undo
2174 2173
 							bt.c_id 	= $course_id  AND
2175 2174
 							btu.blog_id = $blog_id AND
2176 2175
 							btu.user_id = " . $myrow['user_id'];
2177
-			$sql_res = Database::query($sql);
2178
-
2179
-			$task = '';
2180
-
2181
-			while($r = Database::fetch_array($sql_res)) {
2182
-				$task .= stripslashes($r['task']) . ', ';
2183
-			}
2184
-			//echo $task;
2185
-			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2186
-			$row[] = $task;
2187
-			//Link to register users
2188
-
2189
-			if ($myrow["user_id"] != $_user['user_id']) {
2190
-				$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>";
2191
-			} else {
2192
-				$row[] = '';
2193
-			}
2194
-
2195
-			$user_data[] = $row;
2196
-		}
2197
-
2198
-		$query_vars['action'] = 'manage_members';
2199
-		$query_vars['blog_id'] = $blog_id;
2200
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2201
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2202
-		$link = '';
2203
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2204
-		$link .= "blog_id=$blog_id&";
2205
-
2206
-		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2207
-		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2208
-		echo get_lang('WithSelected') . ' : ';
2209
-		echo '<select name="action">';
2210
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2211
-		echo '</select>';
2212
-		echo '<input type="hidden" name="unregister" value="true" />';
2213
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2214
-		echo '</form>';
2215
-	}
2216
-
2217
-	/**
2218
-	 * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2219
-	 * The blog admin can thus select what a certain user can do in the current blog
2220
-	 *
2221
-	 * @param Integer $blog_id
2222
-	 */
2223
-	public static function display_form_user_rights ($blog_id)
2176
+            $sql_res = Database::query($sql);
2177
+
2178
+            $task = '';
2179
+
2180
+            while($r = Database::fetch_array($sql_res)) {
2181
+                $task .= stripslashes($r['task']) . ', ';
2182
+            }
2183
+            //echo $task;
2184
+            $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2185
+            $row[] = $task;
2186
+            //Link to register users
2187
+
2188
+            if ($myrow["user_id"] != $_user['user_id']) {
2189
+                $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>";
2190
+            } else {
2191
+                $row[] = '';
2192
+            }
2193
+
2194
+            $user_data[] = $row;
2195
+        }
2196
+
2197
+        $query_vars['action'] = 'manage_members';
2198
+        $query_vars['blog_id'] = $blog_id;
2199
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2200
+        Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2201
+        $link = '';
2202
+        $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2203
+        $link .= "blog_id=$blog_id&";
2204
+
2205
+        echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2206
+        echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2207
+        echo get_lang('WithSelected') . ' : ';
2208
+        echo '<select name="action">';
2209
+        echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2210
+        echo '</select>';
2211
+        echo '<input type="hidden" name="unregister" value="true" />';
2212
+        echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2213
+        echo '</form>';
2214
+    }
2215
+
2216
+    /**
2217
+     * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2218
+     * The blog admin can thus select what a certain user can do in the current blog
2219
+     *
2220
+     * @param Integer $blog_id
2221
+     */
2222
+    public static function display_form_user_rights ($blog_id)
2223
+    {
2224
+        echo '<legend>'.get_lang('RightsManager').'</legend>';
2225
+        echo '<br />';
2226
+
2227
+        // Integration of patricks permissions system.
2228
+        require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2229
+    }
2230
+
2231
+    /**
2232
+     * Displays the form to create a new post
2233
+     * @author Toon Keppens
2234
+     *
2235
+     * @param Integer $blog_id
2236
+     */
2237
+    public static function display_new_comment_form($blog_id, $post_id, $title)
2238
+    {
2239
+        $form = new FormValidator(
2240
+            'add_post',
2241
+            'post',
2242
+            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(),
2243
+            null,
2244
+            array('enctype' => 'multipart/form-data')
2245
+        );
2246
+
2247
+        $header = get_lang('AddNewComment');
2248
+        if (isset($_GET['task_id'])) {
2249
+            $header = get_lang('ExecuteThisTask');
2250
+        }
2251
+        $form->addHeader($header);
2252
+        $form->addText('title', get_lang('Title'));
2253
+
2254
+        $config = array();
2255
+        if (!api_is_allowed_to_edit()) {
2256
+            $config['ToolbarSet'] = 'ProjectComment';
2257
+        } else {
2258
+            $config['ToolbarSet'] = 'ProjectCommentStudent';
2259
+        }
2260
+        $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2261
+        $form->addFile('user_upload', get_lang('AddAnAttachment'));
2262
+
2263
+        $form->addTextarea('post_file_comment', get_lang('FileComment'));
2264
+
2265
+        $form->addHidden('action', null);
2266
+        $form->addHidden('comment_parent_id', 0);
2267
+
2268
+        if (isset($_GET['task_id'])) {
2269
+            $form->addHidden('new_task_execution_submit', 'true');
2270
+            $form->addHidden('task_id', intval($_GET['task_id']));
2271
+        } else {
2272
+            $form->addHidden('new_comment_submit', 'true');
2273
+        }
2274
+        $form->addButton('save', get_lang('Save'));
2275
+        $form->display();
2276
+    }
2277
+
2278
+
2279
+    /**
2280
+     * show the calender of the given month
2281
+     * @author Patrick Cool
2282
+     * @author Toon Keppens
2283
+     *
2284
+     * @param Array $blogitems an array containing all the blog items for the given month
2285
+     * @param Integer $month: the integer value of the month we are viewing
2286
+     * @param Integer $year: the 4-digit year indication e.g. 2005
2287
+     * @param String $monthName: the language variable for the mont name
2288
+     *
2289
+     * @return html code
2290
+     */
2291
+    public static function display_minimonthcalendar($month, $year, $blog_id)
2224 2292
     {
2225
-		echo '<legend>'.get_lang('RightsManager').'</legend>';
2226
-		echo '<br />';
2227
-
2228
-		// Integration of patricks permissions system.
2229
-		require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2230
-	}
2231
-
2232
-	/**
2233
-	 * Displays the form to create a new post
2234
-	 * @author Toon Keppens
2235
-	 *
2236
-	 * @param Integer $blog_id
2237
-	 */
2238
-	public static function display_new_comment_form($blog_id, $post_id, $title)
2239
-	{
2240
-		$form = new FormValidator(
2241
-			'add_post',
2242
-			'post',
2243
-			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(),
2244
-			null,
2245
-			array('enctype' => 'multipart/form-data')
2246
-		);
2247
-
2248
-		$header = get_lang('AddNewComment');
2249
-		if (isset($_GET['task_id'])) {
2250
-			$header = get_lang('ExecuteThisTask');
2251
-		}
2252
-		$form->addHeader($header);
2253
-		$form->addText('title', get_lang('Title'));
2254
-
2255
-		$config = array();
2256
-		if (!api_is_allowed_to_edit()) {
2257
-			$config['ToolbarSet'] = 'ProjectComment';
2258
-		} else {
2259
-			$config['ToolbarSet'] = 'ProjectCommentStudent';
2260
-		}
2261
-		$form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2262
-		$form->addFile('user_upload', get_lang('AddAnAttachment'));
2263
-
2264
-		$form->addTextarea('post_file_comment', get_lang('FileComment'));
2265
-
2266
-		$form->addHidden('action', null);
2267
-		$form->addHidden('comment_parent_id', 0);
2268
-
2269
-		if (isset($_GET['task_id'])) {
2270
-			$form->addHidden('new_task_execution_submit', 'true');
2271
-			$form->addHidden('task_id', intval($_GET['task_id']));
2272
-		} else {
2273
-			$form->addHidden('new_comment_submit', 'true');
2274
-		}
2275
-		$form->addButton('save', get_lang('Save'));
2276
-		$form->display();
2277
-	}
2278
-
2279
-
2280
-	/**
2281
-	 * show the calender of the given month
2282
-	 * @author Patrick Cool
2283
-	 * @author Toon Keppens
2284
-	 *
2285
-	 * @param Array $blogitems an array containing all the blog items for the given month
2286
-	 * @param Integer $month: the integer value of the month we are viewing
2287
-	 * @param Integer $year: the 4-digit year indication e.g. 2005
2288
-	 * @param String $monthName: the language variable for the mont name
2289
-	 *
2290
-	 * @return html code
2291
-	*/
2292
-	public static function display_minimonthcalendar($month, $year, $blog_id)
2293
-	{
2294
-		// Init
2295
-		$_user = api_get_user_info();
2296
-		global $DaysShort;
2297
-		global $MonthsLong;
2298
-
2299
-		$posts = array();
2300
-		$tasks = array();
2301
-
2302
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2303
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2304
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2305
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2306
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2307
-
2308
-		$course_id = api_get_course_int_id();
2309
-
2310
-		//Handle leap year
2311
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2312
-
2313
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2314
-			$numberofdays[2] = 29;
2315
-
2316
-		//Get the first day of the month
2317
-		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2318
-		$monthName = $MonthsLong[$month-1];
2319
-
2320
-		//Start the week on monday
2321
-		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2322
-		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2323
-		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2324
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2325
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2326
-
2327
-		// Get posts for this month
2328
-		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2293
+        // Init
2294
+        $_user = api_get_user_info();
2295
+        global $DaysShort;
2296
+        global $MonthsLong;
2297
+
2298
+        $posts = array();
2299
+        $tasks = array();
2300
+
2301
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2302
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2303
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2304
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2305
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2306
+
2307
+        $course_id = api_get_course_int_id();
2308
+
2309
+        //Handle leap year
2310
+        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2311
+
2312
+        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2313
+            $numberofdays[2] = 29;
2314
+
2315
+        //Get the first day of the month
2316
+        $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2317
+        $monthName = $MonthsLong[$month-1];
2318
+
2319
+        //Start the week on monday
2320
+        $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2321
+        $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2322
+        $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2323
+        $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2324
+        $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2325
+
2326
+        // Get posts for this month
2327
+        $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2329 2328
 				FROM $tbl_blogs_posts post
2330 2329
 				INNER JOIN $tbl_users user
2331 2330
 				ON post.author_id = user.user_id
@@ -2335,20 +2334,20 @@  discard block
 block discarded – undo
2335 2334
 					MONTH(date_creation) = '".(int)$month."' AND
2336 2335
 					YEAR(date_creation) = '".(int)$year."'
2337 2336
 				ORDER BY date_creation";
2338
-		$result = Database::query($sql);
2339
-
2340
-		// We will create an array of days on which there are posts.
2341
-		if( Database::num_rows($result) > 0) {
2342
-			while($blog_post = Database::fetch_array($result)) {
2343
-				// If the day of this post is not yet in the array, add it.
2344
-				if (!in_array($blog_post['post_day'], $posts))
2345
-					$posts[] = $blog_post['post_day'];
2346
-			}
2347
-		}
2348
-
2349
-		// Get tasks for this month
2350
-		if ($_user['user_id']) {
2351
-			$sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2337
+        $result = Database::query($sql);
2338
+
2339
+        // We will create an array of days on which there are posts.
2340
+        if( Database::num_rows($result) > 0) {
2341
+            while($blog_post = Database::fetch_array($result)) {
2342
+                // If the day of this post is not yet in the array, add it.
2343
+                if (!in_array($blog_post['post_day'], $posts))
2344
+                    $posts[] = $blog_post['post_day'];
2345
+            }
2346
+        }
2347
+
2348
+        // Get tasks for this month
2349
+        if ($_user['user_id']) {
2350
+            $sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2352 2351
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
2353 2352
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
2354 2353
 				INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
@@ -2360,84 +2359,84 @@  discard block
 block discarded – undo
2360 2359
 					MONTH(target_date) = '".(int)$month."' AND
2361 2360
 					YEAR(target_date) = '".(int)$year."'
2362 2361
 				ORDER BY target_date ASC";
2363
-			$result = Database::query($sql);
2364
-
2365
-			if (Database::num_rows($result) > 0) {
2366
-				while ($mytask = Database::fetch_array($result)) {
2367
-					$tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2368
-					$tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2369
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2370
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2371
-					$tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2372
-				}
2373
-			}
2374
-		}
2375
-
2376
-		echo 	'<table id="smallcalendar" class="table table-responsive">',
2377
-				"<tr id=\"title\">\n",
2378
-				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2379
-				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2380
-				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2381
-
2382
-		echo "<tr>\n";
2383
-
2384
-		for($ii = 1; $ii < 8; $ii ++)
2385
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2386
-
2387
-		echo "</tr>";
2388
-
2389
-		$curday = -1;
2390
-		$today = getdate();
2391
-
2392
-		while ($curday <= $numberofdays[$month]) {
2393
-			echo "<tr>";
2394
-			for ($ii = 0; $ii < 7; $ii ++) {
2395
-				if (($curday == -1) && ($ii == $startdayofweek))
2396
-					$curday = 1;
2397
-
2398
-			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2399
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2400
-					$dayheader = "$curday";
2401
-
2402
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2403
-						$dayheader = "$curday";
2404
-						$class = "class=\"days_today\"";
2405
-					}
2406
-
2407
-					echo "<td " . $class.">";
2408
-
2409
-					// If there are posts on this day, create a filter link.
2410
-					if(in_array($curday, $posts))
2411
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2412
-					else
2413
-						echo $dayheader;
2414
-
2415
-					if (count($tasks) > 0) {
2416
-						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2417
-							// Add tasks to calendar
2418
-							foreach ($tasks[$curday] as $task) {
2419
-								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2362
+            $result = Database::query($sql);
2363
+
2364
+            if (Database::num_rows($result) > 0) {
2365
+                while ($mytask = Database::fetch_array($result)) {
2366
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2367
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2368
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2369
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2370
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2371
+                }
2372
+            }
2373
+        }
2374
+
2375
+        echo 	'<table id="smallcalendar" class="table table-responsive">',
2376
+                "<tr id=\"title\">\n",
2377
+                "<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2378
+                "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2379
+                "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2380
+
2381
+        echo "<tr>\n";
2382
+
2383
+        for($ii = 1; $ii < 8; $ii ++)
2384
+            echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2385
+
2386
+        echo "</tr>";
2387
+
2388
+        $curday = -1;
2389
+        $today = getdate();
2390
+
2391
+        while ($curday <= $numberofdays[$month]) {
2392
+            echo "<tr>";
2393
+            for ($ii = 0; $ii < 7; $ii ++) {
2394
+                if (($curday == -1) && ($ii == $startdayofweek))
2395
+                    $curday = 1;
2396
+
2397
+                    if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2398
+                    $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2399
+                    $dayheader = "$curday";
2400
+
2401
+                    if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2402
+                        $dayheader = "$curday";
2403
+                        $class = "class=\"days_today\"";
2404
+                    }
2405
+
2406
+                    echo "<td " . $class.">";
2407
+
2408
+                    // If there are posts on this day, create a filter link.
2409
+                    if(in_array($curday, $posts))
2410
+                        echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2411
+                    else
2412
+                        echo $dayheader;
2413
+
2414
+                    if (count($tasks) > 0) {
2415
+                        if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2416
+                            // Add tasks to calendar
2417
+                            foreach ($tasks[$curday] as $task) {
2418
+                                echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2420 2419
 								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2421
-							}
2422
-						}
2423
-					}
2424
-
2425
-					echo "</td>";
2426
-					$curday ++;
2427
-				} else
2428
-					echo "<td>&nbsp;</td>";
2429
-			}
2430
-			echo "</tr>";
2431
-		}
2432
-		echo "</table>";
2433
-	}
2434
-
2435
-	/**
2436
-	 * Blog admin | Display the form to add a new blog.
2437
-	 *
2438
-	 */
2439
-	public static function display_new_blog_form()
2440
-	{
2420
+                            }
2421
+                        }
2422
+                    }
2423
+
2424
+                    echo "</td>";
2425
+                    $curday ++;
2426
+                } else
2427
+                    echo "<td>&nbsp;</td>";
2428
+            }
2429
+            echo "</tr>";
2430
+        }
2431
+        echo "</table>";
2432
+    }
2433
+
2434
+    /**
2435
+     * Blog admin | Display the form to add a new blog.
2436
+     *
2437
+     */
2438
+    public static function display_new_blog_form()
2439
+    {
2441 2440
         $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add');
2442 2441
         $form->addElement('header', get_lang('AddBlog'));
2443 2442
         $form->addElement('text', 'blog_name', get_lang('Title'));
@@ -2447,34 +2446,34 @@  discard block
 block discarded – undo
2447 2446
         $form->addButtonSave(get_lang('SaveProject'));
2448 2447
 
2449 2448
         $defaults = array(
2450
-			'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2451
-        	'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2452
-		);
2449
+            'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2450
+            'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2451
+        );
2453 2452
         $form->setDefaults($defaults);
2454 2453
         $form->display();
2455
-	}
2456
-
2457
-	/**
2458
-	 * Blog admin | Display the form to edit a blog.
2459
-	 *
2460
-	 */
2461
-	public static function display_edit_blog_form($blog_id)
2462
-	{
2463
-	    $course_id = api_get_course_int_id();
2464
-		$blog_id= intval($blog_id);
2465
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2466
-
2467
-		$sql = "SELECT blog_id, blog_name, blog_subtitle
2454
+    }
2455
+
2456
+    /**
2457
+     * Blog admin | Display the form to edit a blog.
2458
+     *
2459
+     */
2460
+    public static function display_edit_blog_form($blog_id)
2461
+    {
2462
+        $course_id = api_get_course_int_id();
2463
+        $blog_id= intval($blog_id);
2464
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2465
+
2466
+        $sql = "SELECT blog_id, blog_name, blog_subtitle
2468 2467
 		        FROM $tbl_blogs
2469 2468
 		        WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
2470
-		$result = Database::query($sql);
2471
-		$blog = Database::fetch_array($result);
2469
+        $result = Database::query($sql);
2470
+        $blog = Database::fetch_array($result);
2472 2471
 
2473
-		// the form contained errors but we do not want to lose the changes the user already did
2474
-		if ($_POST) {
2475
-			$blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2476
-			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2477
-		}
2472
+        // the form contained errors but we do not want to lose the changes the user already did
2473
+        if ($_POST) {
2474
+            $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2475
+            $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2476
+        }
2478 2477
 
2479 2478
         $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2480 2479
         $form->addElement('header', get_lang('EditBlog'));
@@ -2490,82 +2489,82 @@  discard block
 block discarded – undo
2490 2489
         $defaults['blog_subtitle'] = $blog['blog_subtitle'];
2491 2490
         $form->setDefaults($defaults);
2492 2491
         $form->display();
2493
-	}
2492
+    }
2494 2493
 
2495
-	/**
2496
-	 * Blog admin | Returns table with blogs in this course
2497
-	 */
2498
-	public static function display_blog_list()
2494
+    /**
2495
+     * Blog admin | Returns table with blogs in this course
2496
+     */
2497
+    public static function display_blog_list()
2499 2498
     {
2500
-		global $charset;
2501
-		$_user = api_get_user_info();
2499
+        global $charset;
2500
+        $_user = api_get_user_info();
2502 2501
         $course_id = api_get_course_int_id();
2503 2502
 
2504
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2503
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2505 2504
 
2506
-		//condition for the session
2507
-		$session_id = api_get_session_id();
2508
-		$condition_session = api_get_session_condition($session_id, false);
2505
+        //condition for the session
2506
+        $session_id = api_get_session_id();
2507
+        $condition_session = api_get_session_condition($session_id, false);
2509 2508
 
2510
-		$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2509
+        $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2511 2510
 				FROM $tbl_blogs WHERE c_id = $course_id
2512 2511
 				ORDER BY date_creation DESC";
2513
-		$result = Database::query($sql);
2514
-		$list_info = array();
2515
-		if (Database::num_rows($result)) {
2516
-			while ($row_project=Database::fetch_row($result)) {
2517
-				$list_info[]=$row_project;
2518
-			}
2519
-		}
2520
-
2521
-		$list_content_blog = array();
2522
-		$list_body_blog = array();
2523
-
2524
-		if (is_array($list_info)) {
2525
-			foreach ($list_info as $key => $info_log) {
2526
-				// Validation when belongs to a session
2527
-				$session_img = api_get_session_image($info_log[4], $_user['status']);
2528
-
2529
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2530
-				$title = $info_log[0];
2512
+        $result = Database::query($sql);
2513
+        $list_info = array();
2514
+        if (Database::num_rows($result)) {
2515
+            while ($row_project=Database::fetch_row($result)) {
2516
+                $list_info[]=$row_project;
2517
+            }
2518
+        }
2519
+
2520
+        $list_content_blog = array();
2521
+        $list_body_blog = array();
2522
+
2523
+        if (is_array($list_info)) {
2524
+            foreach ($list_info as $key => $info_log) {
2525
+                // Validation when belongs to a session
2526
+                $session_img = api_get_session_image($info_log[4], $_user['status']);
2527
+
2528
+                $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2529
+                $title = $info_log[0];
2531 2530
                         $image = Display::return_icon('blog.png', $title);
2532
-    			$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;
2531
+                $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;
2533 2532
 
2534
-				$list_body_blog[] = $list_name;
2535
-				$list_body_blog[] = $info_log[1];
2533
+                $list_body_blog[] = $list_name;
2534
+                $list_body_blog[] = $info_log[1];
2536 2535
 
2537
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2538
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2539
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2536
+                $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2537
+                $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2538
+                    $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2540 2539
                                 $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2541 2540
 
2542
-				$my_image.= "</a>\n";
2543
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2544
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2541
+                $my_image.= "</a>\n";
2542
+                $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2543
+                $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2545 2544
                                 $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2546 2545
 
2547
-				$my_image.= "</a>\n";
2548
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2546
+                $my_image.= "</a>\n";
2547
+                $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2549 2548
                                 $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2550 2549
 
2551
-				$my_image.= "</a>\n";
2550
+                $my_image.= "</a>\n";
2552 2551
 
2553
-				$list_body_blog[]=$my_image;
2552
+                $list_body_blog[]=$my_image;
2554 2553
 
2555
-				$list_content_blog[]=$list_body_blog;
2556
-				$list_body_blog = array();
2554
+                $list_content_blog[]=$list_body_blog;
2555
+                $list_body_blog = array();
2557 2556
 
2558
-			}
2559
-			$parameters='';
2560
-			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2561
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2562
-			//$table->set_additional_parameters($parameters);
2563
-			$table->set_header(0, get_lang('Title'));
2564
-			$table->set_header(1, get_lang('SubTitle'));
2565
-			$table->set_header(2, get_lang('Modify'));
2566
-			$table->display();
2567
-		}
2568
-	}
2557
+            }
2558
+            $parameters='';
2559
+            //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2560
+            $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2561
+            //$table->set_additional_parameters($parameters);
2562
+            $table->set_header(0, get_lang('Title'));
2563
+            $table->set_header(1, get_lang('SubTitle'));
2564
+            $table->set_header(2, get_lang('Modify'));
2565
+            $table->display();
2566
+        }
2567
+    }
2569 2568
 }
2570 2569
 
2571 2570
 /**
@@ -2585,34 +2584,34 @@  discard block
 block discarded – undo
2585 2584
  */
2586 2585
 function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2587 2586
 {
2588
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2589
-
2590
-	$blog_id = intval($blog_id);
2591
-	$comment_id = intval($comment_id);
2592
-	$post_id = intval($post_id);
2593
-	$row=array();
2594
-	$where='';
2595
-	if (!empty ($post_id) && is_numeric($post_id)) {
2596
-		$where.=' AND post_id ="'.$post_id.'" ';
2597
-	}
2598
-
2599
-	if (!empty ($comment_id) && is_numeric($comment_id)) {
2600
-		if (!empty ($post_id)) {
2601
-			$where.= ' AND ';
2602
-		}
2603
-		$where.=' comment_id ="'.$comment_id.'" ';
2604
-	}
2587
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2588
+
2589
+    $blog_id = intval($blog_id);
2590
+    $comment_id = intval($comment_id);
2591
+    $post_id = intval($post_id);
2592
+    $row=array();
2593
+    $where='';
2594
+    if (!empty ($post_id) && is_numeric($post_id)) {
2595
+        $where.=' AND post_id ="'.$post_id.'" ';
2596
+    }
2597
+
2598
+    if (!empty ($comment_id) && is_numeric($comment_id)) {
2599
+        if (!empty ($post_id)) {
2600
+            $where.= ' AND ';
2601
+        }
2602
+        $where.=' comment_id ="'.$comment_id.'" ';
2603
+    }
2605 2604
 
2606 2605
     $course_id = api_get_course_int_id();
2607 2606
 
2608
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2607
+    $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2609 2608
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2610 2609
 
2611
-	$result=Database::query($sql);
2612
-	if (Database::num_rows($result)!=0) {
2613
-		$row=Database::fetch_array($result);
2614
-	}
2615
-	return $row;
2610
+    $result=Database::query($sql);
2611
+    if (Database::num_rows($result)!=0) {
2612
+        $row=Database::fetch_array($result);
2613
+    }
2614
+    return $row;
2616 2615
 }
2617 2616
 
2618 2617
 /**
@@ -2626,16 +2625,16 @@  discard block
 block discarded – undo
2626 2625
 
2627 2626
 function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2628 2627
 {
2629
-	$_course = api_get_course_info();
2630
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2631
-	$blog_id = intval($blog_id);
2632
-	$comment_id = intval($comment_id);
2633
-	$post_id = intval($post_id);
2628
+    $_course = api_get_course_info();
2629
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2630
+    $blog_id = intval($blog_id);
2631
+    $comment_id = intval($comment_id);
2632
+    $post_id = intval($post_id);
2634 2633
 
2635 2634
     $course_id = api_get_course_int_id();
2636
-	$where = null;
2635
+    $where = null;
2637 2636
 
2638
-	// delete files in DB
2637
+    // delete files in DB
2639 2638
     if (!empty ($post_id) && is_numeric($post_id)) {
2640 2639
         $where .= ' AND post_id ="'.$post_id.'" ';
2641 2640
     }
@@ -2647,25 +2646,25 @@  discard block
 block discarded – undo
2647 2646
         $where .= ' comment_id ="'.$comment_id.'" ';
2648 2647
     }
2649 2648
 
2650
-	// delete all files in directory
2651
-	$courseDir   = $_course['path'].'/upload/blog';
2652
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2653
-	$updir = $sys_course_path.$courseDir;
2649
+    // delete all files in directory
2650
+    $courseDir   = $_course['path'].'/upload/blog';
2651
+    $sys_course_path = api_get_path(SYS_COURSE_PATH);
2652
+    $updir = $sys_course_path.$courseDir;
2654 2653
 
2655
-	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2654
+    $sql = 'SELECT path FROM '.$blog_table_attachment.'
2656 2655
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2657
-	$result=Database::query($sql);
2658
-
2659
-	while ($row=Database::fetch_row($result)) {
2660
-		$file=$updir.'/'.$row[0];
2661
-		if (Security::check_abs_path($file,$updir) )
2662
-		{
2663
-			@ unlink($file);
2664
-		}
2665
-	}
2666
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2656
+    $result=Database::query($sql);
2657
+
2658
+    while ($row=Database::fetch_row($result)) {
2659
+        $file=$updir.'/'.$row[0];
2660
+        if (Security::check_abs_path($file,$updir) )
2661
+        {
2662
+            @ unlink($file);
2663
+        }
2664
+    }
2665
+    $sql = 'DELETE FROM '. $blog_table_attachment.'
2667 2666
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2668
-	Database::query($sql);
2667
+    Database::query($sql);
2669 2668
 }
2670 2669
 
2671 2670
 /**
@@ -2675,12 +2674,12 @@  discard block
 block discarded – undo
2675 2674
  */
2676 2675
 function get_blog_post_from_user($course_code, $user_id)
2677 2676
 {
2678
-	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2679
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2680
-	$course_info 	= api_get_course_info($course_code);
2681
-	$course_id 		= $course_info['real_id'];
2677
+    $tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2678
+    $tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2679
+    $course_info 	= api_get_course_info($course_code);
2680
+    $course_id 		= $course_info['real_id'];
2682 2681
 
2683
-	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2682
+    $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2684 2683
 			FROM $tbl_blogs blog
2685 2684
 			INNER JOIN  $tbl_blog_post post
2686 2685
 			ON (blog.blog_id = post.blog_id)
@@ -2689,19 +2688,19 @@  discard block
 block discarded – undo
2689 2688
 				post.c_id = $course_id AND
2690 2689
 				author_id =  $user_id AND visibility = 1
2691 2690
 			ORDER BY post.date_creation DESC ";
2692
-	$result = Database::query($sql);
2693
-	$return_data = '';
2694
-
2695
-	if (Database::num_rows($result)!=0) {
2696
-		while ($row=Database::fetch_array($result)) {
2697
-			$return_data.=  '<div class="clear"></div><br />';
2698
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
-			$return_data.=  '<br / >';
2700
-			$return_data.= $row['full_text'];
2701
-			$return_data.= '<br /><br />';
2702
-		}
2703
-	}
2704
-	return $return_data;
2691
+    $result = Database::query($sql);
2692
+    $return_data = '';
2693
+
2694
+    if (Database::num_rows($result)!=0) {
2695
+        while ($row=Database::fetch_array($result)) {
2696
+            $return_data.=  '<div class="clear"></div><br />';
2697
+            $return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2698
+            $return_data.=  '<br / >';
2699
+            $return_data.= $row['full_text'];
2700
+            $return_data.= '<br /><br />';
2701
+        }
2702
+    }
2703
+    return $return_data;
2705 2704
 }
2706 2705
 
2707 2706
 /**
@@ -2718,7 +2717,7 @@  discard block
 block discarded – undo
2718 2717
     $course_info = api_get_course_info($course_code);
2719 2718
     $course_id = $course_info['real_id'];
2720 2719
 
2721
-	$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2720
+    $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2722 2721
 			FROM $tbl_blogs blog INNER JOIN  $tbl_blog_comment comment
2723 2722
 			ON (blog.blog_id = comment.blog_id)
2724 2723
 			WHERE 	blog.c_id = $course_id AND
@@ -2726,18 +2725,18 @@  discard block
 block discarded – undo
2726 2725
 					author_id =  $user_id AND
2727 2726
 					visibility = 1
2728 2727
 			ORDER BY blog_name";
2729
-	$result = Database::query($sql);
2730
-	$return_data = '';
2731
-	if (Database::num_rows($result)!=0) {
2732
-		while ($row=Database::fetch_array($result)) {
2733
-			$return_data.=  '<div class="clear"></div><br />';
2734
-			$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"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
-			$return_data.=  '<br / >';
2736
-			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2737
-			$return_data.=  $row['comment'];
2738
-			$return_data.=  '<br />';
2739
-		}
2740
-	}
2741
-	return $return_data;
2728
+    $result = Database::query($sql);
2729
+    $return_data = '';
2730
+    if (Database::num_rows($result)!=0) {
2731
+        while ($row=Database::fetch_array($result)) {
2732
+            $return_data.=  '<div class="clear"></div><br />';
2733
+            $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"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2734
+            $return_data.=  '<br / >';
2735
+            //$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2736
+            $return_data.=  $row['comment'];
2737
+            $return_data.=  '<br />';
2738
+        }
2739
+    }
2740
+    return $return_data;
2742 2741
 }
2743 2742
 
Please login to merge, or discard this patch.
Spacing   +399 added lines, -399 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);
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			if (Database::num_rows($result) > 0) {
767 767
 				echo '<ul>';
768 768
 				while ($mytask = Database::fetch_array($result)) {
769
-					echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
769
+					echo '<li><a href="blog.php?action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes($mytask['task_id']).'" title="[Blog: '.stripslashes($mytask['blog_name']).'] '.get_lang('ExecuteThisTask').'">'.stripslashes($mytask['title']).'</a></li>';
770 770
 				}
771 771
 				echo '<ul>';
772 772
 			} else {
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 
791 791
 		// Get blog properties
792 792
 		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
793
-				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
793
+				WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'";
794 794
 		$result = Database::query($sql);
795 795
 		$blog = Database::fetch_array($result);
796 796
 		$visibility = $blog['visibility'];
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		if ($visibility == 1) {
800 800
 			// Change visibility state, remove from course home.
801 801
 			$sql = "UPDATE $tbl_blogs SET visibility = '0'
802
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
802
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
803 803
 			Database::query($sql);
804 804
 
805 805
 			$sql = "DELETE FROM $tbl_tool
@@ -808,11 +808,11 @@  discard block
 block discarded – undo
808 808
 		} else {
809 809
 			// Change visibility state, add to course home.
810 810
 			$sql = "UPDATE $tbl_blogs SET visibility = '1'
811
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
811
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
812 812
 			Database::query($sql);
813 813
 
814 814
 			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
815
-					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
815
+					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
816 816
 			Database::query($sql);
817 817
             $id = Database::insert_id();
818 818
 
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
 		        FROM $tbl_blogs_posts post
844 844
                 INNER JOIN $tbl_users user
845 845
                 ON post.author_id = user.user_id
846
-				WHERE 	post.blog_id = '".(int)$blog_id."' AND
846
+				WHERE 	post.blog_id = '".(int) $blog_id."' AND
847 847
 						post.c_id = $course_id AND
848 848
 						$filter
849
-				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
849
+				ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts;
850 850
 		$result = Database::query($sql);
851 851
 
852 852
 		// Display
853
-		if(Database::num_rows($result) > 0) {
853
+		if (Database::num_rows($result) > 0) {
854 854
 		    $limit = 200;
855 855
 			while ($blog_post = Database::fetch_array($result)) {
856 856
 				// Get number of comments
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 						FROM $tbl_blogs_comments
859 859
 						WHERE
860 860
 						    c_id = $course_id AND
861
-						    blog_id = '".(int)$blog_id."' AND
862
-						    post_id = '" . (int)$blog_post['post_id']."'";
861
+						    blog_id = '".(int) $blog_id."' AND
862
+						    post_id = '" . (int) $blog_post['post_id']."'";
863 863
 				$tmp = Database::query($sql);
864 864
 				$blog_post_comments = Database::fetch_array($tmp);
865 865
 
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
 
871 871
 				// Create an introduction text (but keep FULL sentences)
872 872
 				$words = 0;
873
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
873
+				$blog_post_text_cut = cut($blog_post_text, $limit);
874 874
 				$words = strlen($blog_post_text);
875 875
 
876 876
 				if ($words >= $limit) {
877
-					$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>';
877
+					$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>';
878 878
 					$introduction_text = $blog_post_text_cut;
879 879
 				} else {
880 880
 				    $introduction_text = $blog_post_text;
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 				$introduction_text = stripslashes($introduction_text);
885 885
 
886 886
 				echo '<div class="blogpost">';
887
-				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
888
-				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
889
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
890
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
887
+				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>';
888
+				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.$blog_post_date.'</a></span>';
889
+				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>';
890
+				echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>';
891 891
 
892
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
892
+				$file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0);
893 893
 
894 894
 				if (!empty($file_name_array)) {
895 895
 					echo '<br /><br />';
896
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
896
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
897 897
 					echo '<a href="download.php?file=';
898 898
 					echo $file_name_array['path'];
899 899
 					echo ' "> '.$file_name_array['filename'].' </a><br />';
900 900
 					echo '</span>';
901 901
 				}
902 902
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
903
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
903
+				echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - <a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].'</a></span>';
904 904
 				echo '</div>';
905 905
 			}
906 906
 		} else {
907
-			if($filter == '1=1') {
907
+			if ($filter == '1=1') {
908 908
 				echo get_lang('NoArticles');
909 909
 			} else {
910 910
 				echo get_lang('NoArticleMatches');
@@ -918,19 +918,19 @@  discard block
 block discarded – undo
918 918
 	 * @param Integer $blog_id
919 919
 	 * @param String $query_string
920 920
 	 */
921
-	public static function display_search_results ($blog_id, $query_string)
921
+	public static function display_search_results($blog_id, $query_string)
922 922
 	{
923 923
 		// Init
924 924
 		$query_string = Database::escape_string($query_string);
925
-		$query_string_parts = explode(' ',$query_string);
925
+		$query_string_parts = explode(' ', $query_string);
926 926
 		$query_string = array();
927 927
 		foreach ($query_string_parts as $query_part) {
928
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
928
+			$query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' ";
929 929
 		}
930
-		$query_string = '('.implode('OR',$query_string) . ')';
930
+		$query_string = '('.implode('OR', $query_string).')';
931 931
 
932 932
 		// Display the posts
933
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
933
+		echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>';
934 934
 		Blog::display_blog_posts($blog_id, $query_string);
935 935
 	}
936 936
 
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 	public static function display_day_results($blog_id, $query_string)
944 944
 	{
945 945
 		$date_output = $query_string;
946
-		$date = explode('-',$query_string);
947
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
946
+		$date = explode('-', $query_string);
947
+		$query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]);
948 948
 
949 949
 		// Put date in correct output format
950 950
 		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
951 951
 
952 952
 		// Display the posts
953
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
953
+		echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>';
954 954
 		Blog::display_blog_posts($blog_id, $query_string);
955 955
 	}
956 956
 
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 					ON post.author_id = user.user_id
978 978
                 WHERE
979 979
                     post.c_id = $course_id AND
980
-                    post.blog_id = '".(int)$blog_id."' AND
981
-                    post.post_id = '".(int)$post_id."'
980
+                    post.blog_id = '".(int) $blog_id."' AND
981
+                    post.post_id = '".(int) $post_id."'
982 982
                 ORDER BY post_id DESC";
983 983
 		$result = Database::query($sql);
984 984
 		$blog_post = Database::fetch_array($result);
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 		// Get number of comments
987 987
 		$sql = "SELECT COUNT(1) as number_of_comments
988 988
 		        FROM $tbl_blogs_comments
989
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
989
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'";
990 990
 		$result = Database::query($sql);
991 991
 		$blog_post_comments = Database::fetch_array($result);
992 992
 
@@ -997,28 +997,28 @@  discard block
 block discarded – undo
997 997
 
998 998
 		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
999 999
 
1000
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1001
-			$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') . '"><img src="../img/edit.gif" /></a>';
1000
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id))
1001
+			$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').'"><img src="../img/edit.gif" /></a>';
1002 1002
 
1003
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1004
-			$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;"><img src="../img/delete.gif" border="0" /></a>';
1003
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id))
1004
+			$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;"><img src="../img/delete.gif" border="0" /></a>';
1005 1005
 
1006
-		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1007
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1006
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_rate'))
1007
+			$rating_select = Blog::display_rating_form('post', $blog_id, $post_id);
1008 1008
 
1009
-		$blog_post_text=stripslashes($blog_post_text);
1009
+		$blog_post_text = stripslashes($blog_post_text);
1010 1010
 
1011 1011
 		// Display post
1012 1012
 		echo '<div class="blogpost">';
1013
-		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>';
1014
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1015
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1013
+		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>';
1014
+		echo '<span class="blogpost_date">'.$blog_post_date.'</span>';
1015
+		echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />';
1016 1016
 
1017 1017
 		$file_name_array = get_blog_attachment($blog_id, $post_id);
1018 1018
 
1019 1019
         if (!empty($file_name_array)) {
1020 1020
 			echo ' <br />';
1021
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1021
+			echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1022 1022
 			echo '<a href="download.php?file=';
1023 1023
 			echo $file_name_array['path'];
1024 1024
 			echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1029,20 +1029,20 @@  discard block
 block discarded – undo
1029 1029
 			echo '<br />';
1030 1030
 		}
1031 1031
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1032
-		echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1033
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1032
+		echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post', $blog_id, $post_id).$rating_select.'</span>';
1033
+		echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>';
1034 1034
 		echo '</div>';
1035 1035
 
1036 1036
 		// Display comments if there are any
1037
-		if($blog_post_comments['number_of_comments'] > 0) {
1037
+		if ($blog_post_comments['number_of_comments'] > 0) {
1038 1038
 			echo '<div class="comments">';
1039
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1039
+				echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />';
1040 1040
 				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1041 1041
 			echo '</div>';
1042 1042
 		}
1043 1043
 
1044 1044
 		// Display comment form
1045
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1045
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) {
1046 1046
 			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1047 1047
 		}
1048 1048
 	}
@@ -1070,16 +1070,16 @@  discard block
 block discarded – undo
1070 1070
 		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1071 1071
                 WHERE
1072 1072
                     c_id = $course_id AND
1073
-                    blog_id = '".(int)$blog_id."' AND
1074
-                    item_id = '".(int)$item_id."' AND
1073
+                    blog_id = '".(int) $blog_id."' AND
1074
+                    item_id = '".(int) $item_id."' AND
1075 1075
                     rating_type = '".Database::escape_string($type)."' AND
1076
-                    user_id = '".(int)$_user['user_id']."'";
1076
+                    user_id = '".(int) $_user['user_id']."'";
1077 1077
 		$result = Database::query($sql);
1078 1078
 
1079 1079
         // Add rating
1080 1080
 		if (Database::num_rows($result) == 0) {
1081 1081
 			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1082
-					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1082
+					VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')";
1083 1083
 			Database::query($sql);
1084 1084
 
1085 1085
             $id = Database::insert_id();
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1113 1113
 				WHERE
1114 1114
 				    c_id = $course_id AND
1115
-				    blog_id = '".(int)$blog_id."' AND
1116
-				    item_id = '".(int)$item_id."' AND
1115
+				    blog_id = '".(int) $blog_id."' AND
1116
+				    item_id = '".(int) $item_id."' AND
1117 1117
 				    rating_type = '".Database::escape_string($type)."' ";
1118 1118
 		$result = Database::query($sql);
1119 1119
 		$result = Database::fetch_array($result);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 *@return String
1132 1132
 	 */
1133
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1133
+	public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL)
1134 1134
 	{
1135 1135
 		$_user = api_get_user_info();
1136 1136
 		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
@@ -1140,14 +1140,14 @@  discard block
 block discarded – undo
1140 1140
 			// Check if the user has already rated this post
1141 1141
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1142 1142
 					WHERE c_id = $course_id AND
1143
-					blog_id = '".(int)$blog_id."'
1144
-					AND item_id = '".(int)$post_id."'
1143
+					blog_id = '".(int) $blog_id."'
1144
+					AND item_id = '".(int) $post_id."'
1145 1145
 					AND rating_type = '".Database::escape_string($type)."'
1146
-					AND user_id = '".(int)$_user['user_id']."'";
1146
+					AND user_id = '".(int) $_user['user_id']."'";
1147 1147
 			$result = Database::query($sql);
1148 1148
             // Add rating
1149 1149
             if (Database::num_rows($result) == 0) {
1150
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1150
+				return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" 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>';
1151 1151
             } else {
1152 1152
 				return '';
1153 1153
 			}
@@ -1156,14 +1156,14 @@  discard block
 block discarded – undo
1156 1156
         if ($type = 'comment') {
1157 1157
 			// Check if the user has already rated this comment
1158 1158
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1159
-					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1160
-					AND item_id = '".(int)$comment_id."'
1159
+					WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."'
1160
+					AND item_id = '".(int) $comment_id."'
1161 1161
 					AND rating_type = '".Database::escape_string($type)."'
1162
-					AND user_id = '".(int)$_user['user_id']."'";
1162
+					AND user_id = '".(int) $_user['user_id']."'";
1163 1163
 			$result = Database::query($sql);
1164 1164
 
1165 1165
             if (Database::num_rows($result) == 0) {
1166
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>';
1166
+				return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" 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>';
1167 1167
             } else {
1168 1168
 				return '';
1169 1169
 			}
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
                 WHERE
1199 1199
                     comments.c_id = $course_id AND
1200 1200
                     parent_comment_id = $current AND
1201
-                    comments.blog_id = '".(int)$blog_id."' AND
1202
-                    comments.post_id = '".(int)$post_id."'";
1201
+                    comments.blog_id = '".(int) $blog_id."' AND
1202
+                    comments.post_id = '".(int) $post_id."'";
1203 1203
 		$result = Database::query($sql);
1204 1204
 
1205
-		while($comment = Database::fetch_array($result)) {
1205
+		while ($comment = Database::fetch_array($result)) {
1206 1206
 			// Select the children recursivly
1207 1207
 			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1208 1208
 			        FROM $tbl_blogs_comments comments
@@ -1211,8 +1211,8 @@  discard block
 block discarded – undo
1211 1211
 					WHERE
1212 1212
 						comments.c_id = $course_id AND
1213 1213
 						comment_id = $current
1214
-						AND blog_id = '".(int)$blog_id."'
1215
-						AND post_id = '".(int)$post_id."'";
1214
+						AND blog_id = '".(int) $blog_id."'
1215
+						AND post_id = '".(int) $post_id."'";
1216 1216
 			$tmp = Database::query($tmp);
1217 1217
 			$tmp = Database::fetch_array($tmp);
1218 1218
 			$parent_cat = $tmp['parent_comment_id'];
@@ -1222,26 +1222,26 @@  discard block
 block discarded – undo
1222 1222
 			$comment_text = make_clickable(stripslashes($comment['comment']));
1223 1223
 			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1224 1224
 			$blog_comment_actions = "";
1225
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1225
+			if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
+			if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1227 1227
 
1228 1228
 			if (!is_null($comment['task_id'])) {
1229
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1229
+				$border_color = ' border-left: 3px solid #'.$comment['color'];
1230 1230
 			}
1231 1231
 
1232 1232
 			$comment_text = stripslashes($comment_text);
1233 1233
 
1234 1234
 			// Output...
1235 1235
 			$margin = $current_level * 30;
1236
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1237
-				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1238
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1239
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1236
+			echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">';
1237
+				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']).'\'" title="'.get_lang('ReplyToThisComment').'" >'.stripslashes($comment['title']).'</a></span>';
1238
+				echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>';
1239
+				echo '<span class="blogpost_text">'.$comment_text.'</span>';
1240 1240
 
1241
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1241
+				$file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']);
1242 1242
 				if (!empty($file_name_array)) {
1243 1243
 					echo '<br /><br />';
1244
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1244
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1245 1245
 					echo '<a href="download.php?file=';
1246 1246
 					echo $file_name_array['path'];
1247 1247
 					echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 				}
1252 1252
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1253 1253
 				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>';
1254
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1254
+				echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>';
1255 1255
 			echo '</div>';
1256 1256
 
1257 1257
 			// Go further down the tree.
@@ -1267,11 +1267,11 @@  discard block
 block discarded – undo
1267 1267
 	 */
1268 1268
 	public static function display_form_new_post($blog_id)
1269 1269
 	{
1270
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1270
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1271 1271
 			$form = new FormValidator(
1272 1272
 				'add_post',
1273 1273
 				'post',
1274
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1274
+				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(),
1275 1275
 				null,
1276 1276
 				array('enctype' => 'multipart/form-data')
1277 1277
 			);
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1316 1316
 				WHERE
1317 1317
 				post.c_id 			= $course_id AND
1318
-				post.blog_id 		= '".(int)$blog_id ."'
1319
-				AND post.post_id	= '".(int)$post_id."'
1318
+				post.blog_id 		= '".(int) $blog_id."'
1319
+				AND post.post_id	= '".(int) $post_id."'
1320 1320
 				ORDER BY post_id DESC";
1321 1321
 		$result = Database::query($sql);
1322 1322
 		$blog_post = Database::fetch_array($result);
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 		$form = new FormValidator(
1326 1326
 			'edit_post',
1327 1327
 			'post',
1328
-			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1328
+			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id='.intval($_GET['post_id']).'&blog_id='.intval($blog_id).'&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1329 1329
 		);
1330 1330
 
1331 1331
 		$form->addHeader(get_lang('EditPost'));
@@ -1357,26 +1357,26 @@  discard block
 block discarded – undo
1357 1357
 		global $charset;
1358 1358
         $course_id = api_get_course_int_id();
1359 1359
 
1360
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1360
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1361 1361
 			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1362 1362
 			$counter = 0;
1363 1363
 			global $color2;
1364 1364
 
1365 1365
 			echo '<div class="actions">';
1366
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1367
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1366
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />'.get_lang('AddTasks').'</a> ';
1367
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />'.get_lang('AssignTasks').'</a>';
1368 1368
 			?>
1369
-				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1369
+				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a>
1370 1370
 			<?php
1371 1371
 			echo '</div>';
1372 1372
 
1373
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1373
+			echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />';
1374 1374
 			echo "<table class=\"data_table\">";
1375 1375
 			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1376
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1377
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1378
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1379
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1376
+					 "<th width='240'><b>", get_lang('Title'), "</b></th>\n",
1377
+					 "<th><b>", get_lang('Description'), "</b></th>\n",
1378
+					 "<th><b>", get_lang('Color'), "</b></th>\n",
1379
+					 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1380 1380
 				"</tr>\n";
1381 1381
 
1382 1382
 
@@ -1388,31 +1388,31 @@  discard block
 block discarded – undo
1388 1388
                         description,
1389 1389
                         color,
1390 1390
                         system_task
1391
-                    FROM " . $tbl_blogs_tasks . "
1392
-                    WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1391
+                    FROM " . $tbl_blogs_tasks."
1392
+                    WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1393 1393
                     ORDER BY system_task, title";
1394 1394
 			$result = Database::query($sql);
1395 1395
 
1396 1396
 
1397
-			while($task = Database::fetch_array($result)) {
1397
+			while ($task = Database::fetch_array($result)) {
1398 1398
 				$counter++;
1399 1399
 				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1400 1400
 				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1401 1401
 				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1402
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1403
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1402
+				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id'];
1403
+				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1404 1404
 
1405
-				echo	'<tr class="' . $css_class . '" valign="top">',
1406
-							 '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1407
-							 '<td>' . Security::remove_XSS($task['description']) . '</td>',
1408
-							 '<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>',
1405
+				echo	'<tr class="'.$css_class.'" valign="top">',
1406
+							 '<td width="240">'.Security::remove_XSS($task['title']).'</td>',
1407
+							 '<td>'.Security::remove_XSS($task['description']).'</td>',
1408
+							 '<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>',
1409 1409
 							 '<td width="50">',
1410
-							 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1411
-								'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1410
+							 	'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">',
1411
+								'<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1412 1412
 								"</a>\n",
1413
-								'<a href="' . $delete_link . '"',
1413
+								'<a href="'.$delete_link.'"',
1414 1414
 								$delete_confirm,
1415
-								'><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1415
+								'><img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1416 1416
 								"</a>\n",
1417 1417
 							 '</td>',
1418 1418
 						'</tr>';
@@ -1427,23 +1427,23 @@  discard block
 block discarded – undo
1427 1427
 	 *
1428 1428
 	 * @param Integer $blog_id
1429 1429
 	 */
1430
-	public static function display_assigned_task_list ($blog_id)
1430
+	public static function display_assigned_task_list($blog_id)
1431 1431
     {
1432 1432
 		// Init
1433 1433
 		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1434 1434
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1435 1435
 		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1436 1436
 		$counter = 0;
1437
-		global $charset,$color2;
1437
+		global $charset, $color2;
1438 1438
 
1439
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1439
+		echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />';
1440 1440
 		echo "<table class=\"data_table\">";
1441 1441
 		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1442
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1443
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1444
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1445
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1446
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1442
+				 "<th width='240'><b>", get_lang('Member'), "</b></th>\n",
1443
+				 "<th><b>", get_lang('Task'), "</b></th>\n",
1444
+				 "<th><b>", get_lang('Description'), "</b></th>\n",
1445
+				 "<th><b>", get_lang('TargetDate'), "</b></th>\n",
1446
+				 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1447 1447
 			"</tr>";
1448 1448
 
1449 1449
 		$course_id = api_get_course_int_id();
@@ -1455,32 +1455,32 @@  discard block
 block discarded – undo
1455 1455
 				WHERE
1456 1456
 				    task_rel_user.c_id = $course_id AND
1457 1457
 					task.c_id = $course_id AND
1458
-					task_rel_user.blog_id = '".(int)$blog_id."'
1458
+					task_rel_user.blog_id = '".(int) $blog_id."'
1459 1459
 				ORDER BY target_date ASC";
1460 1460
 		$result = Database::query($sql);
1461 1461
 
1462 1462
 		while ($assignment = Database::fetch_array($result)) {
1463 1463
 			$counter++;
1464
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1464
+			$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1465 1465
 			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1466 1466
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1467
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1468
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1467
+			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id'];
1468
+			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1469 1469
 
1470 1470
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1471 1471
 
1472
-			echo	'<tr class="' . $css_class . '" valign="top">',
1473
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1474
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1475
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1476
-						 '<td>' . $assignment['target_date'] . '</td>',
1472
+			echo	'<tr class="'.$css_class.'" valign="top">',
1473
+						 '<td width="240">'.Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)).'</td>',
1474
+						 '<td>'.stripslashes($assignment['title']).'</td>',
1475
+						 '<td>'.stripslashes($assignment['description']).'</td>',
1476
+						 '<td>'.$assignment['target_date'].'</td>',
1477 1477
 						 '<td width="50">',
1478
-						 	'<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'] . '">',
1479
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1478
+						 	'<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'].'">',
1479
+							'<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1480 1480
 							"</a>\n",
1481
-							'<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'] . '" ',
1482
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1483
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1481
+							'<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'].'" ',
1482
+							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"',
1483
+							'<img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1484 1484
 							"</a>\n",
1485 1485
 						 '</td>',
1486 1486
 					'</tr>';
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 	 * @author Toon Keppens
1494 1494
 	 *
1495 1495
 	 */
1496
-	public static function display_new_task_form ($blog_id)
1496
+	public static function display_new_task_form($blog_id)
1497 1497
 	{
1498 1498
 		// Init
1499 1499
         $colors = array(
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
         );
1516 1516
 
1517 1517
 		// form
1518
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1518
+		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">';
1519 1519
 
1520 1520
 		// form title
1521 1521
 		echo '<legend>'.get_lang('AddTask').'</legend>';
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 		// task title
1524 1524
 		echo '	<div class="control-group">
1525 1525
 					<label class="control-label">
1526
-						<span class="form_required">*</span>' . get_lang('Title') . '
1526
+						<span class="form_required">*</span>' . get_lang('Title').'
1527 1527
 					</label>
1528 1528
 					<div class="controls">
1529 1529
 						<input name="task_name" type="text" size="70" />
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 		// task comment
1534 1534
 		echo '	<div class="control-group">
1535 1535
 					<label class="control-label">
1536
-						' . get_lang('Description') . '
1536
+						' . get_lang('Description').'
1537 1537
 					</label>
1538 1538
 					<div class="controls">
1539 1539
 						<textarea name="task_description" cols="45"></textarea>
@@ -1543,18 +1543,18 @@  discard block
 block discarded – undo
1543 1543
 		// task management
1544 1544
 		echo '	<div class="control-group">
1545 1545
 					<label class="control-label">
1546
-						' . get_lang('TaskManager') . '
1546
+						' . get_lang('TaskManager').'
1547 1547
 					</label>
1548 1548
 					<div class="controls">';
1549 1549
                 echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1550 1550
                     echo '<tr>';
1551
-                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1552
-                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1551
+                        echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>';
1552
+                        echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1553 1553
                     echo '</tr>';
1554 1554
                     echo '<tr>';
1555
-                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1556
-                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1557
-                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1555
+                        echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>';
1556
+                        echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>';
1557
+                        echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>';
1558 1558
                     echo '</tr>';
1559 1559
                     echo '<tr>';
1560 1560
                         echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
@@ -1569,13 +1569,13 @@  discard block
 block discarded – undo
1569 1569
 		// task color
1570 1570
 		echo '	<div class="control-group">
1571 1571
 					<label class="control-label">
1572
-						' . get_lang('Color') . '
1572
+						' . get_lang('Color').'
1573 1573
 					</label>
1574 1574
 					<div class="controls">';
1575 1575
         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">';
1576 1576
                 foreach ($colors as $color) {
1577
-                    $style = 'style="background-color: #' . $color . '"';
1578
-                    echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1577
+                    $style = 'style="background-color: #'.$color.'"';
1578
+                    echo '<option value="'.$color.'" '.$style.'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1579 1579
                 }
1580 1580
         echo '</select>';
1581 1581
 		echo '		</div>
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 					<div class="controls">
1587 1587
 							<input type="hidden" name="action" value="" />
1588 1588
 							<input type="hidden" name="new_task_submit" value="true" />
1589
-						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1589
+						<button class="save" type="submit" name="Submit">' . get_lang('Save').'</button>
1590 1590
 					</div>
1591 1591
 				</div>';
1592 1592
 		echo '</form>';
@@ -1600,34 +1600,34 @@  discard block
 block discarded – undo
1600 1600
 	 * @author Toon Keppens
1601 1601
 	 *
1602 1602
 	 */
1603
-	public static function display_edit_task_form ($blog_id, $task_id) {
1603
+	public static function display_edit_task_form($blog_id, $task_id) {
1604 1604
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1605 1605
         $course_id = api_get_course_int_id();
1606 1606
 
1607
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1607
+		$colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000');
1608 1608
 
1609
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1609
+		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1610 1610
 		$result = Database::query($sql);
1611 1611
 		$task = Database::fetch_array($result);
1612 1612
 
1613 1613
 		// Display
1614
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1615
-					<legend>' . get_lang('EditTask') . '</legend>
1614
+		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">
1615
+					<legend>' . get_lang('EditTask').'</legend>
1616 1616
 					<table width="100%" border="0" cellspacing="2">
1617 1617
 						<tr>
1618
-					   <td align="right">' . get_lang('Title') . ':&nbsp;&nbsp;</td>
1619
-					   <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']) . '" /></td>
1618
+					   <td align="right">' . get_lang('Title').':&nbsp;&nbsp;</td>
1619
+					   <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']).'" /></td>
1620 1620
 						</tr>
1621 1621
 						<tr>
1622
-					   <td align="right">' . get_lang('Description') . ':&nbsp;&nbsp;</td>
1622
+					   <td align="right">' . get_lang('Description').':&nbsp;&nbsp;</td>
1623 1623
 					   <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td>
1624 1624
 						</tr>';
1625 1625
 
1626 1626
 						/* edit by Kevin Van Den Haute ([email protected]) */
1627 1627
 						$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1628 1628
 
1629
-						$sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1630
-							     WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
1629
+						$sql = " SELECT id, action FROM ".$tbl_tasks_permissions."
1630
+							     WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1631 1631
 						$result = Database::query($sql);
1632 1632
 
1633 1633
 						$arrPermissions = array();
@@ -1636,22 +1636,22 @@  discard block
 block discarded – undo
1636 1636
 							$arrPermissions[] = $row['action'];
1637 1637
 
1638 1638
 						    echo '<tr>';
1639
-							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1639
+							echo '<td style="text-align:right; vertical-align:top;">'.get_lang('TaskManager').':&nbsp;&nbsp;</td>';
1640 1640
 							echo '<td>';
1641 1641
 								echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1642 1642
 									echo '<tr>';
1643
-										echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1644
-										echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1643
+										echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>';
1644
+										echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1645 1645
 									echo '</tr>';
1646 1646
 									echo '<tr>';
1647
-										echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1648
-										echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1649
-										echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1647
+										echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>';
1648
+										echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>';
1649
+										echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>';
1650 1650
 									echo '</tr>';
1651 1651
 									echo '<tr>';
1652
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1652
+										echo '<td style="text-align:center;"><input '.((in_array('article_delete', $arrPermissions)) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
+										echo '<td style="text-align:center;"><input '.((in_array('article_edit', $arrPermissions)) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
+										echo '<td style="text-align:center;"><input '.((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1655 1655
 									echo '</tr>';
1656 1656
 								echo '</table>';
1657 1657
 							echo '</td>';
@@ -1659,13 +1659,13 @@  discard block
 block discarded – undo
1659 1659
 						/* end of edit */
1660 1660
 
1661 1661
 						echo '<tr>
1662
-					   <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
1662
+					   <td align="right">' . get_lang('Color').':&nbsp;&nbsp;</td>
1663 1663
 					   <td>
1664
-					   	<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">';
1664
+					   	<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">';
1665 1665
                             foreach ($colors as $color) {
1666 1666
                                 $selected = ($color == $task['color']) ? ' selected' : '';
1667
-                                $style = 'style="background-color: #' . $color . '"';
1668
-                                echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1667
+                                $style = 'style="background-color: #'.$color.'"';
1668
+                                echo '<option value="'.$color.'" '.$style.' '.$selected.' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1669 1669
                             }
1670 1670
 		echo '			   </select>
1671 1671
 						  </td>
@@ -1674,9 +1674,9 @@  discard block
 block discarded – undo
1674 1674
 							<td align="right">&nbsp;</td>
1675 1675
 							<td><br /><input type="hidden" name="action" value="" />
1676 1676
 							<input type="hidden" name="edit_task_submit" value="true" />
1677
-							<input type="hidden" name="task_id" value="' . $task['task_id'] . '" />
1678
-							<input type="hidden" name="blog_id" value="' . $task['blog_id'] . '" />
1679
-							<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button></td>
1677
+							<input type="hidden" name="task_id" value="' . $task['task_id'].'" />
1678
+							<input type="hidden" name="blog_id" value="' . $task['blog_id'].'" />
1679
+							<button class="save" type="submit" name="Submit">' . get_lang('Save').'</button></td>
1680 1680
 						</tr>
1681 1681
 					</table>
1682 1682
 				</form>';
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 				FROM $tbl_users user
1699 1699
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1700 1700
 				ON user.user_id = blogs_rel_user.user_id
1701
-				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1701
+				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'";
1702 1702
 		$result = Database::query($sql);
1703 1703
 
1704 1704
 		$options = array();
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 				color,
1718 1718
 				system_task
1719 1719
 			FROM $tbl_blogs_tasks
1720
-			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1720
+			WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1721 1721
 			ORDER BY system_task, title";
1722 1722
 		$result = Database::query($sql);
1723 1723
 
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 	 */
1766 1766
 	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1767 1767
 	{
1768
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1768
+		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1769 1769
 
1770 1770
 		$course_id = api_get_course_int_id();
1771 1771
 
@@ -1774,9 +1774,9 @@  discard block
 block discarded – undo
1774 1774
 			SELECT target_date
1775 1775
 			FROM $tbl_blogs_tasks_rel_user
1776 1776
 			WHERE c_id = $course_id AND
1777
-			      blog_id = '".(int)$blog_id."' AND
1778
-			      user_id = '".(int)$user_id."' AND
1779
-			      task_id = '".(int)$task_id."'";
1777
+			      blog_id = '".(int) $blog_id."' AND
1778
+			      user_id = '".(int) $user_id."' AND
1779
+			      task_id = '".(int) $task_id."'";
1780 1780
 		$result = Database::query($sql);
1781 1781
 		$row = Database::fetch_assoc($result);
1782 1782
 
@@ -1811,11 +1811,11 @@  discard block
 block discarded – undo
1811 1811
 
1812 1812
 		$sql = "
1813 1813
 			SELECT COUNT(*) as 'number'
1814
-			FROM " . $tbl_blogs_tasks_rel_user . "
1814
+			FROM " . $tbl_blogs_tasks_rel_user."
1815 1815
 			WHERE c_id = $course_id AND
1816
-			blog_id = " . (int)$blog_id . "
1817
-			AND	user_id = " . (int)$user_id . "
1818
-			AND	task_id = " . (int)$task_id . "
1816
+			blog_id = ".(int) $blog_id."
1817
+			AND	user_id = " . (int) $user_id."
1818
+			AND	task_id = " . (int) $task_id."
1819 1819
 		";
1820 1820
 
1821 1821
 		$result = Database::query($sql);
@@ -1823,18 +1823,18 @@  discard block
 block discarded – undo
1823 1823
 
1824 1824
 		if ($row['number'] == 0) {
1825 1825
 			$sql = "
1826
-				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1826
+				INSERT INTO " . $tbl_blogs_tasks_rel_user." (
1827 1827
 					c_id,
1828 1828
 					blog_id,
1829 1829
 					user_id,
1830 1830
 					task_id,
1831 1831
 					target_date
1832 1832
 				) VALUES (
1833
-					'" . (int)$course_id . "',
1834
-					'" . (int)$blog_id . "',
1835
-					'" . (int)$user_id . "',
1836
-					'" . (int)$task_id . "',
1837
-					'" . Database::escape_string($target_date) . "'
1833
+					'" . (int) $course_id."',
1834
+					'" . (int) $blog_id."',
1835
+					'" . (int) $user_id."',
1836
+					'" . (int) $task_id."',
1837
+					'" . Database::escape_string($target_date)."'
1838 1838
 				)";
1839 1839
 
1840 1840
 			Database::query($sql);
@@ -1864,12 +1864,12 @@  discard block
 block discarded – undo
1864 1864
 		$course_id = api_get_course_int_id();
1865 1865
 
1866 1866
 		$sql = "SELECT COUNT(*) as 'number'
1867
-                FROM " . $tbl_blogs_tasks_rel_user . "
1867
+                FROM " . $tbl_blogs_tasks_rel_user."
1868 1868
                 WHERE
1869 1869
                     c_id = $course_id AND
1870
-                    blog_id = " . (int)$blog_id . " AND
1871
-                    user_id = " . (int)$user_id . " AND
1872
-                    task_id = " . (int)$task_id . "
1870
+                    blog_id = ".(int) $blog_id." AND
1871
+                    user_id = " . (int) $user_id." AND
1872
+                    task_id = " . (int) $task_id."
1873 1873
             ";
1874 1874
 
1875 1875
 		$result = Database::query($sql);
@@ -1877,17 +1877,17 @@  discard block
 block discarded – undo
1877 1877
 
1878 1878
 		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1879 1879
 			$sql = "
1880
-				UPDATE " . $tbl_blogs_tasks_rel_user . "
1880
+				UPDATE " . $tbl_blogs_tasks_rel_user."
1881 1881
 				SET
1882
-					user_id = " . (int)$user_id . ",
1883
-					task_id = " . (int)$task_id . ",
1884
-					target_date = '" . Database::escape_string($target_date) . "'
1882
+					user_id = " . (int) $user_id.",
1883
+					task_id = " . (int) $task_id.",
1884
+					target_date = '" . Database::escape_string($target_date)."'
1885 1885
 				WHERE
1886 1886
 					c_id = $course_id AND
1887
-					blog_id = " . (int)$blog_id . " AND
1888
-					user_id = " . (int)$old_user_id . " AND
1889
-					task_id = " . (int)$old_task_id . " AND
1890
-					target_date = '" . Database::escape_string($old_target_date) . "'
1887
+					blog_id = ".(int) $blog_id." AND
1888
+					user_id = " . (int) $old_user_id." AND
1889
+					task_id = " . (int) $old_task_id." AND
1890
+					target_date = '" . Database::escape_string($old_target_date)."'
1891 1891
 			";
1892 1892
 			Database::query($sql);
1893 1893
 		}
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
 
1909 1909
 
1910 1910
 		$sql = "SELECT title, description FROM $tbl_blogs_tasks
1911
-				WHERE task_id = '".(int)$task_id."'
1911
+				WHERE task_id = '".(int) $task_id."'
1912 1912
 				AND c_id = $course_id";
1913 1913
 		$result = Database::query($sql);
1914 1914
 		$row = Database::fetch_assoc($result);
@@ -1916,19 +1916,19 @@  discard block
 block discarded – undo
1916 1916
 		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
1917 1917
 				FROM $tbl_blogs_posts post
1918 1918
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1919
-				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
1919
+				WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id
1920 1920
 				ORDER BY post_id DESC
1921 1921
 				LIMIT 0, 100";
1922 1922
 		$result = Database::query($sql);
1923 1923
 
1924 1924
 		// Display
1925
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1926
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1925
+		echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>';
1926
+		echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>';
1927 1927
 
1928 1928
 		if (Database::num_rows($result) > 0) {
1929
-			while($blog_post = Database::fetch_array($result)) {
1929
+			while ($blog_post = Database::fetch_array($result)) {
1930 1930
 			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1931
-				echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1931
+				echo '<a href="blog.php?action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.stripslashes($blog_post['title']).'</a>, '.get_lang('WrittenBy').' '.stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))).'<br />';
1932 1932
 			}
1933 1933
         } else {
1934 1934
             echo get_lang('NoArticles');
@@ -1952,12 +1952,12 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		// Subscribe the user
1954 1954
 		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1955
-		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
1955
+		        VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');";
1956 1956
 		Database::query($sql);
1957 1957
 
1958 1958
 		// Give this user basic rights
1959 1959
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1960
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
1960
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')";
1961 1961
 		Database::query($sql);
1962 1962
 
1963 1963
         $id = Database::insert_id();
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
         }
1968 1968
 
1969 1969
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1970
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
1970
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')";
1971 1971
 		Database::query($sql);
1972 1972
 
1973 1973
         $id = Database::insert_id();
@@ -1993,12 +1993,12 @@  discard block
 block discarded – undo
1993 1993
 
1994 1994
 		// Unsubscribe the user
1995 1995
 		$sql = "DELETE FROM $tbl_blogs_rel_user
1996
-		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
1996
+		        WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'";
1997 1997
 		Database::query($sql);
1998 1998
 
1999 1999
 		// Remove this user's permissions.
2000 2000
 		$sql = "DELETE FROM $tbl_user_permissions
2001
-		        WHERE user_id = '".(int)$user_id."'";
2001
+		        WHERE user_id = '".(int) $user_id."'";
2002 2002
 		Database::query($sql);
2003 2003
 	}
2004 2004
 
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
 		$course_id = $_course['real_id'];
2020 2020
 
2021 2021
 		$currentCourse = $_course['code'];
2022
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2022
+		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2023 2023
 		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2024 2024
 
2025 2025
 		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
@@ -2034,12 +2034,12 @@  discard block
 block discarded – undo
2034 2034
 		$result = Database::query($sql);
2035 2035
 
2036 2036
 		$blog_member_ids = array();
2037
-		while($user = Database::fetch_array($result)) {
2037
+		while ($user = Database::fetch_array($result)) {
2038 2038
 			$blog_member_ids[] = $user['user_id'];
2039 2039
 		}
2040 2040
 
2041 2041
 		// Set table headers
2042
-		$column_header[] = array ('', false, '');
2042
+		$column_header[] = array('', false, '');
2043 2043
 		if ($is_western_name_order) {
2044 2044
 			$column_header[] = array(get_lang('FirstName'), true, '');
2045 2045
 			$column_header[] = array(get_lang('LastName'), true, '');
@@ -2059,13 +2059,13 @@  discard block
 block discarded – undo
2059 2059
 
2060 2060
 		// Add users that are not in this blog to the list.
2061 2061
 		foreach ($student_list as $key=>$user) {
2062
-			if(isset($user['id_user'])) {
2062
+			if (isset($user['id_user'])) {
2063 2063
 				$user['user_id'] = $user['id_user'];
2064 2064
 			}
2065
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2065
+			if (!in_array($user['user_id'], $blog_member_ids)) {
2066 2066
 				$a_infosUser = api_get_user_info($user['user_id']);
2067
-				$row = array ();
2068
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2067
+				$row = array();
2068
+				$row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>';
2069 2069
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2070 2070
 				if ($is_western_name_order) {
2071 2071
 					$row[] = $a_infosUser["firstname"];
@@ -2077,8 +2077,8 @@  discard block
 block discarded – undo
2077 2077
 				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2078 2078
 
2079 2079
 				//Link to register users
2080
-				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2081
-					$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>";
2080
+				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) {
2081
+					$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>";
2082 2082
 				} else {
2083 2083
 					$row[] = '';
2084 2084
 				}
@@ -2089,20 +2089,20 @@  discard block
 block discarded – undo
2089 2089
 		// Display
2090 2090
 		$query_vars['action'] = 'manage_members';
2091 2091
 		$query_vars['blog_id'] = $blog_id;
2092
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2093
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2092
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
2093
+			Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2094 2094
 			$link = '';
2095
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2095
+			$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2096 2096
 			$link .= "blog_id=$blog_id&";
2097 2097
 
2098
-			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2099
-			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2100
-			echo get_lang('WithSelected') . ' : ';
2098
+			echo '<a href="blog.php?'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - ';
2099
+			echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
2100
+			echo get_lang('WithSelected').' : ';
2101 2101
 			echo '<select name="action">';
2102
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2102
+			echo '<option value="select_subscribe">'.get_lang('Register').'</option>';
2103 2103
 			echo '</select>';
2104 2104
 			echo '<input type="hidden" name="register" value="true" />';
2105
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2105
+			echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2106 2106
 		echo '</form>';
2107 2107
 	}
2108 2108
 
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 	 *
2116 2116
 	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2117 2117
 	 */
2118
-	public static function display_form_user_unsubscribe ($blog_id)
2118
+	public static function display_form_user_unsubscribe($blog_id)
2119 2119
 	{
2120 2120
 		$_user = api_get_user_info();
2121 2121
 		$is_western_name_order = api_is_western_name_order();
@@ -2128,34 +2128,34 @@  discard block
 block discarded – undo
2128 2128
 
2129 2129
 		$properties["width"] = "100%";
2130 2130
 		//table column titles
2131
-		$column_header[] = array ('', false, '');
2131
+		$column_header[] = array('', false, '');
2132 2132
 		if ($is_western_name_order) {
2133
-			$column_header[] = array (get_lang('FirstName'), true, '');
2134
-			$column_header[] = array (get_lang('LastName'), true, '');
2133
+			$column_header[] = array(get_lang('FirstName'), true, '');
2134
+			$column_header[] = array(get_lang('LastName'), true, '');
2135 2135
 		} else {
2136
-			$column_header[] = array (get_lang('LastName'), true, '');
2137
-			$column_header[] = array (get_lang('FirstName'), true, '');
2136
+			$column_header[] = array(get_lang('LastName'), true, '');
2137
+			$column_header[] = array(get_lang('FirstName'), true, '');
2138 2138
 		}
2139
-		$column_header[] = array (get_lang('Email'), false, '');
2140
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2141
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2139
+		$column_header[] = array(get_lang('Email'), false, '');
2140
+		$column_header[] = array(get_lang('TaskManager'), true, '');
2141
+		$column_header[] = array(get_lang('UnRegister'), false, '');
2142 2142
 
2143 2143
 		$course_id = api_get_course_int_id();
2144 2144
 
2145 2145
 		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2146 2146
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2147 2147
                 ON user.user_id = blogs_rel_user.user_id
2148
-                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2148
+                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int) $blog_id."'";
2149 2149
 
2150 2150
 		if (!($sql_result = Database::query($sql))) {
2151 2151
 			return false;
2152 2152
 		}
2153 2153
 
2154
-		$user_data = array ();
2154
+		$user_data = array();
2155 2155
 
2156 2156
 		while ($myrow = Database::fetch_array($sql_result)) {
2157
-			$row = array ();
2158
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2157
+			$row = array();
2158
+			$row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>';
2159 2159
 			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2160 2160
 			if ($is_western_name_order) {
2161 2161
 				$row[] = $myrow["firstname"];
@@ -2167,19 +2167,19 @@  discard block
 block discarded – undo
2167 2167
 			$row[] = Display::icon_mailto_link($myrow["email"]);
2168 2168
 
2169 2169
 			$sql = "SELECT bt.title task
2170
-					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2171
-					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2170
+					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu
2171
+					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt
2172 2172
 					ON btu.task_id = bt.task_id
2173 2173
 					WHERE 	btu.c_id 	= $course_id  AND
2174 2174
 							bt.c_id 	= $course_id  AND
2175 2175
 							btu.blog_id = $blog_id AND
2176
-							btu.user_id = " . $myrow['user_id'];
2176
+							btu.user_id = ".$myrow['user_id'];
2177 2177
 			$sql_res = Database::query($sql);
2178 2178
 
2179 2179
 			$task = '';
2180 2180
 
2181
-			while($r = Database::fetch_array($sql_res)) {
2182
-				$task .= stripslashes($r['task']) . ', ';
2181
+			while ($r = Database::fetch_array($sql_res)) {
2182
+				$task .= stripslashes($r['task']).', ';
2183 2183
 			}
2184 2184
 			//echo $task;
2185 2185
 			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
 			//Link to register users
2188 2188
 
2189 2189
 			if ($myrow["user_id"] != $_user['user_id']) {
2190
-				$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>";
2190
+				$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>";
2191 2191
 			} else {
2192 2192
 				$row[] = '';
2193 2193
 			}
@@ -2197,20 +2197,20 @@  discard block
 block discarded – undo
2197 2197
 
2198 2198
 		$query_vars['action'] = 'manage_members';
2199 2199
 		$query_vars['blog_id'] = $blog_id;
2200
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2201
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2200
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
2201
+		Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2202 2202
 		$link = '';
2203
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2203
+		$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2204 2204
 		$link .= "blog_id=$blog_id&";
2205 2205
 
2206
-		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2207
-		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2208
-		echo get_lang('WithSelected') . ' : ';
2206
+		echo '<a href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - ';
2207
+		echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
2208
+		echo get_lang('WithSelected').' : ';
2209 2209
 		echo '<select name="action">';
2210
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2210
+		echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>';
2211 2211
 		echo '</select>';
2212 2212
 		echo '<input type="hidden" name="unregister" value="true" />';
2213
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2213
+		echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2214 2214
 		echo '</form>';
2215 2215
 	}
2216 2216
 
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 	 *
2221 2221
 	 * @param Integer $blog_id
2222 2222
 	 */
2223
-	public static function display_form_user_rights ($blog_id)
2223
+	public static function display_form_user_rights($blog_id)
2224 2224
     {
2225 2225
 		echo '<legend>'.get_lang('RightsManager').'</legend>';
2226 2226
 		echo '<br />';
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 		$form = new FormValidator(
2241 2241
 			'add_post',
2242 2242
 			'post',
2243
-			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(),
2243
+			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(),
2244 2244
 			null,
2245 2245
 			array('enctype' => 'multipart/form-data')
2246 2246
 		);
@@ -2308,21 +2308,21 @@  discard block
 block discarded – undo
2308 2308
 		$course_id = api_get_course_int_id();
2309 2309
 
2310 2310
 		//Handle leap year
2311
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2311
+		$numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2312 2312
 
2313
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2313
+		if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2314 2314
 			$numberofdays[2] = 29;
2315 2315
 
2316 2316
 		//Get the first day of the month
2317 2317
 		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2318
-		$monthName = $MonthsLong[$month-1];
2318
+		$monthName = $MonthsLong[$month - 1];
2319 2319
 
2320 2320
 		//Start the week on monday
2321 2321
 		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2322 2322
 		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2323 2323
 		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2324
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2325
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2324
+		$backwardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
2325
+		$forewardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
2326 2326
 
2327 2327
 		// Get posts for this month
2328 2328
 		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
@@ -2331,15 +2331,15 @@  discard block
 block discarded – undo
2331 2331
 				ON post.author_id = user.user_id
2332 2332
 				WHERE
2333 2333
 					post.c_id = $course_id AND
2334
-					post.blog_id = '".(int)$blog_id."' AND
2335
-					MONTH(date_creation) = '".(int)$month."' AND
2336
-					YEAR(date_creation) = '".(int)$year."'
2334
+					post.blog_id = '".(int) $blog_id."' AND
2335
+					MONTH(date_creation) = '".(int) $month."' AND
2336
+					YEAR(date_creation) = '".(int) $year."'
2337 2337
 				ORDER BY date_creation";
2338 2338
 		$result = Database::query($sql);
2339 2339
 
2340 2340
 		// We will create an array of days on which there are posts.
2341
-		if( Database::num_rows($result) > 0) {
2342
-			while($blog_post = Database::fetch_array($result)) {
2341
+		if (Database::num_rows($result) > 0) {
2342
+			while ($blog_post = Database::fetch_array($result)) {
2343 2343
 				// If the day of this post is not yet in the array, add it.
2344 2344
 				if (!in_array($blog_post['post_day'], $posts))
2345 2345
 					$posts[] = $blog_post['post_day'];
@@ -2356,9 +2356,9 @@  discard block
 block discarded – undo
2356 2356
 					task_rel_user.c_id = $course_id AND
2357 2357
 					task.c_id = $course_id AND
2358 2358
 					blog.c_id = $course_id AND
2359
-					task_rel_user.user_id = '".(int)$_user['user_id']."' AND
2360
-					MONTH(target_date) = '".(int)$month."' AND
2361
-					YEAR(target_date) = '".(int)$year."'
2359
+					task_rel_user.user_id = '".(int) $_user['user_id']."' AND
2360
+					MONTH(target_date) = '".(int) $month."' AND
2361
+					YEAR(target_date) = '".(int) $year."'
2362 2362
 				ORDER BY target_date ASC";
2363 2363
 			$result = Database::query($sql);
2364 2364
 
@@ -2381,7 +2381,7 @@  discard block
 block discarded – undo
2381 2381
 
2382 2382
 		echo "<tr>\n";
2383 2383
 
2384
-		for($ii = 1; $ii < 8; $ii ++)
2384
+		for ($ii = 1; $ii < 8; $ii++)
2385 2385
 			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2386 2386
 
2387 2387
 		echo "</tr>";
@@ -2391,24 +2391,24 @@  discard block
 block discarded – undo
2391 2391
 
2392 2392
 		while ($curday <= $numberofdays[$month]) {
2393 2393
 			echo "<tr>";
2394
-			for ($ii = 0; $ii < 7; $ii ++) {
2394
+			for ($ii = 0; $ii < 7; $ii++) {
2395 2395
 				if (($curday == -1) && ($ii == $startdayofweek))
2396 2396
 					$curday = 1;
2397 2397
 
2398 2398
 			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2399
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2399
+					$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
2400 2400
 					$dayheader = "$curday";
2401 2401
 
2402
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2402
+					if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2403 2403
 						$dayheader = "$curday";
2404 2404
 						$class = "class=\"days_today\"";
2405 2405
 					}
2406 2406
 
2407
-					echo "<td " . $class.">";
2407
+					echo "<td ".$class.">";
2408 2408
 
2409 2409
 					// If there are posts on this day, create a filter link.
2410
-					if(in_array($curday, $posts))
2411
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2410
+					if (in_array($curday, $posts))
2411
+						echo '<a href="blog.php?blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang('ViewPostsOfThisDay').'">'.$curday.'</a>';
2412 2412
 					else
2413 2413
 						echo $dayheader;
2414 2414
 
@@ -2416,14 +2416,14 @@  discard block
 block discarded – undo
2416 2416
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2417 2417
 							// Add tasks to calendar
2418 2418
 							foreach ($tasks[$curday] as $task) {
2419
-								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2420
-								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2419
+								echo '<a href="blog.php?action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes($task['task_id']).'" title="'.$task['title'].' : '.get_lang('InBlog').' : '.$task['blog_name'].' - '.get_lang('ExecuteThisTask').'">
2420
+								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask').'" /></a>';
2421 2421
 							}
2422 2422
 						}
2423 2423
 					}
2424 2424
 
2425 2425
 					echo "</td>";
2426
-					$curday ++;
2426
+					$curday++;
2427 2427
 				} else
2428 2428
 					echo "<td>&nbsp;</td>";
2429 2429
 			}
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 	public static function display_edit_blog_form($blog_id)
2462 2462
 	{
2463 2463
 	    $course_id = api_get_course_int_id();
2464
-		$blog_id= intval($blog_id);
2464
+		$blog_id = intval($blog_id);
2465 2465
 		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2466 2466
 
2467 2467
 		$sql = "SELECT blog_id, blog_name, blog_subtitle
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2477 2477
 		}
2478 2478
 
2479
-        $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2479
+        $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2480 2480
         $form->addElement('header', get_lang('EditBlog'));
2481 2481
         $form->addElement('text', 'blog_name', get_lang('Title'));
2482 2482
         $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle'));
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 		$result = Database::query($sql);
2514 2514
 		$list_info = array();
2515 2515
 		if (Database::num_rows($result)) {
2516
-			while ($row_project=Database::fetch_row($result)) {
2517
-				$list_info[]=$row_project;
2516
+			while ($row_project = Database::fetch_row($result)) {
2517
+				$list_info[] = $row_project;
2518 2518
 			}
2519 2519
 		}
2520 2520
 
@@ -2526,39 +2526,39 @@  discard block
 block discarded – undo
2526 2526
 				// Validation when belongs to a session
2527 2527
 				$session_img = api_get_session_image($info_log[4], $_user['status']);
2528 2528
 
2529
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2529
+				$url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq();
2530 2530
 				$title = $info_log[0];
2531 2531
                         $image = Display::return_icon('blog.png', $title);
2532
-    			$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;
2532
+    			$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;
2533 2533
 
2534 2534
 				$list_body_blog[] = $list_name;
2535 2535
 				$list_body_blog[] = $info_log[1];
2536 2536
 
2537
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2538
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2539
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2540
-                                $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2537
+				$visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible';
2538
+				$visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible';
2539
+			 	$my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">';
2540
+                                $my_image .= Display::return_icon('edit.png', get_lang('EditBlog'));
2541 2541
 
2542
-				$my_image.= "</a>\n";
2543
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2544
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2545
-                                $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2542
+				$my_image .= "</a>\n";
2543
+				$my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" ';
2544
+				$my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >';
2545
+                                $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2546 2546
 
2547
-				$my_image.= "</a>\n";
2548
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2549
-                                $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2547
+				$my_image .= "</a>\n";
2548
+				$my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">';
2549
+                                $my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info));
2550 2550
 
2551
-				$my_image.= "</a>\n";
2551
+				$my_image .= "</a>\n";
2552 2552
 
2553
-				$list_body_blog[]=$my_image;
2553
+				$list_body_blog[] = $my_image;
2554 2554
 
2555
-				$list_content_blog[]=$list_body_blog;
2555
+				$list_content_blog[] = $list_body_blog;
2556 2556
 				$list_body_blog = array();
2557 2557
 
2558 2558
 			}
2559
-			$parameters='';
2559
+			$parameters = '';
2560 2560
 			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2561
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2561
+			$table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project');
2562 2562
 			//$table->set_additional_parameters($parameters);
2563 2563
 			$table->set_header(0, get_lang('Title'));
2564 2564
 			$table->set_header(1, get_lang('SubTitle'));
@@ -2583,34 +2583,34 @@  discard block
 block discarded – undo
2583 2583
  * @author Julio Montoya Dokeos
2584 2584
  * @version avril 2008, dokeos 1.8.5
2585 2585
  */
2586
-function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2586
+function get_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2587 2587
 {
2588 2588
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2589 2589
 
2590 2590
 	$blog_id = intval($blog_id);
2591 2591
 	$comment_id = intval($comment_id);
2592 2592
 	$post_id = intval($post_id);
2593
-	$row=array();
2594
-	$where='';
2593
+	$row = array();
2594
+	$where = '';
2595 2595
 	if (!empty ($post_id) && is_numeric($post_id)) {
2596
-		$where.=' AND post_id ="'.$post_id.'" ';
2596
+		$where .= ' AND post_id ="'.$post_id.'" ';
2597 2597
 	}
2598 2598
 
2599 2599
 	if (!empty ($comment_id) && is_numeric($comment_id)) {
2600 2600
 		if (!empty ($post_id)) {
2601
-			$where.= ' AND ';
2601
+			$where .= ' AND ';
2602 2602
 		}
2603
-		$where.=' comment_id ="'.$comment_id.'" ';
2603
+		$where .= ' comment_id ="'.$comment_id.'" ';
2604 2604
 	}
2605 2605
 
2606 2606
     $course_id = api_get_course_int_id();
2607 2607
 
2608
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2608
+	$sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.'
2609 2609
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2610 2610
 
2611
-	$result=Database::query($sql);
2612
-	if (Database::num_rows($result)!=0) {
2613
-		$row=Database::fetch_array($result);
2611
+	$result = Database::query($sql);
2612
+	if (Database::num_rows($result) != 0) {
2613
+		$row = Database::fetch_array($result);
2614 2614
 	}
2615 2615
 	return $row;
2616 2616
 }
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
  * @version avril 2008, dokeos 1.8.5
2625 2625
  */
2626 2626
 
2627
-function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2627
+function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2628 2628
 {
2629 2629
 	$_course = api_get_course_info();
2630 2630
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
@@ -2648,22 +2648,22 @@  discard block
 block discarded – undo
2648 2648
     }
2649 2649
 
2650 2650
 	// delete all files in directory
2651
-	$courseDir   = $_course['path'].'/upload/blog';
2651
+	$courseDir = $_course['path'].'/upload/blog';
2652 2652
 	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2653 2653
 	$updir = $sys_course_path.$courseDir;
2654 2654
 
2655 2655
 	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2656 2656
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2657
-	$result=Database::query($sql);
2657
+	$result = Database::query($sql);
2658 2658
 
2659
-	while ($row=Database::fetch_row($result)) {
2660
-		$file=$updir.'/'.$row[0];
2661
-		if (Security::check_abs_path($file,$updir) )
2659
+	while ($row = Database::fetch_row($result)) {
2660
+		$file = $updir.'/'.$row[0];
2661
+		if (Security::check_abs_path($file, $updir))
2662 2662
 		{
2663 2663
 			@ unlink($file);
2664 2664
 		}
2665 2665
 	}
2666
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2666
+	$sql = 'DELETE FROM '.$blog_table_attachment.'
2667 2667
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2668 2668
 	Database::query($sql);
2669 2669
 }
@@ -2676,8 +2676,8 @@  discard block
 block discarded – undo
2676 2676
 function get_blog_post_from_user($course_code, $user_id)
2677 2677
 {
2678 2678
 	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2679
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2680
-	$course_info 	= api_get_course_info($course_code);
2679
+	$tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS);
2680
+	$course_info = api_get_course_info($course_code);
2681 2681
 	$course_id 		= $course_info['real_id'];
2682 2682
 
2683 2683
 	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
@@ -2692,13 +2692,13 @@  discard block
 block discarded – undo
2692 2692
 	$result = Database::query($sql);
2693 2693
 	$return_data = '';
2694 2694
 
2695
-	if (Database::num_rows($result)!=0) {
2696
-		while ($row=Database::fetch_array($result)) {
2697
-			$return_data.=  '<div class="clear"></div><br />';
2698
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
-			$return_data.=  '<br / >';
2700
-			$return_data.= $row['full_text'];
2701
-			$return_data.= '<br /><br />';
2695
+	if (Database::num_rows($result) != 0) {
2696
+		while ($row = Database::fetch_array($result)) {
2697
+			$return_data .= '<div class="clear"></div><br />';
2698
+			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png', get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
+			$return_data .= '<br / >';
2700
+			$return_data .= $row['full_text'];
2701
+			$return_data .= '<br /><br />';
2702 2702
 		}
2703 2703
 	}
2704 2704
 	return $return_data;
@@ -2728,14 +2728,14 @@  discard block
 block discarded – undo
2728 2728
 			ORDER BY blog_name";
2729 2729
 	$result = Database::query($sql);
2730 2730
 	$return_data = '';
2731
-	if (Database::num_rows($result)!=0) {
2732
-		while ($row=Database::fetch_array($result)) {
2733
-			$return_data.=  '<div class="clear"></div><br />';
2734
-			$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"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
-			$return_data.=  '<br / >';
2731
+	if (Database::num_rows($result) != 0) {
2732
+		while ($row = Database::fetch_array($result)) {
2733
+			$return_data .= '<div class="clear"></div><br />';
2734
+			$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"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
+			$return_data .= '<br / >';
2736 2736
 			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2737
-			$return_data.=  $row['comment'];
2738
-			$return_data.=  '<br />';
2737
+			$return_data .= $row['comment'];
2738
+			$return_data .= '<br />';
2739 2739
 		}
2740 2740
 	}
2741 2741
 	return $return_data;
Please login to merge, or discard this patch.
Braces   +32 added lines, -22 removed lines patch added patch discarded remove patch
@@ -997,14 +997,17 @@  discard block
 block discarded – undo
997 997
 
998 998
 		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
999 999
 
1000
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1001
-			$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') . '"><img src="../img/edit.gif" /></a>';
1000
+		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
1001
+					$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') . '"><img src="../img/edit.gif" /></a>';
1002
+		}
1002 1003
 
1003
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1004
-			$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;"><img src="../img/delete.gif" border="0" /></a>';
1004
+		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
1005
+					$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;"><img src="../img/delete.gif" border="0" /></a>';
1006
+		}
1005 1007
 
1006
-		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1007
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1008
+		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) {
1009
+					$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1010
+		}
1008 1011
 
1009 1012
 		$blog_post_text=stripslashes($blog_post_text);
1010 1013
 
@@ -1632,8 +1635,9 @@  discard block
 block discarded – undo
1632 1635
 
1633 1636
 						$arrPermissions = array();
1634 1637
 
1635
-						while ($row = Database::fetch_array($result))
1636
-							$arrPermissions[] = $row['action'];
1638
+						while ($row = Database::fetch_array($result)) {
1639
+													$arrPermissions[] = $row['action'];
1640
+						}
1637 1641
 
1638 1642
 						    echo '<tr>';
1639 1643
 							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
@@ -2310,8 +2314,9 @@  discard block
 block discarded – undo
2310 2314
 		//Handle leap year
2311 2315
 		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2312 2316
 
2313
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2314
-			$numberofdays[2] = 29;
2317
+		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) {
2318
+					$numberofdays[2] = 29;
2319
+		}
2315 2320
 
2316 2321
 		//Get the first day of the month
2317 2322
 		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
@@ -2341,8 +2346,9 @@  discard block
 block discarded – undo
2341 2346
 		if( Database::num_rows($result) > 0) {
2342 2347
 			while($blog_post = Database::fetch_array($result)) {
2343 2348
 				// If the day of this post is not yet in the array, add it.
2344
-				if (!in_array($blog_post['post_day'], $posts))
2345
-					$posts[] = $blog_post['post_day'];
2349
+				if (!in_array($blog_post['post_day'], $posts)) {
2350
+									$posts[] = $blog_post['post_day'];
2351
+				}
2346 2352
 			}
2347 2353
 		}
2348 2354
 
@@ -2381,8 +2387,9 @@  discard block
 block discarded – undo
2381 2387
 
2382 2388
 		echo "<tr>\n";
2383 2389
 
2384
-		for($ii = 1; $ii < 8; $ii ++)
2385
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2390
+		for($ii = 1; $ii < 8; $ii ++) {
2391
+					echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2392
+		}
2386 2393
 
2387 2394
 		echo "</tr>";
2388 2395
 
@@ -2392,8 +2399,9 @@  discard block
 block discarded – undo
2392 2399
 		while ($curday <= $numberofdays[$month]) {
2393 2400
 			echo "<tr>";
2394 2401
 			for ($ii = 0; $ii < 7; $ii ++) {
2395
-				if (($curday == -1) && ($ii == $startdayofweek))
2396
-					$curday = 1;
2402
+				if (($curday == -1) && ($ii == $startdayofweek)) {
2403
+									$curday = 1;
2404
+				}
2397 2405
 
2398 2406
 			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2399 2407
 					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
@@ -2407,10 +2415,11 @@  discard block
 block discarded – undo
2407 2415
 					echo "<td " . $class.">";
2408 2416
 
2409 2417
 					// If there are posts on this day, create a filter link.
2410
-					if(in_array($curday, $posts))
2411
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2412
-					else
2413
-						echo $dayheader;
2418
+					if(in_array($curday, $posts)) {
2419
+											echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2420
+					} else {
2421
+											echo $dayheader;
2422
+					}
2414 2423
 
2415 2424
 					if (count($tasks) > 0) {
2416 2425
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
@@ -2424,8 +2433,9 @@  discard block
 block discarded – undo
2424 2433
 
2425 2434
 					echo "</td>";
2426 2435
 					$curday ++;
2427
-				} else
2428
-					echo "<td>&nbsp;</td>";
2436
+				} else {
2437
+									echo "<td>&nbsp;</td>";
2438
+				}
2429 2439
 			}
2430 2440
 			echo "</tr>";
2431 2441
 		}
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.
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.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * File: Browser.php
4
- * Author: Chris Schuld (http://chrisschuld.com/)
5
- * Last Modified: August 20th, 2010
6
- * @version 1.9
7
- * @package PegasusPHP
8
- *
9
- * Copyright (C) 2008-2010 Chris Schuld  ([email protected])
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License as
13
- * published by the Free Software Foundation; either version 2 of
14
- * the License, or (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
- * GNU General Public License for more details at:
20
- * http://www.gnu.org/copyleft/gpl.html
21
- *
22
- *
23
- * Typical Usage:
24
- *
25
- *   $browser = new Browser();
26
- *   if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
27
- *    echo 'You have FireFox version 2 or greater';
28
- *   }
29
- *
30
- * User Agents Sampled from: http://www.useragentstring.com/
31
- *
32
- * This implementation is based on the original work from Gary White
33
- * http://apptools.com/phptools/browser/
34
- * Git and Packagist info: https://github.com/cbschuld/Browser.php
35
- */
3
+     * File: Browser.php
4
+     * Author: Chris Schuld (http://chrisschuld.com/)
5
+     * Last Modified: August 20th, 2010
6
+     * @version 1.9
7
+     * @package PegasusPHP
8
+     *
9
+     * Copyright (C) 2008-2010 Chris Schuld  ([email protected])
10
+     *
11
+     * This program is free software; you can redistribute it and/or
12
+     * modify it under the terms of the GNU General Public License as
13
+     * published by the Free Software Foundation; either version 2 of
14
+     * the License, or (at your option) any later version.
15
+     *
16
+     * This program is distributed in the hope that it will be useful,
17
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+     * GNU General Public License for more details at:
20
+     * http://www.gnu.org/copyleft/gpl.html
21
+     *
22
+     *
23
+     * Typical Usage:
24
+     *
25
+     *   $browser = new Browser();
26
+     *   if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
27
+     *    echo 'You have FireFox version 2 or greater';
28
+     *   }
29
+     *
30
+     * User Agents Sampled from: http://www.useragentstring.com/
31
+     *
32
+     * This implementation is based on the original work from Gary White
33
+     * http://apptools.com/phptools/browser/
34
+     * Git and Packagist info: https://github.com/cbschuld/Browser.php
35
+     */
36 36
 
37 37
 class Browser
38 38
 {
@@ -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.