Changeset d08333e in github
- Timestamp:
- May 5, 2011 8:46:54 AM (2 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- de0a3f9
- Parents:
- 4764079
- Files:
-
- 15 edited
-
CHANGELOG (modified) (1 diff)
-
SQL/mssql.upgrade.sql (modified) (1 diff)
-
SQL/mysql.update.sql (modified) (1 diff)
-
SQL/postgres.update.sql (modified) (1 diff)
-
SQL/sqlite.update.sql (modified) (2 diffs)
-
UPGRADING (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
installer/config.php (modified) (4 diffs)
-
program/include/main.inc (modified) (3 diffs)
-
program/include/rcmail.php (modified) (2 diffs)
-
program/include/rcube_imap.php (modified) (62 diffs)
-
program/steps/mail/func.inc (modified) (1 diff)
-
program/steps/settings/edit_folder.inc (modified) (3 diffs)
-
program/steps/settings/folders.inc (modified) (5 diffs)
-
program/steps/settings/save_folder.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r4764079 rd08333e 2 2 =========================== 3 3 4 - Fix problems with subfolders of INBOX folder on some IMAP servers (#1487725) 5 - Fix handling of folders that doesn't belong to any namespace (#1487637) 4 6 - Fix bug where messages were deleted instead moved to trash folder after Shift key was used (#1487902) 5 7 - Enable multiselection for attachments uploading in capable browsers (#1485969) -
SQL/mssql.upgrade.sql
re6bb836 rd08333e 98 98 GO 99 99 100 -- Updates from version 0.5. 1100 -- Updates from version 0.5.2 101 101 102 102 ALTER TABLE [dbo].[contacts] ADD [words] [text] COLLATE Latin1_General_CI_AI NULL 103 103 GO 104 CREATE INDEX [IX_contactgroupmembers_contact_id] ON [dbo].[contactgroupmembers]([contact_id]) ON [PRIMARY]104 CREATE INDEX [IX_contactgroupmembers_contact_id] ON [dbo].[contactgroupmembers]([contact_id]) ON [PRIMARY] 105 105 GO 106 DELETE FROM [dbo].[messages] 107 GO 108 DELETE FROM [dbo].[cache] 109 GO -
SQL/mysql.update.sql
r09b0e36 rd08333e 134 134 TRUNCATE TABLE `messages`; 135 135 136 -- Updates from version 0.5. 1136 -- Updates from version 0.5.2 137 137 138 138 ALTER TABLE `contacts` ADD `words` TEXT NULL AFTER `vcard`; 139 139 ALTER TABLE `contacts` CHANGE `vcard` `vcard` LONGTEXT /*!40101 CHARACTER SET utf8 */ NULL DEFAULT NULL; 140 140 ALTER TABLE `contactgroupmembers` ADD INDEX `contactgroupmembers_contact_index` (`contact_id`); 141 142 TRUNCATE TABLE `messages`; 143 TRUNCATE TABLE `cache`; -
SQL/postgres.update.sql
r8381ec1 rd08333e 91 91 TRUNCATE messages; 92 92 93 -- Updates from version 0.5. 193 -- Updates from version 0.5.2 94 94 95 95 ALTER TABLE contacts ADD words TEXT NULL; 96 96 CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id); 97 98 TRUNCATE messages; 99 TRUNCATE cache; -
SQL/sqlite.update.sql
re6bb836 rd08333e 184 184 185 185 186 -- Updates from version 0.5. 1186 -- Updates from version 0.5.2 187 187 188 188 CREATE TABLE contacts_tmp ( … … 222 222 223 223 DELETE FROM messages; 224 DELETE FROM cache; 224 225 CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id); -
UPGRADING
r111a6fc3 rd08333e 49 49 1. Check .htaccess settings (some php settings could become required) 50 50 2. If you're using build-in addressbook, run indexing script /bin/indexcontacts.sh. 51 3. When upgrading from version older than 0.6-beta you should make sure 52 your folder settings contain namespace prefix. For example Courier users 53 should add INBOX. prefix to folder names in main configuration file. -
config/main.inc.php.dist
r4ae996c rd08333e 375 375 // store draft message is this mailbox 376 376 // leave blank if draft messages should not be stored 377 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP) 377 378 $rcmail_config['drafts_mbox'] = 'Drafts'; 378 379 379 380 // store spam messages in this mailbox 381 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP) 380 382 $rcmail_config['junk_mbox'] = 'Junk'; 381 383 382 384 // store sent message is this mailbox 383 385 // leave blank if sent messages should not be stored 386 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP) 384 387 $rcmail_config['sent_mbox'] = 'Sent'; 385 388 386 389 // move messages to this folder when deleting them 387 390 // leave blank if they should be deleted directly 391 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP) 388 392 $rcmail_config['trash_mbox'] = 'Trash'; 389 393 390 394 // display these folders separately in the mailbox list. 391 395 // these folders will also be displayed with localized names 396 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP) 392 397 $rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash'); 393 398 -
installer/config.php
re490642 rd08333e 362 362 <div>Store sent messages in this folder</div> 363 363 364 <p class="hint">Leave blank if sent messages should not be stored </p>364 <p class="hint">Leave blank if sent messages should not be stored. Note: folder must include namespace prefix if any.</p> 365 365 </dd> 366 366 … … 375 375 <div>Move messages to this folder when deleting them</div> 376 376 377 <p class="hint">Leave blank if they should be deleted directly </p>377 <p class="hint">Leave blank if they should be deleted directly. Note: folder must include namespace prefix if any.</p> 378 378 </dd> 379 379 … … 388 388 <div>Store draft messages in this folder</div> 389 389 390 <p class="hint">Leave blank if they should not be stored </p>390 <p class="hint">Leave blank if they should not be stored. Note: folder must include namespace prefix if any.</p> 391 391 </dd> 392 392 … … 400 400 ?> 401 401 <div>Store spam messages in this folder</div> 402 403 <p class="hint">Note: folder must include namespace prefix if any.</p> 404 </dd> 405 402 406 </dd> 403 407 </dl> -
program/include/main.inc
r2a38001 rd08333e 1229 1229 $list = $RCMAIL->imap->list_mailboxes(); 1230 1230 1231 foreach ($list as $folder) 1231 $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); 1232 1233 foreach ($list as $folder) { 1232 1234 if (empty($p['exceptions']) || !in_array($folder, $p['exceptions'])) 1233 rcmail_build_folder_tree($a_mailboxes, $folder, $RCMAIL->imap->get_hierarchy_delimiter()); 1235 rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter); 1236 } 1234 1237 1235 1238 $select = new html_select($p); 1236 1239 1237 1240 if ($p['noselection']) 1238 1241 $select->add($p['noselection'], ''); 1239 1242 1240 1243 rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames']); 1241 1244 1242 1245 return $select; 1243 1246 } … … 1252 1255 { 1253 1256 global $RCMAIL; 1257 1258 // Handle namespace prefix 1259 $prefix = ''; 1260 if (!$path) { 1261 $n_folder = $folder; 1262 $folder = $RCMAIL->imap->mod_mailbox($folder); 1263 1264 if ($n_folder != $folder) { 1265 $prefix = substr($n_folder, 0, -strlen($folder)); 1266 } 1267 } 1254 1268 1255 1269 $pos = strpos($folder, $delm); … … 1273 1287 } 1274 1288 1275 $path .= $currentFolder; 1276 1277 // Check \Noselect option (if options are in cache) 1278 if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) { 1279 $virtual = in_array('\\Noselect', $opts); 1280 } 1289 $path .= $prefix.$currentFolder; 1281 1290 1282 1291 if (!isset($arrFolders[$currentFolder])) { 1292 // Check \Noselect option (if options are in cache) 1293 if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) { 1294 $virtual = in_array('\\Noselect', $opts); 1295 } 1296 1283 1297 $arrFolders[$currentFolder] = array( 1284 1298 'id' => $path, -
program/include/rcmail.php
r63e9927 rd08333e 736 736 // user already registered -> update user's record 737 737 if (is_object($user)) { 738 // fix some old settings according to namespace prefix 739 $this->fix_namespace_settings($user); 740 738 741 // create default folders on first login 739 742 if (!$user->data['last_login'] && $config['create_default_folders']) 740 743 $this->imap->create_default_folders(); 744 // update last login timestamp 741 745 $user->touch(); 742 746 } … … 1454 1458 } 1455 1459 1460 /** 1461 * Fixes some user preferences according to namespace handling change. 1462 * Old Roundcube versions were using folder names with removed namespace prefix. 1463 * Now we need to add the prefix on servers where personal namespace has prefix. 1464 * 1465 * @param rcube_user $user User object 1466 */ 1467 private function fix_namespace_settings($user) 1468 { 1469 $prefix = $this->imap->get_namespace('prefix'); 1470 $prefix_len = strlen($prefix); 1471 1472 if (!$prefix_len) 1473 return; 1474 1475 $prefs = $user->get_prefs(); 1476 if (empty($prefs) || $prefs['namespace_fixed']) 1477 return; 1478 1479 // Build namespace prefix regexp 1480 $ns = $this->imap->get_namespace(); 1481 $regexp = array(); 1482 1483 foreach ($ns as $entry) { 1484 if (!empty($entry)) { 1485 foreach ($entry as $item) { 1486 if (strlen($item[0])) { 1487 $regexp[] = preg_quote($item[0], '/'); 1488 } 1489 } 1490 } 1491 } 1492 $regexp = '/^('. implode('|', $regexp).')/'; 1493 1494 // Fix preferences 1495 $opts = array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox', 'archive_mbox'); 1496 foreach ($opts as $opt) { 1497 if ($value = $prefs[$opt]) { 1498 if ($value != 'INBOX' && !preg_match($regexp, $value)) { 1499 $prefs[$opt] = $prefix.$value; 1500 } 1501 } 1502 } 1503 1504 if (!empty($prefs['default_imap_folders'])) { 1505 foreach ($prefs['default_imap_folders'] as $idx => $name) { 1506 if ($name != 'INBOX' && !preg_match($regexp, $name)) { 1507 $prefs['default_imap_folders'][$idx] = $prefix.$name; 1508 } 1509 } 1510 } 1511 1512 if (!empty($prefs['search_mods'])) { 1513 $folders = array(); 1514 foreach ($prefs['search_mods'] as $idx => $value) { 1515 if ($idx != 'INBOX' && $idx != '*' && !preg_match($regexp, $idx)) { 1516 $idx = $prefix.$idx; 1517 } 1518 $folders[$idx] = $value; 1519 } 1520 $prefs['search_mods'] = $folders; 1521 } 1522 1523 if (!empty($prefs['message_threading'])) { 1524 $folders = array(); 1525 foreach ($prefs['message_threading'] as $idx => $value) { 1526 if ($idx != 'INBOX' && !preg_match($regexp, $idx)) { 1527 $idx = $prefix.$idx; 1528 } 1529 $folders[$prefix.$idx] = $value; 1530 } 1531 $prefs['message_threading'] = $folders; 1532 } 1533 1534 if (!empty($prefs['collapsed_folders'])) { 1535 $folders = explode('&&', $prefs['collapsed_folders']); 1536 $count = count($folders); 1537 $folders_str = ''; 1538 1539 if ($count) { 1540 $folders[0] = substr($folders[0], 1); 1541 $folders[$count-1] = substr($folders[$count-1], 0, -1); 1542 } 1543 1544 foreach ($folders as $value) { 1545 if ($value != 'INBOX' && !preg_match($regexp, $value)) { 1546 $value = $prefix.$value; 1547 } 1548 $folders_str .= '&'.$value.'&'; 1549 } 1550 $prefs['collapsed_folders'] = $folders_str; 1551 } 1552 1553 $prefs['namespace_fixed'] = true; 1554 1555 // save updated preferences and reset imap settings (default folders) 1556 $user->save_prefs($prefs); 1557 $this->set_imap_prop(); 1558 } 1559 1456 1560 } -
program/include/rcube_imap.php
r8abc176 rd08333e 340 340 * All operations will be perfomed on this mailbox/folder 341 341 * 342 * @param string $ new_mbox Mailbox/Folder name342 * @param string $mailbox Mailbox/Folder name 343 343 * @access public 344 344 */ 345 function set_mailbox($new_mbox) 346 { 347 $mailbox = $this->mod_mailbox($new_mbox); 348 345 function set_mailbox($mailbox) 346 { 349 347 if ($this->mailbox == $mailbox) 350 348 return; … … 365 363 function select_mailbox($mailbox=null) 366 364 { 367 $mailbox = strlen($mailbox) ? $this->mod_mailbox($mailbox) : $this->mailbox; 365 if (!strlen($mailbox)) { 366 $mailbox = $this->mailbox; 367 } 368 368 369 369 $selected = $this->conn->select($mailbox); … … 452 452 function get_mailbox_name() 453 453 { 454 return $this->conn->connected() ? $this->m od_mailbox($this->mailbox, 'out'): '';454 return $this->conn->connected() ? $this->mailbox : ''; 455 455 } 456 456 … … 524 524 * Get namespace 525 525 * 526 * @param string $name Namespace array index: personal, other, shared, prefix 527 * 526 528 * @return array Namespace data 527 529 * @access public 528 530 */ 529 function get_namespace() 530 { 531 return $this->namespace; 531 function get_namespace($name=null) 532 { 533 $ns = $this->namespace; 534 535 if ($name) { 536 return isset($ns[$name]) ? $ns[$name] : null; 537 } 538 539 unset($ns['prefix']); 540 return $ns; 532 541 } 533 542 … … 610 619 } 611 620 621 // Find personal namespace prefix for mod_mailbox() 622 // Prefix can be removed when there is only one personal namespace 623 if (is_array($this->namespace['personal']) && count($this->namespace['personal']) == 1) { 624 $this->namespace['prefix'] = $this->namespace['personal'][0][0]; 625 } 626 612 627 $_SESSION['imap_namespace'] = $this->namespace; 613 628 $_SESSION['imap_delimiter'] = $this->delimiter; … … 618 633 * Get message count for a specific mailbox 619 634 * 620 * @param string $m box_nameMailbox/folder name621 * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT]622 * @param boolean $force Force reading from server and update cache623 * @param boolean $status Enables storing folder status info (max UID/count),624 * required for mailbox_status()635 * @param string $mailbox Mailbox/folder name 636 * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT] 637 * @param boolean $force Force reading from server and update cache 638 * @param boolean $status Enables storing folder status info (max UID/count), 639 * required for mailbox_status() 625 640 * @return int Number of messages 626 641 * @access public 627 642 */ 628 function messagecount($mbox_name='', $mode='ALL', $force=false, $status=true) 629 { 630 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 643 function messagecount($mailbox='', $mode='ALL', $force=false, $status=true) 644 { 645 if (!strlen($mailbox)) { 646 $mailbox = $this->mailbox; 647 } 648 631 649 return $this->_messagecount($mailbox, $mode, $force, $status); 632 650 } … … 645 663 * @see rcube_imap::messagecount() 646 664 */ 647 private function _messagecount($mailbox ='', $mode='ALL', $force=false, $status=true)665 private function _messagecount($mailbox, $mode='ALL', $force=false, $status=true) 648 666 { 649 667 $mode = strtoupper($mode); 650 651 if (!strlen($mailbox))652 $mailbox = $this->mailbox;653 668 654 669 // count search set … … 777 792 * convert mailbox name with root dir first 778 793 * 779 * @param string $m box_nameMailbox/folder name794 * @param string $mailbox Mailbox/folder name 780 795 * @param int $page Current page to list 781 796 * @param string $sort_field Header field to sort by … … 785 800 * @access public 786 801 */ 787 function list_headers($mbox_name='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) 788 { 789 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 802 function list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) 803 { 804 if (!strlen($mailbox)) { 805 $mailbox = $this->mailbox; 806 } 807 790 808 return $this->_list_headers($mailbox, $page, $sort_field, $sort_order, false, $slice); 791 809 } … … 1347 1365 * new messages because the RECENT flag is not reliable. 1348 1366 * 1349 * @param string $m box_nameMailbox/folder name1367 * @param string $mailbox Mailbox/folder name 1350 1368 * @return int Folder status 1351 1369 */ 1352 function mailbox_status($mbox_name = null) 1353 { 1354 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1370 function mailbox_status($mailbox = null) 1371 { 1372 if (!strlen($mailbox)) { 1373 $mailbox = $this->mailbox; 1374 } 1355 1375 $old = $this->get_folder_stats($mailbox); 1356 1376 … … 1379 1399 * @TODO: move to separate DB table (cache?) 1380 1400 * 1381 * @param string $m box_nameMailbox name1382 * @param string $name Data name1383 * @param mixed $data Data value1384 */ 1385 private function set_folder_stats($m box_name, $name, $data)1386 { 1387 $_SESSION['folders'][$m box_name][$name] = $data;1401 * @param string $mailbox Mailbox name 1402 * @param string $name Data name 1403 * @param mixed $data Data value 1404 */ 1405 private function set_folder_stats($mailbox, $name, $data) 1406 { 1407 $_SESSION['folders'][$mailbox][$name] = $data; 1388 1408 } 1389 1409 … … 1392 1412 * Gets folder statistic data 1393 1413 * 1394 * @param string $mbox_name Mailbox name 1414 * @param string $mailbox Mailbox name 1415 * 1395 1416 * @return array Stats data 1396 1417 */ 1397 private function get_folder_stats($m box_name)1398 { 1399 if ($_SESSION['folders'][$m box_name])1400 return (array) $_SESSION['folders'][$m box_name];1418 private function get_folder_stats($mailbox) 1419 { 1420 if ($_SESSION['folders'][$mailbox]) 1421 return (array) $_SESSION['folders'][$mailbox]; 1401 1422 else 1402 1423 return array(); … … 1407 1428 * Return sorted array of message IDs (not UIDs) 1408 1429 * 1409 * @param string $m box_nameMailbox to get index from1430 * @param string $mailbox Mailbox to get index from 1410 1431 * @param string $sort_field Sort column 1411 1432 * @param string $sort_order Sort order [ASC, DESC] 1412 1433 * @return array Indexed array with message IDs 1413 1434 */ 1414 function message_index($m box_name='', $sort_field=NULL, $sort_order=NULL)1435 function message_index($mailbox='', $sort_field=NULL, $sort_order=NULL) 1415 1436 { 1416 1437 if ($this->threading) 1417 return $this->thread_index($m box_name, $sort_field, $sort_order);1438 return $this->thread_index($mailbox, $sort_field, $sort_order); 1418 1439 1419 1440 $this->_set_sort_order($sort_field, $sort_order); 1420 1441 1421 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1442 if (!strlen($mailbox)) { 1443 $mailbox = $this->mailbox; 1444 } 1422 1445 $key = "{$mailbox}:{$this->sort_field}:{$this->sort_order}:{$this->search_string}.msgi"; 1423 1446 … … 1520 1543 * Return sorted array of threaded message IDs (not UIDs) 1521 1544 * 1522 * @param string $m box_nameMailbox to get index from1545 * @param string $mailbox Mailbox to get index from 1523 1546 * @param string $sort_field Sort column 1524 1547 * @param string $sort_order Sort order [ASC, DESC] 1525 1548 * @return array Indexed array with message IDs 1526 1549 */ 1527 function thread_index($m box_name='', $sort_field=NULL, $sort_order=NULL)1550 function thread_index($mailbox='', $sort_field=NULL, $sort_order=NULL) 1528 1551 { 1529 1552 $this->_set_sort_order($sort_field, $sort_order); 1530 1553 1531 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1554 if (!strlen($mailbox)) { 1555 $mailbox = $this->mailbox; 1556 } 1532 1557 $key = "{$mailbox}:{$this->sort_field}:{$this->sort_order}:{$this->search_string}.thi"; 1533 1558 … … 1694 1719 * Invoke search request to IMAP server 1695 1720 * 1696 * @param string $m box_nameMailbox name to search in1721 * @param string $mailbox Mailbox name to search in 1697 1722 * @param string $str Search criteria 1698 1723 * @param string $charset Search charset … … 1701 1726 * @access public 1702 1727 */ 1703 function search($m box_name='', $str=NULL, $charset=NULL, $sort_field=NULL)1728 function search($mailbox='', $str=NULL, $charset=NULL, $sort_field=NULL) 1704 1729 { 1705 1730 if (!$str) 1706 1731 return false; 1707 1732 1708 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1733 if (!strlen($mailbox)) { 1734 $mailbox = $this->mailbox; 1735 } 1709 1736 1710 1737 $results = $this->_search_index($mailbox, $str, $charset, $sort_field); … … 1800 1827 * without result sorting and caching 1801 1828 * 1802 * @param string $m box_nameMailbox name to search in1803 * @param string $str Search string1804 * @param boolean $ret_uid True if UIDs should be returned1829 * @param string $mailbox Mailbox name to search in 1830 * @param string $str Search string 1831 * @param boolean $ret_uid True if UIDs should be returned 1805 1832 * @return array Search results as list of message IDs or UIDs 1806 1833 * @access public 1807 1834 */ 1808 function search_once($m box_name='', $str=NULL, $ret_uid=false)1835 function search_once($mailbox='', $str=NULL, $ret_uid=false) 1809 1836 { 1810 1837 if (!$str) 1811 1838 return false; 1812 1839 1813 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1840 if (!strlen($mailbox)) { 1841 $mailbox = $this->mailbox; 1842 } 1814 1843 1815 1844 return $this->conn->search($mailbox, $str, $ret_uid); … … 1980 2009 * Return message headers object of a specific message 1981 2010 * 1982 * @param int $id Message ID1983 * @param string $m box_nameMailbox to read from1984 * @param boolean $is_uid True if $id is the message UID1985 * @param boolean $bodystr True if we need also BODYSTRUCTURE in headers2011 * @param int $id Message ID 2012 * @param string $mailbox Mailbox to read from 2013 * @param boolean $is_uid True if $id is the message UID 2014 * @param boolean $bodystr True if we need also BODYSTRUCTURE in headers 1986 2015 * @return object Message headers representation 1987 2016 */ 1988 function get_headers($id, $mbox_name=NULL, $is_uid=true, $bodystr=false) 1989 { 1990 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2017 function get_headers($id, $mailbox=null, $is_uid=true, $bodystr=false) 2018 { 2019 if (!strlen($mailbox)) { 2020 $mailbox = $this->mailbox; 2021 } 1991 2022 $uid = $is_uid ? $id : $this->_id2uid($id, $mailbox); 1992 2023 … … 2530 2561 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2531 2562 * @param string $flag Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT 2532 * @param string $m box_nameFolder name2563 * @param string $mailbox Folder name 2533 2564 * @param boolean $skip_cache True to skip message cache clean up 2565 * 2534 2566 * @return boolean Operation status 2535 2567 */ 2536 function set_flag($uids, $flag, $mbox_name=NULL, $skip_cache=false) 2537 { 2538 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2568 function set_flag($uids, $flag, $mailbox=null, $skip_cache=false) 2569 { 2570 if (!strlen($mailbox)) { 2571 $mailbox = $this->mailbox; 2572 } 2539 2573 2540 2574 $flag = strtoupper($flag); … … 2573 2607 * Remove message flag for one or several messages 2574 2608 * 2575 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2576 * @param string $flag Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT 2577 * @param string $mbox_name Folder name 2609 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2610 * @param string $flag Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT 2611 * @param string $mailbox Folder name 2612 * 2578 2613 * @return int Number of flagged messages, -1 on failure 2579 2614 * @see set_flag 2580 2615 */ 2581 function unset_flag($uids, $flag, $m box_name=NULL)2582 { 2583 return $this->set_flag($uids, 'UN'.$flag, $m box_name);2616 function unset_flag($uids, $flag, $mailbox=null) 2617 { 2618 return $this->set_flag($uids, 'UN'.$flag, $mailbox); 2584 2619 } 2585 2620 … … 2588 2623 * Append a mail message (source) to a specific mailbox 2589 2624 * 2590 * @param string $m box_nameTarget mailbox2591 * @param string $message The message source string or filename2592 * @param string $headers Headers string if $message contains only the body2593 * @param boolean $is_file True if $message is a filename2625 * @param string $mailbox Target mailbox 2626 * @param string $message The message source string or filename 2627 * @param string $headers Headers string if $message contains only the body 2628 * @param boolean $is_file True if $message is a filename 2594 2629 * 2595 2630 * @return boolean True on success, False on error 2596 2631 */ 2597 function save_message($mbox_name, &$message, $headers='', $is_file=false) 2598 { 2599 $mailbox = $this->mod_mailbox($mbox_name); 2632 function save_message($mailbox, &$message, $headers='', $is_file=false) 2633 { 2634 if (!strlen($mailbox)) { 2635 $mailbox = $this->mailbox; 2636 } 2600 2637 2601 2638 // make sure mailbox exists 2602 if ($this->mailbox_exists($m box_name)) {2639 if ($this->mailbox_exists($mailbox)) { 2603 2640 if ($is_file) 2604 2641 $saved = $this->conn->appendFromFile($mailbox, $message, $headers); … … 2626 2663 function move_message($uids, $to_mbox, $from_mbox='') 2627 2664 { 2628 $fbox = $from_mbox; 2629 $tbox = $to_mbox; 2630 $to_mbox = $this->mod_mailbox($to_mbox); 2631 $from_mbox = strlen($from_mbox) ? $this->mod_mailbox($from_mbox) : $this->mailbox; 2632 2633 if ($to_mbox === $from_mbox) 2665 if (!strlen($from_mbox)) { 2666 $from_mbox = $this->mailbox; 2667 } 2668 2669 if ($to_mbox === $from_mbox) { 2634 2670 return false; 2671 } 2635 2672 2636 2673 list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox); … … 2641 2678 2642 2679 // make sure mailbox exists 2643 if ($to_mbox != 'INBOX' && !$this->mailbox_exists($t box)) {2644 if (in_array($t box, $this->default_folders))2645 $this->create_mailbox($t box, true);2680 if ($to_mbox != 'INBOX' && !$this->mailbox_exists($to_mbox)) { 2681 if (in_array($to_mbox, $this->default_folders)) 2682 $this->create_mailbox($to_mbox, true); 2646 2683 else 2647 2684 return false; 2648 2685 } 2649 2686 2687 $config = rcmail::get_instance()->config; 2688 $to_trash = $to_mbox == $config->get('trash_mbox'); 2689 2650 2690 // flag messages as read before moving them 2651 $config = rcmail::get_instance()->config; 2652 if ($config->get('read_when_deleted') && $tbox == $config->get('trash_mbox')) { 2691 if ($to_trash && $config->get('read_when_deleted')) { 2653 2692 // don't flush cache (4th argument) 2654 $this->set_flag($uids, 'SEEN', $f box, true);2693 $this->set_flag($uids, 'SEEN', $from_mbox, true); 2655 2694 } 2656 2695 … … 2666 2705 } 2667 2706 // moving failed 2668 else if ($ config->get('delete_always', false) && $tbox == $config->get('trash_mbox')) {2669 $moved = $this->delete_message($uids, $f box);2707 else if ($to_trash && $config->get('delete_always', false)) { 2708 $moved = $this->delete_message($uids, $from_mbox); 2670 2709 } 2671 2710 … … 2709 2748 function copy_message($uids, $to_mbox, $from_mbox='') 2710 2749 { 2711 $fbox = $from_mbox; 2712 $tbox = $to_mbox; 2713 $to_mbox = $this->mod_mailbox($to_mbox); 2714 $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox; 2750 if (!strlen($from_mbox)) { 2751 $from_mbox = $this->mailbox; 2752 } 2715 2753 2716 2754 list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox); … … 2722 2760 2723 2761 // make sure mailbox exists 2724 if ($to_mbox != 'INBOX' && !$this->mailbox_exists($t box)) {2725 if (in_array($t box, $this->default_folders))2726 $this->create_mailbox($t box, true);2762 if ($to_mbox != 'INBOX' && !$this->mailbox_exists($to_mbox)) { 2763 if (in_array($to_mbox, $this->default_folders)) 2764 $this->create_mailbox($to_mbox, true); 2727 2765 else 2728 2766 return false; … … 2743 2781 * Mark messages as deleted and expunge mailbox 2744 2782 * 2745 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2746 * @param string $mbox_name Source mailbox 2783 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2784 * @param string $mailbox Source mailbox 2785 * 2747 2786 * @return boolean True on success, False on error 2748 2787 */ 2749 function delete_message($uids, $mbox_name='') 2750 { 2751 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2788 function delete_message($uids, $mailbox='') 2789 { 2790 if (!strlen($mailbox)) { 2791 $mailbox = $this->mailbox; 2792 } 2752 2793 2753 2794 list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox); … … 2797 2838 * Clear all messages in a specific mailbox 2798 2839 * 2799 * @param string $mbox_name Mailbox name 2840 * @param string $mailbox Mailbox name 2841 * 2800 2842 * @return int Above 0 on success 2801 2843 */ 2802 function clear_mailbox($mbox_name=NULL) 2803 { 2804 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2844 function clear_mailbox($mailbox=null) 2845 { 2846 if (!strlen($mailbox)) { 2847 $mailbox = $this->mailbox; 2848 } 2805 2849 2806 2850 // SELECT will set messages count for clearFolder() … … 2824 2868 * Send IMAP expunge command and clear cache 2825 2869 * 2826 * @param string $m box_nameMailbox name2870 * @param string $mailbox Mailbox name 2827 2871 * @param boolean $clear_cache False if cache should not be cleared 2872 * 2828 2873 * @return boolean True on success 2829 2874 */ 2830 function expunge($mbox_name='', $clear_cache=true) 2831 { 2832 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2875 function expunge($mailbox='', $clear_cache=true) 2876 { 2877 if (!strlen($mailbox)) { 2878 $mailbox = $this->mailbox; 2879 } 2880 2833 2881 return $this->_expunge($mailbox, $clear_cache); 2834 2882 } … … 2925 2973 * Translate UID to message ID 2926 2974 * 2927 * @param int $uid Message UID 2928 * @param string $mbox_name Mailbox name 2975 * @param int $uid Message UID 2976 * @param string $mailbox Mailbox name 2977 * 2929 2978 * @return int Message ID 2930 2979 */ 2931 function get_id($uid, $mbox_name=NULL) 2932 { 2933 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2980 function get_id($uid, $mailbox=null) 2981 { 2982 if (!strlen($mailbox)) { 2983 $mailbox = $this->mailbox; 2984 } 2985 2934 2986 return $this->_uid2id($uid, $mailbox); 2935 2987 } … … 2939 2991 * Translate message number to UID 2940 2992 * 2941 * @param int $id Message ID 2942 * @param string $mbox_name Mailbox name 2993 * @param int $id Message ID 2994 * @param string $mailbox Mailbox name 2995 * 2943 2996 * @return int Message UID 2944 2997 */ 2945 function get_uid($id, $mbox_name=NULL) 2946 { 2947 $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2998 function get_uid($id, $mailbox=null) 2999 { 3000 if (!strlen($mailbox)) { 3001 $mailbox = $this->mailbox; 3002 } 3003 2948 3004 return $this->_id2uid($id, $mailbox); 2949 3005 } … … 2958 3014 * Public method for listing subscribed folders 2959 3015 * 2960 * Converts mailbox name with root dir first2961 *2962 3016 * @param string $root Optional root folder 2963 3017 * @param string $filter Optional filter for mailbox listing 3018 * 2964 3019 * @return array List of mailboxes/folders 2965 3020 * @access public … … 2967 3022 function list_mailboxes($root='', $filter='*') 2968 3023 { 2969 $a_out = array();2970 3024 $a_mboxes = $this->_list_mailboxes($root, $filter); 2971 3025 2972 foreach ($a_mboxes as $idx => $mbox_row) {2973 if (strlen($name = $this->mod_mailbox($mbox_row, 'out')))2974 $a_out[] = $name;2975 unset($a_mboxes[$idx]);2976 }2977 2978 3026 // INBOX should always be available 2979 if (!in_array('INBOX', $a_ out))2980 array_unshift($a_ out, 'INBOX');3027 if (!in_array('INBOX', $a_mboxes)) 3028 array_unshift($a_mboxes, 'INBOX'); 2981 3029 2982 3030 // sort mailboxes 2983 $a_ out = $this->_sort_mailbox_list($a_out);2984 2985 return $a_ out;3031 $a_mboxes = $this->_sort_mailbox_list($a_mboxes); 3032 3033 return $a_mboxes; 2986 3034 } 2987 3035 … … 3018 3066 if (!$config->get('imap_force_lsub') && $this->get_capability('LIST-EXTENDED')) { 3019 3067 // This will also set mailbox options, LSUB doesn't do that 3020 $a_folders = $this->conn->listMailboxes($ this->mod_mailbox($root), $filter,3068 $a_folders = $this->conn->listMailboxes($root, $filter, 3021 3069 NULL, array('SUBSCRIBED')); 3022 3070 … … 3034 3082 // retrieve list of folders from IMAP server using LSUB 3035 3083 else { 3036 $a_folders = $this->conn->listSubscribed($ this->mod_mailbox($root), $filter);3084 $a_folders = $this->conn->listSubscribed($root, $filter); 3037 3085 } 3038 3086 } … … 3066 3114 else { 3067 3115 // retrieve list of folders from IMAP server 3068 $a_mboxes = $this->conn->listMailboxes($this->mod_mailbox($root), $filter); 3069 } 3070 3071 $a_folders = array(); 3072 if (!is_array($a_mboxes)) 3116 $a_mboxes = $this->conn->listMailboxes($root, $filter); 3117 } 3118 3119 if (!is_array($a_mboxes)) { 3073 3120 $a_mboxes = array(); 3074 3075 // modify names with root dir3076 foreach ($a_mboxes as $idx => $mbox_name) {3077 if (strlen($name = $this->mod_mailbox($mbox_name, 'out')))3078 $a_folders[] = $name;3079 unset($a_mboxes[$idx]);3080 3121 } 3081 3122 3082 3123 // INBOX should always be available 3083 if (!in_array('INBOX', $a_ folders))3084 array_unshift($a_ folders, 'INBOX');3124 if (!in_array('INBOX', $a_mboxes)) 3125 array_unshift($a_mboxes, 'INBOX'); 3085 3126 3086 3127 // filter folders and sort them 3087 $a_folders = $this->_sort_mailbox_list($a_folders); 3088 return $a_folders; 3128 $a_mboxes = $this->_sort_mailbox_list($a_mboxes); 3129 3130 return $a_mboxes; 3089 3131 } 3090 3132 … … 3108 3150 * Get mailbox size (size of all messages in a mailbox) 3109 3151 * 3110 * @param string $name Mailbox name 3152 * @param string $mailbox Mailbox name 3153 * 3111 3154 * @return int Mailbox size in bytes, False on error 3112 3155 */ 3113 function get_mailbox_size($name) 3114 { 3115 $name = $this->mod_mailbox($name); 3116 3156 function get_mailbox_size($mailbox) 3157 { 3117 3158 // @TODO: could we try to use QUOTA here? 3118 $result = $this->conn->fetchHeaderIndex($ name, '1:*', 'SIZE', false);3159 $result = $this->conn->fetchHeaderIndex($mailbox, '1:*', 'SIZE', false); 3119 3160 3120 3161 if (is_array($result)) … … 3160 3201 * Create a new mailbox on the server and register it in local cache 3161 3202 * 3162 * @param string $ nameNew mailbox name3203 * @param string $mailbox New mailbox name 3163 3204 * @param boolean $subscribe True if the new mailbox should be subscribed 3164 * @param boolean True on success 3165 */ 3166 function create_mailbox($name, $subscribe=false) 3167 { 3168 $result = false; 3169 $abs_name = $this->mod_mailbox($name); 3170 $result = $this->conn->createFolder($abs_name); 3205 * 3206 * @return boolean True on success 3207 */ 3208 function create_mailbox($mailbox, $subscribe=false) 3209 { 3210 $result = $this->conn->createFolder($mailbox); 3171 3211 3172 3212 // try to subscribe it 3173 3213 if ($result && $subscribe) 3174 $this->subscribe($ name);3214 $this->subscribe($mailbox); 3175 3215 3176 3216 return $result; … … 3181 3221 * Set a new name to an existing mailbox 3182 3222 * 3183 * @param string $m box_nameMailbox to rename3184 * @param string $new_name New mailbox name3223 * @param string $mailbox Mailbox to rename 3224 * @param string $new_name New mailbox name 3185 3225 * 3186 3226 * @return boolean True on success 3187 3227 */ 3188 function rename_mailbox($mbox_name, $new_name) 3189 { 3190 $result = false; 3191 3192 // make absolute path 3193 $mailbox = $this->mod_mailbox($mbox_name); 3194 $abs_name = $this->mod_mailbox($new_name); 3195 $delm = $this->get_hierarchy_delimiter(); 3228 function rename_mailbox($mailbox, $new_name) 3229 { 3230 if (!strlen($new_name)) { 3231 return false; 3232 } 3233 3234 $delm = $this->get_hierarchy_delimiter(); 3196 3235 3197 3236 // get list of subscribed folders 3198 3237 if ((strpos($mailbox, '%') === false) && (strpos($mailbox, '*') === false)) { 3199 $a_subscribed = $this->_list_mailboxes('', $m box_name. $delm . '*');3200 $subscribed = $this->mailbox_exists($m box_name, true);3238 $a_subscribed = $this->_list_mailboxes('', $mailbox . $delm . '*'); 3239 $subscribed = $this->mailbox_exists($mailbox, true); 3201 3240 } 3202 3241 else { … … 3205 3244 } 3206 3245 3207 if (strlen($abs_name)) 3208 $result = $this->conn->renameFolder($mailbox, $abs_name); 3246 $result = $this->conn->renameFolder($mailbox, $new_name); 3209 3247 3210 3248 if ($result) { … … 3212 3250 if ($subscribed) { 3213 3251 $this->conn->unsubscribe($mailbox); 3214 $this->conn->subscribe($ abs_name);3252 $this->conn->subscribe($new_name); 3215 3253 } 3216 3254 … … 3220 3258 $this->conn->unsubscribe($c_subscribed); 3221 3259 $this->conn->subscribe(preg_replace('/^'.preg_quote($mailbox, '/').'/', 3222 $ abs_name, $c_subscribed));3260 $new_name, $c_subscribed)); 3223 3261 } 3224 3262 } … … 3236 3274 * Remove mailbox from server 3237 3275 * 3238 * @param string $m box_nameMailbox name3276 * @param string $mailbox Mailbox name 3239 3277 * 3240 3278 * @return boolean True on success 3241 3279 */ 3242 function delete_mailbox($mbox_name) 3243 { 3244 $result = false; 3245 $mailbox = $this->mod_mailbox($mbox_name); 3246 $delm = $this->get_hierarchy_delimiter(); 3280 function delete_mailbox($mailbox) 3281 { 3282 $delm = $this->get_hierarchy_delimiter(); 3247 3283 3248 3284 // get list of folders … … 3295 3331 * Checks if folder exists and is subscribed 3296 3332 * 3297 * @param string $m box_nameFolder name3333 * @param string $mailbox Folder name 3298 3334 * @param boolean $subscription Enable subscription checking 3335 * 3299 3336 * @return boolean TRUE or FALSE 3300 3337 */ 3301 function mailbox_exists($m box_name, $subscription=false)3302 { 3303 if ($m box_name == 'INBOX')3338 function mailbox_exists($mailbox, $subscription=false) 3339 { 3340 if ($mailbox == 'INBOX') { 3304 3341 return true; 3342 } 3305 3343 3306 3344 $key = $subscription ? 'subscribed' : 'existing'; 3307 $mbox = $this->mod_mailbox($mbox_name); 3308 3309 if (is_array($this->icache[$key]) && in_array($mbox, $this->icache[$key])) 3345 3346 if (is_array($this->icache[$key]) && in_array($mailbox, $this->icache[$key])) 3310 3347 return true; 3311 3348 3312 3349 if ($subscription) { 3313 $a_folders = $this->conn->listSubscribed('', $m box);3350 $a_folders = $this->conn->listSubscribed('', $mailbox); 3314 3351 } 3315 3352 else { 3316 $a_folders = $this->conn->listMailboxes('', $m box);3317 } 3318 3319 if (is_array($a_folders) && in_array($m box, $a_folders)) {3320 $this->icache[$key][] = $m box;3353 $a_folders = $this->conn->listMailboxes('', $mailbox); 3354 } 3355 3356 if (is_array($a_folders) && in_array($mailbox, $a_folders)) { 3357 $this->icache[$key][] = $mailbox; 3321 3358 return true; 3322 3359 } … … 3329 3366 * Returns the namespace where the folder is in 3330 3367 * 3331 * @param string $m box_nameFolder name3368 * @param string $mailbox Folder name 3332 3369 * 3333 3370 * @return string One of 'personal', 'other' or 'shared' 3334 3371 * @access public 3335 3372 */ 3336 function mailbox_namespace($m box_name)3337 { 3338 if ($m box_name== 'INBOX') {3373 function mailbox_namespace($mailbox) 3374 { 3375 if ($mailbox == 'INBOX') { 3339 3376 return 'personal'; 3340 3377 } … … 3344 3381 foreach ($namespace as $ns) { 3345 3382 if (strlen($ns[0])) { 3346 if ((strlen($ns[0])>1 && $m box_name== substr($ns[0], 0, -1))3347 || strpos($m box_name, $ns[0]) === 03383 if ((strlen($ns[0])>1 && $mailbox == substr($ns[0], 0, -1)) 3384 || strpos($mailbox, $ns[0]) === 0 3348 3385 ) { 3349 3386 return $type; … … 3359 3396 3360 3397 /** 3361 * Modify folder name for input/output according to root dir and namespace 3362 * 3363 * @param string $mbox_name Folder name 3364 * @param string $mode Mode 3398 * Modify folder name according to namespace. 3399 * For output it removes prefix of the personal namespace if it's possible. 3400 * For input it adds the prefix. Use it before creating a folder in root 3401 * of the folders tree. 3402 * 3403 * @param string $mailbox Folder name 3404 * @param string $mode Mode name (out/in) 3405 * 3365 3406 * @return string Folder name 3366 3407 */ 3367 function mod_mailbox($mbox_name, $mode='in') 3368 { 3369 if (!strlen($mbox_name)) 3370 return ''; 3371 3372 if ($mode == 'in') { 3373 // If folder contains namespace prefix, don't modify it 3374 if (is_array($this->namespace['shared'])) { 3375 foreach ($this->namespace['shared'] as $ns) { 3376 if ($ns[0] && strpos($mbox_name, $ns[0]) === 0) { 3377 return $mbox_name; 3378 } 3379 } 3380 } 3381 if (is_array($this->namespace['other'])) { 3382 foreach ($this->namespace['other'] as $ns) { 3383 if ($ns[0] && strpos($mbox_name, $ns[0]) === 0) { 3384 return $mbox_name; 3385 } 3386 } 3387 } 3388 if (is_array($this->namespace['personal'])) { 3389 foreach ($this->namespace['personal'] as $ns) { 3390 if ($ns[0] && strpos($mbox_name, $ns[0]) === 0) { 3391 return $mbox_name; 3392 } 3393 } 3394 // Add prefix if first personal namespace is non-empty 3395 if ($mbox_name != 'INBOX' && $this->namespace['personal'][0][0]) { 3396 return $this->namespace['personal'][0][0].$mbox_name; 3397 } 3398 } 3399 } 3408 function mod_mailbox($mailbox, $mode = 'out') 3409 { 3410 if (!strlen($mailbox)) { 3411 return $mailbox; 3412 } 3413 3414 $prefix = $this->namespace['prefix']; // see set_env() 3415 $prefix_len = strlen($prefix); 3416 3417 if (!$prefix_len) { 3418 return $mailbox; 3419 } 3420 3421 // remove prefix for output 3422 if ($mode == 'out') { 3423 if (substr($mailbox, 0, $prefix_len) === $prefix) { 3424 return substr($mailbox, $prefix_len); 3425 } 3426 } 3427 // add prefix for input (e.g. folder creation) 3400 3428 else { 3401 // Remove prefix if folder is from first ("non-empty") personal namespace 3402 if (is_array($this->namespace['personal'])) { 3403 if ($prefix = $this->namespace['personal'][0][0]) { 3404 if (strpos($mbox_name, $prefix) === 0) { 3405 return substr($mbox_name, strlen($prefix)); 3406 } 3407 } 3408 } 3409 } 3410 3411 return $mbox_name; 3429 return $prefix . $mailbox; 3430 } 3431 3432 return $mailbox; 3412 3433 } 3413 3434 … … 3416 3437 * Gets folder options from LIST response, e.g. \Noselect, \Noinferiors 3417 3438 * 3418 * @param string $m box_nameFolder name3419 * @param bool $force Set to True if options should be refreshed3420 * Options are available after LIST command only3439 * @param string $mailbox Folder name 3440 * @param bool $force Set to True if options should be refreshed 3441 * Options are available after LIST command only 3421 3442 * 3422 3443 * @return array Options list 3423 3444 */ 3424 function mailbox_options($mbox_name, $force=false) 3425 { 3426 $mbox = $this->mod_mailbox($mbox_name); 3427 3428 if ($mbox == 'INBOX') { 3445 function mailbox_options($mailbox, $force=false) 3446 { 3447 if ($mailbox == 'INBOX') { 3429 3448 return array(); 3430 3449 } 3431 3450 3432 if (!is_array($this->conn->data['LIST']) || !is_array($this->conn->data['LIST'][$m box])) {3451 if (!is_array($this->conn->data['LIST']) || !is_array($this->conn->data['LIST'][$mailbox])) { 3433 3452 if ($force) { 3434 $this->conn->listMailboxes('', $m box_name);3453 $this->conn->listMailboxes('', $mailbox); 3435 3454 } 3436 3455 else { … … 3439 3458 } 3440 3459 3441 $opts = $this->conn->data['LIST'][$m box];3460 $opts = $this->conn->data['LIST'][$mailbox]; 3442 3461 3443 3462 return is_array($opts) ? $opts : array(); … … 3480 3499 function set_acl($mailbox, $user, $acl) 3481 3500 { 3482 $mailbox = $this->mod_mailbox($mailbox);3483 3484 3501 if ($this->get_capability('ACL')) 3485 3502 return $this->conn->setACL($mailbox, $user, $acl); … … 3504 3521 function delete_acl($mailbox, $user) 3505 3522 { 3506 $mailbox = $this->mod_mailbox($mailbox);3507 3508 3523 if ($this->get_capability('ACL')) 3509 3524 return $this->conn->deleteACL($mailbox, $user); … … 3524 3539 function get_acl($mailbox) 3525 3540 { 3526 $mailbox = $this->mod_mailbox($mailbox);3527 3528 3541 if ($this->get_capability('ACL')) 3529 3542 return $this->conn->getACL($mailbox); … … 3546 3559 function list_rights($mailbox, $user) 3547 3560 { 3548 $mailbox = $this->mod_mailbox($mailbox);3549 3550 3561 if ($this->get_capability('ACL')) 3551 3562 return $this->conn->listRights($mailbox, $user); … … 3567 3578 function my_rights($mailbox) 3568 3579 { 3569 $mailbox = $this->mod_mailbox($mailbox);3570 3571 3580 if ($this->get_capability('ACL')) 3572 3581 return $this->conn->myRights($mailbox); … … 3588 3597 function set_metadata($mailbox, $entries) 3589 3598 { 3590 if ($mailbox)3591 $mailbox = $this->mod_mailbox($mailbox);3592 3593 3599 if ($this->get_capability('METADATA') || 3594 3600 (!strlen($mailbox) && $this->get_capability('METADATA-SERVER')) … … 3621 3627 function delete_metadata($mailbox, $entries) 3622 3628 { 3623 if ($mailbox)3624 $mailbox = $this->mod_mailbox($mailbox);3625 3626 3629 if ($this->get_capability('METADATA') || 3627 3630 (!strlen($mailbox) && $this->get_capability('METADATA-SERVER')) … … 3655 3658 function get_metadata($mailbox, $entries, $options=array()) 3656 3659 { 3657 if ($mailbox)3658 $mailbox = $this->mod_mailbox($mailbox);3659 3660 3660 if ($this->get_capability('METADATA') || 3661 3661 !strlen(($mailbox) && $this->get_capability('METADATA-SERVER')) … … 4598 4598 4599 4599 /** 4600 * @param int $uid Message UID4601 * @param string $m box_nameMailbox name4600 * @param int $uid Message UID 4601 * @param string $mailbox Mailbox name 4602 4602 * @return int Message (sequence) ID 4603 4603 * @access private 4604 4604 */ 4605 private function _uid2id($uid, $mbox_name=NULL) 4606 { 4607 if (!strlen($mbox_name)) 4608 $mbox_name = $this->mailbox; 4609 4610 if (!isset($this->uid_id_map[$mbox_name][$uid])) { 4611 if (!($id = $this->get_cache_uid2id($mbox_name.'.msg', $uid))) 4612 $id = $this->conn->UID2ID($mbox_name, $uid); 4613 4614 $this->uid_id_map[$mbox_name][$uid] = $id; 4615 } 4616 4617 return $this->uid_id_map[$mbox_name][$uid]; 4618 } 4619 4620 4621 /** 4622 * @param int $id Message (sequence) ID 4623 * @param string $mbox_name Mailbox name 4605 private function _uid2id($uid, $mailbox=NULL) 4606 { 4607 if (!strlen($mailbox)) { 4608 $mailbox = $this->mailbox; 4609 } 4610 4611 if (!isset($this->uid_id_map[$mailbox][$uid])) { 4612 if (!($id = $this->get_cache_uid2id($mailbox.'.msg', $uid))) 4613 $id = $this->conn->UID2ID($mailbox, $uid); 4614 4615 $this->uid_id_map[$mailbox][$uid] = $id; 4616 } 4617 4618 return $this->uid_id_map[$mailbox][$uid]; 4619 } 4620 4621 4622 /** 4623 * @param int $id Message (sequence) ID 4624 * @param string $mailbox Mailbox name 4625 * 4624 4626 * @return int Message UID 4625 4627 * @access private 4626 4628 */ 4627 private function _id2uid($id, $mbox_name=NULL) 4628 { 4629 if (!strlen($mbox_name)) 4630 $mbox_name = $this->mailbox; 4631 4632 if ($uid = array_search($id, (array)$this->uid_id_map[$mbox_name])) 4629 private function _id2uid($id, $mailbox=null) 4630 { 4631 if (!strlen($mailbox)) { 4632 $mailbox = $this->mailbox; 4633 } 4634 4635 if ($uid = array_search($id, (array)$this->uid_id_map[$mailbox])) { 4633 4636 return $uid; 4634 4635 if (!($uid = $this->get_cache_id2uid($mbox_name.'.msg', $id))) 4636 $uid = $this->conn->ID2UID($mbox_name, $id); 4637 4638 $this->uid_id_map[$mbox_name][$uid] = $id; 4637 } 4638 4639 if (!($uid = $this->get_cache_id2uid($mailbox.'.msg', $id))) { 4640 $uid = $this->conn->ID2UID($mailbox, $id); 4641 } 4642 4643 $this->uid_id_map[$mailbox][$uid] = $id; 4639 4644 4640 4645 return $uid; … … 4651 4656 4652 4657 if (is_array($a_mboxes)) 4653 foreach ($a_mboxes as $i => $mbox_name) { 4654 $mailbox = $this->mod_mailbox($mbox_name); 4658 foreach ($a_mboxes as $i => $mailbox) { 4655 4659 $a_mboxes[$i] = $mailbox; 4656 4660 4657 if ($mode =='subscribe')4661 if ($mode == 'subscribe') 4658 4662 $updated = $this->conn->subscribe($mailbox); 4659 else if ($mode =='unsubscribe')4663 else if ($mode == 'unsubscribe') 4660 4664 $updated = $this->conn->unsubscribe($mailbox); 4661 4665 } … … 4668 4672 4669 4673 // modify cached list 4670 if ($mode =='subscribe')4674 if ($mode == 'subscribe') 4671 4675 $a_mailbox_cache = array_merge($a_mailbox_cache, $a_mboxes); 4672 else if ($mode =='unsubscribe')4676 else if ($mode == 'unsubscribe') 4673 4677 $a_mailbox_cache = array_diff($a_mailbox_cache, $a_mboxes); 4674 4678 … … 4685 4689 * @access private 4686 4690 */ 4687 private function _set_messagecount($mbox_name, $mode, $increment) 4688 { 4689 $a_mailbox_cache = false; 4690 $mailbox = strlen($mbox_name) ? $mbox_name : $this->mailbox; 4691 private function _set_messagecount($mailbox, $mode, $increment) 4692 { 4691 4693 $mode = strtoupper($mode); 4692 4693 4694 $a_mailbox_cache = $this->get_cache('messagecount'); 4694 4695 … … 4714 4715 * @access private 4715 4716 */ 4716 private function _clear_messagecount($mbox_name='', $mode=null) 4717 { 4718 $mailbox = strlen($mbox_name) ? $mbox_name : $this->mailbox; 4719 4717 private function _clear_messagecount($mailbox, $mode=null) 4718 { 4720 4719 $a_mailbox_cache = $this->get_cache('messagecount'); 4721 4720 -
program/steps/mail/func.inc
rc08b18c4 rd08333e 131 131 'copy', 'move', 'quota'); 132 132 133 $OUTPUT->set_pagetitle(rcmail_localize_foldername($ mbox_name));133 $OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->mod_mailbox($mbox_name))); 134 134 } 135 135 -
program/steps/settings/edit_folder.inc
rbbce3ed rd08333e 55 55 $options = array(); 56 56 $path = $parent_imap; 57 58 // allow creating subfolders of INBOX folder 59 if ($path == 'INBOX') { 60 $path = $RCMAIL->imap->mod_mailbox($path, 'in'); 61 } 62 } 63 64 // remove personal namespace prefix 65 if (strlen($path)) { 66 $path_id = $path; 67 $path = $RCMAIL->imap->mod_mailbox($path.$delimiter); 68 if ($path[strlen($path)-1] == $delimiter) { 69 $path = substr($path, 0, -1); 70 } 57 71 } 58 72 … … 94 108 95 109 if (strlen($path)) { 96 if ( $options['norename'] || $options['namespace'] != 'personal') {110 if (!empty($options) && ($options['norename'] || $options['namespace'] != 'personal')) { 97 111 // prevent user from moving folder 98 112 $hidden_path = new html_hiddenfield(array('name' => '_parent', 'value' => $path)); … … 101 115 else { 102 116 $radio1 = new html_radiobutton(array('name' => '_parent', 'value' => '')); 103 $radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path ));104 $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path ;117 $radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path_id)); 118 $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id; 105 119 106 120 $html_path = str_replace($delimiter, ' » ', rcmail_localize_folderpath($path)); -
program/steps/settings/folders.inc
rbbb1427 rd08333e 127 127 for ($x=sizeof($folderlist)-1; $x>=0; $x--) { 128 128 if (preg_match($regexp, $folderlist[$x])) { 129 $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]);130 $foldersplit = explode($delimiter, $ folderlist[$x]);131 $level = count($foldersplit) - 1;129 $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); 130 $foldersplit = explode($delimiter, $IMAP->mod_mailbox($folderlist[$x])); 131 $level = count($foldersplit) - 1; 132 132 $display_rename = str_repeat(' ', $level) 133 133 . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); 134 135 134 $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF7-IMAP') : false; 136 135 … … 140 139 } 141 140 141 $index = array_search($name, $folderlist); 142 $name = $IMAP->mod_mailbox($name); 142 143 $foldersplit = explode($delimiter, $name); 143 $level = count($foldersplit) - 1;144 $level = count($foldersplit) - 1; 144 145 $display_rename = str_repeat(' ', $level) . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); 145 $index = array_search($name, $folderlist); 146 $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; 147 148 $OUTPUT->command('replace_folder_row', $oldname_utf8, 149 rcube_charset_convert($name, 'UTF7-IMAP'), $display_rename, $before); 146 $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; 147 148 $OUTPUT->command('replace_folder_row', $oldname_utf8, $name_utf8, $display_rename, $before); 150 149 } 151 150 else if (!$rename) { … … 244 243 // pre-process folders list 245 244 foreach ($a_unsubscribed as $i => $folder) { 246 $foldersplit = explode($delimiter, $folder); 247 $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); 245 $folder_id = $folder; 246 $folder = $IMAP->mod_mailbox($folder); 247 $foldersplit = explode($delimiter, $folder); 248 $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); 248 249 $parent_folder = join($delimiter, $foldersplit); 249 $level = count($foldersplit);250 $level = count($foldersplit); 250 251 251 252 // add any necessary "virtual" parent folders 252 if ($parent_folder && ! $seen[$parent_folder]) {253 if ($parent_folder && !isset($seen[$parent_folder])) { 253 254 for ($i=1; $i<=$level; $i++) { 254 255 $ancestor_folder = join($delimiter, array_slice($foldersplit, 0, $i)); … … 264 265 } 265 266 } 266 267 268 // Handle properly INBOX.INBOX situation 269 if (isset($seen[$folder])) { 270 continue; 271 } 272 267 273 $seen[$folder]++; 268 274 269 275 $list_folders[] = array( 270 'id' => $folder ,276 'id' => $folder_id, 271 277 'name' => $name, 272 278 'level' => $level, … … 355 361 if ($key == $oldname) { 356 362 unset($a_threaded[$key]); 357 $a_threaded[$newname] = true;363 $a_threaded[$newname] = true; 358 364 } 359 365 else if (preg_match($oldprefix, $key)) { 360 366 unset($a_threaded[$key]); 361 $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true;367 $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true; 362 368 } 363 369 } -
program/steps/settings/save_folder.inc
rbbce3ed rd08333e 65 65 else if (strlen($path)) { 66 66 $name_imap = $path . $delimiter . $name_imap; 67 } 68 else { 69 $name_imap = $RCMAIL->imap->mod_mailbox($name, 'in'); 67 70 } 68 71
Note: See TracChangeset
for help on using the changeset viewer.
