Passed
Push — 1.10.x ( 7e3041...c55112 )
by
unknown
237:51 queued 190:59
created
main/inc/lib/agenda.lib.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1482,12 +1482,12 @@  discard block
 block discarded – undo
1482 1482
             }
1483 1483
 
1484 1484
             if (empty($session_id)) {
1485
-                $sessionCondition =  "
1485
+                $sessionCondition = "
1486 1486
                 (
1487 1487
                     agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0)
1488 1488
                 ) ";
1489 1489
             } else {
1490
-                $sessionCondition =  "
1490
+                $sessionCondition = "
1491 1491
                 (
1492 1492
                     agenda.session_id = $session_id AND
1493 1493
                     ip.session_id = $session_id
@@ -1526,13 +1526,13 @@  discard block
 block discarded – undo
1526 1526
             }
1527 1527
 
1528 1528
             if (empty($session_id)) {
1529
-                $sessionCondition =  "
1529
+                $sessionCondition = "
1530 1530
                 (
1531 1531
                     agenda.session_id = 0 AND
1532 1532
                     (ip.session_id IS NULL OR ip.session_id = 0)
1533 1533
                 ) ";
1534 1534
             } else {
1535
-                $sessionCondition =  "
1535
+                $sessionCondition = "
1536 1536
                 (
1537 1537
                     agenda.session_id = $session_id AND
1538 1538
                     ip.session_id = $session_id
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1585 1585
                 $event = array();
1586 1586
                 $event['id'] = 'course_'.$row['id'];
1587
-                $event['unique_id']  = $row['iid'];
1587
+                $event['unique_id'] = $row['iid'];
1588 1588
                 // To avoid doubles
1589 1589
                 if (in_array($event['unique_id'], $eventsAdded)) {
1590 1590
                     continue;
@@ -2661,8 +2661,8 @@  discard block
 block discarded – undo
2661 2661
 
2662 2662
                 $startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e'));
2663 2663
                 $endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e'));
2664
-                $title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8');
2665
-                $description = api_convert_encoding((string)$event->description, $charset, 'UTF-8');
2664
+                $title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8');
2665
+                $description = api_convert_encoding((string) $event->description, $charset, 'UTF-8');
2666 2666
 
2667 2667
                 $id = $this->addEvent(
2668 2668
                     $startDateTime,
@@ -2804,7 +2804,7 @@  discard block
 block discarded – undo
2804 2804
 							ORDER BY start_date ";
2805 2805
             } else {
2806 2806
                 // if the user is not an administrator of that course
2807
-                if (is_array($group_memberships) && count($group_memberships)>0) {
2807
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
2808 2808
                     $sqlquery = "SELECT	agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
2809 2809
 								FROM ".$TABLEAGENDA." agenda,
2810 2810
 									".$TABLE_ITEMPROPERTY." ip
@@ -2834,14 +2834,14 @@  discard block
 block discarded – undo
2834 2834
                 $agendaday = -1;
2835 2835
                 if ($item['start_date'] != '0000-00-00 00:00:00') {
2836 2836
                     $item['start_date'] = api_get_local_time($item['start_date']);
2837
-                    $item['start_date_tms']  = api_strtotime($item['start_date']);
2837
+                    $item['start_date_tms'] = api_strtotime($item['start_date']);
2838 2838
                     $agendaday = date("j", $item['start_date_tms']);
2839 2839
                 }
2840 2840
                 if ($item['end_date'] != '0000-00-00 00:00:00') {
2841 2841
                     $item['end_date'] = api_get_local_time($item['end_date']);
2842 2842
                 }
2843 2843
 
2844
-                $url  = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2844
+                $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2845 2845
 
2846 2846
                 $item['url'] = $url;
2847 2847
                 $item['course_name'] = $array_course_info['title'];
@@ -2853,9 +2853,9 @@  discard block
 block discarded – undo
2853 2853
         }
2854 2854
 
2855 2855
         // sorting by hour for every day
2856
-        $agendaitems = array ();
2856
+        $agendaitems = array();
2857 2857
         while (list ($agendaday, $tmpitems) = each($items)) {
2858
-            if(!isset($agendaitems[$agendaday])) {
2858
+            if (!isset($agendaitems[$agendaday])) {
2859 2859
                 $agendaitems[$agendaday] = '';
2860 2860
             }
2861 2861
             sort($tmpitems);
@@ -3029,9 +3029,9 @@  discard block
 block discarded – undo
3029 3029
             $end_year = $start_end_day_of_week['end']['year'];
3030 3030
             // in sql statements you have to use year-month-day for date calculations
3031 3031
             $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
3032
-            $start_filter  = api_get_utc_datetime($start_filter);
3032
+            $start_filter = api_get_utc_datetime($start_filter);
3033 3033
             $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
3034
-            $end_filter  = api_get_utc_datetime($end_filter);
3034
+            $end_filter = api_get_utc_datetime($end_filter);
3035 3035
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3036 3036
         }
3037 3037
         // 3. creating the SQL statement for getting the personal agenda items in DAY view
@@ -3039,18 +3039,18 @@  discard block
 block discarded – undo
3039 3039
             // we are in day view
3040 3040
             // we could use mysql date() function but this is only available from 4.1 and higher
3041 3041
             $start_filter = $year."-".$month."-".$day." 00:00:00";
3042
-            $start_filter  = api_get_utc_datetime($start_filter);
3042
+            $start_filter = api_get_utc_datetime($start_filter);
3043 3043
             $end_filter = $year."-".$month."-".$day." 23:59:59";
3044
-            $end_filter  = api_get_utc_datetime($end_filter);
3044
+            $end_filter = api_get_utc_datetime($end_filter);
3045 3045
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3046 3046
         }
3047 3047
 
3048 3048
         $result = Database::query($sql);
3049 3049
         while ($item = Database::fetch_array($result, 'ASSOC')) {
3050 3050
 
3051
-            $time_minute 	= api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3052
-            $item['date']   = api_get_local_time($item['date']);
3053
-            $item['start_date_tms']  = api_strtotime($item['date']);
3051
+            $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3052
+            $item['date'] = api_get_local_time($item['date']);
3053
+            $item['start_date_tms'] = api_strtotime($item['date']);
3054 3054
             $item['content'] = $item['text'];
3055 3055
 
3056 3056
             // we break the date field in the database into a date and a time part
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
             $second = $agendatime[2];
3071 3071
 
3072 3072
             if ($type == 'month_view') {
3073
-                $item['calendar_type']  = 'personal';
3073
+                $item['calendar_type'] = 'personal';
3074 3074
                 $item['start_date']  	= $item['date'];
3075 3075
                 $agendaitems[$day][] 	= $item;
3076 3076
                 continue;
@@ -3095,7 +3095,7 @@  discard block
 block discarded – undo
3095 3095
                 // this is the array construction for the DAY view
3096 3096
                 $halfhour = 2 * $agendatime['0'];
3097 3097
                 if ($agendatime['1'] >= '30') {
3098
-                    $halfhour = $halfhour +1;
3098
+                    $halfhour = $halfhour + 1;
3099 3099
                 }
3100 3100
 
3101 3101
                 //Display events by list
@@ -3119,22 +3119,22 @@  discard block
 block discarded – undo
3119 3119
     {
3120 3120
         global $DaysShort, $course_path;
3121 3121
         //Handle leap year
3122
-        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3122
+        $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3123 3123
         if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
3124 3124
             $numberofdays[2] = 29;
3125 3125
         //Get the first day of the month
3126 3126
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
3127 3127
         //Start the week on monday
3128 3128
         $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
3129
-        $g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:'');
3129
+        $g_cc = (isset($_GET['courseCode']) ? $_GET['courseCode'] : '');
3130 3130
 
3131
-        $next_month = ($month == 1 ? 12 : $month -1);
3132
-        $prev_month = ($month == 12 ? 1 : $month +1);
3131
+        $next_month = ($month == 1 ? 12 : $month - 1);
3132
+        $prev_month = ($month == 12 ? 1 : $month + 1);
3133 3133
 
3134
-        $next_year = ($month == 1 ? $year -1 : $year);
3135
-        $prev_year = ($month == 12 ? $year +1 : $year);
3134
+        $next_year = ($month == 1 ? $year - 1 : $year);
3135
+        $prev_year = ($month == 12 ? $year + 1 : $year);
3136 3136
 
3137
-        if ($show_content)  {
3137
+        if ($show_content) {
3138 3138
             $back_url = Display::url(get_lang('Previous'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year);
3139 3139
             $next_url = Display::url(get_lang('Next'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year);
3140 3140
         } else {
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
         $html .= '</div>';
3152 3152
         $html .= '<table id="agenda_list2" class="table table-bordered">';
3153 3153
         $html .= '<tr>';
3154
-        for ($ii = 1; $ii < 8; $ii ++) {
3154
+        for ($ii = 1; $ii < 8; $ii++) {
3155 3155
             $html .= '<td class="weekdays">'.$DaysShort[$ii % 7].'</td>';
3156 3156
         }
3157 3157
         $html .= '</tr>';
@@ -3160,7 +3160,7 @@  discard block
 block discarded – undo
3160 3160
         $today = getdate();
3161 3161
         while ($curday <= $numberofdays[$month]) {
3162 3162
             $html .= "<tr>";
3163
-            for ($ii = 0; $ii < 7; $ii ++) {
3163
+            for ($ii = 0; $ii < 7; $ii++) {
3164 3164
                 if (($curday == -1) && ($ii == $startdayofweek)) {
3165 3165
                     $curday = 1;
3166 3166
                 }
@@ -3174,21 +3174,21 @@  discard block
 block discarded – undo
3174 3174
                     $html .= "<td ".$class.">".$dayheader;
3175 3175
 
3176 3176
                     if (!empty($agendaitems[$curday])) {
3177
-                        $items =  $agendaitems[$curday];
3178
-                        $items =  msort($items, 'start_date_tms');
3177
+                        $items = $agendaitems[$curday];
3178
+                        $items = msort($items, 'start_date_tms');
3179 3179
                         
3180
-                        foreach($items  as $value) {
3180
+                        foreach ($items  as $value) {
3181 3181
                             $value['title'] = Security::remove_XSS($value['title']);
3182 3182
                             $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);
3183 3183
                             $end_time = '';
3184 3184
 
3185 3185
                             if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') {
3186
-                                $end_time    = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3186
+                                $end_time = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3187 3187
                             }
3188 3188
                             $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i>&nbsp;'.$end_time;
3189 3189
                             $time = '<i>'.$start_time.'</i>';
3190 3190
 
3191
-                            switch($value['calendar_type']) {
3191
+                            switch ($value['calendar_type']) {
3192 3192
                                 case 'personal':
3193 3193
                                     $bg_color = '#D0E7F4';
3194 3194
                                     $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL);
@@ -3240,7 +3240,7 @@  discard block
 block discarded – undo
3240 3240
                         }
3241 3241
                     }
3242 3242
                     $html .= "</td>";
3243
-                    $curday ++;
3243
+                    $curday++;
3244 3244
                 } else {
3245 3245
                     $html .= "<td></td>";
3246 3246
                 }
@@ -3261,18 +3261,18 @@  discard block
 block discarded – undo
3261 3261
      * where datestart and dateend are in yyyyMMddhhmmss format.
3262 3262
      * @TODO Implement really personal events (from user DB) and global events (from main DB)
3263 3263
      */
3264
-    public static function get_personal_agenda_items_between_dates($user_id, $date_start='', $date_end='')
3264
+    public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '')
3265 3265
     {
3266
-        $items = array ();
3266
+        $items = array();
3267 3267
         if ($user_id != strval(intval($user_id))) { return $items; }
3268
-        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s');}
3269
-        if (empty($date_end))   { $date_end = date('Y-m-d H:i:s',mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1));}
3268
+        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s'); }
3269
+        if (empty($date_end)) { $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); }
3270 3270
         $expr = '/\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}/';
3271
-        if(!preg_match($expr,$date_start)) { return $items; }
3272
-        if(!preg_match($expr,$date_end)) { return $items; }
3271
+        if (!preg_match($expr, $date_start)) { return $items; }
3272
+        if (!preg_match($expr, $date_end)) { return $items; }
3273 3273
 
3274 3274
         // get agenda-items for every course
3275
-        $courses = api_get_user_courses($user_id,false);
3275
+        $courses = api_get_user_courses($user_id, false);
3276 3276
         foreach ($courses as $id => $course) {
3277 3277
             $c = api_get_course_info_by_id($course['real_id']);
3278 3278
             //databases of the courses
@@ -3296,9 +3296,9 @@  discard block
 block discarded – undo
3296 3296
                     " ORDER BY start_date ";
3297 3297
             } else {
3298 3298
                 // if the user is not an administrator of that course, then...
3299
-                if (is_array($group_memberships) && count($group_memberships)>0)
3299
+                if (is_array($group_memberships) && count($group_memberships) > 0)
3300 3300
                 {
3301
-                    $sqlquery = "SELECT " .
3301
+                    $sqlquery = "SELECT ".
3302 3302
                         "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref ".
3303 3303
                         " FROM ".$t_a." agenda, ".
3304 3304
                         $t_ip." ip ".
@@ -3326,13 +3326,13 @@  discard block
 block discarded – undo
3326 3326
 
3327 3327
             $result = Database::query($sqlquery);
3328 3328
             while ($item = Database::fetch_array($result)) {
3329
-                $agendaday = date("j",strtotime($item['start_date']));
3330
-                $month = date("n",strtotime($item['start_date']));
3331
-                $year = date("Y",strtotime($item['start_date']));
3329
+                $agendaday = date("j", strtotime($item['start_date']));
3330
+                $month = date("n", strtotime($item['start_date']));
3331
+                $year = date("Y", strtotime($item['start_date']));
3332 3332
                 $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
3333
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']);
3333
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']);
3334 3334
                 $start_date = $year.$month.$day.$hour.$min;
3335
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']);
3335
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']);
3336 3336
                 $end_date = $year.$month.$day.$hour.$min;
3337 3337
 
3338 3338
                 $items[] = array(
@@ -3361,7 +3361,7 @@  discard block
 block discarded – undo
3361 3361
         $user = api_get_user_id();
3362 3362
         $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE id=".$id." AND user = ".$user;
3363 3363
         $result = Database::query($sql);
3364
-        if(Database::num_rows($result)==1) {
3364
+        if (Database::num_rows($result) == 1) {
3365 3365
             $item = Database::fetch_array($result);
3366 3366
         } else {
3367 3367
             $item = null;
@@ -3383,9 +3383,9 @@  discard block
 block discarded – undo
3383 3383
         // step 2: we which day this is (0=sunday, 1=monday, ...)
3384 3384
         $number_day_in_week = date('w', $random_day_in_week);
3385 3385
         // step 3: we calculate the timestamp of the monday of the week we are in
3386
-        $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60);
3386
+        $start_timestamp = $random_day_in_week - (($number_day_in_week - 1) * 24 * 60 * 60);
3387 3387
         // step 4: we calculate the timestamp of the sunday of the week we are in
3388
-        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600;
3388
+        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week + 1) * 24 * 60 * 60) - 3600;
3389 3389
         // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year
3390 3390
         $start_day = date('j', $start_timestamp);
3391 3391
         $start_month = date('n', $start_timestamp);
Please login to merge, or discard this patch.