[ Index ] |
|
Code source de IMP H3 (4.1.5) |
1 <?php 2 3 /* Constants used in copy(). */ 4 define('IMP_MESSAGE_MOVE', 1); 5 define('IMP_MESSAGE_COPY', 2); 6 7 /** 8 * The IMP_Message:: class contains all functions related to handling messages 9 * within IMP. Actions such as moving, copying, and deleting messages are 10 * handled in here so that code need not be repeated between mailbox, message, 11 * and other pages. 12 * 13 * Indices format: 14 * =============== 15 * For any function below that requires an $indices parameter, see 16 * IMP::parseIndicesList() for the list of allowable inputs. 17 * 18 * $Horde: imp/lib/Message.php,v 1.164.8.49 2007/07/03 14:56:26 slusarz Exp $ 19 * 20 * Copyright 2000-2007 Chris Hyde <chris@jeks.net> 21 * Copyright 2000-2007 Chuck Hagenbuch <chuck@horde.org> 22 * Copyright 2002-2007 Michael Slusarz <slusarz@bigworm.colorado.edu> 23 * 24 * See the enclosed file COPYING for license information (GPL). If you 25 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. 26 * 27 * @author Chris Hyde <chris@jeks.net> 28 * @author Chuck Hagenbuch <chuck@horde.org> 29 * @author Michael Slusarz <slusarz@bigworm.colorado.edu> 30 * @since IMP 2.3 31 * @package IMP 32 */ 33 class IMP_Message { 34 35 /** 36 * The IMP_IMAP object for the current server. 37 * 38 * @var IMP_IMAP 39 */ 40 var $_impImap; 41 42 /** 43 * Using POP to access mailboxes? 44 * 45 * @var boolean 46 */ 47 var $_usepop = false; 48 49 /** 50 * Returns a reference to the global IMP_Message object, only creating it 51 * if it doesn't already exist. This ensures that only one IMP_Message 52 * instance is instantiated for any given session. 53 * 54 * This method must be invoked as:<code> 55 * $imp_message = &IMP_Message::singleton(); 56 * </code> 57 * 58 * @return IMP_Message The IMP_Message instance. 59 */ 60 function &singleton() 61 { 62 static $message; 63 64 if (!isset($message)) { 65 $message = new IMP_Message(); 66 } 67 68 return $message; 69 } 70 71 /** 72 * Constructor. 73 */ 74 function IMP_Message() 75 { 76 if ($GLOBALS['imp']['base_protocol'] == 'pop3') { 77 $this->_usepop = true; 78 } 79 80 require_once IMP_BASE . '/lib/IMAP.php'; 81 $this->_impImap = &IMP_IMAP::singleton(); 82 } 83 84 /** 85 * Copies or moves a list of messages to a new folder. 86 * Handles use of the IMP_SEARCH_MBOX mailbox and the Trash folder. 87 * 88 * @param string $targetMbox The mailbox to move/copy messages to. 89 * @param integer $action Either IMP_MESSAGE_MOVE or IMP_MESSAGE_COPY. 90 * @param mixed &$indices See above. 91 * 92 * @return boolean True if successful, false if not. 93 */ 94 function copy($targetMbox, $action, &$indices) 95 { 96 global $imp, $notification, $prefs; 97 98 if (!($msgList = IMP::parseIndicesList($indices))) { 99 return false; 100 } 101 102 switch ($action) { 103 case IMP_MESSAGE_MOVE: 104 $imap_flags = CP_UID | CP_MOVE; 105 $message = _("There was an error moving messages from \"%s\" to \"%s\". This is what the server said"); 106 break; 107 108 case IMP_MESSAGE_COPY: 109 $imap_flags = CP_UID; 110 $message = _("There was an error copying messages from \"%s\" to \"%s\". This is what the server said"); 111 break; 112 } 113 114 $return_value = true; 115 116 foreach ($msgList as $folder => $msgIndices) { 117 $msgIdxString = implode(',', $msgIndices); 118 119 /* Switch folders, if necessary (only valid for IMAP). */ 120 $this->_impImap->changeMbox($folder); 121 122 /* Attempt to copy/move messages to new mailbox. */ 123 if (!@imap_mail_copy($imp['stream'], $msgIdxString, $targetMbox, $imap_flags)) { 124 $notification->push(sprintf($message, IMP::displayFolder($folder), IMP::displayFolder($targetMbox)) . ': ' . imap_last_error(), 'horde.error'); 125 $return_value = false; 126 } 127 128 /* If moving, and using the trash, expunge immediately. */ 129 if ($prefs->getValue('use_trash') && 130 ($action == IMP_MESSAGE_MOVE)) { 131 @imap_expunge($imp['stream']); 132 } 133 } 134 135 /* Update the mailbox. */ 136 if (is_a($indices, 'IMP_Mailbox')) { 137 if ($action == IMP_MESSAGE_COPY) { 138 $indices->updateMailbox(IMP_MAILBOX_COPY, $return_value); 139 } else { 140 $indices->updateMailbox(IMP_MAILBOX_MOVE, $return_value); 141 } 142 } 143 144 return $return_value; 145 } 146 147 /** 148 * Deletes a list of messages taking into account whether or not a 149 * Trash folder is being used. 150 * Handles use of the IMP_SEARCH_MBOX mailbox and the Trash folder. 151 * 152 * @param mixed &$indices See above. 153 * @param boolean $nuke Override user preferences and nuke (i.e. 154 * permanently delete) the messages instead? 155 * @param boolean $keeplog Should any history information of the 156 * message be kept? 157 * 158 * @return boolean True if successful, false if not. 159 */ 160 function delete(&$indices, $nuke = false, $keeplog = false) 161 { 162 global $conf, $imp, $notification, $prefs; 163 164 if (!($msgList = IMP::parseIndicesList($indices))) { 165 return false; 166 } 167 168 $trash = IMP::folderPref($prefs->getValue('trash_folder'), true); 169 $use_trash = $prefs->getValue('use_trash'); 170 if ($use_trash && !$trash) { 171 $notification->push(_("Can not move messages to Trash - no Trash mailbox set in preferences."), 'horde.error'); 172 return false; 173 } 174 175 $return_value = true; 176 $use_vtrash = $prefs->getValue('use_vtrash'); 177 $maillog_update = (!$keeplog && !empty($conf['maillog']['use_maillog'])); 178 179 /* If the folder we are deleting from has changed. */ 180 foreach ($msgList as $folder => $msgIndices) { 181 $sequence = implode(',', $msgIndices); 182 183 /* Switch folders, if necessary (only valid for IMAP). */ 184 $this->_impImap->changeMbox($folder); 185 186 /* Trash is only valid for IMAP mailboxes. */ 187 if (!$this->_usepop && 188 !$nuke && 189 !$use_vtrash && 190 $use_trash && 191 ($folder != $trash)) { 192 if (!isset($imp_folder)) { 193 include_once IMP_BASE . '/lib/Folder.php'; 194 $imp_folder = &IMP_Folder::singleton(); 195 } 196 197 if (!$imp_folder->exists($trash)) { 198 if (!$imp_folder->create($trash, $prefs->getValue('subscribe'))) { 199 return false; 200 } 201 } 202 203 if (!@imap_mail_move($imp['stream'], $sequence, $trash, CP_UID)) { 204 $error_msg = imap_last_error(); 205 $error = true; 206 207 /* Handle the case when the mailbox is overquota (moving 208 * message to trash would fail) by first deleting then 209 * copying message to Trash. */ 210 if ((stristr($error_msg, 'over quota') !== false) || 211 (stristr($error_msg, 'quota exceeded') !== false) || 212 (stristr($error_msg, 'exceeded your mail quota') !== false)) { 213 $error = false; 214 $msg_text = array(); 215 216 /* Get text of deleted messages. */ 217 foreach ($msgIndices as $val) { 218 $msg_text[] = imap_fetchheader($imp['stream'], $val, FT_UID | FT_PREFETCHTEXT) . imap_body($imp['stream'], $val, FT_UID); 219 } 220 @imap_delete($imp['stream'], $sequence, FT_UID); 221 @imap_expunge($imp['stream']); 222 223 /* Save messages in Trash folder. */ 224 foreach ($msg_text as $val) { 225 if (!@imap_append($imp['stream'], IMP::serverString($trash), $val)) { 226 $error = true; 227 break; 228 } 229 } 230 } 231 232 if ($error) { 233 $notification->push(sprintf(_("There was an error deleting messages from the folder \"%s\". This is what the server said"), IMP::displayFolder($folder)) . ': ' . $error_msg, 'horde.error'); 234 $return_value = false; 235 } 236 } else { 237 @imap_expunge($imp['stream']); 238 } 239 } else { 240 /* Get the list of Message-IDs for the deleted messages if 241 * using maillogging. */ 242 if ($maillog_update) { 243 $overview = @imap_fetch_overview($imp['stream'], $sequence, FT_UID); 244 } 245 246 /* Delete the messages. */ 247 if (!@imap_delete($imp['stream'], $sequence, FT_UID)) { 248 if ($this->_usepop) { 249 $notification->push(sprintf(_("There was an error deleting messages. This is what the server said: %s"), imap_last_error()), 'horde.error'); 250 } else { 251 $notification->push(sprintf(_("There was an error deleting messages from the folder \"%s\". This is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); 252 } 253 $return_value = false; 254 } else { 255 $delIndices = array($folder => $msgIndices); 256 $flag_str = '\\DELETED'; 257 258 if ($this->_usepop || 259 $nuke || 260 ($use_trash && ($folder == $trash))) { 261 /* Purge messages in the trash folder immediately. */ 262 $this->flag($flag_str, $delIndices); 263 @imap_expunge($imp['stream']); 264 } else { 265 /* If we are using vitrual trash, we must mark the 266 * message as seen or else it will appear as an 267 * 'unseen' message for purposes of new message 268 * counts. */ 269 if ($use_vtrash) { 270 $this->flag($flag_str . ' \\SEEN', $delIndices); 271 } 272 } 273 274 /* Get the list of Message-IDs deleted, and remove 275 * the information from the mail log. */ 276 if ($maillog_update) { 277 $msg_ids = array(); 278 foreach ($overview as $val) { 279 if (!empty($val->message_id)) { 280 $msg_ids[] = $val->message_id; 281 } 282 } 283 require_once IMP_BASE . '/lib/Maillog.php'; 284 IMP_Maillog::deleteLog($msg_ids); 285 } 286 } 287 } 288 } 289 290 /* Update the mailbox. */ 291 if (is_a($indices, 'IMP_Mailbox')) { 292 $indices->updateMailbox(IMP_MAILBOX_DELETE, $return_value); 293 } 294 295 return $return_value; 296 } 297 298 /** 299 * Undeletes a list of messages. 300 * Handles the IMP_SEARCH_MBOX mailbox. 301 * This function works with IMAP only, not POP3. 302 * 303 * @param mixed &$indices See above. 304 * 305 * @return boolean True if successful, false if not. 306 */ 307 function undelete(&$indices) 308 { 309 global $imp, $notification; 310 311 if (!($msgList = IMP::parseIndicesList($indices))) { 312 return false; 313 } 314 315 $return_value = true; 316 317 foreach ($msgList as $folder => $msgIndices) { 318 $msgIdxString = implode(',', $msgIndices); 319 320 /* Switch folders, if necessary. */ 321 $this->_impImap->changeMbox($folder); 322 323 if ($imp['stream'] && 324 !@imap_undelete($imp['stream'], $msgIdxString, FT_UID)) { 325 $notification->push(sprintf(_("There was an error deleting messages in the folder \"%s\". This is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); 326 $return_value = false; 327 } 328 } 329 330 /* Update the mailbox. */ 331 if (is_a($indices, 'IMP_Mailbox')) { 332 $indices->updateMailbox(IMP_MAILBOX_UNDELETE, $return_value); 333 } 334 335 return $return_value; 336 } 337 338 /** 339 * Copies or moves a list of messages to a tasklist or notepad. 340 * Handles use of the IMP_SEARCH_MBOX mailbox and the Trash folder. 341 * 342 * @param string $list The list in which the task or note will be 343 * created. 344 * @param integer $action Either IMP_MESSAGE_MOVE or IMP_MESSAGE_COPY. 345 * @param mixed $indices See above. 346 * @param string $type The object type to create, defaults to task. 347 * 348 * @return boolean True if successful, false if not. 349 */ 350 function createTasksOrNotes($list, $action, &$indices, $type = 'task') 351 { 352 global $registry, $notification, $prefs; 353 354 if (!($msgList = IMP::parseIndicesList($indices))) { 355 return false; 356 } 357 358 require_once IMP_BASE . '/lib/Compose.php'; 359 require_once IMP_BASE . '/lib/MIME/Contents.php'; 360 require_once IMP_BASE . '/lib/MIME/Headers.php'; 361 require_once 'Text/Flowed.php'; 362 require_once 'Horde/iCalendar.php'; 363 364 foreach ($msgList as $folder => $msgIndices) { 365 foreach ($msgIndices as $index) { 366 /* Fetch the message headers. */ 367 $imp_headers = &new IMP_Headers($index); 368 $imp_headers->buildHeaders(); 369 $subject = $imp_headers->getValue('subject'); 370 371 /* Fetch the message contents. */ 372 $imp_contents = &IMP_Contents::singleton($index . IMP_IDX_SEP . $folder); 373 $imp_contents->buildMessage(); 374 375 /* Extract the message body. */ 376 $imp_compose = &new IMP_Compose(); 377 $mime_message = $imp_contents->getMIMEMessage(); 378 $body_id = $imp_compose->getBodyId($imp_contents); 379 $body = $imp_compose->findBody($imp_contents); 380 381 /* Re-flow the message for prettier formatting. */ 382 $flowed = &new Text_Flowed($mime_message->replaceEOL($body, "\n")); 383 if (($mime_message->getContentTypeParameter('delsp') == 'yes') && 384 method_exists($flowed, 'setDelSp')) { 385 $flowed->setDelSp(true); 386 } 387 $body = $flowed->toFlowed(false); 388 389 /* Convert to current charset */ 390 /* TODO: When Horde_iCalendar supports setting of charsets 391 * we need to set it there instead of relying on the fact 392 * that both Nag and IMP use the same charset. */ 393 $body_part = $mime_message->getPart($body_id); 394 $body = String::convertCharset($body, $body_part->getCharset(), NLS::getCharset()); 395 396 /* Create a new iCalendar. */ 397 $vCal = &new Horde_iCalendar(); 398 $vCal->setAttribute('PRODID', '-//The Horde Project//IMP ' . IMP_VERSION . '//EN'); 399 $vCal->setAttribute('METHOD', 'PUBLISH'); 400 401 switch ($type) { 402 case 'task': 403 /* Create a new vTodo object using this message's 404 * contents. */ 405 $vTodo = &Horde_iCalendar::newComponent('vtodo', $vCal); 406 $vTodo->setAttribute('SUMMARY', $subject); 407 $vTodo->setAttribute('DESCRIPTION', $body); 408 $vTodo->setAttribute('PRIORITY', '3'); 409 410 /* Get the list of editable tasklists. */ 411 $lists = $registry->call('tasks/listTasklists', 412 array(false, PERMS_EDIT)); 413 414 /* Attempt to add the new vTodo item to the requested 415 * tasklist. */ 416 $res = $registry->call('tasks/import', 417 array($vTodo, 'text/x-vtodo', $list)); 418 break; 419 420 case 'note': 421 /* Create a new vNote object using this message's 422 * contents. */ 423 $vNote = &Horde_iCalendar::newComponent('vnote', $vCal); 424 $vNote->setAttribute('BODY', $subject . "\n". $body); 425 426 /* Get the list of editable notepads. */ 427 $lists = $registry->call('notes/listNotepads', 428 array(false, PERMS_EDIT)); 429 430 /* Attempt to add the new vNote item to the requested 431 * notepad. */ 432 $res = $registry->call('notes/import', 433 array($vNote, 'text/x-vnote', $list)); 434 break; 435 } 436 437 if (is_a($res, 'PEAR_Error')) { 438 $notification->push($res, $res->getCode()); 439 } elseif (!$res) { 440 switch ($type) { 441 case 'task': $notification->push(_("An unknown error occured while creating the new task."), 'horde.error'); break; 442 case 'note': $notification->push(_("An unknown error occured while creating the new note."), 'horde.error'); break; 443 } 444 } else { 445 $name = '"' . htmlspecialchars($subject) . '"'; 446 447 /* Attempt to convert the object name into a hyperlink. */ 448 switch ($type) { 449 case 'task': 450 $link = $registry->link('tasks/show', 451 array('uid' => $res)); 452 break; 453 case 'note': 454 if ($registry->hasMethod('notes/show')) { 455 $link = $registry->link('notes/show', 456 array('uid' => $res)); 457 } else { 458 $link = false; 459 } 460 break; 461 } 462 if ($link && !is_a($link, 'PEAR_Error')) { 463 $name = sprintf('<a href="%s">%s</a>', 464 Horde::url($link), 465 $name); 466 } 467 468 $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw')); 469 } 470 } 471 } 472 473 /* Delete the original messages if this is a "move" operation. */ 474 if ($action == IMP_MESSAGE_MOVE) { 475 $this->delete($indices); 476 } 477 478 return true; 479 } 480 481 /** 482 * Strips a MIME Part out of a message. 483 * Handles the IMP_SEARCH_MBOX mailbox. 484 * 485 * @param IMP_Mailbox &$imp_mailbox The IMP_Mailbox object with the 486 * current index set to the message to be 487 * processed. 488 * @param string $partid The MIME ID of the part to strip. 489 * 490 * @return boolean Returns true on success, or PEAR_Error on error. 491 */ 492 function stripPart(&$imp_mailbox, $partid) 493 { 494 global $imp; 495 496 /* Return error if no index was provided. */ 497 if (!($msgList = IMP::parseIndicesList($imp_mailbox))) { 498 return PEAR::raiseError('No index provided to IMP_Message::stripPart().'); 499 } 500 501 /* If more than one index provided, return error. */ 502 reset($msgList); 503 list($folder, $index) = each($msgList); 504 if (each($msgList) || (count($index) > 1)) { 505 return PEAR::raiseError('More than 1 index provided to IMP_Message::stripPart().'); 506 } 507 $index = implode('', $index); 508 509 require_once 'Horde/MIME/Part.php'; 510 require_once IMP_BASE . '/lib/MIME/Contents.php'; 511 require_once IMP_BASE . '/lib/MIME/Headers.php'; 512 513 /* Get a local copy of the message and strip out the desired 514 MIME_Part object. */ 515 $contents = &IMP_Contents::singleton($index . IMP_IDX_SEP . $folder); 516 $contents->rebuildMessage(); 517 $message = $contents->getMIMEMessage(); 518 $oldPart = $message->getPart($partid); 519 $newPart = new MIME_Part('text/plain'); 520 521 /* We need to make sure all text is in the correct charset. */ 522 $newPart->setCharset(NLS::getCharset()); 523 $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $oldPart->getType(), $oldPart->getName(true, true)), '8bit'); 524 $message->alterPart($partid, $newPart); 525 526 /* We need to make sure we add "\r\n" after every line for 527 imap_append() - some servers require it (e.g. Cyrus). */ 528 $message->setEOL(MIME_PART_RFC_EOL); 529 530 /* Get the headers for the message. */ 531 $headers = &new IMP_Headers($index); 532 $headers->buildFlags(); 533 $flags = array(); 534 foreach (array('answered', 'deleted', 'draft', 'flagged', 'seen') as $flag) { 535 if ($headers->getFlag($flag)) { 536 $flags[] = '\\' . $flag; 537 } 538 } 539 $flags = implode(' ', $flags); 540 541 /* This is a (sort-of) hack. Right before we append the new message 542 we check imap_status() to determine the next available UID. We 543 use this UID as the new index of the message. */ 544 $folderstring = IMP::serverString($folder); 545 $headerstring = $headers->getHeaderText(); 546 $this->_impImap->changeMbox($folder); 547 $status = @imap_status($imp['stream'], $folderstring, SA_UIDNEXT); 548 if (@imap_append($imp['stream'], $folderstring, $headerstring . $contents->toString($message, true), $flags)) { 549 $this->delete($imp_mailbox, true, true); 550 $imp_mailbox->updateMailbox(IMP_MAILBOX_UPDATE); 551 $imp_mailbox->setNewIndex($status->uidnext); 552 553 /* We need to replace the old index in the query string with the 554 new index. */ 555 $_SERVER['QUERY_STRING'] = preg_replace('/' . $index . '/', $status->uidnext, $_SERVER['QUERY_STRING']); 556 557 return true; 558 } else { 559 return PEAR::raiseError(_("An error occured while attempting to strip the attachment. The IMAP server said: ") . imap_last_error()); 560 } 561 } 562 563 /** 564 * Sets or clears a given flag for a list of messages. 565 * Handles use of the IMP_SEARCH_MBOX mailbox. 566 * This function works with IMAP only, not POP3. 567 * 568 * Valid flags are: 569 * \\SEEN 570 * \\FLAGGED 571 * \\ANSWERED 572 * \\DELETED 573 * \\DRAFT 574 * 575 * @param string $flag The IMAP flag(s) to set or clear. 576 * @param mixed &$indices See above. 577 * @param boolean $action If true, set the flag(s), otherwise clear the 578 * flag(s). 579 * 580 * @return boolean True if successful, false if not. 581 */ 582 function flag($flag, &$indices, $action = true) 583 { 584 if (!($msgList = IMP::parseIndicesList($indices))) { 585 return false; 586 } 587 588 $function = ($action) ? 'imap_setflag_full' : 'imap_clearflag_full'; 589 $return_value = true; 590 591 foreach ($msgList as $folder => $msgIndices) { 592 $msgIdxString = implode(',', $msgIndices); 593 594 /* Switch folders, if necessary. */ 595 $this->_impImap->changeMbox($folder); 596 597 /* Flag/unflag the messages now. */ 598 if (!call_user_func($function, $GLOBALS['imp']['stream'], $msgIdxString, $flag, ST_UID)) { 599 $GLOBALS['notification']->push(sprintf(_("There was an error flagging messages in the folder \"%s\". This is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); 600 $return_value = false; 601 } 602 } 603 604 return $return_value; 605 } 606 607 /** 608 * Sets or clears a given flag(s) for all messages in a list of mailboxes. 609 * This function works with IMAP only, not POP3. 610 * 611 * See flag() for the list of valid flags. 612 * 613 * @param string $flag The IMAP flag(s) to set or clear. 614 * @param array $mboxes The list of mailboxes to flag. 615 * @param boolean $action If true, set the flag(s), otherwise, clear the 616 * flag(s). 617 * 618 * @return boolean True if successful, false if not. 619 */ 620 function flagAllInMailbox($flag, $mboxes, $action = true) 621 { 622 if (empty($mboxes) || !is_array($mboxes)) { 623 return false; 624 } 625 626 $return_value = true; 627 628 foreach ($mboxes as $val) { 629 /* Switch folders, if necessary. */ 630 $this->_impImap->changeMbox($val); 631 if ($uids = @imap_search($GLOBALS['imp']['stream'], 'ALL', SE_UID)) { 632 $indices = array($val => $uids); 633 if (!$this->flag($flag, $indices, $action)) { 634 $return_value = false; 635 } 636 } 637 } 638 639 return $return_value; 640 } 641 642 /** 643 * Expunges all deleted messages from the list of mailboxes. 644 * 645 * @param array $mbox_list The list of mailboxes to empty. 646 */ 647 function expungeMailbox($mbox_list) 648 { 649 global $imp; 650 651 foreach ($mbox_list as $val) { 652 if ($GLOBALS['imp_search']->isSearchMbox($val)) { 653 foreach ($GLOBALS['imp_search']->getSearchFolders($val) as $folder) { 654 $stream = $this->_impImap->openIMAPStream($folder); 655 @imap_expunge($stream); 656 @imap_close($stream); 657 } 658 } else { 659 $this->_impImap->changeMbox($val); 660 @imap_expunge($imp['stream']); 661 } 662 } 663 } 664 665 /** 666 * Empties an entire mailbox. 667 * 668 * @param array $mbox_list The list of mailboxes to empty. 669 */ 670 function emptyMailbox($mbox_list) 671 { 672 global $imp, $notification; 673 674 foreach ($mbox_list as $mbox) { 675 if ($GLOBALS['imp_search']->isVTrashFolder($mbox)) { 676 $this->expungeMailbox($GLOBALS['imp_search']->getSearchFolders($mbox)); 677 $notification->push(_("Emptied all messages from Virtual Trash Folder."), 'horde.success'); 678 continue; 679 } 680 681 $display_mbox = IMP::displayFolder($mbox); 682 683 if (($this->_impImap->changeMbox($mbox)) !== true) { 684 $notification->push(sprintf(_("Could not delete messages from %s. The server said: %s"), $display_mbox, imap_last_error()), 'horde.error'); 685 continue; 686 } 687 688 /* Make sure there is at least 1 message before attempting to 689 delete. */ 690 $delete_array = array($mbox => array('1:*')); 691 if (!@imap_num_msg($imp['stream'])) { 692 $notification->push(sprintf(_("The mailbox %s is already empty."), $display_mbox), 'horde.message'); 693 } elseif (!$this->delete($delete_array, true)) { 694 $notification->push(sprintf(_("There was a problem expunging the mailbox. The server said: %s"), imap_last_error()), 'horde.error'); 695 continue; 696 } else { 697 @imap_expunge($imp['stream']); 698 $notification->push(sprintf(_("Emptied all messages from %s."), $display_mbox), 'horde.success'); 699 } 700 } 701 } 702 703 }
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 |
![]() |