Passed
Push — 1.10.x ( aae6b1...e5a590 )
by Yannick
131:05 queued 81:36
created
main/inc/lib/formvalidator/Rule/UsernameAvailable.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
  */
7 7
 class HTML_QuickForm_Rule_UsernameAvailable extends HTML_QuickForm_Rule
8 8
 {
9
-	/**
10
-	 * Function to check if a username is available
11
-	 * @see HTML_QuickForm_Rule
12
-	 * @param string $username Wanted username
13
-	 * @param string $current_username
14
-	 * @return boolean True if username is available
15
-	 */
16
-	function validate($username, $current_username = null) {
17
-		$user_table = Database::get_main_table(TABLE_MAIN_USER);
9
+    /**
10
+     * Function to check if a username is available
11
+     * @see HTML_QuickForm_Rule
12
+     * @param string $username Wanted username
13
+     * @param string $current_username
14
+     * @return boolean True if username is available
15
+     */
16
+    function validate($username, $current_username = null) {
17
+        $user_table = Database::get_main_table(TABLE_MAIN_USER);
18 18
         $username = Database::escape_string($username);
19 19
         $current_username = Database::escape_string($current_username);
20 20
 
21
-		$sql = "SELECT * FROM $user_table WHERE username = '$username'";
22
-		if (!is_null($current_username)) {
23
-			$sql .= " AND username != '$current_username'";
24
-		}
25
-		$res = Database::query($sql);
26
-		$number = Database::num_rows($res);
27
-		return $number == 0;
28
-	}
21
+        $sql = "SELECT * FROM $user_table WHERE username = '$username'";
22
+        if (!is_null($current_username)) {
23
+            $sql .= " AND username != '$current_username'";
24
+        }
25
+        $res = Database::query($sql);
26
+        $number = Database::num_rows($res);
27
+        return $number == 0;
28
+    }
29 29
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/CompareDateTimeText.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * @return boolean True if the 2 given dates match the operator
13 13
      */
14 14
     function validate($values, $operator = null) {
15
-    	$datetime1 = api_strtotime($values[0]);
15
+        $datetime1 = api_strtotime($values[0]);
16 16
         $datetime2 = api_strtotime($values[1]);
17 17
 
18 18
         if (strpos($operator, 'allow_empty') !== false) {
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
                 return true;
22 22
             }
23 23
         }
24
-		$result =  parent::validate(array($datetime1, $datetime2), $operator);
24
+        $result =  parent::validate(array($datetime1, $datetime2), $operator);
25 25
         return $result;
26 26
     }
27 27
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/MultipleRequired.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     function validate($value, $options = null)
29 29
     {
30
-    	if(is_array($value))
31
-    	{
32
-    		$value = implode(null,$value);
33
-    	}
30
+        if(is_array($value))
31
+        {
32
+            $value = implode(null,$value);
33
+        }
34 34
         if ((string)$value == '') {
35 35
             return false;
36 36
         }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/FileName.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,18 +9,18 @@
 block discarded – undo
9 9
 class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule
10 10
 {
11 11
 
12
-	/**
13
-	 * @param $value array     Uploaded file info (from $_FILES)
14
-	 * @param null $options
15
-	 * @return bool
16
-	 */
17
-	public function validate($value, $options = null)
18
-	{
19
-		if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
20
-			(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
21
-			return is_uploaded_file($elementValue['tmp_name']);
22
-		} else {
23
-			return false;
24
-		}
25
-	}
12
+    /**
13
+     * @param $value array     Uploaded file info (from $_FILES)
14
+     * @param null $options
15
+     * @return bool
16
+     */
17
+    public function validate($value, $options = null)
18
+    {
19
+        if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
20
+            (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
21
+            return is_uploaded_file($elementValue['tmp_name']);
22
+        } else {
23
+            return false;
24
+        }
25
+    }
26 26
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/MaxFileSize.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
  */
8 8
 class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule
9 9
 {
10
-	/**
11
-	 * @param $value array     Uploaded file info (from $_FILES)
12
-	 * @param null $options
13
-	 * @return bool
14
-	 */
15
-	public function validate($elementValue, $maxSize)
16
-	{
17
-		if (!empty($elementValue['error']) &&
18
-			(UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
-		) {
20
-			return false;
21
-		}
22
-		if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
-			return true;
24
-		}
10
+    /**
11
+     * @param $value array     Uploaded file info (from $_FILES)
12
+     * @param null $options
13
+     * @return bool
14
+     */
15
+    public function validate($elementValue, $maxSize)
16
+    {
17
+        if (!empty($elementValue['error']) &&
18
+            (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
+        ) {
20
+            return false;
21
+        }
22
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
+            return true;
24
+        }
25 25
 
26
-		return ($maxSize >= @filesize($elementValue['tmp_name']));
27
-	}
26
+        return ($maxSize >= @filesize($elementValue['tmp_name']));
27
+    }
28 28
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/CompareFields.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
  */
7 7
 class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare 
8 8
 {
9
-	/**
10
-	 * Function to check an array of fields 	 
11
-	 * @param   array of field names
9
+    /**
10
+     * Function to check an array of fields 	 
11
+     * @param   array of field names
12 12
      * @param   string operator ==, >=, etc
13 13
      * @param   string the value to compare
14
-	 * @return boolean True if date is valid
15
-	 */
16
-	function validate($values, $operator_and_max_value) {
14
+     * @return boolean True if date is valid
15
+     */
16
+    function validate($values, $operator_and_max_value) {
17 17
         if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) {
18
-           $final_value = 0;
19
-           foreach ($values as $value) {
20
-               $final_value += $value;
21
-           }
22
-           $params = explode('@', $operator_and_max_value);
23
-           $operator    = $params[0];
24
-           $max_value   = $params[1];                      
25
-           return parent::validate(array($final_value, $max_value), $operator);
18
+            $final_value = 0;
19
+            foreach ($values as $value) {
20
+                $final_value += $value;
21
+            }
22
+            $params = explode('@', $operator_and_max_value);
23
+            $operator    = $params[0];
24
+            $max_value   = $params[1];                      
25
+            return parent::validate(array($final_value, $max_value), $operator);
26 26
         }
27 27
         return false;        
28
-	}
28
+    }
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
main/inc/lib/system_announcements.lib.php 1 patch
Indentation   +433 added lines, -433 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,112 +321,112 @@  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);
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 361
 
362 362
         $lang = is_null($lang) ? '' : $lang;
363 363
 
364
-		$current_access_url_id = 1;
365
-		if (api_is_multiple_url_enabled()) {
366
-			$current_access_url_id = api_get_current_access_url_id();
367
-		}
368
-
369
-		$params = [
370
-			'title' => $title,
371
-			'content' => $content,
372
-			'date_start' => $start,
373
-			'date_end' => $end,
374
-			'visible_teacher' => $visible_teacher,
375
-			'visible_student' => $visible_student,
376
-			'visible_guest' => $visible_guest,
377
-			'lang' => $lang,
378
-			'access_url_id' => $current_access_url_id,
379
-		];
380
-
381
-		$resultId = Database::insert($db_table, $params);
382
-
383
-		if ($resultId) {
384
-
385
-			if ($sendEmailTest) {
386
-				SystemAnnouncementManager::send_system_announcement_by_email(
387
-					$title,
388
-					$content,
389
-					$visible_teacher,
390
-					$visible_student,
391
-					$lang,
392
-					true
393
-				);
394
-			} else {
395
-				if ($send_mail == 1) {
396
-					SystemAnnouncementManager::send_system_announcement_by_email(
397
-						$title,
398
-						$content,
399
-						$visible_teacher,
400
-						$visible_student,
401
-						$lang
402
-					);
403
-				}
404
-			}
405
-
406
-			if ($add_to_calendar) {
407
-				$agenda = new Agenda();
408
-				$agenda->setType('admin');
409
-				$agenda->addEvent(
410
-					$date_start,
411
-					$date_end,
412
-					false,
413
-					$title,
414
-					$original_content
415
-				);
416
-			}
417
-
418
-			return $resultId;
419
-
420
-		}
421
-
422
-		return false;
423
-	}
364
+        $current_access_url_id = 1;
365
+        if (api_is_multiple_url_enabled()) {
366
+            $current_access_url_id = api_get_current_access_url_id();
367
+        }
368
+
369
+        $params = [
370
+            'title' => $title,
371
+            'content' => $content,
372
+            'date_start' => $start,
373
+            'date_end' => $end,
374
+            'visible_teacher' => $visible_teacher,
375
+            'visible_student' => $visible_student,
376
+            'visible_guest' => $visible_guest,
377
+            'lang' => $lang,
378
+            'access_url_id' => $current_access_url_id,
379
+        ];
380
+
381
+        $resultId = Database::insert($db_table, $params);
382
+
383
+        if ($resultId) {
384
+
385
+            if ($sendEmailTest) {
386
+                SystemAnnouncementManager::send_system_announcement_by_email(
387
+                    $title,
388
+                    $content,
389
+                    $visible_teacher,
390
+                    $visible_student,
391
+                    $lang,
392
+                    true
393
+                );
394
+            } else {
395
+                if ($send_mail == 1) {
396
+                    SystemAnnouncementManager::send_system_announcement_by_email(
397
+                        $title,
398
+                        $content,
399
+                        $visible_teacher,
400
+                        $visible_student,
401
+                        $lang
402
+                    );
403
+                }
404
+            }
405
+
406
+            if ($add_to_calendar) {
407
+                $agenda = new Agenda();
408
+                $agenda->setType('admin');
409
+                $agenda->addEvent(
410
+                    $date_start,
411
+                    $date_end,
412
+                    false,
413
+                    $title,
414
+                    $original_content
415
+                );
416
+            }
417
+
418
+            return $resultId;
419
+
420
+        }
421
+
422
+        return false;
423
+    }
424 424
 
425 425
     /**
426
-    * Makes the announcement id visible only for groups in groups_array
427
-    * @param int announcement id
428
-    * @param array array of group id
429
-    **/
426
+     * Makes the announcement id visible only for groups in groups_array
427
+     * @param int announcement id
428
+     * @param array array of group id
429
+     **/
430 430
     public static function announcement_for_groups($announcement_id, $group_array)
431 431
     {
432 432
         $tbl_announcement_group = Database:: get_main_table(
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
     }
461 461
 
462 462
     /**
463
-    * Gets the groups of this announce
464
-    * @param int announcement id
465
-    * @return array array of group id
466
-    **/
463
+     * Gets the groups of this announce
464
+     * @param int announcement id
465
+     * @return array array of group id
466
+     **/
467 467
     public static function get_announcement_groups($announcement_id)
468 468
     {
469 469
         $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
@@ -482,15 +482,15 @@  discard block
 block discarded – undo
482 482
         return $groups;
483 483
     }
484 484
 
485
-	/**
486
-	 * Updates an announcement to the database
487
-	 * @param integer $id      : id of the announcement
488
-	 * @param string  $title   : title of the announcement
489
-	 * @param string  $content : content of the announcement
490
-	 * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
491
-	 * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
492
-	 * @return	bool	True on success, false on failure
493
-	 */
485
+    /**
486
+     * Updates an announcement to the database
487
+     * @param integer $id      : id of the announcement
488
+     * @param string  $title   : title of the announcement
489
+     * @param string  $content : content of the announcement
490
+     * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
491
+     * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
492
+     * @return	bool	True on success, false on failure
493
+     */
494 494
     public static function update_announcement(
495 495
         $id,
496 496
         $title,
@@ -504,51 +504,51 @@  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
-		$langsql = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'";
518
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
517
+        $langsql = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'";
518
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
519 519
 
520
-		if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
521
-			Display :: display_normal_message(get_lang('InvalidStartDate'));
522
-			return false;
523
-		}
520
+        if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
521
+            Display :: display_normal_message(get_lang('InvalidStartDate'));
522
+            return false;
523
+        }
524 524
 
525
-		if (($date_end_to_compare[1] ||
525
+        if (($date_end_to_compare[1] ||
526 526
             $date_end_to_compare[2] ||
527 527
             $date_end_to_compare[0]) &&
528 528
             !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0])
529 529
         ) {
530
-			Display :: display_normal_message(get_lang('InvalidEndDate'));
531
-			return false;
532
-		}
530
+            Display :: display_normal_message(get_lang('InvalidEndDate'));
531
+            return false;
532
+        }
533 533
 
534
-		if (strlen(trim($title)) == 0) {
535
-			Display::display_normal_message(get_lang('InvalidTitle'));
536
-			return false;
537
-		}
534
+        if (strlen(trim($title)) == 0) {
535
+            Display::display_normal_message(get_lang('InvalidTitle'));
536
+            return false;
537
+        }
538 538
 
539
-	    $start    = api_get_utc_datetime($date_start);
539
+        $start    = api_get_utc_datetime($date_start);
540 540
         $end      = api_get_utc_datetime($date_end);
541 541
 
542
-		$title = Database::escape_string($title);
543
-		$content = Database::escape_string($content);
542
+        $title = Database::escape_string($title);
543
+        $content = Database::escape_string($content);
544 544
 
545
-		//Fixing urls that are sent by email
546
-		$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
547
-		$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
545
+        //Fixing urls that are sent by email
546
+        $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
547
+        $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
548 548
 
549
-		$id = intval($id);
550
-		$sql = "UPDATE ".$db_table." SET lang=$langsql,title='".$title."',content='".$content."',date_start='".$start."',date_end='".$end."', ";
551
-		$sql .= " visible_teacher = '".$visible_teacher."', visible_student = '".$visible_student."', visible_guest = '".$visible_guest."' , access_url_id = '".api_get_current_access_url_id()."'  WHERE id = ".$id;
549
+        $id = intval($id);
550
+        $sql = "UPDATE ".$db_table." SET lang=$langsql,title='".$title."',content='".$content."',date_start='".$start."',date_end='".$end."', ";
551
+        $sql .= " visible_teacher = '".$visible_teacher."', visible_student = '".$visible_student."', visible_guest = '".$visible_guest."' , access_url_id = '".api_get_current_access_url_id()."'  WHERE id = ".$id;
552 552
 
553 553
         if ($sendEmailTest) {
554 554
             SystemAnnouncementManager::send_system_announcement_by_email(
@@ -570,89 +570,89 @@  discard block
 block discarded – undo
570 570
                 );
571 571
             }
572 572
         }
573
-		$res = Database::query($sql);
574
-		if ($res === false) {
573
+        $res = Database::query($sql);
574
+        if ($res === false) {
575 575
 
576
-			return false;
577
-		}
578
-		return true;
579
-	}
576
+            return false;
577
+        }
578
+        return true;
579
+    }
580 580
 
581
-	/**
582
-	 * Deletes an announcement
583
-	 * @param 	int $id The identifier of the announcement that should be
584
-	 * @return	bool	True on success, false on failure
585
-	 */
586
-	public static function delete_announcement($id)
581
+    /**
582
+     * Deletes an announcement
583
+     * @param 	int $id The identifier of the announcement that should be
584
+     * @return	bool	True on success, false on failure
585
+     */
586
+    public static function delete_announcement($id)
587 587
     {
588
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
589
-		$id = intval($id);
590
-		$sql = "DELETE FROM ".$db_table." WHERE id =".$id;
591
-		$res = Database::query($sql);
592
-		if ($res === false) {
593
-
594
-			return false;
595
-		}
596
-		return true;
597
-	}
598
-
599
-	/**
600
-	 * Gets an announcement
601
-	 * @param 	int		$id The identifier of the announcement that should be
602
-	 * @return	object	Object of class StdClass or the required class, containing the query result row
603
-	 */
604
-	public static function get_announcement($id)
588
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
589
+        $id = intval($id);
590
+        $sql = "DELETE FROM ".$db_table." WHERE id =".$id;
591
+        $res = Database::query($sql);
592
+        if ($res === false) {
593
+
594
+            return false;
595
+        }
596
+        return true;
597
+    }
598
+
599
+    /**
600
+     * Gets an announcement
601
+     * @param 	int		$id The identifier of the announcement that should be
602
+     * @return	object	Object of class StdClass or the required class, containing the query result row
603
+     */
604
+    public static function get_announcement($id)
605 605
     {
606
-		$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
607
-		$id = intval($id);
608
-		$sql = "SELECT * FROM ".$db_table." WHERE id = ".$id;
609
-		$announcement = Database::fetch_object(Database::query($sql));
610
-
611
-		return $announcement;
612
-	}
613
-
614
-	/**
615
-	 * Change the visibility of an announcement
616
-	 * @param 	int $announcement_id
617
-	 * @param 	int $user For who should the visibility be changed
606
+        $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
607
+        $id = intval($id);
608
+        $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id;
609
+        $announcement = Database::fetch_object(Database::query($sql));
610
+
611
+        return $announcement;
612
+    }
613
+
614
+    /**
615
+     * Change the visibility of an announcement
616
+     * @param 	int $announcement_id
617
+     * @param 	int $user For who should the visibility be changed
618 618
      * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST)
619
-	 * @return 	bool	True on success, false on failure
620
-	 */
621
-	public static function set_visibility($announcement_id, $user, $visible)
619
+     * @return 	bool	True on success, false on failure
620
+     */
621
+    public static function set_visibility($announcement_id, $user, $visible)
622 622
     {
623
-		$db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
624
-		$visible = intval($visible);
625
-		$announcement_id = intval($announcement_id);
623
+        $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
624
+        $visible = intval($visible);
625
+        $announcement_id = intval($announcement_id);
626 626
 
627 627
         if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) {
628 628
             return false;
629 629
         }
630 630
 
631
-		$field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest'));
631
+        $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest'));
632 632
 
633
-		$sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."'
633
+        $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."'
634 634
 		        WHERE id='".$announcement_id."'";
635
-		$res = Database::query($sql);
636
-
637
-		if ($res === false) {
638
-			return false;
639
-		}
640
-
641
-		return true;
642
-	}
643
-
644
-	/**
645
-	 * Send a system announcement by e-mail to all teachers/students depending on parameters
646
-	 * @param	string	Title
647
-	 * @param	string	Content
648
-	 * @param	int		Whether to send to all teachers (1) or not (0)
649
-	 * @param	int		Whether to send to all students (1) or not (0)
650
-	 * @param	string	Language (optional, considered for all languages if left empty)
635
+        $res = Database::query($sql);
636
+
637
+        if ($res === false) {
638
+            return false;
639
+        }
640
+
641
+        return true;
642
+    }
643
+
644
+    /**
645
+     * Send a system announcement by e-mail to all teachers/students depending on parameters
646
+     * @param	string	Title
647
+     * @param	string	Content
648
+     * @param	int		Whether to send to all teachers (1) or not (0)
649
+     * @param	int		Whether to send to all students (1) or not (0)
650
+     * @param	string	Language (optional, considered for all languages if left empty)
651 651
      * @return  bool    True if the message was sent or there was no destination matching. False on database or e-mail sending error.
652
-	 */
653
-	public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false)
652
+     */
653
+    public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false)
654 654
     {
655
-		global $charset;
655
+        global $charset;
656 656
 
657 657
         $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
658 658
         $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset);
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
         }
672 672
 
673 673
         if ($teacher <> 0 AND $student == 0) {
674
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
675
-		}
674
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
675
+        }
676 676
 
677
-		if ($teacher == 0 AND $student <> 0) {
678
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
679
-		}
677
+        if ($teacher == 0 AND $student <> 0) {
678
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
679
+        }
680 680
 
681
-		if ($teacher<> 0 AND $student <> 0) {
682
-			$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
683
-		}
681
+        if ($teacher<> 0 AND $student <> 0) {
682
+            $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
683
+        }
684 684
 
685
-		if (!empty($language)) { //special condition because language was already treated for SQL insert before
686
-			$sql .= " AND language = '".Database::escape_string($language)."' ";
687
-		}
685
+        if (!empty($language)) { //special condition because language was already treated for SQL insert before
686
+            $sql .= " AND language = '".Database::escape_string($language)."' ";
687
+        }
688 688
 
689
-		if (api_is_multiple_url_enabled()) {
689
+        if (api_is_multiple_url_enabled()) {
690 690
             $sql .= " AND access_url_id = '".$current_access_url_id."' ";
691 691
         }
692 692
 
@@ -696,25 +696,25 @@  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')) {
700
-			return true;
701
-		}
699
+        if ((empty($teacher) or $teacher == '0') AND  (empty($student) or $student == '0')) {
700
+            return true;
701
+        }
702 702
 
703
-		$result = Database::query($sql);
704
-		if ($result === false) {
705
-			return false;
706
-		}
703
+        $result = Database::query($sql);
704
+        if ($result === false) {
705
+            return false;
706
+        }
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
-		}
714
-		return $message_sent; //true if at least one e-mail was sent
715
-	}
713
+        }
714
+        return $message_sent; //true if at least one e-mail was sent
715
+    }
716 716
 
717
-	/**
717
+    /**
718 718
      * Displays announcements as an slideshow
719 719
      * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
720 720
      * @param int $id The identifier of the announcement to display
Please login to merge, or discard this patch.
main/inc/lib/pear/excelreader/OLERead.inc 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 
26 26
 function GetInt4d($data, $pos)
27 27
 {
28
-	$value = ord($data[$pos]) | (ord($data[$pos+1])	<< 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
29
-	if ($value>=4294967294)
30
-	{
31
-		$value=-2;
32
-	}
33
-	return $value;
28
+    $value = ord($data[$pos]) | (ord($data[$pos+1])	<< 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
29
+    if ($value>=4294967294)
30
+    {
31
+        $value=-2;
32
+    }
33
+    return $value;
34 34
 }
35 35
 
36 36
 
@@ -45,30 +45,30 @@  discard block
 block discarded – undo
45 45
     
46 46
     function read($sFileName){
47 47
         
48
-    	// check if file exist and is readable (Darko Miljanovic)
49
-    	if(!is_readable($sFileName)) {
50
-    		$this->error = 1;
51
-    		return false;
52
-    	}
48
+        // check if file exist and is readable (Darko Miljanovic)
49
+        if(!is_readable($sFileName)) {
50
+            $this->error = 1;
51
+            return false;
52
+        }
53 53
     	
54
-    	$this->data = @file_get_contents($sFileName);
55
-    	if (!$this->data) { 
56
-    		$this->error = 1; 
57
-    		return false; 
58
-   		}
59
-   		//echo IDENTIFIER_OLE;
60
-   		//echo 'start';
61
-   		if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
62
-    		$this->error = 1; 
63
-    		return false; 
64
-   		}
54
+        $this->data = @file_get_contents($sFileName);
55
+        if (!$this->data) { 
56
+            $this->error = 1; 
57
+            return false; 
58
+            }
59
+            //echo IDENTIFIER_OLE;
60
+            //echo 'start';
61
+            if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
62
+            $this->error = 1; 
63
+            return false; 
64
+            }
65 65
         $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
66 66
         $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
67 67
         $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
68 68
         $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
69 69
         $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
70 70
         
71
-	/*
71
+    /*
72 72
         echo $this->numBigBlockDepotBlocks." ";
73 73
         echo $this->sbdStartBlock." ";
74 74
         echo $this->rootStartBlock." ";
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
         //echo "sbdStartBlock = $this->sbdStartBlock\n";
79 79
         $bigBlockDepotBlocks = array();
80 80
         $pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
81
-       // echo "pos = $pos";
82
-	$bbdBlocks = $this->numBigBlockDepotBlocks;
81
+        // echo "pos = $pos";
82
+    $bbdBlocks = $this->numBigBlockDepotBlocks;
83 83
         
84 84
             if ($this->numExtensionBlocks != 0) {
85 85
                 $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4; 
86 86
             }
87 87
         
88 88
         for ($i = 0; $i < $bbdBlocks; $i++) {
89
-              $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
90
-              $pos += 4;
89
+                $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
90
+                $pos += 4;
91 91
         }
92 92
         
93 93
         
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             }
107 107
         }
108 108
 
109
-       // var_dump($bigBlockDepotBlocks);
109
+        // var_dump($bigBlockDepotBlocks);
110 110
         
111 111
         // readBigBlockDepot
112 112
         $pos = 0;
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
             }
124 124
         }
125 125
 
126
-	//var_dump($this->bigBlockChain);
126
+    //var_dump($this->bigBlockChain);
127 127
         //echo '=====2';
128 128
         // readSmallBlockDepot();
129 129
         $pos = 0;
130
-	    $index = 0;
131
-	    $sbdBlock = $this->sbdStartBlock;
132
-	    $this->smallBlockChain = array();
130
+        $index = 0;
131
+        $sbdBlock = $this->sbdStartBlock;
132
+        $this->smallBlockChain = array();
133 133
 	
134
-	    while ($sbdBlock != -2) {
134
+        while ($sbdBlock != -2) {
135 135
 	
136
-	      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
136
+            $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
137 137
 	
138
-	      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
139
-	        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
140
-	        $pos += 4;
141
-	        $index++;
142
-	      }
138
+            for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
139
+            $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
140
+            $pos += 4;
141
+            $index++;
142
+            }
143 143
 	
144
-	      $sbdBlock = $this->bigBlockChain[$sbdBlock];
145
-	    }
144
+            $sbdBlock = $this->bigBlockChain[$sbdBlock];
145
+        }
146 146
 
147 147
         
148 148
         // readData(rootStartBlock)
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
     }
164 164
     
165
-     function __readData($bl) {
165
+        function __readData($bl) {
166 166
         $block = $bl;
167 167
         $pos = 0;
168 168
         $data = '';
@@ -171,28 +171,28 @@  discard block
 block discarded – undo
171 171
             $pos = ($block + 1) * BIG_BLOCK_SIZE;
172 172
             $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
173 173
             //echo "pos = $pos data=$data\n";	
174
-	    $block = $this->bigBlockChain[$block];
174
+        $block = $this->bigBlockChain[$block];
175
+        }
176
+        return $data;
175 177
         }
176
-		return $data;
177
-     }
178 178
         
179 179
     function __readPropertySets(){
180 180
         $offset = 0;
181 181
         //var_dump($this->entry);
182 182
         while ($offset < strlen($this->entry)) {
183
-              $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
183
+                $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
184 184
             
185
-              $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
185
+                $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
186 186
               
187
-              $type = ord($d[TYPE_POS]);
188
-              //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
187
+                $type = ord($d[TYPE_POS]);
188
+                //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
189 189
         
190
-              $startBlock = GetInt4d($d, START_BLOCK_POS);
191
-              $size = GetInt4d($d, SIZE_POS);
190
+                $startBlock = GetInt4d($d, START_BLOCK_POS);
191
+                $size = GetInt4d($d, SIZE_POS);
192 192
         
193 193
             $name = '';
194 194
             for ($i = 0; $i < $nameSize ; $i++) {
195
-              $name .= $d[$i];
195
+                $name .= $d[$i];
196 196
             }
197 197
             
198 198
             $name = str_replace("\x00", "", $name);
@@ -221,50 +221,50 @@  discard block
 block discarded – undo
221 221
     
222 222
     
223 223
     function getWorkBook(){
224
-    	if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
224
+        if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
225 225
 //    	  getSmallBlockStream(PropertyStorage ps)
226 226
 
227
-			$rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
227
+            $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
228 228
 	        
229
-			$streamData = '';
230
-	        $block = $this->props[$this->wrkbook]['startBlock'];
231
-	        //$count = 0;
232
-	        $pos = 0;
233
-		    while ($block != -2) {
234
-      	          $pos = $block * SMALL_BLOCK_SIZE;
235
-		          $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
229
+            $streamData = '';
230
+            $block = $this->props[$this->wrkbook]['startBlock'];
231
+            //$count = 0;
232
+            $pos = 0;
233
+            while ($block != -2) {
234
+                    $pos = $block * SMALL_BLOCK_SIZE;
235
+                    $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
236 236
 
237
-			      $block = $this->smallBlockChain[$block];
238
-		    }
237
+                    $block = $this->smallBlockChain[$block];
238
+            }
239 239
 			
240
-		    return $streamData;
240
+            return $streamData;
241 241
     		
242 242
 
243
-    	}else{
243
+        }else{
244 244
     	
245
-	        $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
246
-	        if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
247
-	            $numBlocks++;
248
-	        }
245
+            $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
246
+            if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
247
+                $numBlocks++;
248
+            }
249 249
 	        
250
-	        if ($numBlocks == 0) return '';
250
+            if ($numBlocks == 0) return '';
251 251
 	        
252
-	        //echo "numBlocks = $numBlocks\n";
253
-	    //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
254
-	        //print_r($this->wrkbook);
255
-	        $streamData = '';
256
-	        $block = $this->props[$this->wrkbook]['startBlock'];
257
-	        //$count = 0;
258
-	        $pos = 0;
259
-	        //echo "block = $block";
260
-	        while ($block != -2) {
261
-	          $pos = ($block + 1) * BIG_BLOCK_SIZE;
262
-	          $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
263
-	          $block = $this->bigBlockChain[$block];
264
-	        }   
265
-	        //echo 'stream'.$streamData;
266
-	        return $streamData;
267
-    	}
252
+            //echo "numBlocks = $numBlocks\n";
253
+        //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
254
+            //print_r($this->wrkbook);
255
+            $streamData = '';
256
+            $block = $this->props[$this->wrkbook]['startBlock'];
257
+            //$count = 0;
258
+            $pos = 0;
259
+            //echo "block = $block";
260
+            while ($block != -2) {
261
+                $pos = ($block + 1) * BIG_BLOCK_SIZE;
262
+                $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
263
+                $block = $this->bigBlockChain[$block];
264
+            }   
265
+            //echo 'stream'.$streamData;
266
+            return $streamData;
267
+        }
268 268
     }
269 269
     
270 270
 }
Please login to merge, or discard this patch.
main/inc/lib/pear/excelreader/reader.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
                 case SPREADSHEET_EXCEL_READER_TYPE_SST:
465 465
                     //echo "Type_SST\n";
466 466
                      $spos = $pos + 4;
467
-                     $limitpos = $spos + $length;
468
-                     $uniqueStrings = $this->_GetInt4d($this->data, $spos+4);
467
+                        $limitpos = $spos + $length;
468
+                        $uniqueStrings = $this->_GetInt4d($this->data, $spos+4);
469 469
                                                 $spos += 8;
470
-                                       for ($i = 0; $i < $uniqueStrings; $i++) {
470
+                                        for ($i = 0; $i < $uniqueStrings; $i++) {
471 471
         // Read in the number of characters
472 472
                                                 if ($spos == $limitpos) {
473 473
                                                 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
@@ -496,9 +496,9 @@  discard block
 block discarded – undo
496 496
                                                 }
497 497
 
498 498
                                                 if ($extendedString) {
499
-                                                  // Read in cchExtRst
500
-                                                  $extendedRunLength = $this->_GetInt4d($this->data, $spos);
501
-                                                  $spos += 4;
499
+                                                    // Read in cchExtRst
500
+                                                    $extendedRunLength = $this->_GetInt4d($this->data, $spos);
501
+                                                    $spos += 4;
502 502
                                                 }
503 503
 
504 504
                                                 $len = ($asciiEncoding)? $numChars : $numChars*2;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                                                         $charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2));
513 513
                                                         $spos = $limitpos;
514 514
 
515
-                                                         while ($charsLeft > 0){
515
+                                                            while ($charsLeft > 0){
516 516
                                                                 $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
517 517
                                                                 $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
518 518
                                                                         if ($opcode != 0x3c) {
@@ -522,29 +522,29 @@  discard block
 block discarded – undo
522 522
                                                                 $limitpos = $spos + $conlength;
523 523
                                                                 $option = ord($this->data[$spos]);
524 524
                                                                 $spos += 1;
525
-                                                                  if ($asciiEncoding && ($option == 0)) {
525
+                                                                    if ($asciiEncoding && ($option == 0)) {
526 526
                                                                                 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength);
527 527
                                                                     $retstr .= substr($this->data, $spos, $len);
528 528
                                                                     $charsLeft -= $len;
529 529
                                                                     $asciiEncoding = true;
530
-                                                                  }elseif (!$asciiEncoding && ($option != 0)){
530
+                                                                    }elseif (!$asciiEncoding && ($option != 0)){
531 531
                                                                                 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength);
532 532
                                                                     $retstr .= substr($this->data, $spos, $len);
533 533
                                                                     $charsLeft -= $len/2;
534 534
                                                                     $asciiEncoding = false;
535
-                                                                  }elseif (!$asciiEncoding && ($option == 0)) {
535
+                                                                    }elseif (!$asciiEncoding && ($option == 0)) {
536 536
                                                                 // Bummer - the string starts off as Unicode, but after the
537 537
                                                                 // continuation it is in straightforward ASCII encoding
538 538
                                                                                 $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength);
539 539
                                                                         for ($j = 0; $j < $len; $j++) {
540
-                                                                 $retstr .= $this->data[$spos + $j].chr(0);
540
+                                                                    $retstr .= $this->data[$spos + $j].chr(0);
541 541
                                                                 }
542 542
                                                             $charsLeft -= $len;
543 543
                                                                 $asciiEncoding = false;
544
-                                                                  }else{
544
+                                                                    }else{
545 545
                                                             $newstr = '';
546 546
                                                                     for ($j = 0; $j < strlen($retstr); $j++) {
547
-                                                                      $newstr = $retstr[$j].chr(0);
547
+                                                                        $newstr = $retstr[$j].chr(0);
548 548
                                                                     }
549 549
                                                                     $retstr = $newstr;
550 550
                                                                                 $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength);
@@ -552,28 +552,28 @@  discard block
 block discarded – undo
552 552
                                                                     $charsLeft -= $len/2;
553 553
                                                                     $asciiEncoding = false;
554 554
                                                                         //echo "Izavrat\n";
555
-                                                                  }
556
-                                                          $spos += $len;
555
+                                                                    }
556
+                                                            $spos += $len;
557 557
 
558
-                                                         }
558
+                                                            }
559 559
                                                 }
560 560
                                                 //We check the string before send it check the _encodeUTF16
561 561
                                                 //$retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr);
562 562
                                                 $retstr = ($asciiEncoding) ? $this->_encodeUTF16($retstr, true) : $this->_encodeUTF16($retstr);
563 563
 //                                              echo "Str $i = $retstr\n";
564 564
                                         if ($richString){
565
-                                                  $spos += 4 * $formattingRuns;
565
+                                                    $spos += 4 * $formattingRuns;
566 566
                                                 }
567 567
 
568 568
                                                 // For extended strings, skip over the extended string data
569 569
                                                 if ($extendedString) {
570
-                                                  $spos += $extendedRunLength;
570
+                                                    $spos += $extendedRunLength;
571 571
                                                 }
572 572
                                                         //if ($retstr == 'Derby'){
573 573
                                                         //      echo "bb\n";
574 574
                                                         //}
575 575
                                                 $this->sst[]=$retstr;
576
-                                       }
576
+                                        }
577 577
                     /*$continueRecords = array();
578 578
                     while ($this->getNextCode() == Type_CONTINUE) {
579 579
                         $continueRecords[] = &$this->nextRecord();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
                     $this->shareStrings = new SSTRecord($r, $continueRecords);
583 583
                     //print_r($this->shareStrings->strings);
584 584
                      */
585
-                     // echo 'SST read: '.($time_end-$time_start)."\n";
585
+                        // echo 'SST read: '.($time_end-$time_start)."\n";
586 586
                     break;
587 587
 
588 588
                 case SPREADSHEET_EXCEL_READER_TYPE_FILEPASS:
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                         }
608 608
 
609 609
                     $this->formatRecords[$indexCode] = $formatString;
610
-                   // echo "Type.FORMAT\n";
610
+                    // echo "Type.FORMAT\n";
611 611
                     break;
612 612
                 case SPREADSHEET_EXCEL_READER_TYPE_XF:
613 613
                         //global $dateFormats, $numberFormats;
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                                 $rec_name    = substr($this->data, $pos+11, $rec_length);
679 679
                         }
680 680
                     $this->boundsheets[] = array('name'=>$rec_name,
681
-                                                 'offset'=>$rec_offset);
681
+                                                    'offset'=>$rec_offset);
682 682
 
683 683
                     break;
684 684
 
@@ -820,14 +820,14 @@  discard block
 block discarded – undo
820 820
                                 }
821 821
                             $string = sprintf($this->curformat, $numValue * $this->multiplier);
822 822
                         }
823
-                      //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8;
824
-                      $tmppos += 6;
825
-                      $this->addcell($row, $colFirst + $i, $string, $raw);
826
-                      //echo "MULRK $row ".($colFirst + $i)." $string\n";
823
+                        //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8;
824
+                        $tmppos += 6;
825
+                        $this->addcell($row, $colFirst + $i, $string, $raw);
826
+                        //echo "MULRK $row ".($colFirst + $i)." $string\n";
827 827
                     }
828
-                     //MulRKRecord($r);
828
+                        //MulRKRecord($r);
829 829
                     // Get the individual cell records from the multiple record
830
-                     //$num = ;
830
+                        //$num = ;
831 831
 
832 832
                     break;
833 833
                 case SPREADSHEET_EXCEL_READER_TYPE_NUMBER:
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
                     $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent
837 837
                     if ($this->isDate($spos)) {
838 838
                         list($string, $raw) = $this->createDate($tmp['double']);
839
-                     //   $this->addcell(DateRecord($r, 1));
839
+                        //   $this->addcell(DateRecord($r, 1));
840 840
                     }else{
841 841
                         //$raw = $tmp[''];
842 842
                         if (isset($this->_columnsFormat[$column + 1])){
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
                         $raw = $this->createNumber($spos);
846 846
                         $string = sprintf($this->curformat, $raw * $this->multiplier);
847 847
 
848
-                     //   $this->addcell(NumberRecord($r));
848
+                        //   $this->addcell(NumberRecord($r));
849 849
                     }
850 850
                     $this->addcell($row, $column, $string, $raw);
851 851
                     //echo "Number $row $column $string\n";
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                         $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent
869 869
                         if ($this->isDate($spos)) {
870 870
                             list($string, $raw) = $this->createDate($tmp['double']);
871
-                         //   $this->addcell(DateRecord($r, 1));
871
+                            //   $this->addcell(DateRecord($r, 1));
872 872
                         }else{
873 873
                             //$raw = $tmp[''];
874 874
                             if (isset($this->_columnsFormat[$column + 1])){
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                             $raw = $this->createNumber($spos);
878 878
                             $string = sprintf($this->curformat, $raw * $this->multiplier);
879 879
 
880
-                         //   $this->addcell(NumberRecord($r));
880
+                            //   $this->addcell(NumberRecord($r));
881 881
                         }
882 882
                         $this->addcell($row, $column, $string, $raw);
883 883
                         //echo "Number $row $column $string\n";
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
                     $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
900 900
                     $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8));
901 901
 
902
-                   // $this->addcell(LabelRecord($r));
902
+                    // $this->addcell(LabelRecord($r));
903 903
                     break;
904 904
 
905 905
                 case SPREADSHEET_EXCEL_READER_TYPE_EOF:
@@ -914,9 +914,9 @@  discard block
 block discarded – undo
914 914
         }
915 915
 
916 916
         if (!isset($this->sheets[$this->sn]['numRows']))
917
-             $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow'];
917
+                $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow'];
918 918
         if (!isset($this->sheets[$this->sn]['numCols']))
919
-             $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol'];
919
+                $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol'];
920 920
 
921 921
     }
922 922
 
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 // The RK format calls for using only the most significant 30 bits of the
1034 1034
 // 64 bit floating point value. The other 34 bits are assumed to be 0
1035 1035
 // So, we use the upper 30 bits of $rknum as follows...
1036
-         $sign = ($rknum & 0x80000000) >> 31;
1036
+            $sign = ($rknum & 0x80000000) >> 31;
1037 1037
         $exp = ($rknum & 0x7ff00000) >> 20;
1038 1038
         $mantissa = (0x100000 | ($rknum & 0x000ffffc));
1039 1039
         $value = $mantissa / pow( 2 , (20- ($exp - 1023)));
Please login to merge, or discard this patch.