| [ Index ] |
|
Code source de IMP H3 (4.1.5) |
1 <?php 2 /** 3 * The IMP_Folder:: class provides a set of methods for dealing with folders, 4 * accounting for subscription, errors, etc. 5 * 6 * $Horde: imp/lib/Folder.php,v 1.130.10.43 2007/07/18 20:09:50 chuck Exp $ 7 * 8 * Copyright 2000-2007 Chuck Hagenbuch <chuck@horde.org> 9 * Copyright 2000-2007 Jon Parise <jon@csh.rit.edu> 10 * 11 * See the enclosed file COPYING for license information (GPL). If you did not 12 * receive this file, see http://www.fsf.org/copyleft/gpl.html. 13 * 14 * @author Chuck Hagenbuch <chuck@horde.org> 15 * @author Jon Parise <jon@csh.rit.edu> 16 * @since IMP 2.3 17 * @package IMP 18 */ 19 class IMP_Folder { 20 21 /** 22 * Keep around identical lists so that we don't hit the server more that 23 * once in the same page for the same thing. 24 * 25 * @var array 26 */ 27 var $_listCache = array(); 28 29 /** 30 * Keep track of mailbox names that we have complained about to prevent 31 * giving the user identical error messages. 32 * 33 * @var array 34 */ 35 var $_errorCache = array(); 36 37 /** 38 * Cached results from the exists() function. 39 * 40 * @var array 41 */ 42 var $_existsResults = array(); 43 44 /** 45 * Returns a reference to the global IMP_Folder object, only creating it 46 * if it doesn't already exist. This ensures that only one IMP_Folder 47 * instance is instantiated for any given session. 48 * 49 * This method must be invoked as:<code> 50 * $imp_folder = &IMP_Folder::singleton(); 51 * </code> 52 * 53 * @return IMP_Folder The IMP_Folder instance. 54 */ 55 function &singleton() 56 { 57 static $folder; 58 59 if (!isset($folder)) { 60 $folder = new IMP_Folder(); 61 } 62 63 return $folder; 64 } 65 66 /** 67 * Lists folders. 68 * 69 * @param boolean $sub Should we list only subscribed folders? 70 * @param array $filter An list of mailboxes that should be left out of 71 * the list. 72 * 73 * @return array An array of folders, where each array alement is an 74 * associative array containing three values: 'val', with 75 * entire folder name after the server specification; 76 * 'label', with the full-length folder name meant for 77 * display and 'abbrev', containing a shortened (26 78 * characters max) label for display in situations where 79 * space is short. 80 */ 81 function flist($sub = false, $filter = array()) 82 { 83 global $conf, $notification; 84 85 $inbox_entry = array('INBOX' => array('val' => 'INBOX', 'label' => _("Inbox"), 'abbrev' => _("Inbox"))); 86 87 if ($_SESSION['imp']['base_protocol'] == 'pop3') { 88 return $inbox_entry; 89 } 90 91 $list = array(); 92 $subidx = intval($sub); 93 94 /* Compute values that will uniquely identify this list. */ 95 $full_signature = md5(serialize(array($subidx, $filter))); 96 97 /* Either get the list from the cache, or go to the IMAP server to 98 obtain it. */ 99 if ($conf['server']['cache_folders']) { 100 require_once 'Horde/SessionObjects.php'; 101 $sessionOb = &Horde_SessionObjects::singleton(); 102 if (!isset($_SESSION['imp']['cache']['folder_cache'])) { 103 $_SESSION['imp']['cache']['folder_cache'] = array(); 104 } 105 $folder_cache = &$_SESSION['imp']['cache']['folder_cache']; 106 if (isset($folder_cache[$full_signature])) { 107 $data = $sessionOb->query($folder_cache[$full_signature]); 108 if ($data) { 109 return $data; 110 } 111 } 112 } 113 114 if (isset($this->_listCache[$subidx])) { 115 $maildelim = $this->_listCache[$subidx]['d']; 116 $mailsort = $this->_listCache[$subidx]['s']; 117 } else { 118 $maildelim = $mailsort = array(); 119 foreach ($this->_listFolders($sub) as $val) { 120 /* Strip off the prefix only if we are dealing with a personal 121 * namespace. */ 122 $label = $stripped = substr($val, strpos($val, '}') + 1); 123 $ns_info = IMP::getNamespace($label); 124 if ($ns_info['type'] == 'personal') { 125 $label = substr($label, strlen($ns_info['name'])); 126 } 127 if (strcasecmp('INBOX', $label) == 0) { 128 continue; 129 } 130 $maildelim[$stripped] = $ns_info['delimiter']; 131 $mailsort[$stripped] = $label; 132 } 133 $this->_listCache[$subidx] = array('d' => $maildelim, 's' => $mailsort); 134 } 135 136 if (!empty($mailsort)) { 137 // TODO: Fix use of delimiter here 138 require_once IMP_BASE . '/lib/IMAP/Sort.php'; 139 $delimiter = reset($_SESSION['imp']['namespace']); 140 $imap_sort = &new IMP_IMAP_Sort($delimiter['delimiter']); 141 $imap_sort->sortMailboxes($mailsort, true, true); 142 143 foreach ($mailsort as $mbox_name => $label) { 144 if (in_array($mbox_name, $filter)) { 145 continue; 146 } 147 148 if (!($decoded_mailbox = String::convertCharset($mbox_name, 'UTF7-IMAP')) && 149 empty($this->_errorCache[$mbox_name])) { 150 $notification->push(sprintf(_("The folder \"%s\" contains illegal characters in its name. It may cause problems. Please see your system administrator."), $label), 'horde.warning'); 151 $this->_errorCache[$mbox_name] = true; 152 } 153 154 $parts = ($maildelim[$mbox_name]) ? explode($maildelim[$mbox_name], $label) : array($label); 155 $partcount = count($parts); 156 for ($i = 1; $i <= $partcount; $i++) { 157 $item = implode($maildelim[$mbox_name], array_slice($parts, 0, $i)); 158 if (!isset($list[$item])) { 159 $abbrev = $folded = str_repeat(' ', 4 * ($i - 1)) . String::convertCharset($parts[($i - 1)], 'UTF7-IMAP'); 160 if (strlen($abbrev) > 26) { 161 $abbrev = String::substr($abbrev, 0, 10) . '...' . String::substr($abbrev, -13, 13); 162 } 163 $list[$item] = array('val' => ($i == $partcount) ? $mbox_name : '', 'label' => $folded, 'abbrev' => $abbrev); 164 } 165 } 166 } 167 } 168 169 /* Add the INBOX on top of list if not in the filter list. */ 170 if (!in_array('INBOX', $filter)) { 171 $list = $inbox_entry + $list; 172 } 173 174 /* Save in cache, if needed. */ 175 if ($conf['server']['cache_folders']) { 176 $folder_cache[$full_signature] = $sessionOb->storeOid($list, false); 177 } 178 179 return $list; 180 } 181 182 /** 183 * Returns an array of folders. This is a wrapper around the flist() 184 * function which reduces the number of arguments needed if we can assume 185 * that IMP's full environment is present. 186 * 187 * @param array $filter An array of mailboxes to ignore. 188 * @param boolean $sub If set, will be used to determine if we should 189 * list only subscribed folders. 190 * 191 * @return array The array of mailboxes returned by flist(). 192 */ 193 function flist_IMP($filter = array(), $sub = null) 194 { 195 return $this->flist(is_null($sub) ? $GLOBALS['prefs']->getValue('subscribe') : $sub, $filter); 196 } 197 198 /** 199 * Deletes one or more folders. 200 * 201 * @param array $folder_array An array of full utf encoded folder names 202 * to be deleted. 203 * @param boolean $subscribe A boolean describing whether or not to use 204 * folder subscriptions. 205 * 206 * @return boolean Whether or not the folders were successfully deleted. 207 */ 208 function delete($folder_array, $subscribe) 209 { 210 global $conf, $notification; 211 212 $server = IMP::serverString(); 213 $return_value = true; 214 $deleted = array(); 215 216 if ($subscribe) { 217 $sub_folders = $this->_listFolders(true); 218 } 219 220 foreach ($folder_array as $folder) { 221 if (!imap_deletemailbox($_SESSION['imp']['stream'], $server . $folder)) { 222 $notification->push(sprintf(_("The folder \"%s\" was not deleted. This is what the server said"), IMP::displayFolder($folder)) . 223 ': ' . imap_last_error(), 'horde.error'); 224 $return_value = false; 225 } else { 226 if ($subscribe && 227 in_array($server . $folder, $sub_folders) && 228 !imap_unsubscribe($_SESSION['imp']['stream'], $server . $folder)) { 229 $notification->push(sprintf(_("The folder \"%s\" was deleted but you were not unsubscribed from it."), IMP::displayFolder($folder)), 'horde.warning'); 230 $return_value = false; 231 } else { 232 $notification->push(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), 'horde.success'); 233 } 234 235 $deleted[] = $folder; 236 unset($this->_existsResults[$folder]); 237 } 238 } 239 240 if (!empty($deleted)) { 241 /* Update the IMAP_Tree cache. */ 242 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 243 $imaptree = &IMP_Tree::singleton(); 244 if ($imaptree) { 245 $imaptree->delete($deleted); 246 } 247 248 /* Reset the folder cache. */ 249 if ($conf['server']['cache_folders']) { 250 unset($_SESSION['imp']['cache']['folder_cache']); 251 } 252 253 /* Recreate Virtual Folders. */ 254 $GLOBALS['imp_search']->sessionSetup(); 255 } 256 257 return $return_value; 258 } 259 260 /** 261 * Create a new IMAP folder if it does not already exist, and subcribe to 262 * it as well if requested. 263 * 264 * @param string $folder The full utf encoded folder to be created. 265 * @param boolean $subscribe A boolean describing whether or not to use 266 * folder subscriptions. 267 * 268 * @return boolean Whether or not the folder was successfully created. 269 */ 270 function create($folder, $subscribe) 271 { 272 global $conf, $notification; 273 274 /* Check permissions. */ 275 if (!IMP::hasPermission('create_folders')) { 276 $message = @htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, NLS::getCharset()); 277 if (!empty($conf['hooks']['permsdenied'])) { 278 $message = Horde::callHook('_perms_hook_denied', array('imp:create_folders'), 'horde', $message); 279 } 280 $notification->push($message, 'horde.error', array('content.raw')); 281 return false; 282 } elseif (!IMP::hasPermission('max_folders')) { 283 $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, NLS::getCharset()); 284 if (!empty($conf['hooks']['permsdenied'])) { 285 $message = Horde::callHook('_perms_hook_denied', array('imp:max_folders'), 'horde', $message); 286 } 287 $notification->push($message, 'horde.error', array('content.raw')); 288 return false; 289 } 290 291 /* Make sure we are not trying to create a duplicate folder */ 292 if ($this->exists($folder)) { 293 $notification->push(sprintf(_("The folder \"%s\" already exists"), IMP::displayFolder($folder)), 'horde.warning'); 294 return false; 295 } 296 297 /* Attempt to create the mailbox */ 298 if (!imap_createmailbox($_SESSION['imp']['stream'], IMP::serverString($folder))) { 299 $notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), IMP::displayFolder($folder)) . 300 ': ' . imap_last_error(), 'horde.error'); 301 return false; 302 } 303 304 /* Reset the folder cache. */ 305 if ($conf['server']['cache_folders']) { 306 unset($_SESSION['imp']['cache']['folder_cache']); 307 } 308 309 /* If the user uses SUBSCRIBE, then add to the subscribe list */ 310 $res = imap_subscribe($_SESSION['imp']['stream'], IMP::serverString($folder)); 311 if ($subscribe && !$res) { 312 $notification->push(sprintf(_("The folder \"%s\" was created but you were not subscribed to it."), IMP::displayFolder($folder)), 'horde.warning'); 313 } else { 314 /* The folder creation has been successful */ 315 $notification->push(sprintf(_("The folder \"%s\" was successfully created."), IMP::displayFolder($folder)), 'horde.success'); 316 } 317 318 /* Update the IMAP_Tree object. */ 319 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 320 $imaptree = &IMP_Tree::singleton(); 321 if ($imaptree) { 322 $imaptree->insert($folder); 323 } 324 325 /* Recreate Virtual Folders. */ 326 $GLOBALS['imp_search']->sessionSetup(); 327 328 return true; 329 } 330 331 /** 332 * Finds out if a specific folder exists or not. 333 * 334 * @param string $folder The full utf encoded folder name to be checked. 335 * 336 * @return boolean Whether or not the folder exists. 337 */ 338 function exists($folder) 339 { 340 /* Try the IMAP_Tree object first. */ 341 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 342 $imaptree = &IMP_Tree::singleton(); 343 if ($imaptree) { 344 $elt = $imaptree->get($folder); 345 if ($elt && !$imaptree->isContainer($elt)) { 346 return true; 347 } 348 } 349 350 if (!isset($this->_existsResults[$folder])) { 351 $res = @imap_list($_SESSION['imp']['stream'], IMP::serverString(), $folder); 352 $this->_existsResults[$folder] = is_array($res); 353 } 354 355 return $this->_existsResults[$folder]; 356 } 357 358 /** 359 * Renames an IMAP folder. The subscription status remains the same. All 360 * subfolders will also be renamed. 361 * 362 * @param string $old The old utf encoded folder name. 363 * @param string $new The new utf encoded folder name. 364 * 365 * @return boolean Whether or not all folder(s) were successfully renamed. 366 */ 367 function rename($old, $new) 368 { 369 global $conf, $notification; 370 371 /* Don't try to rename from or to an empty string. */ 372 if (strlen($old) == 0 || strlen($new) == 0) { 373 return false; 374 } 375 376 $namespace_info = IMP::getNamespace($old); 377 $server = IMP::serverString(); 378 $success = true; 379 $deleted = $inserted = array(); 380 381 /* Get list of any folders that are underneath this one. */ 382 $all_folders = array($server . $old); 383 $folder_list = imap_list($_SESSION['imp']['stream'], $server, $old . $namespace_info['delimiter'] . '*'); 384 if (is_array($folder_list)) { 385 $all_folders = array_merge($folder_list, $all_folders); 386 387 /* Sort the folders in reverse order because some IMAP servers 388 * will automatically rename all folders when the base folder is 389 * renamed which will result in error messages if we rename from 390 * the bottom up. */ 391 require_once IMP_BASE . '/lib/IMAP/Sort.php'; 392 $ns_new = IMP::getNamespace($new); 393 $imap_sort = &new IMP_IMAP_Sort($ns_new['delimiter']); 394 $imap_sort->sortMailboxes($all_folders); 395 $all_folders = array_reverse($all_folders); 396 } 397 398 $sub_folders = $this->_listFolders(true); 399 400 foreach ($all_folders as $folder_old) { 401 $subscribe = false; 402 403 $old_pos = strpos($folder_old, '}') + 1; 404 405 /* Get the new folder name. */ 406 $folder_new = preg_replace('/' . preg_quote($old, '/') . '/', $new, $folder_old, 1); 407 408 /* Get the folder names without the server prefix. */ 409 $name_old = substr($folder_old, $old_pos); 410 $name_new = substr($folder_new, strpos($folder_new, '}') + 1); 411 412 /* Unsubscribe from current folder. */ 413 if (in_array($folder_old, $sub_folders)) { 414 $subscribe = true; 415 imap_unsubscribe($_SESSION['imp']['stream'], $folder_old); 416 } 417 418 if (imap_renamemailbox($_SESSION['imp']['stream'], $folder_old, $folder_new)) { 419 if ($subscribe) { 420 imap_subscribe($_SESSION['imp']['stream'], $folder_new); 421 } 422 423 $deleted[] = $name_old; 424 $inserted[] = $name_new; 425 426 $notification->push(sprintf(_("The folder \"%s\" was successfully renamed to \"%s\"."), IMP::displayFolder($name_old), IMP::displayFolder($name_new)), 'horde.success'); 427 428 unset($this->_existsResults[$name_old]); 429 430 // Change current mailbox if current mailbox was renamed. 431 if ($_SESSION['imp']['mailbox'] == $name_old) { 432 $_SESSION['imp']['mailbox'] = $name_new; 433 } 434 } else { 435 $notification->push(sprintf(_("Renaming \"%s\" to \"%s\" failed. This is what the server said"), IMP::displayFolder($name_old), IMP::displayFolder($name_new)) . ': ' . imap_last_error(), 'horde.error'); 436 $success = false; 437 } 438 } 439 440 if (!empty($deleted)) { 441 /* Update the IMP_Tree cache. */ 442 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 443 $imaptree = &IMP_Tree::singleton(); 444 if ($imaptree) { 445 $imaptree->rename($deleted, $inserted); 446 } 447 448 /* Reset the folder cache. */ 449 if ($conf['server']['cache_folders']) { 450 unset($_SESSION['imp']['cache']['folder_cache']); 451 } 452 453 /* Recreate Virtual Folders. */ 454 $GLOBALS['imp_search']->sessionSetup(); 455 } 456 457 return $success; 458 } 459 460 /** 461 * Subscribes to one or more IMAP folders. 462 * 463 * @param array $folder_array An array of full utf encoded folder names 464 * to be subscribed. 465 * 466 * @return boolean Whether or not the folders were successfully 467 * subscribed to. 468 */ 469 function subscribe($folder_array) 470 { 471 global $conf, $notification; 472 473 $return_value = true; 474 $subscribed = array(); 475 476 if (!is_array($folder_array)) { 477 $notification->push(_("No folders were specified"), 'horde.warning'); 478 return false; 479 } 480 481 foreach ($folder_array as $folder) { 482 if ($folder != ' ') { 483 if (!imap_subscribe($_SESSION['imp']['stream'], IMP::serverString($folder))) { 484 $notification->push(sprintf(_("You were not subscribed to \"%s\". Here is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); 485 $return_value = false; 486 } else { 487 $notification->push(sprintf(_("You were successfully subscribed to \"%s\""), IMP::displayFolder($folder)), 'horde.success'); 488 $subscribed[] = $folder; 489 } 490 } 491 } 492 493 if (!empty($subscribed)) { 494 /* Initialize the IMAP_Tree object. */ 495 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 496 $imaptree = &IMP_Tree::singleton(); 497 if ($imaptree) { 498 $imaptree->subscribe($subscribed); 499 } 500 501 /* Reset the folder cache. */ 502 if ($conf['server']['cache_folders']) { 503 unset($_SESSION['imp']['cache']['folder_cache']); 504 } 505 } 506 507 return $return_value; 508 } 509 510 /** 511 * Unsubscribes from one or more IMAP folders. 512 * 513 * @param array $folder_array An array of full utf encoded folder names 514 * to be unsubscribed. 515 * 516 * @return boolean Whether or not the folders were successfully 517 * unsubscribed from. 518 */ 519 function unsubscribe($folder_array) 520 { 521 global $conf, $notification; 522 523 $return_value = true; 524 $unsubscribed = array(); 525 526 if (!is_array($folder_array)) { 527 $notification->push(_("No folders were specified"), 'horde.message'); 528 return false; 529 } 530 531 foreach ($folder_array as $folder) { 532 if ($folder != ' ') { 533 if (strcasecmp($folder, 'INBOX') == 0) { 534 $notification->push(sprintf(_("You cannot unsubscribe from \"%s\"."), IMP::displayFolder($folder)), 'horde.error'); 535 } elseif (!imap_unsubscribe($_SESSION['imp']['stream'], IMP::serverString($folder))) { 536 $notification->push(sprintf(_("You were not unsubscribed from \"%s\". Here is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); 537 $return_value = false; 538 } else { 539 $notification->push(sprintf(_("You were successfully unsubscribed from \"%s\""), IMP::displayFolder($folder)), 'horde.success'); 540 $unsubscribed[] = $folder; 541 } 542 } 543 } 544 545 if (!empty($unsubscribed)) { 546 /* Initialize the IMAP_Tree object. */ 547 require_once IMP_BASE . '/lib/IMAP/Tree.php'; 548 $imaptree = &IMP_Tree::singleton(); 549 if ($imaptree) { 550 $imaptree->unsubscribe($unsubscribed); 551 } 552 553 /* Reset the folder cache. */ 554 if ($conf['server']['cache_folders']) { 555 unset($_SESSION['imp']['cache']['folder_cache']); 556 } 557 } 558 559 return $return_value; 560 } 561 562 /** 563 * Generates a string that can be saved out to an mbox format mailbox file 564 * for a folder or set of folders, optionally including all subfolders of 565 * the selected folders as well. All folders will be put into the same 566 * string. 567 * 568 * @author Didi Rieder <adrieder@sbox.tugraz.at> 569 * 570 * @param array $folder_list A list of full utf encoded folder names to 571 * generate an mbox file for. 572 * @param boolean $recursive Include subfolders? 573 * 574 * @return string An mbox format mailbox file. 575 */ 576 function &generateMbox($folder_list, $recursive = false) 577 { 578 $body = ''; 579 580 if (is_array($folder_list)) { 581 require_once IMP_BASE . '/lib/IMAP.php'; 582 $imp_imap = &IMP_IMAP::singleton(); 583 foreach ($folder_list as $folder) { 584 $imp_imap->changeMbox($folder, OP_READONLY); 585 $count = imap_num_msg($_SESSION['imp']['stream']); 586 for ($i = 1; $i <= $count; $i++) { 587 $h = imap_header($_SESSION['imp']['stream'], $i); 588 $from = '<>'; 589 if (isset($h->from[0])) { 590 if (isset($h->from[0]->mailbox) && isset($h->from[0]->host)) { 591 $from = $h->from[0]->mailbox . '@' . $h->from[0]->host; 592 } 593 } 594 595 /* We need this long command since some MUAs (e.g. pine) 596 require a space in front of single digit days. */ 597 $date = sprintf('%s %2s %s', date('D M', $h->udate), date('j', $h->udate), date('H:i:s Y', $h->udate)); 598 $body .= 'From ' . $from . ' ' . $date . "\n"; 599 $body .= str_replace("\r\n", "\n", imap_fetchheader($_SESSION['imp']['stream'], $i, FT_PREFETCHTEXT)); 600 $body .= str_replace("\r\n", "\n", imap_body($_SESSION['imp']['stream'], $i, FT_PEEK) . "\n"); 601 } 602 } 603 } 604 605 return $body; 606 } 607 608 /** 609 * Imports messages into a given folder from a mbox format mailbox file. 610 * 611 * @param string $folder The folder to put the messages into. 612 * @param string $mbox String containing the mbox filename. 613 * 614 * @return mixed False (boolean) on fail or the number of messages 615 * imported (integer) on success. 616 */ 617 function importMbox($folder, $mbox) 618 { 619 $target = IMP::ServerString() . $folder; 620 621 $message = ''; 622 $msgcount = 0; 623 624 $fd = fopen($mbox, "r"); 625 while (!feof($fd)) { 626 $line = fgets($fd, 4096); 627 628 if (preg_match('/From (.+@.+|- )/A', $line)) { 629 if (!empty($message)) { 630 // Make absolutely sure there are no bare newlines. 631 $message = preg_replace("|([^\r])\n|", "\\1\r\n", $message); 632 $message = str_replace("\n\n", "\n\r\n", $message); 633 634 if (imap_append($_SESSION['imp']['stream'], $target, $message)) { 635 $msgcount++; 636 } 637 } 638 $message = ''; 639 } else { 640 $message .= $line; 641 } 642 } 643 fclose($fd); 644 645 if (!empty($message)) { 646 // Make absolutely sure there are no bare newlines. 647 $message = preg_replace("|([^\r])\n|", "\\1\r\n", $message); 648 $message = str_replace("\n\n", "\n\r\n", $message); 649 650 if (imap_append($_SESSION['imp']['stream'], $target, $message)) { 651 $msgcount++; 652 } 653 } 654 655 return ($msgcount > 0) ? $msgcount : false; 656 } 657 658 /** 659 * Get a list of all folders on the server (including any folders in 660 * hidden namespaces). 661 * 662 * @access private 663 * 664 * @param boolean $sub List only subscribed folders? 665 * 666 * @return array An array of folders names. 667 */ 668 function _listFolders($sub = false) 669 { 670 $list = array(); 671 $listcmd = ($sub) ? 'imap_lsub' : 'imap_list'; 672 $server = IMP::serverString(); 673 674 /* According to RFC 3501 [6.3.8], the '*' wildcard doesn't 675 * necessarily match all visible mailboxes. So we have to go 676 * through each namespace separately, even though we may duplicate 677 * mailboxes. */ 678 foreach ($_SESSION['imp']['namespace'] as $val) { 679 $hiddenboxes = $listcmd($_SESSION['imp']['stream'], $server, $val['name'] . '*'); 680 if (is_array($hiddenboxes)) { 681 $list = array_unique(array_merge($list, $hiddenboxes)); 682 } 683 } 684 685 return array_values($list); 686 } 687 688 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 12:30:07 2007 | par Balluche grâce à PHPXref 0.7 |
|