Completed
Push — 1.11.x ( 6904fa...6a92e6 )
by José
525:44 queued 484:20
created
main/inc/lib/legal.lib.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
     {
16 16
     }
17 17
 
18
-	/**
19
-	 * Add a new Term and Condition
20
-	 * @param int $language language id
21
-	 * @param string $content content
22
-	 * @param int $type term and condition type (0 or 1)
23
-	 * @param string $changes explain changes
24
-	 * @return boolean success
25
-	 */
26
-	public static function add($language, $content, $type, $changes)
18
+    /**
19
+     * Add a new Term and Condition
20
+     * @param int $language language id
21
+     * @param string $content content
22
+     * @param int $type term and condition type (0 or 1)
23
+     * @param string $changes explain changes
24
+     * @return boolean success
25
+     */
26
+    public static function add($language, $content, $type, $changes)
27 27
     {
28 28
         $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
29 29
         $last = self::get_last_condition($language);
@@ -64,59 +64,59 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * @param int $id
66 66
      */
67
-	public static function delete($id)
67
+    public static function delete($id)
68 68
     {
69
-		/*
69
+        /*
70 70
 		$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
71 71
 		$id = intval($id);
72 72
 		$sql = "DELETE FROM $legal_table WHERE id = '".$id."'";
73 73
 		*/
74
-	}
74
+    }
75 75
 
76
-	/**
77
-	 * Gets the last version of a Term and condition by language
78
-	 * @param int $language language id
79
-	 * @return array all the info of a Term and condition
80
-	 */
81
-	public static function get_last_condition_version($language)
76
+    /**
77
+     * Gets the last version of a Term and condition by language
78
+     * @param int $language language id
79
+     * @return array all the info of a Term and condition
80
+     */
81
+    public static function get_last_condition_version($language)
82 82
     {
83
-		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
84
-		$language= Database::escape_string($language);
85
-		$sql = "SELECT version FROM $legal_conditions_table
83
+        $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
84
+        $language= Database::escape_string($language);
85
+        $sql = "SELECT version FROM $legal_conditions_table
86 86
 		        WHERE language_id = '".$language."'
87 87
 		        ORDER BY id DESC LIMIT 1 ";
88
-		$result = Database::query($sql);
89
-		$row = Database::fetch_array($result);
88
+        $result = Database::query($sql);
89
+        $row = Database::fetch_array($result);
90 90
         if (Database::num_rows($result) > 0) {
91 91
 
92
-			return $row['version'];
93
-		} else {
92
+            return $row['version'];
93
+        } else {
94 94
 
95
-			return 0;
96
-		}
97
-	}
95
+            return 0;
96
+        }
97
+    }
98 98
 
99
-	/**
100
-	 * Gets the data of a Term and condition by language
101
-	 * @param int $language language id
102
-	 * @return array all the info of a Term and condition
103
-	 */
104
-	public static function get_last_condition($language)
99
+    /**
100
+     * Gets the data of a Term and condition by language
101
+     * @param int $language language id
102
+     * @return array all the info of a Term and condition
103
+     */
104
+    public static function get_last_condition($language)
105 105
     {
106
-		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
107
-		$language= Database::escape_string($language);
108
-		$sql = "SELECT * FROM $legal_conditions_table
106
+        $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
107
+        $language= Database::escape_string($language);
108
+        $sql = "SELECT * FROM $legal_conditions_table
109 109
                 WHERE language_id = '".$language."'
110 110
                 ORDER BY version DESC
111 111
                 LIMIT 1 ";
112
-		$result = Database::query($sql);
113
-		$result = Database::fetch_array($result, 'ASSOC');
112
+        $result = Database::query($sql);
113
+        $result = Database::fetch_array($result, 'ASSOC');
114 114
 
115 115
         if (isset($result['content'])) {
116 116
             $result['content'] = self::replaceTags($result['content']);
117 117
         }
118 118
         return $result;
119
-	}
119
+    }
120 120
 
121 121
     /**
122 122
      * @param string $content
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         return $content;
142 142
     }
143 143
 
144
-	/**
145
-	 * Gets the last version of a Term and condition by language
146
-	 * @param int $language language id
147
-	 * @return boolean | int the version or false if does not exist
148
-	 */
149
-	public static function get_last_version($language)
144
+    /**
145
+     * Gets the last version of a Term and condition by language
146
+     * @param int $language language id
147
+     * @return boolean | int the version or false if does not exist
148
+     */
149
+    public static function get_last_version($language)
150 150
     {
151 151
         $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
152 152
         $language = intval($language);
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
 
165 165
             return false;
166 166
         }
167
-	}
167
+    }
168 168
 
169
-	/**
170
-	 * Show the last condition
171
-	 * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola');
169
+    /**
170
+     * Show the last condition
171
+     * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola');
172 172
      *
173
-	 * @return string html preview
174
-	 */
175
-	public static function show_last_condition($term_preview)
173
+     * @return string html preview
174
+     */
175
+    public static function show_last_condition($term_preview)
176 176
     {
177 177
         $preview = '';
178 178
         switch ($term_preview['type']) {
@@ -201,37 +201,37 @@  discard block
 block discarded – undo
201 201
             default:
202 202
                 break;
203 203
         }
204
-		return 	$preview;
205
-	}
204
+        return 	$preview;
205
+    }
206 206
 
207
-	/**
208
-	 * Get the terms and condition table (only for maintenance)
209
-	 * @param int $from
210
-	 * @param int $number_of_items
211
-	 * @param int $column
212
-	 * @return array
213
-	 */
214
-	public static function get_legal_data($from, $number_of_items, $column)
207
+    /**
208
+     * Get the terms and condition table (only for maintenance)
209
+     * @param int $from
210
+     * @param int $number_of_items
211
+     * @param int $column
212
+     * @return array
213
+     */
214
+    public static function get_legal_data($from, $number_of_items, $column)
215 215
     {
216
-		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
217
-		$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
218
-		$from = intval($from);
219
-		$number_of_items = intval($number_of_items);
220
-		$column = intval($column);
216
+        $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
217
+        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
218
+        $from = intval($from);
219
+        $number_of_items = intval($number_of_items);
220
+        $column = intval($column);
221 221
 
222
- 		$sql  = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
222
+            $sql  = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
223 223
 				FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) ";
224
-		$sql .= "ORDER BY language, version ASC ";
225
-		$sql .= "LIMIT $from, $number_of_items ";
224
+        $sql .= "ORDER BY language, version ASC ";
225
+        $sql .= "LIMIT $from, $number_of_items ";
226 226
 
227
-		$result = Database::query($sql);
228
-		$legals = array();
229
-		$versions = array();
230
-		while ($legal = Database::fetch_array($result)) {
231
-			// max 2000 chars
232
-			//echo strlen($legal[1]); echo '<br>';
233
-			$versions[] = $legal[0];
234
-			$languages[] = $legal[1];
227
+        $result = Database::query($sql);
228
+        $legals = array();
229
+        $versions = array();
230
+        while ($legal = Database::fetch_array($result)) {
231
+            // max 2000 chars
232
+            //echo strlen($legal[1]); echo '<br>';
233
+            $versions[] = $legal[0];
234
+            $languages[] = $legal[1];
235 235
             if (strlen($legal[2]) > 2000) {
236 236
                 $legal[2] = substr($legal[2], 0, 2000).' ... ';
237 237
             }
@@ -240,50 +240,50 @@  discard block
 block discarded – undo
240 240
             } elseif ($legal[4] == 1) {
241 241
                 $legal[4] = get_lang('PageLink');
242 242
             }
243
-			$legals[] = $legal;
244
-		}
245
-		return $legals;
246
-	}
243
+            $legals[] = $legal;
244
+        }
245
+        return $legals;
246
+    }
247 247
 
248
-	/**
249
-	 * Gets the number of terms and conditions available
250
-	 * @return int
251
-	 */
252
-	public static function count()
248
+    /**
249
+     * Gets the number of terms and conditions available
250
+     * @return int
251
+     */
252
+    public static function count()
253 253
     {
254
-		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
255
-		$sql = "SELECT count(*) as count_result
254
+        $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
255
+        $sql = "SELECT count(*) as count_result
256 256
 		        FROM $legal_conditions_table
257 257
 		        ORDER BY id DESC ";
258
-		$result = Database::query($sql);
259
-		$url = Database::fetch_array($result,'ASSOC');
260
-		$result = $url['count_result'];
258
+        $result = Database::query($sql);
259
+        $url = Database::fetch_array($result,'ASSOC');
260
+        $result = $url['count_result'];
261 261
 
262
-		return $result;
263
-	}
262
+        return $result;
263
+    }
264 264
 
265
-	/**
266
-	 * Get type of terms and conditions
267
-	 * @param int $legal_id
268
-	 * @param int $language_id
269
-	 * @return int The current type of terms and conditions
270
-	 */
271
-	public static function get_type_of_terms_and_conditions($legal_id, $language_id)
265
+    /**
266
+     * Get type of terms and conditions
267
+     * @param int $legal_id
268
+     * @param int $language_id
269
+     * @return int The current type of terms and conditions
270
+     */
271
+    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
272 272
     {
273
-		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
274
-		$legal_id = intval($legal_id);
275
-		$language_id = intval($language_id);
276
-		$sql = 'SELECT type FROM '.$legal_conditions_table.'
273
+        $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
274
+        $legal_id = intval($legal_id);
275
+        $language_id = intval($language_id);
276
+        $sql = 'SELECT type FROM '.$legal_conditions_table.'
277 277
 		        WHERE id =  "'.$legal_id.'" AND language_id="'.$language_id.'"';
278
-		$rs = Database::query($sql);
278
+        $rs = Database::query($sql);
279 279
 
280
-		return Database::result($rs,0,'type');
281
-	}
280
+        return Database::result($rs,0,'type');
281
+    }
282 282
 
283 283
     /**
284 284
      * @param int $userId
285 285
      */
286
-	public static function sendLegal($userId)
286
+    public static function sendLegal($userId)
287 287
     {
288 288
         $subject = get_lang('SendTermsSubject');
289 289
         $content = sprintf(
Please login to merge, or discard this patch.
main/inc/lib/security.lib.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public static function remove_XSS($var, $user_status = null, $filter_terms = false)
306 306
     {
307
-    	if ($filter_terms) {
308
-    		$var = self::filter_terms($var);
309
-    	}
307
+        if ($filter_terms) {
308
+            $var = self::filter_terms($var);
309
+        }
310 310
 
311 311
         if (empty($user_status)) {
312 312
             if (api_is_anonymous()) {
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public static function filter_terms($text)
403 403
     {
404
-    	static $bad_terms = array();
404
+        static $bad_terms = array();
405 405
 
406 406
         if (empty($bad_terms)) {
407 407
             $list = api_get_setting('filter_terms');
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
             }
423 423
         }
424 424
 
425
-    	$replace = '***';
426
-    	if (!empty($bad_terms)) {
427
-    		// Fast way
428
-    		$new_text = str_ireplace($bad_terms, $replace, $text, $count);
429
-    		$text = $new_text;
430
-    	}
425
+        $replace = '***';
426
+        if (!empty($bad_terms)) {
427
+            // Fast way
428
+            $new_text = str_ireplace($bad_terms, $replace, $text, $count);
429
+            $text = $new_text;
430
+        }
431 431
         
432
-		return $text;
432
+        return $text;
433 433
     }
434 434
 
435 435
 
Please login to merge, or discard this patch.
main/inc/lib/online.inc.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
  */
166 166
 function LoginDelete($user_id)
167 167
 {
168
-	$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
168
+    $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
169 169
     $user_id = intval($user_id);
170
-	$query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id";
171
-	Database::query($query);
170
+    $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id";
171
+    Database::query($query);
172 172
 }
173 173
 
174 174
 /**
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function user_is_online($user_id)
179 179
 {
180
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
181
-	$table_user = Database::get_main_table(TABLE_MAIN_USER);
180
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
181
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
182 182
 
183
-	$access_url_id = api_get_current_access_url_id();
184
-	$time_limit = api_get_setting('time_limit_whosonline');
183
+    $access_url_id = api_get_current_access_url_id();
184
+    $time_limit = api_get_setting('time_limit_whosonline');
185 185
 
186 186
     $online_time = time() - $time_limit*60;
187 187
     $limit_date = api_get_utc_datetime($online_time);
188 188
     $user_id = intval($user_id);
189 189
 
190
-	$query = " SELECT login_user_id,login_date
190
+    $query = " SELECT login_user_id,login_date
191 191
                FROM $track_online_table track
192 192
                INNER JOIN $table_user u ON (u.id=track.login_user_id)
193 193
                WHERE
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
                     u.id =  $user_id
197 197
                LIMIT 1 ";
198 198
 
199
-	$result = Database::query($query);
200
-	if (Database::num_rows($result)) {
199
+    $result = Database::query($query);
200
+    if (Database::num_rows($result)) {
201 201
 
202
-		return true;
203
-	}
202
+        return true;
203
+    }
204 204
 
205
-	return false;
205
+    return false;
206 206
 
207 207
 }
208 208
 /**
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 
239 239
     $online_time = time() - $time_limit * 60;
240 240
     $current_date = api_get_utc_datetime($online_time);
241
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
242
-	$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
243
-	$table_user	= Database::get_main_table(TABLE_MAIN_USER);
241
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
242
+    $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
243
+    $table_user	= Database::get_main_table(TABLE_MAIN_USER);
244 244
 
245
-	if ($friends) {
246
-		// 	who friends from social network is online
247
-		$query = "SELECT DISTINCT login_user_id, login_date
245
+    if ($friends) {
246
+        // 	who friends from social network is online
247
+        $query = "SELECT DISTINCT login_user_id, login_date
248 248
 				  FROM $track_online_table INNER JOIN $friend_user_table
249 249
 				  ON (friend_user_id = login_user_id)
250 250
 				  WHERE
@@ -254,21 +254,21 @@  discard block
 block discarded – undo
254 254
                     user_id = '".api_get_user_id()."'
255 255
                   ORDER BY $column $direction
256 256
                   LIMIT $from, $number_of_items";
257
-	} else {
258
-		$query = "SELECT DISTINCT login_user_id, login_date
257
+    } else {
258
+        $query = "SELECT DISTINCT login_user_id, login_date
259 259
                     FROM ".$track_online_table ." e
260 260
 		            INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id)
261 261
                   WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."'
262 262
                   ORDER BY $column $direction
263 263
                   LIMIT $from, $number_of_items";
264
-	}
265
-
266
-	if (api_get_multiple_access_url()) {
267
-		$access_url_id = api_get_current_access_url_id();
268
-		if ($access_url_id != -1) {
269
-			if ($friends) {
270
-				// 	friends from social network is online
271
-				$query = "SELECT distinct login_user_id, login_date
264
+    }
265
+
266
+    if (api_get_multiple_access_url()) {
267
+        $access_url_id = api_get_current_access_url_id();
268
+        if ($access_url_id != -1) {
269
+            if ($friends) {
270
+                // 	friends from social network is online
271
+                $query = "SELECT distinct login_user_id, login_date
272 272
 							FROM $track_online_table track INNER JOIN $friend_user_table
273 273
 							ON (friend_user_id = login_user_id)
274 274
 							WHERE   track.access_url_id =  $access_url_id AND
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
                                     relation_type='".USER_RELATION_TYPE_FRIEND."'
278 278
                             ORDER BY $column $direction
279 279
                             LIMIT $from, $number_of_items";
280
-			} else {
281
-				// all users online
282
-				$query = "SELECT login_user_id, login_date
280
+            } else {
281
+                // all users online
282
+                $query = "SELECT login_user_id, login_date
283 283
 						  FROM ".$track_online_table ." track
284 284
                           INNER JOIN ".$table_user ." u
285 285
                           ON (u.id=track.login_user_id)
@@ -287,26 +287,26 @@  discard block
 block discarded – undo
287 287
                                 login_date >= '".$current_date."'
288 288
                           ORDER BY $column $direction
289 289
                           LIMIT $from, $number_of_items";
290
-			}
291
-		}
292
-	}
290
+            }
291
+        }
292
+    }
293 293
 
294
-	//This query will show all registered users. Only for dev purposes.
295
-	/*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u
294
+    //This query will show all registered users. Only for dev purposes.
295
+    /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u
296 296
             GROUP by u.id
297 297
             ORDER BY $column $direction
298 298
             LIMIT $from, $number_of_items";*/
299 299
 
300
-	$result = Database::query($query);
301
-	if ($result) {
302
-		$users_online = array();
303
-		while (list($login_user_id, $login_date) = Database::fetch_row($result)) {
300
+    $result = Database::query($query);
301
+    if ($result) {
302
+        $users_online = array();
303
+        while (list($login_user_id, $login_date) = Database::fetch_row($result)) {
304 304
             $users_online[] = $login_user_id;
305
-		}
306
-		return $users_online;
307
-	} else {
308
-		return false;
309
-	}
305
+        }
306
+        return $users_online;
307
+    } else {
308
+        return false;
309
+    }
310 310
 }
311 311
 
312 312
 function who_is_online_count($time_limit = null, $friends = false)
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
     } else {
317 317
         $time_limit = intval($time_limit);
318 318
     }
319
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
320
-	$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
321
-	$table_user = Database::get_main_table(TABLE_MAIN_USER);
322
-	$online_time = time() - $time_limit * 60;
323
-	$current_date = api_get_utc_datetime($online_time);
324
-
325
-	if ($friends) {
326
-		// 	who friends from social network is online
327
-		$query = "SELECT DISTINCT count(login_user_id) as count
319
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
320
+    $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
321
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
322
+    $online_time = time() - $time_limit * 60;
323
+    $current_date = api_get_utc_datetime($online_time);
324
+
325
+    if ($friends) {
326
+        // 	who friends from social network is online
327
+        $query = "SELECT DISTINCT count(login_user_id) as count
328 328
 				  FROM $track_online_table INNER JOIN $friend_user_table
329 329
                   ON (friend_user_id = login_user_id)
330 330
 				  WHERE
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 				        friend_user_id <> '".api_get_user_id()."' AND
333 333
 				        relation_type='".USER_RELATION_TYPE_FRIEND."' AND
334 334
 				        user_id = '".api_get_user_id()."' ";
335
-	} else {
336
-		// All users online
337
-		$query = "SELECT count(login_id) as count
335
+    } else {
336
+        // All users online
337
+        $query = "SELECT count(login_id) as count
338 338
                   FROM $track_online_table track INNER JOIN $table_user u
339 339
                   ON (u.id=track.login_user_id)
340 340
                   WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date'  ";
341
-	}
342
-
343
-	if (api_get_multiple_access_url()) {
344
-		$access_url_id = api_get_current_access_url_id();
345
-		if ($access_url_id != -1) {
346
-			if ($friends) {
347
-				// 	friends from social network is online
348
-				$query = "SELECT DISTINCT count(login_user_id) as count
341
+    }
342
+
343
+    if (api_get_multiple_access_url()) {
344
+        $access_url_id = api_get_current_access_url_id();
345
+        if ($access_url_id != -1) {
346
+            if ($friends) {
347
+                // 	friends from social network is online
348
+                $query = "SELECT DISTINCT count(login_user_id) as count
349 349
 							FROM $track_online_table track
350 350
 							INNER JOIN $friend_user_table ON (friend_user_id = login_user_id)
351 351
 							WHERE
@@ -353,29 +353,29 @@  discard block
 block discarded – undo
353 353
 							    login_date >= '".$current_date."' AND
354 354
 							    friend_user_id <> '".api_get_user_id()."' AND
355 355
 							    relation_type='".USER_RELATION_TYPE_FRIEND."'  ";
356
-			} else {
357
-				// all users online
358
-				$query = "SELECT count(login_id) as count FROM $track_online_table  track
356
+            } else {
357
+                // all users online
358
+                $query = "SELECT count(login_id) as count FROM $track_online_table  track
359 359
                           INNER JOIN $table_user u ON (u.id=track.login_user_id)
360 360
 						  WHERE
361 361
 						    u.status != ".ANONYMOUS." AND
362 362
 						    track.access_url_id =  $access_url_id AND
363 363
 						    login_date >= '$current_date' ";
364
-			}
365
-		}
366
-	}
364
+            }
365
+        }
366
+    }
367 367
 
368 368
     // Dev purposes show all users online
369 369
     /*$table_user = Database::get_main_table(TABLE_MAIN_USER);
370 370
     $query = "SELECT count(*)  as count FROM ".$table_user;*/
371 371
 
372
-	$result = Database::query($query);
373
-	if (Database::num_rows($result) > 0) {
374
-		$row = Database::fetch_array($result);
375
-		return $row['count'];
376
-	} else {
377
-		return false;
378
-	}
372
+    $result = Database::query($query);
373
+    if (Database::num_rows($result) > 0) {
374
+        $row = Database::fetch_array($result);
375
+        return $row['count'];
376
+    } else {
377
+        return false;
378
+    }
379 379
 }
380 380
 
381 381
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 */
389 389
 function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code)
390 390
 {
391
-	if (empty($course_code)) return false;
391
+    if (empty($course_code)) return false;
392 392
 
393 393
     if (empty($time_limit)) {
394 394
         $time_limit = api_get_setting('time_limit_whosonline');
@@ -401,55 +401,55 @@  discard block
 block discarded – undo
401 401
     $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
402 402
     $course_code = Database::escape_string($course_code);
403 403
     $courseInfo = api_get_course_info($course_code);
404
-	$courseId = $courseInfo['real_id'];
404
+    $courseId = $courseInfo['real_id'];
405 405
 
406 406
     $from = intval($from);
407 407
     $number_of_items = intval($number_of_items);
408 408
 
409
-	$query = "SELECT login_user_id, login_date FROM $track_online_table
409
+    $query = "SELECT login_user_id, login_date FROM $track_online_table
410 410
               WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date'
411 411
               LIMIT $from, $number_of_items ";
412 412
 
413
-	$result = Database::query($query);
414
-	if ($result) {
415
-		$users_online = array();
413
+    $result = Database::query($query);
414
+    if ($result) {
415
+        $users_online = array();
416 416
 
417
-		while(list($login_user_id, $login_date) = Database::fetch_row($result)) {
417
+        while(list($login_user_id, $login_date) = Database::fetch_row($result)) {
418 418
             $users_online[] = $login_user_id;
419
-		}
420
-		return $users_online;
421
-	} else {
422
-		return false;
423
-	}
419
+        }
420
+        return $users_online;
421
+    } else {
422
+        return false;
423
+    }
424 424
 }
425 425
 
426 426
 function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null)
427 427
 {
428
-	if (empty($coursecode)) {
429
-		return false;
430
-	}
431
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
432
-	$coursecode = Database::escape_string($coursecode);
433
-	$time_limit = Database::escape_string($time_limit);
428
+    if (empty($coursecode)) {
429
+        return false;
430
+    }
431
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
432
+    $coursecode = Database::escape_string($coursecode);
433
+    $time_limit = Database::escape_string($time_limit);
434 434
 
435 435
     $online_time = time() - $time_limit * 60;
436 436
     $current_date = api_get_utc_datetime($online_time);
437
-	$courseId = api_get_course_int_id($coursecode);
437
+    $courseId = api_get_course_int_id($coursecode);
438 438
 
439
-	if (empty($courseId)) {
440
-		return false;
441
-	}
439
+    if (empty($courseId)) {
440
+        return false;
441
+    }
442 442
 
443
-	$query = "SELECT count(login_user_id) as count
443
+    $query = "SELECT count(login_user_id) as count
444 444
               FROM $track_online_table
445 445
               WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' ";
446
-	$result = Database::query($query);
447
-	if (Database::num_rows($result) > 0) {
448
-		$row = Database::fetch_array($result);
449
-		return $row['count'];
450
-	} else {
451
-		return false;
452
-	}
446
+    $result = Database::query($query);
447
+    if (Database::num_rows($result) > 0) {
448
+        $row = Database::fetch_array($result);
449
+        return $row['count'];
450
+    } else {
451
+        return false;
452
+    }
453 453
 }
454 454
 
455 455
 /**
@@ -459,15 +459,15 @@  discard block
 block discarded – undo
459 459
  * @deprecated user api_get_user_info($user_id)
460 460
  */
461 461
 function GetFullUserName($uid) {
462
-	$uid = (int) $uid;
463
-	$uid = intval($uid);
464
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);
465
-	$query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid";
466
-	$result = @Database::query($query);
467
-	if (count($result)>0) {
468
-		while(list($firstname,$lastname)= Database::fetch_array($result)) {
469
-			$str = str_replace(' ', '&nbsp;', api_get_person_name($firstname, $lastname));
470
-			return $str;
471
-		}
472
-	}
462
+    $uid = (int) $uid;
463
+    $uid = intval($uid);
464
+    $user_table = Database::get_main_table(TABLE_MAIN_USER);
465
+    $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid";
466
+    $result = @Database::query($query);
467
+    if (count($result)>0) {
468
+        while(list($firstname,$lastname)= Database::fetch_array($result)) {
469
+            $str = str_replace(' ', '&nbsp;', api_get_person_name($firstname, $lastname));
470
+            return $str;
471
+        }
472
+    }
473 473
 }
Please login to merge, or discard this patch.
main/inc/lib/internationalization.lib.php 1 patch
Indentation   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
     if (isset($_configuration['language_measure_frequency']) &&
96 96
         $_configuration['language_measure_frequency'] == 1
97 97
     ) {
98
-      require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php';
99
-      global $langstats;
100
-      $langstats->add_use($variable,'');
98
+        require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php';
99
+        global $langstats;
100
+        $langstats->add_use($variable,'');
101 101
     }
102 102
 
103 103
     if (!isset($used_lang_vars)) {
104
-    	$used_lang_vars = array();
104
+        $used_lang_vars = array();
105 105
     }
106 106
 
107 107
     // Caching results from some API functions, for speed.
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     static $text_direction = array();
292 292
 
293 293
     if (empty($language)) {
294
-    	$language = api_get_interface_language();
294
+        $language = api_get_interface_language();
295 295
     }
296 296
     if (!isset($text_direction[$language])) {
297 297
         $text_direction[$language] = in_array(api_purify_language_id($language),
@@ -528,24 +528,24 @@  discard block
 block discarded – undo
528 528
             case DATE_FORMAT_ONLY_DAYNAME:
529 529
                 $date_format = get_lang('dateFormatOnlyDayName', '', $language);
530 530
                 if (INTL_INSTALLED) {
531
-        			$datetype = IntlDateFormatter::SHORT;
532
-        			$timetype = IntlDateFormatter::NONE;
533
-        		}
531
+                    $datetype = IntlDateFormatter::SHORT;
532
+                    $timetype = IntlDateFormatter::NONE;
533
+                }
534 534
                 break;
535 535
             case DATE_FORMAT_NUMBER_NO_YEAR:
536 536
                 $date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
537
-        		if (INTL_INSTALLED) {
538
-        			$datetype = IntlDateFormatter::SHORT;
539
-        			$timetype = IntlDateFormatter::NONE;
540
-        		}
537
+                if (INTL_INSTALLED) {
538
+                    $datetype = IntlDateFormatter::SHORT;
539
+                    $timetype = IntlDateFormatter::NONE;
540
+                }
541
+                break;
542
+            case DATE_FORMAT_NUMBER:
543
+                $date_format = get_lang('dateFormatShortNumber', '', $language);
544
+                if (INTL_INSTALLED) {
545
+                    $datetype = IntlDateFormatter::SHORT;
546
+                    $timetype = IntlDateFormatter::NONE;
547
+                }
541 548
                 break;
542
-        	case DATE_FORMAT_NUMBER:
543
-        		$date_format = get_lang('dateFormatShortNumber', '', $language);
544
-        		if (INTL_INSTALLED) {
545
-        			$datetype = IntlDateFormatter::SHORT;
546
-        			$timetype = IntlDateFormatter::NONE;
547
-        		}
548
-        		break;
549 549
             case TIME_NO_SEC_FORMAT:
550 550
                 $date_format = get_lang('timeNoSecFormat', '', $language);
551 551
                 if (INTL_INSTALLED) {
@@ -581,14 +581,14 @@  discard block
 block discarded – undo
581 581
                     $timetype = IntlDateFormatter::SHORT;
582 582
                 }
583 583
                 break;
584
-			case DATE_TIME_FORMAT_SHORT:
584
+            case DATE_TIME_FORMAT_SHORT:
585 585
                 $date_format = get_lang('dateTimeFormatShort', '', $language);
586 586
                 if (INTL_INSTALLED) {
587 587
                     $datetype = IntlDateFormatter::FULL;
588 588
                     $timetype = IntlDateFormatter::SHORT;
589 589
                 }
590 590
                 break;
591
-			case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
591
+            case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
592 592
                 $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language);
593 593
                 if (INTL_INSTALLED) {
594 594
                     $datetype = IntlDateFormatter::FULL;
@@ -1700,7 +1700,6 @@  discard block
 block discarded – undo
1700 1700
 
1701 1701
 /**
1702 1702
  * Return true a date is valid
1703
-
1704 1703
  * @param string $date example: 2014-06-30 13:05:05
1705 1704
  * @param string $format example: "Y-m-d H:i:s"
1706 1705
  *
@@ -1969,15 +1968,15 @@  discard block
 block discarded – undo
1969 1968
 function apiGetHumanDateTime($date, $showTime = true, $humanForm = false) {
1970 1969
     if ($showTime) {
1971 1970
         if ($humanForm) {
1972
-           return $date->format('j M Y H:i:s');
1971
+            return $date->format('j M Y H:i:s');
1973 1972
         } else {
1974
-           return $date->format('Y-m-d H:i:s');
1973
+            return $date->format('Y-m-d H:i:s');
1975 1974
         }
1976 1975
     } else {
1977 1976
         if ($humanForm) {
1978
-           return $date->format('j M Y');
1977
+            return $date->format('j M Y');
1979 1978
         } else {
1980
-           return $date->format('Y-m-d');
1979
+            return $date->format('Y-m-d');
1981 1980
         }
1982 1981
     }
1983 1982
 }
Please login to merge, or discard this patch.
main/glossary/index.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
                     api_get_local_time($glossary_data['update_date'])
140 140
                 );
141 141
             } else {
142
-                 $glossary_data['update_date'] = '';
142
+                    $glossary_data['update_date'] = '';
143 143
             }
144 144
 
145 145
             $form->addLabel(get_lang('CreationDate'), $glossary_data['insert_date']);
Please login to merge, or discard this patch.
main/inc/lib/certificate.lib.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
     }
252 252
 
253 253
     /**
254
-    * update user info about certificate
255
-    * @param int $cat_id category id
256
-    * @param int $user_id user id
257
-    * @param string $path_certificate the path name of the certificate
258
-    * @return void
259
-    */
254
+     * update user info about certificate
255
+     * @param int $cat_id category id
256
+     * @param int $user_id user id
257
+     * @param string $path_certificate the path name of the certificate
258
+     * @return void
259
+     */
260 260
     public function update_user_info_about_certificate(
261 261
         $cat_id,
262 262
         $user_id,
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
     }
360 360
 
361 361
     /**
362
-    * Shows the student's certificate (HTML file). If the global setting
363
-    * allow_public_certificates is set to 'false', no certificate can be printed.
364
-    * If the global allow_public_certificates is set to 'true' and the course
365
-    * setting allow_public_certificates is set to 0, no certificate *in this
366
-    * course* can be printed (for anonymous users). Connected users can always
367
-    * print them.
368
-    */
362
+     * Shows the student's certificate (HTML file). If the global setting
363
+     * allow_public_certificates is set to 'false', no certificate can be printed.
364
+     * If the global allow_public_certificates is set to 'true' and the course
365
+     * setting allow_public_certificates is set to 0, no certificate *in this
366
+     * course* can be printed (for anonymous users). Connected users can always
367
+     * print them.
368
+     */
369 369
     public function show()
370 370
     {
371 371
         // Special rules for anonymous users
Please login to merge, or discard this patch.
main/admin/user_list.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
     $firstname = $userInfo['firstname'];
374 374
     $lastname = $userInfo['lastname'];
375 375
 
376
-	if (api_is_western_name_order()) {
377
-		$message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId);
378
-	} else {
379
-		$message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
380
-	}
376
+    if (api_is_western_name_order()) {
377
+        $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId);
378
+    } else {
379
+        $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
380
+    }
381 381
 
382
-	if ($userId) {
382
+    if ($userId) {
383 383
 
384 384
         // Logout the current user
385 385
         LoginDelete(api_get_user_id());
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     }*/
455 455
 
456 456
     if (!in_array($direction, array('ASC','DESC'))) {
457
-    	$direction = 'ASC';
457
+        $direction = 'ASC';
458 458
     }
459 459
     $column = intval($column);
460 460
     $from = intval($from);
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
         $sql .= " WHERE u.creator_id = ".api_get_user_id();
466 466
     }
467 467
 
468
-	$sql .= " ORDER BY col$column $direction ";
469
-	$sql .= " LIMIT $from,$number_of_items";
468
+    $sql .= " ORDER BY col$column $direction ";
469
+    $sql .= " LIMIT $from,$number_of_items";
470 470
 
471
-	$res = Database::query($sql);
471
+    $res = Database::query($sql);
472 472
 
473
-	$users = array ();
473
+    $users = array ();
474 474
     $t = time();
475
-	while ($user = Database::fetch_row($res)) {
476
-		$userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
477
-		$photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
475
+    while ($user = Database::fetch_row($res)) {
476
+        $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
477
+        $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
478 478
 
479 479
         if ($user[7] == 1 && !empty($user[10])) {
480 480
             // check expiration date
481 481
             $expiration_time = convert_sql_date($user[10]);
482 482
             // if expiration date is passed, store a special value for active field
483 483
             if ($expiration_time < $t) {
484
-        	   $user[7] = '-1';
484
+                $user[7] = '-1';
485 485
             }
486 486
         }
487 487
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 */
512 512
 function email_filter($email)
513 513
 {
514
-	return Display :: encrypted_mailto_link($email, $email);
514
+    return Display :: encrypted_mailto_link($email, $email);
515 515
 }
516 516
 
517 517
 /**
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 */
522 522
 function user_filter($name, $params, $row)
523 523
 {
524
-	return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>';
524
+    return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>';
525 525
 }
526 526
 
527 527
 /**
@@ -533,32 +533,32 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function modify_filter($user_id, $url_params, $row)
535 535
 {
536
-	global $charset, $_admins_list;
536
+    global $charset, $_admins_list;
537 537
     $is_admin = in_array($user_id, $_admins_list);
538 538
     $statusname = api_get_status_langvars();
539 539
     $user_is_anonymous = false;
540 540
     $current_user_status_label = $row['7'];
541 541
 
542
-	if ($current_user_status_label == $statusname[ANONYMOUS]) {
543
-		$user_is_anonymous =true;
544
-	}
545
-	$result = '';
546
-	if (!$user_is_anonymous) {
547
-		$icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')'));
548
-		$result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" >
542
+    if ($current_user_status_label == $statusname[ANONYMOUS]) {
543
+        $user_is_anonymous =true;
544
+    }
545
+    $result = '';
546
+    if (!$user_is_anonymous) {
547
+        $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')'));
548
+        $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" >
549 549
 			        '.$icon.'
550 550
 					<div class="blackboard_hide" id="div_'.$user_id.'">&nbsp;&nbsp;</div>
551 551
 					</a>';
552 552
 
553 553
         $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')'));
554
-		$result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" >
554
+        $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" >
555 555
 					'.$icon.'
556 556
 					<div class="blackboard_hide" id="div_s_'.$user_id.'">&nbsp;&nbsp;</div>
557 557
 					</a>';
558
-	} else {
559
-		$result .= Display::return_icon('course_na.png',get_lang('Courses')).'&nbsp;&nbsp;';
560
-		$result .= Display::return_icon('course_na.png',get_lang('Sessions')).'&nbsp;&nbsp;';
561
-	}
558
+    } else {
559
+        $result .= Display::return_icon('course_na.png',get_lang('Courses')).'&nbsp;&nbsp;';
560
+        $result .= Display::return_icon('course_na.png',get_lang('Sessions')).'&nbsp;&nbsp;';
561
+    }
562 562
 
563 563
     if (api_is_platform_admin()) {
564 564
         if (!$user_is_anonymous) {
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
         );
608 608
     }
609 609
 
610
-	if ($is_admin) {
611
-		$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
612
-	} else {
613
-		$result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
614
-	}
610
+    if ($is_admin) {
611
+        $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
612
+    } else {
613
+        $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
614
+    }
615 615
 
616
-	// actions for assigning sessions, courses or users
617
-	if (!api_is_session_admin()) {
616
+    // actions for assigning sessions, courses or users
617
+    if (!api_is_session_admin()) {
618 618
         if ($current_user_status_label == $statusname[SESSIONADMIN]) {
619 619
             $result .= Display::url(
620 620
                 Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                 );
645 645
             }
646 646
         }
647
-	}
647
+    }
648 648
 
649 649
     if (api_is_platform_admin()) {
650 650
         $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'.
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
             }
663 663
         }
664 664
     }
665
-	return $result;
665
+    return $result;
666 666
 }
667 667
 
668 668
 /**
@@ -694,11 +694,11 @@  discard block
 block discarded – undo
694 694
     if ($action === 'edit') {
695 695
         $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16);
696 696
     } elseif ($row['0'] <> $_user['user_id']) {
697
-    	// you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
698
-		$result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>';
699
-	}
697
+        // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
698
+        $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>';
699
+    }
700 700
 
701
-	return $result;
701
+    return $result;
702 702
 }
703 703
 
704 704
 /**
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
712 712
  */
713 713
 function status_filter($status) {
714
-	$statusname = api_get_status_langvars();
715
-	return $statusname[$status];
714
+    $statusname = api_get_status_langvars();
715
+    return $statusname[$status];
716 716
 }
717 717
 
718 718
 if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) {
@@ -728,8 +728,8 @@  discard block
 block discarded – undo
728 728
 
729 729
 if (!empty($action)) {
730 730
     $check = Security::check_token('get');
731
-	if ($check) {
732
-		switch ($action) {
731
+    if ($check) {
732
+        switch ($action) {
733 733
             case 'add_user_to_my_url':
734 734
                 $user_id = $_REQUEST["user_id"];
735 735
                 $result = UrlManager::add_user_to_url($user_id, $current_access_url_id);
@@ -739,45 +739,45 @@  discard block
 block discarded – undo
739 739
                     $message  = Display::return_message($message, 'confirmation');
740 740
                 }
741 741
                 break;
742
-			case 'delete_user':
743
-				if (api_is_platform_admin()) {
742
+            case 'delete_user':
743
+                if (api_is_platform_admin()) {
744 744
                     $user_to_delete = $_GET['user_id'];
745 745
                     $current_user_id = api_get_user_id();
746 746
 
747
-					if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) {
748
-						if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) {
749
-							$message = Display :: return_message(get_lang('UserDeleted'), 'confirmation');
750
-						} else {
751
-							$message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
752
-						}
753
-					} else {
754
-						$message = Display :: return_message(get_lang('CannotDeleteUser'),'error');
755
-					}
756
-				}
757
-				break;
747
+                    if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) {
748
+                        if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) {
749
+                            $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation');
750
+                        } else {
751
+                            $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
752
+                        }
753
+                    } else {
754
+                        $message = Display :: return_message(get_lang('CannotDeleteUser'),'error');
755
+                    }
756
+                }
757
+                break;
758 758
             case 'delete':
759
-				if (api_is_platform_admin()) {
760
-					$number_of_selected_users = count($_POST['id']);
761
-					$number_of_deleted_users = 0;
762
-					if (is_array($_POST['id'])) {
763
-						foreach ($_POST['id'] as $index => $user_id) {
764
-							if ($user_id != $_user['user_id']) {
765
-								if (UserManager::delete_user($user_id)) {
766
-									$number_of_deleted_users++;
767
-								}
768
-							}
769
-						}
770
-					}
771
-					if ($number_of_selected_users == $number_of_deleted_users) {
759
+                if (api_is_platform_admin()) {
760
+                    $number_of_selected_users = count($_POST['id']);
761
+                    $number_of_deleted_users = 0;
762
+                    if (is_array($_POST['id'])) {
763
+                        foreach ($_POST['id'] as $index => $user_id) {
764
+                            if ($user_id != $_user['user_id']) {
765
+                                if (UserManager::delete_user($user_id)) {
766
+                                    $number_of_deleted_users++;
767
+                                }
768
+                            }
769
+                        }
770
+                    }
771
+                    if ($number_of_selected_users == $number_of_deleted_users) {
772 772
                         $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation');
773
-					} else {
773
+                    } else {
774 774
                         $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error');
775
-					}
776
-				}
777
-				break;
778
-		}
779
-		Security::clear_token();
780
-	}
775
+                    }
776
+                }
777
+                break;
778
+        }
779
+        Security::clear_token();
780
+    }
781 781
 }
782 782
 
783 783
 // Create a search-box
@@ -794,15 +794,15 @@  discard block
 block discarded – undo
794 794
 $actionsCenter = '';
795 795
 $actionsRight  = '';
796 796
 if (api_is_platform_admin()) {
797
-	$actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.
798
-         Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>';
797
+    $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.
798
+            Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>';
799 799
 }
800 800
 
801 801
 $actionsLeft .= $form->returnForm();
802 802
 $actionsCenter .= $searchAdvanced;
803 803
 
804 804
 if (isset($_GET['keyword'])) {
805
-	$parameters = array('keyword' => Security::remove_XSS($_GET['keyword']));
805
+    $parameters = array('keyword' => Security::remove_XSS($_GET['keyword']));
806 806
 } elseif (isset ($_GET['keyword_firstname'])) {
807 807
     $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']);
808 808
     $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']);
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
 $table->set_header(2, get_lang('OfficialCode'));
879 879
 
880 880
 if (api_is_western_name_order()) {
881
-	$table->set_header(3, get_lang('FirstName'));
882
-	$table->set_header(4, get_lang('LastName'));
881
+    $table->set_header(3, get_lang('FirstName'));
882
+    $table->set_header(4, get_lang('LastName'));
883 883
 } else {
884
-	$table->set_header(3, get_lang('LastName'));
885
-	$table->set_header(4, get_lang('FirstName'));
884
+    $table->set_header(3, get_lang('LastName'));
885
+    $table->set_header(4, get_lang('FirstName'));
886 886
 }
887 887
 $table->set_header(5, get_lang('LoginName'));
888 888
 $table->set_header(6, get_lang('Email'));
Please login to merge, or discard this patch.
main/inc/lib/usermanager.lib.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1267,13 +1267,13 @@  discard block
 block discarded – undo
1267 1267
     }
1268 1268
 
1269 1269
     /**
1270
-    * Get the users by ID
1271
-    * @param array $ids student ids
1272
-    * @param string $active
1273
-    * @param string $order
1274
-    * @param string $limit
1275
-    * @return array $result student information
1276
-    */
1270
+     * Get the users by ID
1271
+     * @param array $ids student ids
1272
+     * @param string $active
1273
+     * @param string $order
1274
+     * @param string $limit
1275
+     * @return array $result student information
1276
+     */
1277 1277
     public static function get_user_list_by_ids($ids = array(), $active = null, $order = null, $limit = null)
1278 1278
     {
1279 1279
         if (empty($ids)) {
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
      *
2315 2315
      * @return array with extra data info of a user i.e array('field_variable'=>'value');
2316 2316
      */
2317
-     public static function get_extra_user_data_by_value($variable, $value, $all_visibility = true)
2317
+        public static function get_extra_user_data_by_value($variable, $value, $all_visibility = true)
2318 2318
     {
2319 2319
         $extraFieldValue = new ExtraFieldValue('user');
2320 2320
         $extraField = new ExtraField('user');
@@ -3409,12 +3409,12 @@  discard block
 block discarded – undo
3409 3409
         if ($tag_id == 0) {
3410 3410
             //the tag doesn't exist
3411 3411
             $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
3412
-             Database::query($sql);
3412
+                Database::query($sql);
3413 3413
             $last_insert_id = Database::insert_id();
3414 3414
         } else {
3415 3415
             //the tag exists we update it
3416 3416
             $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id  = $tag_id";
3417
-             Database::query($sql);
3417
+                Database::query($sql);
3418 3418
             $last_insert_id = $tag_id;
3419 3419
         }
3420 3420
 
@@ -3610,9 +3610,9 @@  discard block
 block discarded – undo
3610 3610
     }
3611 3611
 
3612 3612
     /**
3613
-      * Get extra filtrable user fields (only type select)
3614
-      * @return array
3615
-      */
3613
+     * Get extra filtrable user fields (only type select)
3614
+     * @return array
3615
+     */
3616 3616
     public static function get_extra_filtrable_fields()
3617 3617
     {
3618 3618
         $extraFieldList = UserManager::get_extra_fields();
@@ -3637,9 +3637,9 @@  discard block
 block discarded – undo
3637 3637
     }
3638 3638
 
3639 3639
     /**
3640
-      * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3641
-      * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3642
-      */
3640
+     * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3641
+     * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3642
+     */
3643 3643
     public static function get_search_form_where_extra_fields()
3644 3644
     {
3645 3645
         $useExtraFields = false;
@@ -3958,23 +3958,23 @@  discard block
 block discarded – undo
3958 3958
     }
3959 3959
 
3960 3960
     /**
3961
-    * Get users followed by human resource manager
3962
-    * @param int $userId
3963
-    * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3964
-    * @param bool $getOnlyUserId
3965
-    * @param bool $getSql
3966
-    * @param bool $getCount
3967
-    * @param int $from
3968
-    * @param int $numberItems
3969
-    * @param int $column
3970
-    * @param string $direction
3971
-    * @param int $active
3972
-    * @param string $lastConnectionDate
3973
-    * @param int $status the function is called by who? COURSEMANAGER, DRH?
3974
-    * @param string $keyword
3961
+     * Get users followed by human resource manager
3962
+     * @param int $userId
3963
+     * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3964
+     * @param bool $getOnlyUserId
3965
+     * @param bool $getSql
3966
+     * @param bool $getCount
3967
+     * @param int $from
3968
+     * @param int $numberItems
3969
+     * @param int $column
3970
+     * @param string $direction
3971
+     * @param int $active
3972
+     * @param string $lastConnectionDate
3973
+     * @param int $status the function is called by who? COURSEMANAGER, DRH?
3974
+     * @param string $keyword
3975 3975
      *
3976
-    * @return array user list
3977
-    */
3976
+     * @return array user list
3977
+     */
3978 3978
     public static function getUsersFollowedByUser(
3979 3979
         $userId,
3980 3980
         $userStatus = null,
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.nusoap_base.php 1 patch
Indentation   +845 added lines, -845 removed lines patch added patch discarded remove patch
@@ -83,809 +83,809 @@  discard block
 block discarded – undo
83 83
 * @access   public
84 84
 */
85 85
 class nusoap_base {
86
-	/**
87
-	 * Identification for HTTP headers.
88
-	 *
89
-	 * @var string
90
-	 * @access private
91
-	 */
92
-	var $title = 'NuSOAP';
93
-	/**
94
-	 * Version for HTTP headers.
95
-	 *
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $version = '0.9.5';
100
-	/**
101
-	 * CVS revision for HTTP headers.
102
-	 *
103
-	 * @var string
104
-	 * @access private
105
-	 */
106
-	var $revision = '$Revision: 1.56 $';
86
+    /**
87
+     * Identification for HTTP headers.
88
+     *
89
+     * @var string
90
+     * @access private
91
+     */
92
+    var $title = 'NuSOAP';
93
+    /**
94
+     * Version for HTTP headers.
95
+     *
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $version = '0.9.5';
100
+    /**
101
+     * CVS revision for HTTP headers.
102
+     *
103
+     * @var string
104
+     * @access private
105
+     */
106
+    var $revision = '$Revision: 1.56 $';
107 107
     /**
108 108
      * Current error string (manipulated by getError/setError)
109
-	 *
110
-	 * @var string
111
-	 * @access private
112
-	 */
113
-	var $error_str = '';
109
+     *
110
+     * @var string
111
+     * @access private
112
+     */
113
+    var $error_str = '';
114 114
     /**
115 115
      * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
116
-	 *
117
-	 * @var string
118
-	 * @access private
119
-	 */
116
+     *
117
+     * @var string
118
+     * @access private
119
+     */
120 120
     var $debug_str = '';
121 121
     /**
122
-	 * toggles automatic encoding of special characters as entities
123
-	 * (should always be true, I think)
124
-	 *
125
-	 * @var boolean
126
-	 * @access private
127
-	 */
128
-	var $charencoding = true;
129
-	/**
130
-	 * the debug level for this instance
131
-	 *
132
-	 * @var	integer
133
-	 * @access private
134
-	 */
135
-	var $debugLevel;
136
-
137
-    /**
138
-	* set schema version
139
-	*
140
-	* @var      string
141
-	* @access   public
142
-	*/
143
-	var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
-
145
-    /**
146
-	* charset encoding for outgoing messages
147
-	*
148
-	* @var      string
149
-	* @access   public
150
-	*/
122
+     * toggles automatic encoding of special characters as entities
123
+     * (should always be true, I think)
124
+     *
125
+     * @var boolean
126
+     * @access private
127
+     */
128
+    var $charencoding = true;
129
+    /**
130
+     * the debug level for this instance
131
+     *
132
+     * @var	integer
133
+     * @access private
134
+     */
135
+    var $debugLevel;
136
+
137
+    /**
138
+     * set schema version
139
+     *
140
+     * @var      string
141
+     * @access   public
142
+     */
143
+    var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
+
145
+    /**
146
+     * charset encoding for outgoing messages
147
+     *
148
+     * @var      string
149
+     * @access   public
150
+     */
151 151
     var $soap_defencoding = 'ISO-8859-1';
152
-	//var $soap_defencoding = 'UTF-8';
153
-
154
-	/**
155
-	* namespaces in an array of prefix => uri
156
-	*
157
-	* this is "seeded" by a set of constants, but it may be altered by code
158
-	*
159
-	* @var      array
160
-	* @access   public
161
-	*/
162
-	var $namespaces = array(
163
-		'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
-		'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
-		'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
-		'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
-		);
168
-
169
-	/**
170
-	* namespaces used in the current context, e.g. during serialization
171
-	*
172
-	* @var      array
173
-	* @access   private
174
-	*/
175
-	var $usedNamespaces = array();
176
-
177
-	/**
178
-	* XML Schema types in an array of uri => (array of xml type => php type)
179
-	* is this legacy yet?
180
-	* no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
-	* @var      array
182
-	* @access   public
183
-	*/
184
-	var $typemap = array(
185
-	'http://www.w3.org/2001/XMLSchema' => array(
186
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
-		// abstract "any" types
190
-		'anyType'=>'string','anySimpleType'=>'string',
191
-		// derived datatypes
192
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
-	'http://www.w3.org/2000/10/XMLSchema' => array(
197
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
-		'float'=>'double','dateTime'=>'string',
199
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
-	'http://www.w3.org/1999/XMLSchema' => array(
201
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
-		'float'=>'double','dateTime'=>'string',
203
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
-	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
152
+    //var $soap_defencoding = 'UTF-8';
153
+
154
+    /**
155
+     * namespaces in an array of prefix => uri
156
+     *
157
+     * this is "seeded" by a set of constants, but it may be altered by code
158
+     *
159
+     * @var      array
160
+     * @access   public
161
+     */
162
+    var $namespaces = array(
163
+        'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
+        'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
+        'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
+        'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
+        );
168
+
169
+    /**
170
+     * namespaces used in the current context, e.g. during serialization
171
+     *
172
+     * @var      array
173
+     * @access   private
174
+     */
175
+    var $usedNamespaces = array();
176
+
177
+    /**
178
+     * XML Schema types in an array of uri => (array of xml type => php type)
179
+     * is this legacy yet?
180
+     * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
+     * @var      array
182
+     * @access   public
183
+     */
184
+    var $typemap = array(
185
+    'http://www.w3.org/2001/XMLSchema' => array(
186
+        'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
+        'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
+        'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
+        // abstract "any" types
190
+        'anyType'=>'string','anySimpleType'=>'string',
191
+        // derived datatypes
192
+        'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
+        'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
+        'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
+        'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
+    'http://www.w3.org/2000/10/XMLSchema' => array(
197
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
+        'float'=>'double','dateTime'=>'string',
199
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
+    'http://www.w3.org/1999/XMLSchema' => array(
201
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
+        'float'=>'double','dateTime'=>'string',
203
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
+    'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
+    'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
206 206
     'http://xml.apache.org/xml-soap' => array('Map')
207
-	);
208
-
209
-	/**
210
-	* XML entities to convert
211
-	*
212
-	* @var      array
213
-	* @access   public
214
-	* @deprecated
215
-	* @see	expandEntities
216
-	*/
217
-	var $xmlEntities = array('quot' => '"','amp' => '&',
218
-		'lt' => '<','gt' => '>','apos' => "'");
219
-
220
-	/**
221
-	* constructor
222
-	*
223
-	* @access	public
224
-	*/
225
-	function __construct() {
226
-		$this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
-	}
228
-
229
-	/**
230
-	* gets the global debug level, which applies to future instances
231
-	*
232
-	* @return	integer	Debug level 0-9, where 0 turns off
233
-	* @access	public
234
-	*/
235
-	function getGlobalDebugLevel() {
236
-		return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
-	}
238
-
239
-	/**
240
-	* sets the global debug level, which applies to future instances
241
-	*
242
-	* @param	int	$level	Debug level 0-9, where 0 turns off
243
-	* @access	public
244
-	*/
245
-	function setGlobalDebugLevel($level) {
246
-		$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
-	}
248
-
249
-	/**
250
-	* gets the debug level for this instance
251
-	*
252
-	* @return	int	Debug level 0-9, where 0 turns off
253
-	* @access	public
254
-	*/
255
-	function getDebugLevel() {
256
-		return $this->debugLevel;
257
-	}
258
-
259
-	/**
260
-	* sets the debug level for this instance
261
-	*
262
-	* @param	int	$level	Debug level 0-9, where 0 turns off
263
-	* @access	public
264
-	*/
265
-	function setDebugLevel($level) {
266
-		$this->debugLevel = $level;
267
-	}
268
-
269
-	/**
270
-	* adds debug data to the instance debug string with formatting
271
-	*
272
-	* @param    string $string debug data
273
-	* @access   private
274
-	*/
275
-	function debug($string){
276
-		if ($this->debugLevel > 0) {
277
-			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
-		}
279
-	}
280
-
281
-	/**
282
-	* adds debug data to the instance debug string without formatting
283
-	*
284
-	* @param    string $string debug data
285
-	* @access   public
286
-	*/
287
-	function appendDebug($string){
288
-		if ($this->debugLevel > 0) {
289
-			// it would be nice to use a memory stream here to use
290
-			// memory more efficiently
291
-			$this->debug_str .= $string;
292
-		}
293
-	}
294
-
295
-	/**
296
-	* clears the current debug data for this instance
297
-	*
298
-	* @access   public
299
-	*/
300
-	function clearDebug() {
301
-		// it would be nice to use a memory stream here to use
302
-		// memory more efficiently
303
-		$this->debug_str = '';
304
-	}
305
-
306
-	/**
307
-	* gets the current debug data for this instance
308
-	*
309
-	* @return   debug data
310
-	* @access   public
311
-	*/
312
-	function &getDebug() {
313
-		// it would be nice to use a memory stream here to use
314
-		// memory more efficiently
315
-		return $this->debug_str;
316
-	}
317
-
318
-	/**
319
-	* gets the current debug data for this instance as an XML comment
320
-	* this may change the contents of the debug data
321
-	*
322
-	* @return   debug data as an XML comment
323
-	* @access   public
324
-	*/
325
-	function &getDebugAsXMLComment() {
326
-		// it would be nice to use a memory stream here to use
327
-		// memory more efficiently
328
-		while (strpos($this->debug_str, '--')) {
329
-			$this->debug_str = str_replace('--', '- -', $this->debug_str);
330
-		}
331
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
332
-    	return $ret;
333
-	}
334
-
335
-	/**
336
-	* expands entities, e.g. changes '<' to '&lt;'.
337
-	*
338
-	* @param	string	$val	The string in which to expand entities.
339
-	* @access	private
340
-	*/
341
-	function expandEntities($val) {
342
-		if ($this->charencoding) {
343
-	    	$val = str_replace('&', '&amp;', $val);
344
-	    	$val = str_replace("'", '&apos;', $val);
345
-	    	$val = str_replace('"', '&quot;', $val);
346
-	    	$val = str_replace('<', '&lt;', $val);
347
-	    	$val = str_replace('>', '&gt;', $val);
348
-	    }
349
-	    return $val;
350
-	}
351
-
352
-	/**
353
-	* returns error string if present
354
-	*
355
-	* @return   mixed error string or false
356
-	* @access   public
357
-	*/
358
-	function getError(){
359
-		if($this->error_str != ''){
360
-			return $this->error_str;
361
-		}
362
-		return false;
363
-	}
364
-
365
-	/**
366
-	* sets error string
367
-	*
368
-	* @return   boolean $string error string
369
-	* @access   private
370
-	*/
371
-	function setError($str){
372
-		$this->error_str = $str;
373
-	}
374
-
375
-	/**
376
-	* detect if array is a simple array or a struct (associative array)
377
-	*
378
-	* @param	mixed	$val	The PHP array
379
-	* @return	string	(arraySimple|arrayStruct)
380
-	* @access	private
381
-	*/
382
-	function isArraySimpleOrStruct($val) {
207
+    );
208
+
209
+    /**
210
+     * XML entities to convert
211
+     *
212
+     * @var      array
213
+     * @access   public
214
+     * @deprecated
215
+     * @see	expandEntities
216
+     */
217
+    var $xmlEntities = array('quot' => '"','amp' => '&',
218
+        'lt' => '<','gt' => '>','apos' => "'");
219
+
220
+    /**
221
+     * constructor
222
+     *
223
+     * @access	public
224
+     */
225
+    function __construct() {
226
+        $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
+    }
228
+
229
+    /**
230
+     * gets the global debug level, which applies to future instances
231
+     *
232
+     * @return	integer	Debug level 0-9, where 0 turns off
233
+     * @access	public
234
+     */
235
+    function getGlobalDebugLevel() {
236
+        return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
+    }
238
+
239
+    /**
240
+     * sets the global debug level, which applies to future instances
241
+     *
242
+     * @param	int	$level	Debug level 0-9, where 0 turns off
243
+     * @access	public
244
+     */
245
+    function setGlobalDebugLevel($level) {
246
+        $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
+    }
248
+
249
+    /**
250
+     * gets the debug level for this instance
251
+     *
252
+     * @return	int	Debug level 0-9, where 0 turns off
253
+     * @access	public
254
+     */
255
+    function getDebugLevel() {
256
+        return $this->debugLevel;
257
+    }
258
+
259
+    /**
260
+     * sets the debug level for this instance
261
+     *
262
+     * @param	int	$level	Debug level 0-9, where 0 turns off
263
+     * @access	public
264
+     */
265
+    function setDebugLevel($level) {
266
+        $this->debugLevel = $level;
267
+    }
268
+
269
+    /**
270
+     * adds debug data to the instance debug string with formatting
271
+     *
272
+     * @param    string $string debug data
273
+     * @access   private
274
+     */
275
+    function debug($string){
276
+        if ($this->debugLevel > 0) {
277
+            $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
+        }
279
+    }
280
+
281
+    /**
282
+     * adds debug data to the instance debug string without formatting
283
+     *
284
+     * @param    string $string debug data
285
+     * @access   public
286
+     */
287
+    function appendDebug($string){
288
+        if ($this->debugLevel > 0) {
289
+            // it would be nice to use a memory stream here to use
290
+            // memory more efficiently
291
+            $this->debug_str .= $string;
292
+        }
293
+    }
294
+
295
+    /**
296
+     * clears the current debug data for this instance
297
+     *
298
+     * @access   public
299
+     */
300
+    function clearDebug() {
301
+        // it would be nice to use a memory stream here to use
302
+        // memory more efficiently
303
+        $this->debug_str = '';
304
+    }
305
+
306
+    /**
307
+     * gets the current debug data for this instance
308
+     *
309
+     * @return   debug data
310
+     * @access   public
311
+     */
312
+    function &getDebug() {
313
+        // it would be nice to use a memory stream here to use
314
+        // memory more efficiently
315
+        return $this->debug_str;
316
+    }
317
+
318
+    /**
319
+     * gets the current debug data for this instance as an XML comment
320
+     * this may change the contents of the debug data
321
+     *
322
+     * @return   debug data as an XML comment
323
+     * @access   public
324
+     */
325
+    function &getDebugAsXMLComment() {
326
+        // it would be nice to use a memory stream here to use
327
+        // memory more efficiently
328
+        while (strpos($this->debug_str, '--')) {
329
+            $this->debug_str = str_replace('--', '- -', $this->debug_str);
330
+        }
331
+        $ret = "<!--\n" . $this->debug_str . "\n-->";
332
+        return $ret;
333
+    }
334
+
335
+    /**
336
+     * expands entities, e.g. changes '<' to '&lt;'.
337
+     *
338
+     * @param	string	$val	The string in which to expand entities.
339
+     * @access	private
340
+     */
341
+    function expandEntities($val) {
342
+        if ($this->charencoding) {
343
+            $val = str_replace('&', '&amp;', $val);
344
+            $val = str_replace("'", '&apos;', $val);
345
+            $val = str_replace('"', '&quot;', $val);
346
+            $val = str_replace('<', '&lt;', $val);
347
+            $val = str_replace('>', '&gt;', $val);
348
+        }
349
+        return $val;
350
+    }
351
+
352
+    /**
353
+     * returns error string if present
354
+     *
355
+     * @return   mixed error string or false
356
+     * @access   public
357
+     */
358
+    function getError(){
359
+        if($this->error_str != ''){
360
+            return $this->error_str;
361
+        }
362
+        return false;
363
+    }
364
+
365
+    /**
366
+     * sets error string
367
+     *
368
+     * @return   boolean $string error string
369
+     * @access   private
370
+     */
371
+    function setError($str){
372
+        $this->error_str = $str;
373
+    }
374
+
375
+    /**
376
+     * detect if array is a simple array or a struct (associative array)
377
+     *
378
+     * @param	mixed	$val	The PHP array
379
+     * @return	string	(arraySimple|arrayStruct)
380
+     * @access	private
381
+     */
382
+    function isArraySimpleOrStruct($val) {
383 383
         $keyList = array_keys($val);
384
-		foreach ($keyList as $keyListValue) {
385
-			if (!is_int($keyListValue)) {
386
-				return 'arrayStruct';
387
-			}
388
-		}
389
-		return 'arraySimple';
390
-	}
391
-
392
-	/**
393
-	* serializes PHP values in accordance w/ section 5. Type information is
394
-	* not serialized if $use == 'literal'.
395
-	*
396
-	* @param	mixed	$val	The value to serialize
397
-	* @param	string	$name	The name (local part) of the XML element
398
-	* @param	string	$type	The XML schema type (local part) for the element
399
-	* @param	string	$name_ns	The namespace for the name of the XML element
400
-	* @param	string	$type_ns	The namespace for the type of the element
401
-	* @param	array	$attributes	The attributes to serialize as name=>value pairs
402
-	* @param	string	$use	The WSDL "use" (encoded|literal)
403
-	* @param	boolean	$soapval	Whether this is called from soapval.
404
-	* @return	string	The serialized element, possibly with child elements
405
-    * @access	public
406
-	*/
407
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
-		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
-		$this->appendDebug('value=' . $this->varDump($val));
410
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
411
-
412
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
-    		$this->debug("serialize_val: serialize soapval");
414
-        	$xml = $val->serialize($use);
415
-			$this->appendDebug($val->getDebug());
416
-			$val->clearDebug();
417
-			$this->debug("serialize_val of soapval returning $xml");
418
-			return $xml;
384
+        foreach ($keyList as $keyListValue) {
385
+            if (!is_int($keyListValue)) {
386
+                return 'arrayStruct';
387
+            }
419 388
         }
420
-		// force valid name if necessary
421
-		if (is_numeric($name)) {
422
-			$name = '__numeric_' . $name;
423
-		} elseif (! $name) {
424
-			$name = 'noname';
425
-		}
426
-		// if name has ns, add ns prefix to name
427
-		$xmlns = '';
389
+        return 'arraySimple';
390
+    }
391
+
392
+    /**
393
+     * serializes PHP values in accordance w/ section 5. Type information is
394
+     * not serialized if $use == 'literal'.
395
+     *
396
+     * @param	mixed	$val	The value to serialize
397
+     * @param	string	$name	The name (local part) of the XML element
398
+     * @param	string	$type	The XML schema type (local part) for the element
399
+     * @param	string	$name_ns	The namespace for the name of the XML element
400
+     * @param	string	$type_ns	The namespace for the type of the element
401
+     * @param	array	$attributes	The attributes to serialize as name=>value pairs
402
+     * @param	string	$use	The WSDL "use" (encoded|literal)
403
+     * @param	boolean	$soapval	Whether this is called from soapval.
404
+     * @return	string	The serialized element, possibly with child elements
405
+     * @access	public
406
+     */
407
+    function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
+        $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
+        $this->appendDebug('value=' . $this->varDump($val));
410
+        $this->appendDebug('attributes=' . $this->varDump($attributes));
411
+
412
+        if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
+            $this->debug("serialize_val: serialize soapval");
414
+            $xml = $val->serialize($use);
415
+            $this->appendDebug($val->getDebug());
416
+            $val->clearDebug();
417
+            $this->debug("serialize_val of soapval returning $xml");
418
+            return $xml;
419
+        }
420
+        // force valid name if necessary
421
+        if (is_numeric($name)) {
422
+            $name = '__numeric_' . $name;
423
+        } elseif (! $name) {
424
+            $name = 'noname';
425
+        }
426
+        // if name has ns, add ns prefix to name
427
+        $xmlns = '';
428 428
         if($name_ns){
429
-			$prefix = 'nu'.rand(1000,9999);
430
-			$name = $prefix.':'.$name;
431
-			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
-		}
433
-		// if type is prefixed, create type prefix
434
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
-			// need to fix this. shouldn't default to xsd if no ns specified
436
-		    // w/o checking against typemap
437
-			$type_prefix = 'xsd';
438
-		} elseif($type_ns){
439
-			$type_prefix = 'ns'.rand(1000,9999);
440
-			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
-		}
442
-		// serialize attributes if present
443
-		$atts = '';
444
-		if($attributes){
445
-			foreach($attributes as $k => $v){
446
-				$atts .= " $k=\"".$this->expandEntities($v).'"';
447
-			}
448
-		}
449
-		// serialize null value
450
-		if (is_null($val)) {
451
-    		$this->debug("serialize_val: serialize null");
452
-			if ($use == 'literal') {
453
-				// TODO: depends on minOccurs
454
-				$xml = "<$name$xmlns$atts/>";
455
-				$this->debug("serialize_val returning $xml");
456
-	        	return $xml;
457
-        	} else {
458
-				if (isset($type) && isset($type_prefix)) {
459
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
460
-				} else {
461
-					$type_str = '';
462
-				}
463
-				$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
-				$this->debug("serialize_val returning $xml");
465
-	        	return $xml;
466
-        	}
467
-		}
429
+            $prefix = 'nu'.rand(1000,9999);
430
+            $name = $prefix.':'.$name;
431
+            $xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
+        }
433
+        // if type is prefixed, create type prefix
434
+        if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
+            // need to fix this. shouldn't default to xsd if no ns specified
436
+            // w/o checking against typemap
437
+            $type_prefix = 'xsd';
438
+        } elseif($type_ns){
439
+            $type_prefix = 'ns'.rand(1000,9999);
440
+            $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
+        }
442
+        // serialize attributes if present
443
+        $atts = '';
444
+        if($attributes){
445
+            foreach($attributes as $k => $v){
446
+                $atts .= " $k=\"".$this->expandEntities($v).'"';
447
+            }
448
+        }
449
+        // serialize null value
450
+        if (is_null($val)) {
451
+            $this->debug("serialize_val: serialize null");
452
+            if ($use == 'literal') {
453
+                // TODO: depends on minOccurs
454
+                $xml = "<$name$xmlns$atts/>";
455
+                $this->debug("serialize_val returning $xml");
456
+                return $xml;
457
+            } else {
458
+                if (isset($type) && isset($type_prefix)) {
459
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
460
+                } else {
461
+                    $type_str = '';
462
+                }
463
+                $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
+                $this->debug("serialize_val returning $xml");
465
+                return $xml;
466
+            }
467
+        }
468 468
         // serialize if an xsd built-in primitive type
469 469
         if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
470
-    		$this->debug("serialize_val: serialize xsd built-in primitive type");
471
-        	if (is_bool($val)) {
472
-        		if ($type == 'boolean') {
473
-	        		$val = $val ? 'true' : 'false';
474
-	        	} elseif (! $val) {
475
-	        		$val = 0;
476
-	        	}
477
-			} else if (is_string($val)) {
478
-				$val = $this->expandEntities($val);
479
-			}
480
-			if ($use == 'literal') {
481
-				$xml = "<$name$xmlns$atts>$val</$name>";
482
-				$this->debug("serialize_val returning $xml");
483
-	        	return $xml;
484
-        	} else {
485
-				$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
-				$this->debug("serialize_val returning $xml");
487
-	        	return $xml;
488
-        	}
470
+            $this->debug("serialize_val: serialize xsd built-in primitive type");
471
+            if (is_bool($val)) {
472
+                if ($type == 'boolean') {
473
+                    $val = $val ? 'true' : 'false';
474
+                } elseif (! $val) {
475
+                    $val = 0;
476
+                }
477
+            } else if (is_string($val)) {
478
+                $val = $this->expandEntities($val);
479
+            }
480
+            if ($use == 'literal') {
481
+                $xml = "<$name$xmlns$atts>$val</$name>";
482
+                $this->debug("serialize_val returning $xml");
483
+                return $xml;
484
+            } else {
485
+                $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
+                $this->debug("serialize_val returning $xml");
487
+                return $xml;
488
+            }
489 489
         }
490
-		// detect type and serialize
491
-		$xml = '';
492
-		switch(true) {
493
-			case (is_bool($val) || $type == 'boolean'):
494
-		   		$this->debug("serialize_val: serialize boolean");
495
-        		if ($type == 'boolean') {
496
-	        		$val = $val ? 'true' : 'false';
497
-	        	} elseif (! $val) {
498
-	        		$val = 0;
499
-	        	}
500
-				if ($use == 'literal') {
501
-					$xml .= "<$name$xmlns$atts>$val</$name>";
502
-				} else {
503
-					$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
-				}
505
-				break;
506
-			case (is_int($val) || is_long($val) || $type == 'int'):
507
-		   		$this->debug("serialize_val: serialize int");
508
-				if ($use == 'literal') {
509
-					$xml .= "<$name$xmlns$atts>$val</$name>";
510
-				} else {
511
-					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
-				}
513
-				break;
514
-			case (is_float($val)|| is_double($val) || $type == 'float'):
515
-		   		$this->debug("serialize_val: serialize float");
516
-				if ($use == 'literal') {
517
-					$xml .= "<$name$xmlns$atts>$val</$name>";
518
-				} else {
519
-					$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
-				}
521
-				break;
522
-			case (is_string($val) || $type == 'string'):
523
-		   		$this->debug("serialize_val: serialize string");
524
-				$val = $this->expandEntities($val);
525
-				if ($use == 'literal') {
526
-					$xml .= "<$name$xmlns$atts>$val</$name>";
527
-				} else {
528
-					$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
-				}
530
-				break;
531
-			case is_object($val):
532
-		   		$this->debug("serialize_val: serialize object");
533
-		    	if (get_class($val) == 'soapval') {
534
-		    		$this->debug("serialize_val: serialize soapval object");
535
-		        	$pXml = $val->serialize($use);
536
-					$this->appendDebug($val->getDebug());
537
-					$val->clearDebug();
538
-		        } else {
539
-					if (! $name) {
540
-						$name = get_class($val);
541
-						$this->debug("In serialize_val, used class name $name as element name");
542
-					} else {
543
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
-					}
545
-					foreach(get_object_vars($val) as $k => $v){
546
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
-					}
548
-				}
549
-				if(isset($type) && isset($type_prefix)){
550
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
551
-				} else {
552
-					$type_str = '';
553
-				}
554
-				if ($use == 'literal') {
555
-					$xml .= "<$name$xmlns$atts>$pXml</$name>";
556
-				} else {
557
-					$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
-				}
559
-				break;
560
-			case (is_array($val) || $type):
561
-				// detect if struct or array
562
-				$valueType = $this->isArraySimpleOrStruct($val);
490
+        // detect type and serialize
491
+        $xml = '';
492
+        switch(true) {
493
+            case (is_bool($val) || $type == 'boolean'):
494
+                   $this->debug("serialize_val: serialize boolean");
495
+                if ($type == 'boolean') {
496
+                    $val = $val ? 'true' : 'false';
497
+                } elseif (! $val) {
498
+                    $val = 0;
499
+                }
500
+                if ($use == 'literal') {
501
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
502
+                } else {
503
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
+                }
505
+                break;
506
+            case (is_int($val) || is_long($val) || $type == 'int'):
507
+                   $this->debug("serialize_val: serialize int");
508
+                if ($use == 'literal') {
509
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
510
+                } else {
511
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
+                }
513
+                break;
514
+            case (is_float($val)|| is_double($val) || $type == 'float'):
515
+                   $this->debug("serialize_val: serialize float");
516
+                if ($use == 'literal') {
517
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
518
+                } else {
519
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
+                }
521
+                break;
522
+            case (is_string($val) || $type == 'string'):
523
+                   $this->debug("serialize_val: serialize string");
524
+                $val = $this->expandEntities($val);
525
+                if ($use == 'literal') {
526
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
527
+                } else {
528
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
+                }
530
+                break;
531
+            case is_object($val):
532
+                   $this->debug("serialize_val: serialize object");
533
+                if (get_class($val) == 'soapval') {
534
+                    $this->debug("serialize_val: serialize soapval object");
535
+                    $pXml = $val->serialize($use);
536
+                    $this->appendDebug($val->getDebug());
537
+                    $val->clearDebug();
538
+                } else {
539
+                    if (! $name) {
540
+                        $name = get_class($val);
541
+                        $this->debug("In serialize_val, used class name $name as element name");
542
+                    } else {
543
+                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
+                    }
545
+                    foreach(get_object_vars($val) as $k => $v){
546
+                        $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
+                    }
548
+                }
549
+                if(isset($type) && isset($type_prefix)){
550
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
551
+                } else {
552
+                    $type_str = '';
553
+                }
554
+                if ($use == 'literal') {
555
+                    $xml .= "<$name$xmlns$atts>$pXml</$name>";
556
+                } else {
557
+                    $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
+                }
559
+                break;
560
+            case (is_array($val) || $type):
561
+                // detect if struct or array
562
+                $valueType = $this->isArraySimpleOrStruct($val);
563 563
                 if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
564
-			   		$this->debug("serialize_val: serialize array");
565
-					$i = 0;
566
-					if(is_array($val) && count($val)> 0){
567
-						foreach($val as $v){
568
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
569
-								$tt_ns = $v->type_ns;
570
-								$tt = $v->type;
571
-							} elseif (is_array($v)) {
572
-								$tt = $this->isArraySimpleOrStruct($v);
573
-							} else {
574
-								$tt = gettype($v);
575
-	                        }
576
-							$array_types[$tt] = 1;
577
-							// TODO: for literal, the name should be $name
578
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
-							++$i;
580
-						}
581
-						if(count($array_types) > 1){
582
-							$array_typename = 'xsd:anyType';
583
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
-							if ($tt == 'integer') {
585
-								$tt = 'int';
586
-							}
587
-							$array_typename = 'xsd:'.$tt;
588
-						} elseif(isset($tt) && $tt == 'arraySimple'){
589
-							$array_typename = 'SOAP-ENC:Array';
590
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
591
-							$array_typename = 'unnamed_struct_use_soapval';
592
-						} else {
593
-							// if type is prefixed, create type prefix
594
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
595
-								 $array_typename = 'xsd:' . $tt;
596
-							} elseif ($tt_ns) {
597
-								$tt_prefix = 'ns' . rand(1000, 9999);
598
-								$array_typename = "$tt_prefix:$tt";
599
-								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
600
-							} else {
601
-								$array_typename = $tt;
602
-							}
603
-						}
604
-						$array_type = $i;
605
-						if ($use == 'literal') {
606
-							$type_str = '';
607
-						} else if (isset($type) && isset($type_prefix)) {
608
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
609
-						} else {
610
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
611
-						}
612
-					// empty array
613
-					} else {
614
-						if ($use == 'literal') {
615
-							$type_str = '';
616
-						} else if (isset($type) && isset($type_prefix)) {
617
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
618
-						} else {
619
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
620
-						}
621
-					}
622
-					// TODO: for array in literal, there is no wrapper here
623
-					$xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
624
-				} else {
625
-					// got a struct
626
-			   		$this->debug("serialize_val: serialize struct");
627
-					if(isset($type) && isset($type_prefix)){
628
-						$type_str = " xsi:type=\"$type_prefix:$type\"";
629
-					} else {
630
-						$type_str = '';
631
-					}
632
-					if ($use == 'literal') {
633
-						$xml .= "<$name$xmlns$atts>";
634
-					} else {
635
-						$xml .= "<$name$xmlns$type_str$atts>";
636
-					}
637
-					foreach($val as $k => $v){
638
-						// Apache Map
639
-						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
640
-							$xml .= '<item>';
641
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
642
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
643
-							$xml .= '</item>';
644
-						} else {
645
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
-						}
647
-					}
648
-					$xml .= "</$name>";
649
-				}
650
-				break;
651
-			default:
652
-		   		$this->debug("serialize_val: serialize unknown");
653
-				$xml .= 'not detected, got '.gettype($val).' for '.$val;
654
-				break;
655
-		}
656
-		$this->debug("serialize_val returning $xml");
657
-		return $xml;
658
-	}
659
-
660
-    /**
661
-    * serializes a message
662
-    *
663
-    * @param string $body the XML of the SOAP body
664
-    * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
665
-    * @param array $namespaces optional the namespaces used in generating the body and headers
666
-    * @param string $style optional (rpc|document)
667
-    * @param string $use optional (encoded|literal)
668
-    * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
669
-    * @return string the message
670
-    * @access public
671
-    */
564
+                        $this->debug("serialize_val: serialize array");
565
+                    $i = 0;
566
+                    if(is_array($val) && count($val)> 0){
567
+                        foreach($val as $v){
568
+                            if(is_object($v) && get_class($v) ==  'soapval'){
569
+                                $tt_ns = $v->type_ns;
570
+                                $tt = $v->type;
571
+                            } elseif (is_array($v)) {
572
+                                $tt = $this->isArraySimpleOrStruct($v);
573
+                            } else {
574
+                                $tt = gettype($v);
575
+                            }
576
+                            $array_types[$tt] = 1;
577
+                            // TODO: for literal, the name should be $name
578
+                            $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
+                            ++$i;
580
+                        }
581
+                        if(count($array_types) > 1){
582
+                            $array_typename = 'xsd:anyType';
583
+                        } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
+                            if ($tt == 'integer') {
585
+                                $tt = 'int';
586
+                            }
587
+                            $array_typename = 'xsd:'.$tt;
588
+                        } elseif(isset($tt) && $tt == 'arraySimple'){
589
+                            $array_typename = 'SOAP-ENC:Array';
590
+                        } elseif(isset($tt) && $tt == 'arrayStruct'){
591
+                            $array_typename = 'unnamed_struct_use_soapval';
592
+                        } else {
593
+                            // if type is prefixed, create type prefix
594
+                            if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
595
+                                    $array_typename = 'xsd:' . $tt;
596
+                            } elseif ($tt_ns) {
597
+                                $tt_prefix = 'ns' . rand(1000, 9999);
598
+                                $array_typename = "$tt_prefix:$tt";
599
+                                $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
600
+                            } else {
601
+                                $array_typename = $tt;
602
+                            }
603
+                        }
604
+                        $array_type = $i;
605
+                        if ($use == 'literal') {
606
+                            $type_str = '';
607
+                        } else if (isset($type) && isset($type_prefix)) {
608
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
609
+                        } else {
610
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
611
+                        }
612
+                    // empty array
613
+                    } else {
614
+                        if ($use == 'literal') {
615
+                            $type_str = '';
616
+                        } else if (isset($type) && isset($type_prefix)) {
617
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
618
+                        } else {
619
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
620
+                        }
621
+                    }
622
+                    // TODO: for array in literal, there is no wrapper here
623
+                    $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
624
+                } else {
625
+                    // got a struct
626
+                        $this->debug("serialize_val: serialize struct");
627
+                    if(isset($type) && isset($type_prefix)){
628
+                        $type_str = " xsi:type=\"$type_prefix:$type\"";
629
+                    } else {
630
+                        $type_str = '';
631
+                    }
632
+                    if ($use == 'literal') {
633
+                        $xml .= "<$name$xmlns$atts>";
634
+                    } else {
635
+                        $xml .= "<$name$xmlns$type_str$atts>";
636
+                    }
637
+                    foreach($val as $k => $v){
638
+                        // Apache Map
639
+                        if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
640
+                            $xml .= '<item>';
641
+                            $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
642
+                            $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
643
+                            $xml .= '</item>';
644
+                        } else {
645
+                            $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
+                        }
647
+                    }
648
+                    $xml .= "</$name>";
649
+                }
650
+                break;
651
+            default:
652
+                   $this->debug("serialize_val: serialize unknown");
653
+                $xml .= 'not detected, got '.gettype($val).' for '.$val;
654
+                break;
655
+        }
656
+        $this->debug("serialize_val returning $xml");
657
+        return $xml;
658
+    }
659
+
660
+    /**
661
+     * serializes a message
662
+     *
663
+     * @param string $body the XML of the SOAP body
664
+     * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
665
+     * @param array $namespaces optional the namespaces used in generating the body and headers
666
+     * @param string $style optional (rpc|document)
667
+     * @param string $use optional (encoded|literal)
668
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
669
+     * @return string the message
670
+     * @access public
671
+     */
672 672
     function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
673 673
     // TODO: add an option to automatically run utf8_encode on $body and $headers
674 674
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
675 675
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
676 676
 
677
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
-	$this->debug("headers:");
679
-	$this->appendDebug($this->varDump($headers));
680
-	$this->debug("namespaces:");
681
-	$this->appendDebug($this->varDump($namespaces));
677
+    $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
+    $this->debug("headers:");
679
+    $this->appendDebug($this->varDump($headers));
680
+    $this->debug("namespaces:");
681
+    $this->appendDebug($this->varDump($namespaces));
682 682
 
683
-	// serialize namespaces
683
+    // serialize namespaces
684 684
     $ns_string = '';
685
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
-		$ns_string .= " xmlns:$k=\"$v\"";
687
-	}
688
-	if($encodingStyle) {
689
-		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
690
-	}
691
-
692
-	// serialize headers
693
-	if($headers){
694
-		if (is_array($headers)) {
695
-			$xml = '';
696
-			foreach ($headers as $k => $v) {
697
-				if (is_object($v) && get_class($v) == 'soapval') {
698
-					$xml .= $this->serialize_val($v, false, false, false, false, false, $use);
699
-				} else {
700
-					$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
701
-				}
702
-			}
703
-			$headers = $xml;
704
-			$this->debug("In serializeEnvelope, serialized array of headers to $headers");
705
-		}
706
-		$headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
707
-	}
708
-	// serialize envelope
709
-	return
710
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
-	'<SOAP-ENV:Envelope'.$ns_string.">".
712
-	$headers.
713
-	"<SOAP-ENV:Body>".
714
-		$body.
715
-	"</SOAP-ENV:Body>".
716
-	"</SOAP-ENV:Envelope>";
717
-    }
718
-
719
-	/**
720
-	 * formats a string to be inserted into an HTML stream
721
-	 *
722
-	 * @param string $str The string to format
723
-	 * @return string The formatted string
724
-	 * @access public
725
-	 * @deprecated
726
-	 */
685
+    foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
+        $ns_string .= " xmlns:$k=\"$v\"";
687
+    }
688
+    if($encodingStyle) {
689
+        $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
690
+    }
691
+
692
+    // serialize headers
693
+    if($headers){
694
+        if (is_array($headers)) {
695
+            $xml = '';
696
+            foreach ($headers as $k => $v) {
697
+                if (is_object($v) && get_class($v) == 'soapval') {
698
+                    $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
699
+                } else {
700
+                    $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
701
+                }
702
+            }
703
+            $headers = $xml;
704
+            $this->debug("In serializeEnvelope, serialized array of headers to $headers");
705
+        }
706
+        $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
707
+    }
708
+    // serialize envelope
709
+    return
710
+    '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
+    '<SOAP-ENV:Envelope'.$ns_string.">".
712
+    $headers.
713
+    "<SOAP-ENV:Body>".
714
+        $body.
715
+    "</SOAP-ENV:Body>".
716
+    "</SOAP-ENV:Envelope>";
717
+    }
718
+
719
+    /**
720
+     * formats a string to be inserted into an HTML stream
721
+     *
722
+     * @param string $str The string to format
723
+     * @return string The formatted string
724
+     * @access public
725
+     * @deprecated
726
+     */
727 727
     function formatDump($str){
728
-		$str = htmlspecialchars($str);
729
-		return nl2br($str);
730
-    }
731
-
732
-	/**
733
-	* contracts (changes namespace to prefix) a qualified name
734
-	*
735
-	* @param    string $qname qname
736
-	* @return	string contracted qname
737
-	* @access   private
738
-	*/
739
-	function contractQname($qname){
740
-		// get element namespace
741
-		//$this->xdebug("Contract $qname");
742
-		if (strrpos($qname, ':')) {
743
-			// get unqualified name
744
-			$name = substr($qname, strrpos($qname, ':') + 1);
745
-			// get ns
746
-			$ns = substr($qname, 0, strrpos($qname, ':'));
747
-			$p = $this->getPrefixFromNamespace($ns);
748
-			if ($p) {
749
-				return $p . ':' . $name;
750
-			}
751
-			return $qname;
752
-		} else {
753
-			return $qname;
754
-		}
755
-	}
756
-
757
-	/**
758
-	* expands (changes prefix to namespace) a qualified name
759
-	*
760
-	* @param    string $qname qname
761
-	* @return	string expanded qname
762
-	* @access   private
763
-	*/
764
-	function expandQname($qname){
765
-		// get element prefix
766
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
-			// get unqualified name
768
-			$name = substr(strstr($qname,':'),1);
769
-			// get ns prefix
770
-			$prefix = substr($qname,0,strpos($qname,':'));
771
-			if(isset($this->namespaces[$prefix])){
772
-				return $this->namespaces[$prefix].':'.$name;
773
-			} else {
774
-				return $qname;
775
-			}
776
-		} else {
777
-			return $qname;
778
-		}
779
-	}
780
-
781
-    /**
782
-    * returns the local part of a prefixed string
783
-    * returns the original string, if not prefixed
784
-    *
785
-    * @param string $str The prefixed string
786
-    * @return string The local part
787
-    * @access public
788
-    */
789
-	function getLocalPart($str){
790
-		if($sstr = strrchr($str,':')){
791
-			// get unqualified name
792
-			return substr( $sstr, 1 );
793
-		} else {
794
-			return $str;
795
-		}
796
-	}
797
-
798
-	/**
799
-    * returns the prefix part of a prefixed string
800
-    * returns false, if not prefixed
801
-    *
802
-    * @param string $str The prefixed string
803
-    * @return mixed The prefix or false if there is no prefix
804
-    * @access public
805
-    */
806
-	function getPrefix($str){
807
-		if($pos = strrpos($str,':')){
808
-			// get prefix
809
-			return substr($str,0,$pos);
810
-		}
811
-		return false;
812
-	}
813
-
814
-	/**
815
-    * pass it a prefix, it returns a namespace
816
-    *
817
-    * @param string $prefix The prefix
818
-    * @return mixed The namespace, false if no namespace has the specified prefix
819
-    * @access public
820
-    */
821
-	function getNamespaceFromPrefix($prefix){
822
-		if (isset($this->namespaces[$prefix])) {
823
-			return $this->namespaces[$prefix];
824
-		}
825
-		//$this->setError("No namespace registered for prefix '$prefix'");
826
-		return false;
827
-	}
828
-
829
-	/**
830
-    * returns the prefix for a given namespace (or prefix)
831
-    * or false if no prefixes registered for the given namespace
832
-    *
833
-    * @param string $ns The namespace
834
-    * @return mixed The prefix, false if the namespace has no prefixes
835
-    * @access public
836
-    */
837
-	function getPrefixFromNamespace($ns) {
838
-		foreach ($this->namespaces as $p => $n) {
839
-			if ($ns == $n || $ns == $p) {
840
-			    $this->usedNamespaces[$p] = $n;
841
-				return $p;
842
-			}
843
-		}
844
-		return false;
845
-	}
846
-
847
-	/**
848
-    * returns the time in ODBC canonical form with microseconds
849
-    *
850
-    * @return string The time in ODBC canonical form with microseconds
851
-    * @access public
852
-    */
853
-	function getmicrotime() {
854
-		if (function_exists('gettimeofday')) {
855
-			$tod = gettimeofday();
856
-			$sec = $tod['sec'];
857
-			$usec = $tod['usec'];
858
-		} else {
859
-			$sec = time();
860
-			$usec = 0;
861
-		}
862
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
-	}
864
-
865
-	/**
866
-	 * Returns a string with the output of var_dump
867
-	 *
868
-	 * @param mixed $data The variable to var_dump
869
-	 * @return string The output of var_dump
870
-	 * @access public
871
-	 */
728
+        $str = htmlspecialchars($str);
729
+        return nl2br($str);
730
+    }
731
+
732
+    /**
733
+     * contracts (changes namespace to prefix) a qualified name
734
+     *
735
+     * @param    string $qname qname
736
+     * @return	string contracted qname
737
+     * @access   private
738
+     */
739
+    function contractQname($qname){
740
+        // get element namespace
741
+        //$this->xdebug("Contract $qname");
742
+        if (strrpos($qname, ':')) {
743
+            // get unqualified name
744
+            $name = substr($qname, strrpos($qname, ':') + 1);
745
+            // get ns
746
+            $ns = substr($qname, 0, strrpos($qname, ':'));
747
+            $p = $this->getPrefixFromNamespace($ns);
748
+            if ($p) {
749
+                return $p . ':' . $name;
750
+            }
751
+            return $qname;
752
+        } else {
753
+            return $qname;
754
+        }
755
+    }
756
+
757
+    /**
758
+     * expands (changes prefix to namespace) a qualified name
759
+     *
760
+     * @param    string $qname qname
761
+     * @return	string expanded qname
762
+     * @access   private
763
+     */
764
+    function expandQname($qname){
765
+        // get element prefix
766
+        if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
+            // get unqualified name
768
+            $name = substr(strstr($qname,':'),1);
769
+            // get ns prefix
770
+            $prefix = substr($qname,0,strpos($qname,':'));
771
+            if(isset($this->namespaces[$prefix])){
772
+                return $this->namespaces[$prefix].':'.$name;
773
+            } else {
774
+                return $qname;
775
+            }
776
+        } else {
777
+            return $qname;
778
+        }
779
+    }
780
+
781
+    /**
782
+     * returns the local part of a prefixed string
783
+     * returns the original string, if not prefixed
784
+     *
785
+     * @param string $str The prefixed string
786
+     * @return string The local part
787
+     * @access public
788
+     */
789
+    function getLocalPart($str){
790
+        if($sstr = strrchr($str,':')){
791
+            // get unqualified name
792
+            return substr( $sstr, 1 );
793
+        } else {
794
+            return $str;
795
+        }
796
+    }
797
+
798
+    /**
799
+     * returns the prefix part of a prefixed string
800
+     * returns false, if not prefixed
801
+     *
802
+     * @param string $str The prefixed string
803
+     * @return mixed The prefix or false if there is no prefix
804
+     * @access public
805
+     */
806
+    function getPrefix($str){
807
+        if($pos = strrpos($str,':')){
808
+            // get prefix
809
+            return substr($str,0,$pos);
810
+        }
811
+        return false;
812
+    }
813
+
814
+    /**
815
+     * pass it a prefix, it returns a namespace
816
+     *
817
+     * @param string $prefix The prefix
818
+     * @return mixed The namespace, false if no namespace has the specified prefix
819
+     * @access public
820
+     */
821
+    function getNamespaceFromPrefix($prefix){
822
+        if (isset($this->namespaces[$prefix])) {
823
+            return $this->namespaces[$prefix];
824
+        }
825
+        //$this->setError("No namespace registered for prefix '$prefix'");
826
+        return false;
827
+    }
828
+
829
+    /**
830
+     * returns the prefix for a given namespace (or prefix)
831
+     * or false if no prefixes registered for the given namespace
832
+     *
833
+     * @param string $ns The namespace
834
+     * @return mixed The prefix, false if the namespace has no prefixes
835
+     * @access public
836
+     */
837
+    function getPrefixFromNamespace($ns) {
838
+        foreach ($this->namespaces as $p => $n) {
839
+            if ($ns == $n || $ns == $p) {
840
+                $this->usedNamespaces[$p] = $n;
841
+                return $p;
842
+            }
843
+        }
844
+        return false;
845
+    }
846
+
847
+    /**
848
+     * returns the time in ODBC canonical form with microseconds
849
+     *
850
+     * @return string The time in ODBC canonical form with microseconds
851
+     * @access public
852
+     */
853
+    function getmicrotime() {
854
+        if (function_exists('gettimeofday')) {
855
+            $tod = gettimeofday();
856
+            $sec = $tod['sec'];
857
+            $usec = $tod['usec'];
858
+        } else {
859
+            $sec = time();
860
+            $usec = 0;
861
+        }
862
+        return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
+    }
864
+
865
+    /**
866
+     * Returns a string with the output of var_dump
867
+     *
868
+     * @param mixed $data The variable to var_dump
869
+     * @return string The output of var_dump
870
+     * @access public
871
+     */
872 872
     function varDump($data) {
873
-		ob_start();
874
-		var_dump($data);
875
-		$ret_val = ob_get_contents();
876
-		ob_end_clean();
877
-		return $ret_val;
878
-	}
879
-
880
-	/**
881
-	* represents the object as a string
882
-	*
883
-	* @return	string
884
-	* @access   public
885
-	*/
886
-	function __toString() {
887
-		return $this->varDump($this);
888
-	}
873
+        ob_start();
874
+        var_dump($data);
875
+        $ret_val = ob_get_contents();
876
+        ob_end_clean();
877
+        return $ret_val;
878
+    }
879
+
880
+    /**
881
+     * represents the object as a string
882
+     *
883
+     * @return	string
884
+     * @access   public
885
+     */
886
+    function __toString() {
887
+        return $this->varDump($this);
888
+    }
889 889
 }
890 890
 
891 891
 // XML Schema Datatype Helper Functions
@@ -901,35 +901,35 @@  discard block
 block discarded – undo
901 901
 * @access   public
902 902
 */
903 903
 function timestamp_to_iso8601($timestamp,$utc=true){
904
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
905
-	$pos = strrpos($datestr, "+");
906
-	if ($pos === FALSE) {
907
-		$pos = strrpos($datestr, "-");
908
-	}
909
-	if ($pos !== FALSE) {
910
-		if (strlen($datestr) == $pos + 5) {
911
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
-		}
913
-	}
914
-	if($utc){
915
-		$pattern = '/'.
916
-		'([0-9]{4})-'.	// centuries & years CCYY-
917
-		'([0-9]{2})-'.	// months MM-
918
-		'([0-9]{2})'.	// days DD
919
-		'T'.			// separator T
920
-		'([0-9]{2}):'.	// hours hh:
921
-		'([0-9]{2}):'.	// minutes mm:
922
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
923
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
924
-		'/';
925
-
926
-		if(preg_match($pattern,$datestr,$regs)){
927
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
928
-		}
929
-		return false;
930
-	} else {
931
-		return $datestr;
932
-	}
904
+    $datestr = date('Y-m-d\TH:i:sO',$timestamp);
905
+    $pos = strrpos($datestr, "+");
906
+    if ($pos === FALSE) {
907
+        $pos = strrpos($datestr, "-");
908
+    }
909
+    if ($pos !== FALSE) {
910
+        if (strlen($datestr) == $pos + 5) {
911
+            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
+        }
913
+    }
914
+    if($utc){
915
+        $pattern = '/'.
916
+        '([0-9]{4})-'.	// centuries & years CCYY-
917
+        '([0-9]{2})-'.	// months MM-
918
+        '([0-9]{2})'.	// days DD
919
+        'T'.			// separator T
920
+        '([0-9]{2}):'.	// hours hh:
921
+        '([0-9]{2}):'.	// minutes mm:
922
+        '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
923
+        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
924
+        '/';
925
+
926
+        if(preg_match($pattern,$datestr,$regs)){
927
+            return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
928
+        }
929
+        return false;
930
+    } else {
931
+        return $datestr;
932
+    }
933 933
 }
934 934
 
935 935
 /**
@@ -940,35 +940,35 @@  discard block
 block discarded – undo
940 940
 * @access   public
941 941
 */
942 942
 function iso8601_to_timestamp($datestr){
943
-	$pattern = '/'.
944
-	'([0-9]{4})-'.	// centuries & years CCYY-
945
-	'([0-9]{2})-'.	// months MM-
946
-	'([0-9]{2})'.	// days DD
947
-	'T'.			// separator T
948
-	'([0-9]{2}):'.	// hours hh:
949
-	'([0-9]{2}):'.	// minutes mm:
950
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
951
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
952
-	'/';
953
-	if(preg_match($pattern,$datestr,$regs)){
954
-		// not utc
955
-		if($regs[8] != 'Z'){
956
-			$op = substr($regs[8],0,1);
957
-			$h = substr($regs[8],1,2);
958
-			$m = substr($regs[8],strlen($regs[8])-2,2);
959
-			if($op == '-'){
960
-				$regs[4] = $regs[4] + $h;
961
-				$regs[5] = $regs[5] + $m;
962
-			} elseif($op == '+'){
963
-				$regs[4] = $regs[4] - $h;
964
-				$regs[5] = $regs[5] - $m;
965
-			}
966
-		}
967
-		return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
943
+    $pattern = '/'.
944
+    '([0-9]{4})-'.	// centuries & years CCYY-
945
+    '([0-9]{2})-'.	// months MM-
946
+    '([0-9]{2})'.	// days DD
947
+    'T'.			// separator T
948
+    '([0-9]{2}):'.	// hours hh:
949
+    '([0-9]{2}):'.	// minutes mm:
950
+    '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
951
+    '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
952
+    '/';
953
+    if(preg_match($pattern,$datestr,$regs)){
954
+        // not utc
955
+        if($regs[8] != 'Z'){
956
+            $op = substr($regs[8],0,1);
957
+            $h = substr($regs[8],1,2);
958
+            $m = substr($regs[8],strlen($regs[8])-2,2);
959
+            if($op == '-'){
960
+                $regs[4] = $regs[4] + $h;
961
+                $regs[5] = $regs[5] + $m;
962
+            } elseif($op == '+'){
963
+                $regs[4] = $regs[4] - $h;
964
+                $regs[5] = $regs[5] - $m;
965
+            }
966
+        }
967
+        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
968 968
 //		return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
969
-	} else {
970
-		return false;
971
-	}
969
+    } else {
970
+        return false;
971
+    }
972 972
 }
973 973
 
974 974
 /**
@@ -980,13 +980,13 @@  discard block
 block discarded – undo
980 980
 */
981 981
 function usleepWindows($usec)
982 982
 {
983
-	$start = gettimeofday();
984
-
985
-	do
986
-	{
987
-		$stop = gettimeofday();
988
-		$timePassed = 1000000 * ($stop['sec'] - $start['sec'])
989
-		+ $stop['usec'] - $start['usec'];
990
-	}
991
-	while ($timePassed < $usec);
983
+    $start = gettimeofday();
984
+
985
+    do
986
+    {
987
+        $stop = gettimeofday();
988
+        $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
989
+        + $stop['usec'] - $start['usec'];
990
+    }
991
+    while ($timePassed < $usec);
992 992
 }
Please login to merge, or discard this patch.