Changeset 938 in subversion
- Timestamp:
- Dec 10, 2007 10:27:19 AM (5 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 2 added
- 20 edited
-
.htaccess (modified) (2 diffs)
-
CHANGELOG (modified) (1 diff)
-
index.php (modified) (6 diffs)
-
program/include/main.inc (modified) (11 diffs)
-
program/include/rcmail_template.inc (modified) (2 diffs)
-
program/include/rcube_user.inc (added)
-
program/js/app.js (modified) (1 diff)
-
program/lib/imap.inc (modified) (2 diffs)
-
program/lib/rc_mail_mime.inc (modified) (4 diffs)
-
program/localization/en_US/labels.inc (modified) (1 diff)
-
program/localization/en_US/messages.inc (modified) (1 diff)
-
program/steps/mail/compose.inc (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (4 diffs)
-
program/steps/mail/sendmail.inc (modified) (10 diffs)
-
program/steps/mail/sendmdn.inc (added)
-
program/steps/mail/show.inc (modified) (1 diff)
-
program/steps/settings/delete_identity.inc (modified) (1 diff)
-
program/steps/settings/edit_identity.inc (modified) (1 diff)
-
program/steps/settings/func.inc (modified) (3 diffs)
-
program/steps/settings/save_identity.inc (modified) (3 diffs)
-
program/steps/settings/save_prefs.inc (modified) (1 diff)
-
skins/default/mail.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/.htaccess
r801 r938 8 8 php_value upload_max_filesize 5M 9 9 php_value post_max_size 6M 10 php_value memory_limit 64M 10 11 </IfModule> 11 12 … … 16 17 php_value upload_max_filesize 5M 17 18 php_value post_max_size 6M 19 php_value memory_limit 64M 18 20 </IfModule> 19 21 -
trunk/roundcubemail/CHANGELOG
r936 r938 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2007/12/10 (thomasb) 5 ---------- 6 - Delegate user-stuff to new class rcube_user 7 - Implement Message-Disposition-Notification (Receipts) 3 8 4 9 2007/12/05 (tomekp) -
trunk/roundcubemail/index.php
r882 r938 3 3 +-----------------------------------------------------------------------+ 4 4 | RoundCube Webmail IMAP Client | 5 | Version 0.1-20071 017|5 | Version 0.1-20071210 | 6 6 | | 7 7 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | … … 42 42 43 43 // application constants 44 define('RCMAIL_VERSION', '0.1-20071 017');44 define('RCMAIL_VERSION', '0.1-20071210'); 45 45 define('RCMAIL_CHARSET', 'UTF-8'); 46 46 define('JS_OBJECT_NAME', 'rcmail'); … … 197 197 198 198 // log in to imap server 199 if (!empty($ _SESSION['user_id']) && $_task=='mail')199 if (!empty($USER->ID) && $_task=='mail') 200 200 { 201 201 $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']); … … 211 211 212 212 // not logged in -> set task to 'login 213 if (empty($ _SESSION['user_id']))213 if (empty($USER->ID)) 214 214 { 215 215 if ($OUTPUT->ajax_call) … … 239 239 240 240 // not logged in -> show login page 241 if ( !$_SESSION['user_id'])241 if (empty($USER->ID)) 242 242 { 243 243 $OUTPUT->task = 'login'; … … 274 274 if ($_action=='viewsource') 275 275 include('program/steps/mail/viewsource.inc'); 276 277 if ($_action=='sendmdn') 278 include('program/steps/mail/sendmdn.inc'); 276 279 277 280 if ($_action=='send') -
trunk/roundcubemail/program/include/main.inc
r931 r938 30 30 require_once('lib/utf7.inc'); 31 31 require_once('lib/utf8.class.php'); 32 require_once('include/rcube_user.inc'); 32 33 require_once('include/rcube_shared.inc'); 33 34 require_once('include/rcmail_template.inc'); … … 49 50 { 50 51 global $sess_id, $sess_user_lang; 51 global $CONFIG, $INSTALL_PATH, $BROWSER, $OUTPUT, $_SESSION, $IMAP, $DB ;52 global $CONFIG, $INSTALL_PATH, $BROWSER, $OUTPUT, $_SESSION, $IMAP, $DB, $USER; 52 53 53 54 // check client … … 88 89 $sess_user_lang = rcube_language_prop($_SESSION['user_lang']); 89 90 91 // create user object 92 $USER = new rcube_user($_SESSION['user_id']); 90 93 91 94 // overwrite config with user preferences … … 322 325 function rcmail_kill_session() 323 326 { 324 // save user preferences 325 $a_user_prefs = $_SESSION['user_prefs']; 326 if (!is_array($a_user_prefs)) 327 $a_user_prefs = array(); 328 327 global $USER; 328 329 329 if ((isset($_SESSION['sort_col']) && $_SESSION['sort_col']!=$a_user_prefs['message_sort_col']) || 330 330 (isset($_SESSION['sort_order']) && $_SESSION['sort_order']!=$a_user_prefs['message_sort_order'])) 331 331 { 332 $a_user_prefs['message_sort_col'] = $_SESSION['sort_col']; 333 $a_user_prefs['message_sort_order'] = $_SESSION['sort_order']; 334 rcmail_save_user_prefs($a_user_prefs); 332 $a_user_prefs = array('message_sort_col' => $_SESSION['sort_col'], 'message_sort_order' => $_SESSION['sort_order']); 333 $USER->save_prefs($a_user_prefs); 335 334 } 336 335 337 336 $_SESSION = array('user_lang' => $GLOBALS['sess_user_lang'], 'auth_time' => time(), 'temp' => true); 338 337 setcookie('sessauth', '-del-', time()-60); 338 $USER->reset(); 339 339 } 340 340 … … 532 532 function rcmail_login($user, $pass, $host=NULL) 533 533 { 534 global $CONFIG, $IMAP, $DB, $ sess_user_lang;534 global $CONFIG, $IMAP, $DB, $USER, $sess_user_lang; 535 535 $user_id = NULL; 536 536 … … 584 584 // try to resolve email address from virtuser table 585 585 if (!empty($CONFIG['virtuser_file']) && strpos($user, '@')) 586 $user = rc mail_email2user($user);586 $user = rcube_user::email2user($user); 587 587 588 588 // lowercase username if it's an e-mail address (#1484473) … … 591 591 592 592 // query if user already registered 593 $sql_result = $DB->query( 594 "SELECT user_id, username, language, preferences 595 FROM ".get_table_name('users')." 596 WHERE mail_host=? AND (username=? OR alias=?)", 597 $host, 598 $user, 599 $user); 593 if ($existing = rcube_user::query($user, $host)) 594 $USER = $existing; 600 595 601 596 // user already registered -> overwrite username 602 if ($ sql_arr = $DB->fetch_assoc($sql_result))603 { 604 $user_id = $ sql_arr['user_id'];605 $user = $ sql_arr['username'];597 if ($USER->ID) 598 { 599 $user_id = $USER->ID; 600 $user = $USER->data['username']; 606 601 } 607 602 608 603 // exit if IMAP login failed 609 604 if (!($imap_login = $IMAP->connect($host, $user, $pass, $imap_port, $imap_ssl))) 610 return FALSE;605 return false; 611 606 612 607 // user already registered 613 if ($ user_id && !empty($sql_arr))608 if ($USER->ID) 614 609 { 615 610 // get user prefs 616 if (strlen($sql_arr['preferences'])) 617 { 618 $user_prefs = unserialize($sql_arr['preferences']); 619 $_SESSION['user_prefs'] = $user_prefs; 620 array_merge($CONFIG, $user_prefs); 621 } 622 611 $_SESSION['user_prefs'] = $USER->get_prefs(); 612 array_merge($CONFIG, $_SESSION['user_prefs']); 623 613 624 614 // set user specific language 625 if ( strlen($sql_arr['language']))626 $sess_user_lang = $_SESSION['user_lang'] = $ sql_arr['language'];615 if (!empty($USER->data['language'])) 616 $sess_user_lang = $_SESSION['user_lang'] = $USER->data['language']; 627 617 628 618 // update user's record 629 $DB->query("UPDATE ".get_table_name('users')." 630 SET last_login=".$DB->now()." 631 WHERE user_id=?", 632 $user_id); 619 $USER->touch(); 633 620 } 634 621 // create new system user 635 622 else if ($CONFIG['auto_create_user']) 636 623 { 637 $user_id = rcmail_create_user($user, $host); 624 if ($created = rcube_user::create($user, $host)) 625 { 626 $USER = $created; 627 628 // get existing mailboxes 629 $a_mailboxes = $IMAP->list_mailboxes(); 630 } 638 631 } 639 632 else … … 647 640 } 648 641 649 if ($user_id) 650 { 651 $_SESSION['user_id'] = $user_id; 642 if ($USER->ID) 643 { 644 $_SESSION['user_id'] = $USER->ID; 645 $_SESSION['username'] = $USER->data['username']; 652 646 $_SESSION['imap_host'] = $host; 653 647 $_SESSION['imap_port'] = $imap_port; 654 648 $_SESSION['imap_ssl'] = $imap_ssl; 655 $_SESSION['username'] = $user;656 649 $_SESSION['user_lang'] = $sess_user_lang; 657 650 $_SESSION['password'] = encrypt_passwd($pass); … … 670 663 return FALSE; 671 664 } 672 673 674 /**675 * Create new entry in users and identities table676 *677 * @param string User name678 * @param string IMAP host679 * @return mixed New user ID or False on failure680 */681 function rcmail_create_user($user, $host)682 {683 global $DB, $CONFIG, $IMAP;684 685 $user_email = '';686 687 // try to resolve user in virtusertable688 if (!empty($CONFIG['virtuser_file']) && !strpos($user, '@'))689 $user_email = rcmail_user2email($user);690 691 $DB->query("INSERT INTO ".get_table_name('users')."692 (created, last_login, username, mail_host, alias, language)693 VALUES (".$DB->now().", ".$DB->now().", ?, ?, ?, ?)",694 strip_newlines($user),695 strip_newlines($host),696 strip_newlines($user_email),697 $_SESSION['user_lang']);698 699 if ($user_id = $DB->insert_id(get_sequence_name('users')))700 {701 $mail_domain = rcmail_mail_domain($host);702 703 if ($user_email=='')704 $user_email = strpos($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);705 706 $user_name = $user!=$user_email ? $user : '';707 708 // try to resolve the e-mail address from the virtuser table709 if (!empty($CONFIG['virtuser_query']) &&710 ($sql_result = $DB->query(preg_replace('/%u/', $DB->escapeSimple($user), $CONFIG['virtuser_query']))) &&711 ($DB->num_rows()>0))712 {713 while ($sql_arr = $DB->fetch_array($sql_result))714 {715 $DB->query("INSERT INTO ".get_table_name('identities')."716 (user_id, del, standard, name, email)717 VALUES (?, 0, 1, ?, ?)",718 $user_id,719 strip_newlines($user_name),720 preg_replace('/^@/', $user . '@', $sql_arr[0]));721 }722 }723 else724 {725 // also create new identity records726 $DB->query("INSERT INTO ".get_table_name('identities')."727 (user_id, del, standard, name, email)728 VALUES (?, 0, 1, ?, ?)",729 $user_id,730 strip_newlines($user_name),731 strip_newlines($user_email));732 }733 734 // get existing mailboxes735 $a_mailboxes = $IMAP->list_mailboxes();736 }737 else738 {739 raise_error(array(740 'code' => 500,741 'type' => 'php',742 'line' => __LINE__,743 'file' => __FILE__,744 'message' => "Failed to create new user"), TRUE, FALSE);745 }746 747 return $user_id;748 }749 665 750 666 … … 791 707 792 708 return $result; 793 }794 795 796 /**797 * Resolve username using a virtuser table798 *799 * @param string E-mail address to resolve800 * @return string Resolved IMAP username801 */802 function rcmail_email2user($email)803 {804 $user = $email;805 $r = rcmail_findinvirtual("^$email");806 807 for ($i=0; $i<count($r); $i++)808 {809 $data = $r[$i];810 $arr = preg_split('/\s+/', $data);811 if(count($arr)>0)812 {813 $user = trim($arr[count($arr)-1]);814 break;815 }816 }817 818 return $user;819 }820 821 822 /**823 * Resolve e-mail address from virtuser table824 *825 * @param string User name826 * @return string Resolved e-mail address827 */828 function rcmail_user2email($user)829 {830 $email = "";831 $r = rcmail_findinvirtual("$user$");832 833 for ($i=0; $i<count($r); $i++)834 {835 $data=$r[$i];836 $arr = preg_split('/\s+/', $data);837 if (count($arr)>0)838 {839 $email = trim($arr[0]);840 break;841 }842 }843 844 return $email;845 }846 847 848 /**849 * Write the given user prefs to the user's record850 *851 * @param mixed User prefs to save852 * @return boolean True on success, False on failure853 */854 function rcmail_save_user_prefs($a_user_prefs)855 {856 global $DB, $CONFIG, $sess_user_lang;857 858 // merge (partial) prefs array with existing settings859 $a_user_prefs += (array)$_SESSION['user_prefs'];860 861 $DB->query("UPDATE ".get_table_name('users')."862 SET preferences=?,863 language=?864 WHERE user_id=?",865 serialize($a_user_prefs),866 $sess_user_lang,867 $_SESSION['user_id']);868 869 if ($DB->affected_rows())870 {871 $_SESSION['user_prefs'] = $a_user_prefs;872 $CONFIG = array_merge($CONFIG, $a_user_prefs);873 return TRUE;874 }875 876 return FALSE;877 709 } 878 710 … … 1514 1346 return $styles; 1515 1347 } 1348 1349 /** 1350 * Try to autodetect operating system and find the correct line endings 1351 * 1352 * @return string The appropriate mail header delimiter 1353 */ 1354 function rcmail_header_delm() 1355 { 1356 global $CONFIG; 1357 1358 // use the configured delimiter for headers 1359 if (!empty($CONFIG['mail_header_delimiter'])) 1360 return $CONFIG['mail_header_delimiter']; 1361 else if (strtolower(substr(PHP_OS, 0, 3)=='win')) 1362 return "\r\n"; 1363 else if (strtolower(substr(PHP_OS, 0, 3)=='mac')) 1364 return "\r\n"; 1365 else 1366 return "\n"; 1367 } 1516 1368 1517 1369 -
trunk/roundcubemail/program/include/rcmail_template.inc
r930 r938 762 762 function rcmail_current_username($attrib) 763 763 { 764 global $ DB;764 global $USER; 765 765 static $s_username; 766 766 … … 769 769 return $s_username; 770 770 771 // get e-mail address form default identity 772 $sql_result = $DB->query( 773 "SELECT email AS mailto 774 FROM ".get_table_name('identities')." 775 WHERE user_id=? 776 AND standard=1 777 AND del<>1", 778 $_SESSION['user_id']); 779 780 if ($DB->num_rows($sql_result)) 781 { 782 $sql_arr = $DB->fetch_assoc($sql_result); 783 $s_username = $sql_arr['mailto']; 784 } 771 if ($sql_arr = $USER->get_identity()) 772 $s_username = $sql_arr['email']; 785 773 else if (strstr($_SESSION['username'], '@')) 786 774 $s_username = $_SESSION['username']; -
trunk/roundcubemail/program/js/app.js
r934 r938 223 223 this.gui_objects.folderlist = this.gui_objects.mailboxlist; 224 224 this.http_request('getunread', ''); 225 } 226 227 // ask user to send MDN 228 if (this.env.mdn_request && this.env.uid) 229 { 230 var mdnurl = '_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox); 231 if (confirm(this.get_label('mdnrequest'))) 232 this.http_post('sendmdn', mdnurl); 233 else 234 this.http_post('mark', mdnurl+'&_flag=mdnsent'); 225 235 } 226 236 -
trunk/roundcubemail/program/lib/imap.inc
r933 r938 1256 1256 $result[$id]->id = $id; 1257 1257 $result[$id]->subject = ""; 1258 $result[$id]->messageID = "mid:".$id; 1258 1259 /* 1259 1260 Start parsing headers. The problem is, some header "lines" take up multiple lines. … … 1294 1295 1295 1296 // create array with header field:data 1296 $headers = array();1297 1297 while ( list($lines_key, $str) = each($lines) ){ 1298 1298 list($field, $string) = iil_SplitHeaderLine($str); 1299 1299 $field = strtolower($field); 1300 $headers[$field] = $string; 1300 1301 switch ($field){ 1302 case 'date'; 1303 $result[$id]->date = $string; 1304 $result[$id]->timestamp = iil_StrToTime($string); 1305 break; 1306 case 'from': 1307 $result[$id]->from = $string; 1308 break; 1309 case 'to': 1310 $result[$id]->to = str_replace("\n", " ", $string); 1311 break; 1312 case 'subject': 1313 $result[$id]->subject = str_replace("\n", "", $string); 1314 break; 1315 case 'reply-to': 1316 $result[$id]->replyto = str_replace("\n", " ", $string); 1317 break; 1318 case 'cc': 1319 $result[$id]->cc = str_replace("\n", " ", $string); 1320 break; 1321 case 'bcc': 1322 $result[$id]->bcc = str_replace("\n", " ", $string); 1323 break; 1324 case 'content-transfer-encoding': 1325 $result[$id]->encoding = str_replace("\n", " ", $string); 1326 break; 1327 case 'content-type': 1328 $ctype_parts = explode(";", $string); 1329 $result[$id]->ctype = array_shift($ctype_parts); 1330 foreach ($ctype_parts as $ctype_add) 1331 if (preg_match('/charset="?([a-z0-9\-]+)"?/i', $ctype_add, $regs)) 1332 $result[$id]->charset = $regs[1]; 1333 break; 1334 case 'in-reply-to': 1335 $result[$id]->in_reply_to = ereg_replace("[\n<>]", '', $string); 1336 break; 1337 case 'references': 1338 $result[$id]->references = $string; 1339 break; 1340 case 'return-receipt-to': 1341 case 'disposition-notification-to': 1342 case 'x-confirm-reading-to': 1343 $result[$id]->mdn_to = str_replace("\n", " ", $string); 1344 break; 1345 case 'message-id': 1346 $result[$id]->messageID = $string; 1347 break; 1348 } 1301 1349 } 1302 $result[$id]->date = $headers["date"]; 1303 $result[$id]->timestamp = iil_StrToTime($headers["date"]); 1304 $result[$id]->from = $headers["from"]; 1305 $result[$id]->to = str_replace("\n", " ", $headers["to"]); 1306 $result[$id]->subject = str_replace("\n", "", $headers["subject"]); 1307 $result[$id]->replyto = str_replace("\n", " ", $headers["reply-to"]); 1308 $result[$id]->cc = str_replace("\n", " ", $headers["cc"]); 1309 $result[$id]->bcc = str_replace("\n", " ", $headers["bcc"]); 1310 $result[$id]->encoding = str_replace("\n", " ", $headers["content-transfer-encoding"]); 1311 $result[$id]->ctype = str_replace("\n", " ", $headers["content-type"]); 1312 $result[$id]->in_reply_to = ereg_replace("[\n<>]",'', $headers['in-reply-to']); 1313 $result[$id]->references = $headers["references"]; 1314 $result[$id]->mdn_to = $headers["disposition-notification-to"]; 1315 1316 list($result[$id]->ctype, $ctype_add) = explode(";", $headers["content-type"]); 1317 1318 if (preg_match('/charset="?([a-z0-9\-]+)"?/i', $ctype_add, $regs)) 1319 $result[$id]->charset = $regs[1]; 1320 1321 $messageID = $headers["message-id"]; 1322 if (!$messageID) "mid:".$id; 1323 $result[$id]->messageID = $messageID; 1324 } 1325 else { 1326 $a=explode(" ", $line); 1327 } 1350 } 1351 else { 1352 $a=explode(" ", $line); 1353 } 1328 1354 1329 1355 } -
trunk/roundcubemail/program/lib/rc_mail_mime.inc
r514 r938 26 26 class rc_mail_mime extends Mail_mime 27 27 { 28 /** 29 * Set build parameters 30 */ 31 function setParam($param) 32 { 33 if (is_array($param)) 34 $this->_build_params = array_merge($this->_build_params, $param); 35 } 28 36 29 37 /** … … 64 72 return true; 65 73 } 66 74 67 75 68 76 /** … … 74 82 { 75 83 return $this->_htmlbody; 84 } 85 86 87 /** 88 * Creates a new mimePart object, using multipart/mixed as 89 * the initial content-type and returns it during the 90 * build process. 91 * 92 * @return object The multipart/mixed mimePart object 93 * @access private 94 */ 95 function &_addMixedPart() 96 { 97 $params['content_type'] = $this->_headers['Content-Type'] ? $this->_headers['Content-Type'] : 'multipart/mixed'; 98 $ret = new Mail_mimePart('', $params); 99 return $ret; 76 100 } 77 101 … … 139 163 // add chunk to output string by regarding the header maxlen 140 164 $len = strlen($value); 141 if ($ line_len + $len < $maxlen)165 if ($i == 0 || $line_len + $len < $maxlen) 142 166 { 143 167 $hdr_value .= ($i>0?', ':'') . $value; -
trunk/roundcubemail/program/localization/en_US/labels.inc
r842 r938 161 161 $labels['addreplyto'] = 'Add Reply-To'; 162 162 163 // mdn 164 $labels['mdnrequest'] = 'The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?'; 165 $labels['receiptread'] = 'Return Receipt (read)'; 166 $labels['yourmessage'] = 'This is a Return Receipt for your message'; 167 $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.'; 163 168 164 169 // address boook -
trunk/roundcubemail/program/localization/en_US/messages.inc
r842 r938 75 75 $messages['errorsavingcontact'] = 'Could not save the contact address'; 76 76 $messages['movingmessage'] = 'Moving message...'; 77 $messages['receiptsent'] = 'Successfully send the receipt message'; 78 $messages['errorsendingreceipt'] = 'Could not send the receipt'; 77 79 78 80 ?> -
trunk/roundcubemail/program/steps/mail/compose.inc
r911 r938 231 231 function rcmail_compose_header_from($attrib) 232 232 { 233 global $IMAP, $MESSAGE, $DB, $ OUTPUT, $compose_mode;233 global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode; 234 234 235 235 // pass the following attributes to the form class … … 264 264 265 265 // get this user's identities 266 $sql_result = $DB->query("SELECT identity_id, name, email, signature, html_signature 267 FROM ".get_table_name('identities')." 268 WHERE user_id=? 269 AND del<>1 270 ORDER BY ".$DB->quoteIdentifier('standard')." DESC, name ASC", 271 $_SESSION['user_id']); 266 $sql_result = $USER->list_identities(); 272 267 273 268 if ($DB->num_rows($sql_result)) … … 870 865 require_once('include/rcube_contacts.inc'); 871 866 872 $CONTACTS = new rcube_contacts($DB, $ _SESSION['user_id']);867 $CONTACTS = new rcube_contacts($DB, $USER->ID); 873 868 $CONTACTS->set_pagesize(1000); 874 869 -
trunk/roundcubemail/program/steps/mail/func.inc
r931 r938 22 22 require_once('lib/html2text.inc'); 23 23 require_once('lib/enriched.inc'); 24 require_once('include/rcube_smtp.inc'); 24 25 25 26 … … 726 727 // part text/[plain|html] OR message/delivery-status 727 728 else if (($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html') && $mail_part->disposition!='attachment') || 728 ($primary_type=='message' && $secondary_type=='delivery-status'))729 ($primary_type=='message' && ($secondary_type=='delivery-status' || $secondary_type=='disposition-notification'))) 729 730 { 730 731 $mail_part->type = 'content'; … … 759 760 { 760 761 if (!$mail_part->filename) 761 $mail_part->filename = ' file_'.$mail_part->mime_id;762 $mail_part->filename = 'Part '.$mail_part->mime_id; 762 763 $a_attachments[] = $mail_part; 763 764 } … … 1251 1252 unset($_SESSION['compose']); 1252 1253 } 1254 1255 1256 /** 1257 * Send the given message compose object using the configured method 1258 */ 1259 function rcmail_deliver_message(&$message, $from, $mailto) 1260 { 1261 global $CONFIG; 1262 1263 $headers = $message->headers(); 1264 $msg_body = $message->get(); 1265 1266 // send thru SMTP server using custom SMTP library 1267 if ($CONFIG['smtp_server']) 1268 { 1269 // generate list of recipients 1270 $a_recipients = array($mailto); 1271 1272 if (strlen($headers['Cc'])) 1273 $a_recipients[] = $headers['Cc']; 1274 if (strlen($headers['Bcc'])) 1275 $a_recipients[] = $headers['Bcc']; 1276 1277 // clean Bcc from header for recipients 1278 $send_headers = $headers; 1279 unset($send_headers['Bcc']); 1280 1281 // send message 1282 $smtp_response = array(); 1283 $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response); 1284 1285 // log error 1286 if (!$sent) 1287 raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, 1288 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); 1289 } 1290 1291 // send mail using PHP's mail() function 1292 else 1293 { 1294 // unset some headers because they will be added by the mail() function 1295 $headers_enc = $message->headers($headers); 1296 $headers_php = $message->_headers; 1297 unset($headers_php['To'], $headers_php['Subject']); 1298 1299 // reset stored headers and overwrite 1300 $message->_headers = array(); 1301 $header_str = $message->txtHeaders($headers_php); 1302 1303 if (ini_get('safe_mode')) 1304 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); 1305 else 1306 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); 1307 } 1308 1309 1310 $message->_headers = array(); 1311 $message->headers($headers); 1312 1313 return $sent; 1314 } 1253 1315 1254 1316 -
trunk/roundcubemail/program/steps/mail/sendmail.inc
r930 r938 23 23 24 24 //require_once('lib/smtp.inc'); 25 require_once('include/rcube_smtp.inc');26 25 require_once('lib/html2text.inc'); 27 26 require_once('lib/rc_mail_mime.inc'); … … 38 37 39 38 39 // get identity record 40 40 function rcmail_get_identity($id) 41 41 { 42 global $DB, $OUTPUT; 43 44 // get identity record 45 $sql_result = $DB->query("SELECT *, email AS mailto 46 FROM ".get_table_name('identities')." 47 WHERE identity_id=? 48 AND user_id=? 49 AND del<>1", 50 $id,$_SESSION['user_id']); 51 52 if ($DB->num_rows($sql_result)) 53 { 54 $sql_arr = $DB->fetch_assoc($sql_result); 42 global $USER, $OUTPUT; 43 44 if ($sql_arr = $USER->get_identity($id)) 45 { 55 46 $out = $sql_arr; 47 $out['mailto'] = $sql_arr['email']; 56 48 $name = strpos($sql_arr['name'], ",") ? '"'.$sql_arr['name'].'"' : $sql_arr['name']; 57 49 $out['string'] = sprintf('%s <%s>', 58 50 rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()), 59 $sql_arr[' mailto']);51 $sql_arr['email']); 60 52 return $out; 61 53 } … … 167 159 168 160 // compose headers array 169 $headers = array('Date' => date(' D, j M Y H:i:s O'),161 $headers = array('Date' => date('r'), 170 162 'From' => rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset), 171 163 'To' => $mailto); … … 226 218 $message_body .= "\r\n" . rcube_charset_convert($footer, 'UTF-8', $message_charset); 227 219 228 // try to autodetect operating system and use the correct line endings229 // use the configured delimiter for headers230 if (!empty($CONFIG['mail_header_delimiter']))231 $header_delm = $CONFIG['mail_header_delimiter'];232 else if (strtolower(substr(PHP_OS, 0, 3)=='win'))233 $header_delm = "\r\n";234 else if (strtolower(substr(PHP_OS, 0, 3)=='mac'))235 $header_delm = "\r\n";236 else237 $header_delm = "\n";238 239 240 220 $isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST)); 241 221 $isHtml = ($isHtmlVal == "1"); 242 222 243 223 // create extended PEAR::Mail_mime instance 244 $MAIL_MIME = new rc_mail_mime( $header_delm);224 $MAIL_MIME = new rc_mail_mime(rcmail_header_delm()); 245 225 246 226 // For HTML-formatted messages, construct the MIME message with both … … 283 263 284 264 // encoding settings for mail composing 285 $ message_param =array(265 $MAIL_MIME->setParam(array( 286 266 'text_encoding' => $transfer_encoding, 287 267 'html_encoding' => 'quoted-printable', … … 290 270 'html_charset' => $message_charset, 291 271 'text_charset' => $message_charset, 292 ); 293 294 // compose message body and get headers 295 $msg_body = $MAIL_MIME->get($message_param); 296 // unset to save memory. 297 unset($MAIL_MIME->_parts); 272 )); 298 273 299 274 // encoding subject header with mb_encode provides better results with asian characters … … 301 276 { 302 277 mb_internal_encoding($message_charset); 303 $ mb_subject= mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');278 $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q'); 304 279 mb_internal_encoding(RCMAIL_CHARSET); 305 280 } 306 281 282 // pass headers to message object 283 $MAIL_MIME->headers($headers); 284 307 285 // Begin SMTP Delivery Block 308 if (!$savedraft) { 309 310 // send thru SMTP server using custom SMTP library 311 if ($CONFIG['smtp_server']) 312 { 313 // generate list of recipients 314 $a_recipients = array($mailto); 315 316 if (strlen($headers['Cc'])) 317 $a_recipients[] = $headers['Cc']; 318 if (strlen($headers['Bcc'])) 319 $a_recipients[] = $headers['Bcc']; 320 321 // clean Bcc from header for recipients 322 $send_headers = $headers; 323 unset($send_headers['Bcc']); 324 325 if (!empty($mb_subject)) 326 $send_headers['Subject'] = $mb_subject; 327 328 // send message 329 $smtp_response = array(); 330 $sent = smtp_mail($from, $a_recipients, ($foo = $MAIL_MIME->txtHeaders($send_headers)), $msg_body, $smtp_response); 331 332 // log error 333 if (!$sent) 334 raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, 335 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); 336 } 337 338 // send mail using PHP's mail() function 339 else 340 { 341 // unset some headers because they will be added by the mail() function 342 $headers_enc = $MAIL_MIME->headers($headers); 343 $headers_php = $MAIL_MIME->_headers; 344 unset($headers_php['To'], $headers_php['Subject']); 345 346 if (!empty($mb_subject)) 347 $headers_enc['Subject'] = $mb_subject; 348 349 // reset stored headers and overwrite 350 $MAIL_MIME->_headers = array(); 351 $header_str = $MAIL_MIME->txtHeaders($headers_php); 352 353 if (ini_get('safe_mode')) 354 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); 355 else 356 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); 357 } 358 286 if (!$savedraft) 287 { 288 $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto); 359 289 360 290 // return to compose page if sending failed … … 365 295 return; 366 296 } 367 368 297 369 298 // set repliead flag … … 383 312 if ($CONFIG[$store_target]) 384 313 { 385 // create string of complete message headers386 $header_str = $MAIL_MIME->txtHeaders($headers);387 388 314 // check if mailbox exists 389 315 if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes())) … … 392 318 $store_folder = TRUE; 393 319 394 // add headers to message body395 $msg_body = $header_str."\r\n".$msg_body;396 397 320 // append message to sent box 398 321 if ($store_folder) 399 $saved = $IMAP->save_message($CONFIG[$store_target], $ msg_body);322 $saved = $IMAP->save_message($CONFIG[$store_target], $MAIL_MIME->getMessage()); 400 323 401 324 // raise error if saving failed -
trunk/roundcubemail/program/steps/mail/show.inc
r933 r938 76 76 // check for unset disposition notification 77 77 if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent) 78 { 79 rcube_add_label('mdnrequest'); 78 80 $OUTPUT->set_env('mdn_request', true); 81 } 79 82 80 83 $next = $prev = -1; -
trunk/roundcubemail/program/steps/settings/delete_identity.inc
r543 r938 22 22 if (($ids = get_input_value('_iid', RCUBE_INPUT_GET)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids)) 23 23 { 24 $DB->query(25 "UPDATE ".get_table_name('identities')."26 SET del=127 WHERE user_id=?28 AND identity_id IN (".$ids.")",29 $_SESSION['user_id']);30 24 31 $count = $DB->affected_rows(); 32 if ($count) 25 if ($USER->delete_identity($ids)) 33 26 $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); 34 27 -
trunk/roundcubemail/program/steps/settings/edit_identity.inc
r543 r938 22 22 if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity') 23 23 { 24 $DB->query("SELECT * FROM ".get_table_name('identities')." 25 WHERE identity_id=? 26 AND user_id=? 27 AND del<>1", 28 get_input_value('_iid', RCUBE_INPUT_GPC), 29 $_SESSION['user_id']); 30 31 $IDENTITY_RECORD = $DB->fetch_assoc(); 24 $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); 32 25 33 26 if (is_array($IDENTITY_RECORD)) -
trunk/roundcubemail/program/steps/settings/func.inc
r922 r938 21 21 22 22 23 // get user record 24 $sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('users')." 25 WHERE user_id=?", 26 $_SESSION['user_id']); 27 28 if ($USER_DATA = $DB->fetch_assoc($sql_result)) 29 { 30 $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER_DATA['username'] . (!strpos($USER_DATA['username'], '@') ? '@'.$USER_DATA['mail_host'] : '')); 31 } 23 if ($USER->ID) 24 $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER->get_username()); 32 25 33 26 … … 205 198 function rcmail_identities_list($attrib) 206 199 { 207 global $DB, $CONFIG, $OUTPUT; 208 209 210 // get contacts from DB 211 $sql_result = $DB->query("SELECT * FROM ".get_table_name('identities')." 212 WHERE del<>1 213 AND user_id=? 214 ORDER BY standard DESC, name ASC", 215 $_SESSION['user_id']); 216 200 global $OUTPUT, $USER; 217 201 218 202 // add id to message list table if not specified … … 224 208 225 209 // create XHTML table 226 $out = rcube_table_output($attrib, $ sql_result, $a_show_cols, 'identity_id');210 $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id'); 227 211 228 212 // set client env -
trunk/roundcubemail/program/steps/settings/save_identity.inc
r543 r938 34 34 35 35 36 $save_data = array(); 37 foreach ($a_save_cols as $col) 38 { 39 $fname = '_'.$col; 40 if (isset($_POST[$fname])) 41 $save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols)); 42 } 43 44 // set "off" values for checkboxes that were not checked, and therefore 45 // not included in the POST body. 46 foreach ($a_boolean_cols as $col) 47 { 48 $fname = '_' . $col; 49 if (!isset($_POST[$fname])) 50 $save_data[$col] = 0; 51 } 52 53 36 54 // update an existing contact 37 55 if ($_POST['_iid']) 56 { 57 if ($updated = $USER->update_identity(get_input_value('_iid', RCUBE_INPUT_POST), $save_data)) 38 58 { 39 $a_write_sql = array();40 41 foreach ($a_save_cols as $col)42 {43 $fname = '_'.$col;44 if (isset($_POST[$fname]))45 $a_write_sql[] = sprintf("%s=%s",46 $DB->quoteIdentifier($col),47 $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols))));48 }49 50 // set "off" values for checkboxes that were not checked, and therefore51 // not included in the POST body.52 foreach ($a_boolean_cols as $col)53 {54 $fname = '_' . $col;55 if (!isset($_POST[$fname]))56 $a_write_sql[] = sprintf("%s=0", $DB->quoteIdentifier($col));57 }58 59 if (sizeof($a_write_sql))60 {61 $DB->query(62 "UPDATE ".get_table_name('identities')."63 SET ".join(', ', $a_write_sql)."64 WHERE identity_id=?65 AND user_id=?66 AND del<>1",67 get_input_value('_iid', RCUBE_INPUT_POST),68 $_SESSION['user_id']);69 70 $updated = $DB->affected_rows();71 }72 73 if ($updated)74 {75 59 $OUTPUT->show_message('successfullysaved', 'confirmation'); 76 60 … … 79 63 80 64 if ($_POST['_framed']) 81 {65 { 82 66 // update the changed col in list 83 67 // ... 84 }85 68 } 69 } 86 70 else if ($DB->is_error()) 87 {71 { 88 72 // show error message 89 73 $OUTPUT->show_message('errorsaving', 'error'); 90 74 rcmail_overwrite_action('edit-identitiy'); 91 75 return; 92 }93 76 } 77 } 94 78 95 79 // insert a new contact 96 80 else 81 { 82 if ($insert_id = $USER->insert_identity($save_data)) 97 83 { 98 $a_insert_cols = $a_insert_values = array();99 100 foreach ($a_save_cols as $col)101 {102 $fname = '_'.$col;103 if (!isset($_POST[$fname]))104 continue;105 106 $a_insert_cols[] = $DB->quoteIdentifier($col);107 $a_insert_values[] = $DB->quote(get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols)));108 }109 110 if (sizeof($a_insert_cols))111 {112 $DB->query("INSERT INTO ".get_table_name('identities')."113 (user_id, ".join(', ', $a_insert_cols).")114 VALUES (?, ".join(', ', $a_insert_values).")",115 $_SESSION['user_id']);116 117 $insert_id = $DB->insert_id(get_sequence_name('identities'));118 }119 120 if ($insert_id)121 {122 84 $_GET['_iid'] = $insert_id; 123 85 … … 126 88 127 89 if ($_POST['_framed']) 128 {90 { 129 91 // add contact row or jump to the page where it should appear 130 92 // .... 131 }132 93 } 94 } 133 95 else 134 {96 { 135 97 // show error message 136 98 $OUTPUT->show_message('errorsaving', 'error'); 137 99 rcmail_overwrite_action('edit-identity'); 138 100 return; 139 }140 101 } 102 } 141 103 142 104 143 105 // mark all other identities as 'not-default' 144 106 if ($default_id) 145 $DB->query( 146 "UPDATE ".get_table_name('identities')." 147 SET ".$DB->quoteIdentifier('standard')."='0' 148 WHERE user_id=? 149 AND identity_id<>? 150 AND del<>1", 151 $_SESSION['user_id'], 152 $default_id); 107 $USER->set_default($default_id); 153 108 154 109 // go to next step -
trunk/roundcubemail/program/steps/settings/save_prefs.inc
r768 r938 45 45 // force min size 46 46 if ($a_user_prefs['pagesize'] < 1) 47 {48 47 $a_user_prefs['pagesize'] = 10; 49 } 48 50 49 if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize'])) 51 {52 50 $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize']; 53 }54 51 55 if ( rcmail_save_user_prefs($a_user_prefs))52 if ($USER->save_prefs($a_user_prefs)) 56 53 $OUTPUT->show_message('successfullysaved', 'confirmation'); 57 54 -
trunk/roundcubemail/skins/default/mail.css
r846 r938 633 633 position:relative; 634 634 min-height: 300px; 635 padding-top: 10px;636 635 padding-bottom: 10px; 637 636 background-color: #FFFFFF; … … 640 639 div.message-part 641 640 { 642 padding: 8px; 643 padding-top: 10px; 644 overflow: hidden; 641 padding: 10px 8px; 642 border-top: 1px solid #ccc; 643 /* overflow: hidden; */ 644 } 645 646 #messagebody div:first-child 647 { 648 border-top: 0; 645 649 } 646 650
Note: See TracChangeset
for help on using the changeset viewer.
