Trying to make both uw and cyrus work with special folders.
[squirrelmail.git] / functions / imap_mailbox.php
CommitLineData
59177427 1<?php
bccadd02 2
35586184 3/**
4 * imap_mailbox.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This impliments all functions that manipulate mailboxes
10 *
11 * $Id$
12 */
f435778e 13
90de1755 14/*
15 Defines Special Mail Boxes
16*/
17
18function isSpecialMailbox( $box ) {
19
20 global $trash_folder, $sent_folder, $draft_folder,
21 $move_to_trash, $move_to_sent, $save_as_draft,
72b9aff9 22 $delimiter, $folder_prefix, $imap_server_type;
90de1755 23
fdc05b69 24 if ( $imap_server_type == 'uw' ) {
25 $boxs = $box;
26 $i = strpos( $sent_folder, $delimiter, strlen( $folder_prefix ) );
27 if ( $i === FALSE ) {
28 $i = strlen( $box );
29 }
30 } else {
31 $boxs = $box . $delimiter;
32 // Skip next second delimiter
33 $i = strpos( $sent_folder, $delimiter );
34 $i = strpos( $sent_folder, $delimiter, $i + 1 );
35 if ( $i === FALSE ) {
36 $i = strlen( $box );
72b9aff9 37 } else {
fdc05b69 38 $i++;
4d6bd355 39 }
7980d569 40 }
72b9aff9 41
90de1755 42 $ret = ( (strtolower($box) == 'inbox') ||
fdc05b69 43 ( substr( $trash_folder, 0, $i ) == substr( $boxs, 0, $i ) &&
90de1755 44 $move_to_trash) ||
fdc05b69 45 ( substr( $sent_folder, 0, $i ) == substr( $boxs, 0, $i ) &&
90de1755 46 $move_to_sent) ||
47 ($box == $draft_folder &&
48 $save_as_draft) );
49
50 return( $ret );
51
52}
53
35586184 54/*************************
55 ** Expunges a mailbox **
56 *************************/
90de1755 57function sqimap_mailbox_expunge ($imap_stream, $mailbox,$handle_errors = TRUE)
43b698c7 58{
1c72b151 59 $read = sqimap_run_command($imap_stream, 'EXPUNGE',
60 $handle_errors, $response, $message);
43b698c7 61}
62
63
64/******************************************************************************
65 ** Checks whether or not the specified mailbox exists
66 ******************************************************************************/
67function sqimap_mailbox_exists ($imap_stream, $mailbox)
68{
69 if (! isset($mailbox)) {
70 return false;
71 }
1c72b151 72 $mbx = sqimap_run_command($imap_stream, "LIST \"\" \"$mailbox\"",
90de1755 73 TRUE, $response, $message);
43b698c7 74 return isset($mbx[0]);
75}
76
77/******************************************************************************
78 ** Selects a mailbox
79 ******************************************************************************/
80function sqimap_mailbox_select ($imap_stream, $mailbox,
90de1755 81 $hide=TRUE, $recent=false)
43b698c7 82{
83 global $auto_expunge;
84
85 if ( $mailbox == 'None' ) {
86 return;
87 }
88
1c72b151 89 $read = sqimap_run_command($imap_stream, "SELECT \"$mailbox\"",
90de1755 90 TRUE, $response, $message);
43b698c7 91 if ($recent) {
92 for ($i=0; $i<count($read); $i++) {
bccadd02 93 if (strpos(strtolower($read[$i]), 'recent')) {
43b698c7 94 $r = explode(' ', $read[$i]);
04632dbc 95 }
43b698c7 96 }
97 return $r[1];
98 }
99 if ($auto_expunge) {
1a16af11 100 $tmp = sqimap_run_command($imap_stream, 'EXPUNGE',
1c72b151 101 false, $a, $b);
43b698c7 102 }
103}
104
105
106
107/******************************************************************************
108 ** Creates a folder
109 ******************************************************************************/
110function sqimap_mailbox_create ($imap_stream, $mailbox, $type)
111{
112 global $delimiter;
113 if (strtolower($type) == 'noselect') {
114 $mailbox = $mailbox.$delimiter;
115 }
1c72b151 116 $read_ary = sqimap_run_command($imap_stream, "CREATE \"$mailbox\"",
90de1755 117 TRUE, $response, $message);
43b698c7 118
119 sqimap_subscribe ($imap_stream, $mailbox);
120}
121
122
123
124/******************************************************************************
125 ** Subscribes to an existing folder
126 ******************************************************************************/
127function sqimap_subscribe ($imap_stream, $mailbox)
128{
1a16af11 129 $read_ary = sqimap_run_command($imap_stream, "SUBSCRIBE \"$mailbox\"",
90de1755 130 TRUE, $response, $message);
43b698c7 131}
132
133
134
135/******************************************************************************
136 ** Unsubscribes to an existing folder
137 ******************************************************************************/
138function sqimap_unsubscribe ($imap_stream, $mailbox)
139{
140 global $imap_server_type;
141
1a16af11 142 $read_ary = sqimap_run_command($imap_stream, "UNSUBSCRIBE \"$mailbox\"",
90de1755 143 TRUE, $response, $message);
43b698c7 144}
145
146
147
148/******************************************************************************
149 ** This function simply deletes the given folder
150 ******************************************************************************/
151function sqimap_mailbox_delete ($imap_stream, $mailbox)
152{
1c72b151 153 $read_ary = sqimap_run_command($imap_stream, "DELETE \"$mailbox\"",
90de1755 154 TRUE, $response, $message);
43b698c7 155 sqimap_unsubscribe ($imap_stream, $mailbox);
156}
157
158/***********************************************************************
159 ** Determines if the user is subscribed to the folder or not
160 **********************************************************************/
161function sqimap_mailbox_is_subscribed($imap_stream, $folder)
162{
163 $boxes = sqimap_mailbox_list ($imap_stream);
164 foreach ($boxes as $ref) {
165 if ($ref['unformatted'] == $folder) {
90de1755 166 return TRUE;
43b698c7 167 }
168 }
169 return false;
170}
171
1c52ba77 172/*
173 Renames a mailbox
174*/
175function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) {
43b698c7 176
1c52ba77 177 if ( $old_name <> $new_name ) {
178
179 global $delimiter;
180
181 if ( substr( $old_name, -1 ) == $delimiter ) {
182 $old_name = substr( $old_name, 0, strlen( $old_name ) - 1 );
183 $new_name = substr( $new_name, 0, strlen( $new_name ) - 1 );
184 $postfix = $delimiter;
185 $boxes = sqimap_mailbox_list($imap_stream);
186 } else {
187 $postfix = '';
188 $boxes = FALSE;
189 }
190
1c72b151 191 $cmd = 'RENAME "' . quoteIMAP($old_name) . '" "' . quoteIMAP($new_name) . '"';
192 $data = sqimap_run_command($imap_stream, $cmd,
1c52ba77 193 TRUE, $response, $message);
194 sqimap_unsubscribe($imap_stream, $old_name.$postfix);
195 sqimap_subscribe($imap_stream, $new_name.$postfix);
196
197 if ( $boxes ) {
198 // Sub-unsub subfolders
199 $l = strlen( $old_name ) + 1;
200 $p = 'unformatted';
201 foreach ( $boxes as $box ) {
202 if ( substr( $box[$p], 0, $l ) == $old_name . $delimiter ) {
203 sqimap_unsubscribe($imap_stream, $box[$p]);
204 sqimap_subscribe($imap_stream,
205 $new_name . $delimiter . substr( $box[$p], $l ) );
206 }
207 }
208 }
209
210 }
211
212}
43b698c7 213
214/******************************************************************************
215 ** Formats a mailbox into 4 parts for the $boxes array
216 **
217 ** The four parts are:
218 **
219 ** raw - Raw LIST/LSUB response from the IMAP server
220 ** formatted - nicely formatted folder name
221 ** unformatted - unformatted, but with delimiter at end removed
222 ** unformatted-dm - folder name as it appears in raw response
223 ** unformatted-disp - unformatted without $folder_prefix
224 **
225 ******************************************************************************/
226function sqimap_mailbox_parse ($line, $line_lsub)
227{
228 global $folder_prefix, $delimiter;
229
230 /* Process each folder line */
231 for ($g=0; $g < count($line); $g++) {
232
233 /* Store the raw IMAP reply */
234 if (isset($line[$g])) {
a7ea7540 235 $boxes[$g]["raw"] = $line[$g];
43b698c7 236 }
237 else {
a7ea7540 238 $boxes[$g]["raw"] = "";
43b698c7 239 }
240
241
242 /* Count number of delimiters ($delimiter) in folder name */
243 $mailbox = trim($line_lsub[$g]);
602e1431 244 $dm_count = substr_count($mailbox, $delimiter);
43b698c7 245 if (substr($mailbox, -1) == $delimiter) {
246 /* If name ends in delimiter - decrement count by one */
247 $dm_count--;
248 }
249
250 /* Format folder name, but only if it's a INBOX.* or have */
251 /* a parent. */
252 $boxesbyname[$mailbox] = $g;
253 $parentfolder = readMailboxParent($mailbox, $delimiter);
254 if ( (strtolower(substr($mailbox, 0, 5)) == "inbox") ||
255 (substr($mailbox, 0, strlen($folder_prefix)) == $folder_prefix) ||
256 ( isset($boxesbyname[$parentfolder]) &&
257 (strlen($parentfolder) > 0) ) ) {
602e1431 258 $indent = $dm_count - ( substr_count($folder_prefix, $delimiter));
43b698c7 259 if ($indent > 0) {
90de1755 260 $boxes[$g]['formatted'] = str_repeat("&nbsp;&nbsp;", $indent);
43b698c7 261 }
262 else {
90de1755 263 $boxes[$g]['formatted'] = '';
43b698c7 264 }
90de1755 265 $boxes[$g]['formatted'] .= readShortMailboxName($mailbox, $delimiter);
43b698c7 266 }
267 else {
90de1755 268 $boxes[$g]['formatted'] = $mailbox;
43b698c7 269 }
90de1755 270
43b698c7 271 $boxes[$g]['unformatted-dm'] = $mailbox;
272 if (substr($mailbox, -1) == $delimiter) {
8e9e8afa 273 $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
43b698c7 274 }
275 $boxes[$g]['unformatted'] = $mailbox;
276 if (substr($mailbox,0,strlen($folder_prefix))==$folder_prefix) {
631b9da3 277 $mailbox = substr($mailbox, strlen($folder_prefix));
43b698c7 278 }
279 $boxes[$g]['unformatted-disp'] = $mailbox;
280 $boxes[$g]['id'] = $g;
90de1755 281
43b698c7 282 $boxes[$g]['flags'] = array();
283 if (isset($line[$g])) {
36dfb0c9 284 ereg("\(([^)]*)\)",$line[$g],$regs);
1a7e1e97 285 $flags = trim(strtolower(str_replace('\\', '',$regs[1])));
43b698c7 286 if ($flags) {
287 $boxes[$g]['flags'] = explode(' ', $flags);
288 }
289 }
290 }
90de1755 291
43b698c7 292 return $boxes;
293}
294
a3439b27 295/**
296 * Sorting function used to sort mailbox names.
297 * + Original patch from dave_michmerhuizen@yahoo.com
298 * + Allows case insensitivity when sorting folders
299 * + Takes care of the delimiter being sorted to the end, causing
300 * subfolders to be listed in below folders that are prefixed
301 * with their parent folders name.
302 * For example: INBOX.foo, INBOX.foobar, and INBOX.foo.bar
303 * Without special sort function: foobar between foo and foo.bar
304 * With special sort function: foobar AFTER foo and foo.bar :)
43b698c7 305 */
a3439b27 306function user_strcasecmp($a, $b) {
307 global $delimiter;
308
309 /* Calculate the length of some strings. */
310 $a_length = strlen($a);
311 $b_length = strlen($b);
312 $min_length = min($a_length, $b_length);
313 $delimiter_length = strlen($delimiter);
314
315 /* Set the initial result value. */
316 $result = 0;
317
318 /* Check the strings... */
319 for ($c = 0; $c < $min_length; ++$c) {
320 $a_del = substr($a, $c, $delimiter_length);
321 $b_del = substr($b, $c, $delimiter_length);
322
323 if (($a_del == $delimiter) && ($b_del == $delimiter)) {
324 $result = 0;
325 } else if (($a_del == $delimiter) && ($b_del != $delimiter)) {
a3439b27 326 $result = -1;
c64c33f4 327 } else if (($a_del != $delimiter) && ($b_del == $delimiter)) {
328 $result = 1;
a3439b27 329 } else {
330 $result = strcasecmp($a{$c}, $b{$c});
331 }
332
333 if ($result != 0) {
334 break;
335 }
336 }
90de1755 337
a3439b27 338 /* If one string is a prefix of the other... */
339 if ($result == 0) {
340 if ($a_length < $b_length) {
341 $result = -1;
342 } else if ($a_length > $b_length) {
343 $result = 1;
344 }
345 }
346
347 return ($result);
43b698c7 348}
349
350
351/******************************************************************************
352 ** Returns sorted mailbox lists in several different ways.
353 ** See comment on sqimap_mailbox_parse() for info about the returned array.
354 ******************************************************************************/
a3439b27 355function sqimap_mailbox_list ($imap_stream) {
90de1755 356 global $data_dir, $username, $list_special_folders_first,
357 $folder_prefix, $trash_folder, $sent_folder, $draft_folder,
358 $move_to_trash, $move_to_sent, $save_as_draft,
359 $delimiter;
360
43b698c7 361 $inbox_in_list = false;
362 $inbox_subscribed = false;
90de1755 363
43b698c7 364 require_once('../src/load_prefs.php');
365 require_once('../functions/array.php');
90de1755 366
43b698c7 367 /** LSUB array **/
1c72b151 368 $lsub_ary = sqimap_run_command ($imap_stream, "LSUB \"$folder_prefix\" \"*\"",
90de1755 369 TRUE, $response, $message);
370
43b698c7 371 /* Section about removing the last element was removed */
372 /* We don't return "* OK" anymore from sqimap_read_data */
90de1755 373
43b698c7 374 $sorted_lsub_ary = array();
375 for ($i=0;$i < count($lsub_ary); $i++) {
376 /* Workaround for EIMS */
377 /* Doesn't work if the mailbox name is multiple lines */
378 if (isset($lsub_ary[$i + 1]) &&
90de1755 379 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
43b698c7 380 $lsub_ary[$i], $regs)) {
381 $i ++;
382 $lsub_ary[$i] = $regs[1] . '"' . addslashes(trim($lsub_ary[$i])) .
383 '"' . $regs[2];
384 }
385 $temp_mailbox_name = find_mailbox_name($lsub_ary[$i]);
386 $sorted_lsub_ary[] = $temp_mailbox_name;
387 if (strtoupper($temp_mailbox_name) == 'INBOX') {
90de1755 388 $inbox_subscribed = TRUE;
43b698c7 389 }
390 }
391 $new_ary = array();
392 for ($i=0; $i < count($sorted_lsub_ary); $i++) {
393 if (!in_array($sorted_lsub_ary[$i], $new_ary)) {
ee62ce13 394 $new_ary[] = $sorted_lsub_ary[$i];
43b698c7 395 }
396 }
397 $sorted_lsub_ary = $new_ary;
398 if (isset($sorted_lsub_ary)) {
399 usort($sorted_lsub_ary, 'user_strcasecmp');
90de1755 400 }
401
43b698c7 402 /** LIST array **/
403 $sorted_list_ary = array();
404 for ($i=0; $i < count($sorted_lsub_ary); $i++) {
405 if (substr($sorted_lsub_ary[$i], -1) == $delimiter) {
f9b3e5d9 406 $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
43b698c7 407 }
408 else {
f9b3e5d9 409 $mbx = $sorted_lsub_ary[$i];
43b698c7 410 }
90de1755 411
1c72b151 412 $read = sqimap_run_command ($imap_stream, "LIST \"\" \"$mbx\"",
90de1755 413 TRUE, $response, $message);
43b698c7 414 /* Another workaround for EIMS */
90de1755 415 if (isset($read[1]) &&
416 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
43b698c7 417 $read[0], $regs)) {
418 $read[0] = $regs[1] . '"' . addslashes(trim($read[1])) .
90de1755 419 '"' . $regs[2];
43b698c7 420 }
90de1755 421
43b698c7 422 if (isset($sorted_list_ary[$i])) {
90de1755 423 $sorted_list_ary[$i] = '';
43b698c7 424 }
90de1755 425
43b698c7 426 if (isset($read[0])) {
44a3ca20 427 $sorted_list_ary[$i] = $read[0];
43b698c7 428 }
429 else {
90de1755 430 $sorted_list_ary[$i] = '';
43b698c7 431 }
90de1755 432
433 if (isset($sorted_list_ary[$i]) &&
434 strtoupper(find_mailbox_name($sorted_list_ary[$i])) == 'INBOX') {
435 $inbox_in_list = TRUE;
43b698c7 436 }
437 }
90de1755 438
43b698c7 439 /**
440 * Just in case they're not subscribed to their inbox,
441 * we'll get it for them anyway
442 */
443 if ($inbox_subscribed == false || $inbox_in_list == false) {
1c72b151 444 $inbox_ary = sqimap_run_command ($imap_stream, "LIST \"\" \"INBOX\"",
90de1755 445 TRUE, $response, $message);
43b698c7 446 /* Another workaround for EIMS */
447 if (isset($inbox_ary[1]) &&
90de1755 448 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
43b698c7 449 $inbox_ary[0], $regs)) {
450 $inbox_ary[0] = $regs[1] . '"' . addslashes(trim($inbox_ary[1])) .
451 '"' . $regs[2];
452 }
90de1755 453
43b698c7 454 $sorted_list_ary[] = $inbox_ary[0];
455 $sorted_lsub_ary[] = find_mailbox_name($inbox_ary[0]);
456 }
90de1755 457
43b698c7 458 $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary);
90de1755 459
43b698c7 460 /** Now, lets sort for special folders **/
90de1755 461 $boxesnew = $used = array();
462
43b698c7 463 /* Find INBOX */
90de1755 464 foreach ( $boxes as $k => $box ) {
465 if ( strtolower($box['unformatted']) == 'inbox') {
466 $boxesnew[] = $box;
467 $used[$k] = TRUE;
468 } else {
469 $used[$k] = FALSE;
43b698c7 470 }
471 }
90de1755 472
43b698c7 473 /* List special folders and their subfolders, if requested. */
90de1755 474 if ($list_special_folders_first == TRUE) {
475
476 foreach ( $boxes as $k => $box ) {
477 if ( !$used[$k] &&
478 isSpecialMailbox( $box['unformatted'] ) ) {
479 $boxesnew[] = $box;
480 $used[$k] = TRUE;
2752bb16 481 }
43b698c7 482 }
90de1755 483
43b698c7 484 }
90de1755 485
43b698c7 486 /* Rest of the folders */
90de1755 487 foreach ( $boxes as $k => $box ) {
488 if ( !$used[$k] ) {
489 $boxesnew[] = $box;
43b698c7 490 }
491 }
90de1755 492
493 return( $boxesnew );
43b698c7 494}
495
90de1755 496/*
497 * Returns a list of all folders, subscribed or not
498 */
43b698c7 499function sqimap_mailbox_list_all ($imap_stream)
500{
501 global $list_special_folders_first, $folder_prefix;
502 global $delimiter;
90de1755 503
504 if (!function_exists('ary_sort')) {
43b698c7 505 include_once('../functions/array.php');
506 }
90de1755 507
43b698c7 508 $ssid = sqimap_session_id();
90de1755 509 $lsid = strlen( $ssid );
43b698c7 510 fputs ($imap_stream, $ssid . " LIST \"$folder_prefix\" *\r\n");
90de1755 511 $read_ary = sqimap_read_data ($imap_stream, $ssid, TRUE, $response, $message);
43b698c7 512 $g = 0;
90de1755 513 $phase = 'inbox';
514
43b698c7 515 for ($i = 0; $i < count($read_ary); $i++) {
516 /* Another workaround for EIMS */
517 if (isset($read_ary[$i + 1]) &&
90de1755 518 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
43b698c7 519 $read_ary[$i], $regs)) {
520 $i ++;
90de1755 521 $read_ary[$i] = $regs[1] . '"' .
1c52ba77 522 addslashes(trim($read_ary[$i])) .
523 '"' . $regs[2];
43b698c7 524 }
90de1755 525 if (substr($read_ary[$i], 0, $lsid) != $ssid ) {
526
43b698c7 527 /* Store the raw IMAP reply */
8e9e8afa 528 $boxes[$g]["raw"] = $read_ary[$i];
1c52ba77 529
43b698c7 530 /* Count number of delimiters ($delimiter) in folder name */
8e9e8afa 531 $mailbox = find_mailbox_name($read_ary[$i]);
602e1431 532 $dm_count = substr_count($mailbox, $delimiter);
43b698c7 533 if (substr($mailbox, -1) == $delimiter) {
0cfd745a 534 /* If name ends in delimiter - decrement count by one */
90de1755 535 $dm_count--;
43b698c7 536 }
90de1755 537
43b698c7 538 /* Format folder name, but only if it's a INBOX.* or have */
539 /* a parent. */
2752bb16 540 $boxesbyname[$mailbox] = $g;
525b7ae6 541 $parentfolder = readMailboxParent($mailbox, $delimiter);
90de1755 542 if((eregi('^inbox'.quotemeta($delimiter), $mailbox)) ||
146e0c45 543 (ereg('^'.$folder_prefix, $mailbox)) ||
2752bb16 544 ( isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
43b698c7 545 if ($dm_count) {
90de1755 546 $boxes[$g]['formatted'] = str_repeat('&nbsp;&nbsp;', $dm_count);
43b698c7 547 }
548 else {
90de1755 549 $boxes[$g]['formatted'] = '';
43b698c7 550 }
90de1755 551 $boxes[$g]['formatted'] .= readShortMailboxName($mailbox, $delimiter);
2752bb16 552 }
43b698c7 553 else {
90de1755 554 $boxes[$g]['formatted'] = $mailbox;
43b698c7 555 }
90de1755 556
8e9e8afa 557 $boxes[$g]["unformatted-dm"] = $mailbox;
43b698c7 558 if (substr($mailbox, -1) == $delimiter) {
559 $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
560 }
90de1755 561 $boxes[$g]['unformatted'] = $mailbox;
562 $boxes[$g]['unformatted-disp'] =
0cfd745a 563 ereg_replace('^' . $folder_prefix, '', $mailbox);
90de1755 564 $boxes[$g]['id'] = $g;
565
8e9e8afa 566 /** Now lets get the flags for this mailbox **/
1c72b151 567 $read_mlbx = sqimap_run_command ($imap_stream, "LIST \"\" \"$mailbox\"",
90de1755 568 TRUE, $response, $message);
569
43b698c7 570 /* Another workaround for EIMS */
571 if (isset($read_mlbx[1]) &&
90de1755 572 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
43b698c7 573 $read_mlbx[0], $regs)) {
1c52ba77 574 $read_mlbx[0] = $regs[1] . '"' .
575 addslashes(trim($read_mlbx[1])) .
576 '"' . $regs[2];
43b698c7 577 }
90de1755 578
579 $flags = substr($read_mlbx[0], strpos($read_mlbx[0], '(')+1);
580 $flags = substr($flags, 0, strpos($flags, ')'));
146e0c45 581 $flags = str_replace('\\', '', $flags);
8e9e8afa 582 $flags = trim(strtolower($flags));
583 if ($flags) {
1c52ba77 584 $boxes[$g]['flags'] = explode(' ', $flags);
90de1755 585 } else {
43b698c7 586 $boxes[$g]['flags'] = array();
12d61439 587 }
43b698c7 588 }
589 $g++;
590 }
591 if(is_array($boxes)) {
1c52ba77 592 $boxes = ary_sort ($boxes, 'unformatted', 1);
43b698c7 593 }
90de1755 594
43b698c7 595 return $boxes;
596}
5bdd7223 597
f7b1b3b1 598?>