Changeset 962 in subversion


Ignore:
Timestamp:
Jan 28, 2008 9:28:08 AM (5 years ago)
Author:
till
Message:
  • comitted part of the patch
  • fixed a lot of CS
  • fixed some bugs I "saw"
Location:
branches/devel-vnext/program
Files:
1 added
29 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-vnext/program/include/rcube/rcmail_compose.php

    r806 r962  
    1111    $MESSAGE       = $registry->get('MESSAGE', 'core'); 
    1212    $DB            = $registry->get('DB', 'core'); 
     13    $USER          = $registry->get('USER', 'core'); 
    1314    $compose_mode  = $registry->get('compose_mode', 'core'); 
    1415    $sa_recipients = $registry->get('sa_recipients', 'core'); 
     
    2425 
    2526    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 session 
    34             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; 
    6465    } 
    6566 
     
    7677    if ($fname && !empty($_POST[$fname])) { 
    7778        $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) { 
    8080        // get recipent address(es) out of the message headers 
    8181        if ($header=='to' && !empty($reply_to)) { 
    8282            $fvalue = $reply_to; 
    83         } 
    84         else if ($header=='to' && !empty($from)) { 
     83        } else if ($header=='to' && !empty($from)) { 
    8584            $fvalue = $from; 
    8685        } 
     
    158157    $MESSAGE       = $registry->get('MESSAGE', 'core'); 
    159158    $DB            = $registry->get('DB', 'core'); 
     159    $USER          = $registry->get('USER', 'core'); 
    160160    $compose_mode  = $registry->get('compose_mode', 'core'); 
    161161    $OUTPUT        = $registry->get('OUTPUT', 'core'); 
     
    190190    } 
    191191 
    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(); 
    204193    if ($DB->num_rows($sql_result) == 0) { 
    205194        $input_from = new html_inputfield($field_attrib); 
     
    239228            } 
    240229        } 
    241  
     230         
    242231        // set identity if it's one of the reply-message recipients 
    243232        if (in_array($sql_arr['email'], $a_recipients)) { 
    244233            $from_id = $sql_arr['identity_id']; 
    245234        } 
     235         
    246236        if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE['FROM'])) { 
    247237            $MESSAGE['FROM'][] = $sql_arr['email']; 
    248238        } 
     239         
    249240        if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE['headers']->from, $sql_arr['email'])) { 
    250241            $from_id = $sql_arr['identity_id']; 
     
    286277    if ($CONFIG['htmleditor']) { 
    287278        $isHtml = true; 
    288     } 
    289     else { 
     279    } else { 
    290280        $isHtml = false; 
    291281    } 
     
    295285    if (!empty($_POST['_message'])) { 
    296286        $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 
    300289        $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 
    301290        if ($hasHtml && $CONFIG['htmleditor']) { 
    302291            $body = rcmail_first_html_part($MESSAGE); 
    303292            $isHtml = true; 
    304         } 
    305         else { 
     293        } else { 
    306294            $body = rcmail_first_text_part($MESSAGE); 
    307295            $isHtml = false; 
    308296        } 
    309297        $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 
    313300        $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 
    314301        if ($hasHtml && $CONFIG['htmleditor']) { 
    315302            $body = rcmail_first_html_part($MESSAGE); 
    316303            $isHtml = true; 
    317         } 
    318         else { 
     304        } else { 
    319305            $body = rcmail_first_text_part($MESSAGE); 
    320306            $isHtml = false; 
    321307        } 
    322308        $body = rcmail_create_forward_body($body, $isHtml); 
    323     } 
    324     elseif ($compose_mode == RCUBE_COMPOSE_DRAFT) { 
     309    } elseif ($compose_mode == RCUBE_COMPOSE_DRAFT) { 
    325310        $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 
    326311        if ($hasHtml && $CONFIG['htmleditor']) { 
    327312            $body = rcmail_first_html_part($MESSAGE); 
    328313            $isHtml = true; 
    329         } 
    330         else { 
    331            $body = rcmail_first_text_part($MESSAGE); 
     314        } else { 
     315            $body = rcmail_first_text_part($MESSAGE); 
    332316            $isHtml = false; 
    333317        } 
    334318        $body = rcmail_create_draft_body($body, $isHtml); 
    335319    } 
     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     
    336325    $out = $form_start ? "$form_start\n" : ''; 
    337326 
    338     //tfk_debug($MESSAGE['headers']); 
    339  
    340327    $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        )); 
    348334    $out .= $saveid->show(); 
    349335 
     
    370356        $OUTPUT->include_script('googiespell.js'); 
    371357        $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'); 
    393378        $OUTPUT->add_label('checking'); 
    394379    } 
     
    428413            if (strpos($a_lines[$n], '>')===0) { 
    429414                $a_lines[$n] = '>'.$a_lines[$n]; 
    430             } 
    431             else { 
     415            } else { 
    432416                $a_lines[$n] = '> '.$a_lines[$n]; 
    433417            } 
     
    438422        // add title line 
    439423        $prefix = sprintf( 
    440                         "\n\n\nOn %s, %s wrote:\n", 
    441                         $_date, 
    442                         $_from 
     424            "\n\n\nOn %s, %s wrote:\n", 
     425            $_date, 
     426            $_from 
    443427        ); 
    444428 
     
    450434        } 
    451435        $suffix = ''; 
    452     } 
    453     else { 
     436    } else { 
    454437        $_msg = "<br><br>On %s, %s wrote:<br><blockquote type=\"cite\" "; 
    455438        $_msg.= "style=\"padding-left: 5px; border-left: #1010ff 2px solid; "; 
    456439        $_msg.= "margin-left: 5px; width: 100%%\">"; 
    457440        $prefix = sprintf( 
    458                         $_msg, 
    459                         $_date, 
    460                         $_from 
     441            $_msg, 
     442            $_date, 
     443            $_from 
    461444        ); 
    462445        $suffix = "</blockquote>"; 
     
    478461    $_to      = $MESSAGE['headers']->to; 
    479462 
     463    $prefix = ''; 
     464    $suffix = ''; 
    480465    if (! $bodyIsHtml) { 
    481466        // soft-wrap message first 
    482467        $body = wordwrap($body, 80); 
    483468 
    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>"; 
    506483    } 
    507484 
     
    510487        rcmail_write_compose_attachments($MESSAGE); 
    511488    } 
    512     return $prefix.$body; 
    513 } 
    514  
     489    return $prefix.$body.$suffix; 
     490} 
    515491 
    516492function rcmail_create_draft_body($body, $bodyIsHtml) 
     
    530506    return $body; 
    531507} 
    532  
    533508 
    534509function rcmail_write_compose_attachments(&$message) 
  • branches/devel-vnext/program/steps/addressbook/copy.inc

    r806 r962  
    2727$target = rcube::get_input_value('_to', rcube::INPUT_POST); 
    2828if ( 
    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 
    3331) { 
    3432    if ($target != '0') { 
    3533        $TARGET = new rcube_ldap($CONFIG['ldap_public'][$target]); 
    36     } 
    37     else { 
     34    } else { 
    3835        $TARGET = new rcube_contacts($DB, $_SESSION['user_id']); 
    3936    } 
     
    4643    if (empty($success)) { 
    4744        $OUTPUT->show_message('copyerror', 'error'); 
    48     } 
    49     else { 
     45    } else { 
    5046        $OUTPUT->show_message('copysuccess', 'notice', array('nr' => count($success))); 
    5147    } 
     48     
     49    // close connection to second address directory 
     50        $TARGET->close(); 
    5251} 
    5352 
  • branches/devel-vnext/program/steps/addressbook/func.inc

    r806 r962  
    3737) { 
    3838    $CONTACTS = new rcube_ldap($CONFIG['ldap_public'][$source]); 
    39 } 
    40 else { 
     39} else { 
    4140    /** 
    4241     * @todo resolve conditional include (maybe autoload) 
    4342     */ 
    44     if ( 
    45         isset($CONFIG['addressbook_plugin']) 
    46         && empty($CONFIG['addressbook_plugin']) === FALSE 
    47     ) { 
     43    if (isset($CONFIG['addressbook_plugin']) && !empty($CONFIG['addressbook_plugin'])) { 
    4844        require_once 'plugins/addressbook/rcube_contacts_' . $CONFIG['addressbook_plugin'] . '.inc'; 
    4945        $abook_class = 'rcube_contacts_' . $CONFIG['addressbook_plugin']; 
     
    6359// set list properties and session vars 
    6460if (!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 { 
    6963    $CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1); 
    7064} 
     
    7569    $CONTACTS->set_search_set($_SESSION['search'][$_REQUEST['_search']]); 
    7670} 
     71 
    7772// set data source env 
    7873$OUTPUT->set_env('source', $source ? $source : '0'); 
     
    8580} 
    8681$OUTPUT->set_env('address_sources', $js_list); 
    87  
    8882 
    8983function rcmail_directory_list($attrib) 
     
    155149} 
    156150 
    157  
    158151/** 
    159152 * return the message list as HTML table 
  • branches/devel-vnext/program/steps/addressbook/mailto.inc

    r806 r962  
    1616 +-----------------------------------------------------------------------+ 
    1717 
    18  $Id: copy.inc 471 2007-02-09 21:25:50Z thomasb $ 
     18 $Id: mailto.inc 471 2007-02-09 21:25:50Z thomasb $ 
    1919 
    2020*/ 
     
    2828$mailto     = array(); 
    2929 
    30 if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && $CONTACTS->ready) { 
     30if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) 
     31        && $CONTACTS->ready) { 
    3132    $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid); 
    3233 
     
    3839if (!empty($mailto)) { 
    3940    $mailto_str = join(', ', $mailto); 
    40     $mailto_id = substr(md5($mailto_str), 0, 16); 
     41    $mailto_id  = substr(md5($mailto_str), 0, 16); 
     42     
    4143    $_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 { 
    4549    $OUTPUT->show_message('nocontactsfound', 'warning'); 
    4650} 
  • branches/devel-vnext/program/steps/addressbook/save.inc

    r806 r962  
    3232 
    3333// 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 ) { 
     34if (( 
     35        !rcube::get_input_value('_name', rcube::INPUT_POST) 
     36    || !rcube::get_input_value('_email', rcube::INPUT_POST) 
     37    ) && $_framed) { 
    4138    $OUTPUT->show_message('formincomplete', 'warning'); 
    4239    rcube::override_action(empty($_POST['_cid']) ? 'add' : 'show'); 
     
    7774        $OUTPUT->show_message('successfullysaved', 'confirmation');     
    7875        rcube::override_action('show'); 
    79     } 
    80     else { 
     76    } else { 
    8177        // show error message 
    8278        $OUTPUT->show_message('errorsaving', 'error'); 
    8379        rcube::override_action('show'); 
    8480    } 
    85 } 
    86 // insert a new contact 
    87 else { 
     81} else { // insert a new contact 
    8882    // 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); 
    9087   
    9188    // show warning message 
     
    115112        rcube::override_action('show'); 
    116113        $_GET['_cid'] = $insert_id; 
    117     } 
    118     else { 
     114    } else { 
    119115        // show error message 
    120116        $OUTPUT->show_message('errorsaving', 'error'); 
     
    122118    } 
    123119} 
    124 ?> 
  • branches/devel-vnext/program/steps/error.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
  • branches/devel-vnext/program/steps/mail/addcontact.inc

    r806 r962  
    7171 
    7272        // check for existing contacts 
    73         $existing = $CONTACTS->search('email', $contact['email'], false); 
     73        $existing = $CONTACTS->search('email', $contact['email'], true, false); 
    7474        if ($done = $existing->count) { 
    7575            $OUTPUT->show_message('contactexists', 'warning'); 
  • branches/devel-vnext/program/steps/mail/check_recent.inc

    r806 r962  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
     
    3232    if ($mbox_name == $IMAP->get_mailbox_name()) { 
    3333        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); 
    3641            $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); 
    3742 
    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); 
    4045            $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 
    4146            $OUTPUT->command('set_quota', $IMAP->get_quota()); 
     
    4348            // add new message headers to list 
    4449            $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                 
    4657                $header = $IMAP->get_headers($id, NULL, FALSE); 
    4758                if ($header->recent) { 
     
    5162            rcmail_js_message_list($a_headers, TRUE); 
    5263        } 
    53     } 
    54     else { 
     64    } else { 
    5565        if ($IMAP->messagecount($mbox_name, 'RECENT')) { 
    5666            $OUTPUT->command( 
     
    6373} 
    6474$OUTPUT->send(); 
    65 ?> 
  • branches/devel-vnext/program/steps/mail/compose.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    4646} 
    4747 
    48 // this version does not support HTML mails 
    49 $CONFIG['htmleditor'] = false; 
    50 $CONFIG = $registry->set('CONFIG', $CONFIG, 'core'); 
    51  
     48if ($_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} 
    5258 
    5359$MESSAGE_FORM = $registry->set('MESSAGE_FORM', NULL, 'core'); 
     
    117123        $_SESSION['compose']['reply_uid']   = $msg_uid; 
    118124        $_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); 
    122126 
    123127        if (!empty($_GET['_all'])) { 
     
    141145// register UI objects 
    142146$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    ) 
    153158); 
    154159 
     
    160165    $abook_class = 'rcube_contacts_' . $CONFIG['addressbook_plugin']; 
    161166    $CONTACTS = new $abook_class ( 
    162                         $_SESSION['username'], 
    163                         $_SESSION['password'] 
     167        $_SESSION['username'], 
     168        $_SESSION['password'] 
    164169    ); 
    165 } 
    166 else { 
     170} else { 
    167171    $DB = $registry->get('DB', 'core'); 
    168172 
    169     $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']); 
     173    $CONTACTS = new rcube_contacts($DB, $USER->ID); 
    170174    $CONTACTS->set_pagesize(1000); 
    171175} 
  • branches/devel-vnext/program/steps/mail/folders.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    4242 
    4343        return; 
    44     } 
    45     else { 
     44    } else { 
    4645        $commands = "// expunged: $success\n"; 
    4746    } 
    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 
    5149    $success = $IMAP->clear_mailbox($mbox); 
    5250 
     
    5755        $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 
    5856        $OUTPUT->command('set_unread_count', $mbox_name, 0); 
    59     } 
    60     else { 
     57    } else { 
    6158        $commands = "// purged: $success"; 
    6259    } 
  • branches/devel-vnext/program/steps/mail/func.inc

    r806 r962  
    2222require_once 'lib/html2text.inc'; 
    2323require_once 'lib/enriched.inc'; 
    24  
     24require_once 'include/rcube_smtp.inc'; 
    2525 
    2626$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; 
     
    3636// set imap properties and session vars 
    3737if ($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)); 
    4039} 
    4140 
    4241if (!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']))); 
    4543} 
    4644 
     
    5755} 
    5856// set message set for search result 
    59 if ( 
    60     !empty($_REQUEST['_search']) 
    61     && isset($_SESSION['search'][$_REQUEST['_search']]) 
    62 ) { 
     57if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) { 
    6358    $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]); 
    6459} 
     
    9085} 
    9186if (!$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('&nbsp;', $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 
     91if (empty($_action) || $_action == 'list') { 
     92    $OUTPUT->set_pagetitle( 
     93        rcube::charset_convert($IMAP->get_mailbox_name(), 'UTF-7')); 
     94} 
    36795 
    36896/** 
     
    404132    // allow the following attributes to be added to the <table> tag 
    405133    $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        ) 
    412140    ); 
    413141 
     
    422150 
    423151    // 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']) 
    426153        && ($f = array_search('from', $a_show_cols)) 
    427154        && !array_search('to', $a_show_cols) 
     
    454181        if ($IMAP->get_capability('sort') && in_array($col, $a_sort_cols)) { 
    455182            // have buttons configured 
    456             if ( 
    457                 !empty($attrib['sortdescbutton']) 
    458                 || !empty($attrib['sortascbutton']) 
    459             ) { 
     183            if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton'])) { 
    460184                $sort = '&nbsp;&nbsp;'; 
    461185 
     
    463187                if (!empty($attrib['sortascbutton'])) { 
    464188                    $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')); 
    473195                } 
    474196 
     
    476198                if (!empty($attrib['sortdescbutton'])) { 
    477199                    $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')); 
    483205                } 
    484             } 
    485             // just add a link tag to the header 
    486             else { 
     206            } else { // just add a link tag to the header 
    487207                $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_name 
     208                    '<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 
    493213                ); 
    494214            } 
     
    507227 
    508228    // 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    } 
    516232 
    517233    $a_js_message_arr = array(); 
     
    733449 
    734450    // 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 
    737453        $a_msg_cols = array(); 
    738454        $a_msg_flags = array(); 
     455 
     456        if (empty($header)) { 
     457            continue; 
     458        } 
    739459 
    740460        // format each col; similar as in rcmail_message_list() 
     
    742462            if ($col=='from' || $col=='to') { 
    743463                $cont = Q(rcmail_address_string($header->$col, 3), 'show'); 
    744             } 
    745             elseif ($col=='subject') { 
     464            } elseif ($col == 'subject') { 
    746465                $action    = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; 
    747466                $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draf_uid' : '_uid'; 
     
    751470                } 
    752471                $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                             $cont 
     472                    '<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 
    759478                ); 
    760             } 
    761             elseif ($col=='size') { 
     479            } elseif ($col=='size') { 
    762480                $cont = show_bytes($header->$col); 
    763             } 
    764             elseif ($col=='date') { 
     481            } elseif ($col=='date') { 
    765482                $cont = rcube::format_date($header->date); 
    766             } 
    767             else { 
     483            } else { 
    768484                $cont = Q($header->$col); 
    769485            } 
     
    775491        $a_msg_flags['replied'] = $header->answered ? 1 : 0; 
    776492        $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_top 
     493            '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 
    783499        ); 
    784500    } 
    785501} 
    786  
    787502 
    788503// return an HTML iframe for loading mail content 
     
    792507    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    793508 
    794     if (empty($attrib['id'])) 
     509    if (empty($attrib['id'])) { 
    795510        $attrib['id'] = 'rcmailcontentwindow'; 
    796  
     511    } 
     512     
    797513    // allow the following attributes to be added to the <iframe> tag 
    798514    $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') 
    801517    ); 
    802518    $framename = $attrib['id']; 
    803519 
    804520    $out = sprintf( 
    805                 '<iframe name="%s"%s></iframe>'."\n", 
    806                 $framename, 
    807                 $attrib_str 
     521        '<iframe name="%s"%s></iframe>'."\n", 
     522        $framename, 
     523        $attrib_str 
    808524    ); 
    809525 
     
    821537    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    822538 
    823     if (!$attrib['id']) 
     539    if (!$attrib['id']) { 
    824540        $attrib['id'] = 'rcmcountdisplay'; 
    825  
     541    } 
     542     
    826543    $OUTPUT->add_gui_object('countdisplay', $attrib['id']); 
    827544 
    828545    // allow the following attributes to be added to the <span> tag 
    829546    $attrib_str = rcube::create_attrib_string($attrib, array('style', 'class', 'id')); 
    830  
    831547 
    832548    $out = '<span' . $attrib_str . '>'; 
     
    843559    $OUTPUT    = $registry->get('OUTPUT', 'core'); 
    844560 
    845     if (!$attrib['id']) 
     561    if (!$attrib['id']) { 
    846562        $attrib['id'] = 'rcmquotadisplay'; 
    847  
     563    } 
     564     
    848565    $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); 
    849566 
     
    857574} 
    858575 
    859  
    860576function rcmail_quota_content($display) 
    861577{ 
     
    866582    if (!$IMAP->get_capability('QUOTA')) { 
    867583        $quota_text = rcube::gettext('unknown'); 
    868     } 
    869     elseif ($quota = $IMAP->get_quota()) { 
     584    } elseif ($quota = $IMAP->get_quota()) { 
    870585        $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"] 
    875590        ); 
    876591 
     
    879594            $attrib = array('width' => 100, 'height' => 14); 
    880595            $quota_text = sprintf( 
    881                             '<img src="./bin/quotaimg.php?u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', 
    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&amp;q=%d&amp;w=%d&amp;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 { 
    891605        $quota_text = rcube::gettext('unlimited'); 
    892606    } 
    893607    return $quota_text; 
    894608} 
    895  
    896609 
    897610function rcmail_get_messagecount_text($count=NULL, $page=NULL) 
     
    903616    if (isset($MESSAGE['index'])) { 
    904617        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            ) 
    912625        ); 
    913626    } 
    914627 
    915     if ($page===NULL) { 
     628    if ($page === NULL) { 
    916629        $page = $IMAP->list_page; 
    917630    } 
    918631    $start_msg = ($page-1) * $IMAP->page_size + 1; 
    919     $max = $count!==NULL ? $count : $IMAP->messagecount(); 
     632    $max       = $count!==NULL ? $count : $IMAP->messagecount(); 
    920633 
    921634    if ($max==0) { 
    922635        $out = rcube::gettext('mailboxempty'); 
    923     } 
    924     else { 
     636    } else { 
    925637        $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))); 
    929641    } 
    930642    return Q($out); 
    931643} 
    932  
    933644 
    934645function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) 
     
    957668        // remove remote images and scripts 
    958669        $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' 
    966677        ); 
    967678 
    968679        $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            ''); 
    976687 
    977688        // set flag if message containes remote obejcts that where blocked 
     
    980691                $REMOTE_OBJECTS = TRUE; 
    981692                $registry->set( 
    982                         'REMOTE_OBJECTS', 
    983                         $REMOTE_OBJECTS, 
    984                         'core' 
     693                    'REMOTE_OBJECTS', 
     694                    $REMOTE_OBJECTS, 
     695                    'core' 
    985696                ); 
    986697                break; 
     
    1014725    if ($part->ctype_parameters['format'] != 'flowed') { 
    1015726        $body = wordwrap(trim($body), 80); 
    1016     } 
    1017     else { 
     727    } else { 
    1018728        /** 
    1019729         * @author Till Klampaeckel <till@php.net> 
     
    1055765    // insert the links for urls and mailtos 
    1056766    $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) 
    1060770    ); 
    1061771    return '<div class="pre">' . $body . "\n</div>"; 
     
    1123833        $structure->type = 'content'; 
    1124834        $a_return_parts[] = &$structure; 
    1125     } 
    1126  
    1127     // message contains alternative parts 
    1128     else if ( 
     835    } else if ( // message contains alternative parts 
    1129836        $message_ctype_primary=='multipart' 
    1130837        && $message_ctype_secondary=='alternative' 
     
    1135842 
    1136843        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); 
    1138846            $sub_ctype_secondary = strtolower($sub_part->ctype_secondary); 
    1139847 
    1140848            // 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') { 
    1142850                $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') { 
    1144852                $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') { 
    1146854                $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')) { 
    1148856                $related_part = $p; 
     857            } 
    1149858        } 
    1150859 
    1151860        // 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); 
    1155863            $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 
    1159871            $print_part = &$structure->parts[$html_part]; 
    1160         } 
    1161         else if (is_null($enriched_part) !== TRUE) { 
     872        } else if ($enriched_part !== null) { 
    1162873            $print_part = &$structure->parts[$enriched_part]; 
    1163         } 
    1164         else if (is_null($plain_part) !== TRUE) { 
     874        } else if ($plain_part !== null) { 
    1165875            $print_part = &$structure->parts[$plain_part]; 
    1166876        } 
     877         
    1167878        // show message body 
    1168879        if (is_object($print_part)) { 
     880             
    1169881            $print_part->type = 'content'; 
    1170882            $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 
    1174887            $c = new stdClass; 
    1175888            $c->type = 'content'; 
     
    1206919            // part text/[plain|html] OR message/delivery-status 
    1207920            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') 
    1213923                || 
    1214                 ($primary_type=='message' && $secondary_type=='delivery-status') 
     924                ($primary_type=='message' 
     925                && ($secondary_type=='delivery-status' || $secondary_type=='disposition-notification')) 
    1215926            ) { 
    1216927                $mail_part->type  = 'content'; 
     
    1248959                    ); 
    1249960                    $sa_inline_objects[] = $mail_part; 
    1250                 } 
    1251                 // is regular attachment 
    1252                 else { 
     961                } else { 
     962                    // is regular attachment 
    1253963                    if (!$mail_part->filename) { 
    1254                         $mail_part->filename = 'file_' . $mail_part->mime_id; 
     964                        $mail_part->filename = 'Part ' . $mail_part->mime_id; 
    1255965                    } 
    1256966                    $a_attachments[] = $mail_part; 
     
    1260970 
    1261971        // 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) { 
    1263973            $a_replaces = array(); 
    1264974 
    1265975            foreach ($sa_inline_objects as $inline_object) { 
    1266976                $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                    )); 
    1272981            } 
    1273982            // add replace array to each content part 
     
    13381047        if ($hkey=='date' && empty($headers[$hkey]) === false) { 
    13391048            $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 { 
    13421056            $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                ) 
    13571061            ); 
    13581062        } 
     
    13951099        $attrib['id'] = 'rcmailMsgBody'; 
    13961100    } 
    1397     $safe_mode = (bool)$_GET['_safe']; 
     1101    $safe_mode  = intval($_GET['_safe']); 
    13981102    $attrib_str = rcube::create_attrib_string($attrib, array('style', 'class', 'id')); 
    1399     $out = '<div '. $attrib_str . ">\n"; 
     1103    $out        = '<div '. $attrib_str . ">\n"; 
    14001104 
    14011105    $header_attrib = array(); 
     
    14081112    // this is an ecrypted message 
    14091113    // -> 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') { 
    14111115        $p = new stdClass; 
    14121116        $p->type = 'content'; 
     
    14451149            } 
    14461150        } 
    1447     } 
    1448     else { 
     1151    } else { 
    14491152        $out .= $MESSAGE['body']; 
    14501153    } 
     
    14541157 
    14551158    // list images after mail body 
    1456     if ( 
    1457         get_boolean($attrib['showimages']) 
     1159    if (get_boolean($attrib['showimages']) 
    14581160        && $ctype_primary=='multipart' 
    1459         && $ctype_secondary=='mixed' 
    1460         && sizeof($MESSAGE['attachments']) 
     1161        && !empty($MESSAGE['attachments']) 
    14611162        && !strstr($message_body, '<html') 
    1462         && strlen($GET_URL) 
    1463     ) { 
     1163        && strlen($GET_URL)) { 
    14641164        foreach ($MESSAGE['attachments'] as $attach_prop) { 
    14651165            if (strpos($attach_prop->mimetype, 'image/')===0) { 
     
    14921192    $body = preg_replace('/\x00/', '', $body); 
    14931193 
     1194    $base_url       = ''; 
    14941195    $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    } 
    14961203 
    14971204    // find STYLE tags 
     
    15011208 
    15021209        // 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); 
    15041214 
    15051215        $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); 
     
    15111221    // remove SCRIPT tags 
    15121222    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)))) 
    15141224        { 
    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             
    15171228            $body_lc = strtolower($body); 
    15181229        } 
     
    15271238 
    15281239    // 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) { 
    15321241        $body = preg_replace('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Uie', "'\\1=\"'.make_absolute_url('\\3', '$base_url').'\"'", $body); 
    15331242        $body = preg_replace('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Uie', "'\\1\''.make_absolute_url('\\3', '$base_url').'\')'", $body); 
     
    15361245 
    15371246    // 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); 
    15391250 
    15401251    // add comments arround html and other tags 
     
    15501261 
    15511262    $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); 
    15621266 
    15631267    // quote <? of php and xml files that are specified as text/html 
     
    15671271} 
    15681272 
    1569  
    15701273// 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:')) { 
     1274function 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'] .= "&amp;c=" . urlencode($container_id); 
     1282    } else if (stristr((string)$attrib['href'], 'mailto:')) { 
    15771283        $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}!='#') { 
    15841288        $attrib['target'] = '_blank'; 
    15851289    } 
    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} 
    16351297 
    16361298function rcmail_has_html_part($message_parts) 
     
    16401302   } 
    16411303   // check all message parts 
    1642    foreach ($message_parts as $pid => $part) 
    1643    { 
     1304   foreach ($message_parts as $pid => $part) { 
    16441305      $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary); 
    1645       if ($mimetype=='text/html') 
    1646       { 
     1306      if ($mimetype == 'text/html') { 
    16471307         return TRUE; 
    16481308      } 
    16491309   } 
    1650  
    16511310   return FALSE; 
    16521311} 
     
    16971356        if ($mimetype=='text/plain') { 
    16981357            return $IMAP->get_message_part($message_struct['UID'], $pid, $part); 
    1699         } 
    1700         else if ($mimetype=='text/html') { 
     1358        } else if ($mimetype=='text/html') { 
    17011359            $html_part = $IMAP->get_message_part($message_struct['UID'], $pid, $part); 
    17021360 
     
    17121370    return FALSE; 
    17131371} 
    1714  
    17151372 
    17161373// decode address string and re-format it as HTML links 
     
    17381395        if ($PRINT_MODE) { 
    17391396            $out .= sprintf('%s &lt;%s&gt;', Q($part['name']), $part['mailto']); 
    1740         } 
    1741         elseif (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { 
     1397        } elseif (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { 
    17421398            $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'])); 
    17491405            if ($addicon) { 
    17501406                $out .= sprintf( 
    1751                             '&nbsp;<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                             $addicon 
     1407                    '&nbsp;<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 
    17571413                ); 
    17581414            } 
    1759         } 
    1760         else { 
     1415        } else { 
    17611416            if ($part['name']) { 
    17621417                $out .= Q($part['name']); 
     
    17781433    return $out; 
    17791434} 
    1780  
    17811435 
    17821436function rcmail_message_part_controls() 
     
    17871441    $MESSAGE  = $registry->get('MESSAGE', 'core'); 
    17881442 
    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']) 
    17921445        || !($_GET['_uid'] && $_GET['_part']) 
    1793         || !$MESSAGE['parts'][$_GET['_part']] 
    1794     ) { 
     1446        || !$MESSAGE['parts'][$part]) { 
    17951447        return ''; 
    17961448    } 
    1797     $part = &$MESSAGE['parts'][$_GET['_part']]; 
     1449     
     1450    $part = &$MESSAGE['parts'][$part]; 
    17981451 
    17991452    $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        )); 
    18111463    $out = '<table '. $attrib_str . ">\n"; 
    18121464 
    18131465    if ($filename) { 
    18141466        $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'))); 
    18201472    } 
    18211473 
    18221474    if ($part->size) { 
    18231475        $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) 
    18271479        ); 
    18281480    } 
     
    18301482 
    18311483    return $out; 
    1832   } 
    1833  
    1834  
     1484} 
    18351485 
    18361486function rcmail_message_part_frame($attrib) 
     
    18391489    $MESSGAGE = $registry->get('MESSAGE', 'core'); 
    18401490 
    1841     $part = $MESSAGE['parts'][$_GET['_part']]; 
     1491    $part = $MESSAGE['parts'][asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))]; 
     1492     
    18421493    $ctype_primary = strtolower($part->ctype_primary); 
    18431494 
    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     
    18501497    $attrib_str = rcube::create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height')); 
    18511498    $out = '<iframe '. $attrib_str . "></iframe>"; 
    18521499 
    1853   return $out; 
    1854   } 
    1855  
     1500    return $out; 
     1501} 
     1502 
     1503/** 
     1504 * Send the given message compose object using the configured method 
     1505 */ 
     1506function 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} 
    18561562 
    18571563// clear message composing settings 
     
    18711577} 
    18721578 
    1873  
    18741579// register UI objects 
    18751580$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  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2828 
    2929    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).'">'; 
    3131    echo "\n</head>\n<body>"; 
    3232    echo $message; 
     
    4949    rcube::parse_template('messagepart'); 
    5050    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)) { 
    5352    if ($part = $MESSAGE['parts'][$pid]) { 
    5453        $ctype_primary = strtolower($part->ctype_primary); 
     
    6564            header("Cache-Control: private", false); 
    6665            header("Content-Type: application/octet-stream"); 
    67         } 
    68         else { 
     66        } else { 
    6967            header("Content-Type: $mimetype"); 
    7068        } 
     
    10098            } 
    10199            $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 { 
    105102            header( 
    106103                sprintf( 
    107104                    'Content-Disposition: %s; filename="%s";', 
    108                     $part->disposition ? $part->disposition : 'attachment', 
     105                    $_GET['_download'] ? 'attachment' : 'inline', 
    109106                    $part->filename ? $part->filename : "roundcube.$ctype_secondary" 
    110107                ) 
     
    112109 
    113110            // 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); 
    115112        } 
    116113        exit; 
    117114    } 
    118 } 
    119 // print message 
    120 else { 
     115} else { // print message 
    121116    $ctype_primary = strtolower($MESSAGE['structure']->ctype_primary); 
    122117    $ctype_secondary = strtolower($MESSAGE['structure']->ctype_secondary); 
     
    128123    $cont = ''; 
    129124    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        ) 
    135130    ); 
    136131 
  • branches/devel-vnext/program/steps/mail/getunread.inc

    r623 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
  • branches/devel-vnext/program/steps/mail/list.inc

    r806 r962  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
     
    4545 
    4646// fetch message headers 
    47 if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) { 
     47if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) { 
    4848    $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); 
    4949} 
     50$count  = $IMAP->messagecount($mbox_name); 
    5051$unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh'])); 
    5152 
     
    6263if (isset($a_headers) && count($a_headers)) { 
    6364    rcmail_js_message_list($a_headers); 
     65} else { 
     66    $OUTPUT->show_message('nomessagesfound', 'notice'); 
    6467} 
    65  
    6668// send response 
    6769$OUTPUT->send(); 
    68 ?> 
  • branches/devel-vnext/program/steps/mail/move_del.inc

    r806 r962  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
     
    2323$OUTPUT   = $registry->get('OUTPUT', 'core'); 
    2424 
     25// count messages before changing anything 
     26$old_count = $IMAP->messagecount(); 
     27$old_pages = ceil($old_count / $IMAP->page_size); 
     28 
    2529// move messages 
    2630if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) { 
     
    3842        exit; 
    3943    } 
    40 } 
    41 // delete messages 
    42 else if ($_action=='delete' && !empty($_POST['_uid'])) { 
     44} else if ($_action=='delete' && !empty($_POST['_uid'])) { // delete messages 
    4345    $count = sizeof(explode(',', ($uids = rcube::get_input_value('_uid', rcube::INPUT_POST)))); 
    4446    $del   = $IMAP->delete_message($uids, rcube::get_input_value('_mbox', rcube::INPUT_POST)); 
     
    5153        exit; 
    5254    } 
    53 } 
    54 // unknown action or missing query param 
    55 else { 
     55} else { // unknown action or missing query param 
    5656    //rcube::tfk_debug('/ unknown action'); 
    5757    exit; 
    5858} 
    5959 
    60 // refresh saved seach set after moving some messages 
     60// refresh saved seacrh set after moving some messages 
    6161if ( 
    6262    ($search_request = rcube::get_input_value('_search', rcube::INPUT_GPC)) 
    63     && $IMAP->search_set 
    64 ) { 
     63    && $IMAP->search_set) { 
    6564    $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 
    6665} 
    6766 
     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) 
     73if ($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 
    6879// update message count display 
    69 $msg_count = $IMAP->messagecount(); 
    70 $pages     = ceil($msg_count / $IMAP->page_size); 
    7180$OUTPUT->set_env('pagecount', $pages); 
     81$OUTPUT->set_env('current_page', $IMAP->list_page); 
    7282$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); 
    73  
    7483 
    7584// update mailboxlist 
     
    8392 
    8493// add new rows from next page (if any) 
    85 if ($_POST['_from'] != 'show' && $pages > 1 && $IMAP->list_page < $pages) { 
     94if ($_POST['_from'] != 'show' && ($jump_back || $nextpage_count > 0)) { 
    8695    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col']; 
    8796    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 
    8897 
    8998    $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    } 
    91102 
    92103    rcmail_js_message_list($a_headers); 
     
    95106// send response 
    96107$OUTPUT->send(); 
    97 ?> 
  • branches/devel-vnext/program/steps/mail/quotadisplay.inc

    r623 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
  • branches/devel-vnext/program/steps/mail/rss.inc

    r806 r962  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                      | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
     
    3636 
    3737$REMOTE_REQUEST = TRUE; 
    38 $OUTPUT_TYPE = 'rss'; 
     38$OUTPUT_TYPE    = 'rss'; 
    3939 
    4040$registry = rcube_registry::get_instance(); 
     
    4646  $webmail_url .= 's'; 
    4747} 
     48 
    4849$webmail_url .= '://'.$_SERVER['SERVER_NAME']; 
    49 if ($_SERVER['SERVER_PORT'] != '80') { 
     50if ($_SERVER['SERVER_PORT'] != '80') { 
    5051        $webmail_url .= ':'.$_SERVER['SERVER_PORT']; 
    5152} 
     53 
    5254$webmail_url .= '/'; 
    5355if (dirname($_SERVER['SCRIPT_NAME']) != '/') { 
     
    6466// Send global XML output 
    6567header('Content-type: text/xml'); 
    66 echo '<?xml version="1.0" encoding="UTF-8"?> 
    67         <rss version="2.0" 
     68echo '<?xml version="1.0" encoding="UTF-8"?>'; 
     69echo '<rss version="2.0" 
    6870         xmlns:dc="http://purl.org/dc/elements/1.1/" 
    6971         xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
     
    9193// Check if the user wants to override the default sortingmethode 
    9294if (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)); 
    9497} 
    9598 
     
    97100if ($messagecount > 0) { 
    98101    $items = $IMAP->list_headers('INBOX', null, $sort_col, $sort_order); 
    99     foreach ($items as $item) 
    100     { 
     102    foreach ($items as $item) { 
    101103 
    102104        // Convert '"name" <email>' to 'email (name)' 
  • branches/devel-vnext/program/steps/mail/search.inc

    r806 r962  
    3434if (preg_match("/^from:/i", $str)) { 
    3535    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)) { 
    4039    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)) { 
    4543    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)) { 
    5047    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)) { 
    5551    list(,$srch) = explode(":", $str); 
    56     $subject = "TEXT"; 
    57     $search = trim($srch); 
    58 } 
    59 // search in subject and sender by default 
    60 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); 
    6359} 
    6460 
     
    7268    // Get the headers 
    7369    $result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 
    74     $count = count($result_h); 
     70    $count    = $IMAP->messagecount(); 
    7571 
    7672    // save search results in session 
  • branches/devel-vnext/program/steps/mail/sendmail.inc

    r806 r962  
    3030$IMAP     = $registry->get('IMAP', 'core'); 
    3131 
    32 //require_once('lib/smtp.inc'); 
    33 require_once 'include/rcube_smtp.php'; 
    3432require_once 'lib/html2text.inc'; 
    35  
    3633 
    3734if (!isset($_SESSION['compose']['id'])) { 
     
    5148} 
    5249$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']) 
    5653); 
    5754$savedraft = ((empty($_POST['_draft']) === false) ? TRUE : FALSE); 
     
    7673 
    7774// set default charset 
    78 $input_charset = $OUTPUT->get_charset(); 
     75$input_charset   = $OUTPUT->get_charset(); 
    7976$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; 
    8077 
    81 $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/'); 
     78$mailto_regexp  = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/'); 
    8279$mailto_replace = array(', ', ', ', '', ','); 
    8380 
    8481// replace new lines and strip ending ', ' 
    8582$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) 
    8986); 
    9087 
     
    104101//rcube::tfk_debug('We got identity.'); 
    105102 
    106 $from = $identity_arr['mailto']; 
     103$from     = $identity_arr['mailto']; 
    107104$first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto; 
    108105 
     
    112109// compose headers array 
    113110$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'   => $mailto 
     111    '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 
    117114); 
    118115 
     
    120117if (!empty($_POST['_cc'])) { 
    121118    $headers['Cc'] = preg_replace( 
    122                         $mailto_regexp, 
    123                         $mailto_replace, 
    124                         rcube::get_input_value( 
    125                             '_cc', 
    126                             rcube::INPUT_POST, 
    127                             TRUE, $message_charset 
    128                         ) 
     119        $mailto_regexp, 
     120        $mailto_replace, 
     121        rcube::get_input_value( 
     122            '_cc', 
     123            rcube::INPUT_POST, 
     124            TRUE, $message_charset 
     125        ) 
    129126    ); 
    130127} 
    131128if (!empty($_POST['_bcc'])) { 
    132129    $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) 
    135132    ); 
    136133} 
    137134if (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']; 
    139136} 
    140137// add subject 
    141138$headers['Subject'] = trim( 
    142                         rcube::get_input_value( 
    143                             '_subject', 
    144                             rcube::INPUT_POST, 
    145                             FALSE, 
    146                             $message_charset 
    147                         ) 
     139    rcube::get_input_value( 
     140        '_subject', 
     141        rcube::INPUT_POST, 
     142        FALSE, 
     143        $message_charset 
     144    ) 
    148145); 
    149146 
     
    251248        return; 
    252249    } 
    253 } 
    254 else { 
     250} else { 
    255251    $message_body = wordwrap($message_body, 75, "\r\n"); 
    256252    $message_body = wordwrap($message_body, 998, "\r\n", true); 
     
    269265        } 
    270266        $status = $MAIL_MIME->addAttachment( 
    271                         $attachment['path'], 
    272                         $attachment['mimetype'], 
    273                         $attachment['name'], 
    274                         true, 
    275                         'base64', 
    276                         'attachment', 
    277                         $message_charset 
     267            $attachment['path'], 
     268            $attachment['mimetype'], 
     269            $attachment['name'], 
     270            true, 
     271            'base64', 
     272            'attachment', 
     273            $message_charset 
    278274        ); 
    279275        if (PEAR::isError($status)) { 
     
    289285    foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { 
    290286        $status = $MAIL_MIME->addAttachment( 
    291                         $filepath, 
    292                         $files['type'][$i], 
    293                         $files['name'][$i], 
    294                         true, 
    295                         'base64', 
    296                         'attachment', 
    297                         $message_charset 
     287            $filepath, 
     288            $files['type'][$i], 
     289            $files['name'][$i], 
     290            true, 
     291            'base64', 
     292            'attachment', 
     293            $message_charset 
    298294        ); 
    299295        if (PEAR::isError($status)) { 
     
    404400            ); 
    405401        } 
    406     } 
    407     else { // send mail using PHP's mail() function 
     402    } else { // send mail using PHP's mail() function 
    408403 
    409404        //rcube::tfk_debug('We try to send using mail().'); 
     
    428423                        $header_str 
    429424            ); 
    430         } 
    431         else { 
     425        } else { 
    432426            $sent = mail( 
    433427                        $headers_enc['To'], 
     
    454448if ($savedraft) { 
    455449    $store_target = 'drafts_mbox'; 
    456 } 
    457 else { 
     450} else { 
    458451  $store_target = 'sent_mbox'; 
    459452} 
     
    466459    if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes())) { 
    467460        $store_folder = $IMAP->create_mailbox($CONFIG[$store_target], TRUE); 
    468     } 
    469     else { 
     461    } else { 
    470462        $store_folder = TRUE; 
    471463    } 
     
    533525 
    534526    $OUTPUT->send('iframe'); 
    535 } 
    536 else { 
     527} else { 
    537528    if ($CONFIG['smtp_log'] === true) { 
    538529        $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) : '' 
    545536        ); 
    546537 
  • branches/devel-vnext/program/steps/mail/show.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    5252 
    5353    // 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); 
    5557 
    5658    // allow caching, unless remote images are present 
    5759    if ((bool)rcube::get_input_value('_safe', rcube::INPUT_GET)) { 
    5860        send_nocacheing_headers(); 
    59     } 
    60     else { 
     61    } else if (empty($CONFIG['devel_mode'])) { 
    6162        send_modified_header($_SESSION['login_time'], $etag); 
    6263    } 
    6364 
    6465    $MESSAGE['subject'] = rcube_imap::decode_mime_string( 
    65                                 $MESSAGE['headers']->subject, 
    66                                 $MESSAGE['headers']->charset 
     66        $MESSAGE['headers']->subject, 
     67        $MESSAGE['headers']->charset 
    6768    ); 
    6869    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     
    7172    if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID'])) { 
    7273        $_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            ) 
    7980        ); 
    8081        list($MESSAGE['parts'], $MESSAGE['attachments']) = $_message_parts; 
    81     } 
    82     else { 
     82    } else { 
    8383        $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 
    8484    } 
     
    9191    // give message uid to the client 
    9292    $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    } 
    9499 
    95100    $next = $prev = -1; 
  • branches/devel-vnext/program/steps/mail/spell.inc

    r806 r962  
    55 |                                                                       | 
    66 | This file is part of the RoundCube Webmail client                     | 
    7  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    88 | Licensed under the GNU GPL                                            | 
    99 |                                                                       | 
  • branches/devel-vnext/program/steps/mail/upload.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
  • branches/devel-vnext/program/steps/mail/viewsource.inc

    r806 r962  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
  • branches/devel-vnext/program/steps/settings/delete_identity.inc

    r806 r962  
    2020*/ 
    2121 
    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); 
    3123 
    32     $count = $DB->affected_rows(); 
    33     if ($count) { 
     24if ($ids && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids)) { 
     25    if ($USER->delete_identity($ids)) { 
    3426        $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); 
    3527    } 
     
    4537// go to identities page 
    4638rcube::override_action('identities'); 
    47 ?> 
  • branches/devel-vnext/program/steps/settings/edit_identity.inc

    r806 r962  
    2020 
    2121if (($_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)); 
    3324    $registry->set('IDENTITY_RECORD', $IDENTITY_RECORD, 'core'); 
    3425    if (is_array($IDENTITY_RECORD)) { 
     
    3627    } 
    3728    $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')); 
    4131} 
    4232$OUTPUT->include_script('list.js'); 
     
    4737    $IDENTITY_RECORD = $registry->get('IDENTITY_RECORD', 'core'); 
    4838    $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 
    6352    if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity') { 
    6453        return rcube::gettext('notfound'); 
     
    7059    unset($attrib['form']); 
    7160 
    72  
    7361    // list of available cols 
    7462    $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')); 
    8371 
    8472 
     
    9280                        $IDENTITY_RECORD[$attrib['part']], 
    9381                        $attrib, 
    94                         $colprop['type'] 
    95             ); 
     82                        $colprop['type']); 
    9683            return $out; 
    9784        } 
    98         else { 
    99             return ''; 
    100         } 
     85        return ''; 
    10186    } 
    102  
    10387 
    10488    // return the complete edit form as table 
     
    10690 
    10791    foreach ($a_show_cols as $col => $colprop) { 
    108         $attrib['id'] = 'rcmfd_'.$col; 
     92        $attrib['id'] = 'rcmfd_' . $col; 
    10993 
    11094        if (strlen($colprop['onclick'])) { 
    11195            $attrib['onclick'] = $colprop['onclick']; 
    112         } 
    113         else { 
     96        } else { 
    11497            unset($attrib['onclick']); 
    11598        } 
     
    119102            $attrib['rows'] = $colprop['rows']; 
    120103            $attrib['mce_editable'] = $IDENTITY_RECORD['html_signature'] ? "true" : "false"; 
    121         } 
    122         else { 
     104        } else { 
    123105            unset($attrib['size']); 
    124106            unset($attrib['rows']); 
     
    128110        $label = strlen($colprop['label']) ? $colprop['label'] : $col; 
    129111        $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']); 
    135116 
    136117        $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); 
    141122    } 
    142123    $out .= "\n</table>$form_end"; 
     
    151132} 
    152133rcube::parse_template('editidentity'); 
    153 ?> 
  • branches/devel-vnext/program/steps/settings/func.inc

    r956 r962  
    2020*/ 
    2121 
    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     ); 
     22if ($USER->ID) { 
     23        $OUTPUT->set_pagetitle( 
     24                rcube::gettext('settingsfor') . ' ' . $USER->get_username()); 
    3725} 
    38  
    3926 
    4027function rcmail_user_prefs_form($attrib) 
     
    176163 
    177164    // Show checkbox for HTML Editor 
    178     if (false && !isset($no_override['htmleditor'])) { 
     165    if (!isset($no_override['htmleditor'])) { 
    179166        $field_id = 'rcmfd_htmleditor'; 
    180167        $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); 
     
    188175 
    189176    // 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", 
    194187                    $field_id, 
    195188                    Q(rcube::gettext('previewpane')), 
     
    233226    $CONFIG   = $registry->get_all('config'); 
    234227    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    235  
     228        $USER     = $registry->get('USER', 'core'); 
    236229 
    237230    // 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"; 
    242235    $sql_result = $DB->query($_query, $_SESSION['user_id']); 
    243236 
    244237    $identities_data = array(); 
    245     /** 
    246      * macbay hack 
    247      */ 
    248238    while ($sql_result && ($sql_arr = $DB->fetch_assoc($sql_result))) { 
    249239        $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&ouml;schen" />'; 
    252240        $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" />'; 
    254241 
    255242        array_push($identities_data, $sql_arr); 
    256         //echo '<pre>'; var_dump($sql_arr); echo '</pre>'; 
    257     } 
    258     //exit; 
     243    } 
    259244 
    260245    // add id to message list table if not specified 
  • branches/devel-vnext/program/steps/settings/manage_folders.inc

    r806 r962  
    2727$IMAP     = $registry->get('IMAP', 'core'); 
    2828 
    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'); 
    3230 
    3331// subscribe to one or more mailboxes 
    3432if ($_action=='subscribe') { 
    3533    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); 
    3835    } 
    3936    if ($OUTPUT->ajax_call) { 
     
    4542else if ($_action=='unsubscribe') { 
    4643    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); 
    4945    } 
    5046    if ($OUTPUT->ajax_call) { 
    5147        $OUTPUT->remote_response('// unsubscribed'); 
    5248    } 
    53 } 
    54  
    55 // create a new mailbox 
    56 else if ($_action=='create-folder') { 
     49} else if ($_action=='create-folder') { // create a new mailbox 
    5750    if (!empty($_POST['_name'])) { 
    5851        $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 
    6354        ); 
    6455    } 
    6556    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('&nbsp;&nbsp;&nbsp;&nbsp;', $str); 
     64         
     65                $OUTPUT->command('add_folder_row', $create, $display_create); 
    7166        $OUTPUT->send(); 
    72     } 
    73     else if (!$create && $OUTPUT->ajax_call) { 
     67    } else if (!$create && $OUTPUT->ajax_call) { 
    7468        $OUTPUT->show_message('errorsaving', 'error'); 
    7569        $OUTPUT->remote_response(); 
     
    7872        $OUTPUT->show_message('errorsaving', 'error'); 
    7973    } 
    80 } 
    81  
    82 // rename a mailbox 
    83 else if ($_action=='rename-folder') { 
     74} else if ($_action=='rename-folder') { // rename a mailbox 
    8475    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(); 
    8581 
    8682        $oldname         = rcube::get_input_value('_folder_oldname', rcube::INPUT_POST); 
     
    9389    } 
    9490    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('&nbsp;&nbsp;&nbsp;&nbsp;', $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('&nbsp;&nbsp;&nbsp;&nbsp;', $level) . rcube::charset_convert($foldersplit[$level], 'UTF-7'); 
     104                                 
     105                                $OUTPUT->command('replace_folder_row', $mbox, $c_rename, $display_rename); 
     106                        } 
     107                } 
    101108        $OUTPUT->command('reset_folder_rename'); 
    102109        $OUTPUT->send(); 
    103     } 
    104     elseif (!$rename && $OUTPUT->ajax_call) { 
     110    } elseif (!$rename && $OUTPUT->ajax_call) { 
    105111        $OUTPUT->command('reset_folder_rename'); 
    106112        $OUTPUT->show_message('errorsaving', 'error'); 
     
    110116        $OUTPUT->show_message('errorsaving', 'error'); 
    111117    } 
    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 
    116122    if ($mboxes = rcube::get_input_value('_mboxes', rcube::INPUT_POST)) { 
    117123        $deleted = $IMAP->delete_mailbox(array($mboxes)); 
     
    120126    if ($OUTPUT->ajax_call && $deleted) { 
    121127        $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         
    122138        $OUTPUT->show_message('folderdeleted', 'confirmation'); 
    123139        $OUTPUT->send(); 
     
    187203    $a_unsubscribed = $IMAP->list_unsubscribed(); 
    188204    $a_subscribed   = $IMAP->list_mailboxes(); 
     205    $delimiter      = $IMAP->get_hierarchy_delimiter(); 
    189206    $a_js_folders   = array(); 
    190207  
     
    226243        $folder_js   = JQ($folder); 
    227244        $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('&nbsp;&nbsp;&nbsp;&nbsp;', $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; 
    236255        } 
    237256        if (strlen($folder_html) > 40) { 
     
    283302    $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']); 
    284303    $OUTPUT->set_env('subscriptionrows', $a_js_folders); 
    285  
     304        $OUTPUT->set_env('defaultfolders', $CONFIG['default_imap_folders']); 
     305        $OUTPUT->set_env('delimiter', $delimiter); 
     306         
    286307    return $out;   
    287308} 
  • branches/devel-vnext/program/steps/settings/save_identity.inc

    r806 r962  
    2323    exit; 
    2424} 
    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         
    3030$a_html_cols    = array('signature'); 
    3131$a_boolean_cols = array('standard', 'html_signature'); 
     
    3939} 
    4040 
     41$save_data = array(); 
     42foreach ($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} 
    4149 
    42 // update an existing contact 
     50// set "off" values for checkboxes that were not checked, and therefore 
     51// not included in the POST body. 
     52foreach ($a_boolean_cols as $col) { 
     53        $fname = '_' . $col; 
     54        if (!isset($_POST[$fname])) { 
     55                $save_data[$col] = 0; 
     56        } 
     57} 
     58 
    4359if ($_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) { 
    8865        $OUTPUT->show_message('successfullysaved', 'confirmation'); 
    8966 
     
    9572            // ... 
    9673        } 
    97     } 
    98     else if ($DB->is_error()) { 
     74    } else if ($DB->is_error()) { 
    9975        // show error message 
    10076        $OUTPUT->show_message('errorsaving', 'error'); 
     
    10278        return; 
    10379    } 
    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)) { 
    13382        $_GET['_iid'] = $insert_id; 
    13483 
     
    14089            // .... 
    14190        } 
    142     } 
    143     else { 
     91    } else { 
    14492        // show error message 
    14593        $OUTPUT->show_message('errorsaving', 'error'); 
     
    14997} 
    15098 
    151  
    15299// mark all other identities as 'not-default' 
    153100if ($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); 
    160102} 
    161103// go to next step 
  • branches/devel-vnext/program/steps/settings/save_prefs.inc

    r806 r962  
    4343    $a_user_prefs['pagesize'] = 10; 
    4444} 
    45 rcube::tfk_debug($a_user_prefs['pagesize']); 
    46 rcube::tfk_debug($CONFIG['max_pagesize']); 
     45 
    4746if (isset($CONFIG['max_pagesize']) && empty($CONFIG['max_pagesize']) !== TRUE) { 
    4847    if ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']) { 
     
    5756} 
    5857 
    59 if (rcube::save_user_prefs($a_user_prefs)) { 
     58// force min size 
     59if ($a_user_prefs['pagesize'] < 1) { 
     60        $a_user_prefs['pagesize'] = 10; 
     61} 
     62if (isset($CONFIG['max_pagesize']) 
     63        && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize'])) { 
     64        $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize']; 
     65} 
     66 
     67if ($USER->save_prefs($a_user_prefs)) { 
    6068    $OUTPUT->show_message('successfullysaved', 'confirmation'); 
    6169} 
Note: See TracChangeset for help on using the changeset viewer.