Completed
Pull Request — 1.11.x (#1223)
by José
199:23 queued 154:45
created
main/inc/lib/system/session.class.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
14 14
 class Session implements \ArrayAccess
15 15
 {
16 16
 
17
+    /**
18
+     * @param string $variable
19
+     */
17 20
     static function read($variable, $default = null)
18 21
     {
19 22
         return isset($_SESSION[$variable]) ? $_SESSION[$variable] : $default;
Please login to merge, or discard this patch.
main/inc/lib/system/web/request.class.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -31,6 +31,10 @@
 block discarded – undo
31 31
         return $method == 'GET';
32 32
     }
33 33
 
34
+    /**
35
+     * @param string $key
36
+     * @param string $default
37
+     */
34 38
     public static function post($key, $default = null)
35 39
     {
36 40
         return isset($_POST[$key]) ? $_POST[$key] : $default;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
16 16
     }
17 17
 
18
-    public static function has($key){
18
+    public static function has($key) {
19 19
         return isset($_REQUEST[$key]);
20 20
     }
21 21
 
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
  * @author Patrick Cool
17 17
  * @author René Haentjens, added CSV file import (October 2004)
18 18
  * @package chamilo.link
19
-
20 19
  */
21 20
 
22 21
 // Including libraries
Please login to merge, or discard this patch.
main/inc/lib/system_announcements.lib.php 3 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param int    Whether the announcement should be visible to anonymous users (1) or not (0)
307 307
 	 * @param string The language for which the announvement should be shown. Leave null for all langages
308 308
 	 * @param int    Whether to send an e-mail to all users (1) or not (0)
309
-	 * @return mixed  insert_id on success, false on failure
309
+	 * @return false|string  insert_id on success, false on failure
310 310
 	 */
311 311
     public static function add_announcement(
312 312
         $title,
@@ -648,6 +648,8 @@  discard block
 block discarded – undo
648 648
 	 * @param	int		Whether to send to all teachers (1) or not (0)
649 649
 	 * @param	int		Whether to send to all students (1) or not (0)
650 650
 	 * @param	string	Language (optional, considered for all languages if left empty)
651
+	 * @param integer|null $teacher
652
+	 * @param integer|null $student
651 653
      * @return  bool    True if the message was sent or there was no destination matching. False on database or e-mail sending error.
652 654
 	 */
653 655
 	public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
         $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
23 23
 		$userGroup = new UserGroup();
24 24
 
25
-        $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0);
25
+        $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0);
26 26
         $groups = array();
27 27
         foreach ($temp_user_groups as $user_group) {
28 28
             $groups = array_merge($groups, array($user_group['id']));
29 29
             $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id']));
30 30
         }
31 31
 
32
-        $groups_string = '('.implode($groups,',').')';
32
+        $groups_string = '('.implode($groups, ',').')';
33 33
         $now = api_get_utc_datetime();
34 34
         $sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date
35 35
 				FROM  $db_table
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
      * @param string $user_id
105 105
      * @return string
106 106
      */
107
-    public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='')
107
+    public static function display_all_announcements($visible, $id = -1, $start = 0, $user_id = '')
108 108
     {
109 109
 		$user_selected_language = api_get_interface_language();
110
-		$start	= intval($start);
110
+		$start = intval($start);
111 111
         $userGroup = new UserGroup();
112 112
 	    $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
113
-	    $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0);
113
+	    $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0);
114 114
         $groups = array();
115 115
 	    foreach ($temp_user_groups as $user_group) {
116 116
 	        $groups = array_merge($groups, array($user_group['id']));
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	    }
119 119
 
120 120
 	    // Checks if tables exists to not break platform not updated
121
-	    $groups_string = '('.implode($groups,',').')';
121
+	    $groups_string = '('.implode($groups, ',').')';
122 122
 
123 123
 		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
124
-		$now  = api_get_utc_datetime();
124
+		$now = api_get_utc_datetime();
125 125
 
126 126
 		$sql = "SELECT * FROM ".$db_table."
127 127
 				WHERE
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
             $sql .= " AND access_url_id IN ('1', '$current_access_url_id')";
153 153
 		}
154 154
 
155
-		if(!isset($_GET['start']) || $_GET['start'] == 0) {
155
+		if (!isset($_GET['start']) || $_GET['start'] == 0) {
156 156
 			$sql .= " ORDER BY date_start DESC LIMIT ".$start.",20";
157 157
 		} else {
158
-			$sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20";
158
+			$sql .= " ORDER BY date_start DESC LIMIT ".($start + 1).",20";
159 159
 		}
160 160
 		$announcements = Database::query($sql);
161 161
 		$content = '';
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public static function display_arrow($user_id)
209 209
     {
210
-		$start = (int)$_GET['start'];
211
-		$nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id);
212
-		$next = ((int)$_GET['start']+19);
213
-		$prev = ((int)$_GET['start']-19);
210
+		$start = (int) $_GET['start'];
211
+		$nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start, $user_id);
212
+		$next = ((int) $_GET['start'] + 19);
213
+		$prev = ((int) $_GET['start'] - 19);
214 214
 		$content = '';
215
-		if(!isset($_GET['start']) || $_GET['start'] == 0) {
216
-			if($nb_announcement > 20) {
215
+		if (!isset($_GET['start']) || $_GET['start'] == 0) {
216
+			if ($nb_announcement > 20) {
217 217
 				$content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>';
218 218
 			}
219 219
 		} else {
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
         $sendEmailTest = false
323 323
     ) {
324 324
 		$original_content = $content;
325
-		$a_dateS = explode(' ',$date_start);
326
-		$a_arraySD = explode('-',$a_dateS[0]);
327
-		$a_arraySH = explode(':',$a_dateS[1]);
328
-		$date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
325
+		$a_dateS = explode(' ', $date_start);
326
+		$a_arraySD = explode('-', $a_dateS[0]);
327
+		$a_arraySH = explode(':', $a_dateS[1]);
328
+		$date_start_to_compare = array_merge($a_arraySD, $a_arraySH);
329 329
 
330
-		$a_dateE = explode(' ',$date_end);
331
-		$a_arrayED = explode('-',$a_dateE[0]);
332
-		$a_arrayEH = explode(':',$a_dateE[1]);
333
-		$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
330
+		$a_dateE = explode(' ', $date_end);
331
+		$a_arrayED = explode('-', $a_dateE[0]);
332
+		$a_arrayEH = explode(':', $a_dateE[1]);
333
+		$date_end_to_compare = array_merge($a_arrayED, $a_arrayEH);
334 334
 
335 335
 		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
336 336
 
@@ -504,15 +504,15 @@  discard block
 block discarded – undo
504 504
         $send_mail = 0,
505 505
         $sendEmailTest = false
506 506
     ) {
507
-		$a_dateS = explode(' ',$date_start);
508
-		$a_arraySD = explode('-',$a_dateS[0]);
509
-		$a_arraySH = explode(':',$a_dateS[1]);
510
-		$date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
507
+		$a_dateS = explode(' ', $date_start);
508
+		$a_arraySD = explode('-', $a_dateS[0]);
509
+		$a_arraySH = explode(':', $a_dateS[1]);
510
+		$date_start_to_compare = array_merge($a_arraySD, $a_arraySH);
511 511
 
512
-		$a_dateE = explode(' ',$date_end);
513
-		$a_arrayED = explode('-',$a_dateE[0]);
514
-		$a_arrayEH = explode(':',$a_dateE[1]);
515
-		$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
512
+		$a_dateE = explode(' ', $date_end);
513
+		$a_arrayED = explode('-', $a_dateE[0]);
514
+		$a_arrayEH = explode(':', $a_dateE[1]);
515
+		$date_end_to_compare = array_merge($a_arrayED, $a_arrayEH);
516 516
 
517 517
 		$langsql = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'";
518 518
 		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
 			return false;
537 537
 		}
538 538
 
539
-	    $start    = api_get_utc_datetime($date_start);
540
-        $end      = api_get_utc_datetime($date_end);
539
+	    $start = api_get_utc_datetime($date_start);
540
+        $end = api_get_utc_datetime($date_end);
541 541
 
542 542
 		$title = Database::escape_string($title);
543 543
 		$content = Database::escape_string($content);
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
                 $sendEmailTest
561 561
             );
562 562
         } else {
563
-            if ($send_mail==1) {
563
+            if ($send_mail == 1) {
564 564
                 SystemAnnouncementManager::send_system_announcement_by_email(
565 565
                     $title,
566 566
                     $content,
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 		global $charset;
656 656
 
657 657
         $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
658
-        $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset);
658
+        $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'), '', $content)), ENT_QUOTES, $charset);
659 659
         $now = api_get_utc_datetime();
660 660
 
661 661
         if ($sendEmailTest) {
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
679 679
 		}
680 680
 
681
-		if ($teacher<> 0 AND $student <> 0) {
681
+		if ($teacher <> 0 AND $student <> 0) {
682 682
 			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
683 683
 		}
684 684
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
         // Expiration date
697 697
         $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') ";
698 698
 
699
-		if ((empty($teacher) or $teacher == '0') AND  (empty($student) or $student == '0')) {
699
+		if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) {
700 700
 			return true;
701 701
 		}
702 702
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 
708 708
         $message_sent = false;
709 709
 
710
-		while ($row = Database::fetch_array($result,'ASSOC')) {
710
+		while ($row = Database::fetch_array($result, 'ASSOC')) {
711 711
             MessageManager::send_message_simple($row['user_id'], $title, $content);
712 712
             $message_sent = true;
713 713
 		}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
         $cut_size = 500;
728 728
         $now = api_get_utc_datetime();
729 729
 
730
-        $sql = "SELECT * FROM " . $table . "
730
+        $sql = "SELECT * FROM ".$table."
731 731
 				WHERE
732 732
 				    (lang = '$user_selected_language' OR lang = '') AND
733 733
 				    ('$now' >= date_start AND '$now' <= date_end) ";
Please login to merge, or discard this patch.
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@  discard block
 block discarded – undo
10 10
     CONST VISIBLE_STUDENT = 2;
11 11
     CONST VISIBLE_TEACHER = 3;
12 12
 
13
-	/**
14
-	 * Displays all announcements
15
-	 * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
16
-	 * @param int $id The identifier of the announcement to display
17
-	 */
18
-	public static function display_announcements($visible, $id = -1)
13
+    /**
14
+     * Displays all announcements
15
+     * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
16
+     * @param int $id The identifier of the announcement to display
17
+     */
18
+    public static function display_announcements($visible, $id = -1)
19 19
     {
20
-		$user_selected_language = api_get_interface_language();
21
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
20
+        $user_selected_language = api_get_interface_language();
21
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
22 22
         $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
23
-		$userGroup = new UserGroup();
23
+        $userGroup = new UserGroup();
24 24
 
25 25
         $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0);
26 26
         $groups = array();
@@ -55,47 +55,47 @@  discard block
 block discarded – undo
55 55
                         WHERE group_id in $groups_string
56 56
                     ) ";
57 57
         }
58
-		$current_access_url_id = 1;
59
-		if (api_is_multiple_url_enabled()) {
60
-			$current_access_url_id = api_get_current_access_url_id();
61
-		}
62
-		$sql .= " AND access_url_id = '$current_access_url_id' ";
63
-		$sql .= " ORDER BY date_start DESC LIMIT 0,7";
64
-
65
-		$announcements = Database::query($sql);
66
-		if (Database::num_rows($announcements) > 0) {
67
-			$query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
68
-			$query_string = ereg_replace('&$', '', $query_string);
69
-			$url = api_get_self();
70
-			echo '<div class="system_announcements">';
71
-			echo '<h3>'.get_lang('SystemAnnouncements').'</h3>';
72
-			echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>';
73
-
74
-			while ($announcement = Database::fetch_object($announcements)) {
75
-				if ($id != $announcement->id) {
76
-					if (strlen($query_string) > 0) {
77
-						$show_url = 'news_list.php#'.$announcement->id;
78
-					} else {
79
-						$show_url = 'news_list.php#'.$announcement->id;
80
-					}
81
-			        $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
82
-					echo '<a name="'.$announcement->id.'"></a>
58
+        $current_access_url_id = 1;
59
+        if (api_is_multiple_url_enabled()) {
60
+            $current_access_url_id = api_get_current_access_url_id();
61
+        }
62
+        $sql .= " AND access_url_id = '$current_access_url_id' ";
63
+        $sql .= " ORDER BY date_start DESC LIMIT 0,7";
64
+
65
+        $announcements = Database::query($sql);
66
+        if (Database::num_rows($announcements) > 0) {
67
+            $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
68
+            $query_string = ereg_replace('&$', '', $query_string);
69
+            $url = api_get_self();
70
+            echo '<div class="system_announcements">';
71
+            echo '<h3>'.get_lang('SystemAnnouncements').'</h3>';
72
+            echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>';
73
+
74
+            while ($announcement = Database::fetch_object($announcements)) {
75
+                if ($id != $announcement->id) {
76
+                    if (strlen($query_string) > 0) {
77
+                        $show_url = 'news_list.php#'.$announcement->id;
78
+                    } else {
79
+                        $show_url = 'news_list.php#'.$announcement->id;
80
+                    }
81
+                    $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
82
+                    echo '<a name="'.$announcement->id.'"></a>
83 83
 						<div class="system_announcement">
84 84
 							<div class="system_announcement_title"><a name="ann'.$announcement->id.'" href="'.$show_url.'">'.$announcement->title.'</a></div><div class="system_announcement_date">'.$display_date.'</div>
85 85
 					  	</div>';
86
-				} else {
87
-					echo '<div class="system_announcement">
86
+                } else {
87
+                    echo '<div class="system_announcement">
88 88
 							<div class="system_announcement_title">'
89
-								.$announcement->display_date.'
89
+                                .$announcement->display_date.'
90 90
 								<a name="ann'.$announcement->id.'" href="'.$url.'?'.$query_string.'#ann'.$announcement->id.'">'.$announcement->title.'</a>
91 91
 							</div>';
92
-				}
93
-				echo '<br />';
94
-			}
95
-			echo '</div>';
96
-		}
97
-		return;
98
-	}
92
+                }
93
+                echo '<br />';
94
+            }
95
+            echo '</div>';
96
+        }
97
+        return;
98
+    }
99 99
 
100 100
     /**
101 101
      * @param $visible
@@ -106,100 +106,100 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='')
108 108
     {
109
-		$user_selected_language = api_get_interface_language();
110
-		$start	= intval($start);
109
+        $user_selected_language = api_get_interface_language();
110
+        $start	= intval($start);
111 111
         $userGroup = new UserGroup();
112
-	    $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
113
-	    $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0);
112
+        $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
113
+        $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0);
114 114
         $groups = array();
115
-	    foreach ($temp_user_groups as $user_group) {
116
-	        $groups = array_merge($groups, array($user_group['id']));
117
-	        $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id']));
118
-	    }
115
+        foreach ($temp_user_groups as $user_group) {
116
+            $groups = array_merge($groups, array($user_group['id']));
117
+            $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id']));
118
+        }
119 119
 
120
-	    // Checks if tables exists to not break platform not updated
121
-	    $groups_string = '('.implode($groups,',').')';
120
+        // Checks if tables exists to not break platform not updated
121
+        $groups_string = '('.implode($groups,',').')';
122 122
 
123
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
124
-		$now  = api_get_utc_datetime();
123
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
124
+        $now  = api_get_utc_datetime();
125 125
 
126
-		$sql = "SELECT * FROM ".$db_table."
126
+        $sql = "SELECT * FROM ".$db_table."
127 127
 				WHERE
128 128
 				    (lang = '$user_selected_language' OR lang IS NULL) AND
129 129
 				    ( '$now' >= date_start AND '$now' <= date_end) ";
130 130
 
131
-		switch ($visible) {
132
-			case self::VISIBLE_GUEST :
133
-				$sql .= " AND visible_guest = 1 ";
134
-				break;
135
-			case self::VISIBLE_STUDENT :
136
-				$sql .= " AND visible_student = 1 ";
137
-				break;
138
-			case self::VISIBLE_TEACHER :
139
-				$sql .= " AND visible_teacher = 1 ";
140
-				break;
141
-		}
142
-
143
-	    if (count($groups) > 0) {
131
+        switch ($visible) {
132
+            case self::VISIBLE_GUEST :
133
+                $sql .= " AND visible_guest = 1 ";
134
+                break;
135
+            case self::VISIBLE_STUDENT :
136
+                $sql .= " AND visible_student = 1 ";
137
+                break;
138
+            case self::VISIBLE_TEACHER :
139
+                $sql .= " AND visible_teacher = 1 ";
140
+                break;
141
+        }
142
+
143
+        if (count($groups) > 0) {
144 144
             $sql .= " OR id IN (
145 145
                     SELECT announcement_id FROM $tbl_announcement_group
146 146
                     WHERE group_id in $groups_string
147 147
                     ) ";
148
-	    }
148
+        }
149 149
 
150
-		if (api_is_multiple_url_enabled()) {
151
-			$current_access_url_id = api_get_current_access_url_id();
150
+        if (api_is_multiple_url_enabled()) {
151
+            $current_access_url_id = api_get_current_access_url_id();
152 152
             $sql .= " AND access_url_id IN ('1', '$current_access_url_id')";
153
-		}
154
-
155
-		if(!isset($_GET['start']) || $_GET['start'] == 0) {
156
-			$sql .= " ORDER BY date_start DESC LIMIT ".$start.",20";
157
-		} else {
158
-			$sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20";
159
-		}
160
-		$announcements = Database::query($sql);
161
-		$content = '';
162
-		if (Database::num_rows($announcements) > 0) {
163
-			$query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
164
-			$query_string = ereg_replace('&$', '', $query_string);
165
-			$url = api_get_self();
166
-			$content .= '<div class="system_announcements">';
167
-			$content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>';
168
-			$content .= '<table align="center">';
169
-				$content .= '<tr>';
170
-					$content .= '<td>';
171
-						$content .= SystemAnnouncementManager :: display_arrow($user_id);
172
-					$content .= '</td>';
173
-				$content .= '</tr>';
174
-			$content .= '</table>';
175
-			$content .= '<table align="center" border="0" width="900px">';
176
-			while ($announcement = Database::fetch_object($announcements)) {
177
-				$display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
178
-				$content .= '<tr><td>';
179
-				$content .= '<a name="'.$announcement->id.'"></a>
153
+        }
154
+
155
+        if(!isset($_GET['start']) || $_GET['start'] == 0) {
156
+            $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20";
157
+        } else {
158
+            $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20";
159
+        }
160
+        $announcements = Database::query($sql);
161
+        $content = '';
162
+        if (Database::num_rows($announcements) > 0) {
163
+            $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
164
+            $query_string = ereg_replace('&$', '', $query_string);
165
+            $url = api_get_self();
166
+            $content .= '<div class="system_announcements">';
167
+            $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>';
168
+            $content .= '<table align="center">';
169
+                $content .= '<tr>';
170
+                    $content .= '<td>';
171
+                        $content .= SystemAnnouncementManager :: display_arrow($user_id);
172
+                    $content .= '</td>';
173
+                $content .= '</tr>';
174
+            $content .= '</table>';
175
+            $content .= '<table align="center" border="0" width="900px">';
176
+            while ($announcement = Database::fetch_object($announcements)) {
177
+                $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
178
+                $content .= '<tr><td>';
179
+                $content .= '<a name="'.$announcement->id.'"></a>
180 180
 						<div class="system_announcement">
181 181
 						<h2>'.$announcement->title.'</h2><div class="system_announcement_date">'.$display_date.'</div>
182 182
 						<br />
183 183
 					  	<div class="system_announcement_content">'
184
-					  			.$announcement->content.'
184
+                                    .$announcement->content.'
185 185
 						</div>
186 186
 					  </div><br />';
187
-				$content .= '</tr></td>';
188
-			}
189
-			$content .= '</table>';
190
-
191
-			$content .= '<table align="center">';
192
-				$content .= '<tr>';
193
-					$content .= '<td>';
194
-						$content .= SystemAnnouncementManager :: display_arrow($user_id);
195
-					$content .= '</td>';
196
-				$content .= '</tr>';
197
-			$content .= '</table>';
198
-			$content .= '</div>';
199
-		}
200
-
201
-		return $content;
202
-	}
187
+                $content .= '</tr></td>';
188
+            }
189
+            $content .= '</table>';
190
+
191
+            $content .= '<table align="center">';
192
+                $content .= '<tr>';
193
+                    $content .= '<td>';
194
+                        $content .= SystemAnnouncementManager :: display_arrow($user_id);
195
+                    $content .= '</td>';
196
+                $content .= '</tr>';
197
+            $content .= '</table>';
198
+            $content .= '</div>';
199
+        }
200
+
201
+        return $content;
202
+    }
203 203
 
204 204
     /**
205 205
      * @param int $user_id
@@ -207,23 +207,23 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public static function display_arrow($user_id)
209 209
     {
210
-		$start = (int)$_GET['start'];
211
-		$nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id);
212
-		$next = ((int)$_GET['start']+19);
213
-		$prev = ((int)$_GET['start']-19);
214
-		$content = '';
215
-		if(!isset($_GET['start']) || $_GET['start'] == 0) {
216
-			if($nb_announcement > 20) {
217
-				$content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>';
218
-			}
219
-		} else {
220
-			echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>';
221
-			if ($nb_announcement > 20) {
222
-				$content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>';
223
-			}
224
-		}
225
-		return $content;
226
-	}
210
+        $start = (int)$_GET['start'];
211
+        $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id);
212
+        $next = ((int)$_GET['start']+19);
213
+        $prev = ((int)$_GET['start']-19);
214
+        $content = '';
215
+        if(!isset($_GET['start']) || $_GET['start'] == 0) {
216
+            if($nb_announcement > 20) {
217
+                $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>';
218
+            }
219
+        } else {
220
+            echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>';
221
+            if ($nb_announcement > 20) {
222
+                $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>';
223
+            }
224
+        }
225
+        return $content;
226
+    }
227 227
 
228 228
     /**
229 229
      * @param int $start
@@ -232,82 +232,82 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public static function count_nb_announcement($start = 0, $user_id = '')
234 234
     {
235
-		$start = intval($start);
236
-		$visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT;
237
-		$user_selected_language = api_get_interface_language();
238
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
239
-		$sql = 'SELECT id FROM '.$db_table.'
235
+        $start = intval($start);
236
+        $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT;
237
+        $user_selected_language = api_get_interface_language();
238
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
239
+        $sql = 'SELECT id FROM '.$db_table.'
240 240
 		        WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) ';
241
-		if (isset($user_id)) {
242
-			switch ($visibility) {
243
-				case self::VISIBLE_GUEST :
244
-					$sql .= " AND visible_guest = 1 ";
245
-					break;
246
-				case self::VISIBLE_STUDENT :
247
-					$sql .= " AND visible_student = 1 ";
248
-					break;
249
-				case self::VISIBLE_TEACHER :
250
-					$sql .= " AND visible_teacher = 1 ";
251
-					break;
252
-			}
253
- 		}
254
-
255
-		$current_access_url_id = 1;
256
-		if (api_is_multiple_url_enabled()) {
257
-			$current_access_url_id = api_get_current_access_url_id();
258
-		}
259
-		$sql .= " AND access_url_id = '$current_access_url_id' ";
260
-
261
-
262
-		$sql .= 'LIMIT '.$start.', 21';
263
-		$announcements = Database::query($sql);
264
-		$i = 0;
265
-		while ($rows = Database::fetch_array($announcements)) {
266
-			$i++;
267
-		}
268
-		return $i;
269
-	}
270
-
271
-	/**
272
-	 * Get all announcements
273
-	 * @return array An array with all available system announcements (as php
274
-	 * objects)
275
-	 */
276
-	public static function get_all_announcements()
241
+        if (isset($user_id)) {
242
+            switch ($visibility) {
243
+                case self::VISIBLE_GUEST :
244
+                    $sql .= " AND visible_guest = 1 ";
245
+                    break;
246
+                case self::VISIBLE_STUDENT :
247
+                    $sql .= " AND visible_student = 1 ";
248
+                    break;
249
+                case self::VISIBLE_TEACHER :
250
+                    $sql .= " AND visible_teacher = 1 ";
251
+                    break;
252
+            }
253
+            }
254
+
255
+        $current_access_url_id = 1;
256
+        if (api_is_multiple_url_enabled()) {
257
+            $current_access_url_id = api_get_current_access_url_id();
258
+        }
259
+        $sql .= " AND access_url_id = '$current_access_url_id' ";
260
+
261
+
262
+        $sql .= 'LIMIT '.$start.', 21';
263
+        $announcements = Database::query($sql);
264
+        $i = 0;
265
+        while ($rows = Database::fetch_array($announcements)) {
266
+            $i++;
267
+        }
268
+        return $i;
269
+    }
270
+
271
+    /**
272
+     * Get all announcements
273
+     * @return array An array with all available system announcements (as php
274
+     * objects)
275
+     */
276
+    public static function get_all_announcements()
277 277
     {
278
-		$table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
279
-		$now = api_get_utc_datetime();
280
-		$sql = "SELECT *, IF ( '$now'  >= date_start AND '$now' <= date_end, '1', '0') AS visible
278
+        $table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
279
+        $now = api_get_utc_datetime();
280
+        $sql = "SELECT *, IF ( '$now'  >= date_start AND '$now' <= date_end, '1', '0') AS visible
281 281
 				FROM $table";
282 282
 
283
-		$current_access_url_id = 1;
284
-		if (api_is_multiple_url_enabled()) {
285
-			$current_access_url_id = api_get_current_access_url_id();
286
-		}
287
-		$sql .= " WHERE access_url_id = '$current_access_url_id' ";
288
-		$sql .= " ORDER BY date_start ASC";
289
-
290
-		$announcements = Database::query($sql);
291
-		$all_announcements = array();
292
-		while ($announcement = Database::fetch_object($announcements)) {
293
-			$all_announcements[] = $announcement;
294
-		}
295
-		return $all_announcements;
296
-	}
297
-
298
-	/**
299
-	 * Adds an announcement to the database
300
-	 * @param string Title of the announcement
301
-	 * @param string Content of the announcement
302
-	 * @param string Start date (YYYY-MM-DD HH:II: SS)
303
-	 * @param string End date (YYYY-MM-DD HH:II: SS)
304
-	 * @param int    Whether the announcement should be visible to teachers (1) or not (0)
305
-	 * @param int    Whether the announcement should be visible to students (1) or not (0)
306
-	 * @param int    Whether the announcement should be visible to anonymous users (1) or not (0)
307
-	 * @param string The language for which the announvement should be shown. Leave null for all langages
308
-	 * @param int    Whether to send an e-mail to all users (1) or not (0)
309
-	 * @return mixed  insert_id on success, false on failure
310
-	 */
283
+        $current_access_url_id = 1;
284
+        if (api_is_multiple_url_enabled()) {
285
+            $current_access_url_id = api_get_current_access_url_id();
286
+        }
287
+        $sql .= " WHERE access_url_id = '$current_access_url_id' ";
288
+        $sql .= " ORDER BY date_start ASC";
289
+
290
+        $announcements = Database::query($sql);
291
+        $all_announcements = array();
292
+        while ($announcement = Database::fetch_object($announcements)) {
293
+            $all_announcements[] = $announcement;
294
+        }
295
+        return $all_announcements;
296
+    }
297
+
298
+    /**
299
+     * Adds an announcement to the database
300
+     * @param string Title of the announcement
301
+     * @param string Content of the announcement
302
+     * @param string Start date (YYYY-MM-DD HH:II: SS)
303
+     * @param string End date (YYYY-MM-DD HH:II: SS)
304
+     * @param int    Whether the announcement should be visible to teachers (1) or not (0)
305
+     * @param int    Whether the announcement should be visible to students (1) or not (0)
306
+     * @param int    Whether the announcement should be visible to anonymous users (1) or not (0)
307
+     * @param string The language for which the announvement should be shown. Leave null for all langages
308
+     * @param int    Whether to send an e-mail to all users (1) or not (0)
309
+     * @return mixed  insert_id on success, false on failure
310
+     */
311 311
     public static function add_announcement(
312 312
         $title,
313 313
         $content,
@@ -321,115 +321,115 @@  discard block
 block discarded – undo
321 321
         $add_to_calendar = false,
322 322
         $sendEmailTest = false
323 323
     ) {
324
-		$original_content = $content;
325
-		$a_dateS = explode(' ',$date_start);
326
-		$a_arraySD = explode('-',$a_dateS[0]);
327
-		$a_arraySH = explode(':',$a_dateS[1]);
328
-		$date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
324
+        $original_content = $content;
325
+        $a_dateS = explode(' ',$date_start);
326
+        $a_arraySD = explode('-',$a_dateS[0]);
327
+        $a_arraySH = explode(':',$a_dateS[1]);
328
+        $date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
329 329
 
330
-		$a_dateE = explode(' ',$date_end);
331
-		$a_arrayED = explode('-',$a_dateE[0]);
332
-		$a_arrayEH = explode(':',$a_dateE[1]);
333
-		$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
330
+        $a_dateE = explode(' ',$date_end);
331
+        $a_arrayED = explode('-',$a_dateE[0]);
332
+        $a_arrayEH = explode(':',$a_dateE[1]);
333
+        $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
334 334
 
335
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
335
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
336 336
 
337
-		if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
338
-			Display :: display_normal_message(get_lang('InvalidStartDate'));
339
-			return false;
340
-		}
337
+        if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
338
+            Display :: display_normal_message(get_lang('InvalidStartDate'));
339
+            return false;
340
+        }
341 341
 
342
-		if (($date_end_to_compare[1] ||
342
+        if (($date_end_to_compare[1] ||
343 343
             $date_end_to_compare[2] ||
344 344
             $date_end_to_compare[0]) &&
345 345
             !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0])
346 346
         ) {
347
-			Display :: display_normal_message(get_lang('InvalidEndDate'));
348
-			return false;
349
-		}
350
-		if (strlen(trim($title)) == 0) {
351
-			Display::display_normal_message(get_lang('InvalidTitle'));
352
-			return false;
353
-		}
354
-
355
-		$start = api_get_utc_datetime($date_start);
347
+            Display :: display_normal_message(get_lang('InvalidEndDate'));
348
+            return false;
349
+        }
350
+        if (strlen(trim($title)) == 0) {
351
+            Display::display_normal_message(get_lang('InvalidTitle'));
352
+            return false;
353
+        }
354
+
355
+        $start = api_get_utc_datetime($date_start);
356 356
         $end = api_get_utc_datetime($date_end);
357 357
 
358
-		//Fixing urls that are sent by email
359
-		//$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
360
-		//$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
361
-		$content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
362
-		$content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
363
-
364
-
365
-		$lang = is_null($lang) ? '' : $lang;
366
-
367
-		$current_access_url_id = 1;
368
-		if (api_is_multiple_url_enabled()) {
369
-			$current_access_url_id = api_get_current_access_url_id();
370
-		}
371
-
372
-		$params = [
373
-			'title' => $title,
374
-			'content' => $content,
375
-			'date_start' => $start,
376
-			'date_end' => $end,
377
-			'visible_teacher' => $visible_teacher,
378
-			'visible_student' => $visible_student,
379
-			'visible_guest' => $visible_guest,
380
-			'lang' => $lang,
381
-			'access_url_id' => $current_access_url_id,
382
-		];
383
-
384
-		$resultId = Database::insert($db_table, $params);
385
-
386
-		if ($resultId) {
387
-
388
-			if ($sendEmailTest) {
389
-				SystemAnnouncementManager::send_system_announcement_by_email(
390
-					$title,
391
-					$content,
392
-					$visible_teacher,
393
-					$visible_student,
394
-					$lang,
395
-					true
396
-				);
397
-			} else {
398
-				if ($send_mail == 1) {
399
-					SystemAnnouncementManager::send_system_announcement_by_email(
400
-						$title,
401
-						$content,
402
-						$visible_teacher,
403
-						$visible_student,
404
-						$lang
405
-					);
406
-				}
407
-			}
408
-
409
-			if ($add_to_calendar) {
410
-				$agenda = new Agenda();
411
-				$agenda->setType('admin');
412
-				$agenda->addEvent(
413
-					$date_start,
414
-					$date_end,
415
-					false,
416
-					$title,
417
-					$original_content
418
-				);
419
-			}
420
-
421
-			return $resultId;
422
-
423
-		}
424
-
425
-		return false;
426
-	}
358
+        //Fixing urls that are sent by email
359
+        //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
360
+        //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
361
+        $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
362
+        $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
363
+
364
+
365
+        $lang = is_null($lang) ? '' : $lang;
366
+
367
+        $current_access_url_id = 1;
368
+        if (api_is_multiple_url_enabled()) {
369
+            $current_access_url_id = api_get_current_access_url_id();
370
+        }
371
+
372
+        $params = [
373
+            'title' => $title,
374
+            'content' => $content,
375
+            'date_start' => $start,
376
+            'date_end' => $end,
377
+            'visible_teacher' => $visible_teacher,
378
+            'visible_student' => $visible_student,
379
+            'visible_guest' => $visible_guest,
380
+            'lang' => $lang,
381
+            'access_url_id' => $current_access_url_id,
382
+        ];
383
+
384
+        $resultId = Database::insert($db_table, $params);
385
+
386
+        if ($resultId) {
387
+
388
+            if ($sendEmailTest) {
389
+                SystemAnnouncementManager::send_system_announcement_by_email(
390
+                    $title,
391
+                    $content,
392
+                    $visible_teacher,
393
+                    $visible_student,
394
+                    $lang,
395
+                    true
396
+                );
397
+            } else {
398
+                if ($send_mail == 1) {
399
+                    SystemAnnouncementManager::send_system_announcement_by_email(
400
+                        $title,
401
+                        $content,
402
+                        $visible_teacher,
403
+                        $visible_student,
404
+                        $lang
405
+                    );
406
+                }
407
+            }
408
+
409
+            if ($add_to_calendar) {
410
+                $agenda = new Agenda();
411
+                $agenda->setType('admin');
412
+                $agenda->addEvent(
413
+                    $date_start,
414
+                    $date_end,
415
+                    false,
416
+                    $title,
417
+                    $original_content
418
+                );
419
+            }
420
+
421
+            return $resultId;
422
+
423
+        }
424
+
425
+        return false;
426
+    }
427 427
 
428 428
     /**
429
-    * Makes the announcement id visible only for groups in groups_array
430
-    * @param int announcement id
431
-    * @param array array of group id
432
-    **/
429
+     * Makes the announcement id visible only for groups in groups_array
430
+     * @param int announcement id
431
+     * @param array array of group id
432
+     **/
433 433
     public static function announcement_for_groups($announcement_id, $group_array)
434 434
     {
435 435
         $tbl_announcement_group = Database:: get_main_table(
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
     }
464 464
 
465 465
     /**
466
-    * Gets the groups of this announce
467
-    * @param int announcement id
468
-    * @return array array of group id
469
-    **/
466
+     * Gets the groups of this announce
467
+     * @param int announcement id
468
+     * @return array array of group id
469
+     **/
470 470
     public static function get_announcement_groups($announcement_id)
471 471
     {
472 472
         $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
         return $groups;
486 486
     }
487 487
 
488
-	/**
489
-	 * Updates an announcement to the database
490
-	 * @param integer $id      : id of the announcement
491
-	 * @param string  $title   : title of the announcement
492
-	 * @param string  $content : content of the announcement
493
-	 * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
494
-	 * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
495
-	 * @return	bool	True on success, false on failure
496
-	 */
488
+    /**
489
+     * Updates an announcement to the database
490
+     * @param integer $id      : id of the announcement
491
+     * @param string  $title   : title of the announcement
492
+     * @param string  $content : content of the announcement
493
+     * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
494
+     * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
495
+     * @return	bool	True on success, false on failure
496
+     */
497 497
     public static function update_announcement(
498 498
         $id,
499 499
         $title,
@@ -509,43 +509,43 @@  discard block
 block discarded – undo
509 509
     ) {
510 510
         $em = Database::getManager();
511 511
 
512
-		$a_dateS = explode(' ',$date_start);
513
-		$a_arraySD = explode('-',$a_dateS[0]);
514
-		$a_arraySH = explode(':',$a_dateS[1]);
515
-		$date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
512
+        $a_dateS = explode(' ',$date_start);
513
+        $a_arraySD = explode('-',$a_dateS[0]);
514
+        $a_arraySH = explode(':',$a_dateS[1]);
515
+        $date_start_to_compare = array_merge($a_arraySD,$a_arraySH);
516 516
 
517
-		$a_dateE = explode(' ',$date_end);
518
-		$a_arrayED = explode('-',$a_dateE[0]);
519
-		$a_arrayEH = explode(':',$a_dateE[1]);
520
-		$date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
517
+        $a_dateE = explode(' ',$date_end);
518
+        $a_arrayED = explode('-',$a_dateE[0]);
519
+        $a_arrayEH = explode(':',$a_dateE[1]);
520
+        $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH);
521 521
 
522 522
         $lang = is_null($lang) ? '' : $lang;
523 523
 
524
-		if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
525
-			Display :: display_normal_message(get_lang('InvalidStartDate'));
526
-			return false;
527
-		}
524
+        if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
525
+            Display :: display_normal_message(get_lang('InvalidStartDate'));
526
+            return false;
527
+        }
528 528
 
529
-		if (($date_end_to_compare[1] ||
529
+        if (($date_end_to_compare[1] ||
530 530
             $date_end_to_compare[2] ||
531 531
             $date_end_to_compare[0]) &&
532 532
             !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0])
533 533
         ) {
534
-			Display :: display_normal_message(get_lang('InvalidEndDate'));
535
-			return false;
536
-		}
534
+            Display :: display_normal_message(get_lang('InvalidEndDate'));
535
+            return false;
536
+        }
537 537
 
538
-		if (strlen(trim($title)) == 0) {
539
-			Display::display_normal_message(get_lang('InvalidTitle'));
540
-			return false;
541
-		}
538
+        if (strlen(trim($title)) == 0) {
539
+            Display::display_normal_message(get_lang('InvalidTitle'));
540
+            return false;
541
+        }
542 542
 
543
-	    $start    = api_get_utc_datetime($date_start);
543
+        $start    = api_get_utc_datetime($date_start);
544 544
         $end      = api_get_utc_datetime($date_end);
545 545
 
546
-		//Fixing urls that are sent by email
547
-		//$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
548
-		//$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
546
+        //Fixing urls that are sent by email
547
+        //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
548
+        //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
549 549
         $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
550 550
         $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content);
551 551
 
@@ -595,84 +595,84 @@  discard block
 block discarded – undo
595 595
         $em->merge($announcement);
596 596
         $em->flush();
597 597
 
598
-		return true;
599
-	}
598
+        return true;
599
+    }
600 600
 
601
-	/**
602
-	 * Deletes an announcement
603
-	 * @param 	int $id The identifier of the announcement that should be
604
-	 * @return	bool	True on success, false on failure
605
-	 */
606
-	public static function delete_announcement($id)
601
+    /**
602
+     * Deletes an announcement
603
+     * @param 	int $id The identifier of the announcement that should be
604
+     * @return	bool	True on success, false on failure
605
+     */
606
+    public static function delete_announcement($id)
607 607
     {
608
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
609
-		$id = intval($id);
610
-		$sql = "DELETE FROM ".$db_table." WHERE id =".$id;
611
-		$res = Database::query($sql);
612
-		if ($res === false) {
613
-
614
-			return false;
615
-		}
616
-		return true;
617
-	}
618
-
619
-	/**
620
-	 * Gets an announcement
621
-	 * @param 	int		$id The identifier of the announcement that should be
622
-	 * @return	object	Object of class StdClass or the required class, containing the query result row
623
-	 */
624
-	public static function get_announcement($id)
608
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
609
+        $id = intval($id);
610
+        $sql = "DELETE FROM ".$db_table." WHERE id =".$id;
611
+        $res = Database::query($sql);
612
+        if ($res === false) {
613
+
614
+            return false;
615
+        }
616
+        return true;
617
+    }
618
+
619
+    /**
620
+     * Gets an announcement
621
+     * @param 	int		$id The identifier of the announcement that should be
622
+     * @return	object	Object of class StdClass or the required class, containing the query result row
623
+     */
624
+    public static function get_announcement($id)
625 625
     {
626
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
627
-		$id = intval($id);
628
-		$sql = "SELECT * FROM ".$db_table." WHERE id = ".$id;
629
-		$announcement = Database::fetch_object(Database::query($sql));
630
-
631
-		return $announcement;
632
-	}
633
-
634
-	/**
635
-	 * Change the visibility of an announcement
636
-	 * @param 	int $announcement_id
637
-	 * @param 	int $user For who should the visibility be changed
626
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
627
+        $id = intval($id);
628
+        $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id;
629
+        $announcement = Database::fetch_object(Database::query($sql));
630
+
631
+        return $announcement;
632
+    }
633
+
634
+    /**
635
+     * Change the visibility of an announcement
636
+     * @param 	int $announcement_id
637
+     * @param 	int $user For who should the visibility be changed
638 638
      * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST)
639
-	 * @return 	bool	True on success, false on failure
640
-	 */
641
-	public static function set_visibility($announcement_id, $user, $visible)
639
+     * @return 	bool	True on success, false on failure
640
+     */
641
+    public static function set_visibility($announcement_id, $user, $visible)
642 642
     {
643
-		$db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
644
-		$visible = intval($visible);
645
-		$announcement_id = intval($announcement_id);
643
+        $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
644
+        $visible = intval($visible);
645
+        $announcement_id = intval($announcement_id);
646 646
 
647 647
         if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) {
648 648
             return false;
649 649
         }
650 650
 
651
-		$field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest'));
651
+        $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest'));
652 652
 
653
-		$sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."'
653
+        $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."'
654 654
 		        WHERE id='".$announcement_id."'";
655
-		$res = Database::query($sql);
656
-
657
-		if ($res === false) {
658
-			return false;
659
-		}
660
-
661
-		return true;
662
-	}
663
-
664
-	/**
665
-	 * Send a system announcement by e-mail to all teachers/students depending on parameters
666
-	 * @param	string	Title
667
-	 * @param	string	Content
668
-	 * @param	int		Whether to send to all teachers (1) or not (0)
669
-	 * @param	int		Whether to send to all students (1) or not (0)
670
-	 * @param	string	Language (optional, considered for all languages if left empty)
655
+        $res = Database::query($sql);
656
+
657
+        if ($res === false) {
658
+            return false;
659
+        }
660
+
661
+        return true;
662
+    }
663
+
664
+    /**
665
+     * Send a system announcement by e-mail to all teachers/students depending on parameters
666
+     * @param	string	Title
667
+     * @param	string	Content
668
+     * @param	int		Whether to send to all teachers (1) or not (0)
669
+     * @param	int		Whether to send to all students (1) or not (0)
670
+     * @param	string	Language (optional, considered for all languages if left empty)
671 671
      * @return  bool    True if the message was sent or there was no destination matching. False on database or e-mail sending error.
672
-	 */
673
-	public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false)
672
+     */
673
+    public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false)
674 674
     {
675
-		global $charset;
675
+        global $charset;
676 676
 
677 677
         $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
678 678
         $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset);
@@ -691,22 +691,22 @@  discard block
 block discarded – undo
691 691
         }
692 692
 
693 693
         if ($teacher <> 0 AND $student == 0) {
694
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
695
-		}
694
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
695
+        }
696 696
 
697
-		if ($teacher == 0 AND $student <> 0) {
698
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
699
-		}
697
+        if ($teacher == 0 AND $student <> 0) {
698
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
699
+        }
700 700
 
701
-		if ($teacher<> 0 AND $student <> 0) {
702
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
703
-		}
701
+        if ($teacher<> 0 AND $student <> 0) {
702
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
703
+        }
704 704
 
705
-		if (!empty($language)) { //special condition because language was already treated for SQL insert before
706
-			$sql .= " AND language = '".Database::escape_string($language)."' ";
707
-		}
705
+        if (!empty($language)) { //special condition because language was already treated for SQL insert before
706
+            $sql .= " AND language = '".Database::escape_string($language)."' ";
707
+        }
708 708
 
709
-		if (api_is_multiple_url_enabled()) {
709
+        if (api_is_multiple_url_enabled()) {
710 710
             $sql .= " AND access_url_id = '".$current_access_url_id."' ";
711 711
         }
712 712
 
@@ -716,25 +716,25 @@  discard block
 block discarded – undo
716 716
         // Expiration date
717 717
         $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') ";
718 718
 
719
-		if ((empty($teacher) or $teacher == '0') AND  (empty($student) or $student == '0')) {
720
-			return true;
721
-		}
719
+        if ((empty($teacher) or $teacher == '0') AND  (empty($student) or $student == '0')) {
720
+            return true;
721
+        }
722 722
 
723
-		$result = Database::query($sql);
724
-		if ($result === false) {
725
-			return false;
726
-		}
723
+        $result = Database::query($sql);
724
+        if ($result === false) {
725
+            return false;
726
+        }
727 727
 
728 728
         $message_sent = false;
729 729
 
730
-		while ($row = Database::fetch_array($result,'ASSOC')) {
730
+        while ($row = Database::fetch_array($result,'ASSOC')) {
731 731
             MessageManager::send_message_simple($row['user_id'], $title, $content);
732 732
             $message_sent = true;
733
-		}
734
-		return $message_sent; //true if at least one e-mail was sent
735
-	}
733
+        }
734
+        return $message_sent; //true if at least one e-mail was sent
735
+    }
736 736
 
737
-	/**
737
+    /**
738 738
      * Displays announcements as an slideshow
739 739
      * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
740 740
      * @param int $id The identifier of the announcement to display
Please login to merge, or discard this patch.
main/inc/lib/table_sort.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 	 * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC)
81 81
 	 * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column.
82 82
 	 * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3]
83
-	 * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE)
83
+	 * @param integer $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE)
84 84
 	 * @return array The sorted dataset
85 85
 	 * @author [email protected]
86 86
 	 */
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
                 $new_data_order = array();
159 159
                 if (!empty($docs_to_sort)) {
160
-                    foreach($docs_to_sort as $id => $document) {
160
+                    foreach ($docs_to_sort as $id => $document) {
161 161
                         if (isset($new_data[$id])) {
162 162
                             $new_data_order[] = $new_data[$id];
163 163
                         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 }
166 166
 
167 167
                 if (!empty($folder_to_sort)) {
168
-                    foreach($folder_to_sort as $id => $document) {
168
+                    foreach ($folder_to_sort as $id => $document) {
169 169
                         if (isset($new_data[$id])) {
170 170
                             $new_data_order[] = $new_data[$id];
171 171
                         }
Please login to merge, or discard this patch.
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 class TableSort
16 16
 {
17 17
     /**
18
-    * Sorts 2-dimensional table.
19
-    * @param array $data The data to be sorted.
20
-    * @param int $column The column on which the data should be sorted (default = 0)
21
-    * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC)
22
-    * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC,
23
-    * SORT_STRING,SORT_DATE,SORT_IMAGE)
24
-    * @return array The sorted dataset
25
-    * @author [email protected]
26
-    */
27
-	public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR)
18
+     * Sorts 2-dimensional table.
19
+     * @param array $data The data to be sorted.
20
+     * @param int $column The column on which the data should be sorted (default = 0)
21
+     * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC)
22
+     * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC,
23
+     * SORT_STRING,SORT_DATE,SORT_IMAGE)
24
+     * @return array The sorted dataset
25
+     * @author [email protected]
26
+     */
27
+    public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR)
28 28
     {
29 29
         if (!is_array($data) || empty($data)) {
30 30
             return array();
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
         usort($data, create_function('$a, $b', $compare_function));
72 72
 
73 73
         return $data;
74
-	}
74
+    }
75 75
 
76
-	/**
77
-	 * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted.
78
-	 * @param array $data The data to be sorted.
79
-	 * @param int $column The column on which the data should be sorted (default = 0)
80
-	 * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC)
81
-	 * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column.
82
-	 * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3]
83
-	 * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE)
84
-	 * @return array The sorted dataset
85
-	 * @author [email protected]
86
-	 */
87
-	public static function sort_table_config(
76
+    /**
77
+     * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted.
78
+     * @param array $data The data to be sorted.
79
+     * @param int $column The column on which the data should be sorted (default = 0)
80
+     * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC)
81
+     * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column.
82
+     * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3]
83
+     * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE)
84
+     * @return array The sorted dataset
85
+     * @author [email protected]
86
+     */
87
+    public static function sort_table_config(
88 88
         $data,
89 89
         $column = 0,
90 90
         $direction = SORT_ASC,
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
             if (!empty($data)) {
133 133
                 foreach ($data as $document) {
134 134
                     if ($document['type'] == 'folder') {
135
-                      $docs_to_sort[$document['id']]   = api_strtolower($document['name']);
135
+                        $docs_to_sort[$document['id']]   = api_strtolower($document['name']);
136 136
                     } else {
137
-                      $folder_to_sort[$document['id']] = api_strtolower($document['name']);
137
+                        $folder_to_sort[$document['id']] = api_strtolower($document['name']);
138 138
                     }
139 139
                     $new_data[$document['id']] = $document;
140 140
                 }
@@ -196,91 +196,91 @@  discard block
 block discarded – undo
196 196
             usort($data, create_function('$a, $b', $compare_function));
197 197
         }
198 198
 
199
-		if (is_array($column_show) && !empty($column_show)) {
199
+        if (is_array($column_show) && !empty($column_show)) {
200 200
 
201
-			// We show only the columns data that were set up on the $column_show array
202
-			$new_order_data = array();
203
-			$count_data = count($data);
204
-			$count_column_show = count($column_show);
205
-			for ($j = 0; $j < $count_data; $j++) {
206
-				$k = 0;
207
-				for ($i = 0; $i < $count_column_show; $i++) {
208
-					if ($column_show[$i]) {
209
-						$new_order_data[$j][$k] = $data[$j][$i];
210
-					}
211
-					$k++;
212
-				}
213
-			}
214
-			// Replace the multi-arrays
215
-			$data = $new_order_data;
216
-		}
201
+            // We show only the columns data that were set up on the $column_show array
202
+            $new_order_data = array();
203
+            $count_data = count($data);
204
+            $count_column_show = count($column_show);
205
+            for ($j = 0; $j < $count_data; $j++) {
206
+                $k = 0;
207
+                for ($i = 0; $i < $count_column_show; $i++) {
208
+                    if ($column_show[$i]) {
209
+                        $new_order_data[$j][$k] = $data[$j][$i];
210
+                    }
211
+                    $k++;
212
+                }
213
+            }
214
+            // Replace the multi-arrays
215
+            $data = $new_order_data;
216
+        }
217 217
 
218
-		return $data;
219
-	}
218
+        return $data;
219
+    }
220 220
 
221
-	/**
222
-	 * Checks whether a column of a 2D-array contains only numeric values
223
-	 * @param array $data		The data-array
224
-	 * @param int $column		The index of the column to check
225
-	 * @return bool				TRUE if column contains only dates, FALSE otherwise
226
-	 * @todo Take locale into account (eg decimal point or comma ?)
227
-	 * @author [email protected]
228
-	 */
229
-	private static function is_numeric_column(& $data, $column)
221
+    /**
222
+     * Checks whether a column of a 2D-array contains only numeric values
223
+     * @param array $data		The data-array
224
+     * @param int $column		The index of the column to check
225
+     * @return bool				TRUE if column contains only dates, FALSE otherwise
226
+     * @todo Take locale into account (eg decimal point or comma ?)
227
+     * @author [email protected]
228
+     */
229
+    private static function is_numeric_column(& $data, $column)
230 230
     {
231
-		$is_numeric = true;
232
-		foreach ($data as $index => & $row) {
233
-			$is_numeric &= is_numeric(strip_tags($row[$column]));
234
-			if (!$is_numeric) {
235
-				break;
236
-			}
237
-		}
238
-		return $is_numeric;
239
-	}
231
+        $is_numeric = true;
232
+        foreach ($data as $index => & $row) {
233
+            $is_numeric &= is_numeric(strip_tags($row[$column]));
234
+            if (!$is_numeric) {
235
+                break;
236
+            }
237
+        }
238
+        return $is_numeric;
239
+    }
240 240
 
241
-	/**
242
-	 * Checks whether a column of a 2D-array contains only dates (GNU date syntax)
243
-	 * @param array $data		The data-array
244
-	 * @param int $column		The index of the column to check
245
-	 * @return bool				TRUE if column contains only dates, FALSE otherwise
246
-	 * @author [email protected]
247
-	 */
248
-	private static function is_date_column(& $data, $column)
241
+    /**
242
+     * Checks whether a column of a 2D-array contains only dates (GNU date syntax)
243
+     * @param array $data		The data-array
244
+     * @param int $column		The index of the column to check
245
+     * @return bool				TRUE if column contains only dates, FALSE otherwise
246
+     * @author [email protected]
247
+     */
248
+    private static function is_date_column(& $data, $column)
249 249
     {
250
-		$is_date = true;
251
-		foreach ($data as $index => & $row) {
252
-			if (strlen(strip_tags($row[$column])) != 0) {
253
-				$check_date = strtotime(strip_tags($row[$column]));
254
-				// strtotime Returns a timestamp on success, FALSE otherwise.
255
-				// Previous to PHP 5.1.0, this function would return -1 on failure.
256
-				$is_date &= ($check_date != -1 && $check_date);
257
-			} else {
258
-				$is_date &= false;
259
-			}
260
-			if (!$is_date) {
261
-				break;
262
-			}
263
-		}
264
-		return $is_date;
265
-	}
250
+        $is_date = true;
251
+        foreach ($data as $index => & $row) {
252
+            if (strlen(strip_tags($row[$column])) != 0) {
253
+                $check_date = strtotime(strip_tags($row[$column]));
254
+                // strtotime Returns a timestamp on success, FALSE otherwise.
255
+                // Previous to PHP 5.1.0, this function would return -1 on failure.
256
+                $is_date &= ($check_date != -1 && $check_date);
257
+            } else {
258
+                $is_date &= false;
259
+            }
260
+            if (!$is_date) {
261
+                break;
262
+            }
263
+        }
264
+        return $is_date;
265
+    }
266 266
 
267
-	/**
268
-	 * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>)
269
-	 * @param array $data		The data-array
270
-	 * @param int $column		The index of the column to check
271
-	 * @return bool				TRUE if column contains only images, FALSE otherwise
272
-	 * @author [email protected]
273
-	 */
274
-	private static function is_image_column(& $data, $column)
267
+    /**
268
+     * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>)
269
+     * @param array $data		The data-array
270
+     * @param int $column		The index of the column to check
271
+     * @return bool				TRUE if column contains only images, FALSE otherwise
272
+     * @author [email protected]
273
+     */
274
+    private static function is_image_column(& $data, $column)
275 275
     {
276
-		$is_image = true;
277
-		foreach ($data as $index => & $row) {
278
-			$is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag
279
-			$is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values
280
-			if (!$is_image) {
281
-				break;
282
-			}
283
-		}
284
-		return $is_image;
285
-	}
276
+        $is_image = true;
277
+        foreach ($data as $index => & $row) {
278
+            $is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag
279
+            $is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values
280
+            if (!$is_image) {
281
+                break;
282
+            }
283
+        }
284
+        return $is_image;
285
+    }
286 286
 }
Please login to merge, or discard this patch.
main/inc/lib/template.lib.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -330,6 +330,7 @@  discard block
 block discarded – undo
330 330
     /**
331 331
      * Sets the footer visibility
332 332
      * @param bool true if we show the footer
333
+     * @param boolean $status
333 334
      */
334 335
     public function set_footer($status)
335 336
     {
@@ -370,6 +371,7 @@  discard block
 block discarded – undo
370 371
     /**
371 372
      * Sets the header visibility
372 373
      * @param bool true if we show the header
374
+     * @param boolean $status
373 375
      */
374 376
     public function set_header($status)
375 377
     {
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@
 block discarded – undo
338 338
 
339 339
         if (empty($certificatesItem) && empty($searchItem)) {
340 340
             return null;
341
-        }else{
341
+        } else{
342 342
             $content.= $certificatesItem;
343 343
             $content.= $searchItem;
344 344
         }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
                 $content = '<li class="help">';
277 277
                 $content .= Display::url(
278 278
                     Display::return_icon('help.large.png', get_lang('Help')),
279
-                    api_get_path(WEB_CODE_PATH) . 'help/help.php?open=' . $help,
279
+                    api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help,
280 280
                     [
281 281
                         'class' => 'ajax',
282 282
                         'data-title' => get_lang('Help')
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             'web_course' => api_get_path(WEB_COURSE_PATH),
491 491
             'web_main' => api_get_path(WEB_CODE_PATH),
492 492
             'web_css' => api_get_path(WEB_CSS_PATH),
493
-            'web_css_theme' => api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/',
493
+            'web_css_theme' => api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/',
494 494
             'web_ajax' => api_get_path(WEB_AJAX_PATH),
495 495
             'web_img' => api_get_path(WEB_IMG_PATH),
496 496
             'web_plugin' => api_get_path(WEB_PLUGIN_PATH),
@@ -548,12 +548,12 @@  discard block
 block discarded – undo
548 548
         foreach ($bowerCSSFiles as $file) {
549 549
             $css[] = api_get_path(WEB_PATH).'web/assets/'.$file;
550 550
         }
551
-        $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/bootstrap-select/css/bootstrap-select.min.css';
552
-        $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css';
553
-        $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css';
551
+        $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap-select/css/bootstrap-select.min.css';
552
+        $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css';
553
+        $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css';
554 554
 
555 555
         if (api_is_global_chat_enabled()) {
556
-            $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css';
556
+            $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css';
557 557
         }
558 558
 
559 559
         //THEME CSS STYLE
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 
598 598
         if (is_file(api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/editor.css')) {
599 599
             $css[] = api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/editor.css';
600
-        }else{
600
+        } else {
601 601
             $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'editor.css');
602 602
         }
603 603
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 
633 633
             $style_print = '';
634 634
             if (is_readable(api_get_path(SYS_CSS_PATH).$this->theme.'/print.css')) {
635
-                $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH) . $this->theme . '/print.css'),
635
+                $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/print.css'),
636 636
                     'print');
637 637
             }
638 638
             $this->assign('css_style_print', $style_print);
@@ -655,10 +655,10 @@  discard block
 block discarded – undo
655 655
 
656 656
         $isoCode = api_get_language_isocode();
657 657
 
658
-        $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_' . strtoupper($isoCode) . '.min.js';
658
+        $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js';
659 659
 
660 660
         if ($isoCode == 'en') {
661
-            $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_US.min.js';
661
+            $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_US.min.js';
662 662
         }
663 663
         // JS files
664 664
         $js_files = array(
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
         }
709 709
 
710 710
         if ($isoCode != 'en') {
711
-            $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $isoCode . '.js';
712
-            $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-' . $isoCode . '.min.js';
711
+            $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-'.$isoCode.'.js';
712
+            $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-'.$isoCode.'.min.js';
713 713
         }
714 714
 
715 715
         foreach ($bowerJsFiles as $file) {
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
         }
791 791
 
792 792
         $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM));
793
-        $this->assign('offline_button',Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM));
793
+        $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM));
794 794
 
795 795
         // Get language iso-code for this page - ignore errors
796 796
         $this->assign('document_language', api_get_language_isocode());
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
         $this->assign('section_name', 'section-'.$this_section);
850 850
 
851 851
         //Defaul root chamilo favicon
852
-        $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />';
852
+        $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />';
853 853
 
854 854
         //Added to verify if in the current Chamilo Theme exist a favicon
855
-        $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/';
855
+        $favicoThemeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/images/';
856 856
 
857 857
         //If exist pick the current chamilo theme favicon
858
-        if (is_file($favicoThemeUrl . 'favicon.ico')) {
859
-            $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH). 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />';
858
+        if (is_file($favicoThemeUrl.'favicon.ico')) {
859
+            $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/images/favicon.ico" type="image/x-icon" />';
860 860
         }
861 861
 
862 862
         if (api_is_multiple_url_enabled()) {
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
         if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
887 887
             $bug_notification_link = '<li class="report">
888 888
 		<a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank">
889
-                    '. $iconBug . '
889
+                    '. $iconBug.'
890 890
                 </a>
891 891
 		</li>';
892 892
         }
@@ -1003,13 +1003,13 @@  discard block
 block discarded – undo
1003 1003
         $socialMeta = '';
1004 1004
         $metaTitle = api_get_setting('meta_title');
1005 1005
         if (!empty($metaTitle)) {
1006
-            $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n";
1006
+            $socialMeta .= '<meta name="twitter:card" content="summary" />'."\n";
1007 1007
             $metaSite = api_get_setting('meta_twitter_site');
1008 1008
             if (!empty($metaSite)) {
1009
-                $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
1009
+                $socialMeta .= '<meta name="twitter:site" content="'.$metaSite.'" />'."\n";
1010 1010
                 $metaCreator = api_get_setting('meta_twitter_creator');
1011 1011
                 if (!empty($metaCreator)) {
1012
-                    $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n";
1012
+                    $socialMeta .= '<meta name="twitter:creator" content="'.$metaCreator.'" />'."\n";
1013 1013
                 }
1014 1014
             }
1015 1015
 
@@ -1021,19 +1021,19 @@  discard block
 block discarded – undo
1021 1021
             if (!$userId && !$skillId) {
1022 1022
                 // no combination of user and skill ID has been defined,
1023 1023
                 // so print the normal OpenGraph meta tags
1024
-                $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n";
1025
-                $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n";
1024
+                $socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n";
1025
+                $socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n";
1026 1026
 
1027 1027
                 $metaDescription = api_get_setting('meta_description');
1028 1028
                 if (!empty($metaDescription)) {
1029
-                    $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n";
1029
+                    $socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n";
1030 1030
                 }
1031 1031
 
1032 1032
                 $metaImage = api_get_setting('meta_image_path');
1033 1033
                 if (!empty($metaImage)) {
1034
-                    if (is_file(api_get_path(SYS_PATH) . $metaImage)) {
1035
-                        $path = api_get_path(WEB_PATH) . $metaImage;
1036
-                        $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n";
1034
+                    if (is_file(api_get_path(SYS_PATH).$metaImage)) {
1035
+                        $path = api_get_path(WEB_PATH).$metaImage;
1036
+                        $socialMeta .= '<meta property="og:image" content="'.$path.'" />'."\n";
1037 1037
                     }
1038 1038
                 }
1039 1039
             }
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
         // Tutor name
1068 1068
         if (api_get_setting('show_tutor_data') == 'true') {
1069 1069
             // Course manager
1070
-            $courseId  = api_get_course_int_id();
1070
+            $courseId = api_get_course_int_id();
1071 1071
             $id_session = api_get_session_id();
1072 1072
             if (!empty($courseId)) {
1073 1073
                 $tutor_data = '';
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
             $courseId = api_get_course_int_id();
1100 1100
             if (!empty($courseId)) {
1101 1101
                 $teacher_data = '';
1102
-                $mail= CourseManager::get_emails_of_tutors_to_course($courseId);
1102
+                $mail = CourseManager::get_emails_of_tutors_to_course($courseId);
1103 1103
                 if (!empty($mail)) {
1104 1104
                     $teachers_parsed = array();
1105 1105
                     foreach ($mail as $value) {
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
                     'sessionVar'   => basename(__FILE__, '.php'),
1334 1334
                     'imageOptions' => array(
1335 1335
                         'font_size' => 20,
1336
-                        'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/',
1336
+                        'font_path' => api_get_path(SYS_FONTS_PATH).'opensans/',
1337 1337
                         'font_file' => 'OpenSans-Regular.ttf',
1338 1338
                         //'output' => 'gif'
1339 1339
                     )
Please login to merge, or discard this patch.
main/inc/lib/text.lib.php 4 patches
Doc Comments   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,6 +52,7 @@  discard block
 block discarded – undo
52 52
  * Converts the text of a html-document to a given encoding, the meta-tag is changed accordingly.
53 53
  * @param string $string                The input full-html document.
54 54
  * @param string                        The new encoding value to be set.
55
+ * @param string $encoding
55 56
  */
56 57
 function api_set_encoding_html(&$string, $encoding) {
57 58
     $old_encoding = api_detect_encoding_html($string);
@@ -74,7 +75,7 @@  discard block
 block discarded – undo
74 75
  * Returns the title of a html document.
75 76
  * @param string $string                The contents of the input document.
76 77
  * @param string $input_encoding        The encoding of the input document. If the value is not set, it is detected.
77
- * @param string $$output_encoding      The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
78
+ * @param string $output_encoding      The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
78 79
  * @return string                       The retrieved title, html-entities and extra-whitespace between the words are cleaned.
79 80
  */
80 81
 function api_get_title_html(&$string, $output_encoding = null, $input_encoding = null) {
@@ -433,7 +434,7 @@  discard block
 block discarded – undo
433 434
  * @since wordpress  2.8.1
434 435
  * @access private
435 436
  *
436
- * @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
437
+ * @param string[] $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
437 438
  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
438 439
  * @return string The string with the replaced svalues.
439 440
  */
@@ -628,6 +629,7 @@  discard block
 block discarded – undo
628 629
  * @param string    The text to "cut"
629 630
  * @param int       Count of chars
630 631
  * @param bool      Whether to embed in a <span title="...">...</span>
632
+ * @param integer $maxchar
631 633
  * @return string
632 634
  * */
633 635
 function cut($text, $maxchar, $embed = false) {
@@ -645,7 +647,7 @@  discard block
 block discarded – undo
645 647
  *
646 648
  * @param mixed     Number to convert
647 649
  * @param int       Decimal points 0=never, 1=if needed, 2=always
648
- * @return mixed    An integer or a float depends on the parameter
650
+ * @return string|null    An integer or a float depends on the parameter
649 651
  */
650 652
 function float_format($number, $flag = 1) {
651 653
     if (is_numeric($number)) {
@@ -689,7 +691,7 @@  discard block
 block discarded – undo
689 691
 /**
690 692
  * Gets the week from a day
691 693
  * @param   string   Date in UTC (2010-01-01 12:12:12)
692
- * @return  int      Returns an integer with the week number of the year
694
+ * @return  string      Returns an integer with the week number of the year
693 695
  */
694 696
 function get_week_from_day($date) {
695 697
     if (!empty($date)) {
@@ -739,6 +741,9 @@  discard block
 block discarded – undo
739 741
 	return $output.$end;
740 742
 }
741 743
 
744
+/**
745
+ * @param string $glue
746
+ */
742 747
 function implode_with_key($glue, $array) {
743 748
     if (!empty($array)) {
744 749
         $string = '';
@@ -817,7 +822,7 @@  discard block
 block discarded – undo
817 822
 /**
818 823
  * @param string $string
819 824
  * @param bool $capitalizeFirstCharacter
820
- * @return mixed
825
+ * @return string
821 826
  */
822 827
 function underScoreToCamelCase($string, $capitalizeFirstCharacter = true)
823 828
 {
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
     if (@preg_match('/(.*<head.*)(<meta[^>]*content=[^>]*>)(.*<\/head>.*)/si', $string, $matches)) {
59 59
         $meta = $matches[2];
60 60
         if (@preg_match("/(<meta[^>]*charset=)(.*)([\"';][^>]*>)/si", $meta, $matches1)) {
61
-            $meta = $matches1[1] . $encoding . $matches1[3];
62
-            $string = $matches[1] . $meta . $matches[3];
61
+            $meta = $matches1[1].$encoding.$matches1[3];
62
+            $string = $matches[1].$meta.$matches[3];
63 63
         } else {
64
-            $string = $matches[1] . '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>' . $matches[3];
64
+            $string = $matches[1].'<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>'.$matches[3];
65 65
         }
66 66
     } else {
67 67
         $count = 1;
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
     if (!preg_match(_PCRE_XML_ENCODING, $string)) {
169 169
         if (strpos($matches[0], 'standalone') !== false) {
170 170
             // The encoding option should precede the standalone option, othewise DOMDocument fails to load the document.
171
-            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone' , $matches[0]);
171
+            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone', $matches[0]);
172 172
         } else {
173
-            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>' , $matches[0]);
173
+            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>', $matches[0]);
174 174
         }
175 175
         return api_convert_encoding(str_replace($matches[0], $replace, $string), $to_encoding, $from_encoding);
176 176
     }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 function _make_url_clickable_cb($matches) {
336 336
     $url = $matches[2];
337 337
 
338
-    if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
338
+    if (')' == $matches[3] && strpos($url, '(')) {
339 339
         // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
340 340
         // Then we can let the parenthesis balancer do its thing below.
341 341
         $url .= $matches[3];
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
     }
346 346
 
347 347
     // Include parentheses in the URL only if paired
348
-    while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
349
-        $suffix = strrchr( $url, ')' ) . $suffix;
350
-        $url = substr( $url, 0, strrpos( $url, ')' ) );
348
+    while (substr_count($url, '(') < substr_count($url, ')')) {
349
+        $suffix = strrchr($url, ')').$suffix;
350
+        $url = substr($url, 0, strrpos($url, ')'));
351 351
     }
352 352
 
353 353
     $url = esc_url($url);
354
-    if ( empty($url) )
354
+    if (empty($url))
355 355
         return $matches[0];
356 356
 
357
-    return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
357
+    return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix;
358 358
 }
359 359
 
360 360
 /**
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
  * @param string $_context Private. Use esc_url_raw() for database usage.
375 375
  * @return string The cleaned $url after the 'clean_url' filter is applied.
376 376
  */
377
-function esc_url( $url, $protocols = null, $_context = 'display' ) {
377
+function esc_url($url, $protocols = null, $_context = 'display') {
378 378
     //$original_url = $url;
379 379
 
380
-    if ( '' == $url )
380
+    if ('' == $url)
381 381
         return $url;
382 382
     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
383 383
     $strip = array('%0d', '%0a', '%0D', '%0A');
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
      * presume it needs http:// appended (unless a relative
388 388
      * link starting with /, # or ? or a php file).
389 389
      */
390
-    if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
391
-        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
392
-        $url = 'http://' . $url;
390
+    if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) &&
391
+        !preg_match('/^[a-z0-9-]+?\.php/i', $url))
392
+        $url = 'http://'.$url;
393 393
 
394 394
     return Security::remove_XSS($url);
395 395
 
@@ -437,12 +437,12 @@  discard block
 block discarded – undo
437 437
  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
438 438
  * @return string The string with the replaced svalues.
439 439
  */
440
-function _deep_replace( $search, $subject ) {
440
+function _deep_replace($search, $subject) {
441 441
     $subject = (string) $subject;
442 442
 
443 443
     $count = 1;
444
-    while ( $count ) {
445
-        $subject = str_replace( $search, '', $subject, $count );
444
+    while ($count) {
445
+        $subject = str_replace($search, '', $subject, $count);
446 446
     }
447 447
 
448 448
     return $subject;
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 function _make_web_ftp_clickable_cb($matches) {
465 465
     $ret = '';
466 466
     $dest = $matches[2];
467
-    $dest = 'http://' . $dest;
467
+    $dest = 'http://'.$dest;
468 468
     $dest = esc_url($dest);
469
-    if ( empty($dest) )
469
+    if (empty($dest))
470 470
         return $matches[0];
471 471
 
472 472
     // removed trailing [.,;:)] from URL
473
-    if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
473
+    if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) {
474 474
         $ret = substr($dest, -1);
475
-        $dest = substr($dest, 0, strlen($dest)-1);
475
+        $dest = substr($dest, 0, strlen($dest) - 1);
476 476
     }
477
-    return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
477
+    return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
478 478
 }
479 479
 
480 480
 /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
  * @return string HTML A element with email address.
491 491
  */
492 492
 function _make_email_clickable_cb($matches) {
493
-    $email = $matches[2] . '@' . $matches[3];
494
-    return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
493
+    $email = $matches[2].'@'.$matches[3];
494
+    return $matches[1]."<a href=\"mailto:$email\">$email</a>";
495 495
 }
496 496
 
497 497
 /**
@@ -505,30 +505,30 @@  discard block
 block discarded – undo
505 505
  * @param string $text Content to convert URIs.
506 506
  * @return string Content with converted URIs.
507 507
  */
508
-function make_clickable( $text ) {
508
+function make_clickable($text) {
509 509
     $r = '';
510
-    $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
510
+    $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags
511 511
     $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
512
-    foreach ( $textarr as $piece ) {
512
+    foreach ($textarr as $piece) {
513 513
 
514
-        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
514
+        if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece))
515 515
             $nested_code_pre++;
516
-        elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
516
+        elseif (('</code>' === strtolower($piece) || '</pre>' === strtolower($piece)) && $nested_code_pre)
517 517
             $nested_code_pre--;
518 518
 
519
-        if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
519
+        if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && !preg_match('|^<\s*[\w]{1,20}+://|', $piece))) {
520 520
             $r .= $piece;
521 521
             continue;
522 522
         }
523 523
 
524 524
         // Long strings might contain expensive edge cases ...
525
-        if ( 10000 < strlen( $piece ) ) {
525
+        if (10000 < strlen($piece)) {
526 526
             // ... break it up
527
-            foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
528
-                if ( 2101 < strlen( $chunk ) ) {
527
+            foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses
528
+                if (2101 < strlen($chunk)) {
529 529
                     $r .= $chunk; // Too big, no whitespace: bail.
530 530
                 } else {
531
-                    $r .= make_clickable( $chunk );
531
+                    $r .= make_clickable($chunk);
532 532
                 }
533 533
             }
534 534
         } else {
@@ -549,18 +549,18 @@  discard block
 block discarded – undo
549 549
 			~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
550 550
             // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
551 551
 
552
-            $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
552
+            $ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret);
553 553
 
554
-            $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
555
-            $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
554
+            $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
555
+            $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
556 556
 
557
-            $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
557
+            $ret = substr($ret, 1, -1); // Remove our whitespace padding.
558 558
             $r .= $ret;
559 559
         }
560 560
     }
561 561
 
562 562
     // Cleanup of accidental links within links
563
-    $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
563
+    $r = preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r);
564 564
     return $r;
565 565
 }
566 566
 
@@ -595,27 +595,27 @@  discard block
 block discarded – undo
595 595
  * @param int $goal The desired chunk length.
596 596
  * @return array Numeric array of chunks.
597 597
  */
598
-function _split_str_by_whitespace( $string, $goal ) {
598
+function _split_str_by_whitespace($string, $goal) {
599 599
     $chunks = array();
600 600
 
601
-    $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
601
+    $string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000");
602 602
 
603
-    while ( $goal < strlen( $string_nullspace ) ) {
604
-        $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
603
+    while ($goal < strlen($string_nullspace)) {
604
+        $pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000");
605 605
 
606
-        if ( false === $pos ) {
607
-            $pos = strpos( $string_nullspace, "\000", $goal + 1 );
608
-            if ( false === $pos ) {
606
+        if (false === $pos) {
607
+            $pos = strpos($string_nullspace, "\000", $goal + 1);
608
+            if (false === $pos) {
609 609
                 break;
610 610
             }
611 611
         }
612 612
 
613
-        $chunks[] = substr( $string, 0, $pos + 1 );
614
-        $string = substr( $string, $pos + 1 );
615
-        $string_nullspace = substr( $string_nullspace, $pos + 1 );
613
+        $chunks[] = substr($string, 0, $pos + 1);
614
+        $string = substr($string, $pos + 1);
615
+        $string_nullspace = substr($string_nullspace, $pos + 1);
616 616
     }
617 617
 
618
-    if ( $string ) {
618
+    if ($string) {
619 619
         $chunks[] = $string;
620 620
     }
621 621
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  */
694 694
 function get_week_from_day($date) {
695 695
     if (!empty($date)) {
696
-       $time = api_strtotime($date,'UTC');
696
+       $time = api_strtotime($date, 'UTC');
697 697
        return date('W', $time);
698 698
     } else {
699 699
         return date('W');
@@ -710,17 +710,17 @@  discard block
 block discarded – undo
710 710
  * @return a reduce string
711 711
  */
712 712
 
713
-function substrwords($text,$maxchar,$end='...')
713
+function substrwords($text, $maxchar, $end = '...')
714 714
 {
715
-	if(strlen($text)>$maxchar)
715
+	if (strlen($text) > $maxchar)
716 716
 	{
717
-		$words=explode(" ",$text);
717
+		$words = explode(" ", $text);
718 718
 		$output = '';
719
-		$i=0;
720
-		while(1)
719
+		$i = 0;
720
+		while (1)
721 721
 		{
722
-			$length = (strlen($output)+strlen($words[$i]));
723
-			if($length>$maxchar)
722
+			$length = (strlen($output) + strlen($words[$i]));
723
+			if ($length > $maxchar)
724 724
 			{
725 725
 				break;
726 726
 			}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 function implode_with_key($glue, $array) {
743 743
     if (!empty($array)) {
744 744
         $string = '';
745
-        foreach($array as $key => $value) {
745
+        foreach ($array as $key => $value) {
746 746
             if (empty($value)) {
747 747
                 $value = 'null';
748 748
             }
@@ -764,13 +764,13 @@  discard block
 block discarded – undo
764 764
 {
765 765
     $file_size = intval($file_size);
766 766
     if ($file_size >= 1073741824) {
767
-        $file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
768
-    } elseif($file_size >= 1048576) {
769
-        $file_size = round($file_size / 1048576 * 100) / 100 . 'M';
770
-    } elseif($file_size >= 1024) {
771
-        $file_size = round($file_size / 1024 * 100) / 100 . 'k';
767
+        $file_size = round($file_size / 1073741824 * 100) / 100.'G';
768
+    } elseif ($file_size >= 1048576) {
769
+        $file_size = round($file_size / 1048576 * 100) / 100.'M';
770
+    } elseif ($file_size >= 1024) {
771
+        $file_size = round($file_size / 1024 * 100) / 100.'k';
772 772
     } else {
773
-        $file_size = $file_size . 'B';
773
+        $file_size = $file_size.'B';
774 774
     }
775 775
     return $file_size;
776 776
 }
@@ -779,18 +779,18 @@  discard block
 block discarded – undo
779 779
 {
780 780
     $year	 = '0000';
781 781
     $month = $day = $hours = $minutes = $seconds = '00';
782
-    if (isset($array['Y']) && (isset($array['F']) || isset($array['M']))  && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
782
+    if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
783 783
         $year = $array['Y'];
784
-        $month = isset($array['F'])?$array['F']:$array['M'];
785
-        if (intval($month) < 10 ) $month = '0'.$month;
784
+        $month = isset($array['F']) ? $array['F'] : $array['M'];
785
+        if (intval($month) < 10) $month = '0'.$month;
786 786
         $day = $array['d'];
787
-        if (intval($day) < 10 ) $day = '0'.$day;
787
+        if (intval($day) < 10) $day = '0'.$day;
788 788
         $hours = $array['H'];
789
-        if (intval($hours) < 10 ) $hours = '0'.$hours;
789
+        if (intval($hours) < 10) $hours = '0'.$hours;
790 790
         $minutes = $array['i'];
791
-        if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
791
+        if (intval($minutes) < 10) $minutes = '0'.$minutes;
792 792
     }
793
-    if (checkdate($month,$day,$year)) {
793
+    if (checkdate($month, $day, $year)) {
794 794
         $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
795 795
     }
796 796
     return $datetime;
Please login to merge, or discard this patch.
Braces   +31 added lines, -20 removed lines patch added patch discarded remove patch
@@ -351,8 +351,9 @@  discard block
 block discarded – undo
351 351
     }
352 352
 
353 353
     $url = esc_url($url);
354
-    if ( empty($url) )
355
-        return $matches[0];
354
+    if ( empty($url) ) {
355
+            return $matches[0];
356
+    }
356 357
 
357 358
     return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
358 359
 }
@@ -377,8 +378,9 @@  discard block
 block discarded – undo
377 378
 function esc_url( $url, $protocols = null, $_context = 'display' ) {
378 379
     //$original_url = $url;
379 380
 
380
-    if ( '' == $url )
381
-        return $url;
381
+    if ( '' == $url ) {
382
+            return $url;
383
+    }
382 384
     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
383 385
     $strip = array('%0d', '%0a', '%0D', '%0A');
384 386
     $url = _deep_replace($strip, $url);
@@ -388,8 +390,9 @@  discard block
 block discarded – undo
388 390
      * link starting with /, # or ? or a php file).
389 391
      */
390 392
     if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
391
-        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
392
-        $url = 'http://' . $url;
393
+        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) {
394
+            $url = 'http://' . $url;
395
+    }
393 396
 
394 397
     return Security::remove_XSS($url);
395 398
 
@@ -466,8 +469,9 @@  discard block
 block discarded – undo
466 469
     $dest = $matches[2];
467 470
     $dest = 'http://' . $dest;
468 471
     $dest = esc_url($dest);
469
-    if ( empty($dest) )
470
-        return $matches[0];
472
+    if ( empty($dest) ) {
473
+            return $matches[0];
474
+    }
471 475
 
472 476
     // removed trailing [.,;:)] from URL
473 477
     if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
@@ -511,10 +515,11 @@  discard block
 block discarded – undo
511 515
     $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
512 516
     foreach ( $textarr as $piece ) {
513 517
 
514
-        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
515
-            $nested_code_pre++;
516
-        elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
517
-            $nested_code_pre--;
518
+        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) {
519
+                    $nested_code_pre++;
520
+        } elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) {
521
+                    $nested_code_pre--;
522
+        }
518 523
 
519 524
         if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
520 525
             $r .= $piece;
@@ -723,15 +728,13 @@  discard block
 block discarded – undo
723 728
 			if($length>$maxchar)
724 729
 			{
725 730
 				break;
726
-			}
727
-			else
731
+			} else
728 732
 			{
729 733
 				$output = $output." ".$words[$i];
730 734
 				$i++;
731 735
 			};
732 736
 		};
733
-	}
734
-	else
737
+	} else
735 738
 	{
736 739
 		$output = $text;
737 740
 		return $output;
@@ -782,13 +785,21 @@  discard block
 block discarded – undo
782 785
     if (isset($array['Y']) && (isset($array['F']) || isset($array['M']))  && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
783 786
         $year = $array['Y'];
784 787
         $month = isset($array['F'])?$array['F']:$array['M'];
785
-        if (intval($month) < 10 ) $month = '0'.$month;
788
+        if (intval($month) < 10 ) {
789
+            $month = '0'.$month;
790
+        }
786 791
         $day = $array['d'];
787
-        if (intval($day) < 10 ) $day = '0'.$day;
792
+        if (intval($day) < 10 ) {
793
+            $day = '0'.$day;
794
+        }
788 795
         $hours = $array['H'];
789
-        if (intval($hours) < 10 ) $hours = '0'.$hours;
796
+        if (intval($hours) < 10 ) {
797
+            $hours = '0'.$hours;
798
+        }
790 799
         $minutes = $array['i'];
791
-        if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
800
+        if (intval($minutes) < 10 ) {
801
+            $minutes = '0'.$minutes;
802
+        }
792 803
     }
793 804
     if (checkdate($month,$day,$year)) {
794 805
         $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
  */
694 694
 function get_week_from_day($date) {
695 695
     if (!empty($date)) {
696
-       $time = api_strtotime($date,'UTC');
697
-       return date('W', $time);
696
+        $time = api_strtotime($date,'UTC');
697
+        return date('W', $time);
698 698
     } else {
699 699
         return date('W');
700 700
     }
@@ -712,31 +712,31 @@  discard block
 block discarded – undo
712 712
 
713 713
 function substrwords($text,$maxchar,$end='...')
714 714
 {
715
-	if(strlen($text)>$maxchar)
716
-	{
717
-		$words=explode(" ",$text);
718
-		$output = '';
719
-		$i=0;
720
-		while(1)
721
-		{
722
-			$length = (strlen($output)+strlen($words[$i]));
723
-			if($length>$maxchar)
724
-			{
725
-				break;
726
-			}
727
-			else
728
-			{
729
-				$output = $output." ".$words[$i];
730
-				$i++;
731
-			};
732
-		};
733
-	}
734
-	else
735
-	{
736
-		$output = $text;
737
-		return $output;
738
-	}
739
-	return $output.$end;
715
+    if(strlen($text)>$maxchar)
716
+    {
717
+        $words=explode(" ",$text);
718
+        $output = '';
719
+        $i=0;
720
+        while(1)
721
+        {
722
+            $length = (strlen($output)+strlen($words[$i]));
723
+            if($length>$maxchar)
724
+            {
725
+                break;
726
+            }
727
+            else
728
+            {
729
+                $output = $output." ".$words[$i];
730
+                $i++;
731
+            };
732
+        };
733
+    }
734
+    else
735
+    {
736
+        $output = $text;
737
+        return $output;
738
+    }
739
+    return $output.$end;
740 740
 }
741 741
 
742 742
 function implode_with_key($glue, $array) {
Please login to merge, or discard this patch.
main/inc/lib/timeline.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      * @todo the form should be auto generated
74 74
      * @param   string  url
75 75
      * @param   string  action add, edit
76
-     * @return  obj     form validator obj
76
+     * @return  FormValidator     form validator obj
77 77
      */
78 78
     public function return_form($url, $action)
79 79
     {
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     );
26 26
     public $is_course_model = true;
27 27
 
28
-	public function __construct()
28
+    public function __construct()
29 29
     {
30 30
         $this->table =  Database::get_course_table(TABLE_TIMELINE);
31
-	}
31
+    }
32 32
 
33 33
     /**
34 34
      * Get the count of elements
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Displays the title + grid
54 54
      */
55
-	public function listing()
55
+    public function listing()
56 56
     {
57
-		// action links
58
-		$html = '<div class="actions">';
57
+        // action links
58
+        $html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
-		$html .= '</div>';
60
+        $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
+        $html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
64
-	}
64
+    }
65 65
 
66 66
     public function get_status_list()
67 67
     {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70'));
91 91
         //$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
92
-	    $status_list = $this->get_status_list();
92
+        $status_list = $this->get_status_list();
93 93
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
94 94
         if ($action == 'edit') {
95 95
             //$form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         // Setting the rules
175 175
         $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
176
-		return $form;
176
+        return $form;
177 177
 
178 178
     }
179 179
 
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
     public function save_item($params)
185 185
     {
186 186
         $params['c_id'] = api_get_course_int_id();
187
-	    $id = parent::save($params);
188
-	    if (!empty($id)) {
189
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
-   		}
191
-   		return $id;
187
+        $id = parent::save($params);
188
+        if (!empty($id)) {
189
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
+            }
191
+            return $id;
192 192
     }
193 193
 
194 194
     /**
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
         $params['c_id'] = api_get_course_int_id();
200 200
         $params['parent_id'] = '0';
201 201
         $params['type'] = 'default';
202
-	    $id = parent::save($params);
203
-	    if (!empty($id)) {
204
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
-   		}
206
-   		return $id;
202
+        $id = parent::save($params);
203
+        if (!empty($id)) {
204
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
+            }
206
+            return $id;
207 207
     }
208 208
 
209 209
     public function delete($id) {
210
-	    parent::delete($id);
211
-	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
210
+        parent::delete($id);
211
+        //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
212 212
     }
213 213
 
214 214
     public function get_url($id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $item['asset'] = array( 'media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250
-         );
250
+            );
251 251
 
252 252
         //Cleaning items
253 253
         unset($item['id']);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct()
29 29
     {
30
-        $this->table =  Database::get_course_table(TABLE_TIMELINE);
30
+        $this->table = Database::get_course_table(TABLE_TIMELINE);
31 31
 	}
32 32
 
33 33
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function get_all($where_conditions = array())
48 48
     {
49
-        return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'headline ASC'));
49
+        return Database::select('*', $this->table, array('where'=>$where_conditions, 'order' =>'headline ASC'));
50 50
     }
51 51
 
52 52
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		// action links
58 58
 		$html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
60
+		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
61 61
 		$html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         }
245 245
         unset($item['end_date']);
246 246
         // Assets
247
-        $item['asset'] = array( 'media'     => $item['media'],
247
+        $item['asset'] = array('media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250 250
          );
Please login to merge, or discard this patch.
main/inc/lib/urlmanager.lib.php 4 patches
Doc Comments   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     * @param	string	$url The URL of the site
19 19
     * @param	string  $description The description of the site
20 20
     * @param	int		$active is active or not
21
-    * @return boolean if success
21
+    * @return Doctrine\DBAL\Driver\Statement|null if success
22 22
     */
23 23
     public static function add($url, $description, $active)
24 24
     {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     * @param	string 	$url
44 44
     * @param	string  $description The description of the site
45 45
     * @param	int		$active is active or not
46
-    * @return 	boolean if success
46
+    * @return 	Doctrine\DBAL\Driver\Statement|null if success
47 47
     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     * @author Julio Montoya
68 68
     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
70
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
71 71
     * */
72 72
     public static function delete($id)
73 73
     {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     * @author Julio Montoya
367 367
     * @param int user id
368 368
     * @param int url id
369
-    * @return boolean true if success
369
+    * @return integer true if success
370 370
     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     * @author Julio Montoya
385 385
     * @param int $courseId
386 386
     * @param int $urlId
387
-    * @return boolean true if success
387
+    * @return integer true if success
388 388
     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @author Julio Montoya
406 406
      * @param int $userGroupId
407 407
      * @param int $urlId
408
-     * @return boolean true if success
408
+     * @return integer true if success
409 409
      * */
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     * @author Julio Montoya
425 425
     * @param int user id
426 426
     * @param int url id
427
-    * @return boolean true if success
427
+    * @return integer true if success
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
@@ -545,6 +545,8 @@  discard block
 block discarded – undo
545 545
      * @author Julio Montoya
546 546
      * @param  array of course ids
547 547
      * @param  array of url_ids
548
+     * @param integer[] $courseCategoryList
549
+     * @param integer[] $urlList
548 550
      * @return array
549 551
      **/
550 552
     public static function addCourseCategoryListToUrl($courseCategoryList, $urlList)
@@ -575,7 +577,7 @@  discard block
 block discarded – undo
575 577
      * @author Julio Montoya
576 578
      * @param int $categoryCourseId
577 579
      * @param int $urlId
578
-     * @return boolean true if success
580
+     * @return integer true if success
579 581
      * */
580 582
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 583
     {
@@ -592,7 +594,7 @@  discard block
 block discarded – undo
592 594
     /**
593 595
      * @param int $userGroupId
594 596
      * @param int $urlId
595
-     * @return int
597
+     * @return string
596 598
      */
597 599
     public static function addUserGroupToUrl($userGroupId, $urlId)
598 600
     {
@@ -692,7 +694,7 @@  discard block
 block discarded – undo
692 694
      * @param int $courseId
693 695
      * @param int $url_id
694 696
      *
695
-     * @return resource
697
+     * @return boolean
696 698
      */
697 699
     public static function add_course_to_url($courseId, $url_id = 1)
698 700
     {
@@ -763,7 +765,7 @@  discard block
 block discarded – undo
763 765
     * @param  int  $courseId
764 766
     * @param  int  $urlId
765 767
      *
766
-    * @return boolean true if success
768
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
767 769
     * */
768 770
     public static function delete_url_rel_course($courseId, $urlId)
769 771
     {
@@ -781,7 +783,7 @@  discard block
 block discarded – undo
781 783
      * @param  int $userGroupId
782 784
      * @param  int $urlId
783 785
      *
784
-     * @return boolean true if success
786
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
785 787
      * */
786 788
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
787 789
     {
@@ -800,7 +802,7 @@  discard block
 block discarded – undo
800 802
      * @param  int $userGroupId
801 803
      * @param  int $urlId
802 804
      *
803
-     * @return boolean true if success
805
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
804 806
      * */
805 807
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
806 808
     {
@@ -819,7 +821,7 @@  discard block
 block discarded – undo
819 821
     * @param  char  course code
820 822
     * @param  int url id
821 823
      *
822
-    * @return boolean true if success
824
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
823 825
     * */
824 826
     public static function delete_url_rel_session($session_id, $url_id)
825 827
     {
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 class UrlManager
12 12
 {
13 13
     /**
14
-    * Creates a new url access
15
-    *
16
-    * @author Julio Montoya <[email protected]>,
17
-    *
18
-    * @param	string	$url The URL of the site
19
-    * @param	string  $description The description of the site
20
-    * @param	int		$active is active or not
21
-    * @return boolean if success
22
-    */
14
+     * Creates a new url access
15
+     *
16
+     * @author Julio Montoya <[email protected]>,
17
+     *
18
+     * @param	string	$url The URL of the site
19
+     * @param	string  $description The description of the site
20
+     * @param	int		$active is active or not
21
+     * @return boolean if success
22
+     */
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Updates an URL access
40
-    * @author Julio Montoya <[email protected]>,
41
-    *
42
-    * @param	int 	$url_id The url id
43
-    * @param	string 	$url
44
-    * @param	string  $description The description of the site
45
-    * @param	int		$active is active or not
46
-    * @return 	boolean if success
47
-    */
39
+     * Updates an URL access
40
+     * @author Julio Montoya <[email protected]>,
41
+     *
42
+     * @param	int 	$url_id The url id
43
+     * @param	string 	$url
44
+     * @param	string  $description The description of the site
45
+     * @param	int		$active is active or not
46
+     * @return 	boolean if success
47
+     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
50 50
         $url_id = intval($url_id);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     /**
66
-    * Deletes an url
67
-    * @author Julio Montoya
68
-    * @param int $id url id
66
+     * Deletes an url
67
+     * @author Julio Montoya
68
+     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
71
-    * */
70
+     * @return boolean true if success
71
+     * */
72 72
     public static function delete($id)
73 73
     {
74 74
         $id = intval($id);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     /**
203
-    * Gets the inner join of access_url and the course table
204
-    *
205
-    * @author Julio Montoya
206
-    * @param int  access url id
207
-    * @return array   Database::store_result of the result
208
-    **/
203
+     * Gets the inner join of access_url and the course table
204
+     *
205
+     * @author Julio Montoya
206
+     * @param int  access url id
207
+     * @return array   Database::store_result of the result
208
+     **/
209 209
     public static function get_url_rel_course_data($access_url_id = null)
210 210
     {
211 211
         $where = '';
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
     }
363 363
 
364 364
     /**
365
-    * Checks the relationship between an URL and a User (return the num_rows)
366
-    * @author Julio Montoya
367
-    * @param int user id
368
-    * @param int url id
369
-    * @return boolean true if success
370
-    * */
365
+     * Checks the relationship between an URL and a User (return the num_rows)
366
+     * @author Julio Montoya
367
+     * @param int user id
368
+     * @param int url id
369
+     * @return boolean true if success
370
+     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
         $num = Database::num_rows($result);
378 378
 
379 379
         return $num;
380
-	}
380
+    }
381 381
 
382 382
     /**
383
-    * Checks the relationship between an URL and a Course (return the num_rows)
384
-    * @author Julio Montoya
385
-    * @param int $courseId
386
-    * @param int $urlId
387
-    * @return boolean true if success
388
-    * */
383
+     * Checks the relationship between an URL and a Course (return the num_rows)
384
+     * @author Julio Montoya
385
+     * @param int $courseId
386
+     * @param int $urlId
387
+     * @return boolean true if success
388
+     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
     /**
423
-    * Checks the relationship between an URL and a Session (return the num_rows)
424
-    * @author Julio Montoya
425
-    * @param int user id
426
-    * @param int url id
427
-    * @return boolean true if success
428
-    * */
423
+     * Checks the relationship between an URL and a Session (return the num_rows)
424
+     * @author Julio Montoya
425
+     * @param int user id
426
+     * @param int url id
427
+     * @return boolean true if success
428
+     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431 431
         $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
     }
738 738
 
739 739
     /**
740
-    * Deletes an url and user relationship
741
-    * @author Julio Montoya
742
-    * @param int user id
743
-    * @param int url id
740
+     * Deletes an url and user relationship
741
+     * @author Julio Montoya
742
+     * @param int user id
743
+     * @param int url id
744 744
      *
745
-    * @return boolean true if success
746
-    * */
745
+     * @return boolean true if success
746
+     * */
747 747
     public static function delete_url_rel_user($user_id, $url_id)
748 748
     {
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
     }
759 759
 
760 760
     /**
761
-    * Deletes an url and course relationship
762
-    * @author Julio Montoya
763
-    * @param  int  $courseId
764
-    * @param  int  $urlId
761
+     * Deletes an url and course relationship
762
+     * @author Julio Montoya
763
+     * @param  int  $courseId
764
+     * @param  int  $urlId
765 765
      *
766
-    * @return boolean true if success
767
-    * */
766
+     * @return boolean true if success
767
+     * */
768 768
     public static function delete_url_rel_course($courseId, $urlId)
769 769
     {
770 770
         $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
     }
815 815
 
816 816
     /**
817
-    * Deletes an url and session relationship
818
-    * @author Julio Montoya
819
-    * @param  char  course code
820
-    * @param  int url id
817
+     * Deletes an url and session relationship
818
+     * @author Julio Montoya
819
+     * @param  char  course code
820
+     * @param  int url id
821 821
      *
822
-    * @return boolean true if success
823
-    * */
822
+     * @return boolean true if success
823
+     * */
824 824
     public static function delete_url_rel_session($session_id, $url_id)
825 825
     {
826 826
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -262,8 +262,9 @@
 block discarded – undo
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265
-        if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
265
+        if (!empty($access_url_id)) {
266
+                    $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267
+        }
267 268
 
268 269
         $sql = "SELECT id, name, access_url_id
269 270
                 FROM $tbl_session u
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
26
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
26
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
27 27
         $sql = "INSERT INTO $table
28 28
                 SET url 	= '".Database::escape_string($url)."',
29 29
                 description = '".Database::escape_string($description)."',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $id = intval($id);
75 75
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
76
-        $sql= "DELETE FROM $table WHERE id = ".$id;
76
+        $sql = "DELETE FROM $table WHERE id = ".$id;
77 77
         $result = Database::query($sql);
78 78
 
79 79
         return $result;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function url_exist($url)
88 88
     {
89
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
89
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
90 90
         $sql = "SELECT id FROM $table
91 91
                 WHERE url = '".Database::escape_string($url)."' ";
92 92
         $res = Database::query($sql);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * */
121 121
     public static function url_count()
122 122
     {
123
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
123
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
124 124
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
125 125
         $res = Database::query($sql);
126
-        $url = Database::fetch_array($res,'ASSOC');
126
+        $url = Database::fetch_array($res, 'ASSOC');
127 127
         $result = $url['count_result'];
128 128
 
129 129
         return $result;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 FROM $table
142 142
                 ORDER BY id";
143 143
         $res = Database::query($sql);
144
-        $urls = array ();
144
+        $urls = array();
145 145
         while ($url = Database::fetch_array($res)) {
146 146
             $urls[] = $url;
147 147
         }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      **/
259 259
     public static function get_url_rel_session_data($access_url_id = null)
260 260
     {
261
-        $where ='';
261
+        $where = '';
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265 265
         if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
266
+            $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267 267
 
268 268
         $sql = "SELECT id, name, access_url_id
269 269
                 FROM $tbl_session u
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
294 294
 
295 295
         if (!empty($access_url_id)) {
296
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
296
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
297 297
         }
298 298
 
299 299
         $sql = "SELECT id, name, access_url_id
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
374
-        $sql= "SELECT user_id FROM $table
374
+        $sql = "SELECT user_id FROM $table
375 375
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
376 376
         $result = Database::query($sql);
377 377
         $num = Database::num_rows($result);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
392
-        $sql= "SELECT c_id FROM $table_url_rel_course
392
+        $sql = "SELECT c_id FROM $table_url_rel_course
393 393
                WHERE
394 394
                     access_url_id = ".intval($urlId)." AND
395 395
                     c_id = '".intval($courseId)."'";
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
412 412
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
413
-        $sql= "SELECT usergroup_id FROM $table
413
+        $sql = "SELECT usergroup_id FROM $table
414 414
                WHERE access_url_id = ".intval($urlId)." AND
415 415
                      usergroup_id = ".intval($userGroupId);
416 416
         $result = Database::query($sql);
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
431
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
432 432
         $session_id = intval($session_id);
433
-        $url_id		= intval($url_id);
433
+        $url_id = intval($url_id);
434 434
         $sql = "SELECT session_id FROM $table_url_rel_session
435 435
                 WHERE
436 436
                     access_url_id = ".intval($url_id)." AND
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
454 454
         $result_array = array();
455 455
 
456
-        if (is_array($user_list) && is_array($url_list)){
456
+        if (is_array($user_list) && is_array($url_list)) {
457 457
             foreach ($url_list as $url_id) {
458 458
                 foreach ($user_list as $user_id) {
459
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
460
-                    if ($count==0) {
459
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
460
+                    if ($count == 0) {
461 461
                         $sql = "INSERT INTO $table_url_rel_user
462 462
                                 SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id);
463 463
                         $result = Database::query($sql);
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
      * @param  array of url_ids
483 483
      * @return array
484 484
      **/
485
-    public static function add_courses_to_urls($course_list,$url_list)
485
+    public static function add_courses_to_urls($course_list, $url_list)
486 486
     {
487 487
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
488 488
         $result_array = array();
489 489
 
490
-        if (is_array($course_list) && is_array($url_list)){
490
+        if (is_array($course_list) && is_array($url_list)) {
491 491
             foreach ($url_list as $url_id) {
492 492
                 foreach ($course_list as $course_code) {
493 493
                     $courseInfo = api_get_course_info($course_code);
494 494
                     $courseId = $courseInfo['real_id'];
495 495
 
496 496
                     $count = self::relation_url_course_exist($courseId, $url_id);
497
-                    if ($count==0) {
497
+                    if ($count == 0) {
498 498
                         $sql = "INSERT INTO $table_url_rel_course
499 499
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
500 500
                         $result = Database::query($sql);
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 581
     {
582 582
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
583
-        $sql= "SELECT course_category_id FROM $table
583
+        $sql = "SELECT course_category_id FROM $table
584 584
                WHERE access_url_id = ".intval($urlId)." AND
585 585
                      course_category_id = ".intval($categoryCourseId);
586 586
         $result = Database::query($sql);
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
750 750
         $result = true;
751 751
         if (!empty($user_id) && !empty($url_id)) {
752
-            $sql= "DELETE FROM $table_url_rel_user
752
+            $sql = "DELETE FROM $table_url_rel_user
753 753
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
754 754
             $result = Database::query($sql);
755 755
         }
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
770 770
         $result = true;
771 771
         if (!empty($userId)) {
772
-            $sql= "DELETE FROM $table_url_rel_user
772
+            $sql = "DELETE FROM $table_url_rel_user
773 773
                    WHERE user_id = ".intval($userId);
774 774
             Database::query($sql);
775 775
         }
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
     * */
788 788
     public static function delete_url_rel_course($courseId, $urlId)
789 789
     {
790
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
-        $sql= "DELETE FROM $table_url_rel_course
790
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
+        $sql = "DELETE FROM $table_url_rel_course
792 792
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
793 793
         $result = Database::query($sql);
794 794
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
807 807
     {
808 808
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
809
-        $sql= "DELETE FROM $table
809
+        $sql = "DELETE FROM $table
810 810
                WHERE usergroup_id = '".intval($userGroupId)."' AND
811 811
                      access_url_id=".intval($urlId)."  ";
812 812
         $result = Database::query($sql);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
826 826
     {
827 827
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
828
-        $sql= "DELETE FROM $table
828
+        $sql = "DELETE FROM $table
829 829
                WHERE course_category_id = '".intval($userGroupId)."' AND
830 830
                      access_url_id=".intval($urlId)."  ";
831 831
         $result = Database::query($sql);
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
     public static function delete_url_rel_session($session_id, $url_id)
845 845
     {
846 846
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
847
-        $sql= "DELETE FROM $table_url_rel_session
847
+        $sql = "DELETE FROM $table_url_rel_session
848 848
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
849
-        $result = Database::query($sql,'ASSOC');
849
+        $result = Database::query($sql, 'ASSOC');
850 850
 
851 851
         return $result;
852 852
     }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      * */
860 860
     public static function update_urls_rel_user($user_list, $access_url_id)
861 861
     {
862
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
862
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
863 863
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
864 864
         $result = Database::query($sql);
865 865
         $existing_users = array();
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
         $result = Database::query($sql);
914 914
 
915 915
         $existing_courses = array();
916
-        while ($row = Database::fetch_array($result)){
916
+        while ($row = Database::fetch_array($result)) {
917 917
             $existing_courses[] = $row['c_id'];
918 918
         }
919 919
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         $result = Database::query($sql);
947 947
         $existingItems = array();
948 948
 
949
-        while ($row = Database::fetch_array($result)){
949
+        while ($row = Database::fetch_array($result)) {
950 950
             $existingItems[] = $row['usergroup_id'];
951 951
         }
952 952
 
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
         $result = Database::query($sql);
980 980
         $existingItems = array();
981 981
 
982
-        while ($row = Database::fetch_array($result)){
982
+        while ($row = Database::fetch_array($result)) {
983 983
             $existingItems[] = $row['course_category_id'];
984 984
         }
985 985
 
@@ -1020,15 +1020,15 @@  discard block
 block discarded – undo
1020 1020
      * @param array user list
1021 1021
      * @param int access_url_id
1022 1022
      * */
1023
-    public static function update_urls_rel_session($session_list,$access_url_id)
1023
+    public static function update_urls_rel_session($session_list, $access_url_id)
1024 1024
     {
1025
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1025
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1026 1026
 
1027 1027
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1028 1028
         $result = Database::query($sql);
1029 1029
         $existing_sessions = array();
1030 1030
 
1031
-        while ($row = Database::fetch_array($result)){
1031
+        while ($row = Database::fetch_array($result)) {
1032 1032
             $existing_sessions[] = $row['session_id'];
1033 1033
         }
1034 1034
 
@@ -1057,13 +1057,13 @@  discard block
 block discarded – undo
1057 1057
      */
1058 1058
     public static function get_access_url_from_user($user_id)
1059 1059
     {
1060
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1060
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1062 1062
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1063 1063
                 ON (url_rel_user.access_url_id = u.id)
1064 1064
                 WHERE user_id = ".intval($user_id);
1065 1065
         $result = Database::query($sql);
1066
-        $url_list = Database::store_result($result,'ASSOC');
1066
+        $url_list = Database::store_result($result, 'ASSOC');
1067 1067
         return $url_list;
1068 1068
     }
1069 1069
 
@@ -1073,14 +1073,14 @@  discard block
 block discarded – undo
1073 1073
      */
1074 1074
     public static function get_access_url_from_course($courseId)
1075 1075
     {
1076
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1076
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1078 1078
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1079 1079
                 ON (c.access_url_id = u.id)
1080 1080
                 WHERE c_id = ".intval($courseId);
1081 1081
 
1082 1082
         $result = Database::query($sql);
1083
-        $url_list = Database::store_result($result,'ASSOC');
1083
+        $url_list = Database::store_result($result, 'ASSOC');
1084 1084
         return $url_list;
1085 1085
     }
1086 1086
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
     public static function get_access_url_from_session($session_id)
1092 1092
     {
1093 1093
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1094
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1094
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1095 1095
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1096 1096
                 ON (url_rel_session.access_url_id = u.id)
1097 1097
                 WHERE session_id = ".intval($session_id);
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
      */
1108 1108
     public static function get_url_id($url)
1109 1109
     {
1110
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1110
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1111 1111
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1112 1112
         $result = Database::query($sql);
1113 1113
         $access_url_id = Database::result($result, 0, 0);
Please login to merge, or discard this patch.
main/inc/lib/usergroup.lib.php 3 patches
Doc Comments   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
      * @param int    $groupId
1014 1014
      * @param string $picture
1015 1015
      *
1016
-     * @return bool|string
1016
+     * @return false|string
1017 1017
      */
1018 1018
     public function manageFileUpload($groupId, $picture)
1019 1019
     {
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
     }
1156 1156
 
1157 1157
     /**
1158
-     * @return mixed
1158
+     * @return integer
1159 1159
      */
1160 1160
     public function getGroupType()
1161 1161
     {
@@ -1359,6 +1359,8 @@  discard block
 block discarded – undo
1359 1359
      * @param string height
1360 1360
      * @param string picture size it can be small_,  medium_  or  big_
1361 1361
      * @param string style css
1362
+     * @param integer $height
1363
+     * @param integer $size_picture
1362 1364
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1363 1365
      */
1364 1366
     public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
@@ -1420,7 +1422,7 @@  discard block
 block discarded – undo
1420 1422
      * @param	string	Type of path to return (can be 'none', 'system', 'rel', 'web')
1421 1423
      * @param	bool	Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
1422 1424
      * @param	bool	If we want that the function returns the /main/img/unknown.jpg image set it at true
1423
-     * @return	array 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1425
+     * @return	integer 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1424 1426
      */
1425 1427
     public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
1426 1428
     {
@@ -1470,7 +1472,7 @@  discard block
 block discarded – undo
1470 1472
     }
1471 1473
 
1472 1474
     /**
1473
-     * @return array
1475
+     * @return string[]
1474 1476
      */
1475 1477
     public function getAllowedPictureExtensions()
1476 1478
     {
@@ -1660,7 +1662,7 @@  discard block
 block discarded – undo
1660 1662
      * @author Julio Montoya
1661 1663
      * @param  int  $user_id
1662 1664
      * @param  int $group_id
1663
-     * @return boolean true if success
1665
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
1664 1666
      * */
1665 1667
     public function delete_user_rel_group($user_id, $group_id)
1666 1668
     {
@@ -1872,6 +1874,8 @@  discard block
 block discarded – undo
1872 1874
      * @param int from value
1873 1875
      * @param int limit
1874 1876
      * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px')
1877
+     * @param integer $from
1878
+     * @param integer $limit
1875 1879
      * @return array list of users in a group
1876 1880
      */
1877 1881
     public function get_users_by_group(
@@ -1970,6 +1974,8 @@  discard block
 block discarded – undo
1970 1974
      * Shows the left column of the group page
1971 1975
      * @param int group id
1972 1976
      * @param int user id
1977
+     * @param integer $group_id
1978
+     * @param integer $user_id
1973 1979
      *
1974 1980
      */
1975 1981
     public function show_group_column_information($group_id, $user_id, $show = '')
@@ -2323,7 +2329,7 @@  discard block
 block discarded – undo
2323 2329
      * @param int $group_id
2324 2330
      * @param int $parent_group_id if 0, we delete the parent_group association
2325 2331
      * @param int $relation_type
2326
-     * @return resource
2332
+     * @return Doctrine\DBAL\Driver\Statement|null
2327 2333
      **/
2328 2334
     public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1)
2329 2335
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1906,8 +1906,9 @@
 block discarded – undo
1906 1906
                 $new_relation_type[] ="'$rel'";
1907 1907
             }
1908 1908
             $relation_type = implode(',', $new_relation_type);
1909
-            if (!empty($relation_type))
1910
-                $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1909
+            if (!empty($relation_type)) {
1910
+                            $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1911
+            }
1911 1912
         }
1912 1913
 
1913 1914
         $sql = "SELECT picture_uri as image, u.id, u.firstname, u.lastname, relation_type
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             ";
83 83
             $result = Database::query($sql);
84 84
             if (Database::num_rows($result)) {
85
-                $row  = Database::fetch_array($result);
85
+                $row = Database::fetch_array($result);
86 86
 
87 87
                 return $row['count'];
88 88
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             ";
103 103
             $result = Database::query($sql);
104 104
             if (Database::num_rows($result)) {
105
-                $row  = Database::fetch_array($result);
105
+                $row = Database::fetch_array($result);
106 106
                 return $row['count'];
107 107
             }
108 108
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             ";
128 128
             $result = Database::query($sql);
129 129
             if (Database::num_rows($result)) {
130
-                $row  = Database::fetch_array($result);
130
+                $row = Database::fetch_array($result);
131 131
                 return $row['count'];
132 132
             }
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             ";
149 149
             $result = Database::query($sql);
150 150
             if (Database::num_rows($result)) {
151
-                $row  = Database::fetch_array($result);
151
+                $row = Database::fetch_array($result);
152 152
                 return $row['count'];
153 153
             }
154 154
 
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
                 INNER JOIN {$this->table} g
530 530
                 ON (u.usergroup_id = g.id)
531 531
                 ";
532
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
532
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
533 533
         } else {
534 534
             $from = $this->usergroup_rel_user_table." u
535 535
                 INNER JOIN {$this->table} g
536 536
                 ON (u.usergroup_id = g.id)
537 537
                 ";
538
-            $where =  array('where' => array('user_id = ?' => $userId));
538
+            $where = array('where' => array('user_id = ?' => $userId));
539 539
         }
540 540
 
541 541
         if ($filterByType !== null) {
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
             $urlId = api_get_current_access_url_id();
569 569
             $from = $this->usergroup_rel_user_table." u
570 570
                     INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
571
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
571
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
572 572
         } else {
573 573
             $from = $this->usergroup_rel_user_table." u ";
574
-            $where =  array('where' => array('user_id = ?' => $userId));
574
+            $where = array('where' => array('user_id = ?' => $userId));
575 575
         }
576 576
 
577 577
         $results = Database::select(
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
             }
858 858
             $result = $new_result;
859 859
         }
860
-        $columns = array('name', 'users', 'courses','sessions', 'group_type');
860
+        $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
861 861
 
862 862
         if (!in_array($sidx, $columns)) {
863 863
             $sidx = 'name';
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
                 }
1264 1264
             }
1265 1265
         }
1266
-        $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
1266
+        $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
1267 1267
 
1268 1268
         return $response;
1269 1269
     }
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
      * @param string style css
1373 1373
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1374 1374
      */
1375
-    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
1375
+    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
1376 1376
     {
1377 1377
         $picture = array();
1378 1378
         $picture['style'] = $style;
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
             if (file_exists($file) && !is_dir($file)) {
1416 1416
                 $picture['file'] = $image_array['dir'].$picture_file;
1417 1417
             } else {
1418
-                $picture['file'] = Display::returnIconPath('group_na.png',64);
1418
+                $picture['file'] = Display::returnIconPath('group_na.png', 64);
1419 1419
             }
1420 1420
         }
1421 1421
         return $picture;
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
      */
1486 1486
     public function getAllowedPictureExtensions()
1487 1487
     {
1488
-        return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
1488
+        return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
1489 1489
     }
1490 1490
 
1491 1491
     /**
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
         if (empty($user_id)) {
1520 1520
             $user_id = api_get_user_id();
1521 1521
         }
1522
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1522
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1523 1523
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
1524 1524
             return true;
1525 1525
         } else {
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         if (empty($user_id)) {
1538 1538
             $user_id = api_get_user_id();
1539 1539
         }
1540
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1540
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1541 1541
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
1542 1542
             return true;
1543 1543
         } else {
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             GROUP_USER_PERMISSION_READER,
1565 1565
             GROUP_USER_PERMISSION_HRM,
1566 1566
         );
1567
-        $user_role	= self::get_user_group_role($user_id, $group_id);
1567
+        $user_role = self::get_user_group_role($user_id, $group_id);
1568 1568
         if (in_array($user_role, $roles)) {
1569 1569
             return true;
1570 1570
         } else {
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
      * */
1582 1582
     public function get_user_group_role($user_id, $group_id)
1583 1583
     {
1584
-        $table_group_rel_user= $this->usergroup_rel_user_table;
1584
+        $table_group_rel_user = $this->usergroup_rel_user_table;
1585 1585
         $return_value = 0;
1586 1586
         if (!empty($user_id) && !empty($group_id)) {
1587 1587
             $sql = "SELECT relation_type FROM $table_group_rel_user
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
                         usergroup_id = ".intval($group_id)." AND
1590 1590
                         user_id = ".intval($user_id)." ";
1591 1591
             $result = Database::query($sql);
1592
-            if (Database::num_rows($result)>0) {
1593
-                $row = Database::fetch_array($result,'ASSOC');
1592
+            if (Database::num_rows($result) > 0) {
1593
+                $row = Database::fetch_array($result, 'ASSOC');
1594 1594
                 $return_value = $row['relation_type'];
1595 1595
             }
1596 1596
         }
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
         if (is_array($user_list) && is_array($group_list)) {
1646 1646
             foreach ($group_list as $group_id) {
1647 1647
                 foreach ($user_list as $user_id) {
1648
-                    $role = self::get_user_group_role($user_id,$group_id);
1648
+                    $role = self::get_user_group_role($user_id, $group_id);
1649 1649
                     if ($role == 0) {
1650 1650
                         $sql = "INSERT INTO $table_url_rel_group
1651 1651
 		               			SET
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
     public function delete_user_rel_group($user_id, $group_id)
1677 1677
     {
1678 1678
         $table = $this->usergroup_rel_user_table;
1679
-        $sql= "DELETE FROM $table
1679
+        $sql = "DELETE FROM $table
1680 1680
                WHERE
1681 1681
                 user_id = ".intval($user_id)." AND
1682 1682
                 usergroup_id = ".intval($group_id)."  ";
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 
1733 1733
         $sql = "UPDATE $table_group_rel_user
1734 1734
    				SET relation_type = ".intval($relation_type)."
1735
-                WHERE user_id = $user_id AND usergroup_id = $group_id" ;
1735
+                WHERE user_id = $user_id AND usergroup_id = $group_id";
1736 1736
         Database::query($sql);
1737 1737
     }
1738 1738
 
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
         if (Database::num_rows($result) > 0) {
1775 1775
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1776 1776
                 if ($with_image) {
1777
-                    $picture = self::get_picture_group($row['id'], $row['picture'],80);
1777
+                    $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1778 1778
                     $img = '<img src="'.$picture['file'].'" />';
1779 1779
                     $row['picture'] = $img;
1780 1780
                 }
@@ -1810,11 +1810,11 @@  discard block
 block discarded – undo
1810 1810
 				ORDER BY count DESC
1811 1811
 				LIMIT $num";
1812 1812
 
1813
-        $result=Database::query($sql);
1813
+        $result = Database::query($sql);
1814 1814
         $array = array();
1815 1815
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1816 1816
             if ($with_image) {
1817
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1817
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1818 1818
                 $img = '<img src="'.$picture['file'].'" />';
1819 1819
                 $row['picture'] = $img;
1820 1820
             }
@@ -1859,11 +1859,11 @@  discard block
 block discarded – undo
1859 1859
                 ORDER BY created_at DESC
1860 1860
                 LIMIT $num ";
1861 1861
 
1862
-        $result=Database::query($sql);
1862
+        $result = Database::query($sql);
1863 1863
         $array = array();
1864 1864
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1865 1865
             if ($with_image) {
1866
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1866
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1867 1867
                 $img = '<img src="'.$picture['file'].'" />';
1868 1868
                 $row['picture'] = $img;
1869 1869
             }
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1898 1898
         $group_id = intval($group_id);
1899 1899
 
1900
-        if (empty($group_id)){
1900
+        if (empty($group_id)) {
1901 1901
             return array();
1902 1902
         }
1903 1903
 
@@ -1912,9 +1912,9 @@  discard block
 block discarded – undo
1912 1912
             $where_relation_condition = '';
1913 1913
         } else {
1914 1914
             $new_relation_type = array();
1915
-            foreach($relation_type as $rel) {
1915
+            foreach ($relation_type as $rel) {
1916 1916
                 $rel = intval($rel);
1917
-                $new_relation_type[] ="'$rel'";
1917
+                $new_relation_type[] = "'$rel'";
1918 1918
             }
1919 1919
             $relation_type = implode(',', $new_relation_type);
1920 1920
             if (!empty($relation_type))
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1959 1959
         $group_id = intval($group_id);
1960 1960
 
1961
-        if (empty($group_id)){
1961
+        if (empty($group_id)) {
1962 1962
             return array();
1963 1963
         }
1964 1964
 
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 			    WHERE gu.usergroup_id= $group_id
1970 1970
 			    ORDER BY relation_type, firstname";
1971 1971
 
1972
-        $result=Database::query($sql);
1972
+        $result = Database::query($sql);
1973 1973
         $array = array();
1974 1974
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1975 1975
             $array[$row['id']] = $row;
@@ -1998,33 +1998,33 @@  discard block
 block discarded – undo
1998 1998
             case GROUP_USER_PERMISSION_READER:
1999 1999
                 // I'm just a reader
2000 2000
                 $relation_group_title = get_lang('IAmAReader');
2001
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2002
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2003
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2004
-                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2001
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2002
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2003
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2004
+                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2005 2005
                 if (UserGroup::canLeave($group_info)) {
2006
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2007
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2006
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2007
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2008 2008
                 }
2009 2009
                 break;
2010 2010
             case GROUP_USER_PERMISSION_ADMIN:
2011 2011
                 $relation_group_title = get_lang('IAmAnAdmin');
2012
-                $links .=  '<li class="'. ($show == 'group_edit' ? 'active' : '') .'"><a href="group_edit.php?id='.$group_id.'">'.
2013
-                            Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '</a></li>';
2014
-                $links .=  '<li class="'. ($show == 'member_list' ? 'active' : '') .'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2015
-                            Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2016
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2017
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2012
+                $links .= '<li class="'.($show == 'group_edit' ? 'active' : '').'"><a href="group_edit.php?id='.$group_id.'">'.
2013
+                            Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'</a></li>';
2014
+                $links .= '<li class="'.($show == 'member_list' ? 'active' : '').'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2015
+                            Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2016
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2017
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2018 2018
                 if (UserGroup::canLeave($group_info)) {
2019 2019
                     $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2020
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2020
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2021 2021
                 }
2022 2022
                 break;
2023 2023
             case GROUP_USER_PERMISSION_PENDING_INVITATION:
2024 2024
 //				$links .=  '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>';
2025 2025
                 break;
2026 2026
             case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
2027
-                $relation_group_title =  get_lang('WaitingForAdminResponse');
2027
+                $relation_group_title = get_lang('WaitingForAdminResponse');
2028 2028
                 break;
2029 2029
             case GROUP_USER_PERMISSION_MODERATOR:
2030 2030
                 $relation_group_title = get_lang('IAmAModerator');
@@ -2032,28 +2032,28 @@  discard block
 block discarded – undo
2032 2032
                 //$links .=  '<li><a href="groups.php?id='.$group_id.'">'.				Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
2033 2033
                 //$links .=  '<li><a href="group_members.php?id='.$group_id.'">'.		Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
2034 2034
                 if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
2035
-                    $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2036
-                                Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2035
+                    $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2036
+                                Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2037 2037
                 }
2038
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2038
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2040 2040
                 if (UserGroup::canLeave($group_info)) {
2041
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2042
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2041
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2042
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2043 2043
                 }
2044 2044
                 break;
2045 2045
             case GROUP_USER_PERMISSION_HRM:
2046 2046
                 $relation_group_title = get_lang('IAmAHRM');
2047 2047
                 $links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax" title="'.get_lang('ComposeMessage').'" data-size="lg" data-title="'.get_lang('ComposeMessage').'">'.
2048
-                            Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '</a></li>';
2049
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'">'.
2050
-                            Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '</a></li>';
2051
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2052
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2053
-                $links .=  '<li><a href="group_members.php?id='.$group_id.'">'.
2054
-                            Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '</a></li>';
2055
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2056
-                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2048
+                            Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').'</a></li>';
2049
+                $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
2050
+                            Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'</a></li>';
2051
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2052
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2053
+                $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
2054
+                            Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'</a></li>';
2055
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2056
+                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2057 2057
                 break;
2058 2058
             default:
2059 2059
                 //$links .=  '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
      */
2091 2091
     public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
2092 2092
     {
2093
-        $table_group_rel_user	= $this->usergroup_rel_user_table;
2094
-        $tbl_group				= $this->table;
2095
-        $user_id 				= intval($user_id);
2093
+        $table_group_rel_user = $this->usergroup_rel_user_table;
2094
+        $tbl_group = $this->table;
2095
+        $user_id = intval($user_id);
2096 2096
 
2097 2097
         if ($relation_type == 0) {
2098 2098
             $where_relation_condition = '';
2099 2099
         } else {
2100
-            $relation_type 			= intval($relation_type);
2100
+            $relation_type = intval($relation_type);
2101 2101
             $where_relation_condition = "AND gu.relation_type = $relation_type ";
2102 2102
         }
2103 2103
 
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
         }
2171 2171
 
2172 2172
         $direction = 'ASC';
2173
-        if (!in_array($direction, array('ASC','DESC'))) {
2173
+        if (!in_array($direction, array('ASC', 'DESC'))) {
2174 2174
             $direction = 'ASC';
2175 2175
         }
2176 2176
 
@@ -2181,8 +2181,8 @@  discard block
 block discarded – undo
2181 2181
         $sql .= " LIMIT $from,$number_of_items";
2182 2182
 
2183 2183
         $res = Database::query($sql);
2184
-        if (Database::num_rows($res)> 0) {
2185
-            while ($row = Database::fetch_array($res,'ASSOC')) {
2184
+        if (Database::num_rows($res) > 0) {
2185
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
2186 2186
                 if (!in_array($row['id'], $return)) {
2187 2187
                     $return[$row['id']] = $row;
2188 2188
                 }
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
             if ($i == $max_level) {
2208 2208
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
2209 2209
             } else {
2210
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
2210
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
2211 2211
             }
2212 2212
             if ($i == 1) {
2213 2213
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
         $nameList = '<ul class="list-unstyled">';
2396 2396
 
2397 2397
         foreach ($groupsNameListParsed as $name) {
2398
-            $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
2398
+            $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>';
2399 2399
         }
2400 2400
 
2401 2401
         $nameList .= '</ul>';
Please login to merge, or discard this patch.