Changeset 623 in subversion


Ignore:
Timestamp:
Jun 20, 2007 11:22:40 AM (6 years ago)
Author:
till
Message:

+ switch from global to rc_registry is complete
+ more logging/debugging
+ many CS changes
+ put different functions into their own file

# todo: fix JS inclusion (probably in template class)

Location:
branches/devel-vnext
Files:
4 added
35 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-vnext/index.php

    r622 r623  
    5656$registry->set('s_mbstring_loaded', null, 'core'); 
    5757$registry->set('sa_languages', null, 'core'); 
     58$registry->set('MAIN_TASKS', $MAIN_TASKS, 'core'); 
    5859 
    5960/** 
     
    224225 
    225226$IMAP = $registry->get('IMAP', 'core'); 
    226 rc_main::tfk_debug(var_export($IMAP, true) . "\n\nIMAP LOADED."); 
     227//rc_main::tfk_debug(var_export($IMAP, true) . "\n\nIMAP LOADED."); 
    227228 
    228229// log in to imap server 
     
    294295$_name = ''; 
    295296 
     297rc_main::tfk_debug("testing: $_task / $_action"); 
     298 
    296299// include task specific files 
    297300if ($_task == 'mail') { 
     
    340343    // make sure the message count is refreshed 
    341344    $IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE); 
     345    $registry->set('IMAP', $IMAP, 'core'); 
    342346} 
    343347 
     
    401405    } 
    402406} 
     407 
     408rc_main::tfk_debug('We included?'); 
    403409 
    404410// parse main template 
  • branches/devel-vnext/program/include/bugs.inc

    r589 r623  
    2323// throw system error and show error page 
    2424function raise_error($arg=array(), $log=FALSE, $terminate=FALSE) 
    25   { 
    26   global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE; 
     25{ 
     26    $registry       = rc_registry::getInstance(); 
     27    $__page_content = $registry->get('registry', 'core'); 
     28    $CONFIG         = $registry->get('CONFIG', 'core'); 
     29    $OUTPUT         = $registry->get('OUTPUT', 'core'); 
     30    $ERROR_CODE     = $registry->get('ERROR_CODE', 'core'); 
     31    $ERROR_MESSAGE  = $registry->get('ERROR_MESSAGE', 'core'); 
    2732   
    2833  /* $arg keys: 
     
    3439  */ 
    3540 
    36   // report bug (if not incompatible browser) 
    37   if ($log && $arg['type'] && $arg['message']) 
    38     log_bug($arg); 
     41    // report bug (if not incompatible browser) 
     42    if ($log && $arg['type'] && $arg['message']) { 
     43        log_bug($arg); 
     44    } 
     45    // display error page and terminate script 
     46    if ($terminate) { 
     47        $ERROR_CODE    = $arg['code']; 
     48        $ERROR_MESSAGE = $arg['message']; 
    3949 
    40   // display error page and terminate script 
    41   if ($terminate) 
    42     { 
    43     $ERROR_CODE = $arg['code']; 
    44     $ERROR_MESSAGE = $arg['message']; 
    45     include("program/steps/error.inc"); 
    46     exit; 
     50        $registry->set('ERROR_CODE', $ERROR_CODE, 'core'); 
     51        $registry->set('ERROR_MESSAGE', $ERROR_MESSAGE, 'core'); 
     52 
     53        include 'program/steps/error.inc'; 
     54        exit; 
    4755    } 
    48   } 
     56} 
    4957 
    5058 
    5159// report error 
    5260function log_bug($arg_arr) 
    53   { 
    54   global $CONFIG, $INSTALL_PATH; 
    55   $program = $arg_arr['type']=='xpath' ? 'XPath' : strtoupper($arg_arr['type']); 
     61{ 
     62    $registry     = rc_registry::getInstance(); 
     63    $CONFIG       = $registry->get('CONFIG', 'core'); 
     64    $INSTALL_PATH = $registry->get('INSTALL_PATH', 'core'); 
    5665 
    57   // write error to local log file 
    58   if ($CONFIG['debug_level'] & 1) 
    59     { 
    60     $log_entry = sprintf("[%s] %s Error: %s in %s on line %d\n", 
    61                  date("d-M-Y H:i:s O", mktime()), 
    62                  $program, 
    63                  $arg_arr['message'], 
    64                  $arg_arr['file'], 
    65                  $arg_arr['line']); 
     66    $program = $arg_arr['type']=='xpath' ? 'XPath' : strtoupper($arg_arr['type']); 
     67 
     68    // write error to local log file 
     69    if ($CONFIG['debug_level'] & 1) { 
     70        $log_entry = sprintf( 
     71                        "[%s] %s Error: %s in %s on line %d\n", 
     72                        date('d-M-Y H:i:s O'), 
     73                        $program, 
     74                        $arg_arr['message'], 
     75                        $arg_arr['file'], 
     76                        $arg_arr['line'] 
     77        ); 
    6678                  
    67     if (empty($CONFIG['log_dir'])) 
    68       $CONFIG['log_dir'] = $INSTALL_PATH.'logs'; 
    69        
    70     // try to open specific log file for writing 
    71     if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a')) 
    72      
    73       { 
    74       fwrite($fp, $log_entry); 
    75       fclose($fp); 
    76       } 
    77     else 
    78       { 
    79       // send error to PHPs error handler 
    80       trigger_error($arg_arr['message']); 
    81       } 
     79        if (empty($CONFIG['log_dir'])) { 
     80            $CONFIG['log_dir'] = $INSTALL_PATH.'logs'; 
     81            $registry->set('CONFIG', $CONFIG, 'core'); 
     82        } 
     83 
     84        // try to open specific log file for writing 
     85        if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a')) { 
     86            fwrite($fp, $log_entry); 
     87            fclose($fp); 
     88        } 
     89        else { 
     90            // send error to PHPs error handler 
     91            trigger_error($arg_arr['message']); 
     92        } 
    8293    } 
    8394 
    84 /* 
    85   // resport the bug to the global bug reporting system 
    86   if ($CONFIG['debug_level'] & 2) 
    87     { 
    88     $delm = '%AC'; 
    89     http_request(sprintf('http://roundcube.net/log/bug.php?_type=%s&_domain=%s&_server_ip=%s&_client_ip=%s&_useragent=%s&_url=%s%%3A//%s&_errors=%s%s%s%s%s', 
    90                  $arg_arr['type'], 
    91                  $GLOBALS['HTTP_HOST'], 
    92                  $GLOBALS['SERVER_ADDR'], 
    93                  $GLOBALS['REMOTE_ADDR'], 
    94                  rawurlencode($GLOBALS['HTTP_USER_AGENT']), 
    95                          $GLOBALS['SERVER_PORT']==43 ? 'https' : 'http', 
    96                          $GLOBALS['HTTP_HOST'].$GLOBALS['REQUEST_URI'], 
    97                          $arg_arr['file'], $delm, 
    98                  $arg_arr['line'], $delm, 
    99                  rawurlencode($arg_arr['message']))); 
     95    /* 
     96    // resport the bug to the global bug reporting system 
     97    if ($CONFIG['debug_level'] & 2) { 
     98        $delm = '%AC'; 
     99        http_request( 
     100            sprintf( 
     101                'http://roundcube.net/log/bug.php?_type=%s&_domain=%s&_server_ip=%s&_client_ip=%s&_useragent=%s&_url=%s%%3A//%s&_errors=%s%s%s%s%s', 
     102                $arg_arr['type'], 
     103                $GLOBALS['HTTP_HOST'], 
     104                $GLOBALS['SERVER_ADDR'], 
     105                $GLOBALS['REMOTE_ADDR'], 
     106                rawurlencode($GLOBALS['HTTP_USER_AGENT']), 
     107                        $GLOBALS['SERVER_PORT']==43 ? 'https' : 'http', 
     108                        $GLOBALS['HTTP_HOST'].$GLOBALS['REQUEST_URI'], 
     109                        $arg_arr['file'], $delm, 
     110                $arg_arr['line'], $delm, 
     111                rawurlencode($arg_arr['message']) 
     112            ) 
     113        ); 
    100114    } 
    101 */ 
     115    */ 
    102116 
    103   // show error if debug_mode is on 
    104   if ($CONFIG['debug_level'] & 4) 
    105     { 
    106     print "<b>$program Error"; 
     117    // show error if debug_mode is on 
     118    if ($CONFIG['debug_level'] & 4) { 
     119        echo "<b>$program Error"; 
    107120 
    108     if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) 
    109       print " in $arg_arr[file] ($arg_arr[line])"; 
     121        if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) { 
     122            echo " in {$arg_arr['file']} ({$arg_arr['line']})"; 
     123        } 
    110124 
    111     print ":</b>&nbsp;"; 
    112     print nl2br($arg_arr['message']); 
    113     print '<br />'; 
    114     flush(); 
     125        echo ':</b>&nbsp;'; 
     126        echo nl2br($arg_arr['message']); 
     127        echo '<br />'; 
     128        flush(); 
    115129    } 
    116   } 
    117  
     130} 
    118131?> 
  • branches/devel-vnext/program/include/cache.inc

    r589 r623  
    2222 
    2323function rcube_read_cache($key) 
    24   { 
    25   global $DB, $CACHE_KEYS; 
    26    
    27   // query db 
    28   $sql_result = $DB->query("SELECT cache_id, data 
    29                             FROM ".get_table_name('cache')." 
    30                             WHERE  user_id=? 
    31                             AND    cache_key=?", 
    32                             $_SESSION['user_id'], 
    33                             $key); 
     24{ 
     25    $registry   = rc_registry::getInstance(); 
     26    $DB         = $registry->get('DB', 'core'); 
     27    $CACHE_KEYS = $registry->get('CACHE_KEYS', 'core'); 
    3428 
    35   // get cached data 
    36   if ($sql_arr = $DB->fetch_assoc($sql_result)) 
    37     { 
    38     $data = $sql_arr['data']; 
    39     $CACHE_KEYS[$key] = $sql_arr['cache_id']; 
     29    // query db 
     30    $_query = "SELECT cache_id, data"; 
     31    $_query.= " FROM " . rc_main::get_table_name('cache'); 
     32    $_query.= " WHERE user_id=?"; 
     33    $_query.= " AND cache_key=?"; 
     34    $sql_result = $DB->query($_query, $_SESSION['user_id'], $key); 
     35 
     36    // get cached data 
     37    if ($sql_arr = $DB->fetch_assoc($sql_result)) { 
     38        $data = $sql_arr['data']; 
     39        $CACHE_KEYS[$key] = $sql_arr['cache_id']; 
    4040    } 
    41   else 
    42     $data = FALSE; 
    43  
    44   return $data; 
    45   } 
     41    else { 
     42        $data = FALSE; 
     43    } 
     44    $registry->set('CACHE_KEYS', $CACHE_KEYS, 'core'); 
     45    return $data; 
     46} 
    4647 
    4748 
    4849function rcube_write_cache($key, $data, $session_cache=FALSE) 
    49   { 
    50   global $DB, $CACHE_KEYS, $sess_id; 
    51    
    52   // check if we already have a cache entry for this key 
    53   if (!isset($CACHE_KEYS[$key])) 
    54     { 
    55     $sql_result = $DB->query("SELECT cache_id 
    56                               FROM ".get_table_name('cache')." 
    57                               WHERE  user_id=? 
    58                               AND    cache_key=?", 
    59                               $_SESSION['user_id'], 
    60                               $key); 
    61                                       
    62     if ($sql_arr = $DB->fetch_assoc($sql_result)) 
    63       $CACHE_KEYS[$key] = $sql_arr['cache_id']; 
    64     else 
    65       $CACHE_KEYS[$key] = FALSE; 
     50{ 
     51    $registry   = rc_registry::getInstance(); 
     52    $DB         = $registry->get('DB', 'core'); 
     53    $CACHE_KEYS = $registry->get('CACHE_KEYS', 'core'); 
     54    $sess_id    = $registry->get('sess_id', 'core'); 
     55 
     56    // check if we already have a cache entry for this key 
     57    if (!isset($CACHE_KEYS[$key])) { 
     58        $_query = "SELECT cache_id"; 
     59        $_query.= " FROM " . rc_main::get_table_name('cache'); 
     60        $_query.= " WHERE user_id=?"; 
     61        $_query.= " AND cache_key=?"; 
     62        $sql_result = $DB->query($_query, $_SESSION['user_id'], $key); 
     63 
     64        if ($sql_arr = $DB->fetch_assoc($sql_result)) { 
     65            $CACHE_KEYS[$key] = $sql_arr['cache_id']; 
     66        } 
     67        else { 
     68            $CACHE_KEYS[$key] = FALSE; 
     69        } 
     70        $registry->set('CACHE_KEYS', $CACHE_KEYS, 'core'); 
    6671    } 
    6772 
    68   // update existing cache record 
    69   if ($CACHE_KEYS[$key]) 
    70     { 
    71     $DB->query("UPDATE ".get_table_name('cache')." 
    72                 SET    created=now(), 
    73                        data=? 
    74                 WHERE  user_id=? 
    75                 AND    cache_key=?", 
    76                 $data, 
    77                 $_SESSION['user_id'], 
    78                 $key); 
     73    // update existing cache record 
     74    if ($CACHE_KEYS[$key]) { 
     75        $_query = "UPDATE " . rc_main::get_table_name('cache'); 
     76        $_query.= " SET created=now(),"; 
     77        $_query.= " data=?"; 
     78        $_query.= " WHERE user_id=?"; 
     79        $_query.= " AND cache_key=?"; 
     80        $DB->query($_query, $data, $_SESSION['user_id'], $key); 
    7981    } 
    80   // add new cache record 
    81   else 
    82     { 
    83     $DB->query("INSERT INTO ".get_table_name('cache')." 
    84                 (created, user_id, session_id, cache_key, data) 
    85                 VALUES (now(), ?, ?, ?, ?)", 
     82    // add new cache record 
     83    else { 
     84        $_query = "INSERT INTO " . rc_main::get_table_name('cache'); 
     85        $_query.= " (created, user_id, session_id, cache_key, data)"; 
     86        $_query.= " VALUES (now(), ?, ?, ?, ?)"; 
     87        $DB->query( 
     88                $_query, 
    8689                $_SESSION['user_id'], 
    8790                $session_cache ? $sess_id : 'NULL', 
    8891                $key, 
    89                 $data); 
     92                $data 
     93        ); 
    9094    } 
    91   } 
     95} 
    9296 
    9397 
    9498function rcube_clear_cache($key) 
    95   { 
    96   global $DB; 
     99{ 
     100    $registry = rc_registry::getInstance(); 
     101    $DB       = $registry->get('DB', 'core'); 
    97102 
    98   $DB->query("DELETE FROM ".get_table_name('cache')." 
    99               WHERE  user_id=? 
    100               AND    cache_key=?", 
    101               $_SESSION['user_id'], 
    102               $key); 
    103   } 
    104  
    105  
     103    $_query = "DELETE FROM " . rc_main::get_table_name('cache'); 
     104    $_query.= " WHERE user_id=?"; 
     105    $_query.= " AND cache_key=?"; 
     106    $DB->query($_query, $_SESSION['user_id'], $key); 
     107} 
    106108?> 
  • branches/devel-vnext/program/include/main.inc

    r622 r623  
    6464    static function rcmail_startup($task = 'mail') 
    6565    { 
    66         //global $sess_id, $sess_user_lang; 
    67         //global $CONFIG, $INSTALL_PATH, $BROWSER, $OUTPUT, $_SESSION, $IMAP, $DB; 
    68  
    6966        $registry     = rc_registry::getInstance(); 
    7067        $INSTALL_PATH = $registry->get('INSTALL_PATH', 'core'); 
     
    7471        // check client 
    7572        $BROWSER = rcube_browser(); 
     73        $registry->set('BROWSER', $BROWSER, 'core'); 
    7674 
    7775        self::tfk_debug('// load browser'); 
     
    104102        session_start(); 
    105103        $sess_id = session_id(); 
     104        $registry->set('sess_id', $sess_id, 'core'); 
    106105 
    107106        // create session and set session vars 
     
    114113        // set session vars global 
    115114        $sess_user_lang = self::rcube_language_prop($_SESSION['user_lang']); 
    116  
     115        $registry->set('sess_user_lang', $sess_user_lang, 'core'); 
    117116 
    118117        // overwrite config with user preferences 
     
    120119            $CONFIG = array_merge($CONFIG, $_SESSION['user_prefs']); 
    121120        } 
     121        $registry->set('CONFIG', $CONFIG, 'core'); 
    122122 
    123123        // reset some session parameters when changing task 
     
    141141        } 
    142142        register_shutdown_function(array('rc_main', 'rcmail_shutdown')); 
    143  
    144         $registry->set('sess_id', $sess_id, 'core'); 
    145         $registry->set('sess_user_lang', $sess_user_lang, 'core'); 
    146         $registry->set('CONFIG', $CONFIG, 'core'); 
    147         $registry->set('BROWSER', $BROWSER, 'core'); 
    148  
    149         //global $OUTPUT, $IMAP 
    150143    } 
    151144 
     
    205198            $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php'; 
    206199        } 
    207         if ($fname && is_file('config/'.$fname)) { 
    208             include('config/'.$fname); 
     200        if ($fname && is_file('config/' . $fname)) { 
     201            include('config/' . $fname); 
    209202            $config = array_merge($config, $rcmail_config); 
    210203        } 
     
    386379 
    387380        // return table name if configured 
    388         $config_key = 'db_table_'.$table; 
     381        $config_key = 'db_table_' . $table; 
    389382 
    390383        if (strlen($CONFIG[$config_key])) { 
     
    403396 
    404397        // return table name if configured 
    405         $config_key = 'db_sequence_'.$sequence; 
     398        $config_key = 'db_sequence_' . $sequence; 
    406399 
    407400        if (strlen($CONFIG[$config_key])) { 
     
    534527 
    535528 
    536     // auto-select IMAP host based on the posted login information 
     529    /** 
     530     * auto-select IMAP host based on the posted login information 
     531     * 
     532     * @access static 
     533     * @link   ./index.php 
     534     * @todo   Remove reference to $_POST superglobal. 
     535     */ 
    537536    static function rcmail_autoselect_host() 
    538537    { 
     
    540539        $CONFIG   = $registry->get('CONFIG', 'core'); 
    541540 
    542         $host = isset($_POST['_host']) ? self::get_input_value('_host', RCUBE_INPUT_POST) : $CONFIG['default_host']; 
     541        $host = ''; 
     542        if (isset($_POST['_host']) && empty($_POST['_host']) === false) { 
     543            $host .= self::get_input_value('_host', RCUBE_INPUT_POST); 
     544        } 
     545        else { 
     546            $host .= $CONFIG['default_host']; 
     547        } 
     548        //self::tfk_debug('/ POST: ' . $_POST['_host']); 
     549        //self::tfk_debug('/ default host: ' . var_export($CONFIG['default_host'], true)); 
     550 
    543551        if (is_array($host)) { 
    544552            list($user, $domain) = explode('@', self::get_input_value('_user', RCUBE_INPUT_POST)); 
     
    557565            } 
    558566        } 
     567        self::tfk_debug($host); 
    559568        return $host; 
    560569    } 
     
    11801189        // encode for HTML output 
    11811190        if ($enctype=='html') { 
    1182             if (is_null($html_encode_arr)) { 
     1191 
     1192            //self::tfk_debug('/ html :-)'); 
     1193 
     1194            if (empty($html_encode_arr)) { 
    11831195                $html_encode_arr = get_html_translation_table(HTML_SPECIALCHARS); 
    11841196                unset($html_encode_arr['?']); 
    1185                 $registry->set('html_encode_arr', $html_encode_arr, 'core'); 
     1197                $registry->set( 
     1198                            'html_encode_arr', 
     1199                            $html_encode_arr, 
     1200                            'core' 
     1201                ); 
    11861202            } 
    11871203 
    11881204            $ltpos = strpos($str, '<'); 
    11891205            $encode_arr = $html_encode_arr; 
     1206 
     1207            //self::tfk_debug(var_export($encode_arr, true)); 
    11901208 
    11911209            // don't replace quotes and html tags 
     
    12161234        } 
    12171235        // if the replace tables for XML and JS are not yet defined 
    1218         if (is_null($js_rep_table)) { 
     1236        if (empty($js_rep_table)) { 
    12191237            $js_rep_table = $xml_rep_table = array(); 
    12201238            $xml_rep_table['&'] = '&amp;'; 
     
    12931311        $registry = rc_registry::getInstance(); 
    12941312        $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    1295         $value = NULL; 
     1313        $value    = NULL; 
    12961314 
    12971315        if ($source == RCUBE_INPUT_GET && isset($_GET[$fname])) { 
     
    13021320        } 
    13031321        else if ($source == RCUBE_INPUT_GPC) { 
    1304             if (isset($_POST[$fname])) 
     1322            if (isset($_POST[$fname])) { 
    13051323                $value = $_POST[$fname]; 
    1306             else if (isset($_GET[$fname])) 
     1324            } 
     1325            else if (isset($_GET[$fname])) { 
    13071326                $value = $_GET[$fname]; 
    1308             else if (isset($_COOKIE[$fname])) 
     1327            } 
     1328            else if (isset($_COOKIE[$fname])) { 
    13091329                $value = $_COOKIE[$fname]; 
     1330            } 
    13101331        } 
    13111332 
     
    13231344        } 
    13241345        return $value; 
    1325       } 
     1346    } 
    13261347 
    13271348    /** 
  • branches/devel-vnext/program/include/rcmail_template.inc

    r622 r623  
    7676    } 
    7777 
    78     /* 
    79     // PHP 4 compatibility 
    80     function rcmail_template(&$config, $task) 
    81     { 
    82         $this->__construct($config, $task); 
    83     }*/ 
    84  
    85  
    8678    /** 
    8779     * Set environment variable 
     
    221213 
    222214    // send response code 
    223     print rcube_charset_convert($this->get_js_commands() . $add, RCMAIL_CHARSET, $this->get_charset()); 
     215    echo rc_main::rcube_charset_convert($this->get_js_commands() . $add, RCMAIL_CHARSET, $this->get_charset()); 
    224216 
    225217    if ($flush)  // flush the output buffer 
     
    348340    function parse_with_globals($input) 
    349341    { 
    350         $GLOBALS['__comm_path'] = $GLOBALS['COMM_PATH']; 
     342        $registry  = rc_registry::getInstance(); 
     343        $COMM_PATH = $registry->get('COMM_PATH', 'core'); 
     344 
     345        $GLOBALS['__comm_path'] = $COMM_PATH; 
    351346        return preg_replace('/\$(__[a-z0-9_\-]+)/e', '$GLOBALS["\\1"]', $input); 
    352347    } 
     
    516511    function button($attrib) 
    517512    { 
    518         global $CONFIG, $OUTPUT, $BROWSER, $MAIN_TASKS; 
     513        $registry   = rc_registry::getInstance(); 
     514        $CONFIG     = $registry->get('CONFIG', 'core'); 
     515        $OUTPUT     = $registry->get('OUTPUT', 'core'); 
     516        $BROWSER    = $registry->get('BROWSER', 'core'); 
     517        $MAIN_TASKS = $registry->get('MAIN_TASKS', 'core'); 
     518 
    519519        static $sa_buttons = array(); 
    520520        static $s_button_count = 100; 
     
    607607            // make valid href to specific buttons 
    608608            if (in_array($attrib['command'], $MAIN_TASKS)) { 
    609                 $attrib['href'] = rc_main::Q(rcmail_url(null, null, $attrib['command'])); 
     609                $attrib['href'] = rc_main::Q(rc_main::rcmail_url(null, null, $attrib['command'])); 
    610610            } 
    611611            else if (in_array($attrib['command'], $a_static_commands)) { 
    612                 $attrib['href'] = rc_main::Q(rcmail_url($attrib['command'])); 
     612                $attrib['href'] = rc_main::Q(rc_main::rcmail_url($attrib['command'])); 
    613613            } 
    614614        } 
     
    660660        // generate image tag 
    661661        if ($attrib['type']=='image') { 
    662             $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'width', 'height', 'border', 'hspace', 'vspace', 'align', 'alt')); 
     662            $attrib_str = rc_main::create_attrib_string( 
     663                                $attrib, 
     664                                array( 
     665                                    'style', 'class', 'id', 'width', 
     666                                    'height', 'border', 'hspace', 
     667                                    'vspace', 'align', 'alt' 
     668                                ) 
     669            ); 
    663670            $img_tag = sprintf('<img src="%%s"%s />', $attrib_str); 
    664671            $btn_content = sprintf($img_tag, $skin_path.$attrib['image']); 
     
    678685                $attrib['value'] = $attrib['label']; 
    679686 
    680             $attrib_str = create_attrib_string($attrib, array('type', 'value', 'onclick', 'id', 'class', 'style')); 
     687            $attrib_str = rc_main::create_attrib_string( 
     688                                $attrib, 
     689                                array( 
     690                                    'type', 'value', 'onclick', 
     691                                    'id', 'class', 'style' 
     692                                ) 
     693            ); 
    681694            $out = sprintf('<input%s disabled="disabled" />', $attrib_str); 
    682695        } 
     
    684697        // generate html code for button 
    685698        if ($btn_content) { 
    686             $attrib_str = create_attrib_string($attrib, $link_attrib); 
     699            $attrib_str = rc_main::create_attrib_string($attrib, $link_attrib); 
    687700            $out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content); 
    688701        } 
  • branches/devel-vnext/program/include/rcube/rcmail_compose.php

    r606 r623  
    22/** 
    33 * @todo Create a class. 
    4  * @todo Get rid off globals. 
    54 * @ignore 
    65 */ 
     
    87function rcmail_compose_headers($attrib) 
    98{ 
    10     global $IMAP, $MESSAGE, $DB, $compose_mode; 
    11     static $sa_recipients = array(); 
     9    $registry      = rc_registry::getInstance(); 
     10    $IMAP          = $registry->get('IMAP', 'core'); 
     11    $MESSAGE       = $registry->get('MESSAGE', 'core'); 
     12    $DB            = $registry->get('DB', 'core'); 
     13    $compose_mode  = $registry->get('compose_mode', 'core'); 
     14    $sa_recipients = $registry->get('sa_recipients', 'core'); 
     15 
     16    if (is_null($sa_recipients)) { 
     17        $sa_recipients = array(); 
     18    } 
    1219 
    1320    list($form_start, $form_end) = get_form_tags($attrib); 
     
    2532 
    2633            // we have a set of recipients stored is session 
    27             if (($mailto_id = get_input_value('_mailto', RCUBE_INPUT_GET)) && $_SESSION['mailto'][$mailto_id]) { 
     34            if (($mailto_id = rc_main::get_input_value('_mailto', RCUBE_INPUT_GET)) && $_SESSION['mailto'][$mailto_id]) { 
    2835                $fvalue = $_SESSION['mailto'][$mailto_id]; 
    2936            } 
    3037            elseif (!empty($_GET['_to'])) { 
    31                 $fvalue = get_input_value('_to', RCUBE_INPUT_GET); 
     38                $fvalue = rc_main::get_input_value('_to', RCUBE_INPUT_GET); 
    3239            } 
    3340 
     
    6572 
    6673    if ($fname && !empty($_POST[$fname])) { 
    67         $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); 
     74        $fvalue = rc_main::get_input_value($fname, RCUBE_INPUT_POST, TRUE); 
    6875    } 
    6976    else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { 
     
    127134        $out = $form_start.$out; 
    128135    } 
     136 
     137    $registry->set('sa_recipients', $sa_recipients, 'core'); 
     138 
    129139    return $out; 
    130140} 
     
    132142 
    133143 
    134 function rcmail_compose_header_from($attrib) { 
    135     global $IMAP, $MESSAGE, $DB, $OUTPUT, $compose_mode; 
     144function rcmail_compose_header_from($attrib) 
     145{ 
     146    $registry      = rc_registry::getInstance(); 
     147    $MESSAGE       = $registry->get('MESSAGE', 'core'); 
     148    $DB            = $registry->get('DB', 'core'); 
     149    $compose_mode  = $registry->get('compose_mode', 'core'); 
     150    $OUTPUT        = $registry->get('OUTPUT', 'core'); 
    136151 
    137152    // pass the following attributes to the form class 
     
    166181    // get this user's identities 
    167182    $_query = "SELECT identity_id, name, email, signature, html_signature"; 
    168     $_query.= " FROM " . get_table_name('identities'); 
     183    $_query.= " FROM " . rc_main::get_table_name('identities'); 
    169184    $_query.= " WHERE user_id=?"; 
    170185    $_query.= " AND del<>1"; 
     
    193208    while ($sql_arr = $DB->fetch_assoc($sql_result)) { 
    194209        $identity_id = $sql_arr['identity_id']; 
    195         $select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id); 
     210        $select_from->add(rc_main::format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id); 
    196211 
    197212        // add signature to array 
     
    220235    // overwrite identity selection with post parameter 
    221236    if (isset($_POST['_from'])) { 
    222         $from_id = get_input_value('_from', RCUBE_INPUT_POST); 
     237        $from_id = rc_main::get_input_value('_from', RCUBE_INPUT_POST); 
    223238    } 
    224239    $out = $select_from->show($from_id); 
     
    235250 
    236251 
    237 function rcmail_compose_body($attrib) { 
    238     global $CONFIG, $OUTPUT, $MESSAGE, $compose_mode; 
     252function rcmail_compose_body($attrib) 
     253{ 
     254    $registry      = rc_registry::getInstance(); 
     255    $CONFIG        = $registry->get('CONFIG', 'core'); 
     256    $MESSAGE       = $registry->get('MESSAGE', 'core'); 
     257    $OUTPUT        = $registry->get('OUTPUT', 'core'); 
     258    $compose_mode  = $registry->get('compose_mode', 'core'); 
     259    $COMM_PATH     = $registry->get('COMM_PATH', 'core'); 
    239260 
    240261    list($form_start, $form_end) = get_form_tags($attrib); 
     
    256277    // use posted message body 
    257278    if (!empty($_POST['_message'])) { 
    258         $body = get_input_value('_message', RCUBE_INPUT_POST, TRUE); 
     279        $body = rc_main::get_input_value('_message', RCUBE_INPUT_POST, TRUE); 
    259280    } 
    260281    // compose reply-body 
     
    291312        } 
    292313        else { 
    293             $body = rcmail_first_text_part($MESSAGE); 
     314           $body = rcmail_first_text_part($MESSAGE); 
    294315            $isHtml = false; 
    295316        } 
     
    342363                      "googie.decorateTextarea('%s');\n". 
    343364                      "%s.set_env('spellcheck', googie);", 
    344                       $GLOBALS['COMM_PATH'], 
    345                       JQ(Q(rcube_label('checkspelling'))), 
    346                       JQ(Q(rcube_label('resumeediting'))), 
    347                       JQ(Q(rcube_label('close'))), 
    348                       JQ(Q(rcube_label('revertto'))), 
    349                       JQ(Q(rcube_label('nospellerrors'))), 
     365                      $COMM_PATH, 
     366                      rc_main::JQ(rc_main::Q(rcube_label('checkspelling'))), 
     367                      rc_main::JQ(rc_main::Q(rcube_label('resumeediting'))), 
     368                      rc_main::JQ(rc_main::Q(rcube_label('close'))), 
     369                      rc_main::JQ(rc_main::Q(rcube_label('revertto'))), 
     370                      rc_main::JQ(rc_main::Q(rcube_label('nospellerrors'))), 
    350371                      $lang_set, 
    351372                      substr($_SESSION['user_lang'], 0, 2), 
     
    353374                      JS_OBJECT_NAME), 'foot' 
    354375        ); 
    355         rcube_add_label('checking'); 
     376        rc_main::rcube_add_label('checking'); 
    356377    } 
    357378    $out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;visibility:hidden;"></iframe>'; 
     
    370391function rcmail_create_reply_body($body, $bodyIsHtml) 
    371392{ 
    372     global $IMAP, $MESSAGE; 
     393    $registry = rc_registry::getInstance(); 
     394    $IMAP     = $registry->get('IMAP', 'core'); 
     395    $MESSAGE  = $registry->get('MESSAGE', 'core'); 
    373396 
    374397    $_date = $MESSAGE['headers']->date; 
     
    428451function rcmail_create_forward_body($body, $bodyIsHtml) 
    429452{ 
    430     global $IMAP, $MESSAGE; 
     453    $registry = rc_registry::getInstance(); 
     454    $IMAP     = $registry->get('IMAP', 'core'); 
     455    $MESSAGE  = $registry->get('MESSAGE', 'core'); 
    431456 
    432457 
     
    474499function rcmail_create_draft_body($body, $bodyIsHtml) 
    475500{ 
    476     global $IMAP, $MESSAGE; 
     501    $registry = rc_registry::getInstance(); 
     502    $IMAP     = $registry->get('IMAP', 'core'); 
     503    $MESSAGE  = $registry->get('MESSAGE', 'core'); 
    477504 
    478505    // add attachments 
     
    490517function rcmail_write_compose_attachments(&$message) 
    491518{ 
    492     global $IMAP, $CONFIG; 
     519    $registry = rc_registry::getInstance(); 
     520    $CONFIG   = $registry->get('CONFIG', 'core'); 
     521    $IMAP     = $registry->get('IMAP', 'core'); 
    493522 
    494523    $temp_dir = unslashify($CONFIG['temp_dir']); 
     
    538567function rcmail_compose_subject($attrib) 
    539568{ 
    540     global $CONFIG, $MESSAGE, $compose_mode; 
     569    $registry     = rc_registry::getInstance(); 
     570    $CONFIG       = $registry->get('CONFIG', 'core'); 
     571    $MESSAGE      = $registry->get('MESSAGE', 'core'); 
     572    $compose_mode = $registry->get('compose_mode', 'core'); 
    541573 
    542574    list($form_start, $form_end) = get_form_tags($attrib); 
     
    552584    // use subject from post 
    553585    if (isset($_POST['_subject'])) { 
    554         $subject = get_input_value('_subject', RCUBE_INPUT_POST, TRUE); 
     586        $subject = rc_main::get_input_value('_subject', RCUBE_INPUT_POST, TRUE); 
    555587    } 
    556588    // create a reply-subject 
     
    593625function rcmail_compose_attachment_list($attrib) 
    594626{ 
    595     global $OUTPUT, $CONFIG; 
     627    $registry = rc_registry::getInstance(); 
     628    $CONFIG   = $registry->get('CONFIG', 'core'); 
     629    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    596630 
    597631    // add ID if not given 
     
    600634    } 
    601635    // allow the following attributes to be added to the <ul> tag 
    602     $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); 
     636    $attrib_str = rc_main::create_attrib_string($attrib, array('id', 'class', 'style')); 
    603637 
    604638    $out = '<ul'. $attrib_str . ">\n"; 
     
    642676function rcmail_compose_attachment_form($attrib) 
    643677{ 
    644     global $OUTPUT, $SESS_HIDDEN_FIELD; 
     678    $registry          = rc_registry::getInstance(); 
     679    $OUTPUT            = $registry->get('OUTPUT', 'core'); 
     680    $SESS_HIDDEN_FIELD = $registry->get('SESS_HIDDEN_FIELD', 'core'); 
    645681 
    646682    // add ID if not given 
     
    649685    } 
    650686    // allow the following attributes to be added to the <div> tag 
    651     $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); 
     687    $attrib_str  = rc_main::create_attrib_string($attrib, array('id', 'class', 'style')); 
    652688    $input_field = rcmail_compose_attachment_field(array('style="height:15px;"')); 
    653     $label_send = rcube_label('upload'); 
     689    $label_send  = rcube_label('upload'); 
    654690    $label_close = rcube_label('close'); 
    655691    $js_instance = JS_OBJECT_NAME; 
     
    680716{ 
    681717    // allow the following attributes to be added to the <input> tag 
    682     $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'size')); 
     718    $attrib_str = rc_main::create_attrib_string($attrib, array('id', 'class', 'style', 'size')); 
    683719 
    684720    $out = '<input type="file" name="_attachments[]"'. $attrib_str . " />"; 
     
    734770function rcmail_editor_selector($attrib) 
    735771{ 
    736     global $CONFIG, $MESSAGE, $compose_mode; 
     772    $registry     = rc_registry::getInstance(); 
     773    $CONFIG       = $registry->get('CONFIG', 'core'); 
     774    $MESSAGE      = $registry->get('MESSAGE', 'core'); 
     775    $compose_mode = $registry->get('compose_mode', 'core'); 
    737776 
    738777    $choices = array( 
     
    782821function get_form_tags($attrib) 
    783822{ 
    784     global $CONFIG, $OUTPUT, $MESSAGE_FORM, $SESS_HIDDEN_FIELD; 
     823    $registry          = rc_registry::getInstance(); 
     824    $CONFIG            = $registry->get('CONFIG', 'core'); 
     825    $MESSAGE_FORM      = $registry->get('MESSAGE_FORM', 'core'); 
     826    $OUTPUT            = $registry->get('OUTPUT', 'core'); 
     827    $SESS_HIDDEN_FIELD = $registry->get('SESS_HIDDEN_FIELD', 'core'); 
    785828 
    786829    $form_start = ''; 
     
    797840    $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form'; 
    798841 
    799     if (!strlen($MESSAGE_FORM)) 
     842    if (!strlen($MESSAGE_FORM)) { 
    800843        $OUTPUT->add_gui_object('messageform', $form_name); 
    801  
     844    } 
    802845    $MESSAGE_FORM = $form_name; 
    803846 
     847    $registry->set('MESSAGE_FORM', $MESSAGE_FORM, 'core'); 
     848 
    804849    return array($form_start, $form_end); 
    805850} 
  • branches/devel-vnext/program/include/rcube/rcmail_send.php

    r592 r623  
    1717    function get_identity($id) 
    1818    { 
    19         global $DB, $OUTPUT; 
     19        $registry = rc_registry::getInstance(); 
     20        $DB       = $registry->get('DB', 'core'); 
     21        $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    2022 
    2123        // get identity record 
     
    2628        $_query.= " AND del<>1"; 
    2729 
    28         tfk_debug('Identity: ' . $_query); 
     30        rc_main::tfk_debug('Identity: ' . $_query); 
    2931 
    3032        $sql_result = $DB->query($_query, $id, $_SESSION['user_id']); 
     
    3840            $out['string'] = sprintf( 
    3941                                '%s <%s>', 
    40                                 rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()), 
     42                                rc_main::rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()), 
    4143                                $sql_arr['mailto'] 
    4244            ); 
     
    6163    function attach_emoticons(&$mime_message) 
    6264    { 
    63         global $CONFIG, $INSTALL_PATH; 
     65        $registry     = rc_registry::getInstance(); 
     66        $INSTALL_PATH = $registry->get('INSTALL_PATH', 'core'); 
     67        $CONFIG       = $registry->get('CONFIG', 'core'); 
    6468 
    6569        $htmlContents = $mime_message->getHtmlBody(); 
  • branches/devel-vnext/program/include/rcube_contacts.inc

    r589 r623  
    2222class rcube_contacts 
    2323{ 
    24   var $db = null; 
    25   var $db_name = ''; 
    26   var $user_id = 0; 
    27   var $filter = null; 
    28   var $result = null; 
    29   var $search_fields; 
    30   var $search_string; 
    31   var $table_cols = array('name', 'email', 'firstname', 'surname'); 
    32    
    33   /** public properties */ 
    34   var $primary_key = 'contact_id'; 
    35   var $readonly = false; 
    36   var $list_page = 1; 
    37   var $page_size = 10; 
    38   var $ready = false; 
    39  
    40    
    41   /** 
    42    * Object constructor 
    43    * 
    44    * @param object  Instance of the rcube_db class 
    45    * @param integer User-ID 
    46    */ 
    47   function __construct($dbconn, $user) 
    48   { 
    49     $this->db = $dbconn; 
    50     $this->db_name = get_table_name('contacts'); 
    51     $this->user_id = $user; 
    52     $this->ready = $this->db && !$this->db->is_error(); 
    53   } 
     24    var $db = null; 
     25    var $db_name = ''; 
     26    var $user_id = 0; 
     27    var $filter = null; 
     28    var $result = null; 
     29    var $search_fields; 
     30    var $search_string; 
     31    var $table_cols = array('name', 'email', 'firstname', 'surname'); 
     32 
     33    /** public properties */ 
     34    var $primary_key = 'contact_id'; 
     35    var $readonly = false; 
     36    var $list_page = 1; 
     37    var $page_size = 10; 
     38    var $ready = false; 
     39 
     40 
     41    /** 
     42     * Object constructor 
     43     * 
     44     * @param object  Instance of the rcube_db class 
     45     * @param integer User-ID 
     46     */ 
     47    function __construct($dbconn, $user) 
     48    { 
     49        $this->db = $dbconn; 
     50        $this->db_name = rc_main::get_table_name('contacts'); 
     51        $this->user_id = $user; 
     52        $this->ready = $this->db && !$this->db->is_error(); 
     53    } 
    5454 
    5555  /** 
     
    9797    $this->filter = $filter; 
    9898  } 
    99    
    100    
     99 
     100 
    101101  /** 
    102102   * Getter for saved search properties 
     
    120120    $this->search_string = null; 
    121121  } 
    122    
    123    
     122 
     123 
    124124  /** 
    125125   * List the current set of contact records 
     
    139139      $start_row = $subset < 0 ? $this->result->first + $this->page_size + $subset : $this->result->first; 
    140140      $length = $subset != 0 ? abs($subset) : $this->page_size; 
    141        
     141 
    142142      $sql_result = $this->db->limitquery( 
    143143        "SELECT * FROM ".$this->db_name." 
     
    150150        $this->user_id); 
    151151    } 
    152      
     152 
    153153    while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) 
    154154    { 
     
    159159      $this->result->add($sql_arr); 
    160160    } 
    161      
     161 
    162162    return $this->result; 
    163163  } 
     
    176176    if (!is_array($fields)) 
    177177      $fields = array($fields); 
    178        
     178 
    179179    $add_where = array(); 
    180180    foreach ($fields as $col) 
     
    188188        $add_where[] = $this->db->quoteIdentifier($col)." LIKE ".$this->db->quote(strlen($value)>2 ? "%$value%" : "$value%"); 
    189189    } 
    190      
     190 
    191191    if (!empty($add_where)) 
    192192    { 
     
    197197        $this->result = $this->count(); 
    198198    } 
    199     
    200     return $this->result;  
     199 
     200    return $this->result; 
    201201  } 
    202202 
     
    232232    return $this->result; 
    233233  } 
    234    
    235    
     234 
     235 
    236236  /** 
    237237   * Get a specific contact record 
     
    245245    if ($this->result && ($first = $this->result->first()) && $first[$this->primary_key] == $id) 
    246246      return $assoc ? $first : $this->result; 
    247        
     247 
    248248    $this->db->query( 
    249249      "SELECT * FROM ".$this->db_name." 
     
    263263    return $assoc && $sql_arr ? $sql_arr : $this->result; 
    264264  } 
    265    
    266    
     265 
     266 
    267267  /** 
    268268   * Create a new contact record 
     
    271271   * @return The created record ID on success, False on error 
    272272   */ 
    273   function insert($save_data, $check=false) 
    274   { 
    275     if (is_object($save_data) && is_a($save_data, rcube_result_set)) 
    276       return $this->insert_recset($save_data, $check); 
    277  
    278     $insert_id = $existing = false; 
    279  
    280     if ($check) 
    281       $existing = $this->search('email', $save_data['email'], false); 
    282  
    283     $a_insert_cols = $a_insert_values = array(); 
    284     foreach ($this->table_cols as $col) 
    285       if (isset($save_data[$col])) 
    286       { 
    287         $a_insert_cols[] = $this->db->quoteIdentifier($col); 
    288         $a_insert_values[] = $this->db->quote($save_data[$col]); 
    289       } 
    290      
    291     if (!$existing->count && !empty($a_insert_cols)) 
    292     { 
    293       $this->db->query( 
    294         "INSERT INTO ".$this->db_name." 
    295          (user_id, changed, del, ".join(', ', $a_insert_cols).") 
    296          VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")", 
    297         $this->user_id); 
    298          
    299       $insert_id = $this->db->insert_id(get_sequence_name('contacts')); 
    300     } 
    301      
    302     return $insert_id; 
     273    function insert($save_data, $check=false) 
     274    { 
     275        if (is_object($save_data) && is_a($save_data, rcube_result_set)) { 
     276            return $this->insert_recset($save_data, $check); 
     277        } 
     278        $insert_id = $existing = false; 
     279 
     280        if ($check) { 
     281            $existing = $this->search('email', $save_data['email'], false); 
     282        } 
     283        $a_insert_cols = $a_insert_values = array(); 
     284        foreach ($this->table_cols as $col) { 
     285            if (isset($save_data[$col])) { 
     286                $a_insert_cols[] = $this->db->quoteIdentifier($col); 
     287                $a_insert_values[] = $this->db->quote($save_data[$col]); 
     288            } 
     289        } 
     290 
     291        if (!$existing->count && !empty($a_insert_cols)) { 
     292            $_query = "INSERT INTO " . $this->db_name; 
     293            $_query.= " (user_id, changed, del, " . join(', ', $a_insert_cols).")"; 
     294            $_query.= " VALUES (?, " . $this->db->now() . ", 0, "; 
     295            $_query.= join(', ', $a_insert_values).")"; 
     296            $this->db->query($_query, $this->user_id); 
     297 
     298            $insert_id = $this->db->insert_id( 
     299                                rc_main::get_sequence_name('contacts') 
     300            ); 
     301        } 
     302 
     303        return $insert_id; 
    303304  } 
    304305 
     
    317318    return $ids; 
    318319  } 
    319    
    320    
     320 
     321 
    321322  /** 
    322323   * Update a specific contact record 
     
    347348      $updated = $this->db->affected_rows(); 
    348349    } 
    349      
     350 
    350351    return $updated; 
    351352  } 
    352    
    353    
     353 
     354 
    354355  /** 
    355356   * Mark one or more contact records as deleted 
     
    385386  var $current = 0; 
    386387  var $records = array(); 
    387    
     388 
    388389  function __construct($c=0, $f=0) 
    389390  { 
     
    391392    $this->first = (int)$f; 
    392393  } 
    393    
     394 
    394395  function rcube_result_set($c=0, $f=0) 
    395396  { 
    396397    $this->__construct($c, $f); 
    397398  } 
    398    
     399 
    399400  function add($rec) 
    400401  { 
    401402    $this->records[] = $rec; 
    402403  } 
    403    
     404 
    404405  function iterate() 
    405406  { 
    406407    return $this->records[$this->current++]; 
    407408  } 
    408    
     409 
    409410  function first() 
    410411  { 
     
    412413    return $this->records[$this->current++]; 
    413414  } 
    414    
     415 
    415416  // alias 
    416417  function next() 
     
    418419    return $this->iterate(); 
    419420  } 
    420    
     421 
    421422  function seek($i) 
    422423  { 
    423424    $this->current = $i; 
    424425  } 
    425    
     426 
    426427} 
    427428 
  • branches/devel-vnext/program/include/rcube_imap.inc

    r622 r623  
    410410    function _list_mailboxes($root='', $filter='*') 
    411411    { 
    412         global $CONFIG; 
     412        $registry = rc_registry::getInstance(); 
     413        $CONFIG   = $registry->get('CONFIG', 'core'); 
    413414 
    414415        $a_defaults = $a_out = array(); 
     
    941942                                $mbox_name, 
    942943                                $criteria, 
    943                                 rcube_charset_convert($str, $charset, 'ISO-8859-1'), 
     944                                rc_main::rcube_charset_convert($str, $charset, 'ISO-8859-1'), 
    944945                                'ISO-8859-1' 
    945946                ); 
     
    12781279          $o_part->charset = 'ISO-8859-1'; 
    12791280 
    1280         $body = rcube_charset_convert($body, $o_part->charset); 
     1281        $body = rc_main::rcube_charset_convert($body, $o_part->charset); 
    12811282        } 
    12821283      } 
     
    22472248 
    22482249    // no encoding information, use fallback 
    2249     return rcube_charset_convert($input, !empty($fallback) ? $fallback : 'ISO-8859-1'); 
     2250    return rc_main::rcube_charset_convert($input, !empty($fallback) ? $fallback : 'ISO-8859-1'); 
    22502251    } 
    22512252 
     
    22752276        } 
    22762277 
    2277       return rcube_charset_convert($rest, $a[0]); 
     2278      return rc_main::rcube_charset_convert($rest, $a[0]); 
    22782279      } 
    22792280    else 
     
    23262327    { 
    23272328    if (is_array($ctype_param) && !empty($ctype_param['charset'])) 
    2328       return rcube_charset_convert($body, $ctype_param['charset']); 
     2329      return rc_main::rcube_charset_convert($body, $ctype_param['charset']); 
    23292330 
    23302331    // defaults to what is specified in the class header 
    2331     return rcube_charset_convert($body,  'ISO-8859-1'); 
     2332    return rc_main::rcube_charset_convert($body,  'ISO-8859-1'); 
    23322333    } 
    23332334 
  • branches/devel-vnext/program/include/rcube_shared.inc

    r622 r623  
    228228// send HTTP header for no-cacheing steps 
    229229function send_nocacheing_headers() 
    230   { 
    231   if (headers_sent()) 
    232     return; 
    233  
    234   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT"); 
    235   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 
    236   header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
    237   header("Pragma: no-cache"); 
    238   } 
     230{ 
     231    if (headers_sent()) { 
     232        return; 
     233    } 
     234    header("Expires: ".gmdate("D, d M Y H:i:s")." GMT"); 
     235    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 
     236    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
     237    header("Pragma: no-cache"); 
     238} 
    239239 
    240240 
     
    254254function send_modified_header($mdate, $etag=null) 
    255255{ 
    256   if (headers_sent()) 
    257     return; 
    258  
    259   $iscached = false; 
    260   if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) 
    261     $iscached = true; 
    262  
    263   $etag = $etag ? "\"$etag\"" : null; 
    264   if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) 
    265     $iscached = true; 
    266  
    267   if ($iscached) 
    268     header("HTTP/1.x 304 Not Modified"); 
    269   else 
    270     header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mdate)." GMT"); 
    271  
    272   header("Cache-Control: max-age=0"); 
    273   header("Expires: "); 
    274   header("Pragma: "); 
    275  
    276   if ($etag) 
    277     header("Etag: $etag"); 
    278  
    279   if ($iscached) 
    280     exit; 
     256    if (headers_sent()) { 
     257        rc_main::tfk_debug("/ Headerz sent?!"); 
     258        return; 
     259    } 
     260    $iscached = false; 
     261    if ( 
     262        $_SERVER['HTTP_IF_MODIFIED_SINCE'] 
     263        && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate 
     264    ) { 
     265        $iscached = true; 
     266    } 
     267 
     268    $etag = $etag ? "\"$etag\"" : null; 
     269    if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { 
     270        $iscached = true; 
     271    } 
     272    if ($iscached) { 
     273        header("HTTP/1.x 304 Not Modified"); 
     274    } 
     275    else { 
     276        header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mdate)." GMT"); 
     277    } 
     278    header("Cache-Control: max-age=0"); 
     279    header("Expires: "); 
     280    header("Pragma: "); 
     281 
     282    if ($etag) { 
     283        header("Etag: $etag"); 
     284    } 
     285    $iscached = FALSE; 
     286    if ($iscached) { 
     287        rc_main::tfk_debug("/ serving from cache"); 
     288        exit; 
     289    } 
    281290} 
    282291 
  • branches/devel-vnext/program/include/rcube_smtp.inc

    r589 r623  
    2222 
    2323// include required PEAR classes 
    24 require_once('Net/SMTP.php'); 
     24require_once 'Net/SMTP.php'; 
    2525 
    2626 
     
    2828define('SMTP_MIME_CRLF', "\r\n"); 
    2929 
    30 $SMTP_CONN = null; 
     30$SMTP_CONN = $registry->set('SMTP_CONN', NULL, 'core'); 
    3131 
    3232/** 
     
    5151 */ 
    5252function smtp_mail($from, $recipients, &$headers, &$body, &$response) 
    53   { 
    54   global $SMTP_CONN, $CONFIG; 
    55   $smtp_timeout = null; 
    56   $smtp_host = $CONFIG['smtp_server']; 
    57   $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; 
    58   $smtp_host_url = parse_url($CONFIG['smtp_server']); 
    59    
    60   // overwrite port 
    61   if ($smtp_host_url['host'] && $smtp_host_url['port']) 
    62     { 
    63     $smtp_host = $smtp_host_url['host']; 
    64     $smtp_port = $smtp_host_url['port']; 
    65     } 
    66  
    67   // re-write smtp host 
    68   if ($smtp_host_url['host'] && $smtp_host_url['scheme']) 
    69     $smtp_host = sprintf('%s://%s', $smtp_host_url['scheme'], $smtp_host_url['host']); 
    70  
    71  
    72   // create Net_SMTP object and connect to server 
    73   if (!is_object($smtp_conn)) 
    74     { 
    75     $helo_host = !empty($_SERVER['server_name']) ? $_SERVER['server_name'] : 'localhost'; 
    76     $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); 
    77  
    78     // set debugging 
    79     if ($CONFIG['debug_level'] & 8) 
    80       $SMTP_CONN->setDebug(TRUE); 
    81  
    82  
    83     // try to connect to server and exit on failure 
    84     $result = $SMTP_CONN->connect($smtp_timeout); 
    85     if (PEAR::isError($result)) 
    86       { 
    87       $SMTP_CONN = null; 
    88       $response[] = "Connection failed: ".$result->getMessage(); 
    89       return FALSE; 
    90       } 
    91        
    92     // attempt to authenticate to the SMTP server 
    93     if ($CONFIG['smtp_user'] && $CONFIG['smtp_pass']) 
    94       { 
    95       if (strstr($CONFIG['smtp_user'], '%u')) 
    96         $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']); 
    97       else 
    98         $smtp_user = $CONFIG['smtp_user']; 
    99  
    100       if (strstr($CONFIG['smtp_pass'], '%p')) 
    101         $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $CONFIG['smtp_pass']); 
    102       else 
    103         $smtp_pass = $CONFIG['smtp_pass']; 
    104  
    105       $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; 
    106       $result = $SMTP_CONN->auth($smtp_user, $smtp_pass, $smtp_auth_type); 
    107      
    108       if (PEAR::isError($result)) 
    109         { 
    110         smtp_reset(); 
    111         $response[] .= "Authentication failure: ".$result->getMessage(); 
    112         return FALSE; 
    113         } 
    114       } 
    115     } 
    116  
    117  
    118   // prepare message headers as string 
    119   if (is_array($headers)) 
    120     { 
    121     $headerElements = smtp_prepare_headers($headers); 
    122     if (!$headerElements) 
    123       { 
    124       smtp_reset(); 
    125       return FALSE; 
    126       } 
    127  
    128     list($from, $text_headers) = $headerElements; 
    129     } 
    130   else if (is_string($headers)) 
    131     $text_headers = $headers; 
    132   else 
    133     { 
    134     smtp_reset(); 
    135     $response[] .= "Invalid message headers"; 
    136     return FALSE; 
    137     } 
    138  
    139   // exit if no from address is given 
    140   if (!isset($from)) 
    141     { 
    142     smtp_reset(); 
    143     $response[] .= "No From address has been provided"; 
    144     return FALSE; 
    145     } 
    146  
    147  
    148   // set From: address 
    149   if (PEAR::isError($SMTP_CONN->mailFrom($from))) 
    150     { 
    151     smtp_reset(); 
    152     $response[] .= "Failed to set sender '$from'"; 
    153     return FALSE; 
    154     } 
    155  
    156  
    157   // prepare list of recipients 
    158   $recipients = smtp_parse_rfc822($recipients); 
    159   if (PEAR::isError($recipients)) 
    160     { 
    161     smtp_reset(); 
    162     return FALSE; 
    163     } 
    164  
    165  
    166   // set mail recipients 
    167   foreach ($recipients as $recipient) 
    168     { 
    169     if (PEAR::isError($SMTP_CONN->rcptTo($recipient))) 
    170       { 
    171       smtp_reset(); 
    172       $response[] .= "Failed to add recipient '$recipient'"; 
    173       return FALSE; 
    174       } 
    175     } 
    176  
    177  
    178   // Concatenate headers and body so it can be passed by reference to SMTP_CONN->data 
    179   // so preg_replace in SMTP_CONN->quotedata will store a reference instead of a copy.  
    180   // We are still forced to make another copy here for a couple ticks so we don't really  
    181   // get to save a copy in the method call. 
    182   $data = $text_headers . "\r\n" . $body; 
    183  
    184   // unset old vars to save data and so we can pass into SMTP_CONN->data by reference. 
    185   unset($text_headers, $body); 
    186     
    187   // Send the message's headers and the body as SMTP data. 
    188   if (PEAR::isError($SMTP_CONN->data($data))) 
    189     { 
    190     smtp_reset(); 
    191     $response[] .= "Failed to send data"; 
    192     return FALSE; 
    193     } 
    194  
    195   $response[] = join(': ', $SMTP_CONN->getResponse()); 
    196   return TRUE; 
    197   } 
     53{ 
     54    $registry  = rc_registry::getInstance(); 
     55    $SMTP_CONN = $registry->get('SMTP_CONN', 'core'); 
     56    $CONFIG    = $registry->get('CONFIG', 'core'); 
     57 
     58    $smtp_timeout = null; 
     59    $smtp_host = $CONFIG['smtp_server']; 
     60    $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25; 
     61    $smtp_host_url = parse_url($CONFIG['smtp_server']); 
     62 
     63    // overwrite port 
     64    if ($smtp_host_url['host'] && $smtp_host_url['port']) { 
     65        $smtp_host = $smtp_host_url['host']; 
     66        $smtp_port = $smtp_host_url['port']; 
     67    } 
     68 
     69    // re-write smtp host 
     70    if ($smtp_host_url['host'] && $smtp_host_url['scheme']) { 
     71        $smtp_host = sprintf('%s://%s', $smtp_host_url['scheme'], $smtp_host_url['host']); 
     72    } 
     73 
     74    // create Net_SMTP object and connect to server 
     75    if (!is_object($smtp_conn)) { 
     76        $helo_host = !empty($_SERVER['server_name']) ? $_SERVER['server_name'] : 'localhost'; 
     77        $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); 
     78 
     79        // set debugging 
     80        if ($CONFIG['debug_level'] & 8) { 
     81            $SMTP_CONN->setDebug(TRUE); 
     82        } 
     83        $registry->set('SMTP_CONN', $SMTP_CONN, 'core'); 
     84 
     85        // try to connect to server and exit on failure 
     86        $result = $SMTP_CONN->connect($smtp_timeout); 
     87        if (PEAR::isError($result)) { 
     88            $SMTP_CONN = $registry->set('SMTP_CONN', null, 'core'); 
     89            $response[] = "Connection failed: " . $result->getMessage(); 
     90            return FALSE; 
     91        } 
     92 
     93        // attempt to authenticate to the SMTP server 
     94        if ($CONFIG['smtp_user'] && $CONFIG['smtp_pass']) { 
     95            if (strstr($CONFIG['smtp_user'], '%u')) 
     96                $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']); 
     97            else 
     98                $smtp_user = $CONFIG['smtp_user']; 
     99 
     100            if (strstr($CONFIG['smtp_pass'], '%p')) 
     101                $smtp_pass = str_replace('%p', decrypt_passwd($_SESSION['password']), $CONFIG['smtp_pass']); 
     102            else 
     103                $smtp_pass = $CONFIG['smtp_pass']; 
     104 
     105            $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; 
     106            $result = $SMTP_CONN->auth($smtp_user, $smtp_pass, $smtp_auth_type); 
     107            $registry->set('SMTP_CONN', $SMTP_CONN, 'core'); 
     108 
     109            if (PEAR::isError($result)) { 
     110                smtp_reset(); 
     111                $response[] .= "Authentication failure: ".$result->getMessage(); 
     112                return FALSE; 
     113            } 
     114        } 
     115    } 
     116 
     117 
     118    // prepare message headers as string 
     119    if (is_array($headers)) { 
     120        $headerElements = smtp_prepare_headers($headers); 
     121        if (!$headerElements) { 
     122            smtp_reset(); 
     123            return FALSE; 
     124        } 
     125        list($from, $text_headers) = $headerElements; 
     126    } 
     127    else if (is_string($headers)) { 
     128        $text_headers = $headers; 
     129    } 
     130    else { 
     131        smtp_reset(); 
     132        $response[] .= "Invalid message headers"; 
     133        return FALSE; 
     134    } 
     135 
     136    // exit if no from address is given 
     137    if (!isset($from)) { 
     138        smtp_reset(); 
     139        $response[] .= "No From address has been provided"; 
     140        return FALSE; 
     141    } 
     142 
     143 
     144    // set From: address 
     145    if (PEAR::isError($SMTP_CONN->mailFrom($from))) { 
     146        smtp_reset(); 
     147        $response[] .= "Failed to set sender '$from'"; 
     148        return FALSE; 
     149    } 
     150    $registry->set('SMTP_CONN', $SMTP_CONN, 'core'); 
     151 
     152    // prepare list of recipients 
     153    $recipients = smtp_parse_rfc822($recipients); 
     154    if (PEAR::isError($recipients)) { 
     155        smtp_reset(); 
     156        return FALSE; 
     157    } 
     158 
     159 
     160    // set mail recipients 
     161    foreach ($recipients as $recipient) { 
     162        if (PEAR::isError($SMTP_CONN->rcptTo($recipient))) { 
     163            smtp_reset(); 
     164            $response[] .= "Failed to add recipient '$recipient'"; 
     165            return FALSE; 
     166        } 
     167    } 
     168 
     169 
     170    // Concatenate headers and body so it can be passed by reference to SMTP_CONN->data 
     171    // so preg_replace in SMTP_CONN->quotedata will store a reference instead of a copy. 
     172    // We are still forced to make another copy here for a couple ticks so we don't really 
     173    // get to save a copy in the method call. 
     174    $data = $text_headers . "\r\n" . $body; 
     175 
     176    // unset old vars to save data and so we can pass into SMTP_CONN->data by reference. 
     177    unset($text_headers, $body); 
     178 
     179    // Send the message's headers and the body as SMTP data. 
     180    if (PEAR::isError($SMTP_CONN->data($data))) { 
     181        smtp_reset(); 
     182        $response[] .= "Failed to send data"; 
     183        return FALSE; 
     184    } 
     185 
     186    $response[] = join(': ', $SMTP_CONN->getResponse()); 
     187    return TRUE; 
     188} 
    198189 
    199190 
     
    204195 */ 
    205196function smtp_reset() 
    206   { 
    207   global $SMTP_CONN; 
    208  
    209   if (is_object($SMTP_CONN)) 
    210     { 
    211     $SMTP_CONN->rset(); 
    212     smtp_disconnect(); 
    213     } 
    214   } 
     197{ 
     198    $registry  = rc_registry::getInstance(); 
     199    $SMTP_CONN = $registry->get('SMTP_CONN', 'core'); 
     200 
     201    if (is_object($SMTP_CONN)) { 
     202        $SMTP_CONN->reset(); 
     203        smtp_disconnect(); 
     204    } 
     205} 
    215206 
    216207 
     
    221212 */ 
    222213function smtp_disconnect() 
    223   { 
    224   global $SMTP_CONN; 
    225  
    226   if (is_object($SMTP_CONN)) 
    227     { 
    228     $SMTP_CONN->disconnect(); 
    229     $SMTP_CONN = null; 
    230     } 
    231   } 
     214{ 
     215    $registry  = rc_registry::getInstance(); 
     216    $SMTP_CONN = $registry->get('SMTP_CONN', 'core'); 
     217 
     218    if (is_object($SMTP_CONN)) { 
     219        $SMTP_CONN->disconnect(); 
     220        $registry->set('SMTP_CONN', NULL, 'core'); 
     221    } 
     222} 
    232223 
    233224 
     
    249240 */ 
    250241function smtp_prepare_headers($headers) 
    251   { 
    252   $lines = array(); 
    253   $from = null; 
    254  
    255   foreach ($headers as $key => $value) 
    256     { 
    257     if (strcasecmp($key, 'From') === 0) 
    258       { 
    259       $addresses = smtp_parse_rfc822($value); 
    260  
    261       if (is_array($addresses)) 
    262         $from = $addresses[0]; 
    263  
    264       // Reject envelope From: addresses with spaces. 
    265       if (strstr($from, ' ')) 
    266         return FALSE; 
    267  
    268  
    269       $lines[] = $key . ': ' . $value; 
    270       } 
    271     else if (strcasecmp($key, 'Received') === 0) 
    272       { 
    273       $received = array(); 
    274       if (is_array($value)) 
    275         { 
    276         foreach ($value as $line) 
    277           $received[] = $key . ': ' . $line; 
    278         } 
    279       else 
    280         { 
    281         $received[] = $key . ': ' . $value; 
    282         } 
    283  
    284       // Put Received: headers at the top.  Spam detectors often 
    285       // flag messages with Received: headers after the Subject: 
    286       // as spam. 
    287       $lines = array_merge($received, $lines); 
    288       } 
    289  
    290     else 
    291       { 
    292       // If $value is an array (i.e., a list of addresses), convert 
    293       // it to a comma-delimited string of its elements (addresses). 
    294       if (is_array($value)) 
    295         $value = implode(', ', $value); 
    296  
    297       $lines[] = $key . ': ' . $value; 
    298       } 
    299     } 
    300  
    301   return array($from, join(SMTP_MIME_CRLF, $lines) . SMTP_MIME_CRLF); 
    302   } 
     242{ 
     243    $lines = array(); 
     244    $from = null; 
     245 
     246    foreach ($headers as $key => $value) { 
     247        if (strcasecmp($key, 'From') === 0) { 
     248            $addresses = smtp_parse_rfc822($value); 
     249 
     250            if (is_array($addresses)) { 
     251                $from = $addresses[0]; 
     252            } 
     253            // Reject envelope From: addresses with spaces. 
     254            if (strstr($from, ' ')) { 
     255                return FALSE; 
     256            } 
     257            $lines[] = $key . ': ' . $value; 
     258        } 
     259        else if (strcasecmp($key, 'Received') === 0) { 
     260            $received = array(); 
     261            if (is_array($value))  { 
     262                foreach ($value as $line) { 
     263                    $received[] = $key . ': ' . $line; 
     264                } 
     265            } 
     266            else { 
     267                $received[] = $key . ': ' . $value; 
     268            } 
     269 
     270            // Put Received: headers at the top.  Spam detectors often 
     271            // flag messages with Received: headers after the Subject: 
     272            // as spam. 
     273            $lines = array_merge($received, $lines); 
     274        } 
     275        else { 
     276            // If $value is an array (i.e., a list of addresses), convert 
     277            // it to a comma-delimited string of its elements (addresses). 
     278            if (is_array($value)) { 
     279                $value = implode(', ', $value); 
     280            } 
     281            $lines[] = $key . ': ' . $value; 
     282        } 
     283    } 
     284    return array($from, join(SMTP_MIME_CRLF, $lines) . SMTP_MIME_CRLF); 
     285} 
    303286 
    304287 
     
    317300 */ 
    318301function smtp_parse_rfc822($recipients) 
    319   { 
    320   // if we're passed an array, assume addresses are valid and implode them before parsing. 
    321   if (is_array($recipients)) 
    322     $recipients = implode(', ', $recipients); 
    323      
    324   $addresses = array(); 
    325   $recipients = smtp_explode_quoted_str(",", $recipients); 
    326    
    327   reset($recipients); 
    328   while (list($k, $recipient) = each($recipients)) 
    329     { 
    330   $a = explode(" ", $recipient); 
    331   while (list($k2, $word) = each($a)) 
    332     { 
    333       if ((strpos($word, "@") > 0) && (strpos($word, "\"")===false)) 
    334         { 
    335         $word = ereg_replace('^<|>$', '', trim($word)); 
    336         if (in_array($word, $addresses)===false) 
    337           array_push($addresses, $word); 
    338         } 
    339       } 
    340     } 
    341   return $addresses; 
    342   } 
     302{ 
     303    // if we're passed an array, assume addresses are valid and implode them before parsing. 
     304    if (is_array($recipients)) 
     305        $recipients = implode(', ', $recipients); 
     306 
     307    $addresses = array(); 
     308    $recipients = smtp_explode_quoted_str(",", $recipients); 
     309 
     310    reset($recipients); 
     311    while (list($k, $recipient) = each($recipients)) { 
     312        $a = explode(" ", $recipient); 
     313        while (list($k2, $word) = each($a)) { 
     314            if ((strpos($word, "@") > 0) && (strpos($word, "\"")===false)) { 
     315                $word = ereg_replace('^<|>$', '', trim($word)); 
     316                if (in_array($word, $addresses) === FALSE) { 
     317                    array_push($addresses, $word); 
     318                } 
     319            } 
     320        } 
     321    } 
     322    return $addresses; 
     323} 
    343324 
    344325 
    345326function smtp_explode_quoted_str($delimiter, $string) 
    346   { 
    347   $quotes=explode("\"", $string); 
    348   while ( list($key, $val) = each($quotes)) 
    349     if (($key % 2) == 1)  
    350       $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]); 
     327{ 
     328    $quotes=explode("\"", $string); 
     329    while ( list($key, $val) = each($quotes)) { 
     330        if (($key % 2) == 1) { 
     331            $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]); 
     332        } 
     333    } 
    351334    $string=implode("\"", $quotes); 
    352    
     335 
    353336    $result=explode($delimiter, $string); 
    354     while (list($key, $val) = each($result)) 
    355       $result[$key] = str_replace("_!@!_", $delimiter, $result[$key]); 
    356  
    357   return $result; 
    358   }  
    359  
    360  
     337    while (list($key, $val) = each($result)) { 
     338        $result[$key] = str_replace("_!@!_", $delimiter, $result[$key]); 
     339    } 
     340    return $result; 
     341} 
    361342?> 
  • branches/devel-vnext/program/include/session.inc

    r622 r623  
    4242    $SESS_CLIENT_IP = $registry->get('SESS_CLIENT_IP', 'core'); 
    4343 
    44     if ($DB->is_error()) 
     44    if ($DB->is_error()) { 
    4545        return FALSE; 
    46  
     46    } 
    4747    $_query = "SELECT vars, ip, ".$DB->unixtimestamp('changed')." AS changed"; 
    4848    $_query.= " FROM " . rc_main::get_table_name('session'); 
     
    147147    if (sizeof($a_exp_sessions)) { 
    148148        // delete session cache records 
    149         $DB->query("DELETE FROM ".rc_main::get_table_name('cache')." 
    150                 WHERE  session_id IN ('".join("','", $a_exp_sessions)."')"); 
     149        $_query = "DELETE FROM " . rc_main::get_table_name('cache'); 
     150        $_query.= " WHERE session_id IN ('" . join("','", $a_exp_sessions) . "')"; 
     151        $DB->query($_query); 
    151152 
    152153        // delete session records 
    153         $DB->query("DELETE FROM ".rc_main::get_table_name('session')." 
    154                 WHERE sess_id IN ('".join("','", $a_exp_sessions)."')"); 
     154        $_query = "DELETE FROM " . rc_main::get_table_name('session'); 
     155        $_query.= " WHERE sess_id IN ('" . join("','", $a_exp_sessions) . "')"; 
     156        $DB->query($_query); 
    155157    } 
    156158 
    157159    // also run message cache GC 
    158     rcmail_message_cache_gc(); 
    159     rcmail_temp_gc(); 
    160  
     160    rc_main::rcmail_message_cache_gc(); 
     161    rc_main::rcmail_temp_gc(); 
    161162    return TRUE; 
    162163} 
  • branches/devel-vnext/program/js/app.js

    r602 r623  
    14831483    // mark all message rows as read/unread 
    14841484    var icn_src; 
     1485    if (typeof(this.message_list) == 'undefined') { 
     1486        return; 
     1487    } 
    14851488    var rows = this.message_list.rows; 
    14861489    for (var i=0; i<a_uids.length; i++) 
     
    19011904        $(form).attr('enctype', 'multipart/form-data'); 
    19021905        $(form).submit(); 
    1903        
     1906 
    19041907        // set reference to the form object 
    19051908        this.gui_objects.attachmentform = form; 
  • branches/devel-vnext/program/steps/addressbook/edit.inc

    r589 r623  
    2121 
    2222 
    23 if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) 
    24   $OUTPUT->set_env('cid', $record['ID']); 
    25  
     23if (($cid = rc_main::get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) { 
     24    $OUTPUT->set_env('cid', $record['ID']); 
     25} 
    2626// adding not allowed here 
    27 if ($CONTACTS->readonly) 
    28 { 
    29   $OUTPUT->show_message('sourceisreadonly'); 
    30   rcmail_overwrite_action('show'); 
    31   return; 
     27if ($CONTACTS->readonly) { 
     28    $OUTPUT->show_message('sourceisreadonly'); 
     29    rcmail_overwrite_action('show'); 
     30    return; 
    3231} 
    3332 
    3433function rcmail_contact_editform($attrib) 
    3534{ 
    36   global $CONTACTS, $OUTPUT; 
     35    $registry = rc_registry::getInstance(); 
     36    $CONTACTS = $registry->get('CONTACTS', 'core'); 
     37    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    3738 
    38   // check if we have a valid result 
    39   if ($GLOBALS['_action'] != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first()))) 
    40   { 
    41     $OUTPUT->show_message('contactnotfound'); 
    42     return false; 
    43   } 
     39    // check if we have a valid result 
     40    if ($GLOBALS['_action'] != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first()))) 
     41    { 
     42        $OUTPUT->show_message('contactnotfound'); 
     43        return false; 
     44    } 
    4445 
    45   // add some labels to client 
    46   rcube_add_label('noemailwarning'); 
    47   rcube_add_label('nonamewarning'); 
     46    // add some labels to client 
     47    rcube_add_label('noemailwarning'); 
     48    rcube_add_label('nonamewarning'); 
    4849 
    49   list($form_start, $form_end) = get_form_tags($attrib); 
    50   unset($attrib['form']); 
     50    list($form_start, $form_end) = get_form_tags($attrib); 
     51    unset($attrib['form']); 
    5152 
    52   // a specific part is requested 
    53   if ($attrib['part']) 
    54   { 
    55     $out = $form_start; 
    56     $out .= rcmail_get_edit_field($attrib['part'], $record[$attrib['part']], $attrib);  
    57     return $out; 
    58   } 
     53    // a specific part is requested 
     54    if ($attrib['part']) { 
     55        $out = $form_start; 
     56        $out .= rcmail_get_edit_field($attrib['part'], $record[$attrib['part']], $attrib);  
     57        return $out; 
     58    } 
    5959 
    6060 
    61   // return the complete address edit form as table 
    62   $out = "$form_start<table>\n\n"; 
     61    // return the complete address edit form as table 
     62    $out = "$form_start<table>\n\n"; 
    6363 
    64   $a_show_cols = array('name', 'firstname', 'surname', 'email'); 
    65   foreach ($a_show_cols as $col) 
    66   { 
    67     $attrib['id'] = 'rcmfd_'.$col; 
    68     $value = rcmail_get_edit_field($col, $record[$col], $attrib); 
    69     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     64    $a_show_cols = array('name', 'firstname', 'surname', 'email'); 
     65    foreach ($a_show_cols as $col) { 
     66        $attrib['id'] = 'rcmfd_'.$col; 
     67        $value = rcmail_get_edit_field($col, $record[$col], $attrib); 
     68        $out .= sprintf( 
     69                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    7070                    $attrib['id'], 
    71                     Q(rcube_label($col)), 
    72                     $value); 
    73   } 
    74  
    75   $out .= "\n</table>$form_end"; 
    76  
    77   return $out;   
     71                    rc_main::Q(rcube_label($col)), 
     72                    $value 
     73        ); 
     74    } 
     75    $out .= "\n</table>$form_end"; 
     76    return $out;   
    7877} 
    7978 
     
    8382// similar function as in /steps/settings/edit_identity.inc 
    8483function get_form_tags($attrib) 
    85   { 
    86   global $CONTACTS, $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;   
     84{ 
     85    $registry          = rc_registry::getInstance(); 
     86    $CONTACTS          = $registry->get('CONTACTS', 'core'); 
     87    $OUTPUT            = $registry->get('OUTPUT', 'core'); 
     88    $EDIT_FORM         = $registry->get('EDIT_FORM', 'core'); 
     89    $SESS_HIDDEN_FIELD = $registry->get('SESS_HIDDEN_FIELD', 'core'); 
    8790 
    88   $result = $CONTACTS->get_result(); 
    89   $form_start = ''; 
    90   if (!strlen($EDIT_FORM)) 
    91     { 
    92     $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); 
    93     $hiddenfields->add(array('name' => '_action', 'value' => 'save', 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); 
     91    $result = $CONTACTS->get_result(); 
     92    $form_start = ''; 
     93    if (!strlen($EDIT_FORM)) { 
     94        $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); 
     95        $hiddenfields->add( 
     96                        array( 
     97                            'name' => '_action', 
     98                            'value' => 'save', 
     99                            'source' => rc_main::get_input_value('_source', RCUBE_INPUT_GPC) 
     100                        ) 
     101        ); 
    94102     
    95     if (($result = $CONTACTS->get_result()) && ($record = $result->first())) 
    96       $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 
    97      
    98     $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 
    99     $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 
    100     $form_start .= $hiddenfields->show(); 
     103        if (($result = $CONTACTS->get_result()) && ($record = $result->first())) { 
     104            $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 
     105        } 
     106        $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 
     107        $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 
     108        $form_start .= $hiddenfields->show(); 
    101109    } 
    102110     
    103   $form_end = (strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; 
    104   $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; 
     111    $form_end = (strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; 
     112    $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; 
    105113   
    106   if (!strlen($EDIT_FORM)) 
    107     $OUTPUT->add_gui_object('editform', $form_name); 
    108    
    109   $EDIT_FORM = $form_name; 
     114    if (!strlen($EDIT_FORM)) { 
     115        $OUTPUT->add_gui_object('editform', $form_name); 
     116    } 
     117    $EDIT_FORM = $form_name; 
     118    $registry->set('EDIT_FORM', $EDIT_FORM, 'core'); 
    110119 
    111   return array($form_start, $form_end);   
    112   } 
     120    return array($form_start, $form_end);   
     121} 
    113122 
    114123 
    115124 
    116 if (!$CONTACTS->get_result() && template_exists('addcontact')) 
    117   parse_template('addcontact'); 
    118  
     125if (!$CONTACTS->get_result() && template_exists('addcontact')) { 
     126    rc_main::parse_template('addcontact'); 
     127} 
    119128// this will be executed if no template for addcontact exists 
    120 parse_template('editcontact'); 
     129rc_main::parse_template('editcontact'); 
    121130?> 
  • branches/devel-vnext/program/steps/addressbook/func.inc

    r589 r623  
    2020*/ 
    2121 
    22 require_once('include/rcube_contacts.inc'); 
    23 require_once('include/rcube_ldap.inc'); 
     22require_once 'include/rcube_contacts.inc'; 
     23require_once 'include/rcube_ldap.inc'; 
    2424 
    2525// instantiate a contacts object according to the given source 
     
    7272     
    7373  // allow the following attributes to be added to the <ul> tag 
    74   $out = '<ul' . create_attrib_string($attrib, array('style', 'class', 'id')) . ">\n"; 
     74  $out = '<ul' . rc_main::create_attrib_string($attrib, array('style', 'class', 'id')) . ">\n"; 
    7575  $out .= sprintf($line_templ, 
    7676    'rcmli'.$local_id, 
    7777    !$current ? 'selected' : '', 
    78     Q(rcmail_url('list', array('_source' => 0))), 
     78    rc_main::Q(rc_main::rcmail_url('list', array('_source' => 0))), 
    7979    JS_OBJECT_NAME, 
    8080    $local_id, 
     
    8989  foreach ((array)$CONFIG['ldap_public'] as $id => $prop) 
    9090  { 
    91     $js_id = JQ($id); 
     91    $js_id = rc_main_::JQ($id); 
    9292    $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id); 
    9393    $out .= sprintf($line_templ, 
    9494      'rcmli'.$dom_id, 
    9595      $current == $id ? 'selected' : '', 
    96       Q(rcmail_url('list', array('_source' => $id))), 
    97       JS_OBJECT_NAME, 
    98       $js_id, 
    99       JS_OBJECT_NAME, 
    100       $js_id, 
    101       JS_OBJECT_NAME, 
    102       $js_id, 
    103       JS_OBJECT_NAME, 
    104       $js_id, 
    105       !empty($prop['name']) ? Q($prop['name']) : Q($id)); 
     96      rc_main::Q(rc_main::rcmail_url('list', array('_source' => $id))), 
     97      JS_OBJECT_NAME, 
     98      $js_id, 
     99      JS_OBJECT_NAME, 
     100      $js_id, 
     101      JS_OBJECT_NAME, 
     102      $js_id, 
     103      JS_OBJECT_NAME, 
     104      $js_id, 
     105      !empty($prop['name']) ? rc_main::Q($prop['name']) : rc_main::Q($id)); 
    106106  } 
    107107   
     
    177177     
    178178  $attrib['name'] = $attrib['id']; 
    179   $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); 
     179  $attrib_str = rc_main::create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); 
    180180 
    181181  $OUTPUT->set_env('contentframe', $attrib['name']); 
     
    195195 
    196196  // allow the following attributes to be added to the <span> tag 
    197   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); 
     197  $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id')); 
    198198 
    199199  $out = '<span' . $attrib_str . '>'; 
  • branches/devel-vnext/program/steps/addressbook/mailto.inc

    r589 r623  
    2020*/ 
    2121 
    22 $cid = get_input_value('_cid', RCUBE_INPUT_GET); 
     22$cid        = rc_main::get_input_value('_cid', RCUBE_INPUT_GET); 
    2323$recipients = null; 
    24 $mailto = array(); 
     24$mailto     = array(); 
    2525 
    26 if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && $CONTACTS->ready) 
    27 { 
    28   $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid); 
     26if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && $CONTACTS->ready) { 
     27    $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid); 
    2928 
    30   while (is_object($recipients) && ($rec = $recipients->iterate())) 
    31     $mailto[] = format_email_recipient($rec['email'], $rec['name']); 
     29    while (is_object($recipients) && ($rec = $recipients->iterate())) { 
     30        $mailto[] = rc_main::format_email_recipient($rec['email'], $rec['name']); 
     31    } 
    3232} 
    3333 
    34 if (!empty($mailto)) 
    35 { 
    36   $mailto_str = join(', ', $mailto); 
    37   $mailto_id = substr(md5($mailto_str), 0, 16); 
    38   $_SESSION['mailto'][$mailto_id] = $mailto_str; 
    39   $OUTPUT->command('redirect', rcmail_url('compose', array('_mailto' => $mailto_id), 'mail')); 
     34if (!empty($mailto)) { 
     35    $mailto_str = join(', ', $mailto); 
     36    $mailto_id = substr(md5($mailto_str), 0, 16); 
     37    $_SESSION['mailto'][$mailto_id] = $mailto_str; 
     38    $OUTPUT->command('redirect', rc_main::rcmail_url('compose', array('_mailto' => $mailto_id), 'mail')); 
    4039} 
    41 else 
    42   $OUTPUT->show_message('nocontactsfound', 'warning'); 
    43  
    44  
     40else { 
     41    $OUTPUT->show_message('nocontactsfound', 'warning'); 
     42} 
    4543// send response 
    4644$OUTPUT->send(); 
    47  
    4845?> 
  • branches/devel-vnext/program/steps/mail/check_recent.inc

    r610 r623  
    2020*/ 
    2121 
    22 tfk_debug('About to get some mailboxes.'); 
     22rc_main::tfk_debug('About to get some mailboxes.'); 
    2323 
    2424$a_mailboxes = $IMAP->list_mailboxes(); 
    2525 
    26 tfk_debug('Mailboxes: ' . var_export($a_mailboxes, true)); 
     26rc_main::tfk_debug('Mailboxes: ' . var_export($a_mailboxes, true)); 
    2727 
    2828foreach ($a_mailboxes as $mbox_name) { 
  • branches/devel-vnext/program/steps/mail/compose.inc

    r592 r623  
    3535        $status = @unlink($_SESSION['compose']['attachments'][$id]['path']); 
    3636        if ($status === false) { 
    37             tfk_debug('Could not delete attachment.'); 
     37            rc_main::tfk_debug('Could not delete attachment.'); 
    3838        } 
    3939        $_SESSION['compose']['attachments'][$id] = NULL; 
     
    4747$CONFIG['htmleditor'] = false; 
    4848 
    49 $MESSAGE_FORM = NULL; 
    50 $MESSAGE      = NULL; 
     49$MESSAGE_FORM = $registry->set('MESSAGE_FORM', NULL, 'core'); 
     50$MESSAGE      = $registry->set('MESSAGE', NULL, 'core'); 
    5151 
    5252// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or 
     
    5555// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear 
    5656 
    57 if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_value('_id', RCUBE_INPUT_GET)) { 
     57if ( 
     58    !is_array($_SESSION['compose']) 
     59    || $_SESSION['compose']['id'] != rc_main::get_input_value('_id', RCUBE_INPUT_GET) 
     60) { 
    5861    rcmail_compose_cleanup(); 
    5962    $_SESSION['compose'] = array('id' => uniqid(rand())); 
     
    6164 
    6265// add some labels to client 
    63 rcube_add_label( 
     66rc_main::rcube_add_label( 
    6467    'nosubject', 
    6568    'norecipientwarning', 
     
    8184 
    8285// get reference message and set compose mode 
    83 if ($msg_uid = get_input_value('_reply_uid', RCUBE_INPUT_GET)) { 
     86if ($msg_uid = rc_main::get_input_value('_reply_uid', RCUBE_INPUT_GET)) { 
    8487    $compose_mode = RCUBE_COMPOSE_REPLY; 
    8588} 
    86 elseif ($msg_uid = get_input_value('_forward_uid', RCUBE_INPUT_GET)) { 
     89elseif ($msg_uid = rc_main::get_input_value('_forward_uid', RCUBE_INPUT_GET)) { 
    8790    $compose_mode = RCUBE_COMPOSE_FORWARD; 
    8891} 
    89 elseif ($msg_uid = get_input_value('_draft_uid', RCUBE_INPUT_GET)) { 
     92elseif ($msg_uid = rc_main::get_input_value('_draft_uid', RCUBE_INPUT_GET)) { 
    9093    $compose_mode = RCUBE_COMPOSE_DRAFT; 
    9194} 
     95$registry->set('compose_mode', $compose_mode, 'core'); 
    9296 
    9397if (empty($msg_uid) === false) { 
    9498 
    95     tfk_debug('We got uid: ' . $msg_uid); 
    96     tfk_debug('Compose mode: '  . $compose_mode); 
     99    rc_main::tfk_debug('We got uid: ' . $msg_uid); 
     100    rc_main::tfk_debug('Compose mode: '  . $compose_mode); 
    97101 
    98102    // similar as in program/steps/mail/show.inc 
     
    104108 
    105109 
    106     tfk_debug('Reference message: ' . var_export($MESSAGE, true)); 
     110    rc_main::tfk_debug('Reference message: ' . var_export($MESSAGE, true)); 
    107111 
    108112    if ($compose_mode == RCUBE_COMPOSE_REPLY) { 
     
    124128    } 
    125129} 
     130$registry->set('MESSAGE', $MESSAGE, 'core'); 
    126131 
    127132/****** compose mode functions ********/ 
    128133require_once 'include/rcube/rcmail_compose.php'; 
    129134 
    130 tfk_debug('Passed require for rcmail_compose functions.'); 
     135rc_main::tfk_debug('Passed require for rcmail_compose functions.'); 
    131136 
    132137// register UI objects 
     
    155160    while ($sql_arr = $result->iterate()) { 
    156161        if ($sql_arr['email']) { 
    157             $a_contacts[] = format_email_recipient($sql_arr['email'], JQ($sql_arr['name'])); 
     162            $a_contacts[] = rc_main::format_email_recipient( 
     163                                $sql_arr['email'], 
     164                                rc_main::JQ($sql_arr['name']) 
     165            ); 
    158166        } 
    159167    } 
  • branches/devel-vnext/program/steps/mail/folders.inc

    r608 r623  
    2222 
    2323// send EXPUNGE command 
    24 if ($_action=='expunge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))) { 
     24if ($_action=='expunge' && ($mbox = rc_main::get_input_value('_mbox', RCUBE_INPUT_POST))) { 
    2525    $success = $IMAP->expunge($mbox); 
    2626 
    27     tfk_debug('Expung: ' . $mbox); 
     27    rc_main::tfk_debug('Expung: ' . $mbox); 
    2828 
    2929    // reload message list if current mailbox 
     
    3232        $_action = 'list'; 
    3333 
    34         tfk_debug('Trying to reload list.'); 
     34        rc_main::tfk_debug('Trying to reload list.'); 
    3535 
    3636        $_file = dirname(__FILE__); 
     
    4747} 
    4848// clear mailbox 
    49 elseif ($_action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))) { 
     49elseif ($_action=='purge' && ($mbox = rc_main::get_input_value('_mbox', RCUBE_INPUT_POST))) { 
    5050    $success = $IMAP->clear_mailbox($mbox); 
    5151 
  • branches/devel-vnext/program/steps/mail/func.inc

    r622 r623  
    3232} 
    3333// set imap properties and session vars 
    34 if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC)) { 
     34if ($mbox = rc_main::get_input_value('_mbox', RCUBE_INPUT_GPC)) { 
    3535    $IMAP->set_mailbox($mbox); 
    3636    $_SESSION['mbox'] = $mbox; 
     
    6363// define url for getting message parts 
    6464if (strlen($_GET['_uid'])) { 
    65   $GET_URL = rcmail_url( 
     65    $GET_URL = rc_main::rcmail_url( 
    6666                'get', 
    6767                array( 
    6868                    '_mbox' => $IMAP->get_mailbox_name(), 
    69                     '_uid'  => get_input_value('_uid', RCUBE_INPUT_GET) 
     69                    '_uid'  => rc_main::get_input_value('_uid', RCUBE_INPUT_GET) 
    7070                ) 
    7171    ); 
     72    $registry->set('GET_URL', $GET_URL, 'core'); 
    7273} 
    7374 
     
    8687} 
    8788if (!$OUTPUT->ajax_call) { 
    88     rcube_add_label('checkingmail'); 
     89    rc_main::rcube_add_label('checkingmail'); 
    8990} 
    9091 
     
    106107 
    107108    // add some labels to client 
    108     rcube_add_label('purgefolderconfirm'); 
    109     rcube_add_label('deletemessagesconfirm'); 
     109    rc_main::rcube_add_label('purgefolderconfirm'); 
     110    rc_main::rcube_add_label('deletemessagesconfirm'); 
    110111 
    111112    // $mboxlist_start = rcube_timer(); 
     
    280281                    $unread_count ? ' unread' : '', 
    281282                    $folder['id']==$mbox_name ? ' selected' : '', 
    282                     rc_main::Q(rcmail_url('', array('_mbox' => $folder['id']))), 
     283                    rc_main::Q(rc_main::rcmail_url('', array('_mbox' => $folder['id']))), 
    283284                    JS_OBJECT_NAME, 
    284285                    $js_name, 
     
    353354function rcmail_message_list($attrib) 
    354355{ 
    355     global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT; 
     356    $registry  = rc_registry::getInstance(); 
     357    $IMAP      = $registry->get('IMAP', 'core'); 
     358    $CONFIG    = $registry->get('CONFIG', 'core'); 
     359    $COMM_PATH = $registry->get('COMM_PATH', 'core'); 
     360    $OUTPUT    = $registry->get('OUTPUT', 'core'); 
    356361 
    357362    $skin_path = $CONFIG['skin_path']; 
     
    363368 
    364369    // add some labels to client 
    365     rcube_add_label('from', 'to'); 
     370    rc_main::rcube_add_label('from', 'to'); 
    366371 
    367372    // get message headers 
     
    578583                            '<a href="%s" onclick="return false">%s</a>', 
    579584                            rc_main::Q( 
    580                                 rcmail_url( 
     585                                rc_main::rcmail_url( 
    581586                                    $action, 
    582587                                    array($uid_param=>$header->uid, '_mbox'=>$mbox) 
     
    592597            else if ($col=='date') { 
    593598                $cont_normalized.= @strtotime($header->date); 
    594                 $cont            = format_date($header->date); 
     599                $cont            = rc_main::format_date($header->date); 
    595600            } 
    596601            else { 
     
    689694function rcmail_js_message_list($a_headers, $insert_top=FALSE) 
    690695{ 
    691     global $CONFIG, $IMAP, $OUTPUT; 
     696    $registry = rc_registry::getInstance(); 
     697    $CONFIG   = $registry->get('CONFIG', 'core'); 
     698    $IMAP     = $registry->get('IMAP', 'core'); 
     699    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
    692700 
    693701    $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); 
     
    724732                $cont = sprintf( 
    725733                            '<a href="%s" onclick="return false">%s</a>', 
    726                             rc_main::Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), 
     734                            rc_main::Q( 
     735                                rc_main::rcmail_url( 
     736                                    $action, 
     737                                    array($uid_param=>$header->uid, '_mbox'=>$mbox) 
     738                                ) 
     739                            ), 
    727740                            $cont 
    728741                ); 
     
    732745            } 
    733746            elseif ($col=='date') { 
    734                 $cont = format_date($header->date); 
     747                $cont = rc_main::format_date($header->date); 
    735748            } 
    736749            else { 
     
    796809 
    797810    // allow the following attributes to be added to the <span> tag 
    798     $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); 
     811    $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id')); 
    799812 
    800813 
     
    921934        $body = preg_replace('/charset=[a-z0-9\-]+/i', '', $body); 
    922935 
    923         if ($safe !=== false) { 
     936        if ($safe !== FALSE) { 
    924937            return rc_main::Q($body, 'show', FALSE); 
    925938        } 
     
    949962            if (preg_match($pattern, $body)) { 
    950963                $REMOTE_OBJECTS = TRUE; 
     964                $registry->set('REMOTE_OBJECTS', true, 'core'); 
    951965                break; 
    952966            } 
     
    10271041    $rpl_count = $registry->get('rpl_count', 'core'); 
    10281042 
    1029     if (is_null($rpl_count)) { 
    1030         $rpl_count = 0; 
     1043    if (empty($rpl_count)) { 
     1044        $rpl_count = (int) 0; 
    10311045    } 
    10321046    $rep[$rpl_count] = stripslashes($str); 
    1033     $resp = "##string_replacement{".($rpl_count++)."}##"; 
    1034  
     1047    $resp = "##string_replacement{" . $rpl_count . "}##"; 
     1048    //rc_main::tfk_debug("replace: $resp"); 
     1049    //rc_main::tfk_debug("/ str: $str, count: $rpl_count, total: " . var_export($rep, true)); 
     1050 
     1051    $rpl_count++; 
    10351052    $registry->set('rpl_count', $rpl_count, 'core'); 
    10361053 
     
    11081125        } 
    11091126        // print html/plain part 
    1110         else if ($html_part!==NULL && $prefer_html) 
     1127        else if (is_null($html_part) !== TRUE && $prefer_html) { 
    11111128            $print_part = &$structure->parts[$html_part]; 
    1112         else if ($enriched_part!==NULL) 
     1129        } 
     1130        else if (is_null($enriched_part) !== TRUE) { 
    11131131            $print_part = &$structure->parts[$enriched_part]; 
    1114         else if ($plain_part!==NULL) 
     1132        } 
     1133        else if (is_null($plain_part) !== TRUE) { 
    11151134            $print_part = &$structure->parts[$plain_part]; 
    1116  
     1135        } 
    11171136        // show message body 
    11181137        if (is_object($print_part)) { 
     
    11921211                if ($message_ctype_secondary=='related' && $mail_part->headers['content-id']) 
    11931212                { 
    1194                     $mail_part->content_id = preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']); 
     1213                    $mail_part->content_id = preg_replace( 
     1214                                                array('/^</', '/>$/'), 
     1215                                                '', 
     1216                                                $mail_part->headers['content-id'] 
     1217                    ); 
    11951218                    $sa_inline_objects[] = $mail_part; 
    11961219                } 
    11971220                // is regular attachment 
    11981221                else { 
    1199                     if (!$mail_part->filename) 
    1200                         $mail_part->filename = 'file_'.$mail_part->mime_id; 
     1222                    if (!$mail_part->filename) { 
     1223                        $mail_part->filename = 'file_' . $mail_part->mime_id; 
     1224                    } 
    12011225                    $a_attachments[] = $mail_part; 
    12021226                } 
     
    12091233 
    12101234            foreach ($sa_inline_objects as $inline_object) { 
    1211                 $a_replaces['cid:'.$inline_object->content_id] = htmlspecialchars(sprintf($get_url, $inline_object->mime_id)); 
     1235                $a_replaces['cid:'.$inline_object->content_id] = htmlspecialchars( 
     1236                                                                    sprintf( 
     1237                                                                        $get_url, 
     1238                                                                        $inline_object->mime_id 
     1239                                                                    ) 
     1240                ); 
    12121241            } 
    12131242            // add replace array to each content part 
    12141243            // (will be applied later when part body is available) 
    12151244            for ($i=0; $i<count($a_return_parts); $i++) { 
    1216                 if ($a_return_parts[$i]->type=='content') { 
     1245                if ($a_return_parts[$i]->type == 'content') { 
    12171246                    $a_return_parts[$i]->replaces = $a_replaces; 
    12181247                } 
     
    12251254    } 
    12261255    $registry->set('sa_inline_objects', $sa_inline_objects, 'core'); 
     1256 
    12271257    return array($a_return_parts, $a_attachments); 
    12281258} 
     
    12781308        } 
    12791309        if ($hkey=='date' && empty($headers[$hkey]) === false) { 
    1280             $header_value = format_date(strtotime($headers[$hkey])); 
     1310            $header_value = rc_main::format_date(strtotime($headers[$hkey])); 
    12811311        } 
    12821312        elseif(in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to'))) { 
    1283             $header_value = rc_main::Q(rcmail_address_string($headers[$hkey], NULL, $attrib['addicon']), 'show'); 
     1313            $header_value = rc_main::Q( 
     1314                                rcmail_address_string( 
     1315                                    $headers[$hkey], 
     1316                                    NULL, 
     1317                                    $attrib['addicon'] 
     1318                                ), 
     1319                                'show' 
     1320            ); 
    12841321        } 
    12851322        else { 
    1286             $header_value = rc_main::Q(rcube_imap::decode_mime_string($headers[$hkey], $headers['charset'])); 
     1323            $header_value = rc_main::Q( 
     1324                                rcube_imap::decode_mime_string( 
     1325                                    $headers[$hkey], 
     1326                                    $headers['charset'] 
     1327                                ) 
     1328            ); 
    12871329        } 
    12881330        $out .= "\n<tr>\n"; 
    1289         $out .= '<td class="header-title">'.Q(rcube_label($hkey)).":&nbsp;</td>\n"; 
    1290         $out .= '<td class="'.$hkey.'" width="90%">'.$header_value."</td>\n</tr>"; 
     1331        $out .= '<td class="header-title">' . rc_main::Q(rcube_label($hkey)); 
     1332        $out .= ":&nbsp;</td>\n"; 
     1333        $out .= '<td class="' . $hkey . '" width="90%">' . $header_value; 
     1334        $out .= "</td>\n</tr>"; 
    12911335        $header_count++; 
    12921336    } 
     
    13111355    $REMOTE_OBJECTS = $registry->get('REMOTE_OBJECTS', 'core'); 
    13121356 
    1313     if (!is_array($MESSAGE['parts']) && !$MESSAGE['body']) 
     1357    if (!is_array($MESSAGE['parts']) && !$MESSAGE['body']) { 
    13141358        return ''; 
    1315  
    1316     if (!$attrib['id']) 
     1359    } 
     1360    if (!$attrib['id']) { 
    13171361        $attrib['id'] = 'rcmailMsgBody'; 
    1318  
     1362    } 
    13191363    $safe_mode = (bool)$_GET['_safe']; 
    13201364    $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id')); 
     
    15321576    // also replace body definition because we also stripped off the <body> tag 
    15331577    $styles = preg_replace( 
    1534                 array('/(^\s*<!--)|(-->\s*$)/', '/(^\s*|,\s*|\}\s*)([a-z0-9\._][a-z0-9\.\-_]*)/im', '/<<str_replacement\[([0-9]+)\]>>/e', "/$container_id\s+body/i"), 
    1535                 array('', "\\1#$container_id \\2", "\$a_css_values[\\1]", "$container_id div.rcmBody"), 
     1578                array( 
     1579                    '/(^\s*<!--)|(-->\s*$)/', 
     1580                    '/(^\s*|,\s*|\}\s*)([a-z0-9\._][a-z0-9\.\-_]*)/im', 
     1581                    '/<<str_replacement\[([0-9]+)\]>>/e', 
     1582                    "/$container_id\s+body/i" 
     1583                ), 
     1584                array( 
     1585                    '', 
     1586                    "\\1#$container_id \\2", 
     1587                    "\$a_css_values[\\1]", 
     1588                    "$container_id div.rcmBody" 
     1589                ), 
    15361590                $source 
    15371591    ); 
     
    15421596function rcmail_has_html_part($message_parts) 
    15431597{ 
    1544    if (!is_array($message_parts)) 
     1598   if (!is_array($message_parts)) { 
    15451599      return FALSE; 
    1546  
     1600   } 
    15471601   // check all message parts 
    15481602   foreach ($message_parts as $pid => $part) 
     
    16431697        $j++; 
    16441698        if ($PRINT_MODE) { 
    1645             $out .= sprintf('%s &lt;%s&gt;', Q($part['name']), $part['mailto']); 
     1699            $out .= sprintf('%s &lt;%s&gt;', rc_main::Q($part['name']), $part['mailto']); 
    16461700        } 
    16471701        elseif (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { 
  • branches/devel-vnext/program/steps/mail/get.inc

    r589 r623  
    2020*/ 
    2121 
    22 require_once('Mail/mimeDecode.php'); 
     22require_once 'Mail/mimeDecode.php'; 
    2323 
     24$registry = rc_registry::getInstance(); 
    2425 
    2526// show loading page 
    26 if ($_GET['_preload']) 
    27   { 
    28   $url = str_replace('&_preload=1', '', $_SERVER['REQUEST_URI']); 
    29   $message = rcube_label('loadingdata'); 
     27if ($_GET['_preload']) { 
     28    $url = str_replace('&_preload=1', '', $_SERVER['REQUEST_URI']); 
     29    $message = rcube_label('loadingdata'); 
    3030 
    31   print "<html>\n<head>\n" . 
    32         '<meta http-equiv="refresh" content="0; url='.htmlspecialchars($url).'">' . 
    33         "\n</head>\n<body>" . 
    34         $message . 
    35         "\n</body>\n</html>"; 
    36   exit; 
    37   } 
     31    echo "<html>\n<head>\n"; 
     32    echo '<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($url).'">'; 
     33    echo "\n</head>\n<body>"; 
     34    echo $message; 
     35    echo "\n</body>\n</html>"; 
     36    exit; 
     37} 
    3838 
    3939 
    4040// similar code as in program/steps/mail/show.inc 
    41 if ($_GET['_uid']) 
    42   { 
    43   $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 
    44   $MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); 
    45   $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 
    46   } 
     41if ($_GET['_uid']) { 
     42    $MESSAGE = array('UID' => rc_main::get_input_value('_uid', RCUBE_INPUT_GET)); 
     43    $MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); 
     44    $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 
     45    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     46} 
    4747 
    4848 
    4949// show part page 
    50 if ($_GET['_frame']) 
    51   { 
    52   parse_template('messagepart'); 
    53   exit; 
    54   } 
     50if ($_GET['_frame']) { 
     51    parse_template('messagepart'); 
     52    exit; 
     53} 
     54else if ($pid = rc_main::get_input_value('_part', RCUBE_INPUT_GET)) { 
     55    if ($part = $MESSAGE['parts'][$pid]) { 
     56        $ctype_primary = strtolower($part->ctype_primary); 
     57        $ctype_secondary = strtolower($part->ctype_secondary); 
     58        $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary); 
    5559 
    56 else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) 
    57   { 
    58   if ($part = $MESSAGE['parts'][$pid]); 
    59     { 
    60     $ctype_primary = strtolower($part->ctype_primary); 
    61     $ctype_secondary = strtolower($part->ctype_secondary); 
     60        header("Expires: 0"); 
     61        header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
     62        header("Cache-Control: private", false); 
     63        header("Content-Transfer-Encoding: binary"); 
     64 
     65        // send download headers 
     66        if ($_GET['_download']) { 
     67            header("Cache-Control: private", false); 
     68            header("Content-Type: application/octet-stream"); 
     69        } 
     70        else { 
     71            header("Content-Type: $mimetype"); 
     72        } 
     73        // We need to set the following headers to make downloads work using IE in HTTPS mode. 
     74        if (isset($_SERVER['HTTPS'])) { 
     75            header('Pragma: '); 
     76            header('Cache-Control: '); 
     77        } 
     78 
     79        // deliver part content 
     80        if ($ctype_primary=='text' && $ctype_secondary=='html') { 
     81            // we have to analyze the whole structure again to find inline objects 
     82            list($new_parts, $new_attachments) = 
     83            rcmail_parse_message( 
     84                            $MESSAGE['structure'], 
     85                            array( 
     86                                'safe' => (bool)$_GET['_safe'], 
     87                                'prefer_html' => TRUE, 
     88                                'get_url' => $GET_URL.'&_part=%s' 
     89                            ) 
     90            ); 
     91 
     92            $all_parts = array_merge($new_parts, $new_attachments); 
     93            for ($partix = 0; $partix < sizeof($all_parts); $partix++) { 
     94                if ($all_parts[$partix]->mime_id == $pid) { 
     95                    $part = &$all_parts[$partix]; 
     96                } 
     97            } 
     98 
     99            // get part body if not available 
     100            if (!$part->body) { 
     101                $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part); 
     102            } 
     103            $OUTPUT = new rcube_html_page(); 
     104            $OUTPUT->write(rcmail_print_body($part, (bool)$_GET['_safe'])); 
     105        } 
     106        else { 
     107            header( 
     108                sprintf( 
     109                    'Content-Disposition: %s; filename="%s";', 
     110                    $part->disposition ? $part->disposition : 'attachment', 
     111                    $part->filename ? $part->filename : "roundcube.$ctype_secondary" 
     112                ) 
     113            ); 
     114 
     115            // turn off output buffering and print part content 
     116            $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part->encoding, true); 
     117        } 
     118        exit; 
     119    } 
     120} 
     121// print message 
     122else { 
     123    $ctype_primary = strtolower($MESSAGE['structure']->ctype_primary); 
     124    $ctype_secondary = strtolower($MESSAGE['structure']->ctype_secondary); 
    62125    $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary); 
    63126 
    64     header("Expires: 0"); 
    65     header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    66     header("Cache-Control: private", false); 
    67     header("Content-Transfer-Encoding: binary"); 
     127    // send correct headers for content type 
     128    header("Content-Type: text/html"); 
    68129 
    69     // send download headers 
    70     if ($_GET['_download']) 
    71       { 
    72       header("Cache-Control: private", false); 
    73       header("Content-Type: application/octet-stream"); 
    74       } 
    75     else 
    76       header("Content-Type: $mimetype"); 
     130    $cont = ''; 
     131    list($MESSAGE['parts']) = rcmail_parse_message( 
     132                                    $MESSAGE['structure'], 
     133                                    array( 
     134                                        'safe' => (bool)$_GET['_safe'], 
     135                                        'get_url' => $GET_URL.'&_part=%s' 
     136                                    ) 
     137    ); 
    77138 
    78     // We need to set the following headers to make downloads work using IE in HTTPS mode. 
    79     if (isset($_SERVER['HTTPS'])) 
    80       { 
    81       header('Pragma: '); 
    82       header('Cache-Control: '); 
    83       } 
     139    $cont = "<html>\n<head><title></title>\n</head>\n<body>"; 
     140    $cont .= rcmail_message_body(array()); 
     141    $cont .= "\n</body>\n</html>"; 
    84142 
    85     // deliver part content 
    86     if ($ctype_primary=='text' && $ctype_secondary=='html') 
    87       { 
    88       // we have to analyze the whole structure again to find inline objects 
    89       list($new_parts, $new_attachments) = 
    90         rcmail_parse_message($MESSAGE['structure'], 
    91                              array('safe' => (bool)$_GET['_safe'], 
    92                                    'prefer_html' => TRUE, 
    93                                    'get_url' => $GET_URL.'&_part=%s')); 
    94  
    95       $all_parts = array_merge($new_parts, $new_attachments); 
    96       for ($partix = 0; $partix < sizeof($all_parts); $partix++) 
    97         if ($all_parts[$partix]->mime_id == $pid) 
    98           $part = &$all_parts[$partix]; 
    99  
    100       // get part body if not available 
    101       if (!$part->body) 
    102         $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part); 
    103  
    104       $OUTPUT = new rcube_html_page(); 
    105       $OUTPUT->write(rcmail_print_body($part, (bool)$_GET['_safe'])); 
    106       } 
    107     else 
    108       { 
    109       header(sprintf('Content-Disposition: %s; filename="%s";', 
    110                      $part->disposition ? $part->disposition : 'attachment', 
    111                      $part->filename ? $part->filename : "roundcube.$ctype_secondary")); 
    112  
    113       // turn off output buffering and print part content 
    114       $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part->encoding, true); 
    115       } 
     143    $OUTPUT = new rcube_html_page(); 
     144    $OUTPUT->write($cont); 
    116145 
    117146    exit; 
    118     } 
    119   } 
    120  
    121 // print message 
    122 else 
    123   { 
    124   $ctype_primary = strtolower($MESSAGE['structure']->ctype_primary); 
    125   $ctype_secondary = strtolower($MESSAGE['structure']->ctype_secondary); 
    126   $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary); 
    127  
    128   // send correct headers for content type 
    129   header("Content-Type: text/html"); 
    130  
    131   $cont = '';  
    132   list($MESSAGE['parts']) = rcmail_parse_message($MESSAGE['structure'], 
    133                                                  array('safe' => (bool)$_GET['_safe'], 
    134                                                  'get_url' => $GET_URL.'&_part=%s')); 
    135  
    136   $cont = "<html>\n<head><title></title>\n</head>\n<body>"; 
    137   $cont .= rcmail_message_body(array()); 
    138   $cont .= "\n</body>\n</html>"; 
    139  
    140   $OUTPUT = new rcube_html_page(); 
    141   $OUTPUT->write($cont); 
    142  
    143   exit; 
    144   } 
    145  
    146  
     147} 
    147148// if we arrive here, the requested part was not found 
    148149header('HTTP/1.1 404 Not Found'); 
    149150exit; 
    150  
    151151?> 
  • branches/devel-vnext/program/steps/mail/getunread.inc

    r589 r623  
    2222$a_folders = $IMAP->list_mailboxes(); 
    2323 
    24 if (!empty($a_folders)) 
    25 { 
    26   foreach ($a_folders as $mbox_row) 
    27     $OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN')); 
     24if (!empty($a_folders)) { 
     25    foreach ($a_folders as $mbox_row) { 
     26        $OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN')); 
     27    } 
    2828} 
    2929 
  • branches/devel-vnext/program/steps/mail/list.inc

    r592 r623  
    1919*/ 
    2020 
     21$registry = rc_registry::getInstance(); 
     22$OUTPUT   = $registry->get('OUTPUT', 'core'); 
     23$IMAP     = $registry->get('IMAP', 'core'); 
     24 
     25 
    2126$OUTPUT_TYPE = 'js'; 
     27$registry->set('OUTPUT_TYPE', $OUTPUT_TYPE, 'core'); 
     28 
    2229// is there a sort type for this request? 
    23 if ($sort = get_input_value('_sort', RCUBE_INPUT_GET)) { 
     30if ($sort = rc_main::get_input_value('_sort', RCUBE_INPUT_GET)) { 
    2431    // yes, so set the sort vars 
    2532    list($sort_col, $sort_order) = explode('_', $sort); 
  • branches/devel-vnext/program/steps/mail/mark.inc

    r589 r623  
    2020 
    2121$a_flags_map = array( 
    22   'undelete' => 'UNDELETED', 
    23   'delete' => 'DELETED', 
    24   'read' => 'SEEN', 
    25   'unread' => 'UNSEEN'); 
     22    'undelete' => 'UNDELETED', 
     23    'delete' => 'DELETED', 
     24    'read' => 'SEEN', 
     25    'unread' => 'UNSEEN' 
     26); 
    2627 
    27 if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST))) 
    28 { 
    29   $flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag); 
    30   $marked = $IMAP->set_flag($uids, $flag); 
     28if ( 
     29    ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST)) 
     30    && ($flag = rc_main::get_input_value('_flag', RCUBE_INPUT_POST)) 
     31) { 
     32    $flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag); 
     33    $marked = $IMAP->set_flag($uids, $flag); 
    3134 
    32   if ($marked != -1) 
    33   { 
    34     $mbox_name = $IMAP->get_mailbox_name(); 
    35     $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN')); 
    36     $OUTPUT->send(); 
    37   } 
     35    if ($marked != -1) { 
     36        $mbox_name = $IMAP->get_mailbox_name(); 
     37        $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN')); 
     38        $OUTPUT->send(); 
     39    } 
    3840} 
    39    
    4041exit; 
    4142?> 
  • branches/devel-vnext/program/steps/mail/move_del.inc

    r589 r623  
    2121 
    2222// move messages 
    23 if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) 
    24 { 
    25   $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); 
    26   $target = get_input_value('_target_mbox', RCUBE_INPUT_POST); 
    27   $moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_POST)); 
    28    
    29   if (!$moved) 
    30   { 
    31     // send error message 
    32     $OUTPUT->command('list_mailbox'); 
    33     $OUTPUT->show_message('errormoving', 'error'); 
    34     $OUTPUT->send(); 
     23if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) { 
     24    $count  = sizeof(explode(',', ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST)))); 
     25    $target = rc_main::get_input_value('_target_mbox', RCUBE_INPUT_POST); 
     26    $moved  = $IMAP->move_message($uids, $target, rc_main::get_input_value('_mbox', RCUBE_INPUT_POST)); 
     27 
     28    if (!$moved) { 
     29        // send error message 
     30        $OUTPUT->command('list_mailbox'); 
     31        $OUTPUT->show_message('errormoving', 'error'); 
     32        $OUTPUT->send(); 
     33        exit; 
     34    } 
     35} 
     36// delete messages 
     37else if ($_action=='delete' && !empty($_POST['_uid'])) { 
     38    $count = sizeof(explode(',', ($uids = rc_main::get_input_value('_uid', RCUBE_INPUT_POST)))); 
     39    $del = $IMAP->delete_message($uids, rc_main::get_input_value('_mbox', RCUBE_INPUT_POST)); 
     40 
     41    if (!$del) { 
     42        // send error message 
     43        $OUTPUT->command('list_mailbox'); 
     44        $OUTPUT->show_message('errordeleting', 'error'); 
     45        $OUTPUT->send(); 
     46        exit; 
     47    } 
     48} 
     49// unknown action or missing query param 
     50else { 
     51    rc_main::tfk_debug('/ unknown action'); 
    3552    exit; 
    36   } 
    3753} 
    3854 
    39 // delete messages  
    40 else if ($_action=='delete' && !empty($_POST['_uid'])) 
    41 { 
    42   $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); 
    43   $del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_POST)); 
    44    
    45   if (!$del) 
    46   { 
    47     // send error message 
    48     $OUTPUT->command('list_mailbox'); 
    49     $OUTPUT->show_message('errordeleting', 'error'); 
    50     $OUTPUT->send(); 
    51     exit; 
    52   } 
     55// refresh saved seach set after moving some messages 
     56if ( 
     57    ($search_request = rc_main::get_input_value('_search', RCUBE_INPUT_GPC)) 
     58    && $IMAP->search_set 
     59) { 
     60    $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 
    5361} 
    54    
    55 // unknown action or missing query param 
    56 else 
    57   exit; 
    58  
    59 // refresh saved seach set after moving some messages 
    60 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) 
    61   $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 
    62  
    6362 
    6463// update message count display 
    6564$msg_count = $IMAP->messagecount(); 
    66 $pages = ceil($msg_count / $IMAP->page_size); 
     65$pages     = ceil($msg_count / $IMAP->page_size); 
    6766$OUTPUT->set_env('pagecount', $pages); 
    6867$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); 
     
    7372$OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN')); 
    7473 
    75 if ($_action=='moveto' && $target) 
    76   $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); 
    77  
     74if ($_action=='moveto' && $target) { 
     75    $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); 
     76} 
    7877$OUTPUT->command('set_quota', $IMAP->get_quota()); 
    7978 
    8079// add new rows from next page (if any) 
    81 if ($_POST['_from']!='show' && $pages>1 && $IMAP->list_page < $pages) 
    82 { 
    83   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col']; 
    84   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 
    85    
    86   $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); 
    87   $a_headers = array_slice($a_headers, -$count, $count); 
     80if ($_POST['_from']!='show' && $pages>1 && $IMAP->list_page < $pages) { 
     81    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col']; 
     82    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 
    8883 
    89   rcmail_js_message_list($a_headers); 
     84    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); 
     85    $a_headers = array_slice($a_headers, -$count, $count); 
     86 
     87    rcmail_js_message_list($a_headers); 
    9088} 
    91  
    9289 
    9390// send response 
    9491$OUTPUT->send(); 
    95  
    9692?> 
  • branches/devel-vnext/program/steps/mail/quotadisplay.inc

    r589 r623  
    2121 
    2222$display = isset($_GET['_display']) ? $_GET['_display'] : 'text'; 
    23 $id = isset($_GET['_id']) ? $_GET['_id'] : 'rcmquotadisplay'; 
    24 $quota = rcmail_quota_content($display); 
     23$id      = isset($_GET['_id']) ? $_GET['_id'] : 'rcmquotadisplay'; 
     24$quota   = rcmail_quota_content($display); 
    2525$OUTPUT->remote_response(sprintf("this.gui_objects.%s.innerHTML = '%s';\n", $id, $quota)); 
    2626 
  • branches/devel-vnext/program/steps/mail/search.inc

    r589 r623  
    1414*/ 
    1515 
    16 $REMOTE_REQUEST = TRUE; 
     16$REMOTE_REQUEST = $registry->set('REMOTE_REQUEST', TRUE, 'core'); 
    1717 
    1818// reset list_page and old search results 
     
    2626 
    2727// get search string 
    28 $str = get_input_value('_q', RCUBE_INPUT_GET); 
    29 $mbox = get_input_value('_mbox', RCUBE_INPUT_GET); 
     28$str  = rc_main::get_input_value('_q', RCUBE_INPUT_GET); 
     29$mbox = rc_main::get_input_value('_mbox', RCUBE_INPUT_GET); 
    3030$search_request = md5($mbox.$str); 
    3131 
    3232 
    3333// Check the search string for type of search 
    34 if (preg_match("/^from:/i", $str)) 
    35 { 
    36   list(,$srch) = explode(":", $str); 
    37   $subject =  "HEADER FROM"; 
    38   $search = trim($srch); 
     34if (preg_match("/^from:/i", $str)) { 
     35    list(,$srch) = explode(":", $str); 
     36    $subject =  "HEADER FROM"; 
     37    $search = trim($srch); 
    3938} 
    40 else if (preg_match("/^to:/i", $str)) 
    41 { 
    42   list(,$srch) = explode(":", $str); 
    43   $subject = "HEADER TO"; 
    44   $search = trim($srch); 
     39else if (preg_match("/^to:/i", $str)) { 
     40    list(,$srch) = explode(":", $str); 
     41    $subject = "HEADER TO"; 
     42    $search = trim($srch); 
    4543} 
    46 else if (preg_match("/^cc:/i", $str)) 
    47 { 
    48   list(,$srch) = explode(":", $str); 
    49   $subject = "HEADER CC"; 
    50   $search = trim($srch); 
     44else if (preg_match("/^cc:/i", $str)) { 
     45    list(,$srch) = explode(":", $str); 
     46    $subject = "HEADER CC"; 
     47    $search = trim($srch); 
    5148} 
    52 else if (preg_match("/^subject:/i", $str)) 
    53 { 
    54   list(,$srch) = explode(":", $str); 
    55   $subject = "HEADER SUBJECT"; 
    56   $search = trim($srch); 
     49else if (preg_match("/^subject:/i", $str)) { 
     50    list(,$srch) = explode(":", $str); 
     51    $subject = "HEADER SUBJECT"; 
     52    $search = trim($srch); 
    5753} 
    58 else if (preg_match("/^body:/i", $str)) 
    59 { 
    60   list(,$srch) = explode(":", $str); 
    61   $subject = "TEXT"; 
    62   $search = trim($srch); 
     54else if (preg_match("/^body:/i", $str)) { 
     55    list(,$srch) = explode(":", $str); 
     56    $subject = "TEXT"; 
     57    $search = trim($srch); 
    6358} 
    6459// search in subject and sender by default 
    65 else 
    66 { 
    67   $subject = array("HEADER SUBJECT", "HEADER FROM"); 
    68   $search = trim($str); 
     60else { 
     61    $subject = array("HEADER SUBJECT", "HEADER FROM"); 
     62    $search = trim($str); 
    6963} 
    7064 
     
    7367$result = $IMAP->search($mbox, $subject, $search, $imap_charset); 
    7468$count = 0; 
    75    
     69 
    7670// Make sure our $result is legit.. 
    77 if (is_array($result) && $result[0] != '') 
    78 { 
    79   // Get the headers 
    80   $result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 
    81   $count = count($result_h); 
     71if (is_array($result) && $result[0] != '') { 
     72    // Get the headers 
     73    $result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 
     74    $count = count($result_h); 
    8275 
    83   // save search results in session 
    84   if (!is_array($_SESSION['search'])) 
    85     $_SESSION['search'] = array(); 
    86  
    87   // Make sure we got the headers 
    88   if ($result_h != NULL) 
    89   { 
    90     $_SESSION['search'][$search_request] = $IMAP->get_search_set(); 
    91     rcmail_js_message_list($result_h); 
    92     $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 
    93   } 
     76    // save search results in session 
     77    if (!is_array($_SESSION['search'])) { 
     78        $_SESSION['search'] = array(); 
     79    } 
     80    // Make sure we got the headers 
     81    if ($result_h != NULL) { 
     82        $_SESSION['search'][$search_request] = $IMAP->get_search_set(); 
     83        rcmail_js_message_list($result_h); 
     84        $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 
     85    } 
    9486} 
    95 else 
    96 { 
    97   $OUTPUT->show_message('searchnomatch', 'warning'); 
    98   $search_request = -1; 
     87else { 
     88    $OUTPUT->show_message('searchnomatch', 'warning'); 
     89    $search_request = -1; 
    9990} 
    10091 
  • branches/devel-vnext/program/steps/mail/sendmail.inc

    r595 r623  
    4242 
    4343if (strlen($_POST['_draft_saveid']) > 3) { 
    44     $olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST); 
     44    $olddraftmessageid = rc_main::get_input_value('_draft_saveid', RCUBE_INPUT_POST); 
    4545} 
    4646$message_id = sprintf( 
     
    8080            $mailto_regexp, 
    8181            $mailto_replace, 
    82             get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset) 
     82            rc_main::get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset) 
    8383); 
    8484 
     
    107107$headers = array( 
    108108            'Date' => date('D, j M Y H:i:s O'), 
    109             'From' => rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset), 
     109            'From' => rc_main::rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset), 
    110110            'To'   => $mailto 
    111111); 
     
    116116                        $mailto_regexp, 
    117117                        $mailto_replace, 
    118                         get_input_value( 
     118                        rc_main::get_input_value( 
    119119                            '_cc', 
    120120                            RCUBE_INPUT_POST, 
     
    126126    $headers['Bcc'] = preg_replace( 
    127127                        $mailto_regexp, $mailto_replace, 
    128                         get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset) 
     128                        rc_main::get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset) 
    129129    ); 
    130130} 
    131131if (empty($identity_arr['bcc']) === false) { 
    132   $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc']; 
     132     $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc']; 
    133133} 
    134134// add subject 
    135 $headers['Subject'] = trim(get_input_value('_subject', RCUBE_INPUT_POST, FALSE, $message_charset)); 
     135$headers['Subject'] = trim(rc_main::get_input_value('_subject', RCUBE_INPUT_POST, FALSE, $message_charset)); 
    136136 
    137137if (empty($identity_arr['organization']) === false) { 
     
    168168} 
    169169// fetch message body 
    170 $message_body = get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_charset); 
     170$message_body = rc_main::get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_charset); 
    171171 
    172172// append generic footer to all messages 
     
    176176        $content = fread($fp, filesize($file)); 
    177177        fclose($fp); 
    178         $message_body .= "\r\n" . rcube_charset_convert($content, 'UTF-8', $message_charset); 
     178        $message_body .= "\r\n"; 
     179        $message_body .= rc_main::rcube_charset_convert($content, 'UTF-8', $message_charset); 
    179180    } 
    180181} 
     
    195196} 
    196197 
    197 $isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST)); 
     198$isHtmlVal = strtolower(rc_main::get_input_value('_is_html', RCUBE_INPUT_POST)); 
    198199$isHtml = ($isHtmlVal == "1"); 
    199200 
  • branches/devel-vnext/program/steps/mail/show.inc

    r589 r623  
    2020*/ 
    2121 
    22 require_once('Mail/mimeDecode.php'); 
     22rc_main::tfk_debug('/ show :-)'); 
     23 
     24require_once 'Mail/mimeDecode.php'; 
    2325 
    2426$PRINT_MODE = $_action=='print' ? TRUE : FALSE; 
     27$registry->set('PRINT_MODE', $PRINT_MODE, 'core'); 
    2528 
    2629// similar code as in program/steps/mail/get.inc 
    27 if ($_GET['_uid']) 
    28   { 
    29   $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 
    30   $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); 
    31    
    32   // go back to list if message not found (wrong UID) 
    33   if (!$MESSAGE['headers']) 
    34     { 
    35     $OUTPUT->show_message('messageopenerror', 'error'); 
    36     if ($_action=='preview' && template_exists('messagepreview')) 
    37         parse_template('messagepreview'); 
    38     else 
    39       { 
    40       $_action = 'list'; 
    41       return; 
    42       } 
    43     } 
    44  
    45   // calculate Etag for this request 
    46   $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().($PRINT_MODE?1:0)); 
    47  
    48   // allow caching, unless remote images are present 
    49   if ((bool)get_input_value('_safe', RCUBE_INPUT_GET)) 
    50     send_nocacheing_headers(); 
    51   else 
    52     send_modified_header($_SESSION['login_time'], $etag); 
    53  
    54   $MESSAGE['subject'] = rcube_imap::decode_mime_string($MESSAGE['headers']->subject, $MESSAGE['headers']->charset); 
    55   $OUTPUT->set_pagetitle($MESSAGE['subject']); 
    56    
    57   if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID'])) 
    58     list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message( 
    59       $MESSAGE['structure'], 
    60       array('safe' => (bool)$_GET['_safe'], 
    61             'prefer_html' => $CONFIG['prefer_html'], 
    62             'get_url' => $GET_URL.'&_part=%s') 
    63       ); 
    64   else 
    65     $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 
    66  
    67  
    68   // mark message as read 
    69   if (!$MESSAGE['headers']->seen && $_action != 'preview') 
    70     $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); 
    71  
    72   // give message uid to the client 
    73   $OUTPUT->set_env('uid', $MESSAGE['UID']); 
    74   $OUTPUT->set_env('safemode', (bool)$_GET['_safe']); 
    75  
    76   $next = $prev = -1; 
    77   // get previous, first, next and last message UID 
    78   if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&  
    79       $IMAP->get_capability('sort'))  
    80     { 
    81     // Only if we use custom sorting 
    82     $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 
    83   
    84     $MESSAGE['index'] = array_search((string)$MESSAGE['UID'], $a_msg_index, TRUE); 
    85     $prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ; 
    86     $first = count($a_msg_index)>0 ? $a_msg_index[0] : -1; 
    87     $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ; 
    88     $last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1; 
    89     } 
    90   else 
    91     { 
    92     // this assumes that we are sorted by date_DESC 
    93     $seq = $IMAP->get_id($MESSAGE['UID']); 
    94     $prev = $IMAP->get_uid($seq + 1); 
    95     $first = $IMAP->get_uid($IMAP->messagecount()); 
    96     $next = $IMAP->get_uid($seq - 1); 
    97     $last = $IMAP->get_uid(1); 
    98     $MESSAGE['index'] = $IMAP->messagecount() - $seq; 
    99     } 
    100    
    101   if ($prev > 0) 
    102     $OUTPUT->set_env('prev_uid', $prev); 
    103   if ($first >0) 
    104     $OUTPUT->set_env('first_uid', $first); 
    105   if ($next > 0) 
    106     $OUTPUT->set_env('next_uid', $next); 
    107   if ($last >0) 
    108     $OUTPUT->set_env('last_uid', $last); 
    109   } 
    110  
    111  
     30if ($_GET['_uid']) { 
     31 
     32    rc_main::tfk_debug("/ uid: {$_GET['_uid']}"); 
     33 
     34    $MESSAGE            = array('UID' => rc_main::get_input_value('_uid', RCUBE_INPUT_GET)); 
     35    $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); 
     36 
     37    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     38 
     39    //rc_main::tfk_debug(var_export($MESSAGE, true)); 
     40 
     41    // go back to list if message not found (wrong UID) 
     42    if (!$MESSAGE['headers']) { 
     43        $OUTPUT->show_message('messageopenerror', 'error'); 
     44        if ($_action=='preview' && template_exists('messagepreview')) { 
     45            rc_main::parse_template('messagepreview'); 
     46        } 
     47        else { 
     48            $_action = 'list'; 
     49            return; 
     50        } 
     51    } 
     52 
     53    // calculate Etag for this request 
     54    $etag = md5($MESSAGE['UID'] . $IMAP->get_mailbox_name() . session_id(). ($PRINT_MODE?1:0)); 
     55 
     56    rc_main::tfk_debug("/ etag: $etag"); 
     57    //rc_main::tfk_debug(var_export($MESSAGE, true)); 
     58 
     59    // allow caching, unless remote images are present 
     60    if ((bool)rc_main::get_input_value('_safe', RCUBE_INPUT_GET)) { 
     61        send_nocacheing_headers(); 
     62    } 
     63    else { 
     64        send_modified_header($_SESSION['login_time'], $etag); 
     65    } 
     66 
     67    rc_main::tfk_debug("/ send headerz"); 
     68 
     69    $MESSAGE['subject'] = rcube_imap::decode_mime_string( 
     70                                $MESSAGE['headers']->subject, 
     71                                $MESSAGE['headers']->charset 
     72    ); 
     73    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     74    $OUTPUT->set_pagetitle($MESSAGE['subject']); 
     75 
     76    if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID'])) { 
     77        $_message_parts = rcmail_parse_message( 
     78                                  $MESSAGE['structure'], 
     79                                  array( 
     80                                        'safe'        => (bool)$_GET['_safe'], 
     81                                        'prefer_html' => $CONFIG['prefer_html'], 
     82                                        'get_url'     => $GET_URL.'&_part=%s' 
     83                                  ) 
     84        ); 
     85        list($MESSAGE['parts'], $MESSAGE['attachments']) = $_message_parts; 
     86    } 
     87    else { 
     88        $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 
     89    } 
     90    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     91 
     92    // mark message as read 
     93    if (!$MESSAGE['headers']->seen && $_action != 'preview') { 
     94        $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); 
     95    } 
     96    // give message uid to the client 
     97    $OUTPUT->set_env('uid', $MESSAGE['UID']); 
     98    $OUTPUT->set_env('safemode', (bool)$_GET['_safe']); 
     99 
     100    $next = $prev = -1; 
     101    // get previous, first, next and last message UID 
     102    if ( 
     103        !( 
     104            $_SESSION['sort_col'] == 'date' 
     105            && $_SESSION['sort_order'] == 'DESC' 
     106        ) 
     107        && $IMAP->get_capability('sort') 
     108    ) { 
     109        // Only if we use custom sorting 
     110        $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 
     111 
     112        $MESSAGE['index'] = array_search((string)$MESSAGE['UID'], $a_msg_index, TRUE); 
     113        $prev             = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ; 
     114        $first            = count($a_msg_index)>0 ? $a_msg_index[0] : -1; 
     115        $next             = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ; 
     116        $last             = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1; 
     117    } 
     118    else { 
     119        // this assumes that we are sorted by date_DESC 
     120        $seq              = $IMAP->get_id($MESSAGE['UID']); 
     121        $prev             = $IMAP->get_uid($seq + 1); 
     122        $first            = $IMAP->get_uid($IMAP->messagecount()); 
     123        $next             = $IMAP->get_uid($seq - 1); 
     124        $last             = $IMAP->get_uid(1); 
     125        $MESSAGE['index'] = $IMAP->messagecount() - $seq; 
     126    } 
     127    $registry->set('MESSAGE', $MESSAGE, 'core'); 
     128 
     129    if ($prev > 0) { 
     130        $OUTPUT->set_env('prev_uid', $prev); 
     131    } 
     132    if ($first >0) { 
     133        $OUTPUT->set_env('first_uid', $first); 
     134    } 
     135    if ($next > 0) { 
     136        $OUTPUT->set_env('next_uid', $next); 
     137    } 
     138    if ($last >0) { 
     139        $OUTPUT->set_env('last_uid', $last); 
     140    } 
     141} 
     142 
     143rc_main::tfk_debug("/ hallo"); 
    112144 
    113145function rcmail_message_attachments($attrib) 
    114   { 
    115   global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL; 
    116  
    117   if (sizeof($MESSAGE['attachments'])) 
    118     { 
    119     // allow the following attributes to be added to the <ul> tag 
    120     $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); 
    121     $out = '<ul' . $attrib_str . ">\n"; 
    122  
    123     foreach ($MESSAGE['attachments'] as $attach_prop) 
    124       { 
    125       if ($PRINT_MODE) 
    126         $out .= sprintf('<li>%s (%s)</li>'."\n", 
    127                         $attach_prop->filename, 
    128                         show_bytes($attach_prop->size)); 
    129       else 
    130         $out .= sprintf('<li><a href="%s&amp;_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n", 
    131                         htmlspecialchars($GET_URL), 
    132                         $attach_prop->mime_id, 
    133                         JS_OBJECT_NAME, 
    134                         $attach_prop->mime_id, 
    135                         $attach_prop->mimetype, 
    136                         $attach_prop->filename); 
    137       } 
    138  
    139     $out .= "</ul>"; 
     146{ 
     147    $registry   = rc_registry::getInstance(); 
     148    $CONFIG     = $registry->get('CONFIG', 'core'); 
     149    $OUTPUT     = $registry->get('OUTPUT', 'core'); 
     150    $PRINT_MODE = $registry->get('PRINT_MODE', 'core'); 
     151    $MESSAGE    = $registry->get('MESSAGE', 'core'); 
     152    $GET_URL    = $registry->get('GET_URL', 'core'); 
     153 
     154 
     155    if (sizeof($MESSAGE['attachments'])) { 
     156        // allow the following attributes to be added to the <ul> tag 
     157        $attrib_str = rc_main::create_attrib_string( 
     158                            $attrib, 
     159                            array('style', 'class', 'id') 
     160        ); 
     161        $out = '<ul' . $attrib_str . ">\n"; 
     162 
     163        foreach ($MESSAGE['attachments'] as $attach_prop) { 
     164            if ($PRINT_MODE) { 
     165                $out .= sprintf( 
     166                            '<li>%s (%s)</li>'."\n", 
     167                            $attach_prop->filename, 
     168                            show_bytes($attach_prop->size) 
     169                ); 
     170            } 
     171            else { 
     172                $out .= sprintf( 
     173                            '<li><a href="%s&amp;_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n", 
     174                            htmlspecialchars($GET_URL), 
     175                            $attach_prop->mime_id, 
     176                            JS_OBJECT_NAME, 
     177                            $attach_prop->mime_id, 
     178                            $attach_prop->mimetype, 
     179                            $attach_prop->filename 
     180                ); 
     181            } 
     182        } 
     183 
     184        $out .= "</ul>"; 
     185        return $out; 
     186    } 
     187} 
     188 
     189 
     190 
     191function rcmail_remote_objects_msg($attrib) 
     192{ 
     193    $registry   = rc_registry::getInstance(); 
     194    $CONFIG     = $registry->get('CONFIG', 'core'); 
     195    $OUTPUT     = $registry->get('OUTPUT', 'core'); 
     196 
     197    if (!$attrib['id']) { 
     198        $attrib['id'] = 'rcmremoteobjmsg'; 
     199    } 
     200    // allow the following attributes to be added to the <div> tag 
     201    $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id')); 
     202    $out = '<div' . $attrib_str . ">"; 
     203 
     204    $out .= sprintf( 
     205                '%s&nbsp;<a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>', 
     206                rc_main::Q(rcube_label('blockedimages')), 
     207                JS_OBJECT_NAME, 
     208                rc_main::Q(rcube_label('showimages')) 
     209    ); 
     210 
     211    $out .= '</div>'; 
     212 
     213    $OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']); 
    140214    return $out; 
    141     }   
    142   } 
    143  
    144  
    145  
    146 function rcmail_remote_objects_msg($attrib) 
    147   { 
    148   global $CONFIG, $OUTPUT; 
    149    
    150   if (!$attrib['id']) 
    151     $attrib['id'] = 'rcmremoteobjmsg'; 
    152  
    153   // allow the following attributes to be added to the <div> tag 
    154   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); 
    155   $out = '<div' . $attrib_str . ">"; 
    156    
    157   $out .= sprintf('%s&nbsp;<a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>', 
    158                   Q(rcube_label('blockedimages')), 
    159                   JS_OBJECT_NAME, 
    160                   Q(rcube_label('showimages'))); 
    161    
    162   $out .= '</div>'; 
    163    
    164   $OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']); 
    165   return $out; 
    166   } 
    167  
    168  
    169 $OUTPUT->add_handlers(array( 
    170   'messageattachments' => 'rcmail_message_attachments', 
    171   'blockedobjects' => 'rcmail_remote_objects_msg')); 
    172  
    173  
    174 if ($_action=='print' && template_exists('printmessage')) 
    175   parse_template('printmessage'); 
    176 else if ($_action=='preview' && template_exists('messagepreview')) 
    177     parse_template('messagepreview'); 
    178 else 
    179   parse_template('message'); 
     215} 
     216 
     217 
     218$OUTPUT->add_handlers( 
     219            array( 
     220                'messageattachments' => 'rcmail_message_attachments', 
     221                'blockedobjects' => 'rcmail_remote_objects_msg' 
     222            ) 
     223); 
     224 
     225if ($_action=='print' && rc_main::template_exists('printmessage')) { 
     226    rc_main::parse_template('printmessage'); 
     227} 
     228elseif ($_action=='preview' && rc_main::template_exists('messagepreview')) { 
     229    rc_main::parse_template('messagepreview'); 
     230} 
     231else { 
     232    rc_main::parse_template('message'); 
     233} 
    180234?> 
  • branches/devel-vnext/program/steps/mail/spell.inc

    r589 r623  
    2323*/ 
    2424 
    25 $REMOTE_REQUEST = TRUE; 
     25$REMOTE_REQUEST = $registry->set('REMOTE_REQUEST', TRUE, 'core'); 
     26$CONFIG         = $registry->get('CONFIG', 'core'); 
    2627 
    2728// default settings 
    2829$host = "ssl://www.google.com"; 
    2930$port = 443; 
    30 $lang = get_input_value('lang', RCUBE_INPUT_GET); 
     31$lang = rc_main::get_input_value('lang', RCUBE_INPUT_GET); 
    3132$path = "/tbproxy/spell?lang=$lang"; 
    3233 
    3334// spell check uri is configured 
    34 if (!empty($CONFIG['spellcheck_uri'])) 
    35   { 
    36   $a_uri = parse_url($CONFIG['spellcheck_uri']); 
    37   $ssl = ($a_uri['scheme']=='https' || $a_uri['scheme']=='ssl'); 
    38   $port = $a_uri['port'] ? $a_uri['port'] : ($ssl ? 443 : 80); 
    39   $host = ($ssl ? 'ssl://' : '') . $a_uri['host']; 
    40   $path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : '') . $lang; 
    41   } 
     35if (!empty($CONFIG['spellcheck_uri'])) { 
     36    $a_uri = parse_url($CONFIG['spellcheck_uri']); 
     37    $ssl = ($a_uri['scheme']=='https' || $a_uri['scheme']=='ssl'); 
     38    $port = $a_uri['port'] ? $a_uri['port'] : ($ssl ? 443 : 80); 
     39    $host = ($ssl ? 'ssl://' : '') . $a_uri['host']; 
     40    $path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : '') . $lang; 
     41} 
    4242 
    43 $data = file_get_contents('php://input'); 
     43$data  = file_get_contents('php://input'); 
    4444$store = ""; 
    4545 
    46 if ($fp = fsockopen($host, $port, $errno, $errstr, 30)) 
    47   { 
    48   $out = "POST $path HTTP/1.0\r\n"; 
    49   $out .= "Host: $host\r\n"; 
    50   $out .= "Content-Length: " . strlen($data) . "\r\n"; 
    51   $out .= "Content-type: application/x-www-form-urlencoded\r\n"; 
    52   $out .= "Connection: Close\r\n\r\n"; 
    53   $out .= $data; 
    54   fwrite($fp, $out); 
    55    
    56   while (!feof($fp)) 
    57     $store .= fgets($fp, 128); 
    58   fclose($fp); 
    59   } 
     46if ($fp = fsockopen($host, $port, $errno, $errstr, 30)) { 
     47    $out = "POST $path HTTP/1.0\r\n"; 
     48    $out .= "Host: $host\r\n"; 
     49    $out .= "Content-Length: " . strlen($data) . "\r\n"; 
     50    $out .= "Content-type: application/x-www-form-urlencoded\r\n"; 
     51    $out .= "Connection: Close\r\n\r\n"; 
     52    $out .= $data; 
     53    fwrite($fp, $out); 
    6054 
    61 print $store;   
     55    while (!feof($fp)) { 
     56        $store .= fgets($fp, 128); 
     57    } 
     58    fclose($fp); 
     59} 
     60echo $store; 
    6261exit; 
    6362 
  • branches/devel-vnext/program/steps/mail/upload.inc

    r589 r623  
    2121 
    2222 
    23 if (!$_SESSION['compose']) 
    24   { 
    25   exit; 
    26   } 
    27  
     23if (!$_SESSION['compose']) { 
     24    exit; 
     25} 
    2826 
    2927// use common temp dir for file uploads 
    3028$temp_dir = unslashify($CONFIG['temp_dir']); 
    3129 
    32  
    33 if (!is_array($_SESSION['compose']['attachments'])) 
    34   $_SESSION['compose']['attachments'] = array(); 
    35  
     30if (!is_array($_SESSION['compose']['attachments'])) { 
     31    $_SESSION['compose']['attachments'] = array(); 
     32} 
    3633 
    3734$response = ''; 
    3835 
    39 foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) 
    40   { 
    41   $tmpfname = tempnam($temp_dir, 'rcmAttmnt'); 
    42   if (move_uploaded_file($filepath, $tmpfname)) 
     36foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { 
     37    $tmpfname = tempnam($temp_dir, 'rcmAttmnt'); 
     38    if (move_uploaded_file($filepath, $tmpfname)) { 
     39        $id = count($_SESSION['compose']['attachments']); 
     40        $_SESSION['compose']['attachments'][] = array( 
     41                                                    'name' => $_FILES['_attachments']['name'][$i], 
     42                                                    'mimetype' => $_FILES['_attachments']['type'][$i], 
     43                                                    'path' => $tmpfname 
     44        ); 
     45 
     46        if (is_file($CONFIG['skin_path'] . '/images/icons/remove-attachment.png')) { 
     47            $button = sprintf( 
     48                        '<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />', 
     49                        $CONFIG['skin_path'], 
     50                        rc_main::Q(rcube_label('delete')) 
     51            ); 
     52        } 
     53        else { 
     54            $button = rc_main::Q(rcube_label('delete')); 
     55        } 
     56        $content = sprintf( 
     57                    '<a href="#delete" onclick="return %s.command(\'remove-attachment\', \'rcmfile%d\', this)" title="%s">%s</a>%s', 
     58                    JS_OBJECT_NAME, 
     59                    $id, 
     60                    rc_main::Q(rcube_label('delete')), 
     61                    $button, 
     62                    rc_main::Q($_FILES['_attachments']['name'][$i]) 
     63        ); 
     64        $OUTPUT->command('add2attachment_list', "rcmfile$id", $content); 
     65    } 
     66    else // upload failed 
    4367    { 
    44     $id = count($_SESSION['compose']['attachments']); 
    45     $_SESSION['compose']['attachments'][] = array('name' => $_FILES['_attachments']['name'][$i], 
    46                                                   'mimetype' => $_FILES['_attachments']['type'][$i], 
    47                                                   'path' => $tmpfname); 
    48  
    49     if (is_file($CONFIG['skin_path'] . '/images/icons/remove-attachment.png')) 
    50       $button = sprintf( 
    51         '<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />', 
    52         $CONFIG['skin_path'], 
    53         Q(rcube_label('delete'))); 
    54     else 
    55       $button = Q(rcube_label('delete')); 
    56  
    57     $content = sprintf( 
    58       '<a href="#delete" onclick="return %s.command(\'remove-attachment\', \'rcmfile%d\', this)" title="%s">%s</a>%s', 
    59       JS_OBJECT_NAME, 
    60       $id, 
    61       Q(rcube_label('delete')), 
    62       $button, 
    63       Q($_FILES['_attachments']['name'][$i])); 
    64  
    65     $OUTPUT->command('add2attachment_list', "rcmfile$id", $content); 
     68        $err = $_FILES['_attachments']['error'][$i]; 
     69        if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { 
     70            $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); 
     71        } 
     72        else { 
     73            $msg = rcube_label('fileuploaderror'); 
     74        } 
     75        $OUTPUT->command('display_message', $msg, 'error'); 
    6676    } 
    67   else // upload failed 
    68     { 
    69     $err = $_FILES['_attachments']['error'][$i]; 
    70     if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) 
    71       $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); 
    72     else 
    73       $msg = rcube_label('fileuploaderror'); 
    74      
    75     $OUTPUT->command('display_message', $msg, 'error'); 
    76     } 
    77   } 
    78  
     77} 
    7978 
    8079// send html page with JS calls as response 
     
    8281$OUTPUT->command('auto_save_start', false); 
    8382$OUTPUT->send('iframe'); 
    84  
    8583?> 
  • branches/devel-vnext/program/steps/mail/viewsource.inc

    r589 r623  
    2222 
    2323// similar code as in program/steps/mail/get.inc 
    24 if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) 
    25   { 
    26   header('Content-Type: text/plain'); 
    27   //@ob_end_clean(); 
    28   $IMAP->print_raw_body($uid); 
    29   } 
    30 else 
    31   { 
    32   raise_error(array('code' => 500, 
    33                     'type' => 'php', 
    34                     'message' => 'Message UID '.$uid.' not found'), 
    35               TRUE, 
    36               TRUE); 
    37   } 
    38  
     24if ($uid = rc_main::get_input_value('_uid', RCUBE_INPUT_GET)) { 
     25    header('Content-Type: text/plain'); 
     26    //@ob_end_clean(); 
     27    $IMAP->print_raw_body($uid); 
     28} 
     29else { 
     30    raise_error( 
     31        array( 
     32            'code' => 500, 
     33            'type' => 'php', 
     34            'message' => 'Message UID '.$uid.' not found' 
     35        ), 
     36        TRUE, 
     37        TRUE 
     38    ); 
     39} 
    3940exit; 
    4041?> 
  • branches/devel-vnext/program/steps/settings/func.inc

    r589 r623  
    2222 
    2323// get user record 
    24 $sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('users')." 
    25                           WHERE  user_id=?", 
    26                           $_SESSION['user_id']); 
    27                                   
    28 if ($USER_DATA = $DB->fetch_assoc($sql_result)) 
    29   $OUTPUT->set_pagetitle(sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host'])); 
    30  
     24$_query = "SELECT username, mail_host FROM " . rc_main::get_table_name('users'); 
     25$_query.= " WHERE user_id=?"; 
     26$sql_result = $DB->query($_query, $_SESSION['user_id']); 
     27 
     28if ($USER_DATA = $DB->fetch_assoc($sql_result)) { 
     29    $OUTPUT->set_pagetitle( 
     30                sprintf( 
     31                    '%s %s@%s', 
     32                    rcube_label('settingsfor'), 
     33                    $USER_DATA['username'], 
     34                    $USER_DATA['mail_host'] 
     35                ) 
     36    ); 
     37} 
    3138 
    3239 
    3340function rcmail_user_prefs_form($attrib) 
    34   { 
    35   global $DB, $CONFIG, $sess_user_lang; 
    36  
    37   $no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array(); 
    38  
    39   // add some labels to client 
    40   rcube_add_label('nopagesizewarning'); 
    41    
    42   list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs'); 
    43   unset($attrib['form']); 
    44  
    45   // allow the following attributes to be added to the <table> tag 
    46   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
    47  
    48   // return the complete edit form as table 
    49   $out = "$form_start<table" . $attrib_str . ">\n\n"; 
    50  
    51   // show language selection 
    52   if (!isset($no_override['language'])) 
    53     { 
    54     $a_lang = rcube_list_languages(); 
    55     asort($a_lang); 
    56    
    57     $field_id = 'rcmfd_lang'; 
    58     $select_lang = new select(array('name' => '_language', 'id' => $field_id)); 
    59     $select_lang->add(array_values($a_lang), array_keys($a_lang)); 
    60    
    61     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    62                     $field_id, 
    63                     Q(rcube_label('language')), 
    64                     $select_lang->show($sess_user_lang)); 
    65     } 
    66  
    67  
    68   // show page size selection 
    69   if (!isset($no_override['timezone'])) 
    70     { 
    71     $field_id = 'rcmfd_timezone'; 
    72     $select_timezone = new select(array('name' => '_timezone', 'id' => $field_id)); 
    73     $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); 
    74     $select_timezone->add('(GMT -10:00) Hawaii', '-10'); 
    75     $select_timezone->add('(GMT -9:00) Alaska', '-9'); 
    76     $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8'); 
    77     $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7'); 
    78     $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6'); 
    79     $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5'); 
    80     $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4'); 
    81     $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3'); 
    82     $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5'); 
    83     $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2'); 
    84     $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1'); 
    85     $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0'); 
    86     $select_timezone->add('(GMT +1:00) Central European Time', '1'); 
    87     $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2'); 
    88     $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3'); 
    89     $select_timezone->add('(GMT +3:30) Tehran', '3.5'); 
    90     $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4'); 
    91     $select_timezone->add('(GMT +4:30) Kabul', '4.5'); 
    92     $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5'); 
    93     $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5'); 
    94     $select_timezone->add('(GMT +5:45) Kathmandu', '5.75'); 
    95     $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6'); 
    96     $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7'); 
    97     $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8'); 
    98     $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9'); 
    99     $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5'); 
    100     $select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10'); 
    101     $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11'); 
    102     $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12'); 
    103     $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13'); 
    104     $select_timezone->add('(GMT +14:00) Kiribati', '14'); 
    105    
    106    
    107     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    108                     $field_id, 
    109                     Q(rcube_label('timezone')), 
    110                     $select_timezone->show($CONFIG['timezone'])); 
    111     } 
    112  
    113   // daylight savings 
    114   if (!isset($no_override['dst_active'])) 
    115     { 
    116     $field_id = 'rcmfd_dst'; 
    117     $input_dst = new checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1)); 
    118     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    119                     $field_id, 
    120                     Q(rcube_label('dstactive')), 
    121                     $input_dst->show($CONFIG['dst_active'])); 
    122     } 
    123  
    124   // show page size selection 
    125   if (!isset($no_override['pagesize'])) 
    126     { 
    127     $field_id = 'rcmfd_pgsize'; 
    128     $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5)); 
    129  
    130     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    131                     $field_id, 
    132                     Q(rcube_label('pagesize')), 
    133                     $input_pagesize->show($CONFIG['pagesize'])); 
    134     } 
    135  
    136   // MM: Show checkbox for toggling 'pretty dates'  
    137   if (!isset($no_override['prettydate'])) 
    138     { 
    139     $field_id = 'rcmfd_prettydate'; 
    140     $input_prettydate = new checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1)); 
    141  
    142     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    143                     $field_id, 
    144                     Q(rcube_label('prettydate')), 
    145                     $input_prettydate->show($CONFIG['prettydate']?1:0)); 
    146     } 
    147  
    148   // show checkbox for HTML/plaintext messages 
    149   if (!isset($no_override['prefer_html'])) 
    150     { 
    151     $field_id = 'rcmfd_htmlmsg'; 
    152     $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1)); 
    153  
    154     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    155                     $field_id, 
    156                     Q(rcube_label('preferhtml')), 
    157                     $input_pagesize->show($CONFIG['prefer_html']?1:0)); 
    158     } 
    159  
    160   // Show checkbox for HTML Editor 
    161   if (false && !isset($no_override['htmleditor'])) 
    162     { 
    163     $field_id = 'rcmfd_htmleditor'; 
    164     $input_htmleditor = new checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); 
    165     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    166                     $field_id, 
    167                     Q(rcube_label('htmleditor')), 
    168                     $input_htmleditor->show($CONFIG['htmleditor']?1:0)); 
    169     } 
    170  
    171   // show config parameter for preview pane 
    172   if (false && !isset($no_override['preview_pane'])) 
    173     { 
     41{ 
     42    $registry       = rc_registry::getInstance(); 
     43    $DB             = $registry->get('DB', 'core'); 
     44    $CONFIG         = $registry->get('CONFIG', 'core'); 
     45    $sess_user_lang = $registry->get('sess_user_lang', 'core'); 
     46 
     47    $no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array(); 
     48 
     49    // add some labels to client 
     50    rcube_add_label('nopagesizewarning'); 
     51 
     52    list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs'); 
     53    unset($attrib['form']); 
     54 
     55    // allow the following attributes to be added to the <table> tag 
     56    $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
     57 
     58    // return the complete edit form as table 
     59    $out = "$form_start<table" . $attrib_str . ">\n\n"; 
     60 
     61    // show language selection 
     62    if (!isset($no_override['language'])) { 
     63        $a_lang = rcube_list_languages(); 
     64        asort($a_lang); 
     65 
     66        $field_id    = 'rcmfd_lang'; 
     67        $select_lang = new select(array('name' => '_language', 'id' => $field_id)); 
     68        $select_lang->add(array_values($a_lang), array_keys($a_lang)); 
     69 
     70        $out .= sprintf( 
     71                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     72                    $field_id, 
     73                    rc_main::Q(rcube_label('language')), 
     74                    $select_lang->show($sess_user_lang) 
     75        ); 
     76    } 
     77 
     78 
     79    // show page size selection 
     80    if (!isset($no_override['timezone'])) { 
     81        $field_id = 'rcmfd_timezone'; 
     82        $select_timezone = new select(array('name' => '_timezone', 'id' => $field_id)); 
     83        $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); 
     84        $select_timezone->add('(GMT -10:00) Hawaii', '-10'); 
     85        $select_timezone->add('(GMT -9:00) Alaska', '-9'); 
     86        $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8'); 
     87        $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7'); 
     88        $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6'); 
     89        $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5'); 
     90        $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4'); 
     91        $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3'); 
     92        $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5'); 
     93        $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2'); 
     94        $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1'); 
     95        $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0'); 
     96        $select_timezone->add('(GMT +1:00) Central European Time', '1'); 
     97        $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2'); 
     98        $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3'); 
     99        $select_timezone->add('(GMT +3:30) Tehran', '3.5'); 
     100        $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4'); 
     101        $select_timezone->add('(GMT +4:30) Kabul', '4.5'); 
     102        $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5'); 
     103        $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5'); 
     104        $select_timezone->add('(GMT +5:45) Kathmandu', '5.75'); 
     105        $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6'); 
     106        $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7'); 
     107        $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8'); 
     108        $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9'); 
     109        $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5'); 
     110        $select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10'); 
     111        $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11'); 
     112        $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12'); 
     113        $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13'); 
     114        $select_timezone->add('(GMT +14:00) Kiribati', '14'); 
     115 
     116 
     117        $out .= sprintf( 
     118                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     119                    $field_id, 
     120                    rc_main::Q(rcube_label('timezone')), 
     121                    $select_timezone->show($CONFIG['timezone']) 
     122        ); 
     123    } 
     124 
     125    // daylight savings 
     126    if (!isset($no_override['dst_active'])) { 
     127        $field_id  = 'rcmfd_dst'; 
     128        $input_dst = new checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1)); 
     129        $out .= sprintf( 
     130                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     131                    $field_id, 
     132                    rc_main::Q(rcube_label('dstactive')), 
     133                    $input_dst->show($CONFIG['dst_active']) 
     134        ); 
     135    } 
     136 
     137    // show page size selection 
     138    if (!isset($no_override['pagesize'])) { 
     139        $field_id = 'rcmfd_pgsize'; 
     140        $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5)); 
     141 
     142        $out .= sprintf( 
     143                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     144                    $field_id, 
     145                    rc_main::Q(rcube_label('pagesize')), 
     146                    $input_pagesize->show($CONFIG['pagesize']) 
     147        ); 
     148    } 
     149 
     150    // MM: Show checkbox for toggling 'pretty dates' 
     151    if (!isset($no_override['prettydate'])) { 
     152        $field_id = 'rcmfd_prettydate'; 
     153        $input_prettydate = new checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1)); 
     154 
     155        $out .= sprintf( 
     156                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     157                    $field_id, 
     158                    rc_main::Q(rcube_label('prettydate')), 
     159                    $input_prettydate->show($CONFIG['prettydate']?1:0) 
     160        ); 
     161    } 
     162 
     163    // show checkbox for HTML/plaintext messages 
     164    if (!isset($no_override['prefer_html'])) { 
     165        $field_id = 'rcmfd_htmlmsg'; 
     166        $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1)); 
     167 
     168        $out .= sprintf( 
     169                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     170                    $field_id, 
     171                    rc_main::Q(rcube_label('preferhtml')), 
     172                    $input_pagesize->show($CONFIG['prefer_html']?1:0) 
     173        ); 
     174    } 
     175 
     176    // Show checkbox for HTML Editor 
     177    if (false && !isset($no_override['htmleditor'])) { 
     178        $field_id = 'rcmfd_htmleditor'; 
     179        $input_htmleditor = new checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); 
     180        $out .= sprintf( 
     181                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     182                    $field_id, 
     183                    rc_main::Q(rcube_label('htmleditor')), 
     184                    $input_htmleditor->show($CONFIG['htmleditor']?1:0) 
     185        ); 
     186    } 
     187 
     188    // show config parameter for preview pane 
     189    if (false && !isset($no_override['preview_pane'])) { 
    174190    $field_id = 'rcmfd_preview'; 
    175191    $input_preview = new checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1)); 
     
    179195                    $input_preview->show($CONFIG['preview_pane']?1:0)); 
    180196    } 
    181                    
    182   if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave'])) 
    183     { 
    184     $field_id = 'rcmfd_autosave'; 
    185     $select_autosave = new select(array('name' => '_draft_autosave', 'id' => $field_id)); 
    186     $select_autosave->add(rcube_label('never'), 0); 
    187     foreach (array(3, 5, 10) as $i => $min) 
    188       $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60); 
    189  
    190     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    191                     $field_id, 
    192                     Q(rcube_label('autosavedraft')), 
    193                     $select_autosave->show($CONFIG['draft_autosave'])); 
    194     } 
    195  
    196   $out .= "\n</table>$form_end"; 
    197  
    198   return $out;   
    199   } 
     197 
     198    if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave'])) { 
     199        $field_id = 'rcmfd_autosave'; 
     200        $select_autosave = new select(array('name' => '_draft_autosave', 'id' => $field_id)); 
     201        $select_autosave->add(rcube_label('never'), 0); 
     202        foreach (array(3, 5, 10) as $i => $min) { 
     203            $select_autosave->add( 
     204                                rcube_label( 
     205                                    array( 
     206                                        'name' => 'everynminutes', 
     207                                        'vars' => array('n' => $min) 
     208                                    ) 
     209                                ), 
     210                                $min*60 
     211            ); 
     212        } 
     213        $out .= sprintf( 
     214                    "<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
     215                    $field_id, 
     216                    rc_main::Q(rcube_label('autosavedraft')), 
     217                    $select_autosave->show($CONFIG['draft_autosave']) 
     218        ); 
     219    } 
     220 
     221    $out .= "\n</table>$form_end"; 
     222 
     223    return $out; 
     224} 
    200225 
    201226 
    202227 
    203228function rcmail_identities_list($attrib) 
    204   { 
    205   global $DB, $CONFIG, $OUTPUT; 
    206  
    207  
    208   // get contacts from DB 
    209   $sql_result = $DB->query("SELECT * FROM ".get_table_name('identities')." 
    210                             WHERE  del<>1 
    211                             AND    user_id=? 
    212                             ORDER BY standard DESC, name ASC", 
    213                             $_SESSION['user_id']); 
    214  
    215  
    216   // add id to message list table if not specified 
    217   if (!strlen($attrib['id'])) 
    218     $attrib['id'] = 'rcmIdentitiesList'; 
    219  
    220   // define list of cols to be displayed 
    221   $a_show_cols = array('name', 'email', 'organization', 'reply-to'); 
    222  
    223   // create XHTML table   
    224   $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id'); 
    225    
    226   // set client env 
    227   $OUTPUT->add_gui_object('identitieslist', $attrib['id']); 
    228  
    229   return $out; 
    230   } 
     229{ 
     230    $registry = rc_registry::getInstance(); 
     231    $DB       = $registry->get('DB', 'core'); 
     232    $CONFIG   = $registry->get('CONFIG', 'core'); 
     233    $OUTPUT   = $registry->get('OUTPUT', 'core'); 
     234 
     235 
     236    // get contacts from DB 
     237    $_query = "SELECT * FROM " . rc_main::get_table_name('identities'); 
     238    $_query.= " WHERE del<>1"; 
     239    $_query.= " AND user_id=?"; 
     240    $_query.= " ORDER BY standard DESC, name ASC"; 
     241    $sql_result = $DB->query($_query, $_SESSION['user_id']); 
     242 
     243    // add id to message list table if not specified 
     244    if (!strlen($attrib['id'])) { 
     245        $attrib['id'] = 'rcmIdentitiesList'; 
     246    } 
     247    // define list of cols to be displayed 
     248    $a_show_cols = array('name', 'email', 'organization', 'reply-to'); 
     249 
     250    // create XHTML table 
     251    $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id'); 
     252 
     253    // set client env 
     254    $OUTPUT->add_gui_object('identitieslist', $attrib['id']); 
     255 
     256    return $out; 
     257} 
    231258 
    232259 
     
    234261// similar function as in /steps/addressbook/edit.inc 
    235262function get_form_tags($attrib, $action, $add_hidden=array()) 
    236   { 
    237   global $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;   
    238  
    239   $form_start = ''; 
    240   if (!strlen($EDIT_FORM)) 
    241     { 
    242     $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); 
    243     $hiddenfields->add(array('name' => '_action', 'value' => $action)); 
    244      
    245     if ($add_hidden) 
    246       $hiddenfields->add($add_hidden); 
    247      
    248     if ($_GET['_framed'] || $_POST['_framed']) 
    249       $hiddenfields->add(array('name' => '_framed', 'value' => 1)); 
    250      
    251     $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 
    252     $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 
    253     $form_start .= $hiddenfields->show(); 
    254     } 
    255      
    256   $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; 
    257   $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; 
    258  
    259   if (!strlen($EDIT_FORM)) 
    260     $OUTPUT->add_gui_object('editform', $form_name); 
    261    
    262   $EDIT_FORM = $form_name; 
    263  
    264   return array($form_start, $form_end);   
    265   } 
     263{ 
     264    $registry          = rc_registry::getInstance(); 
     265    $EDIT_FORM         = $registry->get('EDIT_FORM', 'core'); 
     266    $SESS_HIDDEN_FIELD = $registry->get('SESS_HIDDEN_FIELD', 'core'); 
     267    $OUTPUT            = $registry->get('OUTPUT', 'core'); 
     268 
     269    $form_start = ''; 
     270    if (!strlen($EDIT_FORM)) { 
     271        $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); 
     272        $hiddenfields->add(array('name' => '_action', 'value' => $action)); 
     273 
     274        if ($add_hidden) { 
     275            $hiddenfields->add($add_hidden); 
     276        } 
     277        if ($_GET['_framed'] || $_POST['_framed']) { 
     278            $hiddenfields->add(array('name' => '_framed', 'value' => 1)); 
     279        } 
     280        $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 
     281        $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 
     282        $form_start .= $hiddenfields->show(); 
     283    } 
     284    $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; 
     285    $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; 
     286 
     287    if (!strlen($EDIT_FORM)) { 
     288        $OUTPUT->add_gui_object('editform', $form_name); 
     289    } 
     290    $EDIT_FORM = $form_name; 
     291    $registry->set('EDIT_FORM', $EDIT_FORM, 'core'); 
     292 
     293    return array($form_start, $form_end); 
     294} 
    266295 
    267296 
    268297// register UI objects 
    269298$OUTPUT->add_handlers(array( 
    270   'userprefs' => 'rcmail_user_prefs_form', 
    271   'itentitieslist' => 'rcmail_identities_list' 
     299    'userprefs' => 'rcmail_user_prefs_form', 
     300    'itentitieslist' => 'rcmail_identities_list' 
    272301)); 
    273  
    274  
    275302?> 
  • branches/devel-vnext/program/steps/settings/identities.inc

    r606 r623  
    3838    $OUTPUT->set_env('contentframe', $attrib['name']); 
    3939 
    40     $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); 
     40    $attrib_str = rc_main::create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); 
    4141    $out = '<iframe'. $attrib_str . '></iframe>'; 
    4242 
  • branches/devel-vnext/program/steps/settings/manage_folders.inc

    r589 r623  
    109109// build table with all folders listed by server 
    110110function rcube_subscription_form($attrib) 
    111   { 
    112   global $IMAP, $CONFIG, $OUTPUT; 
    113  
    114   list($form_start, $form_end) = get_form_tags($attrib, 'folders'); 
    115   unset($attrib['form']); 
     111{ 
     112    global $IMAP, $CONFIG, $OUTPUT; 
     113 
     114    list($form_start, $form_end) = get_form_tags($attrib, 'folders'); 
     115    unset($attrib['form']); 
    116116   
    117117   
     
    120120 
    121121  // allow the following attributes to be added to the <table> tag 
    122   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
     122  $attrib_str = rc_main::create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
    123123 
    124124  $out = "$form_start\n<table" . $attrib_str . ">\n"; 
Note: See TracChangeset for help on using the changeset viewer.