Changeset 962 in subversion
- Timestamp:
- Jan 28, 2008 9:28:08 AM (5 years ago)
- Location:
- branches/devel-vnext/program
- Files:
-
- 1 added
- 29 edited
-
include/rcube/rcmail_compose.php (modified) (15 diffs)
-
steps/addressbook/copy.inc (modified) (2 diffs)
-
steps/addressbook/func.inc (modified) (5 diffs)
-
steps/addressbook/mailto.inc (modified) (3 diffs)
-
steps/addressbook/save.inc (modified) (4 diffs)
-
steps/error.inc (modified) (1 diff)
-
steps/mail/addcontact.inc (modified) (1 diff)
-
steps/mail/check_recent.inc (modified) (5 diffs)
-
steps/mail/compose.inc (modified) (5 diffs)
-
steps/mail/folders.inc (modified) (3 diffs)
-
steps/mail/func.inc (modified) (51 diffs)
-
steps/mail/get.inc (modified) (7 diffs)
-
steps/mail/getunread.inc (modified) (1 diff)
-
steps/mail/list.inc (modified) (3 diffs)
-
steps/mail/move_del.inc (modified) (6 diffs)
-
steps/mail/quotadisplay.inc (modified) (1 diff)
-
steps/mail/rss.inc (modified) (6 diffs)
-
steps/mail/search.inc (modified) (2 diffs)
-
steps/mail/sendmail.inc (modified) (14 diffs)
-
steps/mail/sendmdn.inc (added)
-
steps/mail/show.inc (modified) (4 diffs)
-
steps/mail/spell.inc (modified) (1 diff)
-
steps/mail/upload.inc (modified) (1 diff)
-
steps/mail/viewsource.inc (modified) (1 diff)
-
steps/settings/delete_identity.inc (modified) (2 diffs)
-
steps/settings/edit_identity.inc (modified) (9 diffs)
-
steps/settings/func.inc (modified) (4 diffs)
-
steps/settings/manage_folders.inc (modified) (9 diffs)
-
steps/settings/save_identity.inc (modified) (6 diffs)
-
steps/settings/save_prefs.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-vnext/program/include/rcube/rcmail_compose.php
r806 r962 11 11 $MESSAGE = $registry->get('MESSAGE', 'core'); 12 12 $DB = $registry->get('DB', 'core'); 13 $USER = $registry->get('USER', 'core'); 13 14 $compose_mode = $registry->get('compose_mode', 'core'); 14 15 $sa_recipients = $registry->get('sa_recipients', 'core'); … … 24 25 25 26 switch ($part) { 26 case 'from':27 return rcmail_compose_header_from($attrib);28 29 case 'to':30 $fname = '_to';31 $header = 'to';32 33 // we have a set of recipients stored is session34 if (35 ($mailto_id = rcube::get_input_value('_mailto', rcube::INPUT_GET))36 && $_SESSION['mailto'][$mailto_id]37 ) {38 $fvalue = $_SESSION['mailto'][$mailto_id];39 }40 elseif (!empty($_GET['_to'])) {41 $fvalue = rcube::get_input_value('_to', rcube::INPUT_GET);42 }43 44 case 'cc':45 if (!$fname) {46 $fname = '_cc';47 $header = 'cc';48 }49 case 'bcc':50 if (!$fname) {51 $fname = '_bcc';52 $header = 'bcc';53 }54 $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'wrap', 'tabindex');55 $field_type = 'html_textarea';56 break;57 58 case 'replyto':59 case 'reply-to':60 $fname = '_replyto';61 $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex');62 $field_type = 'html_inputfield';63 break;27 case 'from': 28 return rcmail_compose_header_from($attrib); 29 30 case 'to': 31 $fname = '_to'; 32 $header = 'to'; 33 34 // we have a set of recipients stored is session 35 if ( 36 ($mailto_id = rcube::get_input_value('_mailto', rcube::INPUT_GET)) 37 && $_SESSION['mailto'][$mailto_id] 38 ) { 39 $fvalue = $_SESSION['mailto'][$mailto_id]; 40 } 41 elseif (!empty($_GET['_to'])) { 42 $fvalue = rcube::get_input_value('_to', rcube::INPUT_GET); 43 } 44 45 case 'cc': 46 if (!$fname) { 47 $fname = '_cc'; 48 $header = 'cc'; 49 } 50 case 'bcc': 51 if (!$fname) { 52 $fname = '_bcc'; 53 $header = 'bcc'; 54 } 55 $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'wrap', 'tabindex'); 56 $field_type = 'html_textarea'; 57 break; 58 59 case 'replyto': 60 case 'reply-to': 61 $fname = '_replyto'; 62 $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); 63 $field_type = 'html_inputfield'; 64 break; 64 65 } 65 66 … … 76 77 if ($fname && !empty($_POST[$fname])) { 77 78 $fvalue = rcube::get_input_value($fname, rcube::INPUT_POST, TRUE); 78 } 79 else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { 79 } else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { 80 80 // get recipent address(es) out of the message headers 81 81 if ($header=='to' && !empty($reply_to)) { 82 82 $fvalue = $reply_to; 83 } 84 else if ($header=='to' && !empty($from)) { 83 } else if ($header=='to' && !empty($from)) { 85 84 $fvalue = $from; 86 85 } … … 158 157 $MESSAGE = $registry->get('MESSAGE', 'core'); 159 158 $DB = $registry->get('DB', 'core'); 159 $USER = $registry->get('USER', 'core'); 160 160 $compose_mode = $registry->get('compose_mode', 'core'); 161 161 $OUTPUT = $registry->get('OUTPUT', 'core'); … … 190 190 } 191 191 192 // get this user's identities 193 $_query = "SELECT identity_id, name, email, signature, html_signature"; 194 $_query.= " FROM " . rcube::get_table_name('identities'); 195 $_query.= " WHERE user_id=?"; 196 $_query.= " AND del<>1"; 197 $_query.= " ORDER BY " . $DB->quoteIdentifier('standard')." DESC, name ASC"; 198 199 //rcube::tfk_debug($_query); 200 201 $sql_result = $DB->query($_query, $_SESSION['user_id']); 202 203 192 $sql_result = $USER->list_identities(); 204 193 if ($DB->num_rows($sql_result) == 0) { 205 194 $input_from = new html_inputfield($field_attrib); … … 239 228 } 240 229 } 241 230 242 231 // set identity if it's one of the reply-message recipients 243 232 if (in_array($sql_arr['email'], $a_recipients)) { 244 233 $from_id = $sql_arr['identity_id']; 245 234 } 235 246 236 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE['FROM'])) { 247 237 $MESSAGE['FROM'][] = $sql_arr['email']; 248 238 } 239 249 240 if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE['headers']->from, $sql_arr['email'])) { 250 241 $from_id = $sql_arr['identity_id']; … … 286 277 if ($CONFIG['htmleditor']) { 287 278 $isHtml = true; 288 } 289 else { 279 } else { 290 280 $isHtml = false; 291 281 } … … 295 285 if (!empty($_POST['_message'])) { 296 286 $body = rcube::get_input_value('_message', rcube::INPUT_POST, TRUE); 297 } 298 // compose reply-body 299 elseif ($compose_mode == RCUBE_COMPOSE_REPLY) { 287 } elseif ($compose_mode == RCUBE_COMPOSE_REPLY) { 288 // compose reply-body 300 289 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 301 290 if ($hasHtml && $CONFIG['htmleditor']) { 302 291 $body = rcmail_first_html_part($MESSAGE); 303 292 $isHtml = true; 304 } 305 else { 293 } else { 306 294 $body = rcmail_first_text_part($MESSAGE); 307 295 $isHtml = false; 308 296 } 309 297 $body = rcmail_create_reply_body($body, $isHtml); 310 } 311 // forward message body inline 312 elseif ($compose_mode == RCUBE_COMPOSE_FORWARD) { 298 } elseif ($compose_mode == RCUBE_COMPOSE_FORWARD) { 299 // forward message body inline 313 300 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 314 301 if ($hasHtml && $CONFIG['htmleditor']) { 315 302 $body = rcmail_first_html_part($MESSAGE); 316 303 $isHtml = true; 317 } 318 else { 304 } else { 319 305 $body = rcmail_first_text_part($MESSAGE); 320 306 $isHtml = false; 321 307 } 322 308 $body = rcmail_create_forward_body($body, $isHtml); 323 } 324 elseif ($compose_mode == RCUBE_COMPOSE_DRAFT) { 309 } elseif ($compose_mode == RCUBE_COMPOSE_DRAFT) { 325 310 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 326 311 if ($hasHtml && $CONFIG['htmleditor']) { 327 312 $body = rcmail_first_html_part($MESSAGE); 328 313 $isHtml = true; 329 } 330 else { 331 $body = rcmail_first_text_part($MESSAGE); 314 } else { 315 $body = rcmail_first_text_part($MESSAGE); 332 316 $isHtml = false; 333 317 } 334 318 $body = rcmail_create_draft_body($body, $isHtml); 335 319 } 320 321 $OUTPUT->include_script('tiny_mce/tiny_mce.js'); 322 $OUTPUT->include_script("editor.js"); 323 $OUTPUT->add_script('rcmail_editor_init("$__skin_path");'); 324 336 325 $out = $form_start ? "$form_start\n" : ''; 337 326 338 //tfk_debug($MESSAGE['headers']);339 340 327 $saveid = new html_hiddenfield( 341 array( 342 'name' => '_draft_saveid', 343 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), 344 "", 345 $MESSAGE['headers']->messageID) : '' 346 ) 347 ); 328 array( 329 'name' => '_draft_saveid', 330 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), 331 "", 332 $MESSAGE['headers']->messageID) : '' 333 )); 348 334 $out .= $saveid->show(); 349 335 … … 370 356 $OUTPUT->include_script('googiespell.js'); 371 357 $OUTPUT->add_script( 372 sprintf( 373 "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n". 374 "googie.lang_chck_spell = \"%s\";\n". 375 "googie.lang_rsm_edt = \"%s\";\n". 376 "googie.lang_close = \"%s\";\n". 377 "googie.lang_revert = \"%s\";\n". 378 "googie.lang_no_error_found = \"%s\";\n%s". 379 "googie.setCurrentLanguage('%s');\n". 380 "googie.decorateTextarea('%s');\n". 381 "%s.set_env('spellcheck', googie);", 382 $COMM_PATH, 383 JQ(Q(rcube::gettext('checkspelling'))), 384 JQ(Q(rcube::gettext('resumeediting'))), 385 JQ(Q(rcube::gettext('close'))), 386 JQ(Q(rcube::gettext('revertto'))), 387 JQ(Q(rcube::gettext('nospellerrors'))), 388 $lang_set, 389 substr($_SESSION['user_lang'], 0, 2), 390 $attrib['id'], 391 JS_OBJECT_NAME), 'foot' 392 ); 358 sprintf( 359 "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n". 360 "googie.lang_chck_spell = \"%s\";\n". 361 "googie.lang_rsm_edt = \"%s\";\n". 362 "googie.lang_close = \"%s\";\n". 363 "googie.lang_revert = \"%s\";\n". 364 "googie.lang_no_error_found = \"%s\";\n%s". 365 "googie.setCurrentLanguage('%s');\n". 366 "googie.decorateTextarea('%s');\n". 367 "%s.set_env('spellcheck', googie);", 368 $COMM_PATH, 369 JQ(Q(rcube::gettext('checkspelling'))), 370 JQ(Q(rcube::gettext('resumeediting'))), 371 JQ(Q(rcube::gettext('close'))), 372 JQ(Q(rcube::gettext('revertto'))), 373 JQ(Q(rcube::gettext('nospellerrors'))), 374 $lang_set, 375 substr($_SESSION['user_lang'], 0, 2), 376 $attrib['id'], 377 JS_OBJECT_NAME), 'foot'); 393 378 $OUTPUT->add_label('checking'); 394 379 } … … 428 413 if (strpos($a_lines[$n], '>')===0) { 429 414 $a_lines[$n] = '>'.$a_lines[$n]; 430 } 431 else { 415 } else { 432 416 $a_lines[$n] = '> '.$a_lines[$n]; 433 417 } … … 438 422 // add title line 439 423 $prefix = sprintf( 440 "\n\n\nOn %s, %s wrote:\n",441 $_date,442 $_from424 "\n\n\nOn %s, %s wrote:\n", 425 $_date, 426 $_from 443 427 ); 444 428 … … 450 434 } 451 435 $suffix = ''; 452 } 453 else { 436 } else { 454 437 $_msg = "<br><br>On %s, %s wrote:<br><blockquote type=\"cite\" "; 455 438 $_msg.= "style=\"padding-left: 5px; border-left: #1010ff 2px solid; "; 456 439 $_msg.= "margin-left: 5px; width: 100%%\">"; 457 440 $prefix = sprintf( 458 $_msg,459 $_date,460 $_from441 $_msg, 442 $_date, 443 $_from 461 444 ); 462 445 $suffix = "</blockquote>"; … … 478 461 $_to = $MESSAGE['headers']->to; 479 462 463 $prefix = ''; 464 $suffix = ''; 480 465 if (! $bodyIsHtml) { 481 466 // soft-wrap message first 482 467 $body = wordwrap($body, 80); 483 468 484 $prefix = sprintf( 485 "\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 486 $_subject, 487 $_date, 488 $IMAP->decode_header($_from), 489 $IMAP->decode_header($_to) 490 ); 491 } 492 else { 493 $prefix = sprintf( 494 "<br><br>-------- Original Message --------" . 495 "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" . 496 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Subject: </th><td>%s</td></tr>" . 497 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Date: </th><td>%s</td></tr>" . 498 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">From: </th><td>%s</td></tr>" . 499 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">To: </th><td>%s</td></tr>" . 500 "</tbody></table><br>", 501 Q($_subject), 502 Q($_date), 503 Q($IMAP->decode_header($_from)), 504 Q($IMAP->decode_header($_to)) 505 ); 469 $prefix .= sprintf( 470 "\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 471 $_subject, 472 $_date, 473 $IMAP->decode_header($_from), 474 $IMAP->decode_header($_to)); 475 } else { 476 $prefix .= sprintf( 477 "<br><br>On %s, %s wrote:<br><blockquote type=\"cite\" " . 478 "style=\"padding-left: 5px; border-left: #1010ff 2px solid; " . 479 "margin-left: 5px; width: 100%%\">", 480 $MESSAGE['headers']->date, 481 $IMAP->decode_header($MESSAGE['headers']->from)); 482 $suffix .= "</blockquote>"; 506 483 } 507 484 … … 510 487 rcmail_write_compose_attachments($MESSAGE); 511 488 } 512 return $prefix.$body; 513 } 514 489 return $prefix.$body.$suffix; 490 } 515 491 516 492 function rcmail_create_draft_body($body, $bodyIsHtml) … … 530 506 return $body; 531 507 } 532 533 508 534 509 function rcmail_write_compose_attachments(&$message) -
branches/devel-vnext/program/steps/addressbook/copy.inc
r806 r962 27 27 $target = rcube::get_input_value('_to', rcube::INPUT_POST); 28 28 if ( 29 $cid 30 && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) 31 && strlen($target) 32 && $target != $source 29 $cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) 30 && strlen($target) && $target != $source 33 31 ) { 34 32 if ($target != '0') { 35 33 $TARGET = new rcube_ldap($CONFIG['ldap_public'][$target]); 36 } 37 else { 34 } else { 38 35 $TARGET = new rcube_contacts($DB, $_SESSION['user_id']); 39 36 } … … 46 43 if (empty($success)) { 47 44 $OUTPUT->show_message('copyerror', 'error'); 48 } 49 else { 45 } else { 50 46 $OUTPUT->show_message('copysuccess', 'notice', array('nr' => count($success))); 51 47 } 48 49 // close connection to second address directory 50 $TARGET->close(); 52 51 } 53 52 -
branches/devel-vnext/program/steps/addressbook/func.inc
r806 r962 37 37 ) { 38 38 $CONTACTS = new rcube_ldap($CONFIG['ldap_public'][$source]); 39 } 40 else { 39 } else { 41 40 /** 42 41 * @todo resolve conditional include (maybe autoload) 43 42 */ 44 if ( 45 isset($CONFIG['addressbook_plugin']) 46 && empty($CONFIG['addressbook_plugin']) === FALSE 47 ) { 43 if (isset($CONFIG['addressbook_plugin']) && !empty($CONFIG['addressbook_plugin'])) { 48 44 require_once 'plugins/addressbook/rcube_contacts_' . $CONFIG['addressbook_plugin'] . '.inc'; 49 45 $abook_class = 'rcube_contacts_' . $CONFIG['addressbook_plugin']; … … 63 59 // set list properties and session vars 64 60 if (!empty($_GET['_page'])) { 65 $CONTACTS->set_page(intval($_GET['_page'])); 66 $_SESSION['page'] = $_GET['_page']; 67 } 68 else { 61 $CONTACTS->set_page(($_SESSION['page'] = intval($_GET['_page']))); 62 } else { 69 63 $CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1); 70 64 } … … 75 69 $CONTACTS->set_search_set($_SESSION['search'][$_REQUEST['_search']]); 76 70 } 71 77 72 // set data source env 78 73 $OUTPUT->set_env('source', $source ? $source : '0'); … … 85 80 } 86 81 $OUTPUT->set_env('address_sources', $js_list); 87 88 82 89 83 function rcmail_directory_list($attrib) … … 155 149 } 156 150 157 158 151 /** 159 152 * return the message list as HTML table -
branches/devel-vnext/program/steps/addressbook/mailto.inc
r806 r962 16 16 +-----------------------------------------------------------------------+ 17 17 18 $Id: copy.inc 471 2007-02-09 21:25:50Z thomasb $18 $Id: mailto.inc 471 2007-02-09 21:25:50Z thomasb $ 19 19 20 20 */ … … 28 28 $mailto = array(); 29 29 30 if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && $CONTACTS->ready) { 30 if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) 31 && $CONTACTS->ready) { 31 32 $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid); 32 33 … … 38 39 if (!empty($mailto)) { 39 40 $mailto_str = join(', ', $mailto); 40 $mailto_id = substr(md5($mailto_str), 0, 16); 41 $mailto_id = substr(md5($mailto_str), 0, 16); 42 41 43 $_SESSION['mailto'][$mailto_id] = $mailto_str; 42 $OUTPUT->command('redirect', rcube::url('compose', array('_mailto' => $mailto_id), 'mail')); 43 } 44 else { 44 $OUTPUT->command('redirect', 45 rcube::url('compose', 46 array('_mailto' => $mailto_id), 47 'mail')); 48 } else { 45 49 $OUTPUT->show_message('nocontactsfound', 'warning'); 46 50 } -
branches/devel-vnext/program/steps/addressbook/save.inc
r806 r962 32 32 33 33 // check input 34 if ( 35 ( 36 !rcube::get_input_value('_name', rcube::INPUT_POST) 37 || !rcube::get_input_value('_email', rcube::INPUT_POST) 38 ) 39 && $_framed 40 ) { 34 if (( 35 !rcube::get_input_value('_name', rcube::INPUT_POST) 36 || !rcube::get_input_value('_email', rcube::INPUT_POST) 37 ) && $_framed) { 41 38 $OUTPUT->show_message('formincomplete', 'warning'); 42 39 rcube::override_action(empty($_POST['_cid']) ? 'add' : 'show'); … … 77 74 $OUTPUT->show_message('successfullysaved', 'confirmation'); 78 75 rcube::override_action('show'); 79 } 80 else { 76 } else { 81 77 // show error message 82 78 $OUTPUT->show_message('errorsaving', 'error'); 83 79 rcube::override_action('show'); 84 80 } 85 } 86 // insert a new contact 87 else { 81 } else { // insert a new contact 88 82 // check for existing contacts 89 $existing = $CONTACTS->search('email', $a_record['email'], false); 83 $existing = $CONTACTS->search('email', 84 $a_record['email'], 85 true, 86 false); 90 87 91 88 // show warning message … … 115 112 rcube::override_action('show'); 116 113 $_GET['_cid'] = $insert_id; 117 } 118 else { 114 } else { 119 115 // show error message 120 116 $OUTPUT->show_message('errorsaving', 'error'); … … 122 118 } 123 119 } 124 ?> -
branches/devel-vnext/program/steps/error.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
branches/devel-vnext/program/steps/mail/addcontact.inc
r806 r962 71 71 72 72 // check for existing contacts 73 $existing = $CONTACTS->search('email', $contact['email'], false);73 $existing = $CONTACTS->search('email', $contact['email'], true, false); 74 74 if ($done = $existing->count) { 75 75 $OUTPUT->show_message('contactexists', 'warning'); -
branches/devel-vnext/program/steps/mail/check_recent.inc
r806 r962 5 5 | | 6 6 | This file is part of the RoundCube Webmail client | 7 | Copyright (C) 2005-200 7, RoundCube Dev. - Switzerland |7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 8 8 | Licensed under the GNU GPL | 9 9 | | … … 32 32 if ($mbox_name == $IMAP->get_mailbox_name()) { 33 33 if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) { 34 35 $count = $IMAP->messagecount(NULL, 'ALL', TRUE); 34 35 // refresh saved search set 36 $search_request = rcube::get_input_value('_search', rcube::INPUT_GPC); 37 if ($search_request && $IMAP->search_set) { 38 $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 39 } 40 $count_all = $IMAP->messagecount(NULL, 'ALL', TRUE); 36 41 $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); 37 42 38 $OUTPUT->set_env('messagecount', $ count);39 $OUTPUT->command('set_unread_count', $mbox_name, $unread_count );43 $OUTPUT->set_env('messagecount', $IMAP->messagecount()); 44 $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, true); 40 45 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 41 46 $OUTPUT->command('set_quota', $IMAP->get_quota()); … … 43 48 // add new message headers to list 44 49 $a_headers = array(); 45 for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++) { 50 for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++) { 51 52 // skip message if it does not match the current search 53 if (!$IMAP->in_searchset($id)) { 54 continue; 55 } 56 46 57 $header = $IMAP->get_headers($id, NULL, FALSE); 47 58 if ($header->recent) { … … 51 62 rcmail_js_message_list($a_headers, TRUE); 52 63 } 53 } 54 else { 64 } else { 55 65 if ($IMAP->messagecount($mbox_name, 'RECENT')) { 56 66 $OUTPUT->command( … … 63 73 } 64 74 $OUTPUT->send(); 65 ?> -
branches/devel-vnext/program/steps/mail/compose.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 46 46 } 47 47 48 // this version does not support HTML mails 49 $CONFIG['htmleditor'] = false; 50 $CONFIG = $registry->set('CONFIG', $CONFIG, 'core'); 51 48 if ($_action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs)) { 49 $id = $regs[1]; 50 if (is_array($_SESSION['compose']['attachments'][$id])) { 51 $apath = $_SESSION['compose']['attachments'][$id]['path']; 52 header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']); 53 header('Content-Length: ' . filesize($apath)); 54 readfile($apath); 55 } 56 exit; 57 } 52 58 53 59 $MESSAGE_FORM = $registry->set('MESSAGE_FORM', NULL, 'core'); … … 117 123 $_SESSION['compose']['reply_uid'] = $msg_uid; 118 124 $_SESSION['compose']['reply_msgid'] = $MESSAGE['headers']->messageID; 119 $_SESSION['compose']['references'] = $MESSAGE['headers']->reference; 120 $_SESSION['compose']['references'] .= !empty($MESSAGE['headers']->reference) ? ' ' : ''; 121 $_SESSION['compose']['references'] .= $MESSAGE['headers']->messageID; 125 $_SESSION['compose']['references'] = trim($MESSAGE['headers']->references . " " . $MESSAGE['headers']->messageID); 122 126 123 127 if (!empty($_GET['_all'])) { … … 141 145 // register UI objects 142 146 $OUTPUT->add_handlers( 143 array( 144 'composeheaders' => 'rcmail_compose_headers', 145 'composesubject' => 'rcmail_compose_subject', 146 'composebody' => 'rcmail_compose_body', 147 'composeattachmentlist' => 'rcmail_compose_attachment_list', 148 'composeattachmentform' => 'rcmail_compose_attachment_form', 149 'composeattachment' => 'rcmail_compose_attachment_field', 150 'priorityselector' => 'rcmail_priority_selector', 151 'receiptcheckbox' => 'rcmail_receipt_checkbox', 152 ) 147 array( 148 'composeheaders' => 'rcmail_compose_headers', 149 'composesubject' => 'rcmail_compose_subject', 150 'composebody' => 'rcmail_compose_body', 151 'composeattachmentlist' => 'rcmail_compose_attachment_list', 152 'composeattachmentform' => 'rcmail_compose_attachment_form', 153 'composeattachment' => 'rcmail_compose_attachment_field', 154 'priorityselector' => 'rcmail_priority_selector', 155 'editorselector' => 'rcmail_editor_selector', 156 'receiptcheckbox' => 'rcmail_receipt_checkbox', 157 ) 153 158 ); 154 159 … … 160 165 $abook_class = 'rcube_contacts_' . $CONFIG['addressbook_plugin']; 161 166 $CONTACTS = new $abook_class ( 162 $_SESSION['username'],163 $_SESSION['password']167 $_SESSION['username'], 168 $_SESSION['password'] 164 169 ); 165 } 166 else { 170 } else { 167 171 $DB = $registry->get('DB', 'core'); 168 172 169 $CONTACTS = new rcube_contacts($DB, $ _SESSION['user_id']);173 $CONTACTS = new rcube_contacts($DB, $USER->ID); 170 174 $CONTACTS->set_pagesize(1000); 171 175 } -
branches/devel-vnext/program/steps/mail/folders.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 42 42 43 43 return; 44 } 45 else { 44 } else { 46 45 $commands = "// expunged: $success\n"; 47 46 } 48 } 49 // clear mailbox 50 elseif ($_action=='purge' && ($mbox = rcube::get_input_value('_mbox', rcube::INPUT_POST))) { 47 } elseif ($_action=='purge' && ($mbox = rcube::get_input_value('_mbox', rcube::INPUT_POST))) { 48 // clear mailbox 51 49 $success = $IMAP->clear_mailbox($mbox); 52 50 … … 57 55 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 58 56 $OUTPUT->command('set_unread_count', $mbox_name, 0); 59 } 60 else { 57 } else { 61 58 $commands = "// purged: $success"; 62 59 } -
branches/devel-vnext/program/steps/mail/func.inc
r806 r962 22 22 require_once 'lib/html2text.inc'; 23 23 require_once 'lib/enriched.inc'; 24 24 require_once 'include/rcube_smtp.inc'; 25 25 26 26 $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; … … 36 36 // set imap properties and session vars 37 37 if ($mbox = rcube::get_input_value('_mbox', rcube::INPUT_GPC)) { 38 $IMAP->set_mailbox($mbox); 39 $_SESSION['mbox'] = $mbox; 38 $IMAP->set_mailbox(($_SESSION['mbox'] = $mbox)); 40 39 } 41 40 42 41 if (!empty($_GET['_page'])) { 43 $IMAP->set_page((int)$_GET['_page']); 44 $_SESSION['page'] = (int)$_GET['_page']; 42 $IMAP->set_page(($_SESSION['page'] = intval($_GET['_page']))); 45 43 } 46 44 … … 57 55 } 58 56 // set message set for search result 59 if ( 60 !empty($_REQUEST['_search']) 61 && isset($_SESSION['search'][$_REQUEST['_search']]) 62 ) { 57 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) { 63 58 $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]); 64 59 } … … 90 85 } 91 86 if (!$OUTPUT->ajax_call) { 92 $OUTPUT->add_label('checkingmail'); 93 } 94 95 // return the mailboxlist in HTML 96 function rcmail_mailbox_list($attrib) 97 { 98 $registry = rcube_registry::get_instance(); 99 $IMAP = $registry->get('IMAP', 'core'); 100 $CONFIG = $registry->get_all('config'); 101 $OUTPUT = $registry->get('OUTPUT', 'core'); 102 $COMM_PATH = $registry->get('COMM_PATH', 'core'); 103 104 $s_added_script = $registry->get('s_added_script', 'core'); 105 if (is_null($s_added_script)) { 106 $s_added_script = FALSE; 107 $registry->get('s_added_script', $s_added_script); 108 } 109 $a_mailboxes = $registry->get('a_mailboxes', 'core'); 110 111 // add some labels to client 112 $OUTPUT->add_label('purgefolderconfirm'); 113 $OUTPUT->add_label('deletemessagesconfirm'); 114 115 // $mboxlist_start = rcube_timer(); 116 117 $type = $attrib['type'] ? $attrib['type'] : 'ul'; 118 $add_attrib = $type=='select' ? array('style', 'class', 'id', 'name', 'onchange') : 119 array('style', 'class', 'id'); 120 121 if ($type=='ul' && !$attrib['id']) { 122 $attrib['id'] = 'rcmboxlist'; 123 } 124 // allow the following attributes to be added to the <ul> tag 125 $attrib_str = rcube::create_attrib_string($attrib, $add_attrib); 126 127 $out = '<' . $type . $attrib_str . ">\n"; 128 129 // add no-selection option 130 if ($type=='select' && $attrib['noselection']) { 131 $out .= sprintf( 132 '<option value="0">%s</option>'."\n", 133 rcube::gettext($attrib['noselection']) 134 ); 135 } 136 // get mailbox list 137 $mbox_name = $IMAP->get_mailbox_name(); 138 139 // for these mailboxes we have localized labels 140 $special_mailboxes = array('inbox', 'sent', 'drafts', 'trash', 'junk'); 141 142 143 // build the folders tree 144 if (empty($a_mailboxes)) { 145 // get mailbox list 146 $a_folders = $IMAP->list_mailboxes(); 147 $delimiter = $IMAP->get_hierarchy_delimiter(); 148 $a_mailboxes = array(); 149 150 // rcube_print_time($mboxlist_start, 'list_mailboxes()'); 151 152 foreach ($a_folders as $folder) { 153 rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter); 154 } 155 } 156 157 //var_dump($a_mailboxes); 158 159 if ($type=='select') { 160 $out .= rcmail_render_folder_tree_select( 161 $a_mailboxes, 162 $special_mailboxes, 163 $mbox_name, 164 $attrib['maxlength'] 165 ); 166 } 167 else { 168 $out .= rcmail_render_folder_tree_html( 169 $a_mailboxes, 170 $special_mailboxes, 171 $mbox_name, 172 $attrib['maxlength'] 173 ); 174 } 175 $registry->set('a_mailboxes', $a_mailboxes); 176 // rcube_print_time($mboxlist_start, 'render_folder_tree()'); 177 178 179 if ($type=='ul') { 180 $OUTPUT->add_gui_object('mailboxlist', $attrib['id']); 181 } 182 return $out . "</$type>"; 183 } 184 185 186 187 188 // create a hierarchical array of the mailbox list 189 function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='') 190 { 191 $pos = strpos($folder, $delm); 192 if ($pos !== false) { 193 $subFolders = substr($folder, $pos+1); 194 $currentFolder = substr($folder, 0, $pos); 195 } 196 else { 197 $subFolders = false; 198 $currentFolder = $folder; 199 } 200 201 $path .= $currentFolder; 202 203 if (!isset($arrFolders[$currentFolder])) { 204 $arrFolders[$currentFolder] = array( 205 'id' => $path, 206 'name' => rcube::charset_convert($currentFolder, 'UTF-7'), 207 'folders' => array() 208 ); 209 } 210 211 if (!empty($subFolders)) { 212 rcmail_build_folder_tree( 213 $arrFolders[$currentFolder]['folders'], 214 $subFolders, 215 $delm, 216 $path.$delm 217 ); 218 } 219 } 220 221 222 /** 223 * return html for a structured list <ul> for the mailbox tree 224 */ 225 function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0) 226 { 227 $registry = rcube_registry::get_instance(); 228 $IMAP = $registry->get('IMAP', 'core'); 229 $CONFIG = $registry->get_all('config'); 230 $OUTPUT = $registry->get('OUTPUT', 'core'); 231 $COMM_PATH = $registry->get('COMM_PATH', 'core'); 232 233 $idx = 0; 234 $out = ''; 235 foreach ($arrFolders as $key => $folder) 236 { 237 $zebra_class = ($nestLevel*$idx)%2 ? 'even' : 'odd'; 238 $title = ''; 239 240 $folder_lc = strtolower($folder['id']); 241 if (in_array($folder_lc, $special)) 242 $foldername = rcube::gettext($folder_lc); 243 else { 244 $foldername = $folder['name']; 245 246 // shorten the folder name to a given length 247 if ($maxlength && $maxlength>1) { 248 $fname = abbrevate_string($foldername, $maxlength); 249 if ($fname != $foldername) 250 $title = ' title="'.Q($foldername).'"'; 251 $foldername = $fname; 252 } 253 } 254 255 // add unread message count display 256 if ($unread_count = $IMAP->messagecount($folder['id'], 'RECENT', ($folder['id']==$mbox_name))) 257 $foldername .= sprintf(' (%d)', $unread_count); 258 259 // make folder name safe for ids and class names 260 $folder_id = preg_replace('/[^A-Za-z0-9\-_]/', '', $folder['id']); 261 $class_name = preg_replace('/[^a-z0-9\-_]/', '', $folder_lc); 262 263 // set special class for Sent, Drafts, Trash and Junk 264 if ($folder['id']==$CONFIG['sent_mbox']) { 265 $class_name = 'sent'; 266 } 267 else if ($folder['id']==$CONFIG['drafts_mbox']) { 268 $class_name = 'drafts'; 269 } 270 else if ($folder['id']==$CONFIG['trash_mbox']) { 271 $class_name = 'trash'; 272 } 273 else if ($folder['id']==$CONFIG['junk_mbox']) { 274 $class_name = 'junk'; 275 } 276 277 $js_name = htmlspecialchars(JQ($folder['id'])); 278 279 $_string_out = '<li id="rcmli%s" class="mailbox %s %s%s%s"><a href="%s"'; 280 $_string_out.= ' onclick="return %s.command(\'list\',\'%s\',this)"'; 281 $_string_out.= ' onmouseover="return %s.focus_folder(\'%s\')"'; 282 $_string_out.= ' onmouseout="return %s.unfocus_folder(\'%s\')"'; 283 $_string_out.= ' onmouseup="return %s.folder_mouse_up(\'%s\')"%s>%s</a>'; 284 285 $out .= sprintf( 286 $_string_out, 287 $folder_id, 288 $class_name, 289 $zebra_class, 290 $unread_count ? ' unread' : '', 291 $folder['id']==$mbox_name ? ' selected' : '', 292 Q(rcube::url('', array('_mbox' => $folder['id']))), 293 JS_OBJECT_NAME, 294 $js_name, 295 JS_OBJECT_NAME, 296 $js_name, 297 JS_OBJECT_NAME, 298 $js_name, 299 JS_OBJECT_NAME, 300 $js_name, 301 $title, 302 Q($foldername) 303 ); 304 /** 305 * Close <li> Element. 306 */ 307 $out .= "</li>\n"; 308 309 /** 310 * Append a new list if it has subfolders. 311 * 312 * Work with a seperate list-entry (<li>) to combat giant 313 * onmouseover fuckups. 314 * 315 * @ignore 316 */ 317 if (!empty($folder['folders'])) { 318 $out .= '<li class="mailboxsub">' . "\n<ul>\n"; 319 $out .= rcmail_render_folder_tree_html($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1); 320 $out .= "</ul>\n"; 321 $out .= '</li>' . "\n"; 322 } 323 324 $idx++; 325 } 326 327 return $out; 328 } 329 330 331 // return html for a flat list <select> for the mailbox tree 332 function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0) 333 { 334 $registry = rcube_registry::get_instance(); 335 $IMAP = $registry->get('IMAP', 'core'); 336 $OUTPUT = $registry->get('OUTPUT', 'core'); 337 338 $idx = 0; 339 $out = ''; 340 foreach ($arrFolders as $key=>$folder) { 341 $folder_lc = strtolower($folder['id']); 342 if (in_array($folder_lc, $special)) 343 $foldername = rcube::gettext($folder_lc); 344 else { 345 $foldername = $folder['name']; 346 347 // shorten the folder name to a given length 348 if ($maxlength && $maxlength>1) 349 $foldername = abbrevate_string($foldername, $maxlength); 350 } 351 352 $out .= sprintf( 353 '<option value="%s">%s%s</option>'."\n", 354 htmlspecialchars($folder['id']), 355 str_repeat(' ', $nestLevel*4), 356 Q($foldername)); 357 358 if (!empty($folder['folders'])) 359 $out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1); 360 361 $idx++; 362 } 363 364 return $out; 365 } 366 87 $OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash'); 88 } 89 90 // set page title 91 if (empty($_action) || $_action == 'list') { 92 $OUTPUT->set_pagetitle( 93 rcube::charset_convert($IMAP->get_mailbox_name(), 'UTF-7')); 94 } 367 95 368 96 /** … … 404 132 // allow the following attributes to be added to the <table> tag 405 133 $attrib_str = rcube::create_attrib_string( 406 $attrib,407 array(408 'style', 'class', 'id',409 'cellpadding', 'cellspacing',410 'border', 'summary'411 )134 $attrib, 135 array( 136 'style', 'class', 'id', 137 'cellpadding', 'cellspacing', 138 'border', 'summary' 139 ) 412 140 ); 413 141 … … 422 150 423 151 // show 'to' instead of from in sent messages 424 if ( 425 ($mbox==$CONFIG['sent_mbox'] || $mbox==$CONFIG['drafts_mbox']) 152 if (($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox']) 426 153 && ($f = array_search('from', $a_show_cols)) 427 154 && !array_search('to', $a_show_cols) … … 454 181 if ($IMAP->get_capability('sort') && in_array($col, $a_sort_cols)) { 455 182 // have buttons configured 456 if ( 457 !empty($attrib['sortdescbutton']) 458 || !empty($attrib['sortascbutton']) 459 ) { 183 if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton'])) { 460 184 $sort = ' '; 461 185 … … 463 187 if (!empty($attrib['sortascbutton'])) { 464 188 $sort .= $OUTPUT->button( 465 array( 466 'command' => 'sort', 467 'prop' => $col.'_ASC', 468 'image' => $attrib['sortascbutton'], 469 'align' => 'absmiddle', 470 'title' => 'sortasc' 471 ) 472 ); 189 array( 190 'command' => 'sort', 191 'prop' => $col.'_ASC', 192 'image' => $attrib['sortascbutton'], 193 'align' => 'absmiddle', 194 'title' => 'sortasc')); 473 195 } 474 196 … … 476 198 if (!empty($attrib['sortdescbutton'])) { 477 199 $sort .= $OUTPUT->button(array( 478 'command' => 'sort',479 'prop' => $col.'_DESC',480 'image' => $attrib['sortdescbutton'],481 'align' => 'absmiddle',482 'title' => 'sortdesc'));200 'command' => 'sort', 201 'prop' => $col.'_DESC', 202 'image' => $attrib['sortdescbutton'], 203 'align' => 'absmiddle', 204 'title' => 'sortdesc')); 483 205 } 484 } 485 // just add a link tag to the header 486 else { 206 } else { // just add a link tag to the header 487 207 $col_name = sprintf( 488 '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>',489 JS_OBJECT_NAME,490 $col,491 rcube::gettext('sortby'),492 $col_name208 '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>', 209 JS_OBJECT_NAME, 210 $col, 211 rcube::gettext('sortby'), 212 $col_name 493 213 ); 494 214 } … … 507 227 508 228 // no messages in this mailbox 509 if (!sizeof($a_headers)) { 510 $out .= sprintf( 511 '<tr><td colspan="%d">%s</td></tr>', 512 sizeof($a_show_cols)+2, 513 Q(rcube::gettext('nomessagesfound'))); 514 } 515 229 if (count($a_headers) == 0) { 230 $OUTPUT->show_message('nomessagesfound', 'notice'); 231 } 516 232 517 233 $a_js_message_arr = array(); … … 733 449 734 450 // loop through message headers 735 for ($n=0; $a_headers[$n]; $n++) {736 $header = $a_headers[$n]; 451 foreach ($a_headers as $n => $header) { 452 737 453 $a_msg_cols = array(); 738 454 $a_msg_flags = array(); 455 456 if (empty($header)) { 457 continue; 458 } 739 459 740 460 // format each col; similar as in rcmail_message_list() … … 742 462 if ($col=='from' || $col=='to') { 743 463 $cont = Q(rcmail_address_string($header->$col, 3), 'show'); 744 } 745 elseif ($col=='subject') { 464 } elseif ($col == 'subject') { 746 465 $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; 747 466 $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draf_uid' : '_uid'; … … 751 470 } 752 471 $cont = sprintf( 753 '<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>',754 Q(rcube::url(755 $action,756 array($uid_param=>$header->uid, '_mbox'=>$mbox)757 )),758 $cont472 '<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', 473 Q(rcube::url( 474 $action, 475 array($uid_param=>$header->uid, '_mbox'=>$mbox) 476 )), 477 $cont 759 478 ); 760 } 761 elseif ($col=='size') { 479 } elseif ($col=='size') { 762 480 $cont = show_bytes($header->$col); 763 } 764 elseif ($col=='date') { 481 } elseif ($col=='date') { 765 482 $cont = rcube::format_date($header->date); 766 } 767 else { 483 } else { 768 484 $cont = Q($header->$col); 769 485 } … … 775 491 $a_msg_flags['replied'] = $header->answered ? 1 : 0; 776 492 $OUTPUT->command( 777 'add_message_row',778 $header->uid,779 $a_msg_cols,780 $a_msg_flags,781 preg_match("/multipart\/m/i", $header->ctype),782 $insert_top493 'add_message_row', 494 $header->uid, 495 $a_msg_cols, 496 $a_msg_flags, 497 preg_match("/multipart\/m/i", $header->ctype), 498 $insert_top 783 499 ); 784 500 } 785 501 } 786 787 502 788 503 // return an HTML iframe for loading mail content … … 792 507 $OUTPUT = $registry->get('OUTPUT', 'core'); 793 508 794 if (empty($attrib['id'])) 509 if (empty($attrib['id'])) { 795 510 $attrib['id'] = 'rcmailcontentwindow'; 796 511 } 512 797 513 // allow the following attributes to be added to the <iframe> tag 798 514 $attrib_str = rcube::create_attrib_string( 799 $attrib,800 array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder')515 $attrib, 516 array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder') 801 517 ); 802 518 $framename = $attrib['id']; 803 519 804 520 $out = sprintf( 805 '<iframe name="%s"%s></iframe>'."\n",806 $framename,807 $attrib_str521 '<iframe name="%s"%s></iframe>'."\n", 522 $framename, 523 $attrib_str 808 524 ); 809 525 … … 821 537 $OUTPUT = $registry->get('OUTPUT', 'core'); 822 538 823 if (!$attrib['id']) 539 if (!$attrib['id']) { 824 540 $attrib['id'] = 'rcmcountdisplay'; 825 541 } 542 826 543 $OUTPUT->add_gui_object('countdisplay', $attrib['id']); 827 544 828 545 // allow the following attributes to be added to the <span> tag 829 546 $attrib_str = rcube::create_attrib_string($attrib, array('style', 'class', 'id')); 830 831 547 832 548 $out = '<span' . $attrib_str . '>'; … … 843 559 $OUTPUT = $registry->get('OUTPUT', 'core'); 844 560 845 if (!$attrib['id']) 561 if (!$attrib['id']) { 846 562 $attrib['id'] = 'rcmquotadisplay'; 847 563 } 564 848 565 $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); 849 566 … … 857 574 } 858 575 859 860 576 function rcmail_quota_content($display) 861 577 { … … 866 582 if (!$IMAP->get_capability('QUOTA')) { 867 583 $quota_text = rcube::gettext('unknown'); 868 } 869 elseif ($quota = $IMAP->get_quota()) { 584 } elseif ($quota = $IMAP->get_quota()) { 870 585 $quota_text = sprintf( 871 "%s / %s (%.0f%%)",872 show_bytes($quota["used"] * 1024),873 show_bytes($quota["total"] * 1024),874 $quota["percent"]586 "%s / %s (%.0f%%)", 587 show_bytes($quota["used"] * 1024), 588 show_bytes($quota["total"] * 1024), 589 $quota["percent"] 875 590 ); 876 591 … … 879 594 $attrib = array('width' => 100, 'height' => 14); 880 595 $quota_text = sprintf( 881 '<img src="./bin/quotaimg.php?u=%s&q=%d&w=%d&h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', 882 $quota['used'], $quota['total'], 883 $attrib['width'], $attrib['height'], 884 $attrib['width'], $attrib['height'], 885 $quota_text, 886 show_bytes($quota["used"] * 1024), 887 show_bytes($quota["total"] * 1024)); 888 } 889 } 890 else { 596 '<img src="./bin/quotaimg.php?u=%s&q=%d&w=%d&h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', 597 $quota['used'], $quota['total'], 598 $attrib['width'], $attrib['height'], 599 $attrib['width'], $attrib['height'], 600 $quota_text, 601 show_bytes($quota["used"] * 1024), 602 show_bytes($quota["total"] * 1024)); 603 } 604 } else { 891 605 $quota_text = rcube::gettext('unlimited'); 892 606 } 893 607 return $quota_text; 894 608 } 895 896 609 897 610 function rcmail_get_messagecount_text($count=NULL, $page=NULL) … … 903 616 if (isset($MESSAGE['index'])) { 904 617 return rcube::gettext( 905 array(906 'name' => 'messagenrof',907 'vars' => array(908 'nr' => $MESSAGE['index']+1,909 'count' => $count!==NULL ? $count : $IMAP->messagecount()910 )911 )618 array( 619 'name' => 'messagenrof', 620 'vars' => array( 621 'nr' => $MESSAGE['index']+1, 622 'count' => $count!==NULL ? $count : $IMAP->messagecount() 623 ) 624 ) 912 625 ); 913 626 } 914 627 915 if ($page ===NULL) {628 if ($page === NULL) { 916 629 $page = $IMAP->list_page; 917 630 } 918 631 $start_msg = ($page-1) * $IMAP->page_size + 1; 919 $max = $count!==NULL ? $count : $IMAP->messagecount();632 $max = $count!==NULL ? $count : $IMAP->messagecount(); 920 633 921 634 if ($max==0) { 922 635 $out = rcube::gettext('mailboxempty'); 923 } 924 else { 636 } else { 925 637 $out = rcube::gettext(array('name' => 'messagesfromto', 926 'vars' => array('from' => $start_msg,927 'to' => min($max, $start_msg + $IMAP->page_size - 1),928 'count' => $max)));638 'vars' => array('from' => $start_msg, 639 'to' => min($max, $start_msg + $IMAP->page_size - 1), 640 'count' => $max))); 929 641 } 930 642 return Q($out); 931 643 } 932 933 644 934 645 function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) … … 957 668 // remove remote images and scripts 958 669 $remote_patterns = array( 959 '/<img\s+(.*)src=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui',960 '/(src|background)=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui',961 '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i',962 '/(<link.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i',963 '/url\s*\(["\']?([hftps]{3,5}:\/{2}[^"\'\s]+)["\']?\)/i',964 '/url\s*\(["\']?([\.\/]+[^"\'\s]+)["\']?\)/i',965 '/<script.+<\/script>/Umis'670 '/<img\s+(.*)src=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui', 671 '/(src|background)=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui', 672 '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i', 673 '/(<link.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i', 674 '/url\s*\(["\']?([hftps]{3,5}:\/{2}[^"\'\s]+)["\']?\)/i', 675 '/url\s*\(["\']?([\.\/]+[^"\'\s]+)["\']?\)/i', 676 '/<script.+<\/script>/Umis' 966 677 ); 967 678 968 679 $remote_replaces = array( 969 '<img \\1src=\\2./program/blocked.gif\\4',970 '',971 '',972 '',973 'none',974 'none',975 '');680 '<img \\1src=\\2./program/blocked.gif\\4', 681 '', 682 '', 683 '', 684 'none', 685 'none', 686 ''); 976 687 977 688 // set flag if message containes remote obejcts that where blocked … … 980 691 $REMOTE_OBJECTS = TRUE; 981 692 $registry->set( 982 'REMOTE_OBJECTS',983 $REMOTE_OBJECTS,984 'core'693 'REMOTE_OBJECTS', 694 $REMOTE_OBJECTS, 695 'core' 985 696 ); 986 697 break; … … 1014 725 if ($part->ctype_parameters['format'] != 'flowed') { 1015 726 $body = wordwrap(trim($body), 80); 1016 } 1017 else { 727 } else { 1018 728 /** 1019 729 * @author Till Klampaeckel <till@php.net> … … 1055 765 // insert the links for urls and mailtos 1056 766 $body = preg_replace( 1057 "/##string_replacement\{([0-9]+)\}##/e",1058 "\$replace_strings[\\1]",1059 join("\n", $a_lines)767 "/##string_replacement\{([0-9]+)\}##/e", 768 "\$replace_strings[\\1]", 769 join("\n", $a_lines) 1060 770 ); 1061 771 return '<div class="pre">' . $body . "\n</div>"; … … 1123 833 $structure->type = 'content'; 1124 834 $a_return_parts[] = &$structure; 1125 } 1126 1127 // message contains alternative parts 1128 else if ( 835 } else if ( // message contains alternative parts 1129 836 $message_ctype_primary=='multipart' 1130 837 && $message_ctype_secondary=='alternative' … … 1135 842 1136 843 foreach ($structure->parts as $p => $sub_part) { 1137 $sub_ctype_primary = strtolower($sub_part->ctype_primary); 844 $rel_parts = $attachmnts = null; 845 $sub_ctype_primary = strtolower($sub_part->ctype_primary); 1138 846 $sub_ctype_secondary = strtolower($sub_part->ctype_secondary); 1139 847 1140 848 // check if sub part is 1141 if ($sub_ctype_primary =='text' && $sub_ctype_secondary=='plain')849 if ($sub_ctype_primary == 'text' && $sub_ctype_secondary=='plain') { 1142 850 $plain_part = $p; 1143 else if ($sub_ctype_primary=='text' && $sub_ctype_secondary=='html')851 } else if ($sub_ctype_primary=='text' && $sub_ctype_secondary=='html') { 1144 852 $html_part = $p; 1145 else if ($sub_ctype_primary=='text' && $sub_ctype_secondary=='enriched')853 } else if ($sub_ctype_primary=='text' && $sub_ctype_secondary=='enriched') { 1146 854 $enriched_part = $p; 1147 else if ($sub_ctype_primary=='multipart' && $sub_ctype_secondary=='related')855 } else if ($sub_ctype_primary=='multipart' && ($sub_ctype_secondary=='related' || $sub_ctype_secondary=='mixed')) { 1148 856 $related_part = $p; 857 } 1149 858 } 1150 859 1151 860 // parse related part (alternative part could be in here) 1152 if (is_null($related_part) === FALSE && $prefer_html) { 1153 list($parts, $attachmnts) = rcmail_parse_message($structure->parts[$related_part], $arg, TRUE); 1154 $a_return_parts = array_merge($a_return_parts, $parts); 861 if ($related_part !== NULL) { 862 list($rel_parts, $attachmnts) = rcmail_parse_message($structure->parts[$related_part], $arg, TRUE); 1155 863 $a_attachments = array_merge($a_attachments, $attachmnts); 1156 } 1157 // print html/plain part 1158 else if (is_null($html_part) !== TRUE && $prefer_html) { 864 } 865 866 // merge related parts if any 867 if ($rel_parts && $prefer_html && !$html_part) { 868 $a_return_parts = array_merge($a_return_parts, $rel_parts); 869 } else if ($html_part !== null && $prefer_html) { 870 // choose html/plain part to print 1159 871 $print_part = &$structure->parts[$html_part]; 1160 } 1161 else if (is_null($enriched_part) !== TRUE) { 872 } else if ($enriched_part !== null) { 1162 873 $print_part = &$structure->parts[$enriched_part]; 1163 } 1164 else if (is_null($plain_part) !== TRUE) { 874 } else if ($plain_part !== null) { 1165 875 $print_part = &$structure->parts[$plain_part]; 1166 876 } 877 1167 878 // show message body 1168 879 if (is_object($print_part)) { 880 1169 881 $print_part->type = 'content'; 1170 882 $a_return_parts[] = $print_part; 1171 } 1172 // show plaintext warning 1173 else if ($html_part!==NULL) { 883 884 } else if ($html_part!== NULL && $prefer_html) { 885 886 // show plaintext warning 1174 887 $c = new stdClass; 1175 888 $c->type = 'content'; … … 1206 919 // part text/[plain|html] OR message/delivery-status 1207 920 else if ( 1208 ( 1209 $primary_type=='text' 1210 && ($secondary_type=='plain' || $secondary_type=='html') 1211 && $mail_part->disposition!='attachment' 1212 ) 921 ($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html') 922 && $mail_part->disposition!='attachment') 1213 923 || 1214 ($primary_type=='message' && $secondary_type=='delivery-status') 924 ($primary_type=='message' 925 && ($secondary_type=='delivery-status' || $secondary_type=='disposition-notification')) 1215 926 ) { 1216 927 $mail_part->type = 'content'; … … 1248 959 ); 1249 960 $sa_inline_objects[] = $mail_part; 1250 } 1251 // is regular attachment 1252 else { 961 } else { 962 // is regular attachment 1253 963 if (!$mail_part->filename) { 1254 $mail_part->filename = ' file_' . $mail_part->mime_id;964 $mail_part->filename = 'Part ' . $mail_part->mime_id; 1255 965 } 1256 966 $a_attachments[] = $mail_part; … … 1260 970 1261 971 // if this was a related part try to resolve references 1262 if ($message_ctype_secondary=='related' && sizeof($sa_inline_objects)) {972 if ($message_ctype_secondary=='related' && count($sa_inline_objects) > 0) { 1263 973 $a_replaces = array(); 1264 974 1265 975 foreach ($sa_inline_objects as $inline_object) { 1266 976 $a_replaces['cid:'.$inline_object->content_id] = htmlspecialchars( 1267 sprintf( 1268 $get_url, 1269 $inline_object->mime_id 1270 ) 1271 ); 977 sprintf( 978 $get_url, 979 $inline_object->mime_id 980 )); 1272 981 } 1273 982 // add replace array to each content part … … 1338 1047 if ($hkey=='date' && empty($headers[$hkey]) === false) { 1339 1048 $header_value = rcube::format_date(strtotime($headers[$hkey])); 1340 } 1341 elseif(in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to'))) { 1049 } elseif(in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to'))) { 1050 $header_value = Q(rcmail_address_string( 1051 $headers[$hkey], 1052 NULL, 1053 $attrib['addicon'] 1054 ), 'show'); 1055 } else { 1342 1056 $header_value = Q( 1343 rcmail_address_string( 1344 $headers[$hkey], 1345 NULL, 1346 $attrib['addicon'] 1347 ), 1348 'show' 1349 ); 1350 } 1351 else { 1352 $header_value = Q( 1353 rcube_imap::decode_mime_string( 1354 $headers[$hkey], 1355 $headers['charset'] 1356 ) 1057 rcube_imap::decode_mime_string( 1058 $headers[$hkey], 1059 $headers['charset'] 1060 ) 1357 1061 ); 1358 1062 } … … 1395 1099 $attrib['id'] = 'rcmailMsgBody'; 1396 1100 } 1397 $safe_mode = (bool)$_GET['_safe'];1101 $safe_mode = intval($_GET['_safe']); 1398 1102 $attrib_str = rcube::create_attrib_string($attrib, array('style', 'class', 'id')); 1399 $out = '<div '. $attrib_str . ">\n";1103 $out = '<div '. $attrib_str . ">\n"; 1400 1104 1401 1105 $header_attrib = array(); … … 1408 1112 // this is an ecrypted message 1409 1113 // -> create a plaintext body with the according message 1410 if ( !sizeof($MESSAGE['parts'])&& $MESSAGE['headers']->ctype=='multipart/encrypted') {1114 if (count($MESSAGE['parts']) == 0 && $MESSAGE['headers']->ctype=='multipart/encrypted') { 1411 1115 $p = new stdClass; 1412 1116 $p->type = 'content'; … … 1445 1149 } 1446 1150 } 1447 } 1448 else { 1151 } else { 1449 1152 $out .= $MESSAGE['body']; 1450 1153 } … … 1454 1157 1455 1158 // list images after mail body 1456 if ( 1457 get_boolean($attrib['showimages']) 1159 if (get_boolean($attrib['showimages']) 1458 1160 && $ctype_primary=='multipart' 1459 && $ctype_secondary=='mixed' 1460 && sizeof($MESSAGE['attachments']) 1161 && !empty($MESSAGE['attachments']) 1461 1162 && !strstr($message_body, '<html') 1462 && strlen($GET_URL) 1463 ) { 1163 && strlen($GET_URL)) { 1464 1164 foreach ($MESSAGE['attachments'] as $attach_prop) { 1465 1165 if (strpos($attach_prop->mimetype, 'image/')===0) { … … 1492 1192 $body = preg_replace('/\x00/', '', $body); 1493 1193 1194 $base_url = ''; 1494 1195 $last_style_pos = 0; 1495 $body_lc = strtolower($body); 1196 $body_lc = strtolower($body); 1197 1198 // check for <base href> 1199 $base_reg = '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i'; 1200 if (preg_match($base_reg, $body, $base_regs)) { 1201 $base_url = $base_regs[2]; 1202 } 1496 1203 1497 1204 // find STYLE tags … … 1501 1208 1502 1209 // replace all css definitions with #container [def] 1503 $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id); 1210 $styles = rcmail_mod_css_styles( 1211 substr($body, $pos, $pos2-$pos), 1212 $container_id, 1213 $base_url); 1504 1214 1505 1215 $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); … … 1511 1221 // remove SCRIPT tags 1512 1222 foreach (array('script', 'applet', 'object', 'embed', 'iframe') as $tag) { 1513 while (($pos = strpos($body_lc, '<'.$tag)) && ( $pos2 = strpos($body_lc, '</'.$tag.'>', $pos)))1223 while (($pos = strpos($body_lc, '<'.$tag)) && (($pos2 = strpos($body_lc, '</'.$tag.'>', $pos)) || ($pos3 = strpos($body_lc, '>', $pos)))) 1514 1224 { 1515 $pos2 += strlen('</'.$tag.'>'); 1516 $body = substr($body, 0, $pos) . substr($body, $pos2, strlen($body)-$pos2); 1225 $end = $pos2 ? $pos2 + strlen('</'.$tag.'>') : $pos3 + 1; 1226 $body = substr($body, 0, $pos) . substr($body, $end, strlen($body)-$end); 1227 1517 1228 $body_lc = strtolower($body); 1518 1229 } … … 1527 1238 1528 1239 // resolve <base href> 1529 $base_reg = '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i'; 1530 if (preg_match($base_reg, $body, $regs)) { 1531 $base_url = $regs[2]; 1240 if ($base_url) { 1532 1241 $body = preg_replace('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Uie', "'\\1=\"'.make_absolute_url('\\3', '$base_url').'\"'", $body); 1533 1242 $body = preg_replace('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Uie', "'\\1\''.make_absolute_url('\\3', '$base_url').'\')'", $body); … … 1536 1245 1537 1246 // modify HTML links to open a new window if clicked 1538 $body = preg_replace('/<a\s+([^>]+)>/Uie', "rcmail_alter_html_link('\\1');", $body); 1247 $body = preg_replace('/<(a|link)\s+([^>]+)>/Uie', 1248 "rcmail_alter_html_link('\\1','\\2','$container_id');", 1249 $body); 1539 1250 1540 1251 // add comments arround html and other tags … … 1550 1261 1551 1262 $out = preg_replace( 1552 array( 1553 '/<body([^>]*)>/i', 1554 '/<\/body>/i' 1555 ), 1556 array( 1557 '<div class="rcmBody"\\1>', 1558 '</div>' 1559 ), 1560 $out 1561 ); 1263 array('/<body([^>]*)>/i','/<\/body>/i'), 1264 array('<div class="rcmBody"\\1>','</div>'), 1265 $out); 1562 1266 1563 1267 // quote <? of php and xml files that are specified as text/html … … 1567 1271 } 1568 1272 1569 1570 1273 // parse link attributes and set correct target 1571 function rcmail_alter_html_link($in) 1572 { 1573 $in = preg_replace('/=([^("|\'|\s)]+)(\s|$)/', '="\1"', $in); 1574 $attrib = rcube::parse_attrib_string($in); 1575 1576 if (stristr((string)$attrib['href'], 'mailto:')) { 1274 function rcmail_alter_html_link($tag, $attrs, $container_id) 1275 { 1276 //$in = preg_replace('/=([^("|\'|\s)]+)(\s|$)/', '="\1"', $in); 1277 $attrib = rcube::parse_attrib_string($attrs); 1278 1279 if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) { 1280 $attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']); 1281 $attrib['href'] .= "&c=" . urlencode($container_id); 1282 } else if (stristr((string)$attrib['href'], 'mailto:')) { 1577 1283 $attrib['onclick'] = sprintf( 1578 "return %s.command('compose','%s',this)", 1579 JS_OBJECT_NAME, 1580 JQ(substr($attrib['href'], 7)) 1581 ); 1582 } 1583 else if (!empty($attrib['href']) && $attrib['href']{0}!='#') { 1284 "return %s.command('compose','%s',this)", 1285 JS_OBJECT_NAME, 1286 JQ(substr($attrib['href'], 7))); 1287 } else if (!empty($attrib['href']) && $attrib['href']{0}!='#') { 1584 1288 $attrib['target'] = '_blank'; 1585 1289 } 1586 $resp = '<a'; 1587 $resp.= rcube::create_attrib_string( 1588 $attrib, 1589 array( 1590 'href', 'name', 'target', 'onclick', 'id', 'class', 'style', 'title' 1591 ) 1592 ); 1593 $resp .= '>'; 1594 return $resp; 1595 } 1596 1597 1598 // replace all css definitions with #container [def] 1599 function rcmail_mod_css_styles($source, $container_id) 1600 { 1601 $a_css_values = array(); 1602 $last_pos = 0; 1603 1604 // cut out all contents between { and } 1605 while (($pos = strpos($source, '{', $last_pos)) && ($pos2 = strpos($source, '}', $pos))) 1606 { 1607 $key = sizeof($a_css_values); 1608 $a_css_values[$key] = substr($source, $pos+1, $pos2-($pos+1)); 1609 $source = substr($source, 0, $pos+1); 1610 $source.= "<<str_replacement[$key]>>"; 1611 $source.= substr($source, $pos2, strlen($source)-$pos2); 1612 $last_pos = $pos+2; 1613 } 1614 1615 // remove html commends and add #container to each tag selector. 1616 // also replace body definition because we also stripped off the <body> tag 1617 $styles = preg_replace( 1618 array( 1619 '/(^\s*<!--)|(-->\s*$)/', 1620 '/(^\s*|,\s*|\}\s*)([a-z0-9\._][a-z0-9\.\-_]*)/im', 1621 '/<<str_replacement\[([0-9]+)\]>>/e', 1622 "/$container_id\s+body/i" 1623 ), 1624 array( 1625 '', 1626 "\\1#$container_id \\2", 1627 "\$a_css_values[\\1]", 1628 "$container_id div.rcmBody" 1629 ), 1630 $source 1631 ); 1632 return $styles; 1633 } 1634 1290 1291 $ret = "<$tag" . rcube::create_attrib_string($attrib, 1292 array('href','name','target','onclick','id','class', 1293 'style','title','rel','type','media')); 1294 $ret .= ' />'; 1295 return $ret; 1296 } 1635 1297 1636 1298 function rcmail_has_html_part($message_parts) … … 1640 1302 } 1641 1303 // check all message parts 1642 foreach ($message_parts as $pid => $part) 1643 { 1304 foreach ($message_parts as $pid => $part) { 1644 1305 $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary); 1645 if ($mimetype=='text/html') 1646 { 1306 if ($mimetype == 'text/html') { 1647 1307 return TRUE; 1648 1308 } 1649 1309 } 1650 1651 1310 return FALSE; 1652 1311 } … … 1697 1356 if ($mimetype=='text/plain') { 1698 1357 return $IMAP->get_message_part($message_struct['UID'], $pid, $part); 1699 } 1700 else if ($mimetype=='text/html') { 1358 } else if ($mimetype=='text/html') { 1701 1359 $html_part = $IMAP->get_message_part($message_struct['UID'], $pid, $part); 1702 1360 … … 1712 1370 return FALSE; 1713 1371 } 1714 1715 1372 1716 1373 // decode address string and re-format it as HTML links … … 1738 1395 if ($PRINT_MODE) { 1739 1396 $out .= sprintf('%s <%s>', Q($part['name']), $part['mailto']); 1740 } 1741 elseif (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { 1397 } elseif (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { 1742 1398 $out .= sprintf( 1743 '<a href="mailto:%s" onclick="return %s.command(\'compose\',\'%s\',this)" class="rcmContactAddress" title="%s">%s</a>',1744 Q($part['mailto']),1745 JS_OBJECT_NAME,1746 JQ($part['mailto']),1747 Q($part['mailto']),1748 Q($part['name']));1399 '<a href="mailto:%s" onclick="return %s.command(\'compose\',\'%s\',this)" class="rcmContactAddress" title="%s">%s</a>', 1400 Q($part['mailto']), 1401 JS_OBJECT_NAME, 1402 JQ($part['mailto']), 1403 Q($part['mailto']), 1404 Q($part['name'])); 1749 1405 if ($addicon) { 1750 1406 $out .= sprintf( 1751 ' <a href="#add" onclick="return %s.command(\'add-contact\',\'%s\',this)" title="%s"><img src="%s%s" alt="add" border="0" /></a>',1752 JS_OBJECT_NAME,1753 urlencode($part['string']),1754 rcube::gettext('addtoaddressbook'),1755 $CONFIG['skin_path'],1756 $addicon1407 ' <a href="#add" onclick="return %s.command(\'add-contact\',\'%s\',this)" title="%s"><img src="%s%s" alt="add" border="0" /></a>', 1408 JS_OBJECT_NAME, 1409 urlencode($part['string']), 1410 rcube::gettext('addtoaddressbook'), 1411 $CONFIG['skin_path'], 1412 $addicon 1757 1413 ); 1758 1414 } 1759 } 1760 else { 1415 } else { 1761 1416 if ($part['name']) { 1762 1417 $out .= Q($part['name']); … … 1778 1433 return $out; 1779 1434 } 1780 1781 1435 1782 1436 function rcmail_message_part_controls() … … 1787 1441 $MESSAGE = $registry->get('MESSAGE', 'core'); 1788 1442 1789 if ( 1790 !is_array($MESSAGE) 1791 || !is_array($MESSAGE['parts']) 1443 $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC)); 1444 if (!is_array($MESSAGE) || !is_array($MESSAGE['parts']) 1792 1445 || !($_GET['_uid'] && $_GET['_part']) 1793 || !$MESSAGE['parts'][$_GET['_part']] 1794 ) { 1446 || !$MESSAGE['parts'][$part]) { 1795 1447 return ''; 1796 1448 } 1797 $part = &$MESSAGE['parts'][$_GET['_part']]; 1449 1450 $part = &$MESSAGE['parts'][$part]; 1798 1451 1799 1452 $attrib_str = rcube::create_attrib_string( 1800 $attrib, 1801 array( 1802 'id', 1803 'class', 1804 'style', 1805 'cellspacing', 1806 'cellpadding', 1807 'border', 1808 'summary' 1809 ) 1810 ); 1453 $attrib, 1454 array( 1455 'id', 1456 'class', 1457 'style', 1458 'cellspacing', 1459 'cellpadding', 1460 'border', 1461 'summary' 1462 )); 1811 1463 $out = '<table '. $attrib_str . ">\n"; 1812 1464 1813 1465 if ($filename) { 1814 1466 $out .= sprintf( 1815 '<tr><td class="title">%s</td><td>%s</td><td>[<a href="./?%s">%s</a>]</tr>'."\n",1816 Q(rcube::gettext('filename')),1817 Q($part->filename),1818 str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']),1819 Q(rcube::gettext('download')));1467 '<tr><td class="title">%s</td><td>%s</td><td>[<a href="./?%s">%s</a>]</tr>'."\n", 1468 Q(rcube::gettext('filename')), 1469 Q($part->filename), 1470 str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), 1471 Q(rcube::gettext('download'))); 1820 1472 } 1821 1473 1822 1474 if ($part->size) { 1823 1475 $out .= sprintf( 1824 '<tr><td class="title">%s</td><td>%s</td></tr>' . "\n",1825 Q(rcube::gettext('filesize')),1826 show_bytes($part->size)1476 '<tr><td class="title">%s</td><td>%s</td></tr>' . "\n", 1477 Q(rcube::gettext('filesize')), 1478 show_bytes($part->size) 1827 1479 ); 1828 1480 } … … 1830 1482 1831 1483 return $out; 1832 } 1833 1834 1484 } 1835 1485 1836 1486 function rcmail_message_part_frame($attrib) … … 1839 1489 $MESSGAGE = $registry->get('MESSAGE', 'core'); 1840 1490 1841 $part = $MESSAGE['parts'][$_GET['_part']]; 1491 $part = $MESSAGE['parts'][asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))]; 1492 1842 1493 $ctype_primary = strtolower($part->ctype_primary); 1843 1494 1844 $attrib['src'] = './?'; 1845 $attrib['src'].= str_replace( 1846 '_frame=', 1847 ($ctype_primary=='text' ? '_show=' : '_preload='), 1848 $_SERVER['QUERY_STRING'] 1849 ); 1495 $attrib['src'] = Q('./?'.str_replace('_frame=', ($ctype_primary=='text' ? '_show=' : '_preload='), $_SERVER['QUERY_STRING'])); 1496 1850 1497 $attrib_str = rcube::create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height')); 1851 1498 $out = '<iframe '. $attrib_str . "></iframe>"; 1852 1499 1853 return $out; 1854 } 1855 1500 return $out; 1501 } 1502 1503 /** 1504 * Send the given message compose object using the configured method 1505 */ 1506 function rcmail_deliver_message(&$message, $from, $mailto) 1507 { 1508 $registry = rcube_registry::get_instance(); 1509 $CONFIG = $registry->get('CONFIG', 'core'); 1510 1511 $headers = $message->headers(); 1512 $msg_body = $message->get(); 1513 1514 // send thru SMTP server using custom SMTP library 1515 if ($CONFIG['smtp_server']) { 1516 // generate list of recipients 1517 $a_recipients = array($mailto); 1518 1519 if (strlen($headers['Cc'])) { 1520 $a_recipients[] = $headers['Cc']; 1521 } 1522 if (strlen($headers['Bcc'])) { 1523 $a_recipients[] = $headers['Bcc']; 1524 } 1525 // clean Bcc from header for recipients 1526 $send_headers = $headers; 1527 unset($send_headers['Bcc']); 1528 1529 // send message 1530 $smtp_response = array(); 1531 1532 $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response); 1533 1534 // log error 1535 if (!$sent) { 1536 raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, 1537 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); 1538 } 1539 return $sent; 1540 } 1541 1542 // unset some headers because they will be added by the mail() function 1543 $headers_enc = $message->headers($headers); 1544 $headers_php = $message->_headers; 1545 unset($headers_php['To'], $headers_php['Subject']); 1546 1547 // reset stored headers and overwrite 1548 $message->_headers = array(); 1549 $header_str = $message->txtHeaders($headers_php); 1550 1551 if (ini_get('safe_mode')) { 1552 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); 1553 } else { 1554 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); 1555 } 1556 1557 $message->_headers = array(); 1558 $message->headers($headers); 1559 1560 return $sent; 1561 } 1856 1562 1857 1563 // clear message composing settings … … 1871 1577 } 1872 1578 1873 1874 1579 // register UI objects 1875 1580 $OUTPUT->add_handlers(array( 1876 'mailboxlist' => 'rcmail_mailbox_list', 1877 'messages' => 'rcmail_message_list', 1878 'messagecountdisplay' => 'rcmail_messagecount_display', 1879 'quotadisplay' => 'rcmail_quota_display', 1880 'messageheaders' => 'rcmail_message_headers', 1881 'messagebody' => 'rcmail_message_body', 1882 'messagecontentframe' => 'rcmail_messagecontent_frame', 1883 'messagepartframe' => 'rcmail_message_part_frame', 1884 'messagepartcontrols' => 'rcmail_message_part_controls', 1885 'searchform' => array($OUTPUT, 'search_form') 1886 )); 1887 1888 ?> 1581 'mailboxlist' => 'rcmail_mailbox_list', 1582 'messages' => 'rcmail_message_list', 1583 'messagecountdisplay' => 'rcmail_messagecount_display', 1584 'quotadisplay' => 'rcmail_quota_display', 1585 'messageheaders' => 'rcmail_message_headers', 1586 'messagebody' => 'rcmail_message_body', 1587 'messagecontentframe' => 'rcmail_messagecontent_frame', 1588 'messagepartframe' => 'rcmail_message_part_frame', 1589 'messagepartcontrols' => 'rcmail_message_part_controls', 1590 'searchform' => array($OUTPUT, 'search_form'))); -
branches/devel-vnext/program/steps/mail/get.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 28 28 29 29 echo "<html>\n<head>\n"; 30 echo '<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($url).'">';30 echo '<meta http-equiv="refresh" content="0; url=' . Q($url).'">'; 31 31 echo "\n</head>\n<body>"; 32 32 echo $message; … … 49 49 rcube::parse_template('messagepart'); 50 50 exit; 51 } 52 else if ($pid = rcube::get_input_value('_part', rcube::INPUT_GET)) { 51 } else if ($pid = rcube::get_input_value('_part', rcube::INPUT_GET)) { 53 52 if ($part = $MESSAGE['parts'][$pid]) { 54 53 $ctype_primary = strtolower($part->ctype_primary); … … 65 64 header("Cache-Control: private", false); 66 65 header("Content-Type: application/octet-stream"); 67 } 68 else { 66 } else { 69 67 header("Content-Type: $mimetype"); 70 68 } … … 100 98 } 101 99 $OUTPUT = new rcube_html_page(); 102 $OUTPUT->write(rcmail_print_body($part, (bool)$_GET['_safe'])); 103 } 104 else { 100 $OUTPUT->write(rcmail_print_body($part, intval($_GET['_safe']))); 101 } else { 105 102 header( 106 103 sprintf( 107 104 'Content-Disposition: %s; filename="%s";', 108 $ part->disposition ? $part->disposition : 'attachment',105 $_GET['_download'] ? 'attachment' : 'inline', 109 106 $part->filename ? $part->filename : "roundcube.$ctype_secondary" 110 107 ) … … 112 109 113 110 // turn off output buffering and print part content 114 $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part ->encoding, true);111 $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part, true); 115 112 } 116 113 exit; 117 114 } 118 } 119 // print message 120 else { 115 } else { // print message 121 116 $ctype_primary = strtolower($MESSAGE['structure']->ctype_primary); 122 117 $ctype_secondary = strtolower($MESSAGE['structure']->ctype_secondary); … … 128 123 $cont = ''; 129 124 list($MESSAGE['parts']) = rcmail_parse_message( 130 $MESSAGE['structure'],131 array(132 'safe' => (bool)$_GET['_safe'],133 'get_url' => $GET_URL.'&_part=%s'134 )125 $MESSAGE['structure'], 126 array( 127 'safe' => intval($_GET['_safe']), 128 'get_url' => $GET_URL.'&_part=%s' 129 ) 135 130 ); 136 131 -
branches/devel-vnext/program/steps/mail/getunread.inc
r623 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
branches/devel-vnext/program/steps/mail/list.inc
r806 r962 5 5 | | 6 6 | This file is part of the RoundCube Webmail client | 7 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 8 8 | Licensed under the GNU GPL | 9 9 | | … … 45 45 46 46 // fetch message headers 47 if ($ count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) {47 if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) { 48 48 $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); 49 49 } 50 $count = $IMAP->messagecount($mbox_name); 50 51 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh'])); 51 52 … … 62 63 if (isset($a_headers) && count($a_headers)) { 63 64 rcmail_js_message_list($a_headers); 65 } else { 66 $OUTPUT->show_message('nomessagesfound', 'notice'); 64 67 } 65 66 68 // send response 67 69 $OUTPUT->send(); 68 ?> -
branches/devel-vnext/program/steps/mail/move_del.inc
r806 r962 5 5 | | 6 6 | This file is part of the RoundCube Webmail client | 7 | Copyright (C) 2005-200 7, RoundCube Dev. - Switzerland |7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 8 8 | Licensed under the GNU GPL | 9 9 | | … … 23 23 $OUTPUT = $registry->get('OUTPUT', 'core'); 24 24 25 // count messages before changing anything 26 $old_count = $IMAP->messagecount(); 27 $old_pages = ceil($old_count / $IMAP->page_size); 28 25 29 // move messages 26 30 if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) { … … 38 42 exit; 39 43 } 40 } 41 // delete messages 42 else if ($_action=='delete' && !empty($_POST['_uid'])) { 44 } else if ($_action=='delete' && !empty($_POST['_uid'])) { // delete messages 43 45 $count = sizeof(explode(',', ($uids = rcube::get_input_value('_uid', rcube::INPUT_POST)))); 44 46 $del = $IMAP->delete_message($uids, rcube::get_input_value('_mbox', rcube::INPUT_POST)); … … 51 53 exit; 52 54 } 53 } 54 // unknown action or missing query param 55 else { 55 } else { // unknown action or missing query param 56 56 //rcube::tfk_debug('/ unknown action'); 57 57 exit; 58 58 } 59 59 60 // refresh saved seac h set after moving some messages60 // refresh saved seacrh set after moving some messages 61 61 if ( 62 62 ($search_request = rcube::get_input_value('_search', rcube::INPUT_GPC)) 63 && $IMAP->search_set 64 ) { 63 && $IMAP->search_set) { 65 64 $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 66 65 } 67 66 67 $msg_count = $IMAP->messagecount(); 68 $pages = ceil($msg_count / $IMAP->page_size); 69 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page; 70 $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1); 71 72 // jump back one page (user removed the whole last page) 73 if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) { 74 $IMAP->set_page($IMAP->list_page-1); 75 $_SESSION['page'] = $IMAP->list_page; 76 $jump_back = true; 77 } 78 68 79 // update message count display 69 $msg_count = $IMAP->messagecount();70 $pages = ceil($msg_count / $IMAP->page_size);71 80 $OUTPUT->set_env('pagecount', $pages); 81 $OUTPUT->set_env('current_page', $IMAP->list_page); 72 82 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); 73 74 83 75 84 // update mailboxlist … … 83 92 84 93 // add new rows from next page (if any) 85 if ($_POST['_from'] != 'show' && $pages > 1 && $IMAP->list_page < $pages) {94 if ($_POST['_from'] != 'show' && ($jump_back || $nextpage_count > 0)) { 86 95 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; 87 96 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 88 97 89 98 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); 90 $a_headers = array_slice($a_headers, -$count, $count); 99 if (!$jump_back) { 100 $a_headers = array_slice($a_headers, -$count, $count); 101 } 91 102 92 103 rcmail_js_message_list($a_headers); … … 95 106 // send response 96 107 $OUTPUT->send(); 97 ?> -
branches/devel-vnext/program/steps/mail/quotadisplay.inc
r623 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
branches/devel-vnext/program/steps/mail/rss.inc
r806 r962 5 5 | | 6 6 | This file is part of the RoundCube Webmail client | 7 | Copyright (C) 2005 , RoundCube Dev. - Switzerland |7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 8 8 | Licensed under the GNU GPL | 9 9 | | … … 36 36 37 37 $REMOTE_REQUEST = TRUE; 38 $OUTPUT_TYPE = 'rss';38 $OUTPUT_TYPE = 'rss'; 39 39 40 40 $registry = rcube_registry::get_instance(); … … 46 46 $webmail_url .= 's'; 47 47 } 48 48 49 $webmail_url .= '://'.$_SERVER['SERVER_NAME']; 49 if ($_SERVER['SERVER_PORT'] != '80') {50 if ($_SERVER['SERVER_PORT'] != '80') { 50 51 $webmail_url .= ':'.$_SERVER['SERVER_PORT']; 51 52 } 53 52 54 $webmail_url .= '/'; 53 55 if (dirname($_SERVER['SCRIPT_NAME']) != '/') { … … 64 66 // Send global XML output 65 67 header('Content-type: text/xml'); 66 echo '<?xml version="1.0" encoding="UTF-8"?> 67 <rss version="2.0"68 echo '<?xml version="1.0" encoding="UTF-8"?>'; 69 echo '<rss version="2.0" 68 70 xmlns:dc="http://purl.org/dc/elements/1.1/" 69 71 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" … … 91 93 // Check if the user wants to override the default sortingmethode 92 94 if (isset($_GET['_sort'])) { 93 list($sort_col, $sort_order) = explode('_', $_GET['_sort']); 95 list($sort_col, $sort_order) = explode('_', 96 rcube::get_input_value('_sort', rcube::INPUT_GET)); 94 97 } 95 98 … … 97 100 if ($messagecount > 0) { 98 101 $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order); 99 foreach ($items as $item) 100 { 102 foreach ($items as $item) { 101 103 102 104 // Convert '"name" <email>' to 'email (name)' -
branches/devel-vnext/program/steps/mail/search.inc
r806 r962 34 34 if (preg_match("/^from:/i", $str)) { 35 35 list(,$srch) = explode(":", $str); 36 $subject = "HEADER FROM"; 37 $search = trim($srch); 38 } 39 else if (preg_match("/^to:/i", $str)) { 36 $subject = "HEADER FROM"; 37 $search = trim($srch); 38 } else if (preg_match("/^to:/i", $str)) { 40 39 list(,$srch) = explode(":", $str); 41 $subject = "HEADER TO"; 42 $search = trim($srch); 43 } 44 else if (preg_match("/^cc:/i", $str)) { 40 $subject = "HEADER TO"; 41 $search = trim($srch); 42 } else if (preg_match("/^cc:/i", $str)) { 45 43 list(,$srch) = explode(":", $str); 46 $subject = "HEADER CC"; 47 $search = trim($srch); 48 } 49 else if (preg_match("/^subject:/i", $str)) { 44 $subject = "HEADER CC"; 45 $search = trim($srch); 46 } else if (preg_match("/^subject:/i", $str)) { 50 47 list(,$srch) = explode(":", $str); 51 $subject = "HEADER SUBJECT"; 52 $search = trim($srch); 53 } 54 else if (preg_match("/^body:/i", $str)) { 48 $subject = "HEADER SUBJECT"; 49 $search = trim($srch); 50 } else if (preg_match("/^body:/i", $str)) { 55 51 list(,$srch) = explode(":", $str); 56 $subject = "TEXT";57 $search = trim($srch);58 } 59 // search in subject and sender by default60 else { 61 $subject = array("HEADER SUBJECT", "HEADER FROM");62 $search = trim($str);52 $subject = "TEXT"; 53 $search = trim($srch); 54 } else { 55 // search in subject and sender by default 56 $from = ($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox']) ? "TO" : "FROM"; 57 $subject = array("HEADER SUBJECT", "HEADER $from"); 58 $search = trim($str); 63 59 } 64 60 … … 72 68 // Get the headers 73 69 $result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 74 $count = count($result_h);70 $count = $IMAP->messagecount(); 75 71 76 72 // save search results in session -
branches/devel-vnext/program/steps/mail/sendmail.inc
r806 r962 30 30 $IMAP = $registry->get('IMAP', 'core'); 31 31 32 //require_once('lib/smtp.inc');33 require_once 'include/rcube_smtp.php';34 32 require_once 'lib/html2text.inc'; 35 36 33 37 34 if (!isset($_SESSION['compose']['id'])) { … … 51 48 } 52 49 $message_id = sprintf( 53 '<%s@%s>',54 md5(uniqid('rcmail' . rand(),true)),55 rcube::mail_domain($_SESSION['imap_host'])50 '<%s@%s>', 51 md5(uniqid('rcmail' . rand(),true)), 52 rcube::mail_domain($_SESSION['imap_host']) 56 53 ); 57 54 $savedraft = ((empty($_POST['_draft']) === false) ? TRUE : FALSE); … … 76 73 77 74 // set default charset 78 $input_charset = $OUTPUT->get_charset();75 $input_charset = $OUTPUT->get_charset(); 79 76 $message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; 80 77 81 $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/');78 $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/'); 82 79 $mailto_replace = array(', ', ', ', '', ','); 83 80 84 81 // replace new lines and strip ending ', ' 85 82 $mailto = preg_replace( 86 $mailto_regexp,87 $mailto_replace,88 rcube::get_input_value('_to', rcube::INPUT_POST, TRUE, $message_charset)83 $mailto_regexp, 84 $mailto_replace, 85 rcube::get_input_value('_to', rcube::INPUT_POST, TRUE, $message_charset) 89 86 ); 90 87 … … 104 101 //rcube::tfk_debug('We got identity.'); 105 102 106 $from = $identity_arr['mailto'];103 $from = $identity_arr['mailto']; 107 104 $first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto; 108 105 … … 112 109 // compose headers array 113 110 $headers = array( 114 'Date' => date('D, j M Y H:i:s O'),115 'From' => rcube::charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset),116 'To' => $mailto111 'Date' => date('D, j M Y H:i:s O'), 112 'From' => rcube::charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset), 113 'To' => $mailto 117 114 ); 118 115 … … 120 117 if (!empty($_POST['_cc'])) { 121 118 $headers['Cc'] = preg_replace( 122 $mailto_regexp,123 $mailto_replace,124 rcube::get_input_value(125 '_cc',126 rcube::INPUT_POST,127 TRUE, $message_charset128 )119 $mailto_regexp, 120 $mailto_replace, 121 rcube::get_input_value( 122 '_cc', 123 rcube::INPUT_POST, 124 TRUE, $message_charset 125 ) 129 126 ); 130 127 } 131 128 if (!empty($_POST['_bcc'])) { 132 129 $headers['Bcc'] = preg_replace( 133 $mailto_regexp, $mailto_replace,134 rcube::get_input_value('_bcc', rcube::INPUT_POST, TRUE, $message_charset)130 $mailto_regexp, $mailto_replace, 131 rcube::get_input_value('_bcc', rcube::INPUT_POST, TRUE, $message_charset) 135 132 ); 136 133 } 137 134 if (empty($identity_arr['bcc']) === false) { 138 $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];135 $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc']; 139 136 } 140 137 // add subject 141 138 $headers['Subject'] = trim( 142 rcube::get_input_value(143 '_subject',144 rcube::INPUT_POST,145 FALSE,146 $message_charset147 )139 rcube::get_input_value( 140 '_subject', 141 rcube::INPUT_POST, 142 FALSE, 143 $message_charset 144 ) 148 145 ); 149 146 … … 251 248 return; 252 249 } 253 } 254 else { 250 } else { 255 251 $message_body = wordwrap($message_body, 75, "\r\n"); 256 252 $message_body = wordwrap($message_body, 998, "\r\n", true); … … 269 265 } 270 266 $status = $MAIL_MIME->addAttachment( 271 $attachment['path'],272 $attachment['mimetype'],273 $attachment['name'],274 true,275 'base64',276 'attachment',277 $message_charset267 $attachment['path'], 268 $attachment['mimetype'], 269 $attachment['name'], 270 true, 271 'base64', 272 'attachment', 273 $message_charset 278 274 ); 279 275 if (PEAR::isError($status)) { … … 289 285 foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { 290 286 $status = $MAIL_MIME->addAttachment( 291 $filepath,292 $files['type'][$i],293 $files['name'][$i],294 true,295 'base64',296 'attachment',297 $message_charset287 $filepath, 288 $files['type'][$i], 289 $files['name'][$i], 290 true, 291 'base64', 292 'attachment', 293 $message_charset 298 294 ); 299 295 if (PEAR::isError($status)) { … … 404 400 ); 405 401 } 406 } 407 else { // send mail using PHP's mail() function 402 } else { // send mail using PHP's mail() function 408 403 409 404 //rcube::tfk_debug('We try to send using mail().'); … … 428 423 $header_str 429 424 ); 430 } 431 else { 425 } else { 432 426 $sent = mail( 433 427 $headers_enc['To'], … … 454 448 if ($savedraft) { 455 449 $store_target = 'drafts_mbox'; 456 } 457 else { 450 } else { 458 451 $store_target = 'sent_mbox'; 459 452 } … … 466 459 if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes())) { 467 460 $store_folder = $IMAP->create_mailbox($CONFIG[$store_target], TRUE); 468 } 469 else { 461 } else { 470 462 $store_folder = TRUE; 471 463 } … … 533 525 534 526 $OUTPUT->send('iframe'); 535 } 536 else { 527 } else { 537 528 if ($CONFIG['smtp_log'] === true) { 538 529 $log_entry = sprintf( 539 "[%s] User: %d on %s; Message for %s; %s\n",540 date("d-M-Y H:i:s O", mktime()),541 $_SESSION['user_id'],542 $_SERVER['REMOTE_ADDR'],543 $mailto,544 !empty($smtp_response) ? join('; ', $smtp_response) : ''530 "[%s] User: %d on %s; Message for %s; %s\n", 531 date("d-M-Y H:i:s O", mktime()), 532 $_SESSION['user_id'], 533 $_SERVER['REMOTE_ADDR'], 534 $mailto, 535 !empty($smtp_response) ? join('; ', $smtp_response) : '' 545 536 ); 546 537 -
branches/devel-vnext/program/steps/mail/show.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005-200 7, RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 52 52 53 53 // calculate Etag for this request 54 $etag = md5($MESSAGE['UID'] . $IMAP->get_mailbox_name() . session_id(). ($PRINT_MODE?1:0)); 54 $etag = $MESSAGE['UID'] . $IMAP->get_mailbox_name() . session_id(); 55 $etag .= intval($MESSAGE['headers']->mdn_sent) . intval($PRINT_MODE); 56 $etag = md5($etag); 55 57 56 58 // allow caching, unless remote images are present 57 59 if ((bool)rcube::get_input_value('_safe', rcube::INPUT_GET)) { 58 60 send_nocacheing_headers(); 59 } 60 else { 61 } else if (empty($CONFIG['devel_mode'])) { 61 62 send_modified_header($_SESSION['login_time'], $etag); 62 63 } 63 64 64 65 $MESSAGE['subject'] = rcube_imap::decode_mime_string( 65 $MESSAGE['headers']->subject,66 $MESSAGE['headers']->charset66 $MESSAGE['headers']->subject, 67 $MESSAGE['headers']->charset 67 68 ); 68 69 $registry->set('MESSAGE', $MESSAGE, 'core'); … … 71 72 if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID'])) { 72 73 $_message_parts = rcmail_parse_message( 73 $MESSAGE['structure'],74 array(75 'safe' => (bool)$_GET['_safe'],76 'prefer_html' => $CONFIG['prefer_html'],77 'get_url' => $GET_URL.'&_part=%s'78 )74 $MESSAGE['structure'], 75 array( 76 'safe' => intval($_GET['_safe']), 77 'prefer_html' => $CONFIG['prefer_html'], 78 'get_url' => $GET_URL.'&_part=%s' 79 ) 79 80 ); 80 81 list($MESSAGE['parts'], $MESSAGE['attachments']) = $_message_parts; 81 } 82 else { 82 } else { 83 83 $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 84 84 } … … 91 91 // give message uid to the client 92 92 $OUTPUT->set_env('uid', $MESSAGE['UID']); 93 $OUTPUT->set_env('safemode', (bool)$_GET['_safe']); 93 $OUTPUT->set_env('safemode', intval($_GET['_safe'])); 94 // check for unset disposition notification 95 if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent) { 96 rcube::gettext('mdnrequest'); 97 $OUTPUT->set_env('mdn_request', true); 98 } 94 99 95 100 $next = $prev = -1; -
branches/devel-vnext/program/steps/mail/spell.inc
r806 r962 5 5 | | 6 6 | This file is part of the RoundCube Webmail client | 7 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 8 8 | Licensed under the GNU GPL | 9 9 | | -
branches/devel-vnext/program/steps/mail/upload.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
branches/devel-vnext/program/steps/mail/viewsource.inc
r806 r962 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
branches/devel-vnext/program/steps/settings/delete_identity.inc
r806 r962 20 20 */ 21 21 22 if ( 23 ($ids = rcube::get_input_value('_iid', rcube::INPUT_GET)) 24 && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids) 25 ) { 26 $_query = "UPDATE " . rcube::get_table_name('identities'); 27 $_query.= " SET del=1"; 28 $_query.= " WHERE user_id=?"; 29 $_query.= " AND identity_id IN (" . $ids . ")"; 30 $DB->query($_query, $_SESSION['user_id']); 22 $ids = rcube::get_input_value('_iid', rcube::INPUT_GET); 31 23 32 $count = $DB->affected_rows(); 33 if ($ count) {24 if ($ids && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids)) { 25 if ($USER->delete_identity($ids)) { 34 26 $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); 35 27 } … … 45 37 // go to identities page 46 38 rcube::override_action('identities'); 47 ?> -
branches/devel-vnext/program/steps/settings/edit_identity.inc
r806 r962 20 20 21 21 if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity') { 22 $_query = "SELECT * FROM " . rcube::get_table_name('identities'); 23 $_query.= " WHERE identity_id=?"; 24 $_query.= " AND user_id=?"; 25 $_query.= " AND del<>1"; 26 $DB->query( 27 $_query, 28 rcube::get_input_value('_iid', rcube::INPUT_GPC), 29 $_SESSION['user_id'] 30 ); 31 32 $IDENTITY_RECORD = $DB->fetch_assoc(); 22 $IDENTITY_RECORD = $USER->get_identity( 23 rcube::get_input_value('_iid', rcube::INPUT_GPC)); 33 24 $registry->set('IDENTITY_RECORD', $IDENTITY_RECORD, 'core'); 34 25 if (is_array($IDENTITY_RECORD)) { … … 36 27 } 37 28 $OUTPUT->set_pagetitle(rcube::gettext('edititem')); 38 } 39 else { 40 $OUTPUT->set_pagetitle(rcube::gettext('newitem')); 29 } else { 30 $OUTPUT->set_pagetitle(rcube::gettext('newitem')); 41 31 } 42 32 $OUTPUT->include_script('list.js'); … … 47 37 $IDENTITY_RECORD = $registry->get('IDENTITY_RECORD', 'core'); 48 38 $OUTPUT = $registry->get('OUTPUT', 'core'); 49 /* 50 $OUTPUT->include_script('tiny_mce/tiny_mce_src.js'); 51 $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," . 52 "apply_source_formatting : true," . 53 "content_css : '\$__skin_path' + '/editor_content.css'," . 54 "popups_css : '\$__skin_path' + '/editor_popups.css'," . 55 "editor_css : '\$__skin_path' + '/editor_ui.css'," . 56 "theme : 'advanced'," . 57 "theme_advanced_toolbar_location : 'top'," . 58 "theme_advanced_toolbar_align : 'left'," . 59 "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," . 60 "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," . 61 "theme_advanced_buttons3 : '' });"); 62 */ 39 40 $OUTPUT->include_script('tiny_mce/tiny_mce_src.js'); 41 $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," . 42 "apply_source_formatting : true," . 43 "content_css : '\$__skin_path' + '/editor_content.css'," . 44 "editor_css : '\$__skin_path' + '/editor_ui.css'," . 45 "theme : 'advanced'," . 46 "theme_advanced_toolbar_location : 'top'," . 47 "theme_advanced_toolbar_align : 'left'," . 48 "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," . 49 "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," . 50 "theme_advanced_buttons3 : '' });"); 51 63 52 if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity') { 64 53 return rcube::gettext('notfound'); … … 70 59 unset($attrib['form']); 71 60 72 73 61 // list of available cols 74 62 $a_show_cols = array( 75 'name'=> array('type' => 'text'),76 'email'=> array('type' => 'text'),77 'organization'=> array('type' => 'text'),78 'reply-to'=> array('type' => 'text', 'label' => 'replyto'),79 'bcc'=> array('type' => 'text'),80 'signature' => array('type' => 'textarea', 'size' => "40", 'rows' => "4"),81 // 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'),82 'standard'=> array('type' => 'checkbox', 'label' => 'setdefault'));63 'name' => array('type' => 'text'), 64 'email' => array('type' => 'text'), 65 'organization' => array('type' => 'text'), 66 'reply-to' => array('type' => 'text', 'label' => 'replyto'), 67 'bcc' => array('type' => 'text'), 68 'signature' => array('type' => 'textarea', 'size' => "40", 'rows' => "6"), 69 'html_signature' => array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'_signature\');'), 70 'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); 83 71 84 72 … … 92 80 $IDENTITY_RECORD[$attrib['part']], 93 81 $attrib, 94 $colprop['type'] 95 ); 82 $colprop['type']); 96 83 return $out; 97 84 } 98 else { 99 return ''; 100 } 85 return ''; 101 86 } 102 103 87 104 88 // return the complete edit form as table … … 106 90 107 91 foreach ($a_show_cols as $col => $colprop) { 108 $attrib['id'] = 'rcmfd_' .$col;92 $attrib['id'] = 'rcmfd_' . $col; 109 93 110 94 if (strlen($colprop['onclick'])) { 111 95 $attrib['onclick'] = $colprop['onclick']; 112 } 113 else { 96 } else { 114 97 unset($attrib['onclick']); 115 98 } … … 119 102 $attrib['rows'] = $colprop['rows']; 120 103 $attrib['mce_editable'] = $IDENTITY_RECORD['html_signature'] ? "true" : "false"; 121 } 122 else { 104 } else { 123 105 unset($attrib['size']); 124 106 unset($attrib['rows']); … … 128 110 $label = strlen($colprop['label']) ? $colprop['label'] : $col; 129 111 $value = rcube::get_edit_field( 130 $col, 131 $IDENTITY_RECORD[$col], 132 $attrib, 133 $colprop['type'] 134 ); 112 $col, 113 $IDENTITY_RECORD[$col], 114 $attrib, 115 $colprop['type']); 135 116 136 117 $out .= sprintf( 137 "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",138 $attrib['id'],139 Q(rcube::gettext($label)),140 $value);118 "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 119 $attrib['id'], 120 Q(rcube::gettext($label)), 121 $value); 141 122 } 142 123 $out .= "\n</table>$form_end"; … … 151 132 } 152 133 rcube::parse_template('editidentity'); 153 ?> -
branches/devel-vnext/program/steps/settings/func.inc
r956 r962 20 20 */ 21 21 22 23 // get user record 24 $_query = "SELECT username, mail_host FROM " . rcube::get_table_name('users'); 25 $_query.= " WHERE user_id=?"; 26 $sql_result = $DB->query($_query, $_SESSION['user_id']); 27 28 if ($USER_DATA = $DB->fetch_assoc($sql_result)) { 29 $OUTPUT->set_pagetitle( 30 sprintf( 31 '%s %s@%s', 32 rcube::gettext('settingsfor'), 33 $USER_DATA['username'], 34 $USER_DATA['mail_host'] 35 ) 36 ); 22 if ($USER->ID) { 23 $OUTPUT->set_pagetitle( 24 rcube::gettext('settingsfor') . ' ' . $USER->get_username()); 37 25 } 38 39 26 40 27 function rcmail_user_prefs_form($attrib) … … 176 163 177 164 // Show checkbox for HTML Editor 178 if ( false &&!isset($no_override['htmleditor'])) {165 if (!isset($no_override['htmleditor'])) { 179 166 $field_id = 'rcmfd_htmleditor'; 180 167 $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); … … 188 175 189 176 // show config parameter for preview pane 190 if (false && !isset($no_override['preview_pane'])) { 191 $field_id = 'rcmfd_preview'; 192 $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1)); 193 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 177 if (!isset($no_override['preview_pane'])) { 178 $field_id = 'rcmfd_preview'; 179 $input_preview = new html_checkbox( 180 array( 181 'name' => '_preview_pane', 182 'id' => $field_id, 183 'value' => 1)); 184 185 $out .= sprintf( 186 "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 194 187 $field_id, 195 188 Q(rcube::gettext('previewpane')), … … 233 226 $CONFIG = $registry->get_all('config'); 234 227 $OUTPUT = $registry->get('OUTPUT', 'core'); 235 228 $USER = $registry->get('USER', 'core'); 236 229 237 230 // get contacts from DB 238 $_query = "SELECT * FROM " . rcube::get_table_name('identities');239 $_query .= " WHERE del<>1";240 $_query .= " AND user_id=?";241 $_query .= " ORDER BY standard DESC, name ASC";231 $_query = "SELECT * FROM " . rcube::get_table_name('identities'); 232 $_query .= " WHERE del<>1"; 233 $_query .= " AND user_id=?"; 234 $_query .= " ORDER BY standard DESC, name ASC"; 242 235 $sql_result = $DB->query($_query, $_SESSION['user_id']); 243 236 244 237 $identities_data = array(); 245 /**246 * macbay hack247 */248 238 while ($sql_result && ($sql_arr = $DB->fetch_assoc($sql_result))) { 249 239 $sql_arr['edit'] = ''; 250 //$sql_arr['edit'].= '<img scr="/webmail/img/pencil.gif" alt="Bearbeiten" />';251 //$sql_arr['edit'].= '<img src="/webmail/skins/macbay/img/delete.gif" alt="Löschen" />';252 240 $sql_arr['edit'].= '<roundcube:button id="identities_edit_' . $sql_arr['identity_id'] . '" command="edit" type="image" image="/img/pencil.gif" title="edit" />'; 253 //$sql_arr['edit'].= '<roundcube:button id="identities_delete_' . $sql_arr['identity_id'] . '" command="delete" type="image" style="padding-left:10px;" image="/img/delete.gif" title="delete" />';254 241 255 242 array_push($identities_data, $sql_arr); 256 //echo '<pre>'; var_dump($sql_arr); echo '</pre>'; 257 } 258 //exit; 243 } 259 244 260 245 // add id to message list table if not specified -
branches/devel-vnext/program/steps/settings/manage_folders.inc
r806 r962 27 27 $IMAP = $registry->get('IMAP', 'core'); 28 28 29 //rcube::tfk_debug('DEBUG: ' . $_action); 30 //rcube::tfk_debug('MAILBOX: ' . $_POST['_mboxes']); 31 //rcube::tfk_debug('AJAX?: ' . $OUTPUT->ajax_call); 29 $OUTPUT->include_script('list.js'); 32 30 33 31 // subscribe to one or more mailboxes 34 32 if ($_action=='subscribe') { 35 33 if ($mboxes = rcube::get_input_value('_mboxes', rcube::INPUT_POST)) { 36 $status = $IMAP->subscribe(array($mboxes)); 37 //rcube::tfk_debug('Status: ' . $status); 34 $status = $IMAP->subscribe($mboxes); 38 35 } 39 36 if ($OUTPUT->ajax_call) { … … 45 42 else if ($_action=='unsubscribe') { 46 43 if ($mboxes = rcube::get_input_value('_mboxes', rcube::INPUT_POST)) { 47 $status = $IMAP->unsubscribe(array($mboxes)); 48 //rcube::tfk_debug('Status: ' . $status); 44 $status = $IMAP->unsubscribe($mboxes); 49 45 } 50 46 if ($OUTPUT->ajax_call) { 51 47 $OUTPUT->remote_response('// unsubscribed'); 52 48 } 53 } 54 55 // create a new mailbox 56 else if ($_action=='create-folder') { 49 } else if ($_action=='create-folder') { // create a new mailbox 57 50 if (!empty($_POST['_name'])) { 58 51 $create = $IMAP->create_mailbox( 59 trim( 60 rcube::get_input_value('_name', rcube::INPUT_POST, FALSE, 'UTF-7') 61 ), 62 TRUE 52 trim(rcube::get_input_value('_name', rcube::INPUT_POST, FALSE, 'UTF-7')), 53 TRUE 63 54 ); 64 55 } 65 56 if ($create && $OUTPUT->ajax_call) { 66 $OUTPUT->command( 67 'add_folder_row', 68 $create, 69 rcube::charset_convert($create, 'UTF-7') 70 ); 57 $delimiter = $IMAP->get_hierarchy_delimiter(); 58 $foldersplit = explode($delimiter, $create); 59 60 $_str = substr_count($create, $delimiter)); 61 $_str .= rcube::charset_convert($foldersplit[count($foldersplit)-1], 'UTF-7'); 62 63 $display_create = str_repeat(' ', $str); 64 65 $OUTPUT->command('add_folder_row', $create, $display_create); 71 66 $OUTPUT->send(); 72 } 73 else if (!$create && $OUTPUT->ajax_call) { 67 } else if (!$create && $OUTPUT->ajax_call) { 74 68 $OUTPUT->show_message('errorsaving', 'error'); 75 69 $OUTPUT->remote_response(); … … 78 72 $OUTPUT->show_message('errorsaving', 'error'); 79 73 } 80 } 81 82 // rename a mailbox 83 else if ($_action=='rename-folder') { 74 } else if ($_action=='rename-folder') { // rename a mailbox 84 75 if (!empty($_POST['_folder_oldname']) && !empty($_POST['_folder_newname'])) { 76 77 $a_mboxes = array_unique(array_merge( 78 $IMAP->list_mailboxes(), 79 $IMAP->list_unsubscribed())); 80 $delimiter = $IMAP->get_hierarchy_delimiter(); 85 81 86 82 $oldname = rcube::get_input_value('_folder_oldname', rcube::INPUT_POST); … … 93 89 } 94 90 if ($rename && $OUTPUT->ajax_call) { 95 $OUTPUT->command( 96 'replace_folder_row', 97 $oldname, 98 $rename, 99 rcube::charset_convert($rename, 'UTF-7') 100 ); 91 $delimiter = $IMAP->get_hierarchy_delimiter(); 92 $foldersplit = explode($delimiter, $rename); 93 $level = count($foldersplit) - 1; 94 $display_rename = str_repeat(' ', $level) . rcube::charset_convert($foldersplit[$level], 'UTF-7'); 95 96 $OUTPUT->command('replace_folder_row', $oldname, $rename, $display_rename); 97 98 foreach ($a_mboxes as $mbox) { 99 if (preg_match('/^'.preg_quote($oldname.$delimiter).'/', $mbox)) { 100 $c_rename = preg_replace('/^'.preg_quote($oldname).'/', $rename, $mbox); 101 $foldersplit = explode($delimiter, $c_rename); 102 $level = count($foldersplit) - 1; 103 $display_rename = str_repeat(' ', $level) . rcube::charset_convert($foldersplit[$level], 'UTF-7'); 104 105 $OUTPUT->command('replace_folder_row', $mbox, $c_rename, $display_rename); 106 } 107 } 101 108 $OUTPUT->command('reset_folder_rename'); 102 109 $OUTPUT->send(); 103 } 104 elseif (!$rename && $OUTPUT->ajax_call) { 110 } elseif (!$rename && $OUTPUT->ajax_call) { 105 111 $OUTPUT->command('reset_folder_rename'); 106 112 $OUTPUT->show_message('errorsaving', 'error'); … … 110 116 $OUTPUT->show_message('errorsaving', 'error'); 111 117 } 112 } 113 114 // delete an existing IMAP mailbox 115 elseif ($_action=='delete-folder') { 118 } elseif ($_action=='delete-folder') { // delete an existing IMAP mailbox 119 $a_mboxes = array_merge($IMAP->list_mailboxes(), $IMAP->list_unsubscribed()); 120 $delimiter = $IMAP->get_hierarchy_delimiter(); 121 116 122 if ($mboxes = rcube::get_input_value('_mboxes', rcube::INPUT_POST)) { 117 123 $deleted = $IMAP->delete_mailbox(array($mboxes)); … … 120 126 if ($OUTPUT->ajax_call && $deleted) { 121 127 $OUTPUT->command('remove_folder_row', rcube::get_input_value('_mboxes', rcube::INPUT_POST)); 128 foreach ($a_mboxes as $mbox) { 129 $regex = preg_quote(rcube::get_input_value( 130 '_mboxes', 131 rcube::INPUT_POST) . $delimiter); 132 133 if (preg_match('/^'. $regex .'/', $mbox)) { 134 $OUTPUT->command('remove_folder_row', $mbox); 135 } 136 } 137 122 138 $OUTPUT->show_message('folderdeleted', 'confirmation'); 123 139 $OUTPUT->send(); … … 187 203 $a_unsubscribed = $IMAP->list_unsubscribed(); 188 204 $a_subscribed = $IMAP->list_mailboxes(); 205 $delimiter = $IMAP->get_hierarchy_delimiter(); 189 206 $a_js_folders = array(); 190 207 … … 226 243 $folder_js = JQ($folder); 227 244 $folder_html = ''; 228 if ( 229 $CONFIG['protect_default_folders'] 230 && in_array($folder, $CONFIG['default_imap_folders']) 231 ) { 232 $folder_html.= rcube::gettext(strtolower($folder)); 233 } 234 else { 235 $folder_html.= rcube::charset_convert($folder, 'UTF-7'); 245 246 $foldersplit = explode($delimiter, $folder); 247 $level = count($foldersplit) - 1; 248 $display_folder = str_repeat(' ', $level); 249 $display_folder .= rcube::charset_convert($foldersplit[$level], 'UTF-7'); 250 251 if ($CONFIG['protect_default_folders'] && in_array($folder, $CONFIG['default_imap_folders'])) { 252 $folder_html .= rcube::gettext(strtolower($folder)); 253 } else { 254 $folder_html .= $display_folder; 236 255 } 237 256 if (strlen($folder_html) > 40) { … … 283 302 $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']); 284 303 $OUTPUT->set_env('subscriptionrows', $a_js_folders); 285 304 $OUTPUT->set_env('defaultfolders', $CONFIG['default_imap_folders']); 305 $OUTPUT->set_env('delimiter', $delimiter); 306 286 307 return $out; 287 308 } -
branches/devel-vnext/program/steps/settings/save_identity.inc
r806 r962 23 23 exit; 24 24 } 25 $a_save_cols = array(26 'name', 'email', 'organization',27 'reply-to', 'bcc', 'standard',28 'signature', 'html_signature' 29 ); 25 $a_save_cols = array( 26 'name', 'email', 'organization', 27 'reply-to', 'bcc', 'standard', 28 'signature', 'html_signature'); 29 30 30 $a_html_cols = array('signature'); 31 31 $a_boolean_cols = array('standard', 'html_signature'); … … 39 39 } 40 40 41 $save_data = array(); 42 foreach ($a_save_cols as $col) { 43 $fname = '_'.$col; 44 if (isset($_POST[$fname])) { 45 $save_data[$col] = rcube::get_input_value($fname, 46 rcube::INPUT_POST, in_array($col, $a_html_cols)); 47 } 48 } 41 49 42 // update an existing contact 50 // set "off" values for checkboxes that were not checked, and therefore 51 // not included in the POST body. 52 foreach ($a_boolean_cols as $col) { 53 $fname = '_' . $col; 54 if (!isset($_POST[$fname])) { 55 $save_data[$col] = 0; 56 } 57 } 58 43 59 if ($_POST['_iid']) { 44 $a_write_sql = array(); 45 46 foreach ($a_save_cols as $col) { 47 $fname = '_'.$col; 48 if (isset($_POST[$fname])) { 49 $a_write_sql[] = sprintf( 50 "%s=%s", 51 $DB->quoteIdentifier($col), 52 $DB->quote( 53 rcube::get_input_value( 54 $fname, 55 rcube::INPUT_POST, 56 in_array($col, $a_html_cols) 57 ) 58 ) 59 ); 60 } 61 } 62 63 // set "off" values for checkboxes that were not checked, and therefore 64 // not included in the POST body. 65 foreach ($a_boolean_cols as $col) { 66 $fname = '_' . $col; 67 if (!isset($_POST[$fname])) { 68 $a_write_sql[] = sprintf("%s=0", $DB->quoteIdentifier($col)); 69 } 70 } 71 72 if (sizeof($a_write_sql)) { 73 $_query = "UPDATE " . rcube::get_table_name('identities'); 74 $_query.= " SET " . join(', ', $a_write_sql); 75 $_query.= " WHERE identity_id=?"; 76 $_query.= " AND user_id=?"; 77 $_query.= " AND del<>1"; 78 $DB->query( 79 $_query, 80 rcube::get_input_value('_iid', rcube::INPUT_POST), 81 $_SESSION['user_id'] 82 ); 83 84 $updated = $DB->affected_rows(); 85 } 86 87 if ($updated) { 60 $updated = $USER->update_identity( 61 rcube::get_input_value('_iid', rcube::INPUT_POST), 62 $save_data); 63 64 if ($updated) { 88 65 $OUTPUT->show_message('successfullysaved', 'confirmation'); 89 66 … … 95 72 // ... 96 73 } 97 } 98 else if ($DB->is_error()) { 74 } else if ($DB->is_error()) { 99 75 // show error message 100 76 $OUTPUT->show_message('errorsaving', 'error'); … … 102 78 return; 103 79 } 104 } 105 // insert a new contact 106 else { 107 $a_insert_cols = $a_insert_values = array(); 108 109 foreach ($a_save_cols as $col) { 110 $fname = '_'.$col; 111 if (!isset($_POST[$fname])) { 112 continue; 113 } 114 $a_insert_cols[] = $DB->quoteIdentifier($col); 115 $a_insert_values[] = $DB->quote( 116 rcube::get_input_value( 117 $fname, 118 rcube::INPUT_POST, 119 in_array($col, $a_html_cols) 120 ) 121 ); 122 } 123 if (sizeof($a_insert_cols)) { 124 $_query = "INSERT INTO " . rcube::get_table_name('identities'); 125 $_query.= " (user_id, " . join(', ', $a_insert_cols).")"; 126 $_query.= " VALUES (?, " . join(', ', $a_insert_values).")"; 127 $DB->query($_query, $_SESSION['user_id']); 128 129 $insert_id = $DB->insert_id(rcube::get_sequence_name('identities')); 130 } 131 132 if ($insert_id) { 80 } else { // insert a new contact 81 if ($insert_id = $USER->insert_identity($save_data)) { 133 82 $_GET['_iid'] = $insert_id; 134 83 … … 140 89 // .... 141 90 } 142 } 143 else { 91 } else { 144 92 // show error message 145 93 $OUTPUT->show_message('errorsaving', 'error'); … … 149 97 } 150 98 151 152 99 // mark all other identities as 'not-default' 153 100 if ($default_id) { 154 $_query = "UPDATE " . rcube::get_table_name('identities'); 155 $_query.= " SET " . $DB->quoteIdentifier('standard') . "='0'"; 156 $_query.= " WHERE user_id=?"; 157 $_query.= " AND identity_id<>?"; 158 $_query.= " AND del<>1"; 159 $DB->query($_query, $_SESSION['user_id'], $default_id); 101 $USER->set_default($default_id); 160 102 } 161 103 // go to next step -
branches/devel-vnext/program/steps/settings/save_prefs.inc
r806 r962 43 43 $a_user_prefs['pagesize'] = 10; 44 44 } 45 rcube::tfk_debug($a_user_prefs['pagesize']); 46 rcube::tfk_debug($CONFIG['max_pagesize']); 45 47 46 if (isset($CONFIG['max_pagesize']) && empty($CONFIG['max_pagesize']) !== TRUE) { 48 47 if ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']) { … … 57 56 } 58 57 59 if (rcube::save_user_prefs($a_user_prefs)) { 58 // force min size 59 if ($a_user_prefs['pagesize'] < 1) { 60 $a_user_prefs['pagesize'] = 10; 61 } 62 if (isset($CONFIG['max_pagesize']) 63 && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize'])) { 64 $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize']; 65 } 66 67 if ($USER->save_prefs($a_user_prefs)) { 60 68 $OUTPUT->show_message('successfullysaved', 'confirmation'); 61 69 }
Note: See TracChangeset
for help on using the changeset viewer.
