Page MenuHomePhorge

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/CHANGELOG b/CHANGELOG
index 2b86f3da6..a5b68a7e6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,1438 +1,1444 @@
CHANGELOG RoundCube Webmail
---------------------------
+2008/09/12 (alec)
+----------
+- Added vertical splitter for folders list resizing
+- Added possibility to view all headers in message view
+- Fixed splitter drag/resize on Opera (#1485170)
+
2008/09/12 (thomasb)
----------
- Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)
- Insert "virtual" folders in subscription list (#1484779)
2008/09/05 (thomasb)
----------
- Enable export of address book contacts as vCard
- Respect Content-Location headers in multipart/related messages according to RFC2110 (#1484946)
- Applied mime_decode patch by David Lublink
- Allowed max. attachment size now indicated in compose screen (#1485030)
- Also capture backspace key in list mode (#1484566)
- Allow application/pgp parts to be displayed (#1484753)
- Correctly handle options in mailto-links (#1485228)
- Immediately save sort_col/sort_order in user prefs (#1485265)
2008/09/04 (alec)
----------
- Truncate very long (above 50 characters) attachment filenames when displaying
- Support \" and \\ in quoted strings when parsing BODYSTRUCTURE (mime.inc)
- Allow 'readonly' atributes in input and textarea (#1485312)
2008/09/03 (thomasb)
----------
- Allow to auto-detect client language if none set (#1484434)
- Auto-detect the client timezone (user configurable)
2008/09/03 (alec)
----------
- Add RFC2231 header value continuations support for attachment
filenames + hack for servers that not support that feature
- Fix Reply-To header displaying (#1485314)
2008/09/02 (thomasb)
----------
- Add feature to import contacts from vcard files (#1326103)
- Mark form buttons that provide the most obvious operation (mainaction)
2008/08/30 (alec)
----------
- Improved HTML to TXT conversion by html2text class update
to version 1.0.0
2008/08/28 (alec)
----------
- Added option 'quota_zero_as_unlimited' (#1484604)
- Added PRE handling in html2text class (#1484740)
2008/08/28 (robin)
----------
- Added folder hierarchy collapsing
2008/08/27 (alec)
----------
- Added options to use syslog instead of log file (#1484850)
- Added Logging & Debugging section in Installer
- Write to smtp log also sent MDN confirmations
2008/08/26 (alec)
----------
- Removed support for PEAR::DB driver
2008/08/21 (alec)
----------
- Add Content-Length header while attachments downloading (#1484256)
- Fix In-Reply-To and References headers when composing saved draft
message (#1485288)
- Removed PHP4 class constructors
- Fix html message charset conversion for charsets with underline (#1485287)
- Fix buttons status after contacts deletion (#1485233)
2008/08/21 (estadtherr)
----------
- Fix escaping of To: and From: fields when building message body for reply
or forward in the HTML editor (#1484904)
2008/08/15 (thomasb)
----------
- Use current mailbox name in template (#1485256)
- Better fix for skipping untagged responses (#1485261)
- Added pspell support patch by Kris Steinhoff (#1483960)
- Enable spellchecker for HTML editor (#1485114)
- Respect spellcheck_uri in tinyMCE spellchecker (#1484196)
2008/08/09 (alec)
----------
- Case insensitive contacts searching using PostgreSQL (#1485259)
2008/07/31 (thomasb)
----------
- Make default imap folders configurable for each user (#1485075)
- Save outgoing mail to selectable folder (#1324581)
- Fix hiding of mark menu when clicking th button again (#1484944)
2008/07/21 (alec)
----------
- use long date format in print mode (#1485191)
2008/07/18 (alec)
----------
- Updated TinyMCE to version 3.1.0.1
2008/07/14 (thomasb)
----------
- Re-enable autocomplete attribute for login form (#1485211)
- Check PERMANENTFLAGS before saving $MDNSent flag (#1484963, #1485163)
2008/06/30 (alec)
----------
- Added flag column on messages list (#1484623)
2008/06/24 (alec)
----------
- Patched Mail/MimePart.php (http://pear.php.net/bugs/bug.php?id=14232)
2008/06/24 (alec)
----------
- Allow trash/junk subfolders to be purged (#1485085)
2008/06/20 (alec)
----------
- Added Azerbaijani translation
2008/06/20 (thomasb)
----------
- Store compose parameters in session and redirect to a unique URL
2008/06/18 (thomasb)
----------
- Fixed CRAM-MD5 authentication (#1484819)
- Add fallback to old 'skin_path' property
2008/06/16 (alec)
----------
- Fixed sending emoticons
- Fixed forwarding messages with one HTML attachment (#1484442)
- Fixed encoding of message/rfc822 attachments and image/pjpeg handling (#1484914)
2008/06/15 (alec)
----------
- Added option to select skin in user preferences
WARNING: option 'skin_path' replaced by 'skin' option!
2008/06/14 (alec)
----------
- Added option to disable displaying of attached images below the message body
2008/06/13 (alec)
----------
- Added option to display images in messages from known senders (#1484601)
- Updated PEAR::Mail_Mime
- User preferences grouped in more fieldsets
2008/06/12 (alec)
----------
- Fix corrupted MIME headers of messages in Sent folder (#1485111)
- Fixed bug in MDB2 package: http://pear.php.net/bugs/bug.php?id=14124
- Use keypress instead of keydown to select list's row (#1484816)
2008/06/11 (alec)
----------
- Don't call expunge and don't remove message row after message move
if flag_for_deletion is set to true (#1485002)
2008/06/08 (alec)
----------
- Added option to disable autocompletion from selected LDAP address books (#1484922)
2008/06/07 (thomasb)
----------
- Cleaned up localization names. Now named with lang_COUNTRY according to ISO 639-1/3166-1
- Updated Catalan localization
2008/06/06 (robin)
----------
- Add option to log successful logins
2008/06/06 (alec)
----------
- TLS support in LDAP connections: 'use_tls' property (#1485104)
2008/06/05 (alec)
----------
- Fix removing messages from search set after deleting them (#1485106)
2008/06/03 (alec)
----------
- imap.inc: Fixed iil_MultLine(): use iil_ReadBytes() instead of iil_ReadLine()
- imap.inc: Fixed iil_C_FetchStructureString() to handle many
literal strings in response (#1484969)
- imap.inc: Removed hardcoded data size in iil_ReadLine()
2008/05/30 (alec)
----------
- Support for subfolders in default/protected folders (#1484665)
- Disallowed delimiter in folder name (#1484803)
- Support " and \ in folder names
- Escape \ in login (#1484614)
2008/05/29 (thomasb)
----------
- Better HTML sanitization with the DOM-based washtml script (#1484701)
2008/05/29 (alec)
----------
- Polish localization folder renamed to pl_PL
2008/05/28 (alec)
----------
- Fixed sorting of folders with non-ascii characters
2008/05/21 (alec)
----------
- Localized pagetitle in Settings and Address Book
2008/05/19 (alec)
----------
- Fixed Mysql DDL for default identities creation (#1485070)
2008/05/16 (alec)
----------
- In Preferences added possibility to configure 'read_when_deleted',
'mdn_requests', 'flag_for_deletion' options
2008/05/15 (thomasb)
----------
- Make IMAP auth type configurable (#1483825)
- Fix empty values with FROM_UNIXTIME() in rcube_mdb2 (#1485055)
2008/05/15 (alec)
----------
- Fix attachment list on IE 6/7 (#1484807)
2008/05/12 (estadtherr)
----------
- fix JavaScript in compose.html that shows cc/bcc fields if populated
2008/05/12 (alec)
----------
- Updated PEAR::DB package to version 1.7.13
2008/05/10 (alec)
----------
- Make password input fields of type password in installer (#1484886)
2008/05/09 (alec)
----------
- Don't call CAPABILITY if was recieved as server's optional response
on connect (RFC3501 [7.1])
2008/05/08 (alec)
----------
- Don't attempt to delete cache entries if enable_caching is FALSE (#1485051)
- Optimized messages sorting on servers without sort capability (#1485049)
- Option 'use_SQL_address_book' replaced by 'address_book_type'
- Corrected message headers decoding when charset isn't specified and improved
support for native languages (#1485050, #1485048)
2008/05/07 (davidke/richs)
----------
- Completed LDAP address book support so it can now write to an LDAP server.
- Expanded LDAP configuration options to support LDAP server writes.
- Modified config/main.inc.php.dist:
New Option: $rcmail_config['use_SQL_address_book']
Changed Option: $rcmail_config['ldap_public']['Verisign']
2008/05/05 (alec)
----------
- Installer: encode special characters in DB username/password (#1485042)
- Do charset conversion also for from/to column on messages list
- Fix management of folders with national characters in names (#1485036, #1485001)
2008/05/02 (alec)
----------
- Updated MDB2 package to version 2.5.0b1
- Updated MDB2 pgsql, mysql, mysqli, sqlite drivers to version 1.5.0b1
- Updated MDB2 mssql driver to version 1.3.0b1
- Fixed identities saving when using MDB2 pgsql driver (#1485032)
2008/05/01 (alec)
----------
- Fix BCC header reset (#1484997)
2008/04/30 (thomasb)
----------
- Introduce new application class 'rcmail' and get rid of some global vars
2008/04/29 (alec)
----------
- improved messages list performance - patch from Justin Heesemann
2008/04/23 (alec)
----------
- Append skin_path to images location only when it starts
with '/' sign (#1484859)
2008/04/20 (estadtherr)
----------
- fix parse_attrib_string to handle unquoted values, which fixes
display issues with HTML messages that do not quote attributes
2008/04/17 (alec)
----------
- Fix IMAP response in message body when message has no body (#1484964)
- Updated PEAR::Auth_SASL to 1.0.2
- Fix non-RFC dates formatting (#1484901)
2008/04/16 (estadtherr)
----------
- Fix mail sending with new TinyMCE
2008/04/16 (alec)
----------
- Fix typo in set_charset() (#1484991)
- Decode entities when inserting HTML signature to plain text message (#1484990)
2008/04/15 (estadtherr)
----------
- HTML editing is now working with PHP5 updates and TinyMCE v3.0.6
- fix signature loading on Windows (#1484545)
- add language support to HTML editing (#1484862)
2008/04/15 (alec)
----------
- Fix remove signature when replying (#1333167)
- Fix problem with line with a space at the end (#1484916)
- Don't send set_env() in ajax response when env array is empty
- Fix <!DOCTYPE> tag filtering (#1484391)
- Fix <?xml> tag filtering (#1484403)
2008/04/14 (alec)
----------
- Added sections (fieldset+label) in Settings interface
2008/04/12 (alec)
----------
- Fixed and optimized 'read_when_deleted': mark as read on server side
in one action when marking as deleted, fixed js bugs when deleting
from message preview page
2008/04/12 (thomasb)
----------
- Changed codebase to PHP5 with autoloader
- Added some new classes from devel-vnext branch
2008/04/11 (alec)
----------
- Mark as read in one action with message preview (#1484972)
- Delete redundant quota reads (#1484972)
- Add options for empty trash and expunge inbox on logout (#1483863)
2008/04/10 (alec)
----------
- Add rows highlighting in onmousemove on ksearch list
- Remove lines wrapping when displaying message
- Fix month localization
- Do ob_start/ob_end_clean when reading config files (#1484624)
- Fix debug (ajax) console
2008/04/02 (alec)
----------
- Updated timezones list (#1484908)
- Fix design in Settings (#1484799)
- Fix deleting messages after clicking on "All" (#1484838)
- Fix sorting o0f message list when default folder is empty (#1484317)
- Fix creating a new folder w/a comma in its name (#1484681)
2008/04/01 (thomasb)
----------
- Fix Enter problem on login (#1484839)
- Make the http-received header in outgoing mails configurable
2008/03/30 (till)
----------
- Fix Firefox problem with ob_gzhandler (#1484932)
- Improve message previewpane - less loading (#1484316)
2008/03/28 (thomasb)
----------
- Disable installer by default; add config option to enable it again
2008/03/24 (till)
----------
- Don't send mark requests for already marked messages (#1484906)
- Fix "quote inside a quote" (#1484783)
2008/03/23 (till)
- Applied patch to strip newlines from headers (#1484811)
- Applied patch to trim login (#1484231)
- Added robots.txt
- Fix attachment problem when restoring saved draft without body (#1484506)
- Fix call to undefined function decrypt_passwd()
2008/03/21 (thomasb)
----------
- Add configurable default charset for message decoding
- Applied patch to fix mime decoding an folder subscription (#1484191)
- Applied patch to correctly quote email recipient strings (#1484191)
- Fix wrong charset aliases (#1484818 and #1484598)
- Remove hard-coded size of logo image (#1484378)
- Strip slashes from virtuser email values (#1484700)
- Fixed message part window display in IE6 (#1484610)
2008/02/28 (thomasb)
----------
- Fix folder adding/renaming inspired by #1484800
- Applied patch by Emanuele Rocca to make LDAP filters work with or without brackets
- Fix quirky message selection
- Completed installer
2008/02/20 (thomasb)
----------
- Localize folder name in page title (#1484785)
- Fix code using wrong variable name (#1484018)
- Allow to send mail with BCC recipients only
- Remove MDN headers before saving in sent folder
2008/02/12 (estadtherr)
----------
- fix switching between HTML/plain composing (#1484752)
- condense TinyMCE toolbar down to one line, removing table buttons (#1484747)
- fix image removal in message display when message HTML includes JS event handlers
2008/02/11 (thomasb)
----------
- Add function to mark the selected messages as read/unread (#1457360)
- Also do charset decoding as suggested in RFC 2231 (fix #1484321)
- Show message count in folder list and hint when creating a subfolder
2008/02/08 (thomasb)
----------
- Distinguish ssl and tls for imap connections (#1484667)
- Added some charset aliases to fix typical mis-labelling (#1484565)
2008/02/07 (thomasb)
----------
- Remember decision to display images for a certain message during session (#1484754)
- Truncate attachment filenames to 55 characters due to an IE bug (#1484757)
- Fix size of the attachment preview frame (#1484758)
2008/02/05 (thomasb)
----------
- Fix regular expression for checking e-mail address (#1484710)
- Make sending of read receipts configurable
- Respect config when localize folder names (#1484707)
- Applied patch for updating page title (#1484727, #1484650)
- Applied patch to prevent from purging inbox by uberlinuxguy (#1484449)
- Applied patch to prevent bad header delimiters (#1484751)
- Also send search request when deleting a contact (#1484620)
- Add CSS hack for Safari
2008/02/02 (thomasb)
----------
- Always update $CONFIG with user prefs (#1484729)
- Don't ask for MDN confirmations on drafted messages (#1484691)
- Also respect receipt and priority settings when re-opening a draft message
2008/01/31 (robin)
----------
- Remember search results (closes #1483883), patch by the_glu
2008/01/08 (tomekp)
----------
- add he (Hebrew) localization (#1484713)
2008/01/08 (tomekp)
----------
- update fr localization
2008/01/04 (tomekp)
- purge kur_KU because it has no messages translation
- bump copyright for all localization files
2007/12/31 (tomekp)
----------
- update es localization
2007/12/28 (tomekp)
----------
- update mk localization
2007/12/27 (tomekp)
----------
- update se localization
2007/12/13 (robin)
----------
- Add Received header on outgoing mail
2007/12/10 (estadtherr)
----------
- Upgrade to TinyMCE 2.1.3
- Allow inserting image attachments into HTML messages while composing (#1484557)
2007/12/10 (thomasb)
----------
- Delegate user-stuff to new class rcube_user
- Implement Message-Disposition-Notification (Receipts)
2007/12/05 (tomekp)
----------
- update bg, uk localization
2007/12/04 (tomekp)
----------
- update bg localization
2007/11/25 (thomasb)
----------
- Applied UID fetch patch by Glen Ogilvie
- Applied patch for correct Postgres instructions from ticket #1484674
- Fix overriding of session vars when register_globals is on (#1484670)
- Fix wrong Postgres setup instructions in INSTALL (#1484674)
- Fix bug with case-sensitive folder names (#1484245)
- Don't create default folders by default
- Added Georgian localization by Zaza Zviadadze
- Updated Russian localization
- Fixed some potential security risks (audited by Andris)
- Only show new messages if they match the current search (#1484176)
2007/11/20 (tomekp)
----------
- add Korean (kr) localization
2007/11/14 (tomekp)
----------
- update id_ID localization
2007/11/06 (thomasb)
----------
- Switch to/from when searcing in Sent folder (#1484555)
- Correctly read the References header (#1484646)
- Unset old cookie in before sending a new value (#1484639)
- Correctly decode attachments when downloading them (#1484645 and #1484642)
2007/10/22 (tomekp)
----------
- update ru, eo localizations
2007/10/17 (thomasb)
----------
- Make message listing less error prone
2007/10/10 (thomasb)
----------
- Suppress IE errors when clearing attachments form (#1484356)
- Set preferences field in user table to NULL (#1484386)
- Log error when login fails due to auto_create_user turned off
- Update UPGRADING instructions
2007/10/05 (tomekp)
----------
- Add Esperanto localization
2007/10/04 (Stiwi)
----------
- Updated German localization
2007/10/04 (yllar)
----------
- Added Malay localization
- Updated Lithuanian localization
2007/09/27 (tomekp)
----------
- Update dutch localization (closes #1484588)
2007/09/29 (thomasb)
----------
- Filter linked/imported CSS files (closes #1484056)
2007/09/27 (tomekp)
----------
- Update brazilian portuguese localization (#1484580)
2007/09/26 (thomasb)
----------
- Improve message compose screen (closes #1484383)
- Select next row after removing one from list (#1484387)
2007/09/26 (tomekp)
----------
- Add polish labels for changes in r816.
- Update polish localization (#1484579)
- Update thai localization (#1484578)
2007/09/25 (robin)
----------
- Enable drag-/dropping of folders to a new parent folder (#1457344)
2007/09/24 (robin)
----------
- Fix preview pane size for Safari & Konqueror (#1484187)
2007/09/20 (robin)
----------
- Make smtp HELO/EHLO hostname configurable (#1484067)
2007/09/19 (thomasb)
----------
- IPv6 Compatability (#1484322), Patch #1484373
- Unlock interface when message sending fails (#1484570)
- Eval PHP code in template includes (if configured)
- Show message when folder is empty. Mo more static text in table (#1484395)
- Only display unread count in page title when new messages arrived
- Show mailbox name in page title
2007/09/09 (thomasb)
----------
- Fixed wrong delete button tooltip (#1483965)
- Fixed charset encoding bug (#1484429)
- Applied patch for LDAP version (#1484552)
- Improved XHTML validation
2007/09/05 (thomasb)
----------
- Fix message list selection (#1484550)
- Better fix lowercased usernames (#1484473)
- Update pngbehavior Script as suggested in #1484490
2007/08/29 (richs)
----------
- Fixed moving/deleting messages when more than 1 is selected
2007/08/15 (thomasb)
----------
- Applied patch for LDAP contacts listing by Glen Ogilvie
- Applied patch for more address fields in LDAP contacts (#1484402)
- Close LDAP connections on script shutdown
2007/08/13 (thomasb)
----------
- Add alternative for getallheaders() (fix #1484508)
- Revert changes for mbstring usage (fix #1484509)
2007/08/10 (thomasb)
----------
- Identify mailboxes case-sensitive
- Sort mailbox list case-insensitive (closes #1484338)
- Fix display of multipart messages from Apple Mail (closes #1484027)
- Protect AJAX request from being fetched by a foreign site (XSS)
- Make autocomplete for loginform configurable by the skin template
- Fix compose function from address book (closes #1484426)
- Added //IGNORE to iconv call (patch #1484420, closes #1484023)
- Check if mbstring supports charset (#1484290 and #1484292)
- Prefer iconv over mbstring (as suggested in #1484292)
- Check filesize of template includes (#1484409)
- Updated Simplified Chinese localization
- Added Ukrainian translation
2007/08/09 (richs)
----------
- Fixed bug with buttons not dimming/enabling properly after switching folders
- Fixed compose window becoming unresponsive after saving a draft (#1484487)
- Re-enabled "Back" button in compose window now that bug #1484487 is fixed
- Fixed unresponsive interface issue when downloading attachments (#1484496)
- Lowered status message time from 5 to 3 seconds to improve responsiveness
- Added note to INSTALL about .htaccess limiting upload_max_filesize
- Raised .htaccess upload_max_filesize from 2M to 5M to differ from default php.ini
- Increased "mailboxcontrols" mail.css width from 160 to 170px to fix non-english languages (#1484499)
- Fixed empty-message sending with TinyMCE plain-text mode, or if it's not installed
2007/07/03 (thomasb)
----------
- Added Macedonian (Slavic FYROM) localization
- Fix status message bug #1484464 with regard to #1484353
- Fix address adding bug reported by David Koblas
- Applied socket error patch by Thomas Mangin
2007/06/28 (tomekp)
----------
- fix typos in Polish localization (Janusz Zamecki)
2007/06/27 (tomekp)
----------
- Update Polish (Janusz Zamecki), Croatian (Svebor Prstacic) localization
2007/06/12 (thomasb)
----------
- Updated Turkish, Polish, Finnish/Suomi, Japanese, Hungarian, Greek, Euskara localization
- Added Irish/Gaelic translation
- Little correction in Swedish translation
- Quote username for virtuser_query
- Pass-by-reference workarround for PHP5 in sendmail.inc
2007/06/04 (estadtherr)
----------
- Fixed bug in HTML->Plain editor toggling
2007/05/28 (thomasb)
---------
- Fixed buggy imap_root settings (closes #1484379)
- Prevent default events on subject links (#1484399)
- Typo in rcube_smtp.inc
2007/05/23 (estadtherr)
----------
- Upgrade to TinyMCE v2.1.1.1
2007/05/18 (thomasb)
----------
- Use HTTP-POST requests for actions that change state
2007/05/17 (thomasb)
----------
- Updated Catalan, Russian, Portuguese, Slovak and Chinese translations
- Renamed localization folder for Chinese (Big5)
- Chanegd Slovenian language code from 'si' to 'sl'
- Added Sinhala (Sri-Lanka) localization
- Use global filters and bind username/ for Ldap searches (#1484159)
- Hide quota display if imap server does not support it
- Hide address groups if no LDAP servers configured
- Add link to message subjects (closes #1484257)
- Better SQL query for contact listing/search (closes #1484369)
2007/05/13 (thomasb)
----------
- Updated Norwegian (bokmal), Czech, Danish and Portuguese (standard) translation
- Fixed marking as read in preview pane (closes #1484364)
- CSS hack to display attachments correctly in IE6
- Wrap message body text (closes #1484148)
2007/05/03 (yllar)
----------
- Updated French, Lithuanian, Armenian, Spanish and Italian translations
2007/05/01 (thomasb)
----------
- Updated German, Euskara, Hungarian, Romanian and Spanish translation
- Added Hindi and Kurdish localization
2007/04/28 (thomasb)
----------
- LDAP access is back in address book (closes #1484087)
- Added search function for contacts
- New Template parsing and output encoding
- Fixed bugs #1484119 and #1483978
2007/04/08 (thomasb)
----------
- Fixed message moving procedure (closes #1484308)
- Fixed display of multiple attachments (closes #1466563)
- Fixed check for new messages (closes #1484310)
- List attachments without filename
2007/03/27 (thomasb)
----------
- New session authentication: Change sessid cookie when login, authentication with sessauth cookie is now configurable.
Should close bugs #1483951 and #1484299
2007/03/23 (thomasb)
----------
- Correctly translate mailbox names (closes #1484276)
- Quote e-mail address links (closes #1484300)
2007/03/21 (thomasb)
----------
- Updated PEAR::Mail_mime package
- Added Persian localization
- Updated Catalan and Brazilian Portuguese translations
- Updated INSTALL manual with a note about database passwords
- Accept single quotes for HTML attributes when modifying message body (thanks Jason)
- Sanitize input for new users/identities (thanks Colin Alston)
2007/03/19 (thomasb)
----------
- Don't download HTML message parts
- Convert HTML parts to plaintext if 'prefer_html' is off
- Correctly parse message/rfc822 parts (closes #1484045)
- Code cleanup
2007/03/18 (thomasb)
----------
- Also use user_id for unique key in messages table (closes #1484074)
- Hide contacts drop down on blur (closes #1484203)
- Make entries in contacts drop down clickable
- Turn off browser autocompletion on login page
- Quote <? in text/html message parts
- Hide border around radio buttons
- Replaced old JS function calls.
2007/03/13 (thomasb)
----------
- Applied patch for attachment download by crichardson (closes #1484198)
- Fixed bug in Postgres DB handling (closes #1484068)
- Fixed bug of invalid calls to fetchRow() in rcube_db.inc (closes #1484280)
- Fixed array_merge bug (closes #1484281)
- Fixed flag for deletion in list view (closes #1484264)
- Finally support semicolons as recipient separator (closes ##1484251)
- Fixed message headers (subject) encoding
2007/03/04 (tomekp)
----------
- check if safe mode is on or not (closes #1484269)
2007/03/02 (thomasb)
----------
- Show "no subject" in message list if subject is missing (closes #1484243)
- Solved page caching of message preview (closes #1484153)
- Only use gzip compression if configured (closes #1484236)
2007/02/25 (estadtherr)
----------
- Fixed priority selector issue (#1484150)
- Upgraded to TinyMCE v2.1.0
2007/02/21 (thomasb)
----------
- Fixed some CSS issues in default skin (closes #1484210 and #1484161)
- Prevent from double quoting of numeric HTML character references (closes #1484253)
2007/02/07 (tomekp)
----------
- Updated (bg) translation (Doichin Dokov)
2007/02/06 (tomekp)
----------
- Updated (pl) translation
- Updated (pt_BR) translation (Robson F. Ramaldes)
- Big cleanup in program/localization
2007/02/05 (thomasb)
----------
- Updated Italian, Slovenian, Greek, Bulgarian, Hungarian and Croatian translation
2007/01/07 (estadtherr)
----------
- Fixed display of HTML message attachments (closes #1484178)
2007/01/07 (thomasb)
----------
- Applied patch for preview caching (closes #1484186)
- Added Thai and Vietnamese localization files
2006/12/29 (thomasb)
----------
- Added error handling for attachment uploads
- Use multibyte safe string functions where necessary (closes #1483988)
- Updated Swiss German localization (de_CH)
2006/12/22 (thomasb)
----------
- Applied security patch to validate the submitted host value (by Kees Cook)
- Applied security patch to validate input values when deleting contacts (by Kees Cook)
- Applied security patch that sanitizes emoticon paths when attaching them (by Kees Cook)
- Applied a patch to more aggressively sanitize a HTML message
- Visualize blocked images in HTML messages
2006/12/20 (thomasb)
----------
- Fixed wrong message listing when showing search results (closes #1484131)
- Introduced functions Q() and JQ() as aliases for rep_specialchars_output()
- Show remote images when opening HTML message part as attachment
2006/12/17 (thomasb)
----------
- Added patch by Ryan Rittenhouse & David Glick for a resizeable preview pane
2006/12/06 (thomasb)
----------
- Improve memory usage when sending mail (closes #1484098)
- Mark messages as read once the preview is loaded (closes #1484132)
- Include smtp final response in log (closes #1484081)
2006/12/04 (thomasb)
----------
- Corrected date string in sent message header (closes #1484125)
- Correclty choose "To" column in sent and draft mailboxes (closes #1483943)
- Changed srong tooltips for message browse buttons (closes #1483930)
2006/12/03 (estadtherr)
----------
- Added fix to convert HTML signatures for plain text messages
- Fixed signature delimeter character to be standard (Bug #1484035)
2006/12/01 (thomasb)
----------
- Implemented preview pane
- Fixed XSS vulnerability (Bug #1484109)
- Remove newlines from mail headers (Bug #1484031)
- Selection issues when moving/deleting (Bug #1484044)
- Applied patch of Clement Moulin for imap host auto-selection
- ISO-encode IMAP password for plaintext login (Bugs #1483977 & #1483886)
- Fixed folder name encoding in subscription list (Bug #1484113)
- Fixed JS errors in identity list (Bug #1484120)
- Show client debug console on debug_level 8
- Added Serbian translation
- Updated Spanish and Bulgarian localization
2006/11/22 (robin)
----------
- Fix a bug introduced with Shift-Del yesterday
2006/11/21 (robin)
----------
- Add missing nl_NL translations
- Translate foldernames in folder form (closes #1484113)
2006/11/21 (robin)
----------
- Added first and last buttons to message list, address book
and message detail
- Pressing Shift-Del bypasses Trash folder
- Enable purge command for Junk folder
2006/11/17 (robin)
----------
- Re-initialize message list after shift-select and delete
2006/11/16 (robin)
----------
- Fixed updating message list after expunge and purge
- Fetch all aliases if virtuser_query is used instead
of only the first one
2006/11/11 (estadtherr)
----------
- fixed deletion/moving of messages from within "show" page
2006/11/09 (thomasb)
----------
- Little bugfix in HTML encoding
- Fixed encoding issues and delete-on-reply problem
- Corrected template parsing
2006/11/07 (estadtherr)
----------
- Upgraded to TinyMCE v2.0.8
- Fixed CSS path for editor popups
2006/09/26 (estadtherr)
----------
- Added spellchecker plugin to TinyMCE configuration
- Fixed HTML/Plain toggle labels
2006/09/24 (thomasb)
----------
- Partial client re-write with a common list class
- Re-enabled multi select of contacts (Bug #1484017)
- Enable contact editing right after creation (Bug #1459641)
- Updated Hungarian, Estonian and Traditional Chinese localization
2006/09/19 (thomasb)
----------
- Correct UTF-7 to UTF-8 conversion if mbstring is not available
2006/09/13 (estadtherr)
----------
- Introduction of TinyMCE HTML editor support for message composition and signatures
Note : a new column is added to the "identities" database table
2006/09/12 (estadtherr)
----------
- Fixed html2text treatment of table headers (Bug #1484020)
- Fixed IMAP fetch of message body (Bug #1484019)
2006/09/08 (thomasb)
----------
- Fixed safe_mode problems (Bug #1418381)
- Fixed wrong header encoding (Bug #1483976)
2006/09/07 (thomasb)
----------
- Made automatic draft saving configurable
- Fixed JS bug when renaming folders (Bug #1483989)
- Don't wait for complete page load when calling JavaScript init()
- Some improvements to prevent session expiration
- Prevent from double submit of spell check requests
2006/09/01 (thomasb)
----------
- Imporoved message parsing and HTML validation
- Added quota display as image (by Brett Patterson)
- Corrected creation of a message-id
- Updated Norwegian (bokmal) localization
2006/08/30 (thomasb)
----------
- New indentation for quoted message text
- Improved HTML validity
2006/08/28 (estadtherr)
----------
- Fixed URL character set (Ticket #1445501)
- Fixed saving of contact into MySQL from LDAP query results (Ticket #1483820)
2006/08/25 (thomasb)
----------
- Fixed folder renaming: unsubscribe before rename (Bug #1483920)
- Finalized new message parsing (+ chaching)
- Updated SQL scripts and UPGRADING instructions
2006/08/23 (thomasb)
----------
- Updated Polish, Portuguese, Latvian, Chinese and Japanese localization
2006/08/20 (thomasb)
----------
- Fixed wrong usage of mbstring (Bug #1462439)
- Set default spelling language (Ticket #1483938)
- Added support for Nox Spell Server
2006/08/18 (thomasb)
----------
- Re-built message parsing (Bug #1327068)
Now based on the message structure delivered by the IMAP server.
- Fixed some XSS and SQL injection issues
2006/08/10 (thomasb)
----------
- Fixed charset problems with folder renaming
2006/08/04 (thomasb)
----------
- Fixed Bug in saving identities (Ticket #1483915)
- Set folder name in window title (Bug #1483919)
- Don't add imap_root to INBOX path (Bug #1483816)
- Attempt to create default folders only after login
- Avoid usage of $CONFIG in rcube_imap class
2006/07/30 (thomasb)
----------
- Alter links in HTML messages (Bug #1326402)
- Added fallback if host not found in 'mail_domain' array
- Applied patch of Charles to highlight droptargets (Ticket #1473034)
- Fixed folder renaming (Bug #1483914)
- Added confirmation message after deleting a folder
2006/07/25 (thomasb)
----------
- Made folder renaming a bit more ajax-style
- Changed rename-labels and German translation
- Fixed addressbox countbar width (Bug #1483845)
- Fixed refresh interval problems in Safari (Bug #1483902)
- Fixed clear_message_list_header() errors (Bug #1483898)
- Sanity check of $message_set in imap.inc (Bug #1443200)
- Added correct changing of message list headers for Sent folder
- Updated Spanish localization (Ticket #1483887)
- Applied patch #1483846
2006/07/24 (richs)
----------
- Draft window no longer reloads. It saves to an iframe in the background instead (fixes bug #1483869)
- Draft timer now part of program/js/app.js instead of skins/default/templates/compose.inc
- Draft saving now properly returns an error when saving fails
- Draft timer stops and resets properly when attachments are uploaded, or when saving manually
- Old compose session/attachments are now cleaned up when a new/forward/reply/draft is made/opened
2006/07/19 (thomasb)
----------
- Correct entity encoding of link urls (HTML validity)
- Improved usability in compose step (Ticket #1483807)
- Added absolute URLs to several buttons (for "open in new window")
- Applied patch #1328032
- Fixed Bug/Patch #1443200
2006/07/18 (thomasb)
----------
- Fixed password with spaces issue (Bug #1364122)
- Replaced _auth hash with second cookie (Ticket #1483811)
- Don't use get_input_value() for passwords (Bug #1468895)
- Made password encryption key configurable
- Minor bugfixes with charset encoding
- Added <label> tags to forms (Ticket #1483810)
2006/07/07 (thomasb)
----------
- Fixed INSTALL_PATH bug #1425663
2006/07/03 (richs)
----------
- Fixed compatibility with in-body email addresses containing "+" (Bug #1483836)
- Updated French localizations (Ticket #1483862)
- Incoming messages can now be moved to Drafts, edited, saved, then moved back (Feature #1436191)
- Added Firefox workaround when clicking whitespace to drag messages (Bug #1483857)
- Corrected Dutch and Italian localizations (Ticket #1483851 and #1483848)
- Enabled 'Empty' (purge) command for Junk mailbox (defined in main.inc.php)
2006/06/30 (richs)
----------
- Fixed empty INBOX compatibility bug (Patch #1443200)
- Temporarily fixed French "compact" localization (Patch #1483862)
- Fixed "Select All" not working with Delete interface button (Bug #1332434)
- Fixed messsage list column compatibility with Konqueror (Bug #1395711)
- Fixed "unread count" in window title when count changed (Bug #1483812)
- Fixed DB error when deleting from message table (Patch #1483835)
2006/06/29 (richs)
----------
- Added ability to remove attachments (Feature #1436721)
- Default folders are now auto-created on first login (Feature #1471594)
- Fixed compatibility with folder apostrophes (e.g.: Joe's Folder) (Bug #1429458)
- Corrected Italian localizations
- Tweaked rename-folder form to clear after a rename
2006/06/26 (richs)
----------
- Added button to immediately check for new messages
- New message checking now displays status "Checking for new messages..."
- New message checking now looks for unread messages in all mailboxes (Feature #1326401)
- Task buttons now respond to clicks by darkening (as in other applications)
- Fixed "Sender" column changing to "Recipient" for "Sent" and "Drafts" message lists
- Added ability to sort messages by "Size"
- Added ability to rename folders (Feature #1326396)
- Added 'protect_default_folders' option to main.inc.php to prevent renames/deletes/unsubscribes of default folders
- Corrected 5 typos of "INSTLL" to "INSTALL" in program/include/main.inc
2006/06/25
----------
- Changed behavior to include host-specific configuration (Bug #1483849)
- Assume ISO-8859-1 encoding of mail messages by default (Patch #1483839)
- Fixed spell checker to work with the new URL at google.com
- Some memory and security optimizations sendmail.inc
- Updated UGRADING description
2006/06/19
----------
- Added Drafts support (Feature #1326839) (richs)
2006/06/02
----------
- Updated Estonian localization and moved from ee to et
- Added Bulgarian localization
2006/05/25
----------
- Finalized GoogieSpell integration
2006/05/18
----------
- Added Arabic and Armenian localizations
- Updated Russian localization
- Removed MDB2 classes from repository. Install them seperately if used.
- Updated MDB2 wrapper class contributed by Lukas Kahwe Smith
- Allow & in e-mail addresses
2006/05/05
----------
- Fixed typos in function rcube_button() (Bugs #1473198 and #1473201)
- Check for zlib.output_compression before using ob_gzhandler (Bug #1471069)
- Casting date parts in iil_StrToTime() to avoid warnings (Bug #1482140)
- Corrected INSTALL description (Bug #1476106)
- Added charset to javascript HTTP headers
- Fixed Opera bug with CC and BCC fields (Bug #1474576)
- Changed login page title regarding product name (Bug #1476413)
- Pimped search function
- Applied attachment viewing/forwarding patches by Andrew Fladmark
- Applied prev/next patch by Leonard Bouchet
- Applied patches by Mark Bucciarelli
- Applied patch for requesting receipts by Salvatore Ansani
- Integrated GoogieSpell as suggested by phil (styling is not perfect yet, localization is missing)
2006/04/13
----------
- Added Slovenian localization
- Updated Portuguese localization
- Fixed parent.location problem for compose-links
- Added sort order saving patch by Jacob Brunson
- Added gzip compression support
2006/04/02
----------
- Added Lithuanian localization
- Improved search function
- Added version string as template object
- Load host-specific configuration file (see config/main.inc.php)
- New config parameter adding domain to user names for login
- Strip tags on _auth, _action, _task parameters
- Corrected labels for next/previous page buttons in address book
2006/03/23
----------
- Auto-detect mail header delimiters
- Regard daylight savings
- Localized quota display
- Started implementing search function
2006/03/20
----------
- Avoid error message when saving an unchanged identity (Bug #1429510)
- Fixed hard-coded cols selection for sent folder (Bug #1354586)
- Enable some HTML links for use with "open in new window" or "save target"
- Check meta-key instead of ctrl on Macs
- Ignore double clicks when holding down a modifier key
- Fixed reloading of the login page
- Fixed typo in compose template (Bug #1446852)
- Added compose button to message read step (Request #1433288)
- New config parameter for persistent database connections (Bug #1431817)
2006/03/14
----------
- Don't remove internal HTML tags in plaintext messages
- Improved error handling in DB connection failure
2006/02/22
----------
- Updated localizations
- Fixed bug #1435989
2006/02/19
----------
- Updated localizations
- Applied patch of Anders Karlsson
- Applied patch of Jacob Brunson
- Applied patch for virtuser_query by Robin Elfrink
- Added support for References header (patch by Auke)
- Added support for mbstring module by Tadashi Jokagi
- Added function for automatic remove of slashes on GET and POST vars
if magic_quotes is enabled
2006/02/05
----------
- Added Slovak, Hungarian, Bosnian and Croation translation
- Fixed bug when inserting signatures with !?&
- Chopping message headers before inserting into the message cache table
(to avoid bugs in Postgres)
- Allow one-char domains in e-mail addresses
- Make product name in page title configurable
- Make username available as skin object
- Added session_write_close() in rcube_db class destructor to avoid problems
in PHP 5.0.5
- Use move_uploaded_file() instead of copy() for a more secure handling of
uploaded attachments
- Additional config parameter to show/hide deleted messages
- Added periodic request for checking new mails (Request #1307821)
- Added EXPUNGE command
- Optimized loading time for mail interface
- Changed to full UTF-8 support
- Additional timezones (Patch #1389912)
- Added LDAP public search (experimental)
- Applied patch for correct ctrl/shift behavior for message selection (Bug #1326364)
- Casting to strings when adding empty headers to message cache (Bug #1406026)
- Skip sender-address as recipient when Reply-to-all
- Fixes in utf8-class
- Added patch for Quota display by Aury Fink Filho <nuny@aury.com.br>
- Added garbage collector for message cache
- Added patches for BCC headers
2005/12/16
----------
- Added Turkish and Simplified Chinese translation
- Use virtusertable to resolve e-mail addresses at login
- Configurable mail_domain used to compose correct e-mail addresses
on first login
2005/12/03
----------
- Added Finnish, Romanian, Polish, Czech, British, Norwegian, Greek, Russian,
Estonian and Chinese translation
- Get IMAP server capabilities in array
- Check for NAMESPACE capability before sending command
- Set default user language from config 'locale_string'
- Added sorting patch for message list
- Make default sort col/order configurable
- Fixed XSS in address book and identities
- Added more XSS protection (Bug #1308236)
- Added tab indexes for compose form
- Added 'changed' col to contacts table
- Support for 160-bit session hashes
- Added input check for contacts and identities (Patch #1346523)
- Added messages/warning to compose step (Patch #1323895)
- Added favicon to the default skin
- Fixed Bug #1334337 as far as possible
- Added Reply-To-All functionality (Request #1326395, Patch #1349777)
- Redesign of client side AJAX code (enable multi threading)
- Added keep-alive signal every minute
- Make logs dir configurable
- Added support for SMTPS
- Decode attachment file names
- Make delimiter for message headers configurable
- Add generic footer to sent messages
- Choose the rigt identity when replying
- Remove signature when replying (Request #1333167)
- Signatures for each identity
- Select charset when composing message
- Complete re-design of the caching mechanism
2005/08/11
----------
- Write list header to client even if list is empty
- Add functions "select all", "select none" to message list
- Improved filter for HTML messages to remove potentially malicious tags
(script, iframe, object) and event handlers.
- Buttons for next/previous message in view mode
- Add new created contact to list and show confirmation status
- Added folder management (subscribe/create/delete)
- Log message sending (SMTP log)
- Grant access for Camino browser
- Added German translation
2005/10/20
----------
- Added Swedish, Latvian, Portuguese and Catalan translation
- Make SMTP auth method configurable
- Make mailboxlist scrollable (Bug #1326372)
- Fixed SSL support
- Improved support for Courier IMAP (root folder and delimiter issues)
- Moved taskbar from bottom to top
- Added 'session_lifetime' parameter
- Fixed wrong unread count when deleting message (Bug #1332434)
- Srip tags when creating a new folder (Bug #1332084)
- Translate HTML tags in message headers (Bug #1330134)
- Correction in German translation (Bug #1329434)
- Display folder names with special chars correctly (Bug #1330157)
2005/10/07
----------
- Added French, Italian, Spanish, Danish, Dutch translation
- Clarified license (Bug #1305966)
- Fixed PHP warnings (Bug #1299403)
- Fixed english translation (Bug #1295406)
- Fixed bug #1290833: Last character of email not seen
- Fixed bug #1292199 when creating new user
- Allow more browsers (Bug #1285101)
- Added setting for showing pretty dates
- Added support for SQLite database
- Make use of message caching configurable
- Also add attachments when forwarding a message
- Long folder names will not flow over message list (Bug #1267232)
- Show nested mailboxes hieracically
- Enable IMAPS by host
2005/08/20
----------
- Improved cacheing of mailbox messagecount
- Fixed javascript bug when creating a new message folder
- Fixed javascript bugs #1260990 and #1260992: folder selection
- Make Trash folder configurable
- Auto create folders Inbox, Sent and Trash (if configured)
- Support for IMAP root folder
- Added support fot text/enriched messages
- Make list of special mailboxes configurable
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 8a7ad2c9b..1b5ec1670 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1,3005 +1,3022 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/include/rcube_imap.php |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| IMAP wrapper that implements the Iloha IMAP Library (IIL) |
| See http://ilohamail.org/ for details |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
/*
* Obtain classes from the Iloha IMAP library
*/
require_once('lib/imap.inc');
require_once('lib/mime.inc');
/**
* Interface class for accessing an IMAP server
*
* This is a wrapper that implements the Iloha IMAP Library (IIL)
*
* @package Mail
* @author Thomas Bruederli <roundcube@gmail.com>
* @version 1.40
* @link http://ilohamail.org
*/
class rcube_imap
{
var $db;
var $conn;
var $root_ns = '';
var $root_dir = '';
var $mailbox = 'INBOX';
var $list_page = 1;
var $page_size = 10;
var $sort_field = 'date';
var $sort_order = 'DESC';
var $delimiter = NULL;
var $caching_enabled = FALSE;
var $default_charset = 'ISO-8859-1';
var $default_folders = array('INBOX');
var $default_folders_lc = array('inbox');
var $cache = array();
var $cache_keys = array();
var $cache_changes = array();
var $uid_id_map = array();
var $msg_headers = array();
var $skip_deleted = FALSE;
var $search_set = NULL;
var $search_subject = '';
var $search_string = '';
var $search_charset = '';
var $debug_level = 1;
var $error_code = 0;
/**
* Object constructor
*
* @param object DB Database connection
*/
function __construct($db_conn)
{
$this->db = $db_conn;
}
/**
* Connect to an IMAP server
*
* @param string Host to connect
* @param string Username for IMAP account
* @param string Password for IMAP account
* @param number Port to connect to
* @param string SSL schema (either ssl or tls) or null if plain connection
* @return boolean TRUE on success, FALSE on failure
* @access public
*/
function connect($host, $user, $pass, $port=143, $use_ssl=null, $auth_type=null)
{
global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE;
// check for Open-SSL support in PHP build
if ($use_ssl && in_array('openssl', get_loaded_extensions()))
$ICL_SSL = $use_ssl == 'imaps' ? 'ssl' : $use_ssl;
else if ($use_ssl)
{
raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__,
'message' => 'Open SSL not available;'), TRUE, FALSE);
$port = 143;
}
$ICL_PORT = $port;
$IMAP_USE_INTERNAL_DATE = false;
$this->conn = iil_Connect($host, $user, $pass, array('imap' => $auth_type ? $auth_type : 'check'));
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->port = $port;
$this->ssl = $use_ssl;
// print trace mesages
if ($this->conn && ($this->debug_level & 8))
console($this->conn->message);
// write error log
else if (!$this->conn && $GLOBALS['iil_error'])
{
$this->error_code = $GLOBALS['iil_errornum'];
raise_error(array('code' => 403,
'type' => 'imap',
'message' => $GLOBALS['iil_error']), TRUE, FALSE);
}
// get server properties
if ($this->conn)
{
if (!empty($this->conn->delimiter))
$this->delimiter = $this->conn->delimiter;
if (!empty($this->conn->rootdir))
{
$this->set_rootdir($this->conn->rootdir);
$this->root_ns = ereg_replace('[\.\/]$', '', $this->conn->rootdir);
}
}
return $this->conn ? TRUE : FALSE;
}
/**
* Close IMAP connection
* Usually done on script shutdown
*
* @access public
*/
function close()
{
if ($this->conn)
iil_Close($this->conn);
}
/**
* Close IMAP connection and re-connect
* This is used to avoid some strange socket errors when talking to Courier IMAP
*
* @access public
*/
function reconnect()
{
$this->close();
$this->connect($this->host, $this->user, $this->pass, $this->port, $this->ssl);
// issue SELECT command to restore connection status
if ($this->mailbox)
iil_C_Select($this->conn, $this->mailbox);
}
/**
* Set a root folder for the IMAP connection.
*
* Only folders within this root folder will be displayed
* and all folder paths will be translated using this folder name
*
* @param string Root folder
* @access public
*/
function set_rootdir($root)
{
if (ereg('[\.\/]$', $root)) //(substr($root, -1, 1)==='/')
$root = substr($root, 0, -1);
$this->root_dir = $root;
if (empty($this->delimiter))
$this->get_hierarchy_delimiter();
}
/**
* Set default message charset
*
* This will be used for message decoding if a charset specification is not available
*
* @param string Charset string
* @access public
*/
function set_charset($cs)
{
$this->default_charset = $cs;
}
/**
* This list of folders will be listed above all other folders
*
* @param array Indexed list of folder names
* @access public
*/
function set_default_mailboxes($arr)
{
if (is_array($arr))
{
$this->default_folders = $arr;
$this->default_folders_lc = array();
// add inbox if not included
if (!in_array_nocase('INBOX', $this->default_folders))
array_unshift($this->default_folders, 'INBOX');
// create a second list with lower cased names
foreach ($this->default_folders as $mbox)
$this->default_folders_lc[] = strtolower($mbox);
}
}
/**
* Set internal mailbox reference.
*
* All operations will be perfomed on this mailbox/folder
*
* @param string Mailbox/Folder name
* @access public
*/
function set_mailbox($new_mbox)
{
$mailbox = $this->_mod_mailbox($new_mbox);
if ($this->mailbox == $mailbox)
return;
$this->mailbox = $mailbox;
// clear messagecount cache for this mailbox
$this->_clear_messagecount($mailbox);
}
/**
* Set internal list page
*
* @param number Page number to list
* @access public
*/
function set_page($page)
{
$this->list_page = (int)$page;
}
/**
* Set internal page size
*
* @param number Number of messages to display on one page
* @access public
*/
function set_pagesize($size)
{
$this->page_size = (int)$size;
}
/**
* Save a set of message ids for future message listing methods
*
* @param array List of IMAP fields to search in
* @param string Search string
* @param array List of message ids or NULL if empty
*/
function set_search_set($subject, $str=null, $msgs=null, $charset=null)
{
if (is_array($subject) && $str == null && $msgs == null)
list($subject, $str, $msgs, $charset) = $subject;
if ($msgs != null && !is_array($msgs))
$msgs = split(',', $msgs);
$this->search_subject = $subject;
$this->search_string = $str;
$this->search_set = (array)$msgs;
$this->search_charset = $charset;
}
/**
* Return the saved search set as hash array
* @return array Search set
*/
function get_search_set()
{
return array($this->search_subject, $this->search_string, $this->search_set, $this->search_charset);
}
/**
* Returns the currently used mailbox name
*
* @return string Name of the mailbox/folder
* @access public
*/
function get_mailbox_name()
{
return $this->conn ? $this->_mod_mailbox($this->mailbox, 'out') : '';
}
/**
* Returns the IMAP server's capability
*
* @param string Capability name
* @return mixed Capability value or TRUE if supported, FALSE if not
* @access public
*/
function get_capability($cap)
{
return iil_C_GetCapability($this->conn, strtoupper($cap));
}
/**
* Checks the PERMANENTFLAGS capability of the current mailbox
* and returns true if the given flag is supported by the IMAP server
*
* @param string Permanentflag name
* @return mixed True if this flag is supported
* @access public
*/
function check_permflag($flag)
{
$flagsmap = $GLOBALS['IMAP_FLAGS'];
return (($imap_flag = $flagsmap[strtoupper($flag)]) && in_array_nocase($imap_flag, $this->conn->permanentflags));
}
/**
* Returns the delimiter that is used by the IMAP server for folder separation
*
* @return string Delimiter string
* @access public
*/
function get_hierarchy_delimiter()
{
if ($this->conn && empty($this->delimiter))
$this->delimiter = iil_C_GetHierarchyDelimiter($this->conn);
if (empty($this->delimiter))
$this->delimiter = '/';
return $this->delimiter;
}
/**
* Public method for mailbox listing.
*
* Converts mailbox name with root dir first
*
* @param string Optional root folder
* @param string Optional filter for mailbox listing
* @return array List of mailboxes/folders
* @access public
*/
function list_mailboxes($root='', $filter='*')
{
$a_out = array();
$a_mboxes = $this->_list_mailboxes($root, $filter);
foreach ($a_mboxes as $mbox_row)
{
$name = $this->_mod_mailbox($mbox_row, 'out');
if (strlen($name))
$a_out[] = $name;
}
// INBOX should always be available
if (!in_array_nocase('INBOX', $a_out))
array_unshift($a_out, 'INBOX');
// sort mailboxes
$a_out = $this->_sort_mailbox_list($a_out);
return $a_out;
}
/**
* Private method for mailbox listing
*
* @return array List of mailboxes/folders
* @see rcube_imap::list_mailboxes()
* @access private
*/
function _list_mailboxes($root='', $filter='*')
{
$a_defaults = $a_out = array();
// get cached folder list
$a_mboxes = $this->get_cache('mailboxes');
if (is_array($a_mboxes))
return $a_mboxes;
// retrieve list of folders from IMAP server
$a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter);
if (!is_array($a_folders) || !sizeof($a_folders))
$a_folders = array();
// write mailboxlist to cache
$this->update_cache('mailboxes', $a_folders);
return $a_folders;
}
/**
* Get message count for a specific mailbox
*
* @param string Mailbox/folder name
* @param string Mode for count [ALL|UNSEEN|RECENT]
* @param boolean Force reading from server and update cache
* @return int Number of messages
* @access public
*/
function messagecount($mbox_name='', $mode='ALL', $force=FALSE)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_messagecount($mailbox, $mode, $force);
}
/**
* Private method for getting nr of messages
*
* @access private
* @see rcube_imap::messagecount()
*/
function _messagecount($mailbox='', $mode='ALL', $force=FALSE)
{
$a_mailbox_cache = FALSE;
$mode = strtoupper($mode);
if (empty($mailbox))
$mailbox = $this->mailbox;
// count search set
if ($this->search_string && $mailbox == $this->mailbox && $mode == 'ALL' && !$force)
return count((array)$this->search_set);
$a_mailbox_cache = $this->get_cache('messagecount');
// return cached value
if (!$force && is_array($a_mailbox_cache[$mailbox]) && isset($a_mailbox_cache[$mailbox][$mode]))
return $a_mailbox_cache[$mailbox][$mode];
// RECENT count is fetched a bit different
if ($mode == 'RECENT')
$count = iil_C_CheckForRecent($this->conn, $mailbox);
// use SEARCH for message counting
else if ($this->skip_deleted)
{
$search_str = "ALL UNDELETED";
// get message count and store in cache
if ($mode == 'UNSEEN')
$search_str .= " UNSEEN";
// get message count using SEARCH
// not very performant but more precise (using UNDELETED)
$count = 0;
$index = $this->_search_index($mailbox, $search_str);
if (is_array($index))
{
$str = implode(",", $index);
if (!empty($str))
$count = count($index);
}
}
else
{
if ($mode == 'UNSEEN')
$count = iil_C_CountUnseen($this->conn, $mailbox);
else
$count = iil_C_CountMessages($this->conn, $mailbox);
}
if (!is_array($a_mailbox_cache[$mailbox]))
$a_mailbox_cache[$mailbox] = array();
$a_mailbox_cache[$mailbox][$mode] = (int)$count;
// write back to cache
$this->update_cache('messagecount', $a_mailbox_cache);
return (int)$count;
}
/**
* Public method for listing headers
* convert mailbox name with root dir first
*
* @param string Mailbox/folder name
* @param int Current page to list
* @param string Header field to sort by
* @param string Sort order [ASC|DESC]
* @return array Indexed array with message header objects
* @access public
*/
function list_headers($mbox_name='', $page=NULL, $sort_field=NULL, $sort_order=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_list_headers($mailbox, $page, $sort_field, $sort_order);
}
/**
* Private method for listing message headers
*
* @access private
* @see rcube_imap::list_headers
*/
function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=FALSE)
{
if (!strlen($mailbox))
return array();
// use saved message set
if ($this->search_string && $mailbox == $this->mailbox)
return $this->_list_header_set($mailbox, $this->search_set, $page, $sort_field, $sort_order);
$this->_set_sort_order($sort_field, $sort_order);
$max = $this->_messagecount($mailbox);
$start_msg = ($this->list_page-1) * $this->page_size;
list($begin, $end) = $this->_get_message_range($max, $page);
// mailbox is empty
if ($begin >= $end)
return array();
$headers_sorted = FALSE;
$cache_key = $mailbox.'.msg';
$cache_status = $this->check_cache_status($mailbox, $cache_key);
// cache is OK, we can get all messages from local cache
if ($cache_status>0)
{
$a_msg_headers = $this->get_message_cache($cache_key, $start_msg, $start_msg+$this->page_size, $this->sort_field, $this->sort_order);
$headers_sorted = TRUE;
}
// cache is dirty, sync it
else if ($this->caching_enabled && $cache_status==-1 && !$recursive)
{
$this->sync_header_index($mailbox);
return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE);
}
else
{
// retrieve headers from IMAP
if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')))
{
$mymsgidx = array_slice ($msg_index, $begin, $end-$begin);
$msgs = join(",", $mymsgidx);
}
else
{
$msgs = sprintf("%d:%d", $begin+1, $end);
$msg_index = range($begin, $end);
}
// fetch reuested headers from server
$a_msg_headers = array();
$deleted_count = $this->_fetch_headers($mailbox, $msgs, $a_msg_headers, $cache_key);
if ($this->sort_order == 'DESC' && $headers_sorted) {
//since the sort order is not used in the iil_c_sort function we have to do it here
$a_msg_headers = array_reverse($a_msg_headers);
}
// delete cached messages with a higher index than $max+1
// Changed $max to $max+1 to fix this bug : #1484295
$this->clear_message_cache($cache_key, $max + 1);
// kick child process to sync cache
// ...
}
// return empty array if no messages found
if (!is_array($a_msg_headers) || empty($a_msg_headers)) {
return array();
}
// if not already sorted
if (!$headers_sorted)
{
// use this class for message sorting
$sorter = new rcube_header_sorter();
$sorter->set_sequence_numbers($msg_index);
$sorter->sort_headers($a_msg_headers);
if ($this->sort_order == 'DESC')
$a_msg_headers = array_reverse($a_msg_headers);
}
return array_values($a_msg_headers);
}
/**
* Public method for listing a specific set of headers
* convert mailbox name with root dir first
*
* @param string Mailbox/folder name
* @param array List of message ids to list
* @param int Current page to list
* @param string Header field to sort by
* @param string Sort order [ASC|DESC]
* @return array Indexed array with message header objects
* @access public
*/
function list_header_set($mbox_name='', $msgs, $page=NULL, $sort_field=NULL, $sort_order=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_list_header_set($mailbox, $msgs, $page, $sort_field, $sort_order);
}
/**
* Private method for listing a set of message headers
*
* @access private
* @see rcube_imap::list_header_set()
*/
function _list_header_set($mailbox, $msgs, $page=NULL, $sort_field=NULL, $sort_order=NULL)
{
if (!strlen($mailbox) || empty($msgs))
return array();
// also accept a comma-separated list of message ids
if (is_array ($msgs)) {
$max = count ($msgs);
$msgs = join (',', $msgs);
} else {
$max = count(split(',', $msgs));
}
$this->_set_sort_order($sort_field, $sort_order);
$start_msg = ($this->list_page-1) * $this->page_size;
// fetch reuested headers from server
$a_msg_headers = array();
$this->_fetch_headers($mailbox, $msgs, $a_msg_headers, NULL);
// return empty array if no messages found
if (!is_array($a_msg_headers) || empty($a_msg_headers))
return array();
// if not already sorted
$a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
// only return the requested part of the set
return array_slice(array_values($a_msg_headers), $start_msg, min($max-$start_msg, $this->page_size));
}
/**
* Helper function to get first and last index of the requested set
*
* @param int message count
* @param mixed page number to show, or string 'all'
* @return array array with two values: first index, last index
* @access private
*/
function _get_message_range($max, $page)
{
$start_msg = ($this->list_page-1) * $this->page_size;
if ($page=='all')
{
$begin = 0;
$end = $max;
}
else if ($this->sort_order=='DESC')
{
$begin = $max - $this->page_size - $start_msg;
$end = $max - $start_msg;
}
else
{
$begin = $start_msg;
$end = $start_msg + $this->page_size;
}
if ($begin < 0) $begin = 0;
if ($end < 0) $end = $max;
if ($end > $max) $end = $max;
return array($begin, $end);
}
/**
* Fetches message headers
* Used for loop
*
* @param string Mailbox name
* @param string Message index to fetch
* @param array Reference to message headers array
* @param array Array with cache index
* @return int Number of deleted messages
* @access private
*/
function _fetch_headers($mailbox, $msgs, &$a_msg_headers, $cache_key)
{
// cache is incomplete
$cache_index = $this->get_message_cache_index($cache_key);
// fetch reuested headers from server
$a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs);
$deleted_count = 0;
if (!empty($a_header_index))
{
foreach ($a_header_index as $i => $headers)
{
if ($headers->deleted && $this->skip_deleted)
{
// delete from cache
if ($cache_index[$headers->id] && $cache_index[$headers->id] == $headers->uid)
$this->remove_message_cache($cache_key, $headers->id);
$deleted_count++;
continue;
}
// add message to cache
if ($this->caching_enabled && $cache_index[$headers->id] != $headers->uid)
$this->add_message_cache($cache_key, $headers->id, $headers);
$a_msg_headers[$headers->uid] = $headers;
}
}
return $deleted_count;
}
/**
* Return sorted array of message UIDs
*
* @param string Mailbox to get index from
* @param string Sort column
* @param string Sort order [ASC, DESC]
* @return array Indexed array with message ids
*/
function message_index($mbox_name='', $sort_field=NULL, $sort_order=NULL)
{
$this->_set_sort_order($sort_field, $sort_order);
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
$key = "{$mailbox}:{$this->sort_field}:{$this->sort_order}:{$this->search_string}.msgi";
// we have a saved search result. get index from there
if (!isset($this->cache[$key]) && $this->search_string && $mailbox == $this->mailbox)
{
$this->cache[$key] = $a_msg_headers = array();
$this->_fetch_headers($mailbox, join(',', $this->search_set), $a_msg_headers, NULL);
foreach (iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order) as $i => $msg)
$this->cache[$key][] = $msg->uid;
}
// have stored it in RAM
if (isset($this->cache[$key]))
return $this->cache[$key];
// check local cache
$cache_key = $mailbox.'.msg';
$cache_status = $this->check_cache_status($mailbox, $cache_key);
// cache is OK
if ($cache_status>0)
{
$a_index = $this->get_message_cache_index($cache_key, TRUE, $this->sort_field, $this->sort_order);
return array_values($a_index);
}
// fetch complete message index
$msg_count = $this->_messagecount($mailbox);
if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, '', TRUE)))
{
if ($this->sort_order == 'DESC')
$a_index = array_reverse($a_index);
$this->cache[$key] = $a_index;
}
else
{
$a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", $this->sort_field);
$a_uids = iil_C_FetchUIDs($this->conn, $mailbox);
if ($this->sort_order=="ASC")
asort($a_index);
else if ($this->sort_order=="DESC")
arsort($a_index);
$i = 0;
$this->cache[$key] = array();
foreach ($a_index as $index => $value)
$this->cache[$key][$i++] = $a_uids[$index];
}
return $this->cache[$key];
}
/**
* @access private
*/
function sync_header_index($mailbox)
{
$cache_key = $mailbox.'.msg';
$cache_index = $this->get_message_cache_index($cache_key);
$msg_count = $this->_messagecount($mailbox);
// fetch complete message index
$a_message_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", 'UID');
foreach ($a_message_index as $id => $uid)
{
// message in cache at correct position
if ($cache_index[$id] == $uid)
{
unset($cache_index[$id]);
continue;
}
// message in cache but in wrong position
if (in_array((string)$uid, $cache_index, TRUE))
{
unset($cache_index[$id]);
}
// other message at this position
if (isset($cache_index[$id]))
{
$this->remove_message_cache($cache_key, $id);
unset($cache_index[$id]);
}
// fetch complete headers and add to cache
$headers = iil_C_FetchHeader($this->conn, $mailbox, $id);
$this->add_message_cache($cache_key, $headers->id, $headers);
}
// those ids that are still in cache_index have been deleted
if (!empty($cache_index))
{
foreach ($cache_index as $id => $uid)
$this->remove_message_cache($cache_key, $id);
}
}
/**
* Invoke search request to IMAP server
*
* @param string mailbox name to search in
* @param string search criteria (ALL, TO, FROM, SUBJECT, etc)
* @param string search string
* @return array search results as list of message ids
* @access public
*/
function search($mbox_name='', $criteria='ALL', $str=NULL, $charset=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
// have an array of criterias => execute multiple searches
if (is_array($criteria) && $str)
{
$results = array();
foreach ($criteria as $crit)
if ($search_result = $this->search($mbox_name, $crit, $str, $charset))
$results = array_merge($results, $search_result);
$results = array_unique($results);
$this->set_search_set($criteria, $str, $results, $charset);
return $results;
}
else if ($str && $criteria)
{
$search = (!empty($charset) ? "CHARSET $charset " : '') . sprintf("%s {%d}\r\n%s", $criteria, strlen($str), $str);
$results = $this->_search_index($mailbox, $search);
// try search with ISO charset (should be supported by server)
if (empty($results) && !empty($charset) && $charset!='ISO-8859-1')
$results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, 'ISO-8859-1'), 'ISO-8859-1');
$this->set_search_set($criteria, $str, $results, $charset);
return $results;
}
else
return $this->_search_index($mailbox, $criteria);
}
/**
* Private search method
*
* @return array search results as list of message ids
* @access private
* @see rcube_imap::search()
*/
function _search_index($mailbox, $criteria='ALL')
{
$a_messages = iil_C_Search($this->conn, $mailbox, $criteria);
// clean message list (there might be some empty entries)
if (is_array($a_messages))
{
foreach ($a_messages as $i => $val)
if (empty($val))
unset($a_messages[$i]);
}
return $a_messages;
}
/**
* Refresh saved search set
*
* @return array Current search set
*/
function refresh_search()
{
if (!empty($this->search_subject) && !empty($this->search_string))
$this->search_set = $this->search('', $this->search_subject, $this->search_string, $this->search_charset);
return $this->get_search_set();
}
/**
* Check if the given message ID is part of the current search set
*
* @return boolean True on match or if no search request is stored
*/
function in_searchset($msgid)
{
if (!empty($this->search_string))
return in_array("$msgid", (array)$this->search_set, true);
else
return true;
}
/**
* Return message headers object of a specific message
*
* @param int Message ID
* @param string Mailbox to read from
* @param boolean True if $id is the message UID
* @return object Message headers representation
*/
function get_headers($id, $mbox_name=NULL, $is_uid=TRUE)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
$uid = $is_uid ? $id : $this->_id2uid($id);
// get cached headers
if ($uid && ($headers = &$this->get_cached_message($mailbox.'.msg', $uid)))
return $headers;
$headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid);
// write headers cache
if ($headers)
{
if ($headers->uid && $headers->id)
$this->uid_id_map[$mailbox][$headers->uid] = $headers->id;
$this->add_message_cache($mailbox.'.msg', $headers->id, $headers);
}
return $headers;
}
/**
* Fetch body structure from the IMAP server and build
* an object structure similar to the one generated by PEAR::Mail_mimeDecode
*
* @param int Message UID to fetch
* @return object stdClass Message part tree or False on failure
*/
function &get_structure($uid)
{
$cache_key = $this->mailbox.'.msg';
$headers = &$this->get_cached_message($cache_key, $uid, true);
// return cached message structure
if (is_object($headers) && is_object($headers->structure))
return $headers->structure;
// resolve message sequence number
if (!($msg_id = $this->_uid2id($uid)))
return FALSE;
$structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id);
$structure = iml_GetRawStructureArray($structure_str);
$struct = false;
// parse structure and add headers
if (!empty($structure))
{
$this->_msg_id = $msg_id;
$headers = $this->get_headers($uid);
$struct = &$this->_structure_part($structure);
$struct->headers = get_object_vars($headers);
// don't trust given content-type
if (empty($struct->parts) && !empty($struct->headers['ctype']))
{
$struct->mime_id = '1';
$struct->mimetype = strtolower($struct->headers['ctype']);
list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
}
// write structure to cache
if ($this->caching_enabled)
$this->add_message_cache($cache_key, $msg_id, $headers, $struct);
}
return $struct;
}
/**
* Build message part object
*
* @access private
*/
function &_structure_part($part, $count=0, $parent='')
{
$struct = new rcube_message_part;
$struct->mime_id = empty($parent) ? (string)$count : "$parent.$count";
// multipart
if (is_array($part[0]))
{
$struct->ctype_primary = 'multipart';
// find first non-array entry
for ($i=1; $i<count($part); $i++)
if (!is_array($part[$i]))
{
$struct->ctype_secondary = strtolower($part[$i]);
break;
}
$struct->mimetype = 'multipart/'.$struct->ctype_secondary;
$struct->parts = array();
for ($i=0, $count=0; $i<count($part); $i++)
if (is_array($part[$i]) && count($part[$i]) > 3)
$struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id);
return $struct;
}
// regular part
$struct->ctype_primary = strtolower($part[0]);
$struct->ctype_secondary = strtolower($part[1]);
$struct->mimetype = $struct->ctype_primary.'/'.$struct->ctype_secondary;
// read content type parameters
if (is_array($part[2]))
{
$struct->ctype_parameters = array();
for ($i=0; $i<count($part[2]); $i+=2)
$struct->ctype_parameters[strtolower($part[2][$i])] = $part[2][$i+1];
if (isset($struct->ctype_parameters['charset']))
$struct->charset = $struct->ctype_parameters['charset'];
}
// read content encoding
if (!empty($part[5]) && $part[5]!='NIL')
{
$struct->encoding = strtolower($part[5]);
$struct->headers['content-transfer-encoding'] = $struct->encoding;
}
// get part size
if (!empty($part[6]) && $part[6]!='NIL')
$struct->size = intval($part[6]);
// read part disposition
$di = count($part) - 2;
if ((is_array($part[$di]) && count($part[$di]) == 2 && is_array($part[$di][1])) ||
(is_array($part[--$di]) && count($part[$di]) == 2))
{
$struct->disposition = strtolower($part[$di][0]);
if (is_array($part[$di][1]))
for ($n=0; $n<count($part[$di][1]); $n+=2)
$struct->d_parameters[strtolower($part[$di][1][$n])] = $part[$di][1][$n+1];
}
// get child parts
if (is_array($part[8]) && $di != 8)
{
$struct->parts = array();
for ($i=0, $count=0; $i<count($part[8]); $i++)
if (is_array($part[8][$i]) && count($part[8][$i]) > 5)
$struct->parts[] = $this->_structure_part($part[8][$i], ++$count, $struct->mime_id);
}
// get part ID
if (!empty($part[3]) && $part[3]!='NIL')
{
$struct->content_id = $part[3];
$struct->headers['content-id'] = $part[3];
if (empty($struct->disposition))
$struct->disposition = 'inline';
}
// fetch message headers if message/rfc822 or named part (could contain Content-Location header)
if ($struct->ctype_primary == 'message' || ($struct->ctype_parameters['name'] && !$struct->content_id)) {
$part_headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id);
$struct->headers = $this->_parse_headers($part_headers) + $struct->headers;
}
if ($struct->ctype_primary=='message') {
if (is_array($part[8]) && empty($struct->parts))
$struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id);
}
// normalize filename property
$this->_set_part_filename($struct);
return $struct;
}
/**
* Set attachment filename from message part structure
*
* @access private
* @param object rcube_message_part Part object
*/
function _set_part_filename(&$part)
{
if (!empty($part->d_parameters['filename']))
$filename_mime = $part->d_parameters['filename'];
else if (!empty($part->ctype_parameters['name']))
$filename_mime = $part->ctype_parameters['name'];
else if (!empty($part->d_parameters['filename*']))
$filename_encoded = $part->d_parameters['filename*'];
else if (!empty($part->ctype_parameters['name*']))
$filename_encoded = $part->ctype_parameters['name*'];
// RFC2231 value continuations
// TODO: this should be rewrited to support RFC2231 4.1 combinations
else if (!empty($part->d_parameters['filename*0'])) {
$i = 0;
while (isset($part->d_parameters['filename*'.$i])) {
$i++;
$filename_mime .= $part->d_parameters['filename*'.$i];
}
// some servers (eg. dovecot-1.x) have no support for parameter value continuations
// we must fetch and parse headers "manually"
if ($i<2) {
// TODO: fetch only Content-Type/Content-Disposition header
$headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER');
$filename_mime = '';
$i = 0;
while (preg_match('/filename\*'.$i.'\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) {
$filename_mime .= $matches[1];
$i++;
}
}
}
else if (!empty($part->d_parameters['filename*0*'])) {
$i = 0;
while (isset($part->d_parameters['filename*'.$i.'*'])) {
$i++;
$filename_encoded .= $part->d_parameters['filename*'.$i.'*'];
}
if ($i<2) {
$headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER');
$filename_encoded = '';
$i = 0;
while (preg_match('/filename\*'.$i.'\*\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) {
$filename_encoded .= $matches[1];
$i++;
}
}
}
else if (!empty($part->ctype_parameters['name*0'])) {
$i = 0;
while (isset($part->ctype_parameters['name*'.$i])) {
$i++;
$filename_mime .= $part->ctype_parameters['name*'.$i];
}
if ($i<2) {
$headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER');
$filename_mime = '';
$i = 0;
while (preg_match('/\s+name\*'.$i.'\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) {
$filename_mime .= $matches[1];
$i++;
}
}
}
else if (!empty($part->ctype_parameters['name*0*'])) {
$i = 0;
while (isset($part->ctype_parameters['name*'.$i.'*'])) {
$i++;
$filename_encoded .= $part->ctype_parameters['name*'.$i.'*'];
}
if ($i<2) {
$headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER');
$filename_encoded = '';
$i = 0;
while (preg_match('/\s+name\*'.$i.'\*\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) {
$filename_encoded .= $matches[1];
$i++;
}
}
}
// Content-Disposition
else if (!empty($part->headers['content-description']))
$filename_mime = $part->headers['content-description'];
else
return;
// decode filename
if (!empty($filename_mime)) {
$part->filename = rcube_imap::decode_mime_string($filename_mime,
$part->charset ? $part->charset : rc_detect_encoding($filename_mime, $this->default_charset));
}
else if (!empty($filename_encoded)) {
// decode filename according to RFC 2231, Section 4
list($filename_charset,, $filename_urlencoded) = split('\'', $filename_encoded);
$part->filename = rcube_charset_convert(urldecode($filename_urlencoded), $filename_charset);
}
}
/**
* Fetch message body of a specific message from the server
*
* @param int Message UID
* @param string Part number
* @param object rcube_message_part Part object created by get_structure()
* @param mixed True to print part, ressource to write part contents in
* @return string Message/part body if not printed
*/
function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL)
{
if (!($msg_id = $this->_uid2id($uid)))
return FALSE;
// get part encoding if not provided
if (!is_object($o_part))
{
$structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id);
$structure = iml_GetRawStructureArray($structure_str);
$part_type = iml_GetPartTypeCode($structure, $part);
$o_part = new rcube_message_part;
$o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other');
$o_part->encoding = strtolower(iml_GetPartEncodingString($structure, $part));
$o_part->charset = iml_GetPartCharset($structure, $part);
}
// TODO: Add caching for message parts
if ($print)
{
$mode = $o_part->encoding == 'base64' ? 3 : ($o_part->encoding == 'quoted-printable' ? 1 : 2);
$body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode);
// we have to decode the part manually before printing
if ($mode == 1)
{
echo $this->mime_decode($body, $o_part->encoding);
$body = true;
}
}
else
{
$body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1);
// decode part body
if ($o_part->encoding)
$body = $this->mime_decode($body, $o_part->encoding);
// convert charset (if text or message part)
if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message')
{
// assume default if no charset specified
if (empty($o_part->charset))
$o_part->charset = $this->default_charset;
$body = rcube_charset_convert($body, $o_part->charset);
}
}
return $body;
}
/**
* Fetch message body of a specific message from the server
*
* @param int Message UID
* @return string Message/part body
* @see rcube_imap::get_message_part()
*/
function &get_body($uid, $part=1)
{
$headers = $this->get_headers($uid);
return rcube_charset_convert(
$this->mime_decode($this->get_message_part($uid, $part), 'quoted-printable'),
$headers->charset ? $headers->charset : $this->default_charset);
}
/**
* Returns the whole message source as string
*
* @param int Message UID
* @return string Message source string
*/
function &get_raw_body($uid)
{
if (!($msg_id = $this->_uid2id($uid)))
return FALSE;
$body = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL);
$body .= iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 1);
return $body;
}
+
+
+ /**
+ * Returns the message headers as string
+ *
+ * @param int Message UID
+ * @return string Message headers string
+ */
+ function &get_raw_headers($uid)
+ {
+ if (!($msg_id = $this->_uid2id($uid)))
+ return FALSE;
+
+ $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL);
+
+ return $headers;
+ }
/**
* Sends the whole message source to stdout
*
* @param int Message UID
*/
function print_raw_body($uid)
{
if (!($msg_id = $this->_uid2id($uid)))
return FALSE;
print iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL);
flush();
iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 2);
}
/**
* Set message flag to one or several messages
*
* @param mixed Message UIDs as array or as comma-separated string
* @param string Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT
* @return boolean True on success, False on failure
*/
function set_flag($uids, $flag)
{
$flag = strtoupper($flag);
$msg_ids = array();
if (!is_array($uids))
$uids = explode(',',$uids);
foreach ($uids as $uid) {
$msg_ids[$uid] = $this->_uid2id($uid);
}
if ($flag=='UNDELETED')
$result = iil_C_Undelete($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
else if ($flag=='UNSEEN')
$result = iil_C_Unseen($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
else if ($flag=='UNFLAGGED')
$result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), 'FLAGGED');
else
$result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag);
// reload message headers if cached
$cache_key = $this->mailbox.'.msg';
if ($this->caching_enabled)
{
foreach ($msg_ids as $uid => $id)
{
if ($cached_headers = $this->get_cached_message($cache_key, $uid))
{
$this->remove_message_cache($cache_key, $id);
//$this->get_headers($uid);
}
}
// close and re-open connection
// this prevents connection problems with Courier
$this->reconnect();
}
// set nr of messages that were flaged
$count = count($msg_ids);
// clear message count cache
if ($result && $flag=='SEEN')
$this->_set_messagecount($this->mailbox, 'UNSEEN', $count*(-1));
else if ($result && $flag=='UNSEEN')
$this->_set_messagecount($this->mailbox, 'UNSEEN', $count);
else if ($result && $flag=='DELETED')
$this->_set_messagecount($this->mailbox, 'ALL', $count*(-1));
return $result;
}
/**
* Append a mail message (source) to a specific mailbox
*
* @param string Target mailbox
* @param string Message source
* @return boolean True on success, False on error
*/
function save_message($mbox_name, &$message)
{
$mbox_name = stripslashes($mbox_name);
$mailbox = $this->_mod_mailbox($mbox_name);
// make sure mailbox exists
if (in_array($mailbox, $this->_list_mailboxes()))
$saved = iil_C_Append($this->conn, $mailbox, $message);
if ($saved)
{
// increase messagecount of the target mailbox
$this->_set_messagecount($mailbox, 'ALL', 1);
}
return $saved;
}
/**
* Move a message from one mailbox to another
*
* @param string List of UIDs to move, separated by comma
* @param string Target mailbox
* @param string Source mailbox
* @return boolean True on success, False on error
*/
function move_message($uids, $to_mbox, $from_mbox='')
{
$to_mbox_in = stripslashes($to_mbox);
$from_mbox = stripslashes($from_mbox);
$to_mbox = $this->_mod_mailbox($to_mbox_in);
$from_mbox = $from_mbox ? $this->_mod_mailbox($from_mbox) : $this->mailbox;
// make sure mailbox exists
if (!in_array($to_mbox, $this->_list_mailboxes()))
{
if (in_array($to_mbox_in, $this->default_folders))
$this->create_mailbox($to_mbox_in, TRUE);
else
return FALSE;
}
// convert the list of uids to array
$a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
// exit if no message uids are specified
if (!is_array($a_uids))
return false;
// convert uids to message ids
$a_mids = array();
foreach ($a_uids as $uid)
$a_mids[] = $this->_uid2id($uid, $from_mbox);
$iil_move = iil_C_Move($this->conn, join(',', $a_mids), $from_mbox, $to_mbox);
$moved = !($iil_move === false || $iil_move < 0);
// send expunge command in order to have the moved message
// really deleted from the source mailbox
if ($moved) {
// but only when flag_for_deletion is set to false
if (!rcmail::get_instance()->config->get('flag_for_deletion', false))
{
$this->_expunge($from_mbox, FALSE);
$this->_clear_messagecount($from_mbox);
$this->_clear_messagecount($to_mbox);
}
}
// moving failed
else if (rcmail::get_instance()->config->get('delete_always', false)) {
return iil_C_Delete($this->conn, $from_mbox, join(',', $a_mids));
}
// remove message ids from search set
if ($moved && $this->search_set && $from_mbox == $this->mailbox)
$this->search_set = array_diff($this->search_set, $a_mids);
// update cached message headers
$cache_key = $from_mbox.'.msg';
if ($moved && ($a_cache_index = $this->get_message_cache_index($cache_key)))
{
$start_index = 100000;
foreach ($a_uids as $uid)
{
if (($index = array_search($uid, $a_cache_index)) !== FALSE)
$start_index = min($index, $start_index);
}
// clear cache from the lowest index on
$this->clear_message_cache($cache_key, $start_index);
}
return $moved;
}
/**
* Mark messages as deleted and expunge mailbox
*
* @param string List of UIDs to move, separated by comma
* @param string Source mailbox
* @return boolean True on success, False on error
*/
function delete_message($uids, $mbox_name='')
{
$mbox_name = stripslashes($mbox_name);
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
// convert the list of uids to array
$a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
// exit if no message uids are specified
if (!is_array($a_uids))
return false;
// convert uids to message ids
$a_mids = array();
foreach ($a_uids as $uid)
$a_mids[] = $this->_uid2id($uid, $mailbox);
$deleted = iil_C_Delete($this->conn, $mailbox, join(',', $a_mids));
// send expunge command in order to have the deleted message
// really deleted from the mailbox
if ($deleted)
{
$this->_expunge($mailbox, FALSE);
$this->_clear_messagecount($mailbox);
unset($this->uid_id_map[$mailbox]);
}
// remove message ids from search set
if ($deleted && $this->search_set && $mailbox == $this->mailbox)
$this->search_set = array_diff($this->search_set, $a_mids);
// remove deleted messages from cache
$cache_key = $mailbox.'.msg';
if ($deleted && ($a_cache_index = $this->get_message_cache_index($cache_key)))
{
$start_index = 100000;
foreach ($a_uids as $uid)
{
if (($index = array_search($uid, $a_cache_index)) !== FALSE)
$start_index = min($index, $start_index);
}
// clear cache from the lowest index on
$this->clear_message_cache($cache_key, $start_index);
}
return $deleted;
}
/**
* Clear all messages in a specific mailbox
*
* @param string Mailbox name
* @return int Above 0 on success
*/
function clear_mailbox($mbox_name=NULL)
{
$mbox_name = stripslashes($mbox_name);
$mailbox = !empty($mbox_name) ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
$msg_count = $this->_messagecount($mailbox, 'ALL');
if ($msg_count>0)
{
$cleared = iil_C_ClearFolder($this->conn, $mailbox);
// make sure the message count cache is cleared as well
if ($cleared)
{
$this->clear_message_cache($mailbox.'.msg');
$a_mailbox_cache = $this->get_cache('messagecount');
unset($a_mailbox_cache[$mailbox]);
$this->update_cache('messagecount', $a_mailbox_cache);
}
return $cleared;
}
else
return 0;
}
/**
* Send IMAP expunge command and clear cache
*
* @param string Mailbox name
* @param boolean False if cache should not be cleared
* @return boolean True on success
*/
function expunge($mbox_name='', $clear_cache=TRUE)
{
$mbox_name = stripslashes($mbox_name);
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_expunge($mailbox, $clear_cache);
}
/**
* Send IMAP expunge command and clear cache
*
* @see rcube_imap::expunge()
* @access private
*/
function _expunge($mailbox, $clear_cache=TRUE)
{
$result = iil_C_Expunge($this->conn, $mailbox);
if ($result>=0 && $clear_cache)
{
$this->clear_message_cache($mailbox.'.msg');
$this->_clear_messagecount($mailbox);
}
return $result;
}
/* --------------------------------
* folder managment
* --------------------------------*/
/**
* Get a list of all folders available on the IMAP server
*
* @param string IMAP root dir
* @return array Indexed array with folder names
*/
function list_unsubscribed($root='')
{
static $sa_unsubscribed;
if (is_array($sa_unsubscribed))
return $sa_unsubscribed;
// retrieve list of folders from IMAP server
$a_mboxes = iil_C_ListMailboxes($this->conn, $this->_mod_mailbox($root), '*');
// modify names with root dir
foreach ($a_mboxes as $mbox_name)
{
$name = $this->_mod_mailbox($mbox_name, 'out');
if (strlen($name))
$a_folders[] = $name;
}
// filter folders and sort them
$sa_unsubscribed = $this->_sort_mailbox_list($a_folders);
return $sa_unsubscribed;
}
/**
* Get mailbox quota information
* added by Nuny
*
* @return mixed Quota info or False if not supported
*/
function get_quota()
{
if ($this->get_capability('QUOTA'))
return iil_C_GetQuota($this->conn);
return FALSE;
}
/**
* Subscribe to a specific mailbox(es)
*
* @param array Mailbox name(s)
* @return boolean True on success
*/
function subscribe($a_mboxes)
{
if (!is_array($a_mboxes))
$a_mboxes = array($a_mboxes);
// let this common function do the main work
return $this->_change_subscription($a_mboxes, 'subscribe');
}
/**
* Unsubscribe mailboxes
*
* @param array Mailbox name(s)
* @return boolean True on success
*/
function unsubscribe($a_mboxes)
{
if (!is_array($a_mboxes))
$a_mboxes = array($a_mboxes);
// let this common function do the main work
return $this->_change_subscription($a_mboxes, 'unsubscribe');
}
/**
* Create a new mailbox on the server and register it in local cache
*
* @param string New mailbox name (as utf-7 string)
* @param boolean True if the new mailbox should be subscribed
* @param string Name of the created mailbox, false on error
*/
function create_mailbox($name, $subscribe=FALSE)
{
$result = FALSE;
// replace backslashes
$name = preg_replace('/[\\\]+/', '-', $name);
// reduce mailbox name to 100 chars
$name = substr($name, 0, 100);
$abs_name = $this->_mod_mailbox($name);
$a_mailbox_cache = $this->get_cache('mailboxes');
if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache)))
$result = iil_C_CreateFolder($this->conn, $abs_name);
// try to subscribe it
if ($result && $subscribe)
$this->subscribe($name);
return $result ? $name : FALSE;
}
/**
* Set a new name to an existing mailbox
*
* @param string Mailbox to rename (as utf-7 string)
* @param string New mailbox name (as utf-7 string)
* @return string Name of the renames mailbox, False on error
*/
function rename_mailbox($mbox_name, $new_name)
{
$result = FALSE;
// replace backslashes
$name = preg_replace('/[\\\]+/', '-', $new_name);
// encode mailbox name and reduce it to 100 chars
$name = substr($new_name, 0, 100);
// make absolute path
$mailbox = $this->_mod_mailbox($mbox_name);
$abs_name = $this->_mod_mailbox($name);
// check if mailbox is subscribed
$a_subscribed = $this->_list_mailboxes();
$subscribed = in_array($mailbox, $a_subscribed);
// unsubscribe folder
if ($subscribed)
iil_C_UnSubscribe($this->conn, $mailbox);
if (strlen($abs_name))
$result = iil_C_RenameFolder($this->conn, $mailbox, $abs_name);
if ($result)
{
$delm = $this->get_hierarchy_delimiter();
// check if mailbox children are subscribed
foreach ($a_subscribed as $c_subscribed)
if (preg_match('/^'.preg_quote($mailbox.$delm, '/').'/', $c_subscribed))
{
iil_C_UnSubscribe($this->conn, $c_subscribed);
iil_C_Subscribe($this->conn, preg_replace('/^'.preg_quote($mailbox, '/').'/', $abs_name, $c_subscribed));
}
// clear cache
$this->clear_message_cache($mailbox.'.msg');
$this->clear_cache('mailboxes');
}
// try to subscribe it
if ($result && $subscribed)
iil_C_Subscribe($this->conn, $abs_name);
return $result ? $name : FALSE;
}
/**
* Remove mailboxes from server
*
* @param string Mailbox name
* @return boolean True on success
*/
function delete_mailbox($mbox_name)
{
$deleted = FALSE;
if (is_array($mbox_name))
$a_mboxes = $mbox_name;
else if (is_string($mbox_name) && strlen($mbox_name))
$a_mboxes = explode(',', $mbox_name);
$all_mboxes = iil_C_ListMailboxes($this->conn, $this->_mod_mailbox($root), '*');
if (is_array($a_mboxes))
foreach ($a_mboxes as $mbox_name)
{
$mailbox = $this->_mod_mailbox($mbox_name);
// unsubscribe mailbox before deleting
iil_C_UnSubscribe($this->conn, $mailbox);
// send delete command to server
$result = iil_C_DeleteFolder($this->conn, $mailbox);
if ($result>=0)
$deleted = TRUE;
foreach ($all_mboxes as $c_mbox)
{
$regex = preg_quote($mailbox . $this->delimiter, '/');
$regex = '/^' . $regex . '/';
if (preg_match($regex, $c_mbox))
{
iil_C_UnSubscribe($this->conn, $c_mbox);
$result = iil_C_DeleteFolder($this->conn, $c_mbox);
if ($result>=0)
$deleted = TRUE;
}
}
}
// clear mailboxlist cache
if ($deleted)
{
$this->clear_message_cache($mailbox.'.msg');
$this->clear_cache('mailboxes');
}
return $deleted;
}
/**
* Create all folders specified as default
*/
function create_default_folders()
{
$a_folders = iil_C_ListMailboxes($this->conn, $this->_mod_mailbox(''), '*');
$a_subscribed = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox(''), '*');
// create default folders if they do not exist
foreach ($this->default_folders as $folder)
{
$abs_name = $this->_mod_mailbox($folder);
if (!in_array_nocase($abs_name, $a_folders))
$this->create_mailbox($folder, TRUE);
else if (!in_array_nocase($abs_name, $a_subscribed))
$this->subscribe($folder);
}
}
/* --------------------------------
* internal caching methods
* --------------------------------*/
/**
* @access private
*/
function set_caching($set)
{
if ($set && is_object($this->db))
$this->caching_enabled = TRUE;
else
$this->caching_enabled = FALSE;
}
/**
* @access private
*/
function get_cache($key)
{
// read cache
if (!isset($this->cache[$key]) && $this->caching_enabled)
{
$cache_data = $this->_read_cache_record('IMAP.'.$key);
$this->cache[$key] = strlen($cache_data) ? unserialize($cache_data) : FALSE;
}
return $this->cache[$key];
}
/**
* @access private
*/
function update_cache($key, $data)
{
$this->cache[$key] = $data;
$this->cache_changed = TRUE;
$this->cache_changes[$key] = TRUE;
}
/**
* @access private
*/
function write_cache()
{
if ($this->caching_enabled && $this->cache_changed)
{
foreach ($this->cache as $key => $data)
{
if ($this->cache_changes[$key])
$this->_write_cache_record('IMAP.'.$key, serialize($data));
}
}
}
/**
* @access private
*/
function clear_cache($key=NULL)
{
if (!$this->caching_enabled)
return;
if ($key===NULL)
{
foreach ($this->cache as $key => $data)
$this->_clear_cache_record('IMAP.'.$key);
$this->cache = array();
$this->cache_changed = FALSE;
$this->cache_changes = array();
}
else
{
$this->_clear_cache_record('IMAP.'.$key);
$this->cache_changes[$key] = FALSE;
unset($this->cache[$key]);
}
}
/**
* @access private
*/
function _read_cache_record($key)
{
$cache_data = FALSE;
if ($this->db)
{
// get cached data from DB
$sql_result = $this->db->query(
"SELECT cache_id, data
FROM ".get_table_name('cache')."
WHERE user_id=?
AND cache_key=?",
$_SESSION['user_id'],
$key);
if ($sql_arr = $this->db->fetch_assoc($sql_result))
{
$cache_data = $sql_arr['data'];
$this->cache_keys[$key] = $sql_arr['cache_id'];
}
}
return $cache_data;
}
/**
* @access private
*/
function _write_cache_record($key, $data)
{
if (!$this->db)
return FALSE;
// check if we already have a cache entry for this key
if (!isset($this->cache_keys[$key]))
{
$sql_result = $this->db->query(
"SELECT cache_id
FROM ".get_table_name('cache')."
WHERE user_id=?
AND cache_key=?",
$_SESSION['user_id'],
$key);
if ($sql_arr = $this->db->fetch_assoc($sql_result))
$this->cache_keys[$key] = $sql_arr['cache_id'];
else
$this->cache_keys[$key] = FALSE;
}
// update existing cache record
if ($this->cache_keys[$key])
{
$this->db->query(
"UPDATE ".get_table_name('cache')."
SET created=".$this->db->now().",
data=?
WHERE user_id=?
AND cache_key=?",
$data,
$_SESSION['user_id'],
$key);
}
// add new cache record
else
{
$this->db->query(
"INSERT INTO ".get_table_name('cache')."
(created, user_id, cache_key, data)
VALUES (".$this->db->now().", ?, ?, ?)",
$_SESSION['user_id'],
$key,
$data);
}
}
/**
* @access private
*/
function _clear_cache_record($key)
{
$this->db->query(
"DELETE FROM ".get_table_name('cache')."
WHERE user_id=?
AND cache_key=?",
$_SESSION['user_id'],
$key);
}
/* --------------------------------
* message caching methods
* --------------------------------*/
/**
* Checks if the cache is up-to-date
*
* @param string Mailbox name
* @param string Internal cache key
* @return int -3 = off, -2 = incomplete, -1 = dirty
*/
function check_cache_status($mailbox, $cache_key)
{
if (!$this->caching_enabled)
return -3;
$cache_index = $this->get_message_cache_index($cache_key, TRUE);
$msg_count = $this->_messagecount($mailbox);
$cache_count = count($cache_index);
// console("Cache check: $msg_count !== ".count($cache_index));
if ($cache_count==$msg_count)
{
// get highest index
$header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count");
$cache_uid = array_pop($cache_index);
// uids of highest message matches -> cache seems OK
if ($cache_uid == $header->uid)
return 1;
// cache is dirty
return -1;
}
// if cache count differs less than 10% report as dirty
else if (abs($msg_count - $cache_count) < $msg_count/10)
return -1;
else
return -2;
}
/**
* @access private
*/
function get_message_cache($key, $from, $to, $sort_field, $sort_order)
{
$cache_key = "$key:$from:$to:$sort_field:$sort_order";
$db_header_fields = array('idx', 'uid', 'subject', 'from', 'to', 'cc', 'date', 'size');
if (!in_array($sort_field, $db_header_fields))
$sort_field = 'idx';
if ($this->caching_enabled && !isset($this->cache[$cache_key]))
{
$this->cache[$cache_key] = array();
$sql_result = $this->db->limitquery(
"SELECT idx, uid, headers
FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
ORDER BY ".$this->db->quoteIdentifier($sort_field)." ".
strtoupper($sort_order),
$from,
$to-$from,
$_SESSION['user_id'],
$key);
while ($sql_arr = $this->db->fetch_assoc($sql_result))
{
$uid = $sql_arr['uid'];
$this->cache[$cache_key][$uid] = unserialize($sql_arr['headers']);
// featch headers if unserialize failed
if (empty($this->cache[$cache_key][$uid]))
$this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true);
}
}
return $this->cache[$cache_key];
}
/**
* @access private
*/
function &get_cached_message($key, $uid, $struct=false)
{
$internal_key = '__single_msg';
if ($this->caching_enabled && (!isset($this->cache[$internal_key][$uid]) ||
($struct && empty($this->cache[$internal_key][$uid]->structure))))
{
$sql_select = "idx, uid, headers" . ($struct ? ", structure" : '');
$sql_result = $this->db->query(
"SELECT $sql_select
FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
AND uid=?",
$_SESSION['user_id'],
$key,
$uid);
if ($sql_arr = $this->db->fetch_assoc($sql_result))
{
$this->cache[$internal_key][$uid] = unserialize($sql_arr['headers']);
if (is_object($this->cache[$internal_key][$uid]) && !empty($sql_arr['structure']))
$this->cache[$internal_key][$uid]->structure = unserialize($sql_arr['structure']);
}
}
return $this->cache[$internal_key][$uid];
}
/**
* @access private
*/
function get_message_cache_index($key, $force=FALSE, $sort_col='idx', $sort_order='ASC')
{
static $sa_message_index = array();
// empty key -> empty array
if (!$this->caching_enabled || empty($key))
return array();
if (!empty($sa_message_index[$key]) && !$force)
return $sa_message_index[$key];
$sa_message_index[$key] = array();
$sql_result = $this->db->query(
"SELECT idx, uid
FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
ORDER BY ".$this->db->quote_identifier($sort_col)." ".$sort_order,
$_SESSION['user_id'],
$key);
while ($sql_arr = $this->db->fetch_assoc($sql_result))
$sa_message_index[$key][$sql_arr['idx']] = $sql_arr['uid'];
return $sa_message_index[$key];
}
/**
* @access private
*/
function add_message_cache($key, $index, $headers, $struct=null)
{
if (empty($key) || !is_object($headers) || empty($headers->uid))
return;
// add to internal (fast) cache
$this->cache['__single_msg'][$headers->uid] = $headers;
$this->cache['__single_msg'][$headers->uid]->structure = $struct;
// no further caching
if (!$this->caching_enabled)
return;
// check for an existing record (probly headers are cached but structure not)
$sql_result = $this->db->query(
"SELECT message_id
FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
AND uid=?
AND del<>1",
$_SESSION['user_id'],
$key,
$headers->uid);
// update cache record
if ($sql_arr = $this->db->fetch_assoc($sql_result))
{
$this->db->query(
"UPDATE ".get_table_name('messages')."
SET idx=?, headers=?, structure=?
WHERE message_id=?",
$index,
serialize($headers),
is_object($struct) ? serialize($struct) : NULL,
$sql_arr['message_id']
);
}
else // insert new record
{
$this->db->query(
"INSERT INTO ".get_table_name('messages')."
(user_id, del, cache_key, created, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers, structure)
VALUES (?, 0, ?, ".$this->db->now().", ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?, ?)",
$_SESSION['user_id'],
$key,
$index,
$headers->uid,
(string)substr($this->decode_header($headers->subject, TRUE), 0, 128),
(string)substr($this->decode_header($headers->from, TRUE), 0, 128),
(string)substr($this->decode_header($headers->to, TRUE), 0, 128),
(string)substr($this->decode_header($headers->cc, TRUE), 0, 128),
(int)$headers->size,
serialize($headers),
is_object($struct) ? serialize($struct) : NULL
);
}
}
/**
* @access private
*/
function remove_message_cache($key, $index)
{
if (!$this->caching_enabled)
return;
$this->db->query(
"DELETE FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
AND idx=?",
$_SESSION['user_id'],
$key,
$index);
}
/**
* @access private
*/
function clear_message_cache($key, $start_index=1)
{
if (!$this->caching_enabled)
return;
$this->db->query(
"DELETE FROM ".get_table_name('messages')."
WHERE user_id=?
AND cache_key=?
AND idx>=?",
$_SESSION['user_id'],
$key,
$start_index);
}
/* --------------------------------
* encoding/decoding methods
* --------------------------------*/
/**
* Split an address list into a structured array list
*
* @param string Input string
* @param int List only this number of addresses
* @param boolean Decode address strings
* @return array Indexed list of addresses
*/
function decode_address_list($input, $max=null, $decode=true)
{
$a = $this->_parse_address_list($input, $decode);
$out = array();
// Special chars as defined by RFC 822 need to in quoted string (or escaped).
$special_chars = '[\(\)\<\>\\\.\[\]@,;:"]';
if (!is_array($a))
return $out;
$c = count($a);
$j = 0;
foreach ($a as $val)
{
$j++;
$address = $val['address'];
$name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', trim($val['name']));
if ($name && $address && $name != $address)
$string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
else if ($address)
$string = $address;
else if ($name)
$string = $name;
$out[$j] = array('name' => $name,
'mailto' => $address,
'string' => $string);
if ($max && $j==$max)
break;
}
return $out;
}
/**
* Decode a message header value
*
* @param string Header value
* @param boolean Remove quotes if necessary
* @return string Decoded string
*/
function decode_header($input, $remove_quotes=FALSE)
{
$str = rcube_imap::decode_mime_string((string)$input, $this->default_charset);
if ($str{0}=='"' && $remove_quotes)
$str = str_replace('"', '', $str);
return $str;
}
/**
* Decode a mime-encoded string to internal charset
*
* @param string Header value
* @param string Fallback charset if none specified
* @return string Decoded string
* @static
*/
function decode_mime_string($input, $fallback=null)
{
// Initialize variable
$out = '';
// Iterate instead of recursing, this way if there are too many values we don't have stack overflows
// rfc: all line breaks or other characters not found
// in the Base64 Alphabet must be ignored by decoding software
// delete all blanks between MIME-lines, differently we can
// receive unnecessary blanks and broken utf-8 symbols
$input = preg_replace("/\?=\s+=\?/", '?==?', $input);
// Check if there is stuff to decode
if (strpos($input, '=?') !== false) {
// Loop through the string to decode all occurences of =? ?= into the variable $out
while(($pos = strpos($input, '=?')) !== false) {
// Append everything that is before the text to be decoded
$out .= substr($input, 0, $pos);
// Get the location of the text to decode
$end_cs_pos = strpos($input, "?", $pos+2);
$end_en_pos = strpos($input, "?", $end_cs_pos+1);
$end_pos = strpos($input, "?=", $end_en_pos+1);
// Extract the encoded string
$encstr = substr($input, $pos+2, ($end_pos-$pos-2));
// Extract the remaining string
$input = substr($input, $end_pos+2);
// Decode the string fragement
$out .= rcube_imap::_decode_mime_string_part($encstr);
}
// Deocde the rest (if any)
if (strlen($input) != 0)
$out .= rcube_imap::decode_mime_string($input, $fallback);
// return the results
return $out;
}
// no encoding information, use fallback
return rcube_charset_convert($input,
!empty($fallback) ? $fallback : rcmail::get_instance()->config->get('default_charset', 'ISO-8859-1'));
}
/**
* Decode a part of a mime-encoded string
*
* @access private
*/
function _decode_mime_string_part($str)
{
$a = explode('?', $str);
$count = count($a);
// should be in format "charset?encoding?base64_string"
if ($count >= 3)
{
for ($i=2; $i<$count; $i++)
$rest.=$a[$i];
if (($a[1]=="B")||($a[1]=="b"))
$rest = base64_decode($rest);
else if (($a[1]=="Q")||($a[1]=="q"))
{
$rest = str_replace("_", " ", $rest);
$rest = quoted_printable_decode($rest);
}
return rcube_charset_convert($rest, $a[0]);
}
else
return $str; // we dont' know what to do with this
}
/**
* Decode a mime part
*
* @param string Input string
* @param string Part encoding
* @return string Decoded string
* @access private
*/
function mime_decode($input, $encoding='7bit')
{
switch (strtolower($encoding))
{
case '7bit':
return $input;
break;
case 'quoted-printable':
return quoted_printable_decode($input);
break;
case 'base64':
return base64_decode($input);
break;
default:
return $input;
}
}
/**
* Convert body charset to UTF-8 according to the ctype_parameters
*
* @param string Part body to decode
* @param string Charset to convert from
* @return string Content converted to internal charset
*/
function charset_decode($body, $ctype_param)
{
if (is_array($ctype_param) && !empty($ctype_param['charset']))
return rcube_charset_convert($body, $ctype_param['charset']);
// defaults to what is specified in the class header
return rcube_charset_convert($body, $this->default_charset);
}
/**
* Translate UID to message ID
*
* @param int Message UID
* @param string Mailbox name
* @return int Message ID
*/
function get_id($uid, $mbox_name=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_uid2id($uid, $mailbox);
}
/**
* Translate message number to UID
*
* @param int Message ID
* @param string Mailbox name
* @return int Message UID
*/
function get_uid($id,$mbox_name=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
return $this->_id2uid($id, $mailbox);
}
/* --------------------------------
* private methods
* --------------------------------*/
/**
* @access private
*/
function _mod_mailbox($mbox_name, $mode='in')
{
if ((!empty($this->root_ns) && $this->root_ns == $mbox_name) || $mbox_name == 'INBOX')
return $mbox_name;
if (!empty($this->root_dir) && $mode=='in')
$mbox_name = $this->root_dir.$this->delimiter.$mbox_name;
else if (strlen($this->root_dir) && $mode=='out')
$mbox_name = substr($mbox_name, strlen($this->root_dir)+1);
return $mbox_name;
}
/**
* Validate the given input and save to local properties
* @access private
*/
function _set_sort_order($sort_field, $sort_order)
{
if ($sort_field != null)
$this->sort_field = asciiwords($sort_field);
if ($sort_order != null)
$this->sort_order = strtoupper($sort_order) == 'DESC' ? 'DESC' : 'ASC';
}
/**
* Sort mailboxes first by default folders and then in alphabethical order
* @access private
*/
function _sort_mailbox_list($a_folders)
{
$a_out = $a_defaults = $folders = array();
$delimiter = $this->get_hierarchy_delimiter();
// find default folders and skip folders starting with '.'
foreach ($a_folders as $i => $folder)
{
if ($folder{0}=='.')
continue;
if (($p = array_search(strtolower($folder), $this->default_folders_lc)) !== false && !$a_defaults[$p])
$a_defaults[$p] = $folder;
else
$folders[$folder] = rc_strtolower(rcube_charset_convert($folder, 'UTF-7'));
}
asort($folders, SORT_LOCALE_STRING);
ksort($a_defaults);
$folders = array_merge($a_defaults, array_keys($folders));
// finally we must rebuild the list to move
// subfolders of default folders to their place...
// ...also do this for the rest of folders because
// asort() is not properly sorting case sensitive names
while (list($key, $folder) = each($folders)) {
$a_out[] = $folder;
unset($folders[$key]);
foreach ($folders as $idx => $f) {
if (strpos($f, $folder.$delimiter) === 0) {
$a_out[] = $f;
unset($folders[$idx]);
}
}
reset($folders);
}
return $a_out;
}
/**
* @access private
*/
function _uid2id($uid, $mbox_name=NULL)
{
if (!$mbox_name)
$mbox_name = $this->mailbox;
if (!isset($this->uid_id_map[$mbox_name][$uid]))
$this->uid_id_map[$mbox_name][$uid] = iil_C_UID2ID($this->conn, $mbox_name, $uid);
return $this->uid_id_map[$mbox_name][$uid];
}
/**
* @access private
*/
function _id2uid($id, $mbox_name=NULL)
{
if (!$mbox_name)
$mbox_name = $this->mailbox;
$index = array_flip((array)$this->uid_id_map[$mbox_name]);
if (isset($index[$id]))
$uid = $index[$id];
else
{
$uid = iil_C_ID2UID($this->conn, $mbox_name, $id);
$this->uid_id_map[$mbox_name][$uid] = $id;
}
return $uid;
}
/**
* Subscribe/unsubscribe a list of mailboxes and update local cache
* @access private
*/
function _change_subscription($a_mboxes, $mode)
{
$updated = FALSE;
if (is_array($a_mboxes))
foreach ($a_mboxes as $i => $mbox_name)
{
$mailbox = $this->_mod_mailbox($mbox_name);
$a_mboxes[$i] = $mailbox;
if ($mode=='subscribe')
$result = iil_C_Subscribe($this->conn, $mailbox);
else if ($mode=='unsubscribe')
$result = iil_C_UnSubscribe($this->conn, $mailbox);
if ($result>=0)
$updated = TRUE;
}
// get cached mailbox list
if ($updated)
{
$a_mailbox_cache = $this->get_cache('mailboxes');
if (!is_array($a_mailbox_cache))
return $updated;
// modify cached list
if ($mode=='subscribe')
$a_mailbox_cache = array_merge($a_mailbox_cache, $a_mboxes);
else if ($mode=='unsubscribe')
$a_mailbox_cache = array_diff($a_mailbox_cache, $a_mboxes);
// write mailboxlist to cache
$this->update_cache('mailboxes', $this->_sort_mailbox_list($a_mailbox_cache));
}
return $updated;
}
/**
* Increde/decrese messagecount for a specific mailbox
* @access private
*/
function _set_messagecount($mbox_name, $mode, $increment)
{
$a_mailbox_cache = FALSE;
$mailbox = $mbox_name ? $mbox_name : $this->mailbox;
$mode = strtoupper($mode);
$a_mailbox_cache = $this->get_cache('messagecount');
if (!is_array($a_mailbox_cache[$mailbox]) || !isset($a_mailbox_cache[$mailbox][$mode]) || !is_numeric($increment))
return FALSE;
// add incremental value to messagecount
$a_mailbox_cache[$mailbox][$mode] += $increment;
// there's something wrong, delete from cache
if ($a_mailbox_cache[$mailbox][$mode] < 0)
unset($a_mailbox_cache[$mailbox][$mode]);
// write back to cache
$this->update_cache('messagecount', $a_mailbox_cache);
return TRUE;
}
/**
* Remove messagecount of a specific mailbox from cache
* @access private
*/
function _clear_messagecount($mbox_name='')
{
$a_mailbox_cache = FALSE;
$mailbox = $mbox_name ? $mbox_name : $this->mailbox;
$a_mailbox_cache = $this->get_cache('messagecount');
if (is_array($a_mailbox_cache[$mailbox]))
{
unset($a_mailbox_cache[$mailbox]);
$this->update_cache('messagecount', $a_mailbox_cache);
}
}
/**
* Split RFC822 header string into an associative array
* @access private
*/
function _parse_headers($headers)
{
$a_headers = array();
$lines = explode("\n", $headers);
$c = count($lines);
for ($i=0; $i<$c; $i++)
{
if ($p = strpos($lines[$i], ': '))
{
$field = strtolower(substr($lines[$i], 0, $p));
$value = trim(substr($lines[$i], $p+1));
if (!empty($value))
$a_headers[$field] = $value;
}
}
return $a_headers;
}
/**
* @access private
*/
function _parse_address_list($str, $decode=true)
{
// remove any newlines and carriage returns before
$a = $this->_explode_quoted_string('[,;]', preg_replace( "/[\r\n]/", " ", $str));
$result = array();
foreach ($a as $key => $val)
{
$val = preg_replace("/([\"\w])</", "$1 <", $val);
$sub_a = $this->_explode_quoted_string(' ', $decode ? $this->decode_header($val) : $val);
$result[$key]['name'] = '';
foreach ($sub_a as $k => $v)
{
if (strpos($v, '@') > 0)
$result[$key]['address'] = str_replace('<', '', str_replace('>', '', $v));
else
$result[$key]['name'] .= (empty($result[$key]['name'])?'':' ').str_replace("\"",'',stripslashes($v));
}
if (empty($result[$key]['name']))
$result[$key]['name'] = $result[$key]['address'];
}
return $result;
}
/**
* @access private
*/
function _explode_quoted_string($delimiter, $string)
{
$result = array();
$strlen = strlen($string);
for ($q=$p=$i=0; $i < $strlen; $i++)
{
if ($string{$i} == "\"" && $string{$i-1} != "\\")
$q = $q ? false : true;
else if (!$q && preg_match("/$delimiter/", $string{$i}))
{
$result[] = substr($string, $p, $i - $p);
$p = $i + 1;
}
}
$result[] = substr($string, $p);
return $result;
}
} // end class rcube_imap
/**
* Class representing a message part
*
* @package Mail
*/
class rcube_message_part
{
var $mime_id = '';
var $ctype_primary = 'text';
var $ctype_secondary = 'plain';
var $mimetype = 'text/plain';
var $disposition = '';
var $filename = '';
var $encoding = '8bit';
var $charset = '';
var $size = 0;
var $headers = array();
var $d_parameters = array();
var $ctype_parameters = array();
}
/**
* Class for sorting an array of iilBasicHeader objects in a predetermined order.
*
* @package Mail
* @author Eric Stadtherr
*/
class rcube_header_sorter
{
var $sequence_numbers = array();
/**
* Set the predetermined sort order.
*
* @param array Numerically indexed array of IMAP message sequence numbers
*/
function set_sequence_numbers($seqnums)
{
$this->sequence_numbers = array_flip($seqnums);
}
/**
* Sort the array of header objects
*
* @param array Array of iilBasicHeader objects indexed by UID
*/
function sort_headers(&$headers)
{
/*
* uksort would work if the keys were the sequence number, but unfortunately
* the keys are the UIDs. We'll use uasort instead and dereference the value
* to get the sequence number (in the "id" field).
*
* uksort($headers, array($this, "compare_seqnums"));
*/
uasort($headers, array($this, "compare_seqnums"));
}
/**
* Sort method called by uasort()
*/
function compare_seqnums($a, $b)
{
// First get the sequence number from the header object (the 'id' field).
$seqa = $a->id;
$seqb = $b->id;
// then find each sequence number in my ordered list
$posa = isset($this->sequence_numbers[$seqa]) ? intval($this->sequence_numbers[$seqa]) : -1;
$posb = isset($this->sequence_numbers[$seqb]) ? intval($this->sequence_numbers[$seqb]) : -1;
// return the relative position as the comparison value
return $posa - $posb;
}
}
/**
* Add quoted-printable encoding to a given string
*
* @param string String to encode
* @param int Add new line after this number of characters
* @param boolean True if spaces should be converted into =20
* @return string Encoded string
*/
function quoted_printable_encode($input, $line_max=76, $space_conv=false)
{
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split("/(?:\r\n|\r|\n)/", $input);
$eol = "\r\n";
$escape = "=";
$output = "";
while( list(, $line) = each($lines))
{
//$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary
$linlen = strlen($line);
$newline = "";
for($i = 0; $i < $linlen; $i++)
{
$c = substr( $line, $i, 1 );
$dec = ord( $c );
if ( ( $i == 0 ) && ( $dec == 46 ) ) // convert first point in the line into =2E
{
$c = "=2E";
}
if ( $dec == 32 )
{
if ( $i == ( $linlen - 1 ) ) // convert space at eol only
{
$c = "=20";
}
else if ( $space_conv )
{
$c = "=20";
}
}
else if ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) // always encode "\t", which is *not* required
{
$h2 = floor($dec/16);
$h1 = floor($dec%16);
$c = $escape.$hex["$h2"].$hex["$h1"];
}
if ( (strlen($newline) + strlen($c)) >= $line_max ) // CRLF is not counted
{
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
$newline = "";
// check if newline first character will be point or not
if ( $dec == 46 )
{
$c = "=2E";
}
}
$newline .= $c;
} // end of for
$output .= $newline.$eol;
} // end of while
return trim($output);
}
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 9f94194c4..1b61770c0 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -1,1068 +1,1068 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/include/rcube_template.php |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2006-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Class to handle HTML page output using a skin template. |
| Extends rcube_html_page class from rcube_shared.inc |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
/**
* Class to create HTML page output using a skin template
*
* @package View
* @todo Documentation
* @uses rcube_html_page
*/
class rcube_template extends rcube_html_page
{
var $app;
var $config;
var $framed = false;
var $pagetitle = '';
var $env = array();
var $js_env = array();
var $js_commands = array();
var $object_handlers = array();
public $type = 'html';
public $ajax_call = false;
/**
* Constructor
*
* @todo Use jQuery's $(document).ready() here.
* @todo Replace $this->config with the real rcube_config object
*/
public function __construct($task, $framed = false)
{
parent::__construct();
$this->app = rcmail::get_instance();
$this->config = $this->app->config->all();
//$this->framed = $framed;
$this->set_env('task', $task);
// load the correct skin (in case user-defined)
$this->set_skin($this->config['skin']);
// add common javascripts
$javascript = 'var '.JS_OBJECT_NAME.' = new rcube_webmail();';
// don't wait for page onload. Call init at the bottom of the page (delayed)
$javascript_foot = "if (window.call_init)\n call_init('".JS_OBJECT_NAME."');";
$this->add_script($javascript, 'head_top');
$this->add_script($javascript_foot, 'foot');
$this->scripts_path = 'program/js/';
$this->include_script('common.js');
$this->include_script('app.js');
// register common UI objects
$this->add_handlers(array(
'loginform' => array($this, 'login_form'),
'username' => array($this, 'current_username'),
'message' => array($this, 'message_container'),
'charsetselector' => array($this, 'charset_selector'),
));
}
/**
* Set environment variable
*
* @param string Property name
* @param mixed Property value
* @param boolean True if this property should be added to client environment
*/
public function set_env($name, $value, $addtojs = true)
{
$this->env[$name] = $value;
if ($addtojs || isset($this->js_env[$name])) {
$this->js_env[$name] = $value;
}
}
/**
* Set page title variable
*/
public function set_pagetitle($title)
{
$this->pagetitle = $title;
}
/**
* Set skin
*/
public function set_skin($skin)
{
if (!empty($skin) && is_dir('skins/'.$skin) && is_readable('skins/'.$skin))
$skin_path = 'skins/'.$skin;
else
$skin_path = $this->config['skin_path'] ? $this->config['skin_path'] : 'skins/default';
$this->app->config->set('skin_path', $skin_path);
$this->config['skin_path'] = $skin_path;
}
/**
* Check if a specific template exists
*
* @param string Template name
* @return boolean True if template exists
*/
public function template_exists($name)
{
$filename = $this->config['skin_path'] . '/templates/' . $name . '.html';
return (is_file($filename) && is_readable($filename));
}
/**
* Register a template object handler
*
* @param string Object name
* @param string Function name to call
* @return void
*/
public function add_handler($obj, $func)
{
$this->object_handlers[$obj] = $func;
}
/**
* Register a list of template object handlers
*
* @param array Hash array with object=>handler pairs
* @return void
*/
public function add_handlers($arr)
{
$this->object_handlers = array_merge($this->object_handlers, $arr);
}
/**
* Register a GUI object to the client script
*
* @param string Object name
* @param string Object ID
* @return void
*/
public function add_gui_object($obj, $id)
{
$this->add_script(JS_OBJECT_NAME.".gui_object('$obj', '$id');");
}
/**
* Call a client method
*
* @param string Method to call
* @param ... Additional arguments
*/
public function command()
{
$this->js_commands[] = func_get_args();
}
/**
* Add a localized label to the client environment
*/
public function add_label()
{
$arg_list = func_get_args();
foreach ($arg_list as $i => $name) {
$this->command('add_label', $name, rcube_label($name));
}
}
/**
* Invoke display_message command
*
* @param string Message to display
* @param string Message type [notice|confirm|error]
* @param array Key-value pairs to be replaced in localized text
* @uses self::command()
*/
public function show_message($message, $type='notice', $vars=NULL)
{
$this->command(
'display_message',
rcube_label(array('name' => $message, 'vars' => $vars)),
$type);
}
/**
* Delete all stored env variables and commands
*
* @return void
* @uses rcube_html::reset()
* @uses self::$env
* @uses self::$js_env
* @uses self::$js_commands
* @uses self::$object_handlers
*/
public function reset()
{
$this->env = array();
$this->js_env = array();
$this->js_commands = array();
$this->object_handlers = array();
parent::reset();
}
/**
* Redirect to a certain url
*
* @param mixed Either a string with the action or url parameters as key-value pairs
* @see rcmail::url()
*/
public function redirect($p = array())
{
$location = $this->app->url($p);
header('Location: ' . $location);
exit;
}
/**
* Send the request output to the client.
* This will either parse a skin tempalte or send an AJAX response
*
* @param string Template name
* @param boolean True if script should terminate (default)
*/
public function send($templ = null, $exit = true)
{
if ($templ != 'iframe') {
$this->parse($templ, false);
}
else {
$this->framed = $templ == 'iframe' ? true : $this->framed;
$this->write();
}
if ($exit) {
exit;
}
}
/**
* Process template and write to stdOut
*
* @param string HTML template
* @see rcube_html_page::write()
* @override
*/
public function write($template = '')
{
// unlock interface after iframe load
if ($this->framed) {
array_unshift($this->js_commands, array('set_busy', false));
}
// write all env variables to client
$js = $this->framed ? "if(window.parent) {\n" : '';
$js .= $this->get_js_commands() . ($this->framed ? ' }' : '');
$this->add_script($js, 'head_top');
// call super method
parent::write($template, $this->config['skin_path']);
}
/**
* Parse a specific skin template and deliver to stdout
*
* Either returns nothing, or exists hard (exit();)
*
* @param string Template name
* @param boolean Exit script
* @return void
* @link http://php.net/manual/en/function.exit.php
*/
private function parse($name = 'main', $exit = true)
{
$skin_path = $this->config['skin_path'];
$path = "$skin_path/templates/$name.html";
// read template file
if (($templ = @file_get_contents($path)) === false) {
raise_error(array(
'code' => 501,
'type' => 'php',
'line' => __LINE__,
'file' => __FILE__,
'message' => 'Error loading template for '.$name
), true, true);
return false;
}
// parse for specialtags
$output = $this->parse_conditions($templ);
$output = $this->parse_xml($output);
// add debug console
if ($this->config['debug_level'] & 8) {
- $this->add_footer('<div style="position:absolute;top:5px;left:5px;width:400px;padding:0.2em;background:white;opacity:0.8;z-index:9000">
+ $this->add_footer('<div style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;opacity:0.8;filter:alpha(opacity=80);z-index:9000">
<a href="#toggle" onclick="con=document.getElementById(\'dbgconsole\');con.style.display=(con.style.display==\'none\'?\'block\':\'none\');return false">console</a>
- <form action="/" name="debugform"><textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:x-small"></textarea></form></div>'
+ <form action="/" name="debugform" style="display:inline"><textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:x-small"></textarea></form></div>'
);
}
$output = $this->parse_with_globals($output);
$this->write(trim($output), $skin_path);
if ($exit) {
exit;
}
}
/**
* Return executable javascript code for all registered commands
*
* @return string $out
*/
private function get_js_commands()
{
$out = '';
if (!$this->framed && !empty($this->js_env)) {
$out .= JS_OBJECT_NAME . '.set_env('.json_serialize($this->js_env).");\n";
}
foreach ($this->js_commands as $i => $args) {
$method = array_shift($args);
foreach ($args as $i => $arg) {
$args[$i] = json_serialize($arg);
}
$parent = $this->framed || preg_match('/^parent\./', $method);
$out .= sprintf(
"%s.%s(%s);\n",
($parent ? 'parent.' : '') . JS_OBJECT_NAME,
preg_replace('/^parent\./', '', $method),
implode(',', $args)
);
}
// add command to set page title
if ($this->ajax_call && !empty($this->pagetitle)) {
$out .= sprintf(
"this.set_pagetitle('%s');\n",
JQ((!empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '') . $this->pagetitle)
);
}
return $out;
}
/**
* Make URLs starting with a slash point to skin directory
*
* @param string Input string
* @return string
*/
public function abs_url($str)
{
return preg_replace('/^\//', $this->config['skin_path'].'/', $str);
}
/***** Template parsing methods *****/
/**
* Replace all strings ($varname)
* with the content of the according global variable.
*/
private function parse_with_globals($input)
{
$GLOBALS['__comm_path'] = Q($this->app->comm_path);
return preg_replace('/\$(__[a-z0-9_\-]+)/e', '$GLOBALS["\\1"]', $input);
}
/**
* Public wrapper to dipp into template parsing.
*
* @param string $input
* @return string
* @uses rcube_template::parse_xml()
* @since 0.1-rc1
*/
public function just_parse($input)
{
return $this->parse_xml($input);
}
/**
* Parse for conditional tags
*
* @param string $input
* @return string
*/
private function parse_conditions($input)
{
$matches = preg_split('/<roundcube:(if|elseif|else|endif)\s+([^>]+)>/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($matches && count($matches) == 4) {
if (preg_match('/^(else|endif)$/i', $matches[1])) {
return $matches[0] . $this->parse_conditions($matches[3]);
}
$attrib = parse_attrib_string($matches[2]);
if (isset($attrib['condition'])) {
$condmet = $this->check_condition($attrib['condition']);
$submatches = preg_split('/<roundcube:(elseif|else|endif)\s+([^>]+)>/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
if ($condmet) {
$result = $submatches[0];
$result.= ($submatches[1] != 'endif' ? preg_replace('/.*<roundcube:endif\s+[^>]+>/Uis', '', $submatches[3], 1) : $submatches[3]);
}
else {
$result = "<roundcube:$submatches[1] $submatches[2]>" . $submatches[3];
}
return $matches[0] . $this->parse_conditions($result);
}
raise_error(array(
'code' => 500,
'type' => 'php',
'line' => __LINE__,
'file' => __FILE__,
'message' => "Unable to parse conditional tag " . $matches[2]
), true, false);
}
return $input;
}
/**
* Determines if a given condition is met
*
* @todo Get rid off eval() once I understand what this does.
* @todo Extend this to allow real conditions, not just "set"
* @param string Condition statement
* @return boolean True if condition is met, False is not
*/
private function check_condition($condition)
{
$condition = preg_replace(
array(
'/session:([a-z0-9_]+)/i',
'/config:([a-z0-9_]+)/i',
'/env:([a-z0-9_]+)/i',
'/request:([a-z0-9_]+)/ie'
),
array(
"\$_SESSION['\\1']",
"\$this->config['\\1']",
"\$this->env['\\1']",
"get_input_value('\\1', RCUVE_INPUT_GPC)"
),
$condition);
return eval("return (".$condition.");");
}
/**
* Search for special tags in input and replace them
* with the appropriate content
*
* @param string Input string to parse
* @return string Altered input string
* @todo Use DOM-parser to traverse template HTML
* @todo Maybe a cache.
*/
private function parse_xml($input)
{
return preg_replace_callback('/<roundcube:([-_a-z]+)\s+([^>]+)>/Ui', array($this, 'xml_command_callback'), $input);
}
/**
* This is a callback function for preg_replace_callback (see #1485286)
* It's only purpose is to reconfigure parameters for xml_command, so that the signature isn't disturbed
*/
private function xml_command_callback($matches)
{
$str_attrib = isset($matches[2]) ? $matches[2] : '';
$add_attrib = isset($matches[3]) ? $matches[3] : array();
$command = $matches[1];
//matches[0] is the entire matched portion of the string
return $this->xml_command($command, $str_attrib, $add_attrib);
}
/**
* Convert a xml command tag into real content
*
* @param string Tag command: object,button,label, etc.
* @param string Attribute string
* @return string Tag/Object content
*/
private function xml_command($command, $str_attrib, $add_attrib = array())
{
$command = strtolower($command);
$attrib = parse_attrib_string($str_attrib) + $add_attrib;
// empty output if required condition is not met
if (!empty($attrib['condition']) && !$this->check_condition($attrib['condition'])) {
return '';
}
// execute command
switch ($command) {
// return a button
case 'button':
if ($attrib['name'] || $attrib['command']) {
return $this->button($attrib);
}
break;
// show a label
case 'label':
if ($attrib['name'] || $attrib['command']) {
return Q(rcube_label($attrib + array('vars' => array('product' => $this->config['product_name']))));
}
break;
// include a file
case 'include':
$path = realpath($this->config['skin_path'].$attrib['file']);
if (is_readable($path)) {
if ($this->config['skin_include_php']) {
$incl = $this->include_php($path);
}
else {
$incl = file_get_contents($path);
}
return $this->parse_xml($incl);
}
break;
case 'plugin.include':
//rcube::tfk_debug(var_export($this->config['skin_path'], true));
$path = realpath($this->config['skin_path'].$attrib['file']);
if (!$path) {
//rcube::tfk_debug("Does not exist:");
//rcube::tfk_debug($this->config['skin_path']);
//rcube::tfk_debug($attrib['file']);
//rcube::tfk_debug($path);
}
$incl = file_get_contents($path);
if ($incl) {
return $this->parse_xml($incl);
}
break;
// return code for a specific application object
case 'object':
$object = strtolower($attrib['name']);
// we are calling a class/method
if (($handler = $this->object_handlers[$object]) && is_array($handler)) {
if ((is_object($handler[0]) && method_exists($handler[0], $handler[1])) ||
(is_string($handler[0]) && class_exists($handler[0])))
return call_user_func($handler, $attrib);
}
else if (function_exists($handler)) {
// execute object handler function
return call_user_func($handler, $attrib);
}
if ($object=='productname') {
$name = !empty($this->config['product_name']) ? $this->config['product_name'] : 'RoundCube Webmail';
return Q($name);
}
if ($object=='version') {
$ver = (string)RCMAIL_VERSION;
if (is_file(INSTALL_PATH . '.svn/entries')) {
if (preg_match('/Revision:\s(\d+)/', @shell_exec('svn info'), $regs))
$ver .= ' [SVN r'.$regs[1].']';
}
return $ver;
}
if ($object=='pagetitle') {
$task = $this->env['task'];
$title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '';
if (!empty($this->pagetitle)) {
$title .= $this->pagetitle;
}
else if ($task == 'login') {
$title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name'])));
}
else {
$title .= ucfirst($task);
}
return Q($title);
}
break;
// return variable
case 'var':
$var = explode(':', $attrib['name']);
$name = $var[1];
$value = '';
switch ($var[0]) {
case 'env':
$value = $this->env[$name];
break;
case 'config':
$value = $this->config[$name];
if (is_array($value) && $value[$_SESSION['imap_host']]) {
$value = $value[$_SESSION['imap_host']];
}
break;
case 'request':
$value = get_input_value($name, RCUBE_INPUT_GPC);
break;
case 'session':
$value = $_SESSION[$name];
break;
}
if (is_array($value)) {
$value = implode(', ', $value);
}
return Q($value);
break;
}
return '';
}
/**
* Include a specific file and return it's contents
*
* @param string File path
* @return string Contents of the processed file
*/
private function include_php($file)
{
ob_start();
include $file;
$out = ob_get_contents();
ob_end_clean();
return $out;
}
/**
* Create and register a button
*
* @param array Named button attributes
* @return string HTML button
* @todo Remove all inline JS calls and use jQuery instead.
* @todo Remove all sprintf()'s - they are pretty, but also slow.
*/
public function button($attrib)
{
static $sa_buttons = array();
static $s_button_count = 100;
// these commands can be called directly via url
$a_static_commands = array('compose', 'list');
if (!($attrib['command'] || $attrib['name'])) {
return '';
}
$browser = new rcube_browser();
// try to find out the button type
if ($attrib['type']) {
$attrib['type'] = strtolower($attrib['type']);
}
else {
$attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $attrib['imageact']) ? 'image' : 'link';
}
$command = $attrib['command'];
// take the button from the stack
if ($attrib['name'] && $sa_buttons[$attrib['name']]) {
$attrib = $sa_buttons[$attrib['name']];
}
else if($attrib['image'] || $attrib['imageact'] || $attrib['imagepas'] || $attrib['class']) {
// add button to button stack
if (!$attrib['name']) {
$attrib['name'] = $command;
}
if (!$attrib['image']) {
$attrib['image'] = $attrib['imagepas'] ? $attrib['imagepas'] : $attrib['imageact'];
}
$sa_buttons[$attrib['name']] = $attrib;
}
else if ($command && $sa_buttons[$command]) {
// get saved button for this command/name
$attrib = $sa_buttons[$command];
}
// set border to 0 because of the link arround the button
if ($attrib['type']=='image' && !isset($attrib['border'])) {
$attrib['border'] = 0;
}
if (!$attrib['id']) {
$attrib['id'] = sprintf('rcmbtn%d', $s_button_count++);
}
// get localized text for labels and titles
if ($attrib['title']) {
$attrib['title'] = Q(rcube_label($attrib['title']));
}
if ($attrib['label']) {
$attrib['label'] = Q(rcube_label($attrib['label']));
}
if ($attrib['alt']) {
$attrib['alt'] = Q(rcube_label($attrib['alt']));
}
// set title to alt attribute for IE browsers
if ($browser->ie && $attrib['title'] && !$attrib['alt']) {
$attrib['alt'] = $attrib['title'];
unset($attrib['title']);
}
// add empty alt attribute for XHTML compatibility
if (!isset($attrib['alt'])) {
$attrib['alt'] = '';
}
// register button in the system
if ($attrib['command']) {
$this->add_script(sprintf(
"%s.register_button('%s', '%s', '%s', '%s', '%s', '%s');",
JS_OBJECT_NAME,
$command,
$attrib['id'],
$attrib['type'],
$attrib['imageact'] ? $this->abs_url($attrib['imageact']) : $attrib['classact'],
$attrib['imagesel'] ? $this->abs_url($attrib['imagesel']) : $attrib['classsel'],
$attrib['imageover'] ? $this->abs_url($attrib['imageover']) : ''
));
// make valid href to specific buttons
if (in_array($attrib['command'], rcmail::$main_tasks)) {
$attrib['href'] = Q(rcmail_url(null, null, $attrib['command']));
}
else if (in_array($attrib['command'], $a_static_commands)) {
$attrib['href'] = Q(rcmail_url($attrib['command']));
}
}
// overwrite attributes
if (!$attrib['href']) {
$attrib['href'] = '#';
}
if ($command) {
$attrib['onclick'] = sprintf(
"return %s.command('%s','%s',this)",
JS_OBJECT_NAME,
$command,
$attrib['prop']
);
}
if ($command && $attrib['imageover']) {
$attrib['onmouseover'] = sprintf(
"return %s.button_over('%s','%s')",
JS_OBJECT_NAME,
$command,
$attrib['id']
);
$attrib['onmouseout'] = sprintf(
"return %s.button_out('%s','%s')",
JS_OBJECT_NAME,
$command,
$attrib['id']
);
}
if ($command && $attrib['imagesel']) {
$attrib['onmousedown'] = sprintf(
"return %s.button_sel('%s','%s')",
JS_OBJECT_NAME,
$command,
$attrib['id']
);
$attrib['onmouseup'] = sprintf(
"return %s.button_out('%s','%s')",
JS_OBJECT_NAME,
$command,
$attrib['id']
);
}
$out = '';
// generate image tag
if ($attrib['type']=='image') {
$attrib_str = html::attrib_string(
$attrib,
array(
'style', 'class', 'id', 'width',
'height', 'border', 'hspace',
'vspace', 'align', 'alt', 'tabindex'
)
);
$btn_content = sprintf('<img src="%s"%s />', $this->abs_url($attrib['image']), $attrib_str);
if ($attrib['label']) {
$btn_content .= ' '.$attrib['label'];
}
$link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'title');
}
else if ($attrib['type']=='link') {
$btn_content = $attrib['label'] ? $attrib['label'] : $attrib['command'];
$link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex');
}
else if ($attrib['type']=='input') {
$attrib['type'] = 'button';
if ($attrib['label']) {
$attrib['value'] = $attrib['label'];
}
$attrib_str = html::attrib_string(
$attrib,
array(
'type', 'value', 'onclick',
'id', 'class', 'style', 'tabindex'
)
);
$out = sprintf('<input%s disabled="disabled" />', $attrib_str);
}
// generate html code for button
if ($btn_content) {
$attrib_str = html::attrib_string($attrib, $link_attrib);
$out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
}
return $out;
}
/* ************* common functions delivering gui objects ************** */
/**
* Create a form tag with the necessary hidden fields
*
* @param array Named tag parameters
* @return string HTML code for the form
*/
public function form_tag($attrib, $content = null)
{
if ($this->framed) {
$hiddenfield = new html_hiddenfield(array('name' => '_framed', 'value' => '1'));
$hidden = $hiddenfield->show();
}
if (!$content)
$attrib['noclose'] = true;
return html::tag('form',
$attrib + array('action' => "./", 'method' => "get"),
$hidden . $content);
}
/**
* GUI object 'username'
* Showing IMAP username of the current session
*
* @param array Named tag parameters (currently not used)
* @return string HTML code for the gui object
*/
public function current_username($attrib)
{
static $username;
// alread fetched
if (!empty($username)) {
return $username;
}
// get e-mail address form default identity
if ($sql_arr = $this->app->user->get_identity()) {
$username = $sql_arr['email'];
}
else {
$username = $this->app->user->get_username();
}
return $username;
}
/**
* GUI object 'loginform'
* Returns code for the webmail login form
*
* @param array Named parameters
* @return string HTML code for the gui object
*/
private function login_form($attrib)
{
$default_host = $this->config['default_host'];
$_SESSION['temp'] = true;
$input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30) + $attrib);
$input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'size' => 30) + $attrib);
$input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
$input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
$input_host = null;
if (is_array($default_host)) {
$input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
foreach ($default_host as $key => $value) {
if (!is_array($value)) {
$input_host->add($value, (is_numeric($key) ? $value : $key));
}
else {
$input_host = null;
break;
}
}
}
else if (empty($default_host)) {
$input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost', 'size' => 30));
}
$form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
$this->add_gui_object('loginform', $form_name);
// create HTML table with two cols
$table = new html_table(array('cols' => 2));
$table->add('title', html::label('rcmloginuser', Q(rcube_label('username'))));
$table->add(null, $input_user->show(get_input_value('_user', RCUBE_INPUT_POST)));
$table->add('title', html::label('rcmloginpwd', Q(rcube_label('password'))));
$table->add(null, $input_pass->show());
// add host selection row
if (is_object($input_host)) {
$table->add('title', html::label('rcmloginhost', Q(rcube_label('server'))));
$table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_POST)));
}
$out = $input_action->show();
$out .= $input_tzone->show();
$out .= $table->show();
// surround html output with a form tag
if (empty($attrib['form'])) {
$out = $this->form_tag(array('name' => $form_name, 'method' => "post"), $out);
}
return $out;
}
/**
* GUI object 'searchform'
* Returns code for search function
*
* @param array Named parameters
* @return string HTML code for the gui object
*/
private function search_form($attrib)
{
// add some labels to client
$this->add_label('searching');
$attrib['name'] = '_q';
if (empty($attrib['id'])) {
$attrib['id'] = 'rcmqsearchbox';
}
$input_q = new html_inputfield($attrib);
$out = $input_q->show();
$this->add_gui_object('qsearchbox', $attrib['id']);
// add form tag around text field
if (empty($attrib['form'])) {
$out = $this->form_tag(array(
'name' => "rcmqsearchform",
'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;",
'style' => "display:inline"),
$out);
}
return $out;
}
/**
* Builder for GUI object 'message'
*
* @param array Named tag parameters
* @return string HTML code for the gui object
*/
private function message_container($attrib)
{
if (isset($attrib['id']) === false) {
$attrib['id'] = 'rcmMessageContainer';
}
$this->add_gui_object('message', $attrib['id']);
return html::div($attrib, "");
}
/**
* GUI object 'charsetselector'
*
* @param array Named parameters for the select tag
* @return string HTML code for the gui object
*/
static function charset_selector($attrib)
{
// pass the following attributes to the form class
$field_attrib = array('name' => '_charset');
foreach ($attrib as $attr => $value) {
if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) {
$field_attrib[$attr] = $value;
}
}
$charsets = array(
'US-ASCII' => 'ASCII (English)',
'EUC-JP' => 'EUC-JP (Japanese)',
'EUC-KR' => 'EUC-KR (Korean)',
'BIG5' => 'BIG5 (Chinese)',
'GB2312' => 'GB2312 (Chinese)',
'ISO-2022-JP' => 'ISO-2022-JP (Japanese)',
'ISO-8859-1' => 'ISO-8859-1 (Latin-1)',
'ISO-8859-2' => 'ISO-8895-2 (Central European)',
'ISO-8859-7' => 'ISO-8859-7 (Greek)',
'ISO-8859-9' => 'ISO-8859-9 (Turkish)',
'Windows-1251' => 'Windows-1251 (Cyrillic)',
'Windows-1252' => 'Windows-1252 (Western)',
'Windows-1255' => 'Windows-1255 (Hebrew)',
'Windows-1256' => 'Windows-1256 (Arabic)',
'Windows-1257' => 'Windows-1257 (Baltic)',
'UTF-8' => 'UTF-8'
);
$select = new html_select($field_attrib);
$select->add(array_values($charsets), array_keys($charsets));
$set = $_POST['_charset'] ? $_POST['_charset'] : $this->get_charset();
return $select->show($set);
}
} // end class rcube_template
diff --git a/program/js/app.js b/program/js/app.js
index 36072e384..b724287ef 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1,4092 +1,4144 @@
/*
+-----------------------------------------------------------------------+
| RoundCube Webmail Client Script |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2008, RoundCube Dev, - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
| Authors: Thomas Bruederli <roundcube@gmail.com> |
| Charles McNulty <charles@charlesmcnulty.com> |
+-----------------------------------------------------------------------+
| Requires: common.js, list.js |
+-----------------------------------------------------------------------+
$Id$
*/
var rcube_webmail_client;
function rcube_webmail()
{
this.env = new Object();
this.labels = new Object();
this.buttons = new Object();
this.gui_objects = new Object();
this.commands = new Object();
this.onloads = new Array();
// create protected reference to myself
rcube_webmail_client = this;
this.ref = 'rcube_webmail_client';
var ref = this;
// webmail client settings
this.dblclick_time = 500;
this.message_time = 3000;
this.identifier_expr = new RegExp('[^0-9a-z\-_]', 'gi');
// mimetypes supported by the browser (default settings)
this.mimetypes = new Array('text/plain', 'text/html', 'text/xml',
'image/jpeg', 'image/gif', 'image/png',
'application/x-javascript', 'application/pdf',
'application/x-shockwave-flash');
// default environment vars
this.env.keep_alive = 60; // seconds
this.env.request_timeout = 180; // seconds
this.env.draft_autosave = 0; // seconds
this.env.comm_path = './';
this.env.bin_path = './bin/';
this.env.blankpage = 'program/blank.gif';
// set environment variable(s)
this.set_env = function(p, value)
{
if (p != null && typeof(p) == 'object' && !value)
for (var n in p)
this.env[n] = p[n];
else
this.env[p] = value;
};
// add a localized label to the client environment
this.add_label = function(key, value)
{
this.labels[key] = value;
};
// add a button to the button list
this.register_button = function(command, id, type, act, sel, over)
{
if (!this.buttons[command])
this.buttons[command] = new Array();
var button_prop = {id:id, type:type};
if (act) button_prop.act = act;
if (sel) button_prop.sel = sel;
if (over) button_prop.over = over;
this.buttons[command][this.buttons[command].length] = button_prop;
};
// register a specific gui object
this.gui_object = function(name, id)
{
this.gui_objects[name] = id;
};
// execute the given script on load
this.add_onload = function(f)
{
this.onloads[this.onloads.length] = f;
};
// initialize webmail client
this.init = function()
{
var p = this;
this.task = this.env.task;
// check browser
if (!bw.dom || !bw.xmlhttp_test())
{
this.goto_url('error', '_code=0x199');
return;
}
// find all registered gui objects
for (var n in this.gui_objects)
this.gui_objects[n] = rcube_find_object(this.gui_objects[n]);
// tell parent window that this frame is loaded
if (this.env.framed && parent.rcmail && parent.rcmail.set_busy)
parent.rcmail.set_busy(false);
// enable general commands
this.enable_command('logout', 'mail', 'addressbook', 'settings', true);
switch (this.task)
{
case 'mail':
if (this.gui_objects.messagelist)
{
this.message_list = new rcube_list_widget(this.gui_objects.messagelist, {multiselect:true, draggable:true, keyboard:true, dblclick_time:this.dblclick_time});
this.message_list.row_init = function(o){ p.init_message_row(o); };
this.message_list.addEventListener('dblclick', function(o){ p.msglist_dbl_click(o); });
this.message_list.addEventListener('keypress', function(o){ p.msglist_keypress(o); });
this.message_list.addEventListener('select', function(o){ p.msglist_select(o); });
this.message_list.addEventListener('dragstart', function(o){ p.drag_active = true; if (p.preview_timer) clearTimeout(p.preview_timer); });
this.message_list.addEventListener('dragmove', function(o, e){ p.drag_move(e); });
this.message_list.addEventListener('dragend', function(o){ p.drag_active = false; });
this.message_list.init();
this.enable_command('toggle_status', 'toggle_flag', true);
if (this.gui_objects.mailcontframe)
{
this.gui_objects.mailcontframe.onmousedown = function(e){ return p.click_on_list(e); };
document.onmouseup = function(e){ return p.doc_mouse_up(e); };
}
else
this.message_list.focus();
}
if (this.env.coltypes)
this.set_message_coltypes(this.env.coltypes);
// enable mail commands
this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', 'collapse-folder', true);
if (this.env.search_text != null && document.getElementById('quicksearchbox') != null)
document.getElementById('quicksearchbox').value = this.env.search_text;
if (this.env.action=='show' || this.env.action=='preview')
{
- this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', true);
+ this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', 'load-headers', true);
if (this.env.next_uid)
{
this.enable_command('nextmessage', true);
this.enable_command('lastmessage', true);
}
if (this.env.prev_uid)
{
this.enable_command('previousmessage', true);
this.enable_command('firstmessage', true);
}
}
if (this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox)
this.set_alttext('delete', 'movemessagetotrash');
// make preview/message frame visible
if (this.env.action == 'preview' && this.env.framed && parent.rcmail)
{
this.enable_command('compose', 'add-contact', false);
parent.rcmail.show_contentframe(true);
}
if ((this.env.action=='show' || this.env.action=='preview') && this.env.blockedobjects)
{
if (this.gui_objects.remoteobjectsmsg)
this.gui_objects.remoteobjectsmsg.style.display = 'block';
this.enable_command('load-images', 'always-load', true);
}
if (this.env.action=='compose')
{
this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true);
if (this.env.spellcheck)
{
this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); };
this.set_spellcheck_state('ready');
if (rcube_find_object('_is_html').value == '1')
this.display_spellcheck_controls(false);
}
if (this.env.drafts_mailbox)
this.enable_command('savedraft', true);
}
if (this.env.messagecount)
this.enable_command('select-all', 'select-none', 'expunge', true);
if (this.purge_mailbox_test())
this.enable_command('purge', true);
this.set_page_buttons();
// focus main window
if (this.env.framed && window.parent)
window.parent.focus();
else
window.focus();
// init message compose form
if (this.env.action=='compose')
this.init_messageform();
// show printing dialog
if (this.env.action=='print')
window.print();
// get unread count for each mailbox
if (this.gui_objects.mailboxlist)
{
this.env.unread_counts = {};
this.gui_objects.folderlist = this.gui_objects.mailboxlist;
this.http_request('getunread', '');
}
// ask user to send MDN
if (this.env.mdn_request && this.env.uid)
{
var mdnurl = '_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox);
if (confirm(this.get_label('mdnrequest')))
this.http_post('sendmdn', mdnurl);
else
this.http_post('mark', mdnurl+'&_flag=mdnsent');
}
break;
case 'addressbook':
if (this.gui_objects.contactslist)
{
this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, {multiselect:true, draggable:true, keyboard:true});
this.contact_list.addEventListener('keypress', function(o){ p.contactlist_keypress(o); });
this.contact_list.addEventListener('select', function(o){ p.contactlist_select(o); });
this.contact_list.addEventListener('dragstart', function(o){ p.drag_active = true; });
this.contact_list.addEventListener('dragmove', function(o, e){ p.drag_move(e); });
this.contact_list.addEventListener('dragend', function(o){ p.drag_active = false; });
this.contact_list.init();
if (this.env.cid)
this.contact_list.highlight_row(this.env.cid);
if (this.gui_objects.contactslist.parentNode)
{
this.gui_objects.contactslist.parentNode.onmousedown = function(e){ return p.click_on_list(e); };
document.onmouseup = function(e){ return p.doc_mouse_up(e); };
}
else
this.contact_list.focus();
}
this.set_page_buttons();
if (this.env.address_sources && !this.env.address_sources[this.env.source].readonly)
this.enable_command('add', true);
if (this.env.cid)
this.enable_command('show', 'edit', true);
if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform)
this.enable_command('save', true);
else
this.enable_command('search', 'reset-search', 'moveto', 'import', true);
if (this.contact_list && this.contact_list.rowcount > 0)
this.enable_command('export', true);
this.enable_command('list', true);
break;
case 'settings':
this.enable_command('preferences', 'identities', 'save', 'folders', true);
if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity')
this.enable_command('edit', 'add', 'delete', true);
if (this.env.action=='edit-identity' || this.env.action=='add-identity')
this.enable_command('save', true);
if (this.env.action=='folders')
this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', true);
if (this.gui_objects.identitieslist)
{
this.identity_list = new rcube_list_widget(this.gui_objects.identitieslist, {multiselect:false, draggable:false, keyboard:false});
this.identity_list.addEventListener('select', function(o){ p.identity_select(o); });
this.identity_list.init();
this.identity_list.focus();
if (this.env.iid)
this.identity_list.highlight_row(this.env.iid);
}
if (this.gui_objects.subscriptionlist)
this.init_subscription_list();
break;
case 'login':
var input_user = rcube_find_object('rcmloginuser');
var input_pass = rcube_find_object('rcmloginpwd');
var input_tz = rcube_find_object('rcmlogintz');
if (input_user)
input_user.onkeyup = function(e){ return rcmail.login_user_keyup(e); };
if (input_user && input_user.value=='')
input_user.focus();
else if (input_pass)
input_pass.focus();
// detect client timezone
if (input_tz)
input_tz.value = new Date().getTimezoneOffset() / -60;
this.enable_command('login', true);
break;
default:
break;
}
// enable basic commands
this.enable_command('logout', true);
// flag object as complete
this.loaded = true;
// show message
if (this.pending_message)
this.display_message(this.pending_message[0], this.pending_message[1]);
// start keep-alive interval
this.start_keepalive();
// execute all foreign onload scripts
for (var i=0; i<this.onloads.length; i++)
{
if (typeof(this.onloads[i]) == 'string')
eval(this.onloads[i]);
else if (typeof(this.onloads[i]) == 'function')
this.onloads[i]();
}
};
// start interval for keep-alive/recent_check signal
this.start_keepalive = function()
{
if (this.env.keep_alive && !this.env.framed && this.task=='mail' && this.gui_objects.mailboxlist)
this._int = setInterval(function(){ ref.check_for_recent(); }, this.env.keep_alive * 1000);
else if (this.env.keep_alive && !this.env.framed && this.task!='login')
this._int = setInterval(function(){ ref.send_keep_alive(); }, this.env.keep_alive * 1000);
}
this.init_message_row = function(row)
{
var uid = row.uid;
if (uid && this.env.messages[uid])
{
row.deleted = this.env.messages[uid].deleted ? true : false;
row.unread = this.env.messages[uid].unread ? true : false;
row.replied = this.env.messages[uid].replied ? true : false;
row.flagged = this.env.messages[uid].flagged ? true : false;
}
// set eventhandler to message icon
if ((row.icon = row.obj.cells[0].childNodes[0]) && row.icon.nodeName=='IMG')
{
var p = this;
row.icon.id = 'msgicn_'+row.uid;
row.icon._row = row.obj;
row.icon.onmousedown = function(e) { p.command('toggle_status', this); };
}
// global variable 'flagged_col' may be not defined yet
if (!this.env.flagged_col && this.env.coltypes)
{
var found;
if((found = find_in_array('flag', this.env.coltypes)) >= 0)
this.set_env('flagged_col', found+1);
}
// set eventhandler to flag icon, if icon found
if (this.env.flagged_col && (row.flagged_icon = row.obj.cells[this.env.flagged_col].childNodes[0])
&& row.flagged_icon.nodeName=='IMG')
{
var p = this;
row.flagged_icon.id = 'flaggedicn_'+row.uid;
row.flagged_icon._row = row.obj;
row.flagged_icon.onmousedown = function(e) { p.command('toggle_flag', this); };
}
};
// init message compose form: set focus and eventhandlers
this.init_messageform = function()
{
if (!this.gui_objects.messageform)
return false;
//this.messageform = this.gui_objects.messageform;
var input_from = rcube_find_object('_from');
var input_to = rcube_find_object('_to');
var input_cc = rcube_find_object('_cc');
var input_bcc = rcube_find_object('_bcc');
var input_replyto = rcube_find_object('_replyto');
var input_subject = rcube_find_object('_subject');
var input_message = rcube_find_object('_message');
// init live search events
if (input_to)
this.init_address_input_events(input_to);
if (input_cc)
this.init_address_input_events(input_cc);
if (input_bcc)
this.init_address_input_events(input_bcc);
// add signature according to selected identity
if (input_from && input_from.type=='select-one')
this.change_identity(input_from);
if (input_to && input_to.value=='')
input_to.focus();
else if (input_subject && input_subject.value=='')
input_subject.focus();
else if (input_message)
this.set_caret2start(input_message);
// get summary of all field values
this.compose_field_hash(true);
// start the auto-save timer
this.auto_save_start();
};
this.init_address_input_events = function(obj)
{
var handler = function(e){ return ref.ksearch_keypress(e,this); };
var handler2 = function(e){ return ref.ksearch_blur(e,this); };
if (obj.addEventListener)
{
obj.addEventListener(bw.safari ? 'keydown' : 'keypress', handler, false);
obj.addEventListener('blur', handler2, false);
}
else
{
obj.onkeydown = handler;
obj.onblur = handler2;
}
obj.setAttribute('autocomplete', 'off');
};
/*********************************************************/
/********* client command interface *********/
/*********************************************************/
// execute a specific command on the web client
this.command = function(command, props, obj)
{
if (obj && obj.blur)
obj.blur();
if (this.busy)
return false;
// command not supported or allowed
if (!this.commands[command])
{
// pass command to parent window
if (this.env.framed && parent.rcmail && parent.rcmail.command)
parent.rcmail.command(command, props);
return false;
}
// check input before leaving compose step
if (this.task=='mail' && this.env.action=='compose' && (command=='list' || command=='mail' || command=='addressbook' || command=='settings'))
{
if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning')))
return false;
}
-
// process command
switch (command)
{
case 'login':
if (this.gui_objects.loginform)
this.gui_objects.loginform.submit();
break;
case 'logout':
this.goto_url('logout', '', true);
break;
// commands to switch task
case 'mail':
case 'addressbook':
case 'settings':
this.switch_task(command);
break;
// misc list commands
case 'list':
if (this.task=='mail')
{
if (this.env.search_request<0 || (props != '' && (this.env.search_request && props != this.env.mailbox)))
this.reset_qsearch();
this.list_mailbox(props);
if (this.env.trash_mailbox)
this.set_alttext('delete', this.env.mailbox != this.env.trash_mailbox ? 'movemessagetotrash' : 'deletemessage');
}
else if (this.task=='addressbook')
{
if (this.env.search_request<0 || (this.env.search_request && props != this.env.source))
this.reset_qsearch();
this.list_contacts(props);
this.enable_command('add', (this.env.address_sources && !this.env.address_sources[props].readonly));
}
break;
+ case 'load-headers':
+ this.load_headers(obj);
+ break;
+
+
case 'sort':
// get the type of sorting
var a_sort = props.split('_');
var sort_col = a_sort[0];
var sort_order = a_sort[1] ? a_sort[1].toUpperCase() : null;
var header;
// no sort order specified: toggle
if (sort_order==null)
{
if (this.env.sort_col==sort_col)
sort_order = this.env.sort_order=='ASC' ? 'DESC' : 'ASC';
else
sort_order = this.env.sort_order;
}
if (this.env.sort_col==sort_col && this.env.sort_order==sort_order)
break;
// set table header class
if (header = document.getElementById('rcmHead'+this.env.sort_col))
this.set_classname(header, 'sorted'+(this.env.sort_order.toUpperCase()), false);
if (header = document.getElementById('rcmHead'+sort_col))
this.set_classname(header, 'sorted'+sort_order, true);
// save new sort properties
this.env.sort_col = sort_col;
this.env.sort_order = sort_order;
// reload message list
this.list_mailbox('', '', sort_col+'_'+sort_order);
break;
case 'nextpage':
this.list_page('next');
break;
case 'lastpage':
this.list_page('last');
break;
case 'previouspage':
this.list_page('prev');
break;
case 'firstpage':
this.list_page('first');
break;
case 'expunge':
if (this.env.messagecount)
this.expunge_mailbox(this.env.mailbox);
break;
case 'purge':
case 'empty-mailbox':
if (this.env.messagecount)
this.purge_mailbox(this.env.mailbox);
break;
// common commands used in multiple tasks
case 'show':
if (this.task=='mail')
{
var uid = this.get_single_uid();
if (uid && (!this.env.uid || uid != this.env.uid))
{
if (this.env.mailbox == this.env.drafts_mailbox)
this.goto_url('compose', '_draft_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true);
else
this.show_message(uid);
}
}
else if (this.task=='addressbook')
{
var cid = props ? props : this.get_single_cid();
if (cid && !(this.env.action=='show' && cid==this.env.cid))
this.load_contact(cid, 'show');
}
break;
case 'add':
if (this.task=='addressbook')
this.load_contact(0, 'add');
else if (this.task=='settings')
{
this.identity_list.clear_selection();
this.load_identity(0, 'add-identity');
}
break;
case 'edit':
var cid;
if (this.task=='addressbook' && (cid = this.get_single_cid()))
this.load_contact(cid, 'edit');
else if (this.task=='settings' && props)
this.load_identity(props, 'edit-identity');
break;
case 'save-identity':
case 'save':
if (this.gui_objects.editform)
{
var input_pagesize = rcube_find_object('_pagesize');
var input_name = rcube_find_object('_name');
var input_email = rcube_find_object('_email');
// user prefs
if (input_pagesize && isNaN(parseInt(input_pagesize.value)))
{
alert(this.get_label('nopagesizewarning'));
input_pagesize.focus();
break;
}
// contacts/identities
else
{
if (input_name && input_name.value == '')
{
alert(this.get_label('nonamewarning'));
input_name.focus();
break;
}
else if (input_email && !rcube_check_email(input_email.value))
{
alert(this.get_label('noemailwarning'));
input_email.focus();
break;
}
}
this.gui_objects.editform.submit();
}
break;
case 'delete':
// mail task
if (this.task=='mail')
this.delete_messages();
// addressbook task
else if (this.task=='addressbook')
this.delete_contacts();
// user settings task
else if (this.task=='settings')
this.delete_identity();
break;
// mail task commands
case 'move':
case 'moveto':
if (this.task == 'mail')
this.move_messages(props);
else if (this.task == 'addressbook' && this.drag_active)
this.copy_contact(null, props);
break;
case 'mark':
if (props)
this.mark_message(props);
break;
case 'toggle_status':
if (props && !props._row)
break;
var uid;
var flag = 'read';
if (props._row.uid)
{
uid = props._row.uid;
// toggle read/unread
if (this.message_list.rows[uid].deleted) {
flag = 'undelete';
} else if (!this.message_list.rows[uid].unread)
flag = 'unread';
}
this.mark_message(flag, uid);
break;
case 'toggle_flag':
if (props && !props._row)
break;
var uid;
var flag = 'flagged';
if (props._row.uid)
{
uid = props._row.uid;
this.message_list.dont_select = true;
// toggle flagged/unflagged
if (this.message_list.rows[uid].flagged)
flag = 'unflagged';
}
this.mark_message(flag, uid);
break;
case 'always-load':
if (this.env.uid && this.env.sender) {
this.add_contact(urlencode(this.env.sender));
window.setTimeout(function(){ ref.command('load-images'); }, 300);
break;
}
case 'load-images':
if (this.env.uid)
this.show_message(this.env.uid, true, this.env.action=='preview');
break;
case 'load-attachment':
var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props.part;
// open attachment in frame if it's of a supported mimetype
if (this.env.uid && props.mimetype && find_in_array(props.mimetype, this.mimetypes)>=0)
{
if (props.mimetype == 'text/html')
qstring += '&_safe=1';
this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment');
if (this.attachment_win)
{
window.setTimeout(function(){ ref.attachment_win.focus(); }, 10);
break;
}
}
this.goto_url('get', qstring+'&_download=1', false);
break;
case 'select-all':
this.message_list.select_all(props);
break;
case 'select-none':
this.message_list.clear_selection();
break;
case 'nextmessage':
if (this.env.next_uid)
this.show_message(this.env.next_uid, false, this.env.action=='preview');
break;
case 'lastmessage':
if (this.env.last_uid)
this.show_message(this.env.last_uid);
break;
case 'previousmessage':
if (this.env.prev_uid)
this.show_message(this.env.prev_uid, false, this.env.action=='preview');
break;
case 'firstmessage':
if (this.env.first_uid)
this.show_message(this.env.first_uid);
break;
case 'checkmail':
this.check_for_recent();
break;
case 'compose':
var url = this.env.comm_path+'&_action=compose';
if (this.task=='mail' && this.env.mailbox==this.env.drafts_mailbox)
{
var uid;
if (uid = this.get_single_uid())
url += '&_draft_uid='+uid+'&_mbox='+urlencode(this.env.mailbox);
}
// modify url if we're in addressbook
else if (this.task=='addressbook')
{
// switch to mail compose step directly
if (props && props.indexOf('@') > 0)
{
url = this.get_task_url('mail', url);
this.redirect(url + '&_to='+urlencode(props));
break;
}
// use contact_id passed as command parameter
var a_cids = new Array();
if (props)
a_cids[a_cids.length] = props;
// get selected contacts
else if (this.contact_list)
{
var selection = this.contact_list.get_selection();
for (var n=0; n<selection.length; n++)
a_cids[a_cids.length] = selection[n];
}
if (a_cids.length)
this.http_request('mailto', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source), true);
break;
}
else if (props)
url += '&_to='+urlencode(props);
// don't know if this is necessary...
url = url.replace(/&_framed=1/, "");
this.redirect(url);
break;
case 'spellcheck':
if (window.tinyMCE && tinyMCE.get('compose-body')) {
tinyMCE.execCommand('mceSpellCheck', true);
}
else if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) {
this.env.spellcheck.spellCheck(this.env.spellcheck.check_link);
this.set_spellcheck_state('checking');
}
break;
case 'savedraft':
// Reset the auto-save timer
self.clearTimeout(this.save_timer);
if (!this.gui_objects.messageform)
break;
// if saving Drafts is disabled in main.inc.php
// or if compose form did not change
if (!this.env.drafts_mailbox || this.cmp_hash == this.compose_field_hash())
break;
this.set_busy(true, 'savingmessage');
var form = this.gui_objects.messageform;
form.target = "savetarget";
form._draft.value = '1';
form.submit();
break;
case 'send':
if (!this.gui_objects.messageform)
break;
if (!this.check_compose_input())
break;
// Reset the auto-save timer
self.clearTimeout(this.save_timer);
// all checks passed, send message
this.set_busy(true, 'sendingmessage');
var form = this.gui_objects.messageform;
form.target = "savetarget";
form._draft.value = '';
form.submit();
// clear timeout (sending could take longer)
clearTimeout(this.request_timer);
break;
case 'add-attachment':
this.show_attachment_form(true);
case 'send-attachment':
// Reset the auto-save timer
self.clearTimeout(this.save_timer);
this.upload_file(props)
break;
case 'remove-attachment':
this.remove_attachment(props);
break;
case 'reply-all':
case 'reply':
var uid;
if (uid = this.get_single_uid())
this.goto_url('compose', '_reply_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(command=='reply-all' ? '&_all=1' : ''), true);
break;
case 'forward':
var uid;
if (uid = this.get_single_uid())
this.goto_url('compose', '_forward_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true);
break;
case 'print':
var uid;
if (uid = this.get_single_uid())
{
ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : ''));
if (this.printwin)
{
window.setTimeout(function(){ ref.printwin.focus(); }, 20);
if (this.env.action != 'show')
this.mark_message('read', uid);
}
}
break;
case 'viewsource':
var uid;
if (uid = this.get_single_uid())
{
ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox));
if (this.sourcewin)
window.setTimeout(function(){ ref.sourcewin.focus(); }, 20);
}
break;
case 'add-contact':
this.add_contact(props);
break;
// quicksearch
case 'search':
if (!props && this.gui_objects.qsearchbox)
props = this.gui_objects.qsearchbox.value;
if (props)
{
this.qsearch(props);
break;
}
// reset quicksearch
case 'reset-search':
var s = this.env.search_request;
this.reset_qsearch();
if (s && this.env.mailbox)
this.list_mailbox(this.env.mailbox);
else if (s && this.task == 'addressbook')
this.list_contacts(this.env.source);
break;
case 'import':
if (this.env.action == 'import' && this.gui_objects.importform) {
var file = document.getElementById('rcmimportfile');
if (file && !file.value) {
alert(this.get_label('selectimportfile'));
break;
}
this.gui_objects.importform.submit();
this.set_busy(true, 'importwait');
this.lock_form(this.gui_objects.importform, true);
}
else
this.goto_url('import');
break;
case 'export':
if (this.contact_list.rowcount > 0) {
var add_url = (this.env.source ? '_source='+urlencode(this.env.source)+'&' : '');
if (this.env.search_request)
add_url += '_search='+this.env.search_request;
this.goto_url('export', add_url);
}
break;
// collapse/expand folder
case 'collapse-folder':
if (props)
this.collapse_folder(props);
break;
// user settings commands
case 'preferences':
this.goto_url('');
break;
case 'identities':
this.goto_url('identities');
break;
case 'delete-identity':
this.delete_identity();
case 'folders':
this.goto_url('folders');
break;
case 'subscribe':
this.subscribe_folder(props);
break;
case 'unsubscribe':
this.unsubscribe_folder(props);
break;
case 'create-folder':
this.create_folder(props);
break;
case 'rename-folder':
this.rename_folder(props);
break;
case 'delete-folder':
this.delete_folder(props);
break;
}
return obj ? false : true;
};
// set command enabled or disabled
this.enable_command = function()
{
var args = arguments;
if(!args.length) return -1;
var command;
var enable = args[args.length-1];
for(var n=0; n<args.length-1; n++)
{
command = args[n];
this.commands[command] = enable;
this.set_button(command, (enable ? 'act' : 'pas'));
}
return true;
};
// lock/unlock interface
this.set_busy = function(a, message)
{
if (a && message)
{
var msg = this.get_label(message);
if (msg==message)
msg = 'Loading...';
this.display_message(msg, 'loading', true);
}
else if (!a)
this.hide_message();
this.busy = a;
//document.body.style.cursor = a ? 'wait' : 'default';
if (this.gui_objects.editform)
this.lock_form(this.gui_objects.editform, a);
// clear pending timer
if (this.request_timer)
clearTimeout(this.request_timer);
// set timer for requests
if (a && this.env.request_timeout)
this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000);
};
// return a localized string
this.get_label = function(name)
{
if (this.labels[name])
return this.labels[name];
else
return name;
};
// switch to another application task
this.switch_task = function(task)
{
if (this.task===task && task!='mail')
return;
var url = this.get_task_url(task);
if (task=='mail')
url += '&_mbox=INBOX';
this.redirect(url);
};
this.get_task_url = function(task, url)
{
if (!url)
url = this.env.comm_path;
return url.replace(/_task=[a-z]+/, '_task='+task);
};
// called when a request timed out
this.request_timed_out = function()
{
this.set_busy(false);
this.display_message('Request timed out!', 'error');
};
/*********************************************************/
/********* event handling methods *********/
/*********************************************************/
this.doc_mouse_up = function(e)
{
var model, li;
if (this.message_list) {
this.message_list.blur();
model = this.env.mailboxes;
}
else if (this.contact_list) {
this.contact_list.blur();
model = this.env.address_sources;
}
// handle mouse release when dragging
if (this.drag_active && model) {
for (var k in model) {
if ((li = this.get_folder_li(k)) && rcube_mouse_is_over(e, li.firstChild) && this.check_droptarget(k)) {
this.set_classname(li, 'droptarget', false);
this.command('moveto', model[k].id);
break;
}
}
}
};
this.drag_move = function(e)
{
var li;
var model = this.task == 'mail' ? this.env.mailboxes : this.env.address_sources;
if (this.gui_objects.folderlist && model) {
for (var k in model) {
if (li = this.get_folder_li(k))
this.set_classname(li, 'droptarget', (rcube_mouse_is_over(e, li.firstChild) && this.check_droptarget(k)));
}
}
};
this.collapse_folder = function(id)
{
var div;
if ((li = this.get_folder_li(id)) &&
(div = li.getElementsByTagName("div")[0]) &&
(div.className.match(/collapsed/) || div.className.match(/expanded/)))
{
var ul = li.getElementsByTagName("ul")[0];
if (div.className.match(/collapsed/))
{
ul.style.display = '';
this.set_classname(div, 'collapsed', false);
this.set_classname(div, 'expanded', true);
var reg = new RegExp('&'+escape(id)+'&');
this.set_env('collapsed_folders', this.env.collapsed_folders.replace(reg, ''));
}
else
{
ul.style.display = 'none';
this.set_classname(div, 'expanded', false);
this.set_classname(div, 'collapsed', true);
this.set_env('collapsed_folders', this.env.collapsed_folders+'&'+escape(id)+'&');
// select parent folder if one of its childs is currently selected
if (this.env.mailbox.indexOf(id + this.env.delimiter) == 0)
this.command('list', id);
}
this.http_post('save-pref', '_name=collapsed_folders&_value='+escape(this.env.collapsed_folders));
this.set_unread_count_display(id, false);
}
}
this.click_on_list = function(e)
{
if (this.message_list)
this.message_list.focus();
else if (this.contact_list)
this.contact_list.focus();
var mbox_li;
if (mbox_li = this.get_folder_li())
this.set_classname(mbox_li, 'unfocused', true);
return rcube_event.get_button(e) == 2 ? true : rcube_event.cancel(e);
};
this.msglist_select = function(list)
{
if (this.preview_timer)
clearTimeout(this.preview_timer);
var selected = list.selection.length==1;
// Hide certain command buttons when Drafts folder is selected
if (this.env.mailbox == this.env.drafts_mailbox)
{
this.enable_command('reply', 'reply-all', 'forward', false);
this.enable_command('show', selected);
this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false));
}
else
{
this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false));
}
// start timer for message preview (wait for double click)
if (selected && this.env.contentframe && !list.multi_selecting)
this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, 200);
else if (this.env.contentframe)
this.show_contentframe(false);
};
this.msglist_dbl_click = function(list)
{
if (this.preview_timer)
clearTimeout(this.preview_timer);
var uid = list.get_single_selection();
if (uid && this.env.mailbox == this.env.drafts_mailbox)
this.goto_url('compose', '_draft_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true);
else if (uid)
this.show_message(uid, false, false);
};
this.msglist_keypress = function(list)
{
if (list.key_pressed == list.ENTER_KEY)
this.command('show');
else if (list.key_pressed == list.DELETE_KEY)
this.command('delete');
else if (list.key_pressed == list.BACKSPACE_KEY)
this.command('delete');
else
list.shiftkey = false;
};
this.msglist_get_preview = function()
{
var uid = this.get_single_uid();
if (uid && this.env.contentframe && !this.drag_active)
this.show_message(uid, false, true);
else if (this.env.contentframe)
this.show_contentframe(false);
};
this.check_droptarget = function(id)
{
if (this.task == 'mail')
return (this.env.mailboxes[id] && this.env.mailboxes[id].id != this.env.mailbox && !this.env.mailboxes[id].virtual);
else if (this.task == 'addressbook')
return (id != this.env.source && this.env.address_sources[id] && !this.env.address_sources[id].readonly);
else if (this.task == 'settings')
return (id != this.env.folder);
};
/*********************************************************/
/********* (message) list functionality *********/
/*********************************************************/
// when user doble-clicks on a row
this.show_message = function(id, safe, preview)
{
var add_url = '';
var action = preview ? 'preview': 'show';
var target = window;
if (preview && this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
target = window.frames[this.env.contentframe];
add_url = '&_framed=1';
}
if (safe)
add_url = '&_safe=1';
// also send search request to get the right messages
if (this.env.search_request)
add_url += '&_search='+this.env.search_request;
if (id)
{
var url = '&_action='+action+'&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
if (action == 'preview' && String(target.location.href).indexOf(url) >= 0)
this.show_contentframe(true);
else
{
this.set_busy(true, 'loading');
target.location.href = this.env.comm_path+url;
}
}
};
this.show_contentframe = function(show)
{
var frm;
if (this.env.contentframe && (frm = rcube_find_object(this.env.contentframe)))
{
if (!show && window.frames[this.env.contentframe])
{
if (window.frames[this.env.contentframe].location.href.indexOf(this.env.blankpage)<0)
window.frames[this.env.contentframe].location.href = this.env.blankpage;
}
else if (!bw.safari)
frm.style.display = show ? 'block' : 'none';
}
if (!show && this.busy)
this.set_busy(false);
};
// list a specific page
this.list_page = function(page)
{
if (page=='next')
page = this.env.current_page+1;
if (page=='last')
page = this.env.pagecount;
if (page=='prev' && this.env.current_page>1)
page = this.env.current_page-1;
if (page=='first' && this.env.current_page>1)
page = 1;
if (page > 0 && page <= this.env.pagecount)
{
this.env.current_page = page;
if (this.task=='mail')
this.list_mailbox(this.env.mailbox, page);
else if (this.task=='addressbook')
this.list_contacts(this.env.source, page);
}
};
// list messages of a specific mailbox
this.list_mailbox = function(mbox, page, sort)
{
this.last_selected = 0;
var add_url = '';
var target = window;
if (!mbox)
mbox = this.env.mailbox;
// add sort to url if set
if (sort)
add_url += '&_sort=' + sort;
// also send search request to get the right messages
if (this.env.search_request)
add_url += '&_search='+this.env.search_request;
// set page=1 if changeing to another mailbox
if (!page && mbox != this.env.mailbox)
{
page = 1;
this.env.current_page = page;
if (this.message_list)
this.message_list.clear_selection();
this.show_contentframe(false);
}
if (mbox != this.env.mailbox || (mbox == this.env.mailbox && !page && !sort))
add_url += '&_refresh=1';
this.select_folder(mbox, this.env.mailbox);
this.env.mailbox = mbox;
// load message list remotely
if (this.gui_objects.messagelist)
{
this.list_mailbox_remote(mbox, page, add_url);
return;
}
if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
target = window.frames[this.env.contentframe];
add_url += '&_framed=1';
}
// load message list to target frame/window
if (mbox)
{
this.set_busy(true, 'loading');
target.location.href = this.env.comm_path+'&_mbox='+urlencode(mbox)+(page ? '&_page='+page : '')+add_url;
}
};
// send remote request to load message list
this.list_mailbox_remote = function(mbox, page, add_url)
{
// clear message list first
this.message_list.clear();
// send request to server
var url = '_mbox='+urlencode(mbox)+(page ? '&_page='+page : '');
this.set_busy(true, 'loading');
this.http_request('list', url+add_url, true);
};
this.expunge_mailbox = function(mbox)
{
var lock = false;
var add_url = '';
// lock interface if it's the active mailbox
if (mbox == this.env.mailbox)
{
lock = true;
this.set_busy(true, 'loading');
add_url = '&_reload=1';
}
// send request to server
var url = '_mbox='+urlencode(mbox);
this.http_post('expunge', url+add_url, lock);
};
this.purge_mailbox = function(mbox)
{
var lock = false;
var add_url = '';
if (!confirm(this.get_label('purgefolderconfirm')))
return false;
// lock interface if it's the active mailbox
if (mbox == this.env.mailbox)
{
lock = true;
this.set_busy(true, 'loading');
add_url = '&_reload=1';
}
// send request to server
var url = '_mbox='+urlencode(mbox);
this.http_post('purge', url+add_url, lock);
return true;
};
// test if purge command is allowed
this.purge_mailbox_test = function()
{
return (this.env.messagecount && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox
|| this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter))
|| this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))));
};
// move selected messages to the specified mailbox
this.move_messages = function(mbox)
{
// exit if current or no mailbox specified or if selection is empty
if (!mbox || mbox == this.env.mailbox || (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length)))
return;
var lock = false;
var add_url = '&_target_mbox='+urlencode(mbox)+'&_from='+(this.env.action ? this.env.action : '');
// show wait message
if (this.env.action=='show')
{
lock = true;
this.set_busy(true, 'movingmessage');
}
else if (!this.env.flag_for_deletion)
this.show_contentframe(false);
// Hide message command buttons until a message is selected
this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', false);
this._with_selected_messages('moveto', lock, add_url, (this.env.flag_for_deletion ? false : true));
};
// delete selected messages from the current mailbox
this.delete_messages = function()
{
var selection = this.message_list ? this.message_list.get_selection() : new Array();
// exit if no mailbox specified or if selection is empty
if (!this.env.uid && !selection.length)
return;
// if there is a trash mailbox defined and we're not currently in it:
if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() != String(this.env.trash_mailbox).toLowerCase())
{
// if shift was pressed delete it immediately
if (this.message_list && this.message_list.shiftkey)
{
if (confirm(this.get_label('deletemessagesconfirm')))
this.permanently_remove_messages();
}
else
this.move_messages(this.env.trash_mailbox);
}
// if there is a trash mailbox defined but we *are* in it:
else if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
this.permanently_remove_messages();
// if there isn't a defined trash mailbox and the config is set to flag for deletion
else if (!this.env.trash_mailbox && this.env.flag_for_deletion)
{
this.mark_message('delete');
if(this.env.action=="show")
this.command('nextmessage','',this);
else if (selection.length == 1)
this.message_list.select_next();
}
// if there isn't a defined trash mailbox and the config is set NOT to flag for deletion
else if (!this.env.trash_mailbox)
this.permanently_remove_messages();
};
// delete the selected messages permanently
this.permanently_remove_messages = function()
{
// exit if no mailbox specified or if selection is empty
if (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length))
return;
this.show_contentframe(false);
this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''), true);
};
// Send a specifc request with UIDs of all selected messages
// @private
this._with_selected_messages = function(action, lock, add_url, remove)
{
var a_uids = new Array();
if (this.env.uid)
a_uids[0] = this.env.uid;
else
{
var selection = this.message_list.get_selection();
var rows = this.message_list.rows;
var id;
for (var n=0; n<selection.length; n++)
{
id = selection[n];
a_uids[a_uids.length] = id;
if (remove)
this.message_list.remove_row(id, (n == selection.length-1));
else
{
rows[id].deleted = true;
if (rows[id].classname.indexOf('deleted')<0)
{
rows[id].classname += ' deleted';
this.set_classname(rows[id].obj, 'deleted', true);
}
if (this.env.read_when_deleted)
{
rows[id].classname = rows[id].classname.replace(/\s*unread/, '');
this.set_classname(rows[id].obj, 'unread', false);
}
if (rows[id].icon && this.env.deletedicon)
rows[id].icon.src = this.env.deletedicon;
}
}
}
// also send search request to get the right messages
if (this.env.search_request)
add_url += '&_search='+this.env.search_request;
// send request to server
this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock);
};
// set a specific flag to one or more messages
this.mark_message = function(flag, uid)
{
var a_uids = new Array();
var r_uids = new Array();
var selection = this.message_list ? this.message_list.get_selection() : new Array();
if (uid)
a_uids[0] = uid;
else if (this.env.uid)
a_uids[0] = this.env.uid;
else if (this.message_list)
{
for (var n=0; n<selection.length; n++)
{
a_uids[a_uids.length] = selection[n];
}
}
if (!this.message_list)
r_uids = a_uids;
else
for (var id, n=0; n<a_uids.length; n++)
{
id = a_uids[n];
if ((flag=='read' && this.message_list.rows[id].unread)
|| (flag=='unread' && !this.message_list.rows[id].unread)
|| (flag=='delete' && !this.message_list.rows[id].deleted)
|| (flag=='undelete' && this.message_list.rows[id].deleted)
|| (flag=='flagged' && !this.message_list.rows[id].flagged)
|| (flag=='unflagged' && this.message_list.rows[id].flagged))
{
r_uids[r_uids.length] = id;
}
}
// nothing to do
if (!r_uids.length)
return;
switch (flag)
{
case 'read':
case 'unread':
this.toggle_read_status(flag, r_uids);
break;
case 'delete':
case 'undelete':
this.toggle_delete_status(r_uids);
break;
case 'flagged':
case 'unflagged':
this.toggle_flagged_status(flag, a_uids);
break;
}
};
// set class to read/unread
this.toggle_read_status = function(flag, a_uids)
{
// mark all message rows as read/unread
var icn_src;
var rows = this.message_list.rows;
for (var i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid])
{
rows[uid].unread = (flag=='unread' ? true : false);
if (rows[uid].classname.indexOf('unread')<0 && rows[uid].unread)
{
rows[uid].classname += ' unread';
this.set_classname(rows[uid].obj, 'unread', true);
if (this.env.unreadicon)
icn_src = this.env.unreadicon;
}
else if (!rows[uid].unread)
{
rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
this.set_classname(rows[uid].obj, 'unread', false);
if (this.env.messageicon)
icn_src = this.env.messageicon;
}
if (rows[uid].icon && icn_src
&& !(rows[uid].replied && this.env.repliedicon)
&& !(rows[uid].deleted && this.env.deletedicon))
rows[uid].icon.src = icn_src;
}
}
this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag);
};
// set class to read/unread
this.mark_as_read_from_preview = function(uid)
{
var icn_src;
var rows = parent.rcmail.message_list.rows;
if(rows[uid].unread)
{
rows[uid].unread = false;
rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
parent.rcmail.set_classname(rows[uid].obj, 'unread', false);
if (rows[uid].replied && parent.rcmail.env.repliedicon)
icn_src = parent.rcmail.env.repliedicon;
else if (rows[uid].deleted && parent.rcmail.env.deletedicon)
icn_src = parent.rcmail.env.deletedicon;
else if (parent.rcmail.env.messageicon)
icn_src = parent.rcmail.env.messageicon;
if (rows[uid].icon && icn_src)
rows[uid].icon.src = icn_src;
}
}
// set image to flagged or unflagged
this.toggle_flagged_status = function(flag, a_uids)
{
// mark all message rows as flagged/unflagged
var icn_src;
var rows = this.message_list.rows;
for (var i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid])
{
rows[uid].flagged = (flag=='flagged' ? true : false);
if (rows[uid].flagged && this.env.flaggedicon)
icn_src = this.env.flaggedicon;
else if (this.env.unflaggedicon)
icn_src = this.env.unflaggedicon;
if (rows[uid].flagged_icon && icn_src)
rows[uid].flagged_icon.src = icn_src;
}
}
this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag);
};
// mark all message rows as deleted/undeleted
this.toggle_delete_status = function(a_uids)
{
var rows = this.message_list ? this.message_list.rows : new Array();
if (a_uids.length==1)
{
if (!rows.length || (rows[a_uids[0]] && rows[a_uids[0]].classname.indexOf('deleted') < 0))
this.flag_as_deleted(a_uids);
else
this.flag_as_undeleted(a_uids);
return true;
}
var all_deleted = true;
for (var i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid]) {
if (rows[uid].classname.indexOf('deleted')<0)
{
all_deleted = false;
break;
}
}
}
if (all_deleted)
this.flag_as_undeleted(a_uids);
else
this.flag_as_deleted(a_uids);
return true;
};
this.flag_as_undeleted = function(a_uids)
{
var icn_src;
var rows = this.message_list ? this.message_list.rows : new Array();
for (var i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid]) {
rows[uid].deleted = false;
if (rows[uid].classname.indexOf('deleted') > 0)
{
rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, '');
this.set_classname(rows[uid].obj, 'deleted', false);
}
if (rows[uid].unread && this.env.unreadicon)
icn_src = this.env.unreadicon;
else if (rows[uid].replied && this.env.repliedicon)
icn_src = this.env.repliedicon;
else if (this.env.messageicon)
icn_src = this.env.messageicon;
if (rows[uid].icon && icn_src)
rows[uid].icon.src = icn_src;
}
}
this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=undelete');
return true;
};
this.flag_as_deleted = function(a_uids)
{
var add_url = '';
var r_uids = new Array();
var rows = this.message_list ? this.message_list.rows : new Array();
for (var i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid])
{
rows[uid].deleted = true;
if (rows[uid].classname.indexOf('deleted')<0)
{
rows[uid].classname += ' deleted';
this.set_classname(rows[uid].obj, 'deleted', true);
}
if (this.env.read_when_deleted)
{
rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
this.set_classname(rows[uid].obj, 'unread', false);
}
if (rows[uid].icon && this.env.deletedicon)
rows[uid].icon.src = this.env.deletedicon;
if (rows[uid].unread)
r_uids[r_uids.length] = uid;
}
}
if (r_uids.length)
add_url = '&_ruid='+r_uids.join(',');
this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url);
return true;
};
// flag as read without mark request (called from backend)
// argument should be a coma-separated list of uids
this.flag_deleted_as_read = function(uids)
{
var icn_src;
var rows = this.message_list ? this.message_list.rows : new Array();
var str = String(uids);
var a_uids = new Array();
a_uids = str.split(',');
for (var uid, i=0; i<a_uids.length; i++)
{
uid = a_uids[i];
if (rows[uid])
{
rows[uid].unread = false;
rows[uid].read = true;
rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
this.set_classname(rows[uid].obj, 'unread', false);
if (rows[uid].icon)
rows[uid].icon.src = this.env.deletedicon;
}
}
};
/*********************************************************/
/********* login form methods *********/
/*********************************************************/
// handler for keyboard events on the _user field
this.login_user_keyup = function(e)
{
var key = rcube_event.get_keycode(e);
var elm;
// enter
if ((key==13) && (elm = rcube_find_object('_pass')))
{
elm.focus();
return false;
}
};
/*********************************************************/
/********* message compose methods *********/
/*********************************************************/
// checks the input fields before sending a message
this.check_compose_input = function()
{
// check input fields
var input_to = rcube_find_object('_to');
var input_cc = rcube_find_object('_cc');
var input_bcc = rcube_find_object('_bcc');
var input_subject = rcube_find_object('_subject');
var input_message = rcube_find_object('_message');
// check for empty recipient
var recipients = input_to.value ? input_to.value : (input_cc.value ? input_cc.value : input_bcc.value);
if (!rcube_check_email(recipients.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true))
{
alert(this.get_label('norecipientwarning'));
input_to.focus();
return false;
}
// display localized warning for missing subject
if (input_subject && input_subject.value == '')
{
var subject = prompt(this.get_label('nosubjectwarning'), this.get_label('nosubject'));
// user hit cancel, so don't send
if (!subject && subject !== '')
{
input_subject.focus();
return false;
}
else
{
input_subject.value = subject ? subject : this.get_label('nosubject');
}
}
// check for empty body
if ((!window.tinyMCE || !tinyMCE.get('compose-body')) && input_message.value == '' && !confirm(this.get_label('nobodywarning')))
{
input_message.focus();
return false;
}
else if (window.tinyMCE && tinyMCE.get('compose-body') && !tinyMCE.get('compose-body').getContent() && !confirm(this.get_label('nobodywarning')))
{
tinyMCE.get('compose-body').focus();
return false;
}
return true;
};
this.display_spellcheck_controls = function(vis)
{
if (this.env.spellcheck) {
this.env.spellcheck.check_link.style.visibility = vis ? 'visible' : 'hidden';
this.env.spellcheck.switch_lan_pic.style.visibility = vis ? 'visible' : 'hidden';
}
};
this.set_spellcheck_state = function(s)
{
this.spellcheck_ready = (s=='check_spelling' || s=='ready');
this.enable_command('spellcheck', this.spellcheck_ready);
};
this.set_draft_id = function(id)
{
var f;
if (f = rcube_find_object('_draft_saveid'))
f.value = id;
};
this.auto_save_start = function()
{
if (this.env.draft_autosave)
this.save_timer = self.setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000);
// Unlock interface now that saving is complete
this.busy = false;
};
this.compose_field_hash = function(save)
{
// check input fields
var input_to = rcube_find_object('_to');
var input_cc = rcube_find_object('_cc');
var input_bcc = rcube_find_object('_bcc');
var input_subject = rcube_find_object('_subject');
var editor, input_message;
var str = '';
if (input_to && input_to.value)
str += input_to.value+':';
if (input_cc && input_cc.value)
str += input_cc.value+':';
if (input_bcc && input_bcc.value)
str += input_bcc.value+':';
if (input_subject && input_subject.value)
str += input_subject.value+':';
if (editor = tinyMCE.get('compose-body'))
str += editor.getContent();
else
{
input_message = rcube_find_object('_message');
str += input_message.value;
}
if (save)
this.cmp_hash = str;
return str;
};
this.change_identity = function(obj)
{
if (!obj || !obj.options)
return false;
var id = obj.options[obj.selectedIndex].value;
var input_message = rcube_find_object('_message');
var message = input_message ? input_message.value : '';
var is_html = (rcube_find_object('_is_html').value == '1');
var sig, p;
if (!this.env.identity)
this.env.identity = id
if (!is_html)
{
// remove the 'old' signature
if (this.env.identity && this.env.signatures && this.env.signatures[this.env.identity])
{
if (this.env.signatures[this.env.identity]['is_html'])
sig = this.env.signatures[this.env.identity]['plain_text'];
else
sig = this.env.signatures[this.env.identity]['text'];
if (sig.indexOf('-- ')!=0)
sig = '-- \n'+sig;
p = message.lastIndexOf(sig);
if (p>=0)
message = message.substring(0, p-1) + message.substring(p+sig.length, message.length);
}
// add the new signature string
if (this.env.signatures && this.env.signatures[id])
{
sig = this.env.signatures[id]['text'];
if (this.env.signatures[id]['is_html'])
{
sig = this.env.signatures[id]['plain_text'];
}
if (sig.indexOf('-- ')!=0)
sig = '-- \n'+sig;
message += '\n'+sig;
}
}
else
{
var editor = tinyMCE.get('compose-body');
if (this.env.signatures)
{
// Append the signature as a div within the body
var sigElem = editor.dom.get("_rc_sig");
var newsig = '';
var htmlsig = true;
if (!sigElem)
{
sigElem = editor.getDoc().createElement("div");
sigElem.setAttribute("id", "_rc_sig");
editor.getBody().appendChild(sigElem);
}
if (this.env.signatures[id])
{
newsig = this.env.signatures[id]['text'];
htmlsig = this.env.signatures[id]['is_html'];
}
if (htmlsig)
sigElem.innerHTML = newsig;
else
sigElem.innerHTML = '<pre>' + newsig + '</pre>';
}
}
if (input_message)
input_message.value = message;
this.env.identity = id;
return true;
};
this.show_attachment_form = function(a)
{
if (!this.gui_objects.uploadbox)
return false;
var elm, list;
if (elm = this.gui_objects.uploadbox)
{
if (a && (list = this.gui_objects.attachmentlist))
{
var pos = rcube_get_object_pos(list);
var left = pos.x;
var top = pos.y + list.offsetHeight + 10;
elm.style.top = top+'px';
elm.style.left = left+'px';
}
elm.style.visibility = a ? 'visible' : 'hidden';
}
// clear upload form
try {
if (!a && this.gui_objects.attachmentform != this.gui_objects.messageform)
this.gui_objects.attachmentform.reset();
}
catch(e){} // ignore errors
return true;
};
// upload attachment file
this.upload_file = function(form)
{
if (!form)
return false;
// get file input fields
var send = false;
for (var n=0; n<form.elements.length; n++)
if (form.elements[n].type=='file' && form.elements[n].value)
{
send = true;
break;
}
// create hidden iframe and post upload form
if (send)
{
var ts = new Date().getTime();
var frame_name = 'rcmupload'+ts;
// have to do it this way for IE
// otherwise the form will be posted to a new window
if(document.all)
{
var html = '<iframe name="'+frame_name+'" src="program/blank.gif" style="width:0;height:0;visibility:hidden;"></iframe>';
document.body.insertAdjacentHTML('BeforeEnd',html);
}
else // for standards-compilant browsers
{
var frame = document.createElement('IFRAME');
frame.name = frame_name;
frame.style.border = 'none';
frame.style.width = 0;
frame.style.height = 0;
frame.style.visibility = 'hidden';
document.body.appendChild(frame);
}
form.target = frame_name;
form.action = this.env.comm_path+'&_action=upload';
form.setAttribute('enctype', 'multipart/form-data');
form.submit();
}
// set reference to the form object
this.gui_objects.attachmentform = form;
return true;
};
// add file name to attachment list
// called from upload page
this.add2attachment_list = function(name, content)
{
if (!this.gui_objects.attachmentlist)
return false;
var li = document.createElement('LI');
li.id = name;
li.innerHTML = content;
this.gui_objects.attachmentlist.appendChild(li);
return true;
};
this.remove_from_attachment_list = function(name)
{
if (!this.gui_objects.attachmentlist)
return false;
var list = this.gui_objects.attachmentlist.getElementsByTagName("li");
for (i=0;i<list.length;i++)
if (list[i].id == name)
this.gui_objects.attachmentlist.removeChild(list[i]);
};
this.remove_attachment = function(name)
{
if (name)
this.http_post('remove-attachment', '_file='+urlencode(name));
return true;
};
// send remote request to add a new contact
this.add_contact = function(value)
{
if (value)
this.http_post('addcontact', '_address='+value);
return true;
};
// send remote request to search mail or contacts
this.qsearch = function(value)
{
if (value != '')
{
if (this.message_list)
this.message_list.clear();
else if (this.contact_list) {
this.contact_list.clear(true);
this.show_contentframe(false);
}
// reset vars
this.env.current_page = 1;
this.set_busy(true, 'searching');
this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')+(this.env.source ? '&_source='+urlencode(this.env.source) : ''), true);
}
return true;
};
// reset quick-search form
this.reset_qsearch = function()
{
if (this.gui_objects.qsearchbox)
this.gui_objects.qsearchbox.value = '';
this.env.search_request = null;
return true;
};
this.sent_successfully = function(type, msg)
{
this.list_mailbox();
this.display_message(msg, type, true);
}
/*********************************************************/
/********* keyboard live-search methods *********/
/*********************************************************/
// handler for keyboard events on address-fields
this.ksearch_keypress = function(e, obj)
{
if (typeof(this.env.contacts)!='object' || !this.env.contacts.length)
return true;
if (this.ksearch_timer)
clearTimeout(this.ksearch_timer);
var highlight;
var key = rcube_event.get_keycode(e);
var mod = rcube_event.get_modifier(e);
switch (key)
{
case 38: // key up
case 40: // key down
if (!this.ksearch_pane)
break;
var dir = key==38 ? 1 : 0;
var next;
highlight = document.getElementById('rcmksearchSelected');
if (!highlight)
highlight = this.ksearch_pane.ul.firstChild;
if (highlight && (next = dir ? highlight.previousSibling : highlight.nextSibling))
{
highlight.removeAttribute('id');
this.set_classname(highlight, 'selected', false);
}
if (next)
{
next.setAttribute('id', 'rcmksearchSelected');
this.set_classname(next, 'selected', true);
this.ksearch_selected = next._rcm_id;
}
return rcube_event.cancel(e);
case 9: // tab
if(mod == SHIFT_KEY)
break;
case 13: // enter
if (this.ksearch_selected===null || !this.ksearch_input || !this.ksearch_value)
break;
// insert selected address and hide ksearch pane
this.insert_recipient(this.ksearch_selected);
this.ksearch_hide();
return rcube_event.cancel(e);
case 27: // escape
this.ksearch_hide();
break;
}
// start timer
this.ksearch_timer = window.setTimeout(function(){ ref.ksearch_get_results(); }, 200);
this.ksearch_input = obj;
return true;
};
this.insert_recipient = function(id)
{
if (!this.env.contacts[id] || !this.ksearch_input)
return;
// get cursor pos
var inp_value = this.ksearch_input.value.toLowerCase();
var cpos = this.get_caret_pos(this.ksearch_input);
var p = inp_value.lastIndexOf(this.ksearch_value, cpos);
// replace search string with full address
var pre = this.ksearch_input.value.substring(0, p);
var end = this.ksearch_input.value.substring(p+this.ksearch_value.length, this.ksearch_input.value.length);
var insert = this.env.contacts[id]+', ';
this.ksearch_input.value = pre + insert + end;
// set caret to insert pos
cpos = p+insert.length;
if (this.ksearch_input.setSelectionRange)
this.ksearch_input.setSelectionRange(cpos, cpos);
};
// address search processor
this.ksearch_get_results = function()
{
var inp_value = this.ksearch_input ? this.ksearch_input.value : null;
if (inp_value===null)
return;
// get string from current cursor pos to last comma
var cpos = this.get_caret_pos(this.ksearch_input);
var p = inp_value.lastIndexOf(',', cpos-1);
var q = inp_value.substring(p+1, cpos);
// trim query string
q = q.replace(/(^\s+|\s+$)/g, '').toLowerCase();
if (!q.length || q==this.ksearch_value)
{
if (!q.length && this.ksearch_pane && this.ksearch_pane.visible)
this.ksearch_pane.show(0);
return;
}
this.ksearch_value = q;
// start searching the contact list
var a_results = new Array();
var a_result_ids = new Array();
var c=0;
for (var i=0; i<this.env.contacts.length; i++)
{
if (this.env.contacts[i].toLowerCase().indexOf(q)>=0)
{
a_results[c] = this.env.contacts[i];
a_result_ids[c++] = i;
if (c==15) // limit search results
break;
}
}
// display search results
if (c && a_results.length)
{
var p, ul, li;
// create results pane if not present
if (!this.ksearch_pane)
{
ul = document.createElement('UL');
this.ksearch_pane = new rcube_layer('rcmKSearchpane', {vis:0, zindex:30000});
this.ksearch_pane.elm.appendChild(ul);
this.ksearch_pane.ul = ul;
}
else
ul = this.ksearch_pane.ul;
// remove all search results
ul.innerHTML = '';
// add each result line to list
for (i=0; i<a_results.length; i++)
{
li = document.createElement('LI');
li.innerHTML = a_results[i].replace(/</, '&lt;').replace(/>/, '&gt;');
li._rcm_id = a_result_ids[i];
ul.appendChild(li);
}
// check if last selected item is still in result list
if (this.ksearch_selected!==null)
{
p = find_in_array(this.ksearch_selected, a_result_ids);
if (p>=0 && ul.childNodes)
{
ul.childNodes[p].setAttribute('id', 'rcmksearchSelected');
this.set_classname(ul.childNodes[p], 'selected', true);
}
else
this.ksearch_selected = null;
}
// if no item selected, select the first one
if (this.ksearch_selected===null)
{
ul.firstChild.setAttribute('id', 'rcmksearchSelected');
this.set_classname(ul.firstChild, 'selected', true);
this.ksearch_selected = a_result_ids[0];
}
// move the results pane right under the input box and make it visible
var pos = rcube_get_object_pos(this.ksearch_input);
this.ksearch_pane.move(pos.x, pos.y+this.ksearch_input.offsetHeight);
this.ksearch_pane.show(1);
}
// hide results pane
else
this.ksearch_hide();
};
this.ksearch_blur = function(e, obj)
{
if (this.ksearch_timer)
clearTimeout(this.ksearch_timer);
this.ksearch_value = '';
this.ksearch_input = null;
this.ksearch_hide();
};
this.ksearch_hide = function()
{
this.ksearch_selected = null;
if (this.ksearch_pane)
this.ksearch_pane.show(0);
};
/*********************************************************/
/********* address book methods *********/
/*********************************************************/
this.contactlist_keypress = function(list)
{
if (list.key_pressed == list.DELETE_KEY)
this.command('delete');
};
this.contactlist_select = function(list)
{
if (this.preview_timer)
clearTimeout(this.preview_timer);
var id, frame, ref = this;
if (id = list.get_single_selection())
this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200);
else if (this.env.contentframe)
this.show_contentframe(false);
this.enable_command('compose', list.selection.length > 0);
this.enable_command('edit', (id && this.env.address_sources && !this.env.address_sources[this.env.source].readonly) ? true : false);
this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly);
return false;
};
this.list_contacts = function(src, page)
{
var add_url = '';
var target = window;
if (!src)
src = this.env.source;
if (page && this.current_page==page && src == this.env.source)
return false;
if (src != this.env.source)
{
page = 1;
this.env.current_page = page;
this.reset_qsearch();
}
this.select_folder(src, this.env.source);
this.env.source = src;
// load contacts remotely
if (this.gui_objects.contactslist)
{
this.list_contacts_remote(src, page);
return;
}
if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
target = window.frames[this.env.contentframe];
add_url = '&_framed=1';
}
// also send search request to get the correct listing
if (this.env.search_request)
add_url += '&_search='+this.env.search_request;
this.set_busy(true, 'loading');
target.location.href = this.env.comm_path+(src ? '&_source='+urlencode(src) : '')+(page ? '&_page='+page : '')+add_url;
};
// send remote request to load contacts list
this.list_contacts_remote = function(src, page)
{
// clear message list first
this.contact_list.clear(true);
this.show_contentframe(false);
this.enable_command('delete', 'compose', false);
// send request to server
var url = (src ? '_source='+urlencode(src) : '') + (page ? (src?'&':'') + '_page='+page : '');
this.env.source = src;
// also send search request to get the right messages
if (this.env.search_request)
url += '&_search='+this.env.search_request;
this.set_busy(true, 'loading');
this.http_request('list', url, true);
};
// load contact record
this.load_contact = function(cid, action, framed)
{
var add_url = '';
var target = window;
if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
add_url = '&_framed=1';
target = window.frames[this.env.contentframe];
this.show_contentframe(true);
}
else if (framed)
return false;
if (action && (cid || action=='add') && !this.drag_active)
{
this.set_busy(true);
target.location.href = this.env.comm_path+'&_action='+action+'&_source='+urlencode(this.env.source)+'&_cid='+urlencode(cid) + add_url;
}
return true;
};
// copy a contact to the specified target (group or directory)
this.copy_contact = function(cid, to)
{
if (!cid)
cid = this.contact_list.get_selection().join(',');
if (to != this.env.source && cid && this.env.address_sources[to] && !this.env.address_sources[to].readonly)
this.http_post('copy', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_to='+urlencode(to));
};
this.delete_contacts = function()
{
// exit if no mailbox specified or if selection is empty
var selection = this.contact_list.get_selection();
if (!(selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm')))
return;
var a_cids = new Array();
var qs = '';
if (this.env.cid)
a_cids[a_cids.length] = this.env.cid;
else
{
var id;
for (var n=0; n<selection.length; n++)
{
id = selection[n];
a_cids[a_cids.length] = id;
this.contact_list.remove_row(id, (n == selection.length-1));
}
// hide content frame if we delete the currently displayed contact
if (selection.length == 1)
this.show_contentframe(false);
}
// also send search request to get the right records from the next page
if (this.env.search_request)
qs += '&_search='+this.env.search_request;
// send request to server
this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);
return true;
};
// update a contact record in the list
this.update_contact_row = function(cid, cols_arr)
{
var row;
if (this.contact_list.rows[cid] && (row = this.contact_list.rows[cid].obj))
{
for (var c=0; c<cols_arr.length; c++)
if (row.cells[c])
row.cells[c].innerHTML = cols_arr[c];
return true;
}
return false;
};
/*********************************************************/
/********* user settings methods *********/
/*********************************************************/
this.init_subscription_list = function()
{
var p = this;
this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false, toggleselect:true});
this.subscription_list.addEventListener('select', function(o){ p.subscription_select(o); });
this.subscription_list.addEventListener('dragstart', function(o){ p.drag_active = true; });
this.subscription_list.addEventListener('dragend', function(o){ p.subscription_move_folder(o); });
this.subscription_list.row_init = function (row)
{
var anchors = row.obj.getElementsByTagName('A');
if (anchors[0])
anchors[0].onclick = function() { p.rename_folder(row.id); return false; };
if (anchors[1])
anchors[1].onclick = function() { p.delete_folder(row.id); return false; };
row.obj.onmouseover = function() { p.focus_subscription(row.id); };
row.obj.onmouseout = function() { p.unfocus_subscription(row.id); };
}
this.subscription_list.init();
}
this.identity_select = function(list)
{
var id;
if (id = list.get_single_selection())
this.load_identity(id, 'edit-identity');
};
// load contact record
this.load_identity = function(id, action)
{
if (action=='edit-identity' && (!id || id==this.env.iid))
return false;
var add_url = '';
var target = window;
if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
{
add_url = '&_framed=1';
target = window.frames[this.env.contentframe];
document.getElementById(this.env.contentframe).style.visibility = 'inherit';
}
if (action && (id || action=='add-identity'))
{
this.set_busy(true);
target.location.href = this.env.comm_path+'&_action='+action+'&_iid='+id+add_url;
}
return true;
};
this.delete_identity = function(id)
{
// exit if no mailbox specified or if selection is empty
var selection = this.identity_list.get_selection();
if (!(selection.length || this.env.iid))
return;
if (!id)
id = this.env.iid ? this.env.iid : selection[0];
// if (this.env.framed && id)
this.goto_url('delete-identity', '_iid='+id, true);
return true;
};
this.focus_subscription = function(id)
{
var row, folder;
var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$');
if (this.drag_active && this.env.folder && (row = document.getElementById(id)))
if (this.env.subscriptionrows[id] &&
(folder = this.env.subscriptionrows[id][0]))
{
if (this.check_droptarget(folder) &&
!this.env.subscriptionrows[this.get_folder_row_id(this.env.folder)][2] &&
(folder != this.env.folder.replace(reg, '')) &&
(!folder.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter)))))
{
this.set_env('dstfolder', folder);
this.set_classname(row, 'droptarget', true);
}
}
else if (this.env.folder.match(new RegExp(RegExp.escape(this.env.delimiter))))
{
this.set_env('dstfolder', this.env.delimiter);
this.set_classname(this.subscription_list.frame, 'droptarget', true);
}
}
this.unfocus_subscription = function(id)
{
var row;
this.set_env('dstfolder', null);
if (this.env.subscriptionrows[id] &&
(row = document.getElementById(id)))
this.set_classname(row, 'droptarget', false);
else
this.set_classname(this.subscription_list.frame, 'droptarget', false);
}
this.subscription_select = function(list)
{
var id, folder;
if ((id = list.get_single_selection()) &&
this.env.subscriptionrows['rcmrow'+id] &&
(folder = this.env.subscriptionrows['rcmrow'+id][0]))
this.set_env('folder', folder);
else
this.set_env('folder', null);
if (this.gui_objects.createfolderhint)
this.gui_objects.createfolderhint.innerHTML = this.env.folder ? this.get_label('addsubfolderhint') : '';
};
this.subscription_move_folder = function(list)
{
var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$');
if (this.env.folder && this.env.dstfolder && (this.env.dstfolder != this.env.folder) &&
(this.env.dstfolder != this.env.folder.replace(reg, '')))
{
var reg = new RegExp('[^'+RegExp.escape(this.env.delimiter)+']*['+RegExp.escape(this.env.delimiter)+']', 'g');
var basename = this.env.folder.replace(reg, '');
var newname = this.env.dstfolder==this.env.delimiter ? basename : this.env.dstfolder+this.env.delimiter+basename;
this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.folder)+'&_folder_newname='+urlencode(newname));
}
this.drag_active = false;
this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder));
};
// tell server to create and subscribe a new mailbox
this.create_folder = function(name)
{
if (this.edit_folder)
this.reset_folder_rename();
var form;
if ((form = this.gui_objects.editform) && form.elements['_folder_name'])
{
name = form.elements['_folder_name'].value;
if (name.indexOf(this.env.delimiter)>=0)
{
alert(this.get_label('forbiddencharacter')+' ('+this.env.delimiter+')');
return false;
}
if (this.env.folder && name != '')
name = this.env.folder+this.env.delimiter+name;
this.http_post('create-folder', '_name='+urlencode(name), true);
}
else if (form.elements['_folder_name'])
form.elements['_folder_name'].focus();
};
// start renaming the mailbox name.
// this will replace the name string with an input field
this.rename_folder = function(id)
{
var temp, row, form;
// reset current renaming
if (temp = this.edit_folder)
{
this.reset_folder_rename();
if (temp == id)
return;
}
if (id && this.env.subscriptionrows[id] && (row = document.getElementById(id)))
{
var reg = new RegExp('.*['+RegExp.escape(this.env.delimiter)+']');
this.name_input = document.createElement('INPUT');
this.name_input.value = this.env.subscriptionrows[id][0].replace(reg, '');
this.name_input.style.width = '100%';
reg = new RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$');
this.name_input.__parent = this.env.subscriptionrows[id][0].replace(reg, '');
this.name_input.onkeypress = function(e){ rcmail.name_input_keypress(e); };
row.cells[0].replaceChild(this.name_input, row.cells[0].firstChild);
this.edit_folder = id;
this.name_input.select();
if (form = this.gui_objects.editform)
form.onsubmit = function(){ return false; };
}
};
// remove the input field and write the current mailbox name to the table cell
this.reset_folder_rename = function()
{
var cell = this.name_input ? this.name_input.parentNode : null;
if (cell && this.edit_folder && this.env.subscriptionrows[this.edit_folder])
cell.innerHTML = this.env.subscriptionrows[this.edit_folder][1];
this.edit_folder = null;
};
// handler for keyboard events on the input field
this.name_input_keypress = function(e)
{
var key = rcube_event.get_keycode(e);
// enter
if (key==13)
{
var newname = this.name_input ? this.name_input.value : null;
if (this.edit_folder && newname)
{
if (newname.indexOf(this.env.delimiter)>=0)
{
alert(this.get_label('forbiddencharacter')+' ('+this.env.delimiter+')');
return false;
}
if (this.name_input.__parent)
newname = this.name_input.__parent + this.env.delimiter + newname;
this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.subscriptionrows[this.edit_folder][0])+'&_folder_newname='+urlencode(newname), true);
}
}
// escape
else if (key==27)
this.reset_folder_rename();
};
// delete a specific mailbox with all its messages
this.delete_folder = function(id)
{
var folder = this.env.subscriptionrows[id][0];
if (this.edit_folder)
this.reset_folder_rename();
if (folder && confirm(this.get_label('deletefolderconfirm')))
{
this.http_post('delete-folder', '_mboxes='+urlencode(folder));
this.set_env('folder', null);
if (this.gui_objects.createfolderhint)
this.gui_objects.createfolderhint.innerHTML = '';
}
};
// add a new folder to the subscription list by cloning a folder row
this.add_folder_row = function(name, display_name, replace, before)
{
if (!this.gui_objects.subscriptionlist)
return false;
// find not protected folder
for (var refid in this.env.subscriptionrows)
if (this.env.subscriptionrows[refid]!=null && !this.env.subscriptionrows[refid][2])
break;
var refrow, form;
var tbody = this.gui_objects.subscriptionlist.tBodies[0];
var id = 'rcmrow'+(tbody.childNodes.length+1);
var selection = this.subscription_list.get_single_selection();
if (replace && replace.id)
{
id = replace.id;
refid = replace.id;
}
if (!id || !(refrow = document.getElementById(refid)))
{
// Refresh page if we don't have a table row to clone
this.goto_url('folders');
}
else
{
// clone a table row if there are existing rows
var row = this.clone_table_row(refrow);
row.id = id;
if (before && (before = this.get_folder_row_id(before)))
tbody.insertBefore(row, document.getElementById(before));
else
tbody.appendChild(row);
if (replace)
tbody.removeChild(replace);
}
// add to folder/row-ID map
this.env.subscriptionrows[row.id] = [name, display_name, 0];
// set folder name
row.cells[0].innerHTML = display_name;
// set messages count to zero
if (!replace)
row.cells[1].innerHTML = '*';
if (!replace && row.cells[2] && row.cells[2].firstChild.tagName=='INPUT')
{
row.cells[2].firstChild.value = name;
row.cells[2].firstChild.checked = true;
}
// add new folder to rename-folder list and clear input field
if (!replace && (form = this.gui_objects.editform))
{
if (form.elements['_folder_oldname'])
form.elements['_folder_oldname'].options[form.elements['_folder_oldname'].options.length] = new Option(name,name);
if (form.elements['_folder_name'])
form.elements['_folder_name'].value = '';
}
this.init_subscription_list();
if (selection && document.getElementById('rcmrow'+selection))
this.subscription_list.select_row(selection);
if (document.getElementById(id).scrollIntoView)
document.getElementById(id).scrollIntoView();
};
// replace an existing table row with a new folder line
this.replace_folder_row = function(oldfolder, newfolder, display_name, before)
{
var id = this.get_folder_row_id(oldfolder);
var row = document.getElementById(id);
// replace an existing table row (if found)
this.add_folder_row(newfolder, display_name, row, before);
// rename folder in rename-folder dropdown
var form, elm;
if ((form = this.gui_objects.editform) && (elm = form.elements['_folder_oldname']))
{
for (var i=0;i<elm.options.length;i++)
{
if (elm.options[i].value == oldfolder)
{
elm.options[i].text = display_name;
elm.options[i].value = newfolder;
break;
}
}
form.elements['_folder_newname'].value = '';
}
};
// remove the table row of a specific mailbox from the table
// (the row will not be removed, just hidden)
this.remove_folder_row = function(folder)
{
var row;
var id = this.get_folder_row_id(folder);
if (id && (row = document.getElementById(id)))
row.style.display = 'none';
// remove folder from rename-folder list
var form;
if ((form = this.gui_objects.editform) && form.elements['_folder_oldname'])
{
for (var i=0;i<form.elements['_folder_oldname'].options.length;i++)
{
if (form.elements['_folder_oldname'].options[i].value == folder)
{
form.elements['_folder_oldname'].options[i] = null;
break;
}
}
}
if (form && form.elements['_folder_newname'])
form.elements['_folder_newname'].value = '';
};
this.subscribe_folder = function(folder)
{
if (folder)
this.http_post('subscribe', '_mbox='+urlencode(folder));
};
this.unsubscribe_folder = function(folder)
{
if (folder)
this.http_post('unsubscribe', '_mbox='+urlencode(folder));
};
// helper method to find a specific mailbox row ID
this.get_folder_row_id = function(folder)
{
for (var id in this.env.subscriptionrows)
if (this.env.subscriptionrows[id] && this.env.subscriptionrows[id][0] == folder)
break;
return id;
};
// duplicate a specific table row
this.clone_table_row = function(row)
{
var cell, td;
var new_row = document.createElement('TR');
for(var n=0; n<row.cells.length; n++)
{
cell = row.cells[n];
td = document.createElement('TD');
if (cell.className)
td.className = cell.className;
if (cell.align)
td.setAttribute('align', cell.align);
td.innerHTML = cell.innerHTML;
new_row.appendChild(td);
}
return new_row;
};
/*********************************************************/
/********* GUI functionality *********/
/*********************************************************/
// eable/disable buttons for page shifting
this.set_page_buttons = function()
{
this.enable_command('nextpage', (this.env.pagecount > this.env.current_page));
this.enable_command('lastpage', (this.env.pagecount > this.env.current_page));
this.enable_command('previouspage', (this.env.current_page > 1));
this.enable_command('firstpage', (this.env.current_page > 1));
}
// set button to a specific state
this.set_button = function(command, state)
{
var a_buttons = this.buttons[command];
var button, obj;
if(!a_buttons || !a_buttons.length)
return false;
for(var n=0; n<a_buttons.length; n++)
{
button = a_buttons[n];
obj = document.getElementById(button.id);
// get default/passive setting of the button
if (obj && button.type=='image' && !button.status) {
button.pas = obj._original_src ? obj._original_src : obj.src;
// respect PNG fix on IE browsers
if (obj.runtimeStyle && obj.runtimeStyle.filter && obj.runtimeStyle.filter.match(/src=['"]([^'"]+)['"]/))
button.pas = RegExp.$1;
}
else if (obj && !button.status)
button.pas = String(obj.className);
// set image according to button state
if (obj && button.type=='image' && button[state])
{
button.status = state;
obj.src = button[state];
}
// set class name according to button state
else if (obj && typeof(button[state])!='undefined')
{
button.status = state;
obj.className = button[state];
}
// disable/enable input buttons
if (obj && button.type=='input')
{
button.status = state;
obj.disabled = !state;
}
}
};
// display a specific alttext
this.set_alttext = function(command, label)
{
if (!this.buttons[command] || !this.buttons[command].length)
return;
var button, obj, link;
for (var n=0; n<this.buttons[command].length; n++)
{
button = this.buttons[command][n];
obj = document.getElementById(button.id);
if (button.type=='image' && obj)
{
obj.setAttribute('alt', this.get_label(label));
if ((link = obj.parentNode) && link.tagName == 'A')
link.setAttribute('title', this.get_label(label));
}
else if (obj)
obj.setAttribute('title', this.get_label(label));
}
};
// mouse over button
this.button_over = function(command, id)
{
var a_buttons = this.buttons[command];
var button, img;
if(!a_buttons || !a_buttons.length)
return false;
for(var n=0; n<a_buttons.length; n++)
{
button = a_buttons[n];
if(button.id==id && button.status=='act')
{
img = document.getElementById(button.id);
if (img && button.over)
img.src = button.over;
}
}
};
// mouse down on button
this.button_sel = function(command, id)
{
var a_buttons = this.buttons[command];
var button, img;
if(!a_buttons || !a_buttons.length)
return;
for(var n=0; n<a_buttons.length; n++)
{
button = a_buttons[n];
if(button.id==id && button.status=='act')
{
img = document.getElementById(button.id);
if (img && button.sel)
img.src = button.sel;
}
}
};
// mouse out of button
this.button_out = function(command, id)
{
var a_buttons = this.buttons[command];
var button, img;
if(!a_buttons || !a_buttons.length)
return;
for(var n=0; n<a_buttons.length; n++)
{
button = a_buttons[n];
if(button.id==id && button.status=='act')
{
img = document.getElementById(button.id);
if (img && button.act)
img.src = button.act;
}
}
};
// set/unset a specific class name
this.set_classname = function(obj, classname, set)
{
var reg = new RegExp('\s*'+classname, 'i');
if (!set && obj.className.match(reg))
obj.className = obj.className.replace(reg, '');
else if (set && !obj.className.match(reg))
obj.className += ' '+classname;
};
// write to the document/window title
this.set_pagetitle = function(title)
{
if (title && document.title)
document.title = title;
}
// display a system message
this.display_message = function(msg, type, hold)
{
if (!this.loaded) // save message in order to display after page loaded
{
this.pending_message = new Array(msg, type);
return true;
}
// pass command to parent window
if (this.env.framed && parent.rcmail)
return parent.rcmail.display_message(msg, type, hold);
if (!this.gui_objects.message)
return false;
if (this.message_timer)
clearTimeout(this.message_timer);
var cont = msg;
if (type)
cont = '<div class="'+type+'">'+cont+'</div>';
var _rcube = this;
this.gui_objects.message.innerHTML = cont;
this.gui_objects.message.style.display = 'block';
if (type!='loading')
this.gui_objects.message.onmousedown = function(){ _rcube.hide_message(); return true; };
if (!hold)
this.message_timer = window.setTimeout(function(){ ref.hide_message(); }, this.message_time);
};
// make a message row disapear
this.hide_message = function()
{
if (this.gui_objects.message)
{
this.gui_objects.message.style.display = 'none';
this.gui_objects.message.onmousedown = null;
}
};
// mark a mailbox as selected and set environment variable
this.select_folder = function(name, old)
{
if (this.gui_objects.folderlist)
{
var current_li, target_li;
if ((current_li = this.get_folder_li(old)))
{
this.set_classname(current_li, 'selected', false);
this.set_classname(current_li, 'unfocused', false);
}
if ((target_li = this.get_folder_li(name)))
{
this.set_classname(target_li, 'unfocused', false);
this.set_classname(target_li, 'selected', true);
}
}
};
// helper method to find a folder list item
this.get_folder_li = function(name)
{
if (this.gui_objects.folderlist)
{
name = String(name).replace(this.identifier_expr, '');
return document.getElementById('rcmli'+name);
}
return null;
};
// for reordering column array, Konqueror workaround
this.set_message_coltypes = function(coltypes)
{
this.coltypes = coltypes;
// set correct list titles
var cell, col;
var thead = this.gui_objects.messagelist ? this.gui_objects.messagelist.tHead : null;
for (var n=0; thead && n<this.coltypes.length; n++)
{
col = this.coltypes[n];
if ((cell = thead.rows[0].cells[n+1]) && (col=='from' || col=='to'))
{
// if we have links for sorting, it's a bit more complicated...
if (cell.firstChild && cell.firstChild.tagName=='A')
{
cell.firstChild.innerHTML = this.get_label(this.coltypes[n]);
cell.firstChild.onclick = function(){ return rcmail.command('sort', this.__col, this); };
cell.firstChild.__col = col;
}
else
cell.innerHTML = this.get_label(this.coltypes[n]);
cell.id = 'rcmHead'+col;
}
else if (col == 'subject' && this.message_list)
this.message_list.subject_col = n+1;
else if (col == 'flag' && this.env.unflaggedicon)
{
cell.innerHTML = '<img src="'+this.env.unflaggedicon+'" alt="" />';
}
}
};
// create a table row in the message list
this.add_message_row = function(uid, cols, flags, attachment, attop)
{
if (!this.gui_objects.messagelist || !this.message_list)
return false;
var tbody = this.gui_objects.messagelist.tBodies[0];
var rowcount = tbody.rows.length;
var even = rowcount%2;
this.env.messages[uid] = {deleted:flags.deleted?1:0,
replied:flags.replied?1:0,
unread:flags.unread?1:0,
flagged:flags.flagged?1:0};
var row = document.createElement('TR');
row.id = 'rcmrow'+uid;
row.className = 'message '+(even ? 'even' : 'odd')+(flags.unread ? ' unread' : '')+(flags.deleted ? ' deleted' : '');
if (this.message_list.in_selection(uid))
row.className += ' selected';
var icon = flags.deleted && this.env.deletedicon ? this.env.deletedicon:
(flags.unread && this.env.unreadicon ? this.env.unreadicon :
(flags.replied && this.env.repliedicon ? this.env.repliedicon : this.env.messageicon));
var col = document.createElement('TD');
col.className = 'icon';
col.innerHTML = icon ? '<img src="'+icon+'" alt="" />' : '';
row.appendChild(col);
// add each submitted col
for (var n = 0; n < this.coltypes.length; n++)
{
var c = this.coltypes[n];
col = document.createElement('TD');
col.className = String(c).toLowerCase();
if (c=='flag')
{
if (flags.flagged && this.env.flaggedicon)
col.innerHTML = '<img src="'+this.env.flaggedicon+'" alt="" />';
else if(this.env.unflaggedicon)
col.innerHTML = '<img src="'+this.env.unflaggedicon+'" alt="" />';
}
else
col.innerHTML = cols[c];
row.appendChild(col);
}
col = document.createElement('TD');
col.className = 'icon';
col.innerHTML = attachment && this.env.attachmenticon ? '<img src="'+this.env.attachmenticon+'" alt="" />' : '';
row.appendChild(col);
this.message_list.insert_row(row, attop);
};
// replace content of row count display
this.set_rowcount = function(text)
{
if (this.gui_objects.countdisplay)
this.gui_objects.countdisplay.innerHTML = text;
// update page navigation buttons
this.set_page_buttons();
};
// replace content of mailboxname display
this.set_mailboxname = function(content)
{
if (this.gui_objects.mailboxname && content)
this.gui_objects.mailboxname.innerHTML = content;
};
// replace content of quota display
this.set_quota = function(content)
{
if (this.gui_objects.quotadisplay && content)
this.gui_objects.quotadisplay.innerHTML = content;
};
// update the mailboxlist
this.set_unread_count = function(mbox, count, set_title)
{
if (!this.gui_objects.mailboxlist)
return false;
this.env.unread_counts[mbox] = count;
this.set_unread_count_display(mbox, set_title);
}
// update the mailbox count display
this.set_unread_count_display = function(mbox, set_title)
{
var reg, text_obj, item, mycount, childcount, div;
if (item = this.get_folder_li(mbox))
{
mycount = this.env.unread_counts[mbox];
text_obj = item.getElementsByTagName('a')[0];
reg = /\s+\([0-9]+\)$/i;
childcount = 0;
if ((div = item.getElementsByTagName('div')[0]) &&
div.className.match(/collapsed/))
{
// add children's counters
for (var k in this.env.unread_counts)
if (k.indexOf(mbox + this.env.delimiter) == 0) {
childcount += this.env.unread_counts[k];
}
}
if (mycount && text_obj.innerHTML.match(reg))
text_obj.innerHTML = text_obj.innerHTML.replace(reg, ' ('+mycount+')');
else if (mycount)
text_obj.innerHTML += ' ('+mycount+')';
else
text_obj.innerHTML = text_obj.innerHTML.replace(reg, '');
// set parent's display
reg = new RegExp(RegExp.escape(this.env.delimiter) + '[^' + RegExp.escape(this.env.delimiter) + ']+');
if (mbox.match(reg))
this.set_unread_count_display(mbox.replace(reg, ''), false);
// set the right classes
this.set_classname(item, 'unread', (mycount+childcount)>0 ? true : false);
}
// set unread count to window title
reg = /^\([0-9]+\)\s+/i;
if (set_title && document.title)
{
var doc_title = String(document.title);
var new_title = "";
if (mycount && doc_title.match(reg))
new_title = doc_title.replace(reg, '('+mycount+') ');
else if (mycount)
new_title = '('+mycount+') '+doc_title;
else
new_title = doc_title.replace(reg, '');
this.set_pagetitle(new_title);
}
};
// update parent's mailboxlist (from preview)
this.set_unread_count_from_preview = function(mbox, count, set_title)
{
parent.rcmail.set_unread_count(mbox, count, set_title);
}
// add row to contacts list
this.add_contact_row = function(cid, cols, select)
{
if (!this.gui_objects.contactslist || !this.gui_objects.contactslist.tBodies[0])
return false;
var tbody = this.gui_objects.contactslist.tBodies[0];
var rowcount = tbody.rows.length;
var even = rowcount%2;
var row = document.createElement('TR');
row.id = 'rcmrow'+cid;
row.className = 'contact '+(even ? 'even' : 'odd');
if (this.contact_list.in_selection(cid))
row.className += ' selected';
// add each submitted col
for (var c in cols)
{
col = document.createElement('TD');
col.className = String(c).toLowerCase();
col.innerHTML = cols[c];
row.appendChild(col);
}
this.contact_list.insert_row(row);
this.enable_command('export', (this.contact_list.rowcount > 0));
};
this.toggle_editor = function(checkbox, textAreaId)
{
var ischecked = checkbox.checked;
if (ischecked)
{
tinyMCE.execCommand('mceAddControl', true, textAreaId);
}
else
{
tinyMCE.execCommand('mceRemoveControl', true, textAreaId);
}
};
this.toggle_prefer_html = function(checkbox)
{
var addrbook_show_images;
if (addrbook_show_images = document.getElementById('rcmfd_addrbook_show_images'))
addrbook_show_images.disabled = !checkbox.checked;
}
+ // display fetched raw headers
+ this.set_headers = function(content)
+ {
+ if (this.gui_objects.all_headers_row && this.gui_objects.all_headers_box && content)
+ {
+ var box = this.gui_objects.all_headers_box;
+ box.innerHTML = content;
+ box.style.display = 'block';
+
+ if (this.env.framed && parent.rcmail)
+ parent.rcmail.set_busy(false);
+ else
+ this.set_busy(false);
+ }
+ };
+
+ // display all-headers row and fetch raw message headers
+ this.load_headers = function(elem)
+ {
+ if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box || !this.env.uid)
+ return;
+
+ this.set_classname(elem, 'show-headers', false);
+ this.set_classname(elem, 'hide-headers', true);
+ this.gui_objects.all_headers_row.style.display = bw.ie ? 'block' : 'table-row';
+ elem.onclick = function() { rcmail.hide_headers(elem); }
+
+ // fetch headers only once
+ if (!this.gui_objects.all_headers_box.innerHTML)
+ {
+ this.set_busy(true, 'loading');
+ this.http_post('headers', '_uid='+this.env.uid);
+ }
+ }
+
+
+ // hide all-headers row
+ this.hide_headers = function(elem)
+ {
+ if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box)
+ return;
+
+ this.set_classname(elem, 'hide-headers', false);
+ this.set_classname(elem, 'show-headers', true);
+ this.gui_objects.all_headers_row.style.display = 'none';
+ elem.onclick = function() { rcmail.load_headers(elem); }
+ }
+
/********************************************************/
/********* remote request methods *********/
/********************************************************/
this.redirect = function(url, lock)
{
if (lock || lock === null)
this.set_busy(true);
if (this.env.framed && window.parent)
parent.location.href = url;
else
location.href = url;
};
this.goto_url = function(action, query, lock)
{
var querystring = query ? '&'+query : '';
this.redirect(this.env.comm_path+'&_action='+action+querystring, lock);
};
this.http_sockets = new Array();
// find a non-busy socket or create a new one
this.get_request_obj = function()
{
for (var n=0; n<this.http_sockets.length; n++)
{
if (!this.http_sockets[n].busy)
return this.http_sockets[n];
}
// create a new XMLHTTP object
var i = this.http_sockets.length;
this.http_sockets[i] = new rcube_http_request();
return this.http_sockets[i];
};
// send a http request to the server
this.http_request = function(action, querystring, lock)
{
var request_obj = this.get_request_obj();
querystring += (querystring ? '&' : '') + '_remote=1';
// add timestamp to request url to avoid cacheing problems in Safari
if (bw.safari)
querystring += '&_ts='+(new Date().getTime());
// send request
if (request_obj)
{
console.log('HTTP request: '+this.env.comm_path+'&_action='+action+'&'+querystring);
if (lock)
this.set_busy(true);
var rcm = this;
request_obj.__lock = lock ? true : false;
request_obj.__action = action;
request_obj.onerror = function(o){ ref.http_error(o); };
request_obj.oncomplete = function(o){ ref.http_response(o); };
request_obj.GET(this.env.comm_path+'&_action='+action+'&'+querystring);
}
};
// send a http POST request to the server
this.http_post = function(action, postdata, lock)
{
var request_obj;
if (postdata && typeof(postdata) == 'object')
postdata._remote = 1;
else
postdata += (postdata ? '&' : '') + '_remote=1';
// send request
if (request_obj = this.get_request_obj())
{
console.log('HTTP POST: '+this.env.comm_path+'&_action='+action);
if (lock)
this.set_busy(true);
var rcm = this;
request_obj.__lock = lock ? true : false;
request_obj.__action = action;
request_obj.onerror = function(o){ rcm.http_error(o); };
request_obj.oncomplete = function(o){ rcm.http_response(o); };
request_obj.POST(this.env.comm_path+'&_action='+action, postdata);
}
};
// handle HTTP response
this.http_response = function(request_obj)
{
var ctype = request_obj.get_header('Content-Type');
if (ctype){
ctype = String(ctype).toLowerCase();
var ctype_array=ctype.split(";");
ctype = ctype_array[0];
}
if (request_obj.__lock)
- this.set_busy(false);
+ this.set_busy(false);
console.log(request_obj.get_text());
// if we get javascript code from server -> execute it
if (request_obj.get_text() && (ctype=='text/javascript' || ctype=='application/x-javascript'))
eval(request_obj.get_text());
// process the response data according to the sent action
switch (request_obj.__action) {
case 'delete':
if (this.task == 'addressbook') {
var uid = this.contact_list.get_selection();
this.enable_command('compose', (uid && this.contact_list.rows[uid]));
this.enable_command('delete', 'edit', (uid && this.contact_list.rows[uid] && this.env.address_sources && !this.env.address_sources[this.env.source].readonly));
this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0));
}
case 'moveto':
if (this.env.action == 'show')
this.command('list');
else if (this.message_list)
this.message_list.init();
break;
case 'purge':
case 'expunge':
if (!this.env.messagecount && this.task == 'mail') {
// clear preview pane content
if (this.env.contentframe)
this.show_contentframe(false);
// disable commands useless when mailbox is empty
this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource',
'print', 'load-attachment', 'purge', 'expunge', 'select-all', 'select-none', 'sort', false);
}
break;
case 'check-recent':
case 'getunread':
case 'list':
if (this.task == 'mail') {
if (this.message_list)
this.msglist_select(this.message_list);
this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0));
this.enable_command('purge', this.purge_mailbox_test());
}
else if (this.task == 'addressbook')
this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0));
break;
}
request_obj.reset();
};
// handle HTTP request errors
this.http_error = function(request_obj)
{
//alert('Error sending request: '+request_obj.url+' => HTTP '+request_obj.xmlhttp.status);
if (request_obj.__lock)
this.set_busy(false);
request_obj.reset();
request_obj.__lock = false;
this.display_message('Unknown Server Error!', 'error');
};
// use an image to send a keep-alive siganl to the server
this.send_keep_alive = function()
{
var d = new Date();
this.http_request('keep-alive', '_t='+d.getTime());
};
// send periodic request to check for recent messages
this.check_for_recent = function()
{
if (this.busy)
return;
this.set_busy(true, 'checkingmail');
this.http_request('check-recent', (this.env.search_request ? '_search='+this.env.search_request+'&' : '') + '_t='+(new Date().getTime()), true);
};
/********************************************************/
/********* helper methods *********/
/********************************************************/
// check if we're in show mode or if we have a unique selection
// and return the message uid
this.get_single_uid = function()
{
return this.env.uid ? this.env.uid : (this.message_list ? this.message_list.get_single_selection() : null);
};
// same as above but for contacts
this.get_single_cid = function()
{
return this.env.cid ? this.env.cid : (this.contact_list ? this.contact_list.get_single_selection() : null);
};
this.get_caret_pos = function(obj)
{
if (typeof(obj.selectionEnd)!='undefined')
return obj.selectionEnd;
else if (document.selection && document.selection.createRange)
{
var range = document.selection.createRange();
if (range.parentElement()!=obj)
return 0;
var gm = range.duplicate();
if (obj.tagName=='TEXTAREA')
gm.moveToElementText(obj);
else
gm.expand('textedit');
gm.setEndPoint('EndToStart', range);
var p = gm.text.length;
return p<=obj.value.length ? p : -1;
}
else
return obj.value.length;
};
this.set_caret2start = function(obj)
{
if (obj.createTextRange)
{
var range = obj.createTextRange();
range.collapse(true);
range.select();
}
else if (obj.setSelectionRange)
obj.setSelectionRange(0,0);
obj.focus();
};
// set all fields of a form disabled
this.lock_form = function(form, lock)
{
if (!form || !form.elements)
return;
var type;
for (var n=0; n<form.elements.length; n++)
{
type = form.elements[n];
if (type=='hidden')
continue;
form.elements[n].disabled = lock;
}
};
} // end object rcube_webmail
/**
* Class for sending HTTP requests
* @constructor
*/
function rcube_http_request()
{
this.url = '';
this.busy = false;
this.xmlhttp = null;
// reset object properties
this.reset = function()
{
// set unassigned event handlers
this.onloading = function(){ };
this.onloaded = function(){ };
this.oninteractive = function(){ };
this.oncomplete = function(){ };
this.onabort = function(){ };
this.onerror = function(){ };
this.url = '';
this.busy = false;
this.xmlhttp = null;
}
// create HTMLHTTP object
this.build = function()
{
if (window.XMLHttpRequest)
this.xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject)
{
try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e) { this.xmlhttp = null; }
}
else
{
}
}
// send GET request
this.GET = function(url)
{
this.build();
if (!this.xmlhttp)
{
this.onerror(this);
return false;
}
var _ref = this;
this.url = url;
this.busy = true;
this.xmlhttp.onreadystatechange = function(){ _ref.xmlhttp_onreadystatechange(); };
this.xmlhttp.open('GET', url, true);
this.xmlhttp.setRequestHeader('X-RoundCube-Referer', bw.get_cookie('roundcube_sessid'));
this.xmlhttp.send(null);
};
this.POST = function(url, body, contentType)
{
// default value for contentType if not provided
if (typeof(contentType) == 'undefined')
contentType = 'application/x-www-form-urlencoded';
this.build();
if (!this.xmlhttp)
{
this.onerror(this);
return false;
}
var req_body = body;
if (typeof(body) == 'object')
{
req_body = '';
for (var p in body)
req_body += (req_body ? '&' : '') + p+'='+urlencode(body[p]);
}
var ref = this;
this.url = url;
this.busy = true;
this.xmlhttp.onreadystatechange = function() { ref.xmlhttp_onreadystatechange(); };
this.xmlhttp.open('POST', url, true);
this.xmlhttp.setRequestHeader('Content-Type', contentType);
this.xmlhttp.setRequestHeader('X-RoundCube-Referer', bw.get_cookie('roundcube_sessid'));
this.xmlhttp.send(req_body);
};
// handle onreadystatechange event
this.xmlhttp_onreadystatechange = function()
{
if(this.xmlhttp.readyState == 1)
this.onloading(this);
else if(this.xmlhttp.readyState == 2)
this.onloaded(this);
else if(this.xmlhttp.readyState == 3)
this.oninteractive(this);
else if(this.xmlhttp.readyState == 4)
{
try {
if (this.xmlhttp.status == 0)
this.onabort(this);
else if(this.xmlhttp.status == 200)
this.oncomplete(this);
else
this.onerror(this);
this.busy = false;
}
catch(err)
{
this.onerror(this);
this.busy = false;
}
}
}
// getter method for HTTP headers
this.get_header = function(name)
{
return this.xmlhttp.getResponseHeader(name);
};
this.get_text = function()
{
return this.xmlhttp.responseText;
};
this.get_xml = function()
{
return this.xmlhttp.responseXML;
};
this.reset();
} // end class rcube_http_request
// helper function to call the init method with a delay
function call_init(o)
{
window.setTimeout('if (window[\''+o+'\'] && window[\''+o+'\'].init) { '+o+'.init(); }',
bw.win ? 500 : 200);
}
diff --git a/program/js/common.js b/program/js/common.js
index 209ce1070..063657f89 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -1,627 +1,633 @@
/*
+-----------------------------------------------------------------------+
| RoundCube common js library |
| |
| This file is part of the RoundCube web development suite |
| Copyright (C) 2005-2007, RoundCube Dev, - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
// Constants
var CONTROL_KEY = 1;
var SHIFT_KEY = 2;
var CONTROL_SHIFT_KEY = 3;
/**
* Default browser check class
* @construcotr
*/
function roundcube_browser()
{
this.ver = parseFloat(navigator.appVersion);
this.appver = navigator.appVersion;
this.agent = navigator.userAgent;
this.name = navigator.appName;
this.vendor = navigator.vendor ? navigator.vendor : '';
this.vendver = navigator.vendorSub ? parseFloat(navigator.vendorSub) : 0;
this.product = navigator.product ? navigator.product : '';
this.platform = String(navigator.platform).toLowerCase();
this.lang = (navigator.language) ? navigator.language.substring(0,2) :
(navigator.browserLanguage) ? navigator.browserLanguage.substring(0,2) :
(navigator.systemLanguage) ? navigator.systemLanguage.substring(0,2) : 'en';
this.win = (this.platform.indexOf('win')>=0) ? true : false;
this.mac = (this.platform.indexOf('mac')>=0) ? true : false;
this.linux = (this.platform.indexOf('linux')>=0) ? true : false;
this.unix = (this.platform.indexOf('unix')>=0) ? true : false;
this.dom = document.getElementById ? true : false;
this.dom2 = (document.addEventListener && document.removeEventListener);
this.ie = (document.all) ? true : false;
this.ie4 = (this.ie && !this.dom);
this.ie5 = (this.dom && this.appver.indexOf('MSIE 5')>0);
this.ie6 = (this.dom && this.appver.indexOf('MSIE 6')>0);
this.mz = (this.dom && this.ver>=5); // (this.dom && this.product=='Gecko')
this.ns = ((this.ver<5 && this.name=='Netscape') || (this.ver>=5 && this.vendor.indexOf('Netscape')>=0));
this.ns6 = (this.ns && parseInt(this.vendver)==6); // (this.mz && this.ns) ? true : false;
this.ns7 = (this.ns && parseInt(this.vendver)==7); // this.agent.indexOf('Netscape/7')>0);
this.safari = (this.agent.toLowerCase().indexOf('safari')>0 || this.agent.toLowerCase().indexOf('applewebkit')>0);
this.konq = (this.agent.toLowerCase().indexOf('konqueror')>0);
this.opera = (window.opera) ? true : false;
if(this.opera && window.RegExp)
this.vendver = (/opera(\s|\/)([0-9\.]+)/i.test(navigator.userAgent)) ? parseFloat(RegExp.$2) : -1;
else if(!this.vendver && this.safari)
this.vendver = (/(safari|applewebkit)\/([0-9]+)/i.test(this.agent)) ? parseInt(RegExp.$2) : 0;
else if((!this.vendver && this.mz) || this.agent.indexOf('Camino')>0)
this.vendver = (/rv:([0-9\.]+)/.test(this.agent)) ? parseFloat(RegExp.$1) : 0;
else if(this.ie && window.RegExp)
this.vendver = (/msie\s+([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0;
else if(this.konq && window.RegExp)
this.vendver = (/khtml\/([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0;
// get real language out of safari's user agent
if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/i.test(this.agent)))
this.lang = RegExp.$1;
this.dhtml = ((this.ie4 && this.win) || this.ie5 || this.ie6 || this.ns4 || this.mz);
this.vml = (this.win && this.ie && this.dom && !this.opera);
this.pngalpha = (this.mz || (this.opera && this.vendver>=6) || (this.ie && this.mac && this.vendver>=5) ||
(this.ie && this.win && this.vendver>=5.5) || this.safari);
this.opacity = (this.mz || (this.ie && this.vendver>=5.5 && !this.opera) || (this.safari && this.vendver>=100));
this.cookies = navigator.cookieEnabled;
// test for XMLHTTP support
this.xmlhttp_test = function()
{
var activeX_test = new Function("try{var o=new ActiveXObject('Microsoft.XMLHTTP');return true;}catch(err){return false;}");
this.xmlhttp = (window.XMLHttpRequest || (window.ActiveXObject && activeX_test())) ? true : false;
return this.xmlhttp;
}
}
// static functions for event handling
var rcube_event = {
/**
* returns the event target element
*/
get_target: function(e)
{
e = e || window.event;
return e && e.target ? e.target : e.srcElement;
},
/**
* returns the event key code
*/
get_keycode: function(e)
{
e = e || window.event;
return e && e.keyCode ? e.keyCode : (e && e.which ? e.which : 0);
},
/**
* returns the event key code
*/
get_button: function(e)
{
e = e || window.event;
return e && (typeof e.button != 'undefined') ? e.button : (e && e.which ? e.which : 0);
},
/**
* returns modifier key (constants defined at top of file)
*/
get_modifier: function(e)
{
var opcode = 0;
e = e || window.event;
if (bw.mac && e)
{
opcode += (e.metaKey && CONTROL_KEY) + (e.shiftKey && SHIFT_KEY);
return opcode;
}
if (e)
{
opcode += (e.ctrlKey && CONTROL_KEY) + (e.shiftKey && SHIFT_KEY);
return opcode;
}
},
/**
* Return absolute mouse position of an event
*/
get_mouse_pos: function(e)
{
if (!e) e = window.event;
var mX = (e.pageX) ? e.pageX : e.clientX;
var mY = (e.pageY) ? e.pageY : e.clientY;
if (document.body && document.all)
{
mX += document.body.scrollLeft;
mY += document.body.scrollTop;
}
return { x:mX, y:mY };
},
/**
* Add an object method as event listener to a certain element
*/
add_listener: function(p)
{
if (!p.object || !p.method) // not enough arguments
return;
if (!p.element)
p.element = document;
if (!p.object._rc_events)
p.object._rc_events = [];
var key = p.event + '*' + p.method;
if (!p.object._rc_events[key])
p.object._rc_events[key] = function(e){ return p.object[p.method](e); };
if (p.element.addEventListener)
p.element.addEventListener(p.event, p.object._rc_events[key], false);
else if (p.element.attachEvent)
{
// IE allows multiple events with the same function to be applied to the same object
// forcibly detach the event, then attach
p.element.detachEvent('on'+p.event, p.object._rc_events[key]);
p.element.attachEvent('on'+p.event, p.object._rc_events[key]);
}
else
p.element['on'+p.event] = p.object._rc_events[key];
},
/**
* Remove event listener
*/
remove_listener: function(p)
{
if (!p.element)
p.element = document;
var key = p.event + '*' + p.method;
if (p.object && p.object._rc_events && p.object._rc_events[key]) {
if (p.element.removeEventListener)
p.element.removeEventListener(p.event, p.object._rc_events[key], false);
else if (p.element.detachEvent)
p.element.detachEvent('on'+p.event, p.object._rc_events[key]);
else
p.element['on'+p.event] = null;
}
},
/**
* Prevent event propagation and bubbeling
*/
cancel: function(evt)
{
var e = evt ? evt : window.event;
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
return false;
}
};
var rcube_layer_objects = new Array();
/**
* RoundCube generic layer (floating box) class
*
* @constructor
*/
function rcube_layer(id, attributes)
{
this.name = id;
// create a new layer in the current document
this.create = function(arg)
{
var l = (arg.x) ? arg.x : 0;
var t = (arg.y) ? arg.y : 0;
var w = arg.width;
var h = arg.height;
var z = arg.zindex;
var vis = arg.vis;
var parent = arg.parent;
var obj;
obj = document.createElement('DIV');
+
with(obj)
{
id = this.name;
with(style)
{
- position = 'absolute';
+ position = 'absolute';
visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden';
left = l+'px';
top = t+'px';
- if(w) width = w+'px';
- if(h) height = h+'px';
+ if (w)
+ width = w.toString().match(/\%$/) ? w : w+'px';
+ if (h)
+ height = h.toString().match(/\%$/) ? h : h+'px';
if(z) zIndex = z;
- }
+ }
}
-
- if(parent) parent.appendChild(obj);
- else document.body.appendChild(obj);
+
+ if (parent)
+ parent.appendChild(obj);
+ else
+ document.body.appendChild(obj);
this.elm = obj;
};
// create new layer
if(attributes!=null)
{
this.create(attributes);
this.name = this.elm.id;
}
else // just refer to the object
this.elm = document.getElementById(id);
if(!this.elm)
return false;
// ********* layer object properties *********
this.css = this.elm.style;
this.event = this.elm;
this.width = this.elm.offsetWidth;
this.height = this.elm.offsetHeight;
this.x = parseInt(this.elm.offsetLeft);
this.y = parseInt(this.elm.offsetTop);
this.visible = (this.css.visibility=='visible' || this.css.visibility=='show' || this.css.visibility=='inherit') ? true : false;
this.id = rcube_layer_objects.length;
this.obj = 'rcube_layer_objects['+this.id+']';
rcube_layer_objects[this.id] = this;
// ********* layer object methods *********
// move the layer to a specific position
this.move = function(x, y)
{
this.x = x;
this.y = y;
this.css.left = Math.round(this.x)+'px';
this.css.top = Math.round(this.y)+'px';
}
// move the layer for a specific step
this.shift = function(x,y)
{
x = Math.round(x*100)/100;
y = Math.round(y*100)/100;
this.move(this.x+x, this.y+y);
}
// change the layers width and height
this.resize = function(w,h)
{
this.css.width = w+'px';
this.css.height = h+'px';
this.width = w;
this.height = h;
}
// cut the layer (top,width,height,left)
this.clip = function(t,w,h,l)
{
this.css.clip='rect('+t+' '+w+' '+h+' '+l+')';
this.clip_height = h;
this.clip_width = w;
}
// show or hide the layer
this.show = function(a)
{
if(a==1)
{
this.css.visibility = 'visible';
this.visible = true;
}
else if(a==2)
{
this.css.visibility = 'inherit';
this.visible = true;
}
else
{
this.css.visibility = 'hidden';
this.visible = false;
}
}
// write new content into a Layer
this.write = function(cont)
{
this.elm.innerHTML = cont;
}
// set the given color to the layer background
this.set_bgcolor = function(c)
{
if(!c || c=='#')
c = 'transparent';
this.css.backgroundColor = c;
}
// set the opacity of a layer to the given ammount (in %)
this.set_opacity = function(v)
{
if(!bw.opacity)
return;
var op = v<=1 ? Math.round(v*100) : parseInt(v);
if(bw.ie)
this.css.filter = 'alpha(opacity:'+op+')';
else if(bw.safari)
{
this.css.opacity = op/100;
this.css.KhtmlOpacity = op/100;
}
else if(bw.mz)
this.css.MozOpacity = op/100;
}
}
// check if input is a valid email address
// By Cal Henderson <cal@iamcal.com>
// http://code.iamcal.com/php/rfc822/
function rcube_check_email(input, inline)
{
if (input && window.RegExp)
{
var qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
var dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
var atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
var quoted_pair = '\\x5c[\\x00-\\x7f]';
var domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d';
var quoted_string = '\\x22('+qtext+'|'+quoted_pair+')*\\x22';
var sub_domain = '('+atom+'|'+domain_literal+')';
var word = '('+atom+'|'+quoted_string+')';
var domain = sub_domain+'(\\x2e'+sub_domain+')*';
var local_part = word+'(\\x2e'+word+')*';
var addr_spec = local_part+'\\x40'+domain;
var delim = '[,;\s\n]';
var reg1 = inline ? new RegExp('(^|<|'+delim+')'+addr_spec+'($|>|'+delim+')', 'i') : new RegExp('^'+addr_spec+'$', 'i');
return reg1.test(input) ? true : false;
}
return false;
}
// find a value in a specific array and returns the index
function find_in_array()
{
var args = find_in_array.arguments;
if(!args.length) return -1;
var haystack = typeof(args[0])=='object' ? args[0] : args.length>1 && typeof(args[1])=='object' ? args[1] : new Array();
var needle = typeof(args[0])!='object' ? args[0] : args.length>1 && typeof(args[1])!='object' ? args[1] : '';
var nocase = args.length==3 ? args[2] : false;
if(!haystack.length) return -1;
for(var i=0; i<haystack.length; i++)
if(nocase && haystack[i].toLowerCase()==needle.toLowerCase())
return i;
else if(haystack[i]==needle)
return i;
return -1;
}
// make a string URL safe
function urlencode(str)
{
return window.encodeURIComponent ? encodeURIComponent(str) : escape(str);
}
// get any type of html objects by id/name
function rcube_find_object(id, d)
{
var n, f, obj, e;
if(!d) d = document;
if(d.getElementsByName && (e = d.getElementsByName(id)))
obj = e[0];
if(!obj && d.getElementById)
obj = d.getElementById(id);
if(!obj && d.all)
obj = d.all[id];
if(!obj && d.images.length)
obj = d.images[id];
if(!obj && d.forms.length)
for(f=0; f<d.forms.length; f++)
{
if(d.forms[f].name == id)
obj = d.forms[f];
else if(d.forms[f].elements[id])
obj = d.forms[f].elements[id];
}
if(!obj && d.layers)
{
if(d.layers[id]) obj = d.layers[id];
for(n=0; !obj && n<d.layers.length; n++)
obj = rcube_find_object(id, d.layers[n].document);
}
return obj;
}
// return the absolute position of an object within the document
-function rcube_get_object_pos(obj)
+function rcube_get_object_pos(obj, relative)
{
if(typeof(obj)=='string')
obj = rcube_find_object(obj);
if(!obj) return {x:0, y:0};
var iX = (bw.layers) ? obj.x : obj.offsetLeft;
var iY = (bw.layers) ? obj.y : obj.offsetTop;
- if(bw.ie || bw.mz)
+ if(!relative && (bw.ie || bw.mz))
{
var elm = obj.offsetParent;
while(elm && elm!=null)
{
iX += elm.offsetLeft - (elm.parentNode && elm.parentNode.scrollLeft ? elm.parentNode.scrollLeft : 0);
iY += elm.offsetTop - (elm.parentNode && elm.parentNode.scrollTop ? elm.parentNode.scrollTop : 0);
elm = elm.offsetParent;
}
}
return {x:iX, y:iY};
}
// determine whether the mouse is over the given object or not
function rcube_mouse_is_over(ev, obj)
{
var mouse = rcube_event.get_mouse_pos(ev);
var pos = rcube_get_object_pos(obj);
return ((mouse.x >= pos.x) && (mouse.x < (pos.x + obj.offsetWidth)) &&
(mouse.y >= pos.y) && (mouse.y < (pos.y + obj.offsetHeight)));
}
/**
* Return the currently applied value of a css property
*
* @param {Object} html_element Node reference
* @param {String} css_property Property name to read in Javascript notation (eg. 'textAlign')
* @param {String} mozilla_equivalent Equivalent property name in CSS notation (eg. 'text-align')
* @return CSS property value
* @type String
*/
function get_elements_computed_style(html_element, css_property, mozilla_equivalent)
{
if (arguments.length==2)
mozilla_equivalent = css_property;
var el = html_element;
if (typeof(html_element)=='string')
el = rcube_find_object(html_element);
if (el && el.currentStyle)
return el.currentStyle[css_property];
else if (el && document.defaultView && document.defaultView.getComputedStyle)
return document.defaultView.getComputedStyle(el, null).getPropertyValue(mozilla_equivalent);
else
return false;
}
// cookie functions by GoogieSpell
function setCookie(name, value, expires, path, domain, secure)
{
var curCookie = name + "=" + escape(value) +
(expires ? "; expires=" + expires.toGMTString() : "") +
(path ? "; path=" + path : "") +
(domain ? "; domain=" + domain : "") +
(secure ? "; secure" : "");
document.cookie = curCookie;
}
roundcube_browser.prototype.set_cookie = setCookie;
function getCookie(name)
{
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1)
{
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
roundcube_browser.prototype.get_cookie = getCookie;
// tiny replacement for Firebox functionality
function rcube_console()
{
this.log = function(msg)
{
box = rcube_find_object('console');
+
if (box)
- if (msg[msg.length-1]=='\n')
+ if (msg.charAt(msg.length-1)=='\n')
box.value += msg+'--------------------------------------\n';
else
box.value += msg+'\n--------------------------------------\n';
};
this.reset = function()
{
box = rcube_find_object('console');
if (box)
box.value = '';
};
}
var bw = new roundcube_browser();
if (!window.console)
console = new rcube_console();
// Add escape() method to RegExp object
// http://dev.rubyonrails.org/changeset/7271
RegExp.escape = function(str)
{
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
}
diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
index 75ffea521..82d06b090 100644
--- a/program/localization/en_GB/labels.inc
+++ b/program/localization/en_GB/labels.inc
@@ -1,220 +1,220 @@
<?php
/*
+-----------------------------------------------------------------------+
| language/en_GB/labels.inc |
| |
| Language file of the RoundCube Webmail client |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
| Author: Weiran Zhang (weiran@weiran.co.uk) |
+-----------------------------------------------------------------------+
@version $Id$
*/
$labels = array();
$labels['welcome'] = 'Welcome to $product';
$labels['username'] = 'Username';
$labels['password'] = 'Password';
$labels['server'] = 'Server';
$labels['login'] = 'Login';
$labels['logout'] = 'Logout';
$labels['mail'] = 'E-Mail';
$labels['settings'] = 'Personal Settings';
$labels['addressbook'] = 'Address Book';
$labels['inbox'] = 'Inbox';
$labels['drafts'] = 'Drafts';
$labels['sent'] = 'Sent';
$labels['trash'] = 'Deleted Items';
$labels['junk'] = 'Junk';
$labels['subject'] = 'Subject';
$labels['from'] = 'Sender';
$labels['to'] = 'Recipient';
$labels['cc'] = 'Copy';
$labels['bcc'] = 'Bcc';
$labels['replyto'] = 'Reply-To';
$labels['date'] = 'Date';
$labels['size'] = 'Size';
$labels['priority'] = 'Priority';
$labels['organization'] = 'Organisation';
$labels['reply-to'] = 'Reply-To';
$labels['mailboxlist'] = 'Folders';
$labels['messagesfromto'] = 'Messages $from to $to of $count';
$labels['messagenrof'] = 'Message $nr of $count';
$labels['moveto'] = 'move to...';
$labels['download'] = 'download';
$labels['filename'] = 'File name';
$labels['filesize'] = 'File size';
$labels['preferhtml'] = 'Display HTML';
$labels['htmlmessage'] = 'HTML Message';
$labels['prettydate'] = 'Pretty dates';
$labels['addtoaddressbook'] = 'Add to address book';
$labels['sun'] = 'Sun';
$labels['mon'] = 'Mon';
$labels['tue'] = 'Tue';
$labels['wed'] = 'Wed';
$labels['thu'] = 'Thu';
$labels['fri'] = 'Fri';
$labels['sat'] = 'Sat';
$labels['sunday'] = 'Sunday';
$labels['monday'] = 'Monday';
$labels['tuesday'] = 'Tuesday';
$labels['wednesday'] = 'Wednesday';
$labels['thursday'] = 'Thursday';
$labels['friday'] = 'Friday';
$labels['saturday'] = 'Saturday';
$labels['jan'] = 'Jan';
$labels['feb'] = 'Feb';
$labels['mar'] = 'Mar';
$labels['apr'] = 'Apr';
$labels['may'] = 'May';
$labels['jun'] = 'Jun';
$labels['jul'] = 'Jul';
$labels['aug'] = 'Aug';
$labels['sep'] = 'Sep';
$labels['oct'] = 'Oct';
$labels['nov'] = 'Nov';
$labels['dec'] = 'Dec';
$labels['longjan'] = 'January';
$labels['longfeb'] = 'February';
$labels['longmar'] = 'March';
$labels['longapr'] = 'April';
$labels['longmay'] = 'May';
$labels['longjun'] = 'June';
$labels['longjul'] = 'July';
$labels['longaug'] = 'August';
$labels['longsep'] = 'September';
$labels['longoct'] = 'October';
$labels['longnov'] = 'November';
$labels['longdec'] = 'December';
$labels['today'] = 'Today';
$labels['checkmail'] = 'Check for new messages';
$labels['writenewmessage'] = 'Create a new message';
$labels['replytomessage'] = 'Reply to sender';
$labels['replytoallmessage'] = 'Reply to sender and all recipients';
$labels['forwardmessage'] = 'Forward the message';
$labels['deletemessage'] = 'Delete message';
$labels['movemessagetotrash'] = 'Move message to "Deleted Items"';
$labels['printmessage'] = 'Print this message';
$labels['previousmessage'] = 'Show the previous message';
$labels['previousmessages'] = 'Show previous set of messages';
$labels['firstmessage'] = 'Show the first message';
$labels['firstmessages'] = 'Show first set of messages';
$labels['nextmessage'] = 'Show the next message';
$labels['nextmessages'] = 'Show next set of messages';
$labels['lastmessage'] = 'Show the last message';
$labels['lastmessages'] = 'Show last set of messages';
$labels['backtolist'] = 'Back to message list';
$labels['viewsource'] = 'Show source';
$labels['markmessages'] = 'Mark messages';
$labels['markread'] = 'As read';
$labels['markunread'] = 'As unread';
$labels['select'] = 'Select';
$labels['all'] = 'All';
$labels['none'] = 'None';
$labels['unread'] = 'Unread';
$labels['compact'] = 'Compact';
$labels['empty'] = 'Empty';
$labels['purge'] = 'Purge';
$labels['quota'] = 'Disk usage';
$labels['unknown'] = 'unknown';
$labels['unlimited'] = 'unlimited';
$labels['quicksearch'] = 'Quick search';
$labels['resetsearch'] = 'Reset search';
$labels['compose'] = 'Compose a message';
$labels['savemessage'] = 'Save this draft';
-$labels['sendmessage'] = 'Send the message now';
+$labels['sendmessage'] = 'Send now';
$labels['addattachment'] = 'Attach a file';
$labels['charset'] = 'Charset';
$labels['editortype'] = 'Editor type';
$labels['returnreceipt'] = 'Return receipt';
$labels['checkspelling'] = 'Check spelling';
$labels['resumeediting'] = 'Resume editing';
$labels['revertto'] = 'Revert to';
$labels['attachments'] = 'Attachments';
$labels['upload'] = 'Upload';
$labels['close'] = 'Close';
$labels['low'] = 'Low';
$labels['lowest'] = 'Lowest';
$labels['normal'] = 'Normal';
$labels['high'] = 'High';
$labels['highest'] = 'Highest';
$labels['nosubject'] = '(no subject)';
$labels['showimages'] = 'Display images';
$labels['htmltoggle'] = 'HTML';
$labels['plaintoggle'] = 'Plain text';
$labels['addcc'] = 'Add Cc';
$labels['addbcc'] = 'Add Bcc';
$labels['addreplyto'] = 'Add Reply-To';
$labels['mdnrequest'] = 'The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?';
$labels['receiptread'] = 'Return Receipt (read)';
$labels['yourmessage'] = 'This is a Return Receipt for your message';
$labels['receiptnote'] = 'Note: This receipt only acknowledges that the message was displayed on the recipient\'s computer. There is no guarantee that the recipient has read or understood the message contents.';
$labels['name'] = 'Display name';
$labels['firstname'] = 'First name';
$labels['surname'] = 'Last name';
$labels['email'] = 'E-Mail';
$labels['addcontact'] = 'Add new contact';
$labels['editcontact'] = 'Edit contact';
$labels['edit'] = 'Edit';
$labels['cancel'] = 'Cancel';
$labels['save'] = 'Save';
$labels['delete'] = 'Delete';
$labels['newcontact'] = 'Create new contact card';
$labels['deletecontact'] = 'Delete selected contacts';
$labels['composeto'] = 'Compose mail to';
$labels['contactsfromto'] = 'Contacts $from to $to of $count';
$labels['print'] = 'Print';
$labels['export'] = 'Export';
$labels['previouspage'] = 'Show previous set';
$labels['firstpage'] = 'Show first set';
$labels['nextpage'] = 'Show next set';
$labels['lastpage'] = 'Show last set';
$labels['groups'] = 'Groups';
$labels['personaladrbook'] = 'Personal Addresses';
$labels['settingsfor'] = 'Settings for';
$labels['preferences'] = 'Preferences';
$labels['userpreferences'] = 'User preferences';
$labels['editpreferences'] = 'Edit user preferences';
$labels['identities'] = 'Identities';
$labels['manageidentities'] = 'Manage identities for this account';
$labels['newidentity'] = 'New identity';
$labels['newitem'] = 'New item';
$labels['edititem'] = 'Edit item';
$labels['setdefault'] = 'Set default';
$labels['language'] = 'Language';
$labels['timezone'] = 'Time zone';
$labels['pagesize'] = 'Rows per page';
$labels['signature'] = 'Signature';
$labels['dstactive'] = 'Summer time';
$labels['htmleditor'] = 'Compose HTML messages';
$labels['htmlsignature'] = 'HTML signature';
$labels['previewpane'] = 'Show preview pane';
$labels['logoutclear'] = 'Clear Trash on logout';
$labels['logoutcompact'] = 'Compact Inbox on logout';
$labels['uisettings'] = 'User Interface';
$labels['serversettings'] = 'Server Settings';
$labels['autosavedraft'] = 'Automatically save draft';
$labels['everynminutes'] = 'every $n minutes';
$labels['never'] = 'never';
$labels['folder'] = 'Folder';
$labels['folders'] = 'Folders';
$labels['foldername'] = 'Folder name';
$labels['subscribed'] = 'Subscribed';
$labels['messagecount'] = 'Messages';
$labels['create'] = 'Create';
$labels['createfolder'] = 'Create new folder';
$labels['rename'] = 'Rename';
$labels['renamefolder'] = 'Rename folder';
$labels['deletefolder'] = 'Delete folder';
$labels['managefolders'] = 'Manage folders';
$labels['sortby'] = 'Sort by';
$labels['sortasc'] = 'Sort ascending';
$labels['sortdesc'] = 'Sort descending';
?>
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 565cdc47a..6b503ff4c 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -1,304 +1,304 @@
<?php
/*
+-----------------------------------------------------------------------+
| language/en_US/labels.inc |
| |
| Language file of the RoundCube Webmail client |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
@version $Id$
*/
$labels = array();
// login page
$labels['welcome'] = 'Welcome to $product';
$labels['username'] = 'Username';
$labels['password'] = 'Password';
$labels['server'] = 'Server';
$labels['login'] = 'Login';
// taskbar
$labels['logout'] = 'Logout';
$labels['mail'] = 'E-Mail';
$labels['settings'] = 'Personal Settings';
$labels['addressbook'] = 'Address Book';
// mailbox names
$labels['inbox'] = 'Inbox';
$labels['drafts'] = 'Drafts';
$labels['sent'] = 'Sent';
$labels['trash'] = 'Trash';
$labels['junk'] = 'Junk';
// message listing
$labels['subject'] = 'Subject';
$labels['from'] = 'Sender';
$labels['to'] = 'Recipient';
$labels['cc'] = 'Copy';
$labels['bcc'] = 'Bcc';
$labels['replyto'] = 'Reply-To';
$labels['date'] = 'Date';
$labels['size'] = 'Size';
$labels['priority'] = 'Priority';
$labels['organization'] = 'Organization';
// aliases
$labels['reply-to'] = $labels['replyto'];
$labels['mailboxlist'] = 'Folders';
$labels['messagesfromto'] = 'Messages $from to $to of $count';
$labels['messagenrof'] = 'Message $nr of $count';
$labels['moveto'] = 'move to...';
$labels['download'] = 'download';
$labels['filename'] = 'File name';
$labels['filesize'] = 'File size';
$labels['preferhtml'] = 'Display HTML';
$labels['htmlmessage'] = 'HTML Message';
$labels['showknownimages'] = 'Show images from known senders';
$labels['prettydate'] = 'Pretty dates';
$labels['addtoaddressbook'] = 'Add to address book';
// weekdays short
$labels['sun'] = 'Sun';
$labels['mon'] = 'Mon';
$labels['tue'] = 'Tue';
$labels['wed'] = 'Wed';
$labels['thu'] = 'Thu';
$labels['fri'] = 'Fri';
$labels['sat'] = 'Sat';
// weekdays long
$labels['sunday'] = 'Sunday';
$labels['monday'] = 'Monday';
$labels['tuesday'] = 'Tuesday';
$labels['wednesday'] = 'Wednesday';
$labels['thursday'] = 'Thursday';
$labels['friday'] = 'Friday';
$labels['saturday'] = 'Saturday';
// months short
$labels['jan'] = 'Jan';
$labels['feb'] = 'Feb';
$labels['mar'] = 'Mar';
$labels['apr'] = 'Apr';
$labels['may'] = 'May';
$labels['jun'] = 'Jun';
$labels['jul'] = 'Jul';
$labels['aug'] = 'Aug';
$labels['sep'] = 'Sep';
$labels['oct'] = 'Oct';
$labels['nov'] = 'Nov';
$labels['dec'] = 'Dec';
// months long
$labels['longjan'] = 'January';
$labels['longfeb'] = 'February';
$labels['longmar'] = 'March';
$labels['longapr'] = 'April';
$labels['longmay'] = 'May';
$labels['longjun'] = 'June';
$labels['longjul'] = 'July';
$labels['longaug'] = 'August';
$labels['longsep'] = 'September';
$labels['longoct'] = 'October';
$labels['longnov'] = 'November';
$labels['longdec'] = 'December';
$labels['today'] = 'Today';
// toolbar buttons
$labels['checkmail'] = 'Check for new messages';
$labels['writenewmessage'] = 'Create a new message';
$labels['replytomessage'] = 'Reply to sender';
$labels['replytoallmessage'] = 'Reply to sender and all recipients';
$labels['forwardmessage'] = 'Forward the message';
$labels['deletemessage'] = 'Delete message';
$labels['movemessagetotrash'] = 'Move message to trash';
$labels['printmessage'] = 'Print this message';
$labels['previousmessage'] = 'Show the previous message';
$labels['previousmessages'] = 'Show previous set of messages';
$labels['firstmessage'] = 'Show the first message';
$labels['firstmessages'] = 'Show first set of messages';
$labels['nextmessage'] = 'Show the next message';
$labels['nextmessages'] = 'Show next set of messages';
$labels['lastmessage'] = 'Show the last message';
$labels['lastmessages'] = 'Show last set of messages';
$labels['backtolist'] = 'Back to message list';
$labels['viewsource'] = 'Show source';
$labels['markmessages'] = 'Mark messages';
$labels['markread'] = 'As read';
$labels['markunread'] = 'As unread';
$labels['markflagged'] = 'As flagged';
$labels['markunflagged'] = 'As unflagged';
$labels['select'] = 'Select';
$labels['all'] = 'All';
$labels['none'] = 'None';
$labels['unread'] = 'Unread';
$labels['compact'] = 'Compact';
$labels['empty'] = 'Empty';
$labels['purge'] = 'Purge';
$labels['quota'] = 'Disk usage';
$labels['unknown'] = 'unknown';
$labels['unlimited'] = 'unlimited';
$labels['quicksearch'] = 'Quick search';
$labels['resetsearch'] = 'Reset search';
// message compose
$labels['compose'] = 'Compose a message';
$labels['savemessage'] = 'Save this draft';
-$labels['sendmessage'] = 'Send the message now';
+$labels['sendmessage'] = 'Send now';
$labels['addattachment'] = 'Attach a file';
$labels['charset'] = 'Charset';
$labels['editortype'] = 'Editor type';
$labels['returnreceipt'] = 'Return receipt';
$labels['checkspelling'] = 'Check spelling';
$labels['resumeediting'] = 'Resume editing';
$labels['revertto'] = 'Revert to';
$labels['attachments'] = 'Attachments';
$labels['upload'] = 'Upload';
$labels['close'] = 'Close';
$labels['low'] = 'Low';
$labels['lowest'] = 'Lowest';
$labels['normal'] = 'Normal';
$labels['high'] = 'High';
$labels['highest'] = 'Highest';
$labels['nosubject'] = '(no subject)';
$labels['showimages'] = 'Display images';
$labels['alwaysshow'] = 'Always show images from $sender';
$labels['htmltoggle'] = 'HTML';
$labels['plaintoggle'] = 'Plain text';
$labels['savesentmessagein'] = 'Save sent message in';
$labels['dontsave'] = 'don\'t save';
$labels['maxuploadsize'] = 'Maximum allowed file size is $size';
$labels['addcc'] = 'Add Cc';
$labels['addbcc'] = 'Add Bcc';
$labels['addreplyto'] = 'Add Reply-To';
// mdn
$labels['mdnrequest'] = 'The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?';
$labels['receiptread'] = 'Return Receipt (read)';
$labels['yourmessage'] = 'This is a Return Receipt for your message';
$labels['receiptnote'] = 'Note: This receipt only acknowledges that the message was displayed on the recipient\'s computer. There is no guarantee that the recipient has read or understood the message contents.';
// address boook
$labels['name'] = 'Display name';
$labels['firstname'] = 'First name';
$labels['surname'] = 'Last name';
$labels['email'] = 'E-Mail';
$labels['addcontact'] = 'Add new contact';
$labels['editcontact'] = 'Edit contact';
$labels['edit'] = 'Edit';
$labels['cancel'] = 'Cancel';
$labels['save'] = 'Save';
$labels['delete'] = 'Delete';
$labels['newcontact'] = 'Create new contact card';
$labels['deletecontact'] = 'Delete selected contacts';
$labels['composeto'] = 'Compose mail to';
$labels['contactsfromto'] = 'Contacts $from to $to of $count';
$labels['print'] = 'Print';
$labels['export'] = 'Export';
$labels['exportvcards'] = 'Export contacts in vCard format';
$labels['previouspage'] = 'Show previous set';
$labels['firstpage'] = 'Show first set';
$labels['nextpage'] = 'Show next set';
$labels['lastpage'] = 'Show last set';
$labels['groups'] = 'Groups';
$labels['personaladrbook'] = 'Personal Addresses';
$labels['import'] = 'Import';
$labels['importcontacts'] = 'Import contacts';
$labels['importfromfile'] = 'Import from file:';
$labels['importreplace'] = 'Replace the entire address book';
$labels['importtext'] = 'You can upload contacts from an existing address book.<br/>We currently support importing addresses from the <a href="http://en.wikipedia.org/wiki/VCard">vCard</a> data format.';
$labels['done'] = 'Done';
// settings
$labels['settingsfor'] = 'Settings for';
$labels['preferences'] = 'Preferences';
$labels['userpreferences'] = 'User preferences';
$labels['editpreferences'] = 'Edit user preferences';
$labels['identities'] = 'Identities';
$labels['manageidentities'] = 'Manage identities for this account';
$labels['newidentity'] = 'New identity';
$labels['newitem'] = 'New item';
$labels['edititem'] = 'Edit item';
$labels['setdefault'] = 'Set default';
$labels['autodetect'] = 'Auto';
$labels['language'] = 'Language';
$labels['timezone'] = 'Time zone';
$labels['pagesize'] = 'Rows per page';
$labels['signature'] = 'Signature';
$labels['dstactive'] = 'Daylight saving time';
$labels['htmleditor'] = 'Compose HTML messages';
$labels['htmlsignature'] = 'HTML signature';
$labels['previewpane'] = 'Show preview pane';
$labels['skin'] = 'Interface skin';
$labels['logoutclear'] = 'Clear Trash on logout';
$labels['logoutcompact'] = 'Compact Inbox on logout';
$labels['uisettings'] = 'User Interface';
$labels['serversettings'] = 'Server Settings';
$labels['mailboxview'] = 'Mailbox View';
$labels['mdnrequests'] = 'Sender notifications';
$labels['askuser'] = 'ask the user';
$labels['autosend'] = 'send automatically';
$labels['ignore'] = 'ignore';
$labels['readwhendeleted'] = 'Mark the message as read on delete';
$labels['flagfordeletion'] = 'Flag the message for deletion instead of delete';
$labels['showinlineimages'] = 'Display attached images below the message';
$labels['autosavedraft'] = 'Automatically save draft';
$labels['everynminutes'] = 'every $n minutes';
$labels['never'] = 'never';
$labels['messagesdisplaying'] = 'Messages displaying';
$labels['messagescomposition'] = 'Messages composition';
$labels['folder'] = 'Folder';
$labels['folders'] = 'Folders';
$labels['foldername'] = 'Folder name';
$labels['subscribed'] = 'Subscribed';
$labels['messagecount'] = 'Messages';
$labels['create'] = 'Create';
$labels['createfolder'] = 'Create new folder';
$labels['rename'] = 'Rename';
$labels['renamefolder'] = 'Rename folder';
$labels['deletefolder'] = 'Delete folder';
$labels['managefolders'] = 'Manage folders';
$labels['specialfolders'] = 'Special folders';
$labels['sortby'] = 'Sort by';
$labels['sortasc'] = 'Sort ascending';
$labels['sortdesc'] = 'Sort descending';
?>
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 54abb24fe..7de78a1ef 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1,1279 +1,1287 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/mail/func.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Provide webmail functionality and GUI objects |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
require_once('lib/enriched.inc');
require_once('include/rcube_smtp.inc');
$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';
if (empty($_SESSION['mbox']))
$_SESSION['mbox'] = $IMAP->get_mailbox_name();
// set imap properties and session vars
if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC))
$IMAP->set_mailbox(($_SESSION['mbox'] = $mbox));
if (!empty($_GET['_page']))
$IMAP->set_page(($_SESSION['page'] = intval($_GET['_page'])));
// set mailbox to INBOX if not set
if (empty($_SESSION['mbox']))
$_SESSION['mbox'] = $IMAP->get_mailbox_name();
// set default sort col/order to session
if (!isset($_SESSION['sort_col']))
$_SESSION['sort_col'] = $CONFIG['message_sort_col'];
if (!isset($_SESSION['sort_order']))
$_SESSION['sort_order'] = $CONFIG['message_sort_order'];
// set message set for search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
{
$IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]);
$OUTPUT->set_env('search_request', $_REQUEST['_search']);
$OUTPUT->set_env('search_text', $_SESSION['last_text_search']);
}
// set current mailbox in client environment
$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name());
$OUTPUT->set_env('quota', $IMAP->get_capability('quota'));
$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter());
if ($CONFIG['trash_mbox'])
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);
if ($CONFIG['drafts_mbox'])
$OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']);
if ($CONFIG['junk_mbox'])
$OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']);
if (!$OUTPUT->ajax_call)
rcube_add_label('checkingmail', 'deletemessage', 'movemessagetotrash', 'movingmessage');
// set page title
if (empty($RCMAIL->action) || $RCMAIL->action == 'list')
$OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->get_mailbox_name()));
/**
* return the message list as HTML table
*/
function rcmail_message_list($attrib)
{
global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT;
$skin_path = $CONFIG['skin_path'];
$image_tag = '<img src="%s%s" alt="%s" />';
// check to see if we have some settings for sorting
$sort_col = $_SESSION['sort_col'];
$sort_order = $_SESSION['sort_order'];
// add some labels to client
rcube_add_label('from', 'to');
// get message headers
$a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order);
// add id to message list table if not specified
if (!strlen($attrib['id']))
$attrib['id'] = 'rcubemessagelist';
// allow the following attributes to be added to the <table> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
$out = '<table' . $attrib_str . ">\n";
// define list of cols to be displayed
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject');
$a_sort_cols = array('subject', 'date', 'from', 'to', 'size');
$mbox = $IMAP->get_mailbox_name();
// show 'to' instead of from in sent messages
if (($mbox==$CONFIG['sent_mbox'] || $mbox==$CONFIG['drafts_mbox']) && ($f = array_search('from', $a_show_cols))
&& !array_search('to', $a_show_cols))
$a_show_cols[$f] = 'to';
// add col definition
$out .= '<colgroup>';
$out .= '<col class="icon" />';
foreach ($a_show_cols as $col)
$out .= sprintf('<col class="%s" />', $col);
$out .= '<col class="icon" />';
$out .= "</colgroup>\n";
// add table title
$out .= "<thead><tr>\n<td class=\"icon\">&nbsp;</td>\n";
$javascript = '';
foreach ($a_show_cols as $col)
{
// get column name
$col_name = $col != 'flag' ? Q(rcube_label($col)) : sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], '');
// make sort links
$sort = '';
if (in_array($col, $a_sort_cols))
{
// have buttons configured
if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton']))
{
$sort = '&nbsp;&nbsp;';
// asc link
if (!empty($attrib['sortascbutton']))
{
$sort .= $OUTPUT->button(array(
'command' => 'sort',
'prop' => $col.'_ASC',
'image' => $attrib['sortascbutton'],
'align' => 'absmiddle',
'title' => 'sortasc'));
}
// desc link
if (!empty($attrib['sortdescbutton']))
{
$sort .= $OUTPUT->button(array(
'command' => 'sort',
'prop' => $col.'_DESC',
'image' => $attrib['sortdescbutton'],
'align' => 'absmiddle',
'title' => 'sortdesc'));
}
}
// just add a link tag to the header
else
{
$col_name = sprintf(
'<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>',
JS_OBJECT_NAME,
$col,
rcube_label('sortby'),
$col_name);
}
}
$sort_class = $col==$sort_col ? " sorted$sort_order" : '';
// put it all together
$out .= '<td class="'.$col.$sort_class.'" id="rcmHead'.$col.'">' . "$col_name$sort</td>\n";
}
$out .= '<td class="icon">'.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."</td>\n";
$out .= "</tr></thead>\n<tbody>\n";
// no messages in this mailbox
if (!sizeof($a_headers))
$OUTPUT->show_message('nomessagesfound', 'notice');
$a_js_message_arr = array();
// create row for each message
foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers))
{
$message_icon = $attach_icon = $flagged_icon = '';
$js_row_arr = array();
$zebra_class = $i%2 ? 'even' : 'odd';
// set messag attributes to javascript array
if ($header->deleted)
$js_row_arr['deleted'] = true;
if (!$header->seen)
$js_row_arr['unread'] = true;
if ($header->answered)
$js_row_arr['replied'] = true;
if ($header->flagged)
$js_row_arr['flagged'] = true;
// set message icon
if ($attrib['deletedicon'] && $header->deleted)
$message_icon = $attrib['deletedicon'];
else if ($attrib['unreadicon'] && !$header->seen)
$message_icon = $attrib['unreadicon'];
else if ($attrib['repliedicon'] && $header->answered)
$message_icon = $attrib['repliedicon'];
else if ($attrib['messageicon'])
$message_icon = $attrib['messageicon'];
if ($attrib['flaggedicon'] && $header->flagged)
$flagged_icon = $attrib['flaggedicon'];
else if ($attrib['unflaggedicon'] && !$header->flagged)
$flagged_icon = $attrib['unflaggedicon'];
// set attachment icon
if ($attrib['attachmenticon'] && preg_match("/multipart\/[mr]/i", $header->ctype))
$attach_icon = $attrib['attachmenticon'];
$out .= sprintf('<tr id="rcmrow%d" class="message%s%s %s">'."\n",
$header->uid,
$header->seen ? '' : ' unread',
$header->deleted ? ' deleted' : '',
$header->flagged ? ' flagged' : '',
$zebra_class);
$out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : '');
if (!empty($header->charset))
$IMAP->set_charset($header->charset);
// format each col
foreach ($a_show_cols as $col)
{
if ($col=='from' || $col=='to')
$cont = Q(rcmail_address_string($header->$col, 3, false, $attrib['addicon']), 'show');
else if ($col=='subject')
{
$action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show';
$uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid';
$cont = Q($IMAP->decode_header($header->$col));
if (empty($cont)) $cont = Q(rcube_label('nosubject'));
$cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont);
}
else if ($col=='flag')
$cont = $flagged_icon ? sprintf($image_tag, $skin_path, $flagged_icon, '') : '';
else if ($col=='size')
$cont = show_bytes($header->$col);
else if ($col=='date')
$cont = format_date($header->date);
else
$cont = Q($header->$col);
$out .= '<td class="'.$col.'">' . $cont . "</td>\n";
}
$out .= sprintf("<td class=\"icon\">%s</td>\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : '');
$out .= "</tr>\n";
if (sizeof($js_row_arr))
$a_js_message_arr[$header->uid] = $js_row_arr;
}
// complete message table
$out .= "</tbody></table>\n";
$message_count = $IMAP->messagecount();
// set client env
$OUTPUT->add_gui_object('mailcontframe', 'mailcontframe');
$OUTPUT->add_gui_object('messagelist', $attrib['id']);
$OUTPUT->set_env('messagecount', $message_count);
$OUTPUT->set_env('current_page', $IMAP->list_page);
$OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size));
$OUTPUT->set_env('sort_col', $sort_col);
$OUTPUT->set_env('sort_order', $sort_order);
if ($attrib['messageicon'])
$OUTPUT->set_env('messageicon', $skin_path . $attrib['messageicon']);
if ($attrib['deletedicon'])
$OUTPUT->set_env('deletedicon', $skin_path . $attrib['deletedicon']);
if ($attrib['unreadicon'])
$OUTPUT->set_env('unreadicon', $skin_path . $attrib['unreadicon']);
if ($attrib['repliedicon'])
$OUTPUT->set_env('repliedicon', $skin_path . $attrib['repliedicon']);
if ($attrib['attachmenticon'])
$OUTPUT->set_env('attachmenticon', $skin_path . $attrib['attachmenticon']);
if ($attrib['flaggedicon'])
$OUTPUT->set_env('flaggedicon', $skin_path . $attrib['flaggedicon']);
if ($attrib['unflaggedicon'])
$OUTPUT->set_env('unflaggedicon', $skin_path . $attrib['unflaggedicon']);
$OUTPUT->set_env('messages', $a_js_message_arr);
$OUTPUT->set_env('coltypes', $a_show_cols);
$OUTPUT->include_script('list.js');
return $out;
}
/**
* return javascript commands to add rows to the message list
*/
function rcmail_js_message_list($a_headers, $insert_top=FALSE)
{
global $CONFIG, $IMAP, $OUTPUT;
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject');
$mbox = $IMAP->get_mailbox_name();
// show 'to' instead of from in sent messages
if (($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox'])
&& (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
$a_show_cols[$f] = 'to';
$OUTPUT->command('set_message_coltypes', $a_show_cols);
// loop through message headers
foreach ($a_headers as $n => $header)
{
$a_msg_cols = array();
$a_msg_flags = array();
if (empty($header))
continue;
if (!empty($header->charset))
$IMAP->set_charset($header->charset);
// format each col; similar as in rcmail_message_list()
foreach ($a_show_cols as $col)
{
if ($col=='from' || $col=='to')
$cont = Q(rcmail_address_string($header->$col, 3), 'show');
else if ($col=='subject')
{
$action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show';
$uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid';
$cont = Q($IMAP->decode_header($header->$col));
if (!$cont) $cont = Q(rcube_label('nosubject'));
$cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont);
}
else if ($col=='size')
$cont = show_bytes($header->$col);
else if ($col=='date')
$cont = format_date($header->date);
else
$cont = Q($header->$col);
$a_msg_cols[$col] = $cont;
}
$a_msg_flags['deleted'] = $header->deleted ? 1 : 0;
$a_msg_flags['unread'] = $header->seen ? 0 : 1;
$a_msg_flags['replied'] = $header->answered ? 1 : 0;
$a_msg_flags['flagged'] = $header->flagged ? 1 : 0;
$OUTPUT->command('add_message_row',
$header->uid,
$a_msg_cols,
$a_msg_flags,
preg_match("/multipart\/m/i", $header->ctype),
$insert_top);
}
}
/**
* return an HTML iframe for loading mail content
*/
function rcmail_messagecontent_frame($attrib)
{
global $OUTPUT;
if (empty($attrib['id']))
$attrib['id'] = 'rcmailcontentwindow';
// allow the following attributes to be added to the <iframe> tag
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
$framename = $attrib['id'];
$out = sprintf('<iframe name="%s"%s></iframe>'."\n",
$framename,
$attrib_str);
$OUTPUT->set_env('contentframe', $framename);
$OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
return $out;
}
/**
*
*/
function rcmail_messagecount_display($attrib)
{
global $IMAP, $OUTPUT;
if (!$attrib['id'])
$attrib['id'] = 'rcmcountdisplay';
$OUTPUT->add_gui_object('countdisplay', $attrib['id']);
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
$out = '<span' . $attrib_str . '>';
$out .= rcmail_get_messagecount_text();
$out .= '</span>';
return $out;
}
/**
*
*/
function rcmail_quota_display($attrib)
{
global $OUTPUT, $COMM_PATH;
if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay';
if(isset($attrib['display']))
$_SESSION['quota_display'] = $attrib['display'];
$OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display'));
$out = '<span' . $attrib_str . '>';
$out .= rcmail_quota_content();
$out .= '</span>';
return $out;
}
/**
*
*/
function rcmail_quota_content($quota=NULL)
{
global $IMAP, $COMM_PATH, $RCMAIL;
$display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
if (is_array($quota) && !empty($quota['used']) && !empty($quota['total']))
{
if (!isset($quota['percent']))
$quota['percent'] = $quota['used'] / $quota['total'];
}
elseif (!$IMAP->get_capability('QUOTA'))
return rcube_label('unknown');
else
$quota = $IMAP->get_quota();
if ($quota && !($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited')))
{
$quota_text = sprintf('%s / %s (%.0f%%)',
show_bytes($quota['used'] * 1024),
show_bytes($quota['total'] * 1024),
$quota['percent']);
// show quota as image (by Brett Patterson)
if ($display == 'image' && function_exists('imagegif'))
{
$attrib = array('width' => 100, 'height' => 14);
$quota_text = sprintf('<img src="./bin/quotaimg.php?u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />',
$quota['used'], $quota['total'],
$attrib['width'], $attrib['height'],
$attrib['width'], $attrib['height'],
$quota_text,
show_bytes($quota["used"] * 1024),
show_bytes($quota["total"] * 1024));
}
}
else
$quota_text = rcube_label('unlimited');
return $quota_text;
}
/**
*
*/
function rcmail_get_messagecount_text($count=NULL, $page=NULL)
{
global $IMAP, $MESSAGE;
if (isset($MESSAGE->index))
{
return rcube_label(array('name' => 'messagenrof',
'vars' => array('nr' => $MESSAGE->index+1,
'count' => $count!==NULL ? $count : $IMAP->messagecount())));
}
if ($page===NULL)
$page = $IMAP->list_page;
$start_msg = ($page-1) * $IMAP->page_size + 1;
$max = $count!==NULL ? $count : $IMAP->messagecount();
if ($max==0)
$out = rcube_label('mailboxempty');
else
$out = rcube_label(array('name' => 'messagesfromto',
'vars' => array('from' => $start_msg,
'to' => min($max, $start_msg + $IMAP->page_size - 1),
'count' => $max)));
return Q($out);
}
/**
*
*/
function rcmail_mailbox_name_display($attrib)
{
global $RCMAIL;
if (!$attrib['id'])
$attrib['id'] = 'rcmmailboxname';
$RCMAIL->output->add_gui_object('mailboxname', $attrib['id']);
return html::span($attrib, rcmail_get_mailbox_name_text());
}
function rcmail_get_mailbox_name_text()
{
global $RCMAIL;
return rcmail_localize_foldername($RCMAIL->imap->get_mailbox_name());
}
/**
* Convert the given message part to proper HTML
* which can be displayed the message view
*
* @param object rcube_message_part Message part
* @param bool True if external objects (ie. images ) are allowed
* @param bool True if part should be converted to plaintext
* @return string Formatted HTML string
*/
function rcmail_print_body($part, $p = array())
{
global $REMOTE_OBJECTS;
$p += array('safe' => false, 'plain' => false, 'inline_html' => true);
// convert html to text/plain
if ($part->ctype_secondary == 'html' && $p['plain']) {
$txt = new html2text($part->body, false, true);
$body = $txt->get_text();
$part->ctype_secondary = 'plain';
}
// text/html
else if ($part->ctype_secondary == 'html') {
// charset was converted to UTF-8 in rcube_imap::get_message_part() -> change charset specification in HTML accordingly
$html = $part->body;
if (preg_match('/(\s+content=[\'"]\w+\/\w+;\s*charset)=([a-z0-9-_]+)/i', $html))
$html = preg_replace('/(\s+content=[\'"]\w+\/\w+;\s*charset)=([a-z0-9-_]+)/i', '\\1='.RCMAIL_CHARSET, $html);
else {
// add <head> for malformed messages, washtml cannot work without that
if (!preg_match('/<head>(.*)<\\/head>/Uims', $html))
$html = '<head></head>' . $html;
$html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '</head>')), 0);
}
// PHP bug #32547 workaround: remove title tag
$html = preg_replace('/<title>.*<\/title>/', '', $html);
// clean HTML with washhtml by Frederic Motte
$wash_opts = array(
'show_washed' => false,
'allow_remote' => $p['safe'],
'blocked_src' => "./program/blocked.gif",
'charset' => RCMAIL_CHARSET,
'cid_map' => $part->replaces,
'html_elements' => array('body'),
);
if (!$p['inline_html']) {
$wash_opts['html_elements'] = array('html','head','title','body');
}
/* CSS styles need to be sanitized!
if ($p['safe']) {
$wash_opts['html_elements'][] = 'style';
$wash_opts['html_attribs'] = array('type');
}
*/
$washer = new washtml($wash_opts);
$washer->add_callback('form', 'rcmail_washtml_callback');
$body = $washer->wash($html);
$REMOTE_OBJECTS = $washer->extlinks;
return $body;
}
// text/enriched
else if ($part->ctype_secondary=='enriched') {
$part->ctype_secondary = 'html';
return Q(enriched_to_html($part->body), 'show');
}
else
$body = $part->body;
/**** assert plaintext ****/
// make links and email-addresses clickable
$convert_patterns = $convert_replaces = $replace_strings = array();
$url_chars = 'a-z0-9_\-\+\*\$\/&%=@#:;';
$url_chars_within = '\?\.~,!';
$convert_patterns[] = "/([\w]+):\/\/([a-z0-9\-\.]+[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie";
$convert_replaces[] = "rcmail_str_replacement('<a href=\"\\1://\\2\" target=\"_blank\">\\1://\\2</a>', \$replace_strings)";
$convert_patterns[] = "/([^\/:]|\s)(www\.)([a-z0-9\-]{2,}[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie";
$convert_replaces[] = "rcmail_str_replacement('\\1<a href=\"http://\\2\\3\" target=\"_blank\">\\2\\3</a>', \$replace_strings)";
$convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie';
$convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)";
// search for patterns like links and e-mail addresses
$body = preg_replace($convert_patterns, $convert_replaces, $body);
// split body into single lines
$a_lines = preg_split('/\r?\n/', $body);
$quote_level = 0;
// colorize quoted parts
for ($n=0; $n < sizeof($a_lines); $n++) {
$line = $a_lines[$n];
$quotation = '';
$q = 0;
if (preg_match('/^(>+\s*)+/', $line, $regs)) {
$q = strlen(preg_replace('/\s/', '', $regs[0]));
$line = substr($line, strlen($regs[0]));
if ($q > $quote_level)
$quotation = str_repeat('<blockquote>', $q - $quote_level);
else if ($q < $quote_level)
$quotation = str_repeat("</blockquote>", $quote_level - $q);
}
else if ($quote_level > 0)
$quotation = str_repeat("</blockquote>", $quote_level);
$quote_level = $q;
$a_lines[$n] = $quotation . Q($line, 'replace', false); // htmlquote plaintext
}
// insert the links for urls and mailtos
$body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines));
return "<div class=\"pre\">".$body."\n</div>";
}
/**
* add a string to the replacement array and return a replacement string
*/
function rcmail_str_replacement($str, &$rep)
{
static $count = 0;
$rep[$count] = stripslashes($str);
return "##string_replacement{".($count++)."}##";
}
/**
* Callback function for washtml cleaning class
*/
function rcmail_washtml_callback($tagname, $attrib, $content)
{
switch ($tagname) {
case 'form':
$out = html::div('form', $content);
break;
default:
$out = '';
}
return $out;
}
/**
* return table with message headers
*/
function rcmail_message_headers($attrib, $headers=NULL)
{
global $IMAP, $OUTPUT, $MESSAGE, $PRINT_MODE, $CONFIG;
static $sa_attrib;
// keep header table attrib
if (is_array($attrib) && !$sa_attrib)
$sa_attrib = $attrib;
else if (!is_array($attrib) && is_array($sa_attrib))
$attrib = $sa_attrib;
if (!isset($MESSAGE))
return FALSE;
// get associative array of headers object
if (!$headers)
$headers = is_object($MESSAGE->headers) ? get_object_vars($MESSAGE->headers) : $MESSAGE->headers;
// add empty subject if none exsists
if (empty($headers['subject']))
$headers['subject'] = rcube_label('nosubject');
$header_count = 0;
// allow the following attributes to be added to the <table> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
$out = '<table' . $attrib_str . ">\n";
// show these headers
$standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'bcc', 'replyto', 'date');
-
+
foreach ($standard_headers as $hkey)
{
if (!$headers[$hkey])
continue;
if ($hkey == 'date')
{
if ($PRINT_MODE)
$header_value = format_date($headers[$hkey], $CONFIG['date_long'] ? $CONFIG['date_long'] : 'x');
else
$header_value = format_date($headers[$hkey]);
}
else if ($hkey == 'replyto')
{
if ($headers['replyto'] != $headers['from'])
$header_value = Q(rcmail_address_string($headers['replyto'], null, true, $attrib['addicon']), 'show');
else
continue;
}
else if (in_array($hkey, array('from', 'to', 'cc', 'bcc')))
$header_value = Q(rcmail_address_string($headers[$hkey], null, true, $attrib['addicon']), 'show');
else
$header_value = Q($IMAP->decode_header($headers[$hkey]));
$out .= "\n<tr>\n";
$out .= '<td class="header-title">'.Q(rcube_label($hkey)).":&nbsp;</td>\n";
$out .= '<td class="'.$hkey.'" width="90%">'.$header_value."</td>\n</tr>";
$header_count++;
}
+ // all headers division
+ $out .= "\n".'<tr><td colspan="2" class="more-headers show-headers"
+ onclick="return '.JS_OBJECT_NAME.'.command(\'load-headers\', \'\', this)"></td></tr>';
+ $out .= "\n".'<tr id="all-headers"><td colspan="2" class="all"><div id="headers-source"></div></td></tr>';
+
+ $OUTPUT->add_gui_object('all_headers_row', 'all-headers');
+ $OUTPUT->add_gui_object('all_headers_box', 'headers-source');
+
$out .= "\n</table>\n\n";
return $header_count ? $out : '';
}
/**
* Handler for the 'messagebody' GUI object
*
* @param array Named parameters
* @return string HTML content showing the message body
*/
function rcmail_message_body($attrib)
{
global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $REMOTE_OBJECTS;
if (!is_array($MESSAGE->parts) && empty($MESSAGE->body))
return '';
if (!$attrib['id'])
$attrib['id'] = 'rcmailMsgBody';
$safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']);
$out = '';
$header_attrib = array();
foreach ($attrib as $attr => $value)
if (preg_match('/^headertable([a-z]+)$/i', $attr, $regs))
$header_attrib[$regs[1]] = $value;
if (!empty($MESSAGE->parts))
{
foreach ($MESSAGE->parts as $i => $part)
{
if ($part->type == 'headers')
$out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part->headers);
else if ($part->type == 'content')
{
if (empty($part->ctype_parameters) || empty($part->ctype_parameters['charset']))
$part->ctype_parameters['charset'] = $MESSAGE->headers->charset;
// fetch part if not available
if (!isset($part->body))
$part->body = $MESSAGE->get_part_content($part->mime_id);
$body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html']));
if ($part->ctype_secondary == 'html')
$out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id']));
else
$out .= html::div('message-part', $body);
}
}
}
else
$out .= html::div('message-part', html::div('pre', Q($MESSAGE->body)));
$ctype_primary = strtolower($MESSAGE->structure->ctype_primary);
$ctype_secondary = strtolower($MESSAGE->structure->ctype_secondary);
// list images after mail body
if ($CONFIG['inline_images']
&& $ctype_primary == 'multipart'
&& !empty($MESSAGE->attachments)
&& !strstr($message_body, '<html'))
{
foreach ($MESSAGE->attachments as $attach_prop) {
if (strpos($attach_prop->mimetype, 'image/') === 0) {
$out .= html::tag('hr') . html::p(array('align' => "center"),
html::img(array(
'src' => $MESSAGE->get_part_url($attach_prop->mime_id),
'title' => $attach_prop->filename,
'alt' => $attach_prop->filename,
)));
}
}
}
// tell client that there are blocked remote objects
if ($REMOTE_OBJECTS && !$safe_mode)
$OUTPUT->set_env('blockedobjects', true);
return html::div($attrib, $out);
}
/**
* modify a HTML message that it can be displayed inside a HTML page
*/
function rcmail_html4inline($body, $container_id)
{
$base_url = "";
$last_style_pos = 0;
$body_lc = strtolower($body);
// check for <base href>
if (preg_match(($base_reg = '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i'), $body, $base_regs))
$base_url = $base_regs[2];
// find STYLE tags
while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos)))
{
$pos = strpos($body_lc, '>', $pos)+1;
// replace all css definitions with #container [def]
$styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id, $base_url);
$body = substr($body, 0, $pos) . $styles . substr($body, $pos2);
$body_lc = strtolower($body);
$last_style_pos = $pos2;
}
// resolve <base href>
if ($base_url)
{
$body = preg_replace('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Uie', "'\\1=\"'.make_absolute_url('\\3', '$base_url').'\"'", $body);
$body = preg_replace('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Uie', "'\\1\''.make_absolute_url('\\3', '$base_url').'\')'", $body);
$body = preg_replace($base_reg, '', $body);
}
// modify HTML links to open a new window if clicked
$body = preg_replace('/<(a|link)\s+([^>]+)>/Uie', "rcmail_alter_html_link('\\1','\\2', '$container_id');", $body);
// add comments arround html and other tags
$out = preg_replace(array(
'/(<!DOCTYPE[^>]*>)/i',
'/(<\?xml[^>]*>)/i',
'/(<\/?html[^>]*>)/i',
'/(<\/?head[^>]*>)/i',
'/(<title[^>]*>.*<\/title>)/Ui',
'/(<\/?meta[^>]*>)/i'),
'<!--\\1-->',
$body);
$out = preg_replace(
array('/<body([^>]*)>/i', '/<\/body>/i'),
array('<div class="rcmBody"\\1>', '</div>'),
$out);
// quote <? of php and xml files that are specified as text/html
$out = preg_replace(array('/<\?/', '/\?>/'), array('&lt;?', '?&gt;'), $out);
return $out;
}
/**
* parse link attributes and set correct target
*/
function rcmail_alter_html_link($tag, $attrs, $container_id)
{
$attrib = parse_attrib_string($attrs);
if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href']))
$attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']) . "&amp;c=" . urlencode($container_id);
else if (stristr((string)$attrib['href'], 'mailto:'))
$attrib['onclick'] = sprintf(
"return %s.command('compose','%s',this)",
JS_OBJECT_NAME,
JQ(substr($attrib['href'], 7)));
else if (!empty($attrib['href']) && $attrib['href']{0}!='#')
$attrib['target'] = '_blank';
return "<$tag" . create_attrib_string($attrib, array('href','name','target','onclick','id','class','style','title','rel','type','media')) . ' />';
}
/**
* decode address string and re-format it as HTML links
*/
function rcmail_address_string($input, $max=null, $linked=false, $addicon=null)
{
global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN;
$a_parts = $IMAP->decode_address_list($input);
if (!sizeof($a_parts))
return $input;
$c = count($a_parts);
$j = 0;
$out = '';
foreach ($a_parts as $part) {
$j++;
if ($PRINT_MODE) {
$out .= sprintf('%s &lt;%s&gt;', Q($part['name']), $part['mailto']);
}
else if (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) {
if ($linked) {
$out .= html::a(array(
'href' => 'mailto:'.$part['mailto'],
'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($part['mailto'])),
'title' => $part['mailto'],
'class' => "rcmContactAddress",
),
Q($part['name']));
}
else {
$out .= html::span(array('title' => $part['mailto'], 'class' => "rcmContactAddress"), Q($part['name']));
}
if ($addicon) {
$out .= '&nbsp;' . html::a(array(
'href' => "#add",
'onclick' => sprintf("return %s.command('add-contact','%s',this)", JS_OBJECT_NAME, urlencode($part['string'])),
'title' => rcube_label('addtoaddressbook'),
),
html::img(array(
'src' => $CONFIG['skin_path'] . $addicon,
'alt' => "Add contact",
'border' => 0,
)));
}
}
else {
if ($part['name'])
$out .= Q($part['name']);
if ($part['mailto'])
$out .= (strlen($out) ? ' ' : '') . sprintf('&lt;%s&gt;', Q($part['mailto']));
}
if ($c>$j)
$out .= ','.($max ? '&nbsp;' : ' ');
if ($max && $j==$max && $c>$j) {
$out .= '...';
break;
}
}
return $out;
}
/**
* Wrap text to a given number of characters per line
* but respect the mail quotation of replies messages (>)
*
* @param string Text to wrap
* @param int The line width
* @return string The wrapped text
*/
function rcmail_wrap_quoted($text, $max = 76)
{
// Rebuild the message body with a maximum of $max chars, while keeping quoted message.
$lines = preg_split('/\r?\n/', trim($text));
$out = '';
foreach ($lines as $line) {
if (strlen($line) > $max) {
if (preg_match('/^([>\s]+)/', $line, $regs)) {
$length = strlen($regs[0]);
$prefix = substr($line, 0, $length);
// Remove '> ' from the line, then wordwrap() the line
$line = wordwrap(substr($line, $length), $max - $length);
// Rebuild the line with '> ' at the beginning of each 'subline'
$newline = '';
foreach (explode("\n", $line) as $l) {
$newline .= $prefix . $l . "\n";
}
// Remove the righest newline char
$line = rtrim($newline);
}
else {
$line = wordwrap($line, $max);
}
}
// Append the line
$out .= $line . "\n";
}
return $out;
}
function rcmail_message_part_controls()
{
global $MESSAGE;
$part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
if (!is_object($MESSAGE) || !is_array($MESSAGE->parts) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part])
return '';
$part = $MESSAGE->mime_parts[$part];
$table = new html_table(array('cols' => 3));
if (!empty($part->filename)) {
$table->add('title', Q(rcube_label('filename')));
$table->add(null, Q($part->filename));
$table->add(null, '[' . html::a('?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), Q(rcube_label('download'))) . ']');
}
if (!empty($part->size)) {
$table->add('title', Q(rcube_label('filesize')));
$table->add(null, Q(show_bytes($part->size)));
}
return $table->show($attrib);
}
function rcmail_message_part_frame($attrib)
{
global $MESSAGE;
$part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];
$ctype_primary = strtolower($part->ctype_primary);
$attrib['src'] = Q('./?'.str_replace('_frame=', ($ctype_primary=='text' ? '_show=' : '_preload='), $_SERVER['QUERY_STRING']));
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height'));
$out = '<iframe '. $attrib_str . "></iframe>";
return $out;
}
/**
* clear message composing settings
*/
function rcmail_compose_cleanup()
{
if (!isset($_SESSION['compose']))
return;
// remove attachment files from temp dir
if (is_array($_SESSION['compose']['attachments']))
foreach ($_SESSION['compose']['attachments'] as $attachment)
@unlink($attachment['path']);
unset($_SESSION['compose']);
}
/**
* Send the given message compose object using the configured method
*/
function rcmail_deliver_message(&$message, $from, $mailto)
{
global $CONFIG;
$msg_body = $message->get();
$headers = $message->headers();
// send thru SMTP server using custom SMTP library
if ($CONFIG['smtp_server'])
{
// generate list of recipients
$a_recipients = array($mailto);
if (strlen($headers['Cc']))
$a_recipients[] = $headers['Cc'];
if (strlen($headers['Bcc']))
$a_recipients[] = $headers['Bcc'];
// clean Bcc from header for recipients
$send_headers = $headers;
unset($send_headers['Bcc']);
// here too, it because txtHeaders() below use $message->_headers not only $send_headers
unset($message->_headers['Bcc']);
// send message
$smtp_response = array();
$sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body, $smtp_response);
// log error
if (!$sent)
raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__,
'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE);
}
// send mail using PHP's mail() function
else
{
// unset some headers because they will be added by the mail() function
$headers_enc = $message->headers($headers);
$headers_php = $message->_headers;
unset($headers_php['To'], $headers_php['Subject']);
// reset stored headers and overwrite
$message->_headers = array();
$header_str = $message->txtHeaders($headers_php);
if (ini_get('safe_mode'))
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
else
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
}
if ($sent)
{
// remove MDN headers after sending
unset($headers['Return-Receipt-To'], $headers['Disposition-Notification-To']);
if ($CONFIG['smtp_log'])
write_log('sendmail', sprintf("[%s] User: %d on %s; Message for %s; %s",
date("d-M-Y H:i:s O", mktime()),
$_SESSION['user_id'],
$_SERVER['REMOTE_ADDR'],
$mailto,
!empty($smtp_response) ? join('; ', $smtp_response) : ''));
}
$message->_headers = array();
$message->headers($headers);
return $sent;
}
function rcmail_send_mdn($uid)
{
global $RCMAIL, $IMAP;
$message = new rcube_message($uid);
if ($message->headers->mdn_to && !$message->headers->mdn_sent && $IMAP->check_permflag('MDNSENT'))
{
$identity = $RCMAIL->user->get_identity();
$sender = format_email_recipient($identity['email'], $identity['name']);
$recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to));
$mailto = $recipient['mailto'];
$compose = new rcube_mail_mime($RCMAIL->config->header_delimiter());
$compose->setParam(array(
'text_encoding' => 'quoted-printable',
'html_encoding' => 'quoted-printable',
'head_encoding' => 'quoted-printable',
'head_charset' => RCMAIL_CHARSET,
'html_charset' => RCMAIL_CHARSET,
'text_charset' => RCMAIL_CHARSET,
));
// compose headers array
$headers = array(
'Date' => date('r'),
'From' => $sender,
'To' => $message->headers->mdn_to,
'Subject' => rcube_label('receiptread') . ': ' . $message->subject,
'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])),
'X-Sender' => $identity['email'],
'Content-Type' => 'multipart/report; report-type=disposition-notification',
);
if ($agent = $RCMAIL->config->get('useragent'))
$headers['User-Agent'] = $agent;
$body = rcube_label("yourmessage") . "\r\n\r\n" .
"\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($message->headers->to, $message->headers->charset) . "\r\n" .
"\t" . rcube_label("subject") . ': ' . $message->subject . "\r\n" .
"\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $RCMAIL->config->get('date_long')) . "\r\n" .
"\r\n" . rcube_label("receiptnote") . "\r\n";
$ua = $RCMAIL->config->get('useragent', "RoundCube Webmail (Version ".RCMAIL_VERSION.")");
$report = "Reporting-UA: $ua\r\n";
if ($message->headers->to)
$report .= "Original-Recipient: {$message->headers->to}\r\n";
$report .= "Final-Recipient: rfc822; {$identity['email']}\r\n" .
"Original-Message-ID: {$message->headers->messageID}\r\n" .
"Disposition: manual-action/MDN-sent-manually; displayed\r\n";
$compose->headers($headers);
$compose->setTXTBody(wordwrap($body, 75, "\r\n"));
$compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline');
$sent = rcmail_deliver_message($compose, $identity['email'], $mailto);
if ($sent)
{
$IMAP->set_flag($message->uid, 'MDNSENT');
return true;
}
}
return false;
}
// register UI objects
$OUTPUT->add_handlers(array(
'mailboxlist' => 'rcmail_mailbox_list',
'messages' => 'rcmail_message_list',
'messagecountdisplay' => 'rcmail_messagecount_display',
'quotadisplay' => 'rcmail_quota_display',
'mailboxname' => 'rcmail_mailbox_name_display',
'messageheaders' => 'rcmail_message_headers',
'messagebody' => 'rcmail_message_body',
'messagecontentframe' => 'rcmail_messagecontent_frame',
'messagepartframe' => 'rcmail_message_part_frame',
'messagepartcontrols' => 'rcmail_message_part_controls',
'searchform' => array($OUTPUT, 'search_form'),
));
?>
diff --git a/program/steps/mail/headers.inc b/program/steps/mail/headers.inc
new file mode 100644
index 000000000..653fb9647
--- /dev/null
+++ b/program/steps/mail/headers.inc
@@ -0,0 +1,39 @@
+<?php
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/mail/headers.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Fetch message headers in raw format for display |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+
+ $Id: mark.inc 1580 2008-06-30 09:36:18Z alec $
+
+*/
+
+if ($uid = get_input_value('_uid', RCUBE_INPUT_POST))
+{
+ $source = $IMAP->get_raw_headers($uid);
+
+ if ($source)
+ {
+ $source = htmlspecialchars(trim($source));
+ $source = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $source);
+ $source = preg_replace('/^([a-z0-9_:-]+)/im', '<font class="bold">'.'\1'.'</font>', $source);
+ $source = preg_replace('/\r?\n/', '<br />', $source);
+
+ $OUTPUT->command('set_headers', $source);
+ $OUTPUT->send();
+ }
+}
+
+exit;
+
+?>
diff --git a/skins/default/addresses.css b/skins/default/addresses.css
index 8ae298781..051b0a099 100644
--- a/skins/default/addresses.css
+++ b/skins/default/addresses.css
@@ -1,200 +1,211 @@
/***** RoundCube|Mail address book task styles *****/
-
#abooktoolbar
{
position: absolute;
top: 45px;
left: 200px;
height: 35px;
}
#abooktoolbar a
{
padding-right: 10px;
}
#abookcountbar
{
position: absolute;
bottom: 16px;
- left: 185px;
+ left: 190px;
width: 240px;
height: 20px;
text-align: left;
}
#abookcountbar span
{
font-size: 11px;
color: #333333;
}
-#directorylist, #addresslist, #importbox
+#mainscreen
{
position: absolute;
top: 85px;
+ right: 20px;
bottom: 40px;
- border: 1px solid #999999;
- background-color: #F9F9F9;
- overflow: auto;
+ left: 200px;
/* css hack for IE */
- height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
+ width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
+ height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
}
#directorylist
{
+ position: absolute;
+ top: 85px;
+ bottom: 40px;
left: 20px;
width: 170px;
+ border: 1px solid #999999;
+ background-color: #F9F9F9;
overflow: hidden;
+ /* css hack for IE */
+ height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
}
#addresslist
{
- left: 200px;
- width: 340px;
+ position: absolute;
+ top: 0px;
+ bottom: 0px;
+ border: 1px solid #999999;
+ background-color: #F9F9F9;
+ overflow: auto;
+ /* css hack for IE */
+ height: expression(parseInt(this.parentNode.offsetHeight)+'px');
}
#importbox
{
+ position: absolute;
+ top: 85px;
+ bottom: 40px;
left: 20px;
- right: 40px;
- height: auto;
- bottom: auto;
+ right: 20px;
+ border: 1px solid #999999;
+ background-color: #F9F9F9;
padding-bottom: 4ex;
+ overflow: auto;
+ /* css hack for IE */
+ height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
+}
+
+#addresslist
+{
+ left: 0px;
+ width: 340px;
}
#importbox a
{
color: blue;
}
#directorylist ul
{
list-style: none;
margin: 0;
padding: 0;
}
#directorylist ul li
{
font-size: 11px;
border-bottom: 1px solid #EBEBEB;
white-space: nowrap;
}
#directorylist ul li a
{
display: block;
padding-left: 6px;
padding-top: 2px;
padding-bottom: 2px;
text-decoration: none;
white-space: nowrap;
}
#directorylist li.selected
{
background-color: #929292;
border-bottom: 1px solid #898989;
}
#directorylist li.selected a
{
color: #FFF;
font-weight: bold;
}
#directorylist li.droptarget
{
background-color: #FFFFA6;
}
#contacts-table
{
width: 100%;
table-layout: fixed;
/* css hack for IE */
width: expression(document.getElementById('addresslist').clientWidth);
}
#contacts-table tbody td
{
cursor: default;
}
#contacts-box
{
position: absolute;
- top: 85px;
+ top: 0px;
left: 555px;
- right: 20px;
- bottom: 40px;
+ right: 0px;
+ bottom: 0px;
border: 1px solid #999999;
overflow: hidden;
/* css hack for IE */
- width: expression((parseInt(document.documentElement.clientWidth)-45-document.getElementById('addresslist').offsetLeft-document.getElementById('addresslist').offsetWidth)+'px');
- height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
+ height: expression(parseInt(this.parentNode.offsetHeight)+'px');
+ width: expression((parseInt(this.parentNode.offsetWidth)-555)+'px');
}
-
-#addressviewsplitter
-{
- background-position: 4px center;
-}
-
-#addressviewsplitter .splitterLine
-{
- margin-left: 3px;
- width: 6px;
-}
-
-
body.iframe,
#contact-frame
{
background-color: #F9F9F9;
}
#contact-frame
{
border: none;
/* visibility: hidden; */
}
#contact-title, #groups-title
{
height: 12px !important;
/* height: 20px; */
padding: 4px 5px 3px 5px;
border-bottom: 1px solid #999;
color: #333;
font-size: 11px;
font-weight: bold;
background-color: #EBEBEB;
background-image: url(images/listheader_aqua.gif);
white-space: nowrap;
}
#contact-title
{
padding: 4px 10px 3px 10px;
}
#contact-details
{
padding: 15px 10px 10px 10px;
}
#contact-details table td.title
{
color: #666;
font-weight: bold;
text-align: right;
padding-right: 10px;
}
diff --git a/skins/default/common.css b/skins/default/common.css
index c9a641fa7..a5b73b002 100644
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -1,440 +1,444 @@
/***** RoundCube|Mail basic styles *****/
body
{
margin: 8px;
background-color: #F6F6F6; /* #EBEBEB; */
color: #000000;
}
body.iframe
{
margin: 0px;
background-color: #FFF;
}
body.extwin
{
margin: 10px;
}
body, td, th, div, p, h3
{
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
th
{
font-weight: normal;
}
h3
{
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #000000;
}
a, a:active, a:visited
{
color: #000000;
outline: none;
}
a.button, a.button:visited, a.tab, a.tab:visited, a.axislist
{
color: #000000;
text-decoration: none;
}
a.tab
{
width: 80px;
display: block;
text-align: center;
}
hr
{
height: 1px;
background-color: #666666;
border-style: none;
}
input, textarea
{
font-size: 9pt;
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
padding: 1px;
padding-left: 3px;
padding-right: 3px;
color: #333333;
background-color: #ffffff;
border: 1px solid #666666;
}
input[type="checkbox"],
input[type="radio"],
input[type="file"]
{
border: 0;
padding: 0;
background-color: transparent;
}
input.button
{
height: 20px;
color: #333333;
font-size: 12px;
padding-left: 8px;
padding-right: 8px;
background: url(images/buttons/bg.gif) repeat-x #f0f0f0;
border: 1px solid #a4a4a4;
}
input.button:hover
{
color: black;
}
input.mainaction
{
font-weight: bold;
border: 1px solid #999;
}
img
{
behavior: url('skins/default/pngbehavior.htc');
}
.alttext
{
font-size: 11px;
}
.hint
{
color: #666;
font-size: 11px;
}
/** common user interface objects */
#header
{
position: absolute;
top: 10px;
left: 20px;
width: 170px;
height: 40px;
z-index: 100;
}
#taskbar
{
position: absolute;
top: 0px;
right: 0px;
width: 600px;
height: 37px;
background: url(images/taskbar.gif) top right no-repeat;
padding: 10px 4px 10px 0px;
text-align: right;
white-space: nowrap;
z-index: 2;
}
#taskbar a,
#taskbar a:active,
#taskbar a:visited
{
font-size: 11px;
color: #666666;
text-decoration: none;
padding: 6px 16px 6px 25px;
background-repeat: no-repeat;
}
#taskbar a:hover
{
color: #333333;
}
a.button-mail
{
background-image: url(images/buttons/mail.gif);
}
a.button-addressbook
{
background-image: url(images/buttons/addressbook.gif);
}
a.button-settings
{
background-image: url(images/buttons/settings.gif);
}
a.button-logout
{
background-image: url(images/buttons/logout.gif);
}
#message
{
position: absolute;
display: none;
top: -1px;
left: 200px;
right: 200px;
z-index: 5000;
opacity: 0.85;
+ /* IE */
+ filter: alpha(opacity=85);
}
#message div
{
width: 400px;
margin: 0px auto;
height: 24px;
min-height: 24px;
padding: 8px 10px 8px 46px;
}
#message div.notice,
#remote-objects-message
{
background: url(images/display/info.png) 6px 3px no-repeat;
background-color: #F7FDCB;
border: 1px solid #C2D071;
}
#message div.error,
#message div.warning
{
background: url(images/display/warning.png) 6px 3px no-repeat;
background-color: #EF9398;
border: 1px solid #DC5757;
}
#message div.confirmation
{
background: url(images/display/confirm.png) 6px 3px no-repeat;
background-color: #A6EF7B;
border: 1px solid #76C83F;
}
#message div.loading
{
background: url(images/display/loading.gif) 6px 3px no-repeat;
background-color: #EBEBEB;
border: 1px solid #CCCCCC;
}
.splitter
{
+ user-select: none;
+ -moz-user-select: none;
+ -khtml-user-select: none;
position: absolute;
- padding: 2px;
background: url(images/dimple.png) center no-repeat;
}
.splitter-h
{
cursor: n-resize;
background-position: center 2px;
}
.splitter-v
{
cursor: e-resize;
- background-position: 1px center;
+ background-position: 2px center;
}
.boxtitle
{
height: 12px !important;
padding: 4px 20px 3px 20px;
border-bottom: 1px solid #999;
color: #333;
font-size: 11px;
font-weight: bold;
background-color: #EBEBEB;
background-image: url(images/listheader_aqua.gif);
}
.radios-left label
{
padding-left: 0.3em;
}
/***** common table settings ******/
table.records-table thead tr td
{
height: 20px;
padding: 0px 4px 0px 4px;
vertical-align: middle;
border-bottom: 1px solid #999999;
color: #333333;
background-color: #EBEBEB;
background-image: url(images/listheader_aqua.gif);
font-size: 11px;
font-weight: bold;
}
table.records-table tbody tr td
{
height: 16px;
padding: 2px 4px 2px 4px;
font-size: 11px;
white-space: nowrap;
border-bottom: 1px solid #EBEBEB;
overflow: hidden;
text-align: left;
}
table.records-table tr
{
background-color: #FFFFFF;
}
table.records-table tr.selected td
{
color: #FFFFFF;
background-color: #CC3333;
}
table.records-table tr.focused td
{
}
table.records-table tr.unfocused td
{
color: #FFFFFF;
background-color: #929292;
}
/***** mac-style quicksearch field *****/
#quicksearchbar
{
position: absolute;
top: 60px;
right: 20px;
width: 182px;
height: 20px;
text-align: right;
background: url('images/searchfield.gif') top left no-repeat;
}
#quicksearchbar a
{
position: absolute;
top: 3px;
right: 4px;
text-decoration: none;
}
#quicksearchbar img
{
vertical-align: middle;
}
#quicksearchbox
{
position: absolute;
top: 2px;
left: 20px;
width: 140px;
font-size: 11px;
padding: 0px;
border: none;
}
/*\*/
html>body*#quicksearchbar[id$="quicksearchbar"]:not([class="none"]) { background-image: none; }
html>body*#quicksearchbar[id$="quicksearchbar"]:not([class="none"]) a { top: 5px; }
html>body*#quicksearchbar[id$="quicksearchbar"]:not([class="none"]) #quicksearchbox { width: 180px; top:0px; right: 1px; left: auto; }
/**/
/***** roundcube webmail pre-defined classes *****/
#rcversion
{
position: absolute;
top: 67px;
left: 20px;
width: 160px;
text-align: center;
font-weight: normal;
font-size: x-small;
font-variant: small-caps;
color: #999999;
/*border: 1px solid #308014;
background-color: #b4eeb4;*/
}
#rcmdraglayer
{
width: 300px;
border: 1px solid #999999;
background-color: #F9F9F9;
padding-left: 8px;
padding-right: 8px;
padding-top: 3px;
padding-bottom: 3px;
font-size: 11px;
opacity: 0.7;
-moz-opacity: 0.7;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
a.rcmContactAddress
{
text-decoration: none;
}
a.rcmContactAddress:hover
{
text-decoration: underline;
}
#rcmKSearchpane
{
background-color: #F9F9F9;
border: 1px solid #CCCCCC;
}
#rcmKSearchpane ul
{
margin: 0px;
padding: 2px;
list-style-image: none;
list-style-type: none;
}
#rcmKSearchpane ul li
{
height: 16px;
font-size: 11px;
padding-left: 8px;
padding-top: 2px;
padding-right: 8px;
white-space: nowrap;
}
#rcmKSearchpane ul li.selected
{
color: #ffffff;
background-color: #CC3333;
}
diff --git a/skins/default/images/icons/down_small.gif b/skins/default/images/icons/down_small.gif
new file mode 100644
index 000000000..f865893f4
Binary files /dev/null and b/skins/default/images/icons/down_small.gif differ
diff --git a/skins/default/images/icons/up_small.gif b/skins/default/images/icons/up_small.gif
new file mode 100644
index 000000000..40deb891f
Binary files /dev/null and b/skins/default/images/icons/up_small.gif differ
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 7807ca231..7f76ed85b 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -1,951 +1,1022 @@
/***** RoundCube|Mail mail task styles *****/
#messagetoolbar
{
position: absolute;
top: 45px;
left: 200px;
right: 200px;
height: 35px;
white-space: nowrap;
/* border: 1px solid #cccccc; */
}
#messagetoolbar a
{
padding-right: 10px;
}
#messagetoolbar select
{
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333333;
}
#messagetoolbar select.mboxlist
{
position: absolute;
left: 375px;
top: 10px;
}
#messagetoolbar select.mboxlist option
{
padding-left: 15px;
}
#messagetoolbar select.mboxlist option[value="0"]
{
padding-left: 2px;
}
#markmessagemenu
{
position: absolute;
top: 32px;
left: 90px;
width: auto;
visibility: hidden;
background-color: #F9F9F9;
border: 1px solid #CCC;
padding: 1px;
opacity: 0.9;
z-index: 240;
}
ul.toolbarmenu
{
margin: 0;
padding: 0;
list-style: none;
}
ul.toolbarmenu li
{
font-size: 11px;
white-space: nowrap;
min-width: 130px;
width: auto !important;
width: 130px;
}
ul.toolbarmenu li a
{
display: block;
color: #a0a0a0;
padding: 2px 8px 3px 12px;
text-decoration: none;
}
ul.toolbarmenu li a.active:hover
{
background-color: #ddd;
}
#listcontrols
{
position: absolute;
left: 200px;
bottom: 20px;
height: 16px;
width: 500px;
font-size: 11px;
}
#listcontrols a,
#listcontrols a:active,
#listcontrols a:visited,
#mailboxcontrols a,
#mailboxcontrols a:active,
#mailboxcontrols a:visited,
td.formlinks a,
td.formlinks a:visited
{
color: #999999;
font-size: 11px;
text-decoration: none;
}
#listcontrols a.active,
#listcontrols a.active:active,
#listcontrols a.active:visited,
#mailboxcontrols a.active,
#mailboxcontrols a.active:active,
#mailboxcontrols a.active:visited,
ul.toolbarmenu li a.active,
ul.toolbarmenu li a.active:active,
ul.toolbarmenu li a.active:visited,
td.formlinks a,
td.formlinks a:visited
{
color: #CC0000;
}
#listcontrols a.active:hover,
#mailboxcontrols a.active:hover
{
text-decoration: underline;
}
#messagecountbar
{
position: absolute;
bottom: 16px;
right: 20px;
width: 300px;
height: 20px;
text-align: right;
white-space: nowrap;
}
#messagecountbar span
{
font-size: 11px;
color: #333333;
}
+#mainscreen
+{
+ position: absolute;
+ top: 85px;
+ right: 20px;
+ bottom: 40px;
+ left: 20px;
+ /* css hack for IE */
+ width: expression((parseInt(document.documentElement.clientWidth)-40)+'px');
+ height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+}
+
+#mailrightcontainer
+{
+ position: absolute;
+ top: 0px;
+ left: 170px;
+ bottom: 0px;
+ right: 0px;
+ /* css hack for IE */
+ width: expression((parseInt(this.parentNode.offsetWidth)-170)+'px');
+ height: expression(parseInt(this.parentNode.offsetHeight)+'px');
+}
+
#messagepartcontainer
{
position: absolute;
top: 80px;
left: 20px;
right: 20px;
bottom: 20px;
/* css hack for IE */
width: expression((parseInt(document.documentElement.clientWidth)-40)+'px');
height: expression((parseInt(document.documentElement.clientHeight)-100)+'px');
}
#mailcontframe
{
position: absolute;
- top: 85px;
- left: 200px;
- right: 20px;
- bottom: 40px;
+ width: 100%;
+ top: 0px;
+ bottom: 0px;
border: 1px solid #999999;
background-color: #F9F9F9;
overflow: auto;
/* css hack for IE */
- width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
- height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+ height: expression(parseInt(this.parentNode.offsetHeight)+'px');
}
#mailpreviewframe
{
position: absolute;
- top: 305px;
- left: 200px;
- right: 20px;
- bottom: 40px;
+ width: 100%;
+ top: 205px;
+ bottom: 0px;
border: 1px solid #999999;
background-color: #F9F9F9;
/* css hack for IE */
- width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
- height: expression((parseInt(document.documentElement.clientHeight)-135-document.getElementById('mailcontframe').offsetHeight)+'px');
+ height: expression((parseInt(this.parentNode.offsetHeight)-205)+'px');
}
#messagecontframe
{
- position: absolute;
+ position: relative;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
- /* css hack for IE */
- width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
- height: expression((parseInt(document.documentElement.clientHeight)-135-document.getElementById('mailcontframe').offsetHeight)+'px');
+ width: 100%;
+ height: 100%;
}
#messagepartframe
{
width: 100%;
height: 100%;
border: 1px solid #999999;
background-color: #F9F9F9;
}
#partheader
{
position: absolute;
top: 10px;
left: 220px;
right: 20px;
height: 40px;
/* css hack for IE */
width: expression((parseInt(document.documentElement.clientWidth)-240)+'px');
}
#partheader table td
{
padding-left: 2px;
padding-right: 4px;
vertical-align: middle;
font-size: 11px;
}
#partheader table td.title
{
color: #666666;
font-weight: bold;
}
/** mailbox list styles */
#mailboxlist-header
{
display: block;
height: 12px;
margin: 0;
padding: 3px 10px 4px 10px;
background-color: #EBEBEB;
background-image: url(images/listheader_aqua.gif);
border-bottom: 1px solid #999;
color: #333333;
font-size: 11px;
font-weight: bold;
}
#mailboxlist-container
{
position: absolute;
- top: 85px;
- left: 20px;
- width: 170px;
- bottom: 40px;
+ top: 0px;
+ left: 0px;
+ width: 160px;
+ bottom: 0px;
border: 1px solid #999;
background-color: #F9F9F9;
overflow: auto;
/* css hack for IE */
- height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+ height: expression(parseInt(this.parentNode.offsetHeight)+'px');
}
#mailboxlist
{
position:relative;
width: 100%;
height: auto;
margin: 0px;
padding: 0px;
list-style-image: none;
list-style-type: none;
overflow: hidden;
white-space: nowrap;
}
#mailboxlist li
{
display: block;
position: relative;
font-size: 11px;
background: url(images/icons/folder-closed.png) no-repeat;
background-position: 5px 1px;
border-bottom: 1px solid #EBEBEB;
}
#mailboxlist li div
{
position: absolute;
left: 8px !important;
left: -16px;
top: 2px;
width: 14px;
height: 16px;
}
#mailboxlist li div.collapsed,
#mailboxlist li div.expanded
{
cursor: pointer;
}
#mailboxlist li div.collapsed
{
background: url(images/icons/collapsed.png) bottom right no-repeat;
}
#mailboxlist li div.expanded
{
background: url(images/icons/expanded.png) bottom right no-repeat;
}
#mailboxlist li.inbox
{
background-image: url(images/icons/folder-inbox.png);
}
#mailboxlist li.drafts
{
background-image: url(images/icons/folder-drafts.png);
}
#mailboxlist li.sent
{
background-image: url(images/icons/folder-sent.png);
}
#mailboxlist li.junk
{
background-image: url(images/icons/folder-junk.png);
}
#mailboxlist li.trash
{
background-image: url(images/icons/folder-trash.png);
}
#mailboxlist li a
{
cursor: default;
display: block;
position: relative;
padding-left: 25px;
padding-top: 2px;
padding-bottom: 2px;
text-decoration: none;
}
#mailboxlist li.unread
{
font-weight: bold;
}
#mailboxlist li.virtual > a
{
color: #666;
}
#mailboxlist li.selected,
#mailboxlist li.droptarget li.selected
{
background-color: #929292;
}
#mailboxlist li.selected > a,
#mailboxlist li.droptarget li.selected a
{
color: #FFF;
font-weight: bold;
}
#mailboxlist li.droptarget
{
background-color: #FFFFA6;
}
/* styles for nested folders */
#mailboxlist ul {
list-style: none;
padding: 0;
margin:0;
border-top: 1px solid #EBEBEB;
padding-left: 15px;
background-position: 25px 1px;
background-color: #F9F9F9;
color: blue;
font-weight: normal;
}
#mailboxcontrols
{
position: absolute;
left: 20px;
width: 185px;
bottom: 20px;
height: 16px;
overflow: hidden;
font-size: 11px;
}
/** message list styles */
body.messagelist
{
margin: 0px;
background-color: #F9F9F9;
}
#messagelist
{
width: 100%;
display: table;
table-layout: fixed;
/* css hack for IE */
width: expression(parseInt(document.getElementById('mailcontframe').clientWidth)+'px');
}
/* safari hack \*/
html>body*#messagelist[id$="messagelist"]:not([class="none"]) { table-layout: auto; }
/**/
#messagelist thead tr td
{
height: 20px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 2px;
padding-right: 4px;
vertical-align: middle;
border-bottom: 1px solid #999999;
color: #333333;
background-color: #EBEBEB;
background-image: url(images/listheader_aqua.gif);
font-size: 11px;
font-weight: bold;
}
#messagelist thead tr td.sortedASC,
#messagelist thead tr td.sortedDESC
{
background-image: url(images/listheader_dark.gif);
}
#messagelist thead tr td.sortedASC a
{
background: url(images/sort_asc.gif) top right no-repeat;
}
#messagelist thead tr td.sortedDESC a
{
background: url(images/sort_desc.gif) top right no-repeat;
}
#messagelist thead tr td a
{
display: block;
width: auto !important;
width: 100%;
color: #333333;
text-decoration: none;
}
#messagelist tbody tr td
{
height: 16px;
padding: 2px;
padding-right: 4px;
font-size: 11px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border-bottom: 1px solid #EBEBEB;
cursor: default;
}
#messagelist tbody tr td a
{
color: #000;
text-decoration: none;
white-space: nowrap;
cursor: inherit;
}
#messagelist col
{
display: table-column;
text-align: left;
vertical-align: middle;
}
#messagelist tr td.icon,
#messagelist tr td.flag
{
width: 16px;
vertical-align: middle;
cursor: pointer;
}
#messagelist tr td.subject
{
overflow: hidden;
vertical-align: middle;
}
#messagelist tr td.size
{
width: 70px;
text-align: right;
vertical-align: middle;
}
#messagelist tr td.from,
#messagelist tr td.to
{
width: 180px;
vertical-align: middle;
}
#messagelist tr td.date
{
width: 118px;
vertical-align: middle;
}
#messagelist tr.message
{
background-color: #FFFFFF;
}
/*
#messagelist tr.odd
{
background-color: #F9F9F9;
}
*/
#messagelist tr.unread
{
font-weight: bold;
background-color: #FFFFFF;
}
#messagelist tr.selected td
{
color: #FFFFFF;
background-color: #CC3333;
}
#messagelist tr.unfocused td
{
color: #FFFFFF;
background-color: #929292;
}
#messagelist tr.selected td a
{
color: #FFFFFF;
}
#messagelist tr.unfocused td a
{
color: #FFFFFF;
}
#messagelist tr.deleted td a
{
color: #CCCCCC;
}
#messagelist tr.deleted td,
#messagelist tr.deleted td a
{
color: #CCCCCC;
}
#quotadisplay
{
color: #666666;
font-size: 11px;
}
#quotadisplay img
{
vertical-align: middle;
margin-left: 4px;
border: 1px solid #666666;
}
/** message view styles */
#messageframe
{
position: absolute;
- top: 85px;
- left: 200px;
- right: 20px;
- bottom: 40px;
+ top: 0px;
+ left: 0px;
+ right: 0px;
+ bottom: 0px;
border: 1px solid #999;
background-color: #FFF;
overflow: auto;
/* css hack for IE */
- /* margin-bottom: 10px; */
width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
}
div.messageheaderbox
{
margin: 6px 8px 0px 8px;
border: 1px solid #ccc;
}
table.headers-table
{
width: 100%;
background-color: #EBEBEB;
table-layout: fixed;
}
#messagebody table.headers-table
{
width: auto;
margin: 6px 8px;
background-color: #F4F4F4;
border: 1px solid #ccc;
}
table.headers-table tr td
{
font-size: 11px;
border-bottom:1px solid #FFFFFF;
}
table.headers-table td.header-title
{
- width: 80px;
+ width: 85px;
color: #666666;
font-weight: bold;
text-align: right;
white-space: nowrap;
padding-right: 4px;
}
table.headers-table tr td.subject
{
- width: 95%;
+ width: 90%;
font-weight: bold;
}
+table.headers-table tr td.all
+{
+ width: 100%;
+ color: #666666;
+ text-align: left;
+ padding-right: 10px;
+ vertical-align: center;
+ text-align: center;
+}
+
#attachment-list
{
margin: 0px;
padding: 0px 0px 0px 72px;
min-height: 16px;
list-style-image: none;
list-style-type: none;
background: url(images/icons/attachment.png) 60px 2px no-repeat #DFDFDF;
/* IE6 hack */
_height: expression(Math.min(16, parseInt(document.documentElement.clientHeight))+'px');
}
#attachment-list:after
{
content: ".";
display: block;
height: 0;
font-size: 0;
clear: both;
visibility: hidden;
}
#attachment-list li
{
float: left;
height: 18px;
font-size: 11px;
padding: 2px 0px 0px 15px;
white-space: nowrap;
}
#attachment-list li a
{
text-decoration: none;
}
#attachment-list li a:hover
{
text-decoration: underline;
}
#messagebody
{
position:relative;
min-height: 300px;
padding-bottom: 10px;
background-color: #FFFFFF;
}
div.message-part
{
padding: 10px 8px;
border-top: 1px solid #ccc;
/* overflow: hidden; */
}
#messagebody div:first-child
{
border-top: 0;
}
div.message-part a,
div.message-htmlpart a
{
color: #0000CC;
}
div.message-part div.pre
{
margin: 0px;
padding: 0px;
font-family: monospace;
white-space: -moz-pre-wrap !important;
white-space: pre;
word-wrap: break-word; /* IE (and Safari) */
}
div.message-part blockquote
{
color: blue;
border-left: 2px solid blue;
border-right: 2px solid blue;
background-color: #F6F6F6;
margin: 2px 0px 2px 0px;
padding: 1px 8px 1px 10px;
}
div.message-part blockquote blockquote
{
color: green;
border-left: 2px solid green;
border-right: 2px solid green;
}
div.message-part blockquote blockquote blockquote
{
color: #990000;
border-left: 2px solid #bb0000;
border-right: 2px solid #bb0000;
}
body.iframe div.message-htmlpart
{
margin: 8px;
}
div.message-htmlpart div.rcmBody
{
margin: 8px;
}
#remote-objects-message
{
display: none;
margin: 8px;
min-height: 20px;
padding: 10px 10px 6px 46px;
}
#remote-objects-message a
{
color: #666666;
padding-left: 10px;
}
#remote-objects-message a:hover
{
color: #333333;
}
/** message compose styles */
#compose-toolbar
{
white-space: nowrap;
}
#priority-selector,
#receipt-selector
{
padding-left: 30px;
white-space: nowrap;
}
#compose-container
{
position: absolute;
top: 90px;
left: 200px;
right: 25px;
bottom: 30px;
padding: 0px;
margin: 0px;
/* css hack for IE */
width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
height: expression((parseInt(document.documentElement.clientHeight)-130)+'px');
}
/*
#compose-headers
{
position: absolute;
top: 70px;
left: 200px;
height: 84px;
border-top: 1px solid #cccccc;
overflow: auto;
}
#compose-headers td
{
padding-top: 1px;
padding-bottom: 1px;
border-right: 1px solid #cccccc;
border-bottom: 1px solid #cccccc;
}
*/
#compose-headers
{
width: 100%;
}
/*
#compose-headers td
{
width: 100%;
}
*/
#compose-headers td.top
{
vertical-align: top;
}
#compose-headers td.title,
#compose-subject td.title
{
width: 80px !important;
color: #666666;
font-size: 11px;
font-weight: bold;
padding-right: 10px;
white-space: nowrap;
}
#compose-body,
#compose-headers td textarea,
#compose-headers td input
{
width: 100%;
width: expression('99%');
}
#compose-headers td textarea
{
height: 38px;
}
#compose-cc,
#compose-bcc,
#compose-replyto
{
display: none;
}
#compose-body
{
margin-top: 5px;
margin-bottom: 10px;
height: 90%;
min-height: 280px;
font-size: 9pt;
font-family: "Courier New", Courier, monospace;
}
#compose-attachments
{
position: absolute;
top: 100px;
left: 20px;
width: 160px;
}
#compose-attachments ul
{
margin: 0px;
padding: 0px;
border: 1px solid #CCCCCC;
background-color: #F9F9F9;
list-style-image: none;
list-style-type: none;
}
#compose-attachments ul li
{
height: 18px;
font-size: 11px;
padding-left: 2px;
padding-top: 2px;
padding-right: 4px;
border-bottom: 1px solid #EBEBEB;
white-space: nowrap;
overflow: hidden;
}
#attachment-title
{
background: url(images/icons/attachment.png) top left no-repeat;
padding: 0px 0px 3px 22px;
}
#attachment-form
{
position: absolute;
top: 150px;
left: 20px;
z-index: 200;
padding: 6px;
visibility: hidden;
border: 1px solid #CCCCCC;
background-color: #F9F9F9;
}
#attachment-form div
{
padding: 2px;
}
#attachment-form div.buttons
{
margin-top: 4px;
}
+
+.more-headers
+{
+ cursor: pointer;
+ width: 100%;
+ height: 6px;
+}
+
+.show-headers
+{
+ background: url(images/icons/down_small.gif) no-repeat center;
+}
+
+.hide-headers
+{
+ background: url(images/icons/up_small.gif) no-repeat center;
+}
+
+#all-headers
+{
+ height: 150px;
+ display: none;
+}
+
+#headers-source
+{
+ margin: 0 5px;
+ width: 100%;
+ height: 145px;
+ background: white;
+ overflow: auto;
+ font-size: 11px;
+ white-space: nowrap;
+ border: 1px solid #999999;
+ display: none;
+ text-align: left;
+ color: #666666;
+}
+
+font.bold
+{
+ font-weight: bold;
+}
diff --git a/skins/default/splitter.js b/skins/default/splitter.js
index 31862ce84..4391ae9fe 100644
--- a/skins/default/splitter.js
+++ b/skins/default/splitter.js
@@ -1,214 +1,244 @@
/**
* RoundCube splitter GUI class
*
* @constructor
*/
function rcube_splitter(attrib)
{
this.p1id = attrib.p1;
this.p2id = attrib.p2;
this.id = attrib.id ? attrib.id : this.p1id + '_' + this.p2id + '_splitter';
this.orientation = attrib.orientation;
this.horizontal = (this.orientation == 'horizontal' || this.orientation == 'h');
- this.offset_1 = bw.ie ? 0 : -1;
- this.offset_2 = bw.ie ? -2 : 1;
- this.pos = 0;
+ this.offset = bw.ie6 ? 2 : 0;
+ this.pos = attrib.start ? attrib.start * 1 : 0;
+ this.relative = attrib.relative ? true : false;
+ this.drag_active = false;
this.init = function()
{
this.p1 = document.getElementById(this.p1id);
this.p2 = document.getElementById(this.p2id);
-
+
// create and position the handle for this splitter
- this.p1pos = rcube_get_object_pos(this.p1);
- this.p2pos = rcube_get_object_pos(this.p2);
- var top = this.p1pos.y + this.p1.offsetHeight;
- var height = this.p2pos.y - this.p1pos.y - this.p1.offsetHeight;
- var left = this.p1pos.x + this.p1.offsetWidth;
- var width = this.p2pos.x - this.p1pos.x - this.p1.offsetWidth;
+ this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+ this.p2pos = rcube_get_object_pos(this.p2, this.relative);
if (this.horizontal)
- this.layer = new rcube_layer(this.id, {x: this.p1pos.x, y: top, height: height, width: this.p1.offsetWidth, vis: 1});
+ {
+ var top = this.p1pos.y + this.p1.offsetHeight;
+ this.layer = new rcube_layer(this.id, {x: 0, y: top, height: 10,
+ width: '100%', vis: 1, parent: this.p1.parentNode});
+ }
else
- this.layer = new rcube_layer(this.id, {x: left, y: this.p1pos.y, width: width, height: this.p1.offsetHeight, vis: 1});
+ {
+ var left = this.p1pos.x + this.p1.offsetWidth;
+ this.layer = new rcube_layer(this.id, {x: left, y: 0, width: 10,
+ height: '100%', vis: 1, parent: this.p1.parentNode});
+ }
this.elm = this.layer.elm;
this.elm.className = 'splitter '+(this.horizontal ? 'splitter-h' : 'splitter-v');
+ this.elm.unselectable = 'on';
// add the mouse event listeners
rcube_event.add_listener({element: this.elm, event:'mousedown', object:this, method:'onDragStart'});
- rcube_event.add_listener({element: window, event:'resize', object:this, method:'onResize'});
+ if (bw.ie)
+ rcube_event.add_listener({element: window, event:'resize', object:this, method:'onResize'});
// read saved position from cookie
var cookie = bw.get_cookie(this.id);
if (cookie)
{
var param = cookie.split(':');
+
for (var i=0, p; i<param.length; i++)
{
p = param[i].split('=');
this[p[0]] = !isNaN(p[1]) ? parseFloat(p[1]) : p[1];
}
this.resize();
}
+ else if (this.pos)
+ {
+ this.resize();
+ this.set_cookie();
+ }
};
/**
* Set size and position of all DOM objects
* according to the saved splitter position
*/
this.resize = function()
{
- if (this.horizontal)
+ if (this.horizontal)
{
- this.p1.style.height = Math.floor(this.pos - this.p1pos.y - this.layer.height / 2 + this.offset_1) + 'px';
- this.p2.style.top = Math.ceil(this.pos + (this.layer.height / 2 + this.offset_2)) + 'px';
- this.layer.move(this.layer.x, Math.round(this.pos - this.layer.height / 2 + 1));
+ var lh = this.layer.height - this.offset * 2;
+ this.p1.style.height = Math.floor(this.pos - this.p1pos.y - lh / 2) + 'px';
+ this.p2.style.top = Math.ceil(this.pos + lh / 2) + 'px';
+ this.layer.move(this.layer.x, Math.round(this.pos - lh / 2 + 1));
+ if (bw.ie)
+ this.p2.style.height = (parseInt(this.p2.parentNode.offsetHeight) - parseInt(this.p2.style.top))+'px';
}
else
{
- this.p1.style.width = Math.floor(this.pos - this.p1pos.x - this.layer.width / 2 + this.offset_1) + 'px';
- this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2 + this.offset_2) + 'px';
+ this.p1.style.width = Math.floor(this.pos - this.p1pos.x - this.layer.width / 2) + 'px';
+ this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2) + 'px';
this.layer.move(Math.round(this.pos - this.layer.width / 2 + 1), this.layer.y);
+ if (bw.ie)
+ this.p2.style.width = (parseInt(this.p2.parentNode.offsetWidth) - parseInt(this.p2.style.left))+'px';
}
};
/**
* Handler for mousedown events
*/
this.onDragStart = function(e)
{
- this.p1pos = rcube_get_object_pos(this.p1);
- this.p2pos = rcube_get_object_pos(this.p2);
-
+ this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+ this.p2pos = rcube_get_object_pos(this.p2, this.relative);
+ this.drag_active = true;
+
// start listening to mousemove events
rcube_event.add_listener({element:document, event:'mousemove', object:this, method:'onDrag'});
rcube_event.add_listener({element:document, event:'mouseup', object:this, method:'onDragStop'});
// need to listen in any iframe documents too, b/c otherwise the splitter stops moving when we move over an iframe
var iframes = document.getElementsByTagName('IFRAME');
this.iframe_events = Object();
for (var n in iframes)
{
var iframedoc = null;
if (iframes[n].contentDocument)
iframedoc = iframes[n].contentDocument;
else if (iframes[n].contentWindow)
iframedoc = iframes[n].contentWindow.document;
else if (iframes[n].document)
iframedoc = iframes[n].document;
if (iframedoc)
{
// I don't use the add_listener function for this one because I need to create closures to fetch
// the position of each iframe when the event is received
var s = this;
var id = iframes[n].id;
this.iframe_events[n] = function(e){ e._rc_pos_offset = rcube_get_object_pos(document.getElementById(id)); return s.onDrag(e); }
+
if (iframedoc.addEventListener)
iframedoc.addEventListener('mousemove', this.iframe_events[n], false);
else if (iframes[n].attachEvent)
iframedoc.attachEvent('onmousemove', this.iframe_events[n]);
else
iframedoc['onmousemove'] = this.iframe_events[n];
rcube_event.add_listener({element:iframedoc, event:'mouseup', object:this, method:'onDragStop'});
}
}
}
/**
* Handler for mousemove events
*/
this.onDrag = function(e)
{
var pos = rcube_event.get_mouse_pos(e);
+
+ if (!this.drag_active) return false;
+
if (e._rc_pos_offset)
{
pos.x += e._rc_pos_offset.x;
pos.y += e._rc_pos_offset.y;
}
+ if (this.relative)
+ {
+ var parent = rcube_get_object_pos(this.p1.parentNode);
+ pos.x -= parent.x;
+ pos.y -= parent.y;
+ }
+
if (this.horizontal)
{
if (((pos.y - this.layer.height * 1.5) > this.p1pos.y) && ((pos.y + this.layer.height * 1.5) < (this.p2pos.y + this.p2.offsetHeight)))
{
this.pos = pos.y;
this.resize();
}
}
else
{
if (((pos.x - this.layer.width * 1.5) > this.p1pos.x) && ((pos.x + this.layer.width * 1.5) < (this.p2pos.x + this.p2.offsetWidth)))
{
this.pos = pos.x;
this.resize();
}
}
- this.p1pos = rcube_get_object_pos(this.p1);
- this.p2pos = rcube_get_object_pos(this.p2);
+ this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+ this.p2pos = rcube_get_object_pos(this.p2, this.relative);
return false;
};
/**
* Handler for mouseup events
*/
this.onDragStop = function(e)
{
// cancel the listening for drag events
rcube_event.remove_listener({element:document, event:'mousemove', object:this, method:'onDrag'});
rcube_event.remove_listener({element:document, event:'mouseup', object:this, method:'onDragStop'});
+ this.drag_active = false;
+
var iframes = document.getElementsByTagName('IFRAME');
for (var n in iframes)
{
var iframedoc;
if (iframes[n].contentDocument)
iframedoc = iframes[n].contentDocument;
else if (iframes[n].contentWindow)
iframedoc = iframes[n].contentWindow.document;
else if (iframes[n].document)
iframedoc = iframes[n].document;
if (iframedoc)
{
if (this.iframe_events[n]) {
if (iframedoc.removeEventListener)
iframedoc.removeEventListener('mousemove', this.iframe_events[n], false);
- else if (iframedoc.detachEvent)
+ else if (iframedoc.detachEvent)
iframedoc.detachEvent('onmousemove', this.iframe_events[n]);
else
iframedoc['onmousemove'] = null;
- }
+ }
rcube_event.remove_listener({element:iframedoc, event:'mouseup', object:this, method:'onDragStop'});
}
}
- // save state in cookie
- var exp = new Date();
- exp.setYear(exp.getFullYear() + 1);
- bw.set_cookie(this.id, 'pos='+this.pos, exp);
-
- // Firefox 3 will initiate its built in drag-and-drop on the divider
- // widget if it already has focus when a second drag event starts
- this.p1.focus();
- this.p1.blur();
+ this.set_cookie();
return bw.safari ? true : rcube_event.cancel(e);
};
-
/**
* Handler for window resize events
*/
this.onResize = function(e)
{
- this.p1pos = rcube_get_object_pos(this.p1);
- this.p2pos = rcube_get_object_pos(this.p2);
- var height = this.horizontal ? this.p2pos.y - this.p1pos.y - this.p1.offsetHeight : this.p1.offsetHeight;
- var width = this.horizontal ? this.p1.offsetWidth : this.p2pos.x - this.p1pos.x - this.p1.offsetWidth;
- this.layer.resize(width, height);
+ if (this.horizontal)
+ this.p2.style.height = (parseInt(this.p2.parentNode.offsetHeight) - parseInt(this.p2.style.top))+'px';
+ else
+ this.p2.style.width = (parseInt(this.p2.parentNode.offsetWidth) - parseInt(this.p2.style.left))+'px';
};
+ this.set_cookie = function()
+ {
+ // save state in cookie
+ var exp = new Date();
+ exp.setYear(exp.getFullYear() + 1);
+ bw.set_cookie(this.id, 'pos='+this.pos, exp);
+ }
+
} // end class rcube_splitter
diff --git a/skins/default/templates/addressbook.html b/skins/default/templates/addressbook.html
index 3f8e460a5..df5f20a02 100644
--- a/skins/default/templates/addressbook.html
+++ b/skins/default/templates/addressbook.html
@@ -1,63 +1,70 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<link rel="stylesheet" type="text/css" href="/addresses.css" />
<script type="text/javascript" src="/splitter.js"></script>
</head>
<body>
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
<div id="abooktoolbar">
<roundcube:button command="add" imageSel="/images/buttons/add_contact_sel.png" imageAct="/images/buttons/add_contact_act.png" imagePas="/images/buttons/add_contact_pas.png" width="32" height="32" title="newcontact" />
<roundcube:button command="delete" imageSel="/images/buttons/delete_sel.png" imageAct="/images/buttons/delete_act.png" imagePas="/images/buttons/delete_pas.png" width="32" height="32" title="deletecontact" />
<roundcube:button command="compose" imageSel="/images/buttons/compose_sel.png" imageAct="/images/buttons/compose_act.png" imagePas="/images/buttons/compose_pas.png" width="32" height="32" title="composeto" />
<roundcube:button command="import" imageSel="/images/buttons/adr_import_sel.png" imageAct="/images/buttons/adr_import_act.png" imagePas="/images/buttons/adr_import_pas.png" width="32" height="32" title="importcontacts" />
<roundcube:button command="export" imageSel="/images/buttons/download_sel.png" imageAct="/images/buttons/download_act.png" imagePas="/images/buttons/download_pas.png" width="32" height="32" title="exportvcards" />
</div>
<div id="quicksearchbar">
<roundcube:object name="searchform" type="search" results="5" id="quicksearchbox" /><roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" />
</div>
<roundcube:if condition="config:ldap_public" />
+
<div id="directorylist">
<div id="groups-title"><roundcube:label name="groups" /></div>
<roundcube:object name="directorylist" id="directories-list" />
</div>
<roundcube:else />
+
<style type="text/css">
-#addresslist { left:20px; width:440px }
-#contacts-box { left:475px }
-#abookcountbar { left:20px }
+#abookcountbar { left: 20px;}
+#mainscreen { left:20px; /* IE hack */ width:expression((parseInt(document.documentElement.clientWidth)-40)+'px') }
+#addresslist { width:245px }
+#contacts-box { left:255px; /* IE hack */ width:expression((parseInt(mainscreen.offsetWidth)-255)+'px') }
</style>
<roundcube:endif />
+<div id="mainscreen">
+
<div id="addresslist">
<roundcube:object name="addresslist" id="contacts-table" class="records-table" cellspacing="0" summary="Contacts list" />
</div>
<script type="text/javascript">
- var addrviewsplit = new rcube_splitter({id:'addressviewsplitter', p1: 'addresslist', p2: 'contacts-box', orientation: 'v'});
+ var addrviewsplit = new rcube_splitter({id:'addressviewsplitter', p1: 'addresslist', p2: 'contacts-box', orientation: 'v', relative: true, start: 250});
rcmail.add_onload('addrviewsplit.init()');
</script>
<div id="contacts-box">
<roundcube:object name="addressframe" id="contact-frame" width="100%" height="100%" frameborder="0" src="/watermark.html" />
</div>
+</div>
+
<div id="abookcountbar">
<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstpage" />
<roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previouspage" />
&nbsp;<roundcube:object name="recordsCountDisplay" />&nbsp;
<roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextpage" />
<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastpage" />
</div>
</body>
</html>
diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html
index 7b6037b31..3d2068d91 100644
--- a/skins/default/templates/mail.html
+++ b/skins/default/templates/mail.html
@@ -1,143 +1,156 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<link rel="stylesheet" type="text/css" href="/mail.css" />
<script type="text/javascript" src="/splitter.js"></script>
<script type="text/javascript">
function rcube_mail_ui()
{
this.markmenu = new rcube_layer('markmessagemenu');
}
rcube_mail_ui.prototype = {
show_markmenu: function(show)
{
if (typeof show == 'undefined')
show = this.markmenu.visible ? false : true;
var ref = rcube_find_object('markreadbutton');
if (show && ref)
this.markmenu.move(ref.offsetLeft, ref.offsetTop + ref.offsetHeight);
this.markmenu.show(show);
},
body_mouseup: function(evt, p)
{
if (this.markmenu && this.markmenu.visible && evt.target != rcube_find_object('markreadbutton'))
this.show_markmenu(false);
},
body_keypress: function(evt, p)
{
if (rcube_event.get_keycode(evt) == 27 && this.markmenu && this.markmenu.visible)
this.show_markmenu(false);
}
};
</script>
</head>
<body>
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
+<div id="mainscreen">
+
<div id="mailboxlist-container">
<h3 id="mailboxlist-header"><roundcube:label name="mailboxlist" /></h3>
<roundcube:object name="mailboxlist" id="mailboxlist" maxlength="16" />
</div>
-<div id="mailboxcontrols">
-<roundcube:label name="folder" />:&nbsp;
-<roundcube:button command="expunge" label="compact" classAct="active" />&nbsp;
-<roundcube:button command="purge" label="empty" classAct="active" />&nbsp;
-</div>
+<script type="text/javascript">
+ var mailviewsplitv = new rcube_splitter({id:'mailviewsplitterv', p1: 'mailboxlist-container', p2: 'mailrightcontainer', orientation: 'v', relative: true, start: 165});
+ rcmail.add_onload('mailviewsplitv.init()');
+</script>
+<div id="mailrightcontainer">
<div id="mailcontframe">
<roundcube:object name="messages"
id="messagelist"
cellspacing="0"
summary="Message list"
messageIcon="/images/icons/dot.png"
unreadIcon="/images/icons/unread.png"
deletedIcon="/images/icons/deleted.png"
repliedIcon="/images/icons/replied.png"
attachmentIcon="/images/icons/attachment.png"
flaggedIcon="/images/icons/flagged.png"
unflaggedIcon="/images/icons/unflagged.png" />
</div>
<roundcube:if condition="config:preview_pane == true" />
+
<script type="text/javascript">
- var mailviewsplit = new rcube_splitter({id:'mailviewsplitter', p1: 'mailcontframe', p2: 'mailpreviewframe', orientation: 'h'});
+ var mailviewsplit = new rcube_splitter({id:'mailviewsplitter', p1: 'mailcontframe', p2: 'mailpreviewframe', orientation: 'h', relative: true, start: 200});
rcmail.add_onload('mailviewsplit.init()');
</script>
+
<div id="mailpreviewframe">
<roundcube:object name="messagecontentframe" id="messagecontframe" width="100%" height="100%" frameborder="0" src="/watermark.html" />
</div>
<style type="text/css">
-#mailcontframe {
- bottom: auto;
- height: 208px;
-}
+#mailcontframe { height: 195px; }
</style>
+
<roundcube:endif />
+</div>
+
+</div>
+
+<div id="mailboxcontrols">
+<roundcube:label name="folder" />:&nbsp;
+<roundcube:button command="expunge" label="compact" classAct="active" />&nbsp;
+<roundcube:button command="purge" label="empty" classAct="active" />&nbsp;
+</div>
+
+
<div id="listcontrols">
<roundcube:label name="select" />:&nbsp;
<roundcube:button command="select-all" label="all" classAct="active" />&nbsp;
<roundcube:button command="select-all" prop="unread" label="unread" classAct="active" />&nbsp;
<roundcube:button command="select-none" label="none" classAct="active" /> &nbsp;&nbsp;&nbsp;
<roundcube:if condition="env:quota" />
<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="image" width="120" id="quotadisplay" />
<roundcube:endif />
</div>
+<div id="messagecountbar">
+<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
+<roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
+&nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
+<roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
+<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
+</div>
+
<div id="messagetoolbar">
<roundcube:button command="checkmail" imageSel="/images/buttons/inbox_sel.png" imageAct="/images/buttons/inbox_act.png" imagePas="/images/buttons/inbox_pas.png" width="32" height="32" title="checkmail" />
<roundcube:button command="compose" imageSel="/images/buttons/compose_sel.png" imageAct="/images/buttons/compose_act.png" imagePas="/images/buttons/compose_pas.png" width="32" height="32" title="writenewmessage" />
<roundcube:button name="markreadbutton" id="markreadbutton" image="/images/buttons/markread_act.png" width="32" height="32" title="markmessages" onclick="rcmailUI.show_markmenu();return false" />
<roundcube:button command="reply" imageSel="/images/buttons/reply_sel.png" imageAct="/images/buttons/reply_act.png" imagePas="/images/buttons/reply_pas.png" width="32" height="32" title="replytomessage" />
<roundcube:button command="reply-all" imageSel="/images/buttons/replyall_sel.png" imageAct="/images/buttons/replyall_act.png" imagePas="/images/buttons/replyall_pas.png" width="32" height="32" title="replytoallmessage" />
<roundcube:button command="forward" imageSel="/images/buttons/forward_sel.png" imageAct="/images/buttons/forward_act.png" imagePas="/images/buttons/forward_pas.png" width="32" height="32" title="forwardmessage" />
<roundcube:button command="delete" imageSel="/images/buttons/delete_sel.png" imageAct="/images/buttons/delete_act.png" imagePas="/images/buttons/delete_pas.png" width="32" height="32" title="deletemessage" />
<roundcube:button command="print" imageSel="/images/buttons/print_sel.png" imageAct="/images/buttons/print_act.png" imagePas="/images/buttons/print_pas.png" width="32" height="32" title="printmessage" />
<div id="markmessagemenu">
<ul class="toolbarmenu">
<li><roundcube:button command="mark" prop="read" label="markread" classAct="active" /></li>
<li><roundcube:button command="mark" prop="unread" label="markunread" classAct="active" /></li>
<li><roundcube:button command="mark" prop="flagged" label="markflagged" classAct="active" /></li>
<li><roundcube:button command="mark" prop="unflagged" label="markunflagged" classAct="active" /></li>
</ul>
</div>
</div>
<div id="quicksearchbar">
<roundcube:object name="searchform" type="search" results="5" id="quicksearchbox" /><roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" />
</div>
-<div id="messagecountbar">
-<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
-<roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
-&nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
-<roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
-<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
-</div>
-
<script type="text/javascript">
var rcmailUI = new rcube_mail_ui();
rcube_event.add_listener({ object:rcmailUI, method:'body_mouseup', event:'mouseup' });
rcube_event.add_listener({ object:rcmailUI, method:'body_keypress', event:'keypress' });
</script>
</body>
</html>
diff --git a/skins/default/templates/message.html b/skins/default/templates/message.html
index dc8dab7da..ccd23eb71 100644
--- a/skins/default/templates/message.html
+++ b/skins/default/templates/message.html
@@ -1,49 +1,59 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<link rel="stylesheet" type="text/css" href="/mail.css" />
+<script type="text/javascript" src="/splitter.js"></script>
</head>
<body>
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
<div id="messagecountbar">
<roundcube:button command="firstmessage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessage" />
<roundcube:button command="previousmessage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessage" />
&nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
<roundcube:button command="nextmessage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessage" />
<roundcube:button command="lastmessage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessage" />
</div>
<div id="messagetoolbar">
<roundcube:button command="list" image="/images/buttons/back_act.png" imageSel="/images/buttons/back_sel.png" imageAct="/images/buttons/back_act.png" width="32" height="32" title="backtolist" />
<roundcube:button command="compose" imageSel="/images/buttons/compose_sel.png" imageAct="/images/buttons/compose_act.png" imagePas="/images/buttons/compose_pas.png" width="32" height="32" title="writenewmessage" />
<roundcube:button command="reply" imageSel="/images/buttons/reply_sel.png" imageAct="/images/buttons/reply_act.png" imagePas="/images/buttons/reply_pas.png" width="32" height="32" title="replytomessage" />
<roundcube:button command="reply-all" imageSel="/images/buttons/replyall_sel.png" imageAct="/images/buttons/replyall_act.png" imagePas="/images/buttons/replyall_pas.png" width="32" height="32" title="replytoallmessage" />
<roundcube:button command="forward" imageSel="/images/buttons/forward_sel.png" imageAct="/images/buttons/forward_act.png" imagePas="/images/buttons/forward_pas.png" width="32" height="32" title="forwardmessage" />
<roundcube:button command="delete" imageSel="/images/buttons/delete_sel.png" imageAct="/images/buttons/delete_act.png" imagePas="/images/buttons/delete_pas.png" width="32" height="32" title="deletemessage" />
<roundcube:button command="print" imageSel="/images/buttons/print_sel.png" imageAct="/images/buttons/print_act.png" imagePas="/images/buttons/print_pas.png" width="32" height="32" title="printmessage" />
<roundcube:button command="viewsource" imageSel="/images/buttons/source_sel.png" imageAct="/images/buttons/source_act.png" imagePas="/images/buttons/source_pas.png" width="32" height="32" title="viewsource" />
<roundcube:object name="mailboxlist" type="select" noSelection="moveto" maxlength="25" onchange="rcmail.command('moveto', this.options[this.selectedIndex].value)" class="mboxlist" />
</div>
+<div id="mainscreen">
+
<div id="mailboxlist-container">
<div id="mailboxlist-header"><roundcube:label name="mailboxlist" /></div>
<roundcube:object name="mailboxlist" id="mailboxlist" maxlength="16" />
</div>
<div id="messageframe">
<roundcube:object name="messageHeaders" class="headers-table" cellspacing="0" cellpadding="2" addicon="/images/icons/plus.gif" summary="Message headers" />
<roundcube:object name="messageAttachments" id="attachment-list" />
<roundcube:object name="blockedObjects" id="remote-objects-message" />
<roundcube:object name="messageBody" id="messagebody" />
</div>
+</div>
+
+<script type="text/javascript">
+ var mailviewsplitv = new rcube_splitter({id:'mailviewsplitterv', p1: 'mailboxlist-container', p2: 'messageframe', orientation: 'v', relative: true, start: 165});
+ rcmail.add_onload('mailviewsplitv.init()');
+</script>
+
</body>
</html>

File Metadata

Mime Type
text/x-diff
Expires
Sat, Mar 1, 9:49 AM (18 h, 35 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
166550
Default Alt Text
(430 KB)

Event Timeline