Changeset 197601e in github
- Timestamp:
- Apr 30, 2008 4:21:42 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 3510d7b
- Parents:
- 0dfae00
- Files:
-
- 2 added
- 23 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
index.php (modified) (17 diffs)
-
program/include/iniset.php (modified) (1 diff)
-
program/include/main.inc (modified) (15 diffs)
-
program/include/rcmail.php (added)
-
program/include/rcube_config.php (added)
-
program/include/rcube_imap.php (modified) (1 diff)
-
program/include/rcube_json_output.php (modified) (1 diff)
-
program/include/rcube_shared.inc (modified) (1 diff)
-
program/include/rcube_template.php (modified) (10 diffs)
-
program/include/rcube_user.php (modified) (28 diffs)
-
program/steps/addressbook/edit.inc (modified) (5 diffs)
-
program/steps/addressbook/save.inc (modified) (3 diffs)
-
program/steps/mail/compose.inc (modified) (10 diffs)
-
program/steps/mail/folders.inc (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (1 diff)
-
program/steps/mail/move_del.inc (modified) (3 diffs)
-
program/steps/mail/sendmail.inc (modified) (1 diff)
-
program/steps/mail/show.inc (modified) (4 diffs)
-
program/steps/settings/edit_identity.inc (modified) (4 diffs)
-
program/steps/settings/func.inc (modified) (5 diffs)
-
program/steps/settings/manage_folders.inc (modified) (5 diffs)
-
program/steps/settings/save_identity.inc (modified) (1 diff)
-
program/steps/settings/save_prefs.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r2577821 r197601e 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2008/04/30 (thomasb) 5 ---------- 6 - Introduce new application class 'rcmail' and get rid of some global vars 3 7 4 8 2008/04/29 (alec) -
config/main.inc.php.dist
r47124c22 r197601e 119 119 120 120 // the default locale setting 121 $rcmail_config['l ocale_string'] = 'en';121 $rcmail_config['language'] = 'en'; 122 122 123 123 // use this format for short date display -
index.php
r47124c22 r197601e 3 3 +-----------------------------------------------------------------------+ 4 4 | RoundCube Webmail IMAP Client | 5 | Version 0.1-20080 328|5 | Version 0.1-20080430 | 6 6 | | 7 7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | … … 46 46 // define global vars 47 47 $OUTPUT_TYPE = 'html'; 48 $MAIN_TASKS = array('mail','settings','addressbook','logout');49 50 // catch some url/post parameters51 $_task = strip_quotes(get_input_value('_task', RCUBE_INPUT_GPC));52 $_action = strip_quotes(get_input_value('_action', RCUBE_INPUT_GPC));53 $_framed = (!empty($_GET['_framed']) || !empty($_POST['_framed']));54 55 // use main task if empty or invalid value56 if (empty($_task) || !in_array($_task, $MAIN_TASKS))57 $_task = 'mail';58 59 48 60 49 // set output buffering 61 if ($ _action != 'get' && $_action != 'viewsource') {50 if ($RCMAIL->action != 'get' && $RCMAIL->action != 'viewsource') { 62 51 // use gzip compression if supported 63 52 if (function_exists('ob_gzhandler') … … 72 61 73 62 74 // start session with requested task 75 rcmail_startup($_task); 76 77 // set session related variables 78 $COMM_PATH = sprintf('./?_task=%s', $_task); 79 $SESS_HIDDEN_FIELD = ''; 80 81 82 // add framed parameter 83 if ($_framed) { 84 $COMM_PATH .= '&_framed=1'; 85 $SESS_HIDDEN_FIELD .= "\n".'<input type="hidden" name="_framed" value="1" />'; 86 } 87 63 // init application and start session with requested task 64 $RCMAIL = rcmail::get_instance(); 88 65 89 66 // init output class 90 if (!empty($_GET['_remote']) || !empty($_POST['_remote'])) { 91 rcmail_init_json(); 92 } 93 else { 94 rcmail_load_gui(); 95 } 67 $OUTPUT = (!empty($_GET['_remote']) || !empty($_POST['_remote'])) ? $RCMAIL->init_json() : $RCMAIL->load_gui((!empty($_GET['_framed']) || !empty($_POST['_framed']))); 96 68 97 69 … … 106 78 107 79 // error steps 108 if ($ _action=='error' && !empty($_GET['_code'])) {80 if ($RCMAIL->action=='error' && !empty($_GET['_code'])) { 109 81 raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE); 110 82 } 111 83 112 84 // try to log in 113 if ($ _action=='login' && $_task=='mail') {85 if ($RCMAIL->action=='login' && $RCMAIL->task=='mail') { 114 86 $host = rcmail_autoselect_host(); 115 87 … … 119 91 } 120 92 else if ($_SESSION['temp'] && !empty($_POST['_user']) && isset($_POST['_pass']) && 121 rcmail_login(trim(get_input_value('_user', RCUBE_INPUT_POST), ' '),93 $RCMAIL->login(trim(get_input_value('_user', RCUBE_INPUT_POST), ' '), 122 94 get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'), $host)) { 123 95 // create new session ID … … 129 101 130 102 // send redirect 131 header("Location: $COMM_PATH");103 header("Location: {$RCMAIL->comm_path}"); 132 104 exit; 133 105 } … … 139 111 140 112 // end session 141 else if (($ _task=='logout' || $_action=='logout') && isset($_SESSION['user_id'])) {113 else if (($RCMAIL->task=='logout' || $RCMAIL->action=='logout') && isset($_SESSION['user_id'])) { 142 114 $OUTPUT->show_message('loggedout'); 143 115 rcmail_logout_actions(); … … 146 118 147 119 // check session and auth cookie 148 else if ($ _action != 'login' && $_SESSION['user_id'] && $_action != 'send') {120 else if ($RCMAIL->action != 'login' && $_SESSION['user_id'] && $RCMAIL->action != 'send') { 149 121 if (!rcmail_authenticate_session()) { 150 122 $OUTPUT->show_message('sessionerror', 'error'); … … 155 127 156 128 // log in to imap server 157 if (!empty($ USER->ID) && $_task=='mail') {129 if (!empty($RCMAIL->user->ID) && $RCMAIL->task == 'mail') { 158 130 $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']); 159 131 if (!$conn) { … … 162 134 } 163 135 else { 164 rcmail_set_imap_prop();136 $RCMAIL->set_imap_prop(); 165 137 } 166 138 } … … 168 140 169 141 // not logged in -> set task to 'login 170 if (empty($ USER->ID)) {142 if (empty($RCMAIL->user->ID)) { 171 143 if ($OUTPUT->ajax_call) 172 144 $OUTPUT->remote_response("setTimeout(\"location.href='\"+this.env.comm_path+\"'\", 2000);"); 173 145 174 $ _task = 'login';146 $RCMAIL->task = 'login'; 175 147 } 176 148 … … 185 157 186 158 187 // set task and action to client188 $OUTPUT->set_env('task', $_task);189 if (!empty($_action)) {190 $OUTPUT->set_env('action', $_action);191 }192 193 194 195 159 // not logged in -> show login page 196 if (empty($ USER->ID)) {160 if (empty($RCMAIL->user->ID)) { 197 161 // check if installer is still active 198 162 if ($CONFIG['enable_installer'] && is_readable('./installer/index.php')) { … … 214 178 215 179 // handle keep-alive signal 216 if ($ _action=='keep-alive') {180 if ($RCMAIL->action=='keep-alive') { 217 181 $OUTPUT->reset(); 218 182 $OUTPUT->send(''); … … 221 185 222 186 // include task specific files 223 if ($ _task=='mail') {187 if ($RCMAIL->task=='mail') { 224 188 include_once('program/steps/mail/func.inc'); 225 189 226 if ($ _action=='show' || $_action=='preview' || $_action=='print')190 if ($RCMAIL->action=='show' || $RCMAIL->action=='preview' || $RCMAIL->action=='print') 227 191 include('program/steps/mail/show.inc'); 228 192 229 if ($ _action=='get')193 if ($RCMAIL->action=='get') 230 194 include('program/steps/mail/get.inc'); 231 195 232 if ($ _action=='moveto' || $_action=='delete')196 if ($RCMAIL->action=='moveto' || $RCMAIL->action=='delete') 233 197 include('program/steps/mail/move_del.inc'); 234 198 235 if ($ _action=='mark')199 if ($RCMAIL->action=='mark') 236 200 include('program/steps/mail/mark.inc'); 237 201 238 if ($ _action=='viewsource')202 if ($RCMAIL->action=='viewsource') 239 203 include('program/steps/mail/viewsource.inc'); 240 204 241 if ($ _action=='sendmdn')205 if ($RCMAIL->action=='sendmdn') 242 206 include('program/steps/mail/sendmdn.inc'); 243 207 244 if ($ _action=='send')208 if ($RCMAIL->action=='send') 245 209 include('program/steps/mail/sendmail.inc'); 246 210 247 if ($ _action=='upload')211 if ($RCMAIL->action=='upload') 248 212 include('program/steps/mail/upload.inc'); 249 213 250 if ($ _action=='compose' || $_action=='remove-attachment' || $_action=='display-attachment')214 if ($RCMAIL->action=='compose' || $RCMAIL->action=='remove-attachment' || $RCMAIL->action=='display-attachment') 251 215 include('program/steps/mail/compose.inc'); 252 216 253 if ($ _action=='addcontact')217 if ($RCMAIL->action=='addcontact') 254 218 include('program/steps/mail/addcontact.inc'); 255 219 256 if ($ _action=='expunge' || $_action=='purge')220 if ($RCMAIL->action=='expunge' || $RCMAIL->action=='purge') 257 221 include('program/steps/mail/folders.inc'); 258 222 259 if ($ _action=='check-recent')223 if ($RCMAIL->action=='check-recent') 260 224 include('program/steps/mail/check_recent.inc'); 261 225 262 if ($ _action=='getunread')226 if ($RCMAIL->action=='getunread') 263 227 include('program/steps/mail/getunread.inc'); 264 228 265 if ($ _action=='list' && isset($_REQUEST['_remote']))229 if ($RCMAIL->action=='list' && isset($_REQUEST['_remote'])) 266 230 include('program/steps/mail/list.inc'); 267 231 268 if ($ _action=='search')232 if ($RCMAIL->action=='search') 269 233 include('program/steps/mail/search.inc'); 270 234 271 if ($ _action=='spell')235 if ($RCMAIL->action=='spell') 272 236 include('program/steps/mail/spell.inc'); 273 237 274 if ($ _action=='rss')238 if ($RCMAIL->action=='rss') 275 239 include('program/steps/mail/rss.inc'); 276 240 … … 281 245 282 246 // include task specific files 283 if ($ _task=='addressbook') {247 if ($RCMAIL->task=='addressbook') { 284 248 include_once('program/steps/addressbook/func.inc'); 285 249 286 if ($ _action=='save')250 if ($RCMAIL->action=='save') 287 251 include('program/steps/addressbook/save.inc'); 288 252 289 if ($ _action=='edit' || $_action=='add')253 if ($RCMAIL->action=='edit' || $RCMAIL->action=='add') 290 254 include('program/steps/addressbook/edit.inc'); 291 255 292 if ($ _action=='delete')256 if ($RCMAIL->action=='delete') 293 257 include('program/steps/addressbook/delete.inc'); 294 258 295 if ($ _action=='show')259 if ($RCMAIL->action=='show') 296 260 include('program/steps/addressbook/show.inc'); 297 261 298 if ($ _action=='list' && $_REQUEST['_remote'])262 if ($RCMAIL->action=='list' && $_REQUEST['_remote']) 299 263 include('program/steps/addressbook/list.inc'); 300 264 301 if ($ _action=='search')265 if ($RCMAIL->action=='search') 302 266 include('program/steps/addressbook/search.inc'); 303 267 304 if ($ _action=='copy')268 if ($RCMAIL->action=='copy') 305 269 include('program/steps/addressbook/copy.inc'); 306 270 307 if ($ _action=='mailto')271 if ($RCMAIL->action=='mailto') 308 272 include('program/steps/addressbook/mailto.inc'); 309 273 } … … 311 275 312 276 // include task specific files 313 if ($ _task=='settings') {277 if ($RCMAIL->task=='settings') { 314 278 include_once('program/steps/settings/func.inc'); 315 279 316 if ($ _action=='save-identity')280 if ($RCMAIL->action=='save-identity') 317 281 include('program/steps/settings/save_identity.inc'); 318 282 319 if ($ _action=='add-identity' || $_action=='edit-identity')283 if ($RCMAIL->action=='add-identity' || $RCMAIL->action=='edit-identity') 320 284 include('program/steps/settings/edit_identity.inc'); 321 285 322 if ($ _action=='delete-identity')286 if ($RCMAIL->action=='delete-identity') 323 287 include('program/steps/settings/delete_identity.inc'); 324 288 325 if ($ _action=='identities')289 if ($RCMAIL->action=='identities') 326 290 include('program/steps/settings/identities.inc'); 327 291 328 if ($ _action=='save-prefs')292 if ($RCMAIL->action=='save-prefs') 329 293 include('program/steps/settings/save_prefs.inc'); 330 294 331 if ($ _action=='folders' || $_action=='subscribe' || $_action=='unsubscribe' ||332 $ _action=='create-folder' || $_action=='rename-folder' || $_action=='delete-folder')295 if ($RCMAIL->action=='folders' || $RCMAIL->action=='subscribe' || $RCMAIL->action=='unsubscribe' || 296 $RCMAIL->action=='create-folder' || $RCMAIL->action=='rename-folder' || $RCMAIL->action=='delete-folder') 333 297 include('program/steps/settings/manage_folders.inc'); 334 298 } … … 336 300 337 301 // parse main template 338 $OUTPUT->send($ _task);302 $OUTPUT->send($RCMAIL->task); 339 303 340 304 -
program/include/iniset.php
r47124c22 r197601e 3 3 /* 4 4 +-----------------------------------------------------------------------+ 5 | program/include/iniset. inc|5 | program/include/iniset.php | 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | -
program/include/main.inc
r2577821 r197601e 41 41 42 42 /** 43 * Initial startup function44 * to register session, create database and imap connections45 *46 * @param string Current task47 */48 function rcmail_startup($task='mail')49 {50 global $sess_id, $sess_user_lang;51 global $CONFIG, $OUTPUT, $IMAP, $DB, $USER;52 53 // start output buffering, we don't need any output yet,54 // it'll be cleared after reading of config files, etc.55 ob_start();56 57 // load configuration58 $CONFIG = rcmail_load_config();59 60 // set session domain61 if (isset($CONFIG['session_domain']) && !empty($CONFIG['session_domain'])) {62 ini_set('session.cookie_domain', $CONFIG['session_domain']);63 }64 65 // set session garbage collecting time according to session_lifetime66 if (!empty($CONFIG['session_lifetime']))67 ini_set('session.gc_maxlifetime', ($CONFIG['session_lifetime']) * 120);68 69 // prepare DB connection70 $dbwrapper = empty($CONFIG['db_backend']) ? 'db' : $CONFIG['db_backend'];71 $dbclass = "rcube_" . $dbwrapper;72 73 $DB = new $dbclass($CONFIG['db_dsnw'], $CONFIG['db_dsnr'], $CONFIG['db_persistent']);74 $DB->sqlite_initials = INSTALL_PATH.'SQL/sqlite.initial.sql';75 $DB->set_debug((bool)$CONFIG['sql_debug']);76 $DB->db_connect('w');77 78 // use database for storing session data79 include_once('include/session.inc');80 81 // clear output buffer82 ob_end_clean();83 84 // init session85 session_start();86 $sess_id = session_id();87 88 // create session and set session vars89 if (!isset($_SESSION['auth_time']))90 {91 $_SESSION['user_lang'] = rcube_language_prop($CONFIG['locale_string']);92 $_SESSION['auth_time'] = time();93 $_SESSION['temp'] = true;94 }95 96 // set session vars global97 $sess_user_lang = rcube_language_prop($_SESSION['user_lang']);98 99 // create user object100 $USER = new rcube_user($_SESSION['user_id']);101 102 // overwrite config with user preferences103 $CONFIG = array_merge($CONFIG, (array)$USER->get_prefs());104 105 // reset some session parameters when changing task106 if ($_SESSION['task'] != $task)107 unset($_SESSION['page']);108 109 // set current task to session110 $_SESSION['task'] = $task;111 112 // create IMAP object113 if ($task=='mail')114 rcmail_imap_init();115 116 // set localization117 if ($CONFIG['locale_string'])118 setlocale(LC_ALL, $CONFIG['locale_string']);119 else if ($sess_user_lang)120 setlocale(LC_ALL, $sess_user_lang);121 122 register_shutdown_function('rcmail_shutdown');123 }124 125 126 /**127 * Load roundcube configuration array128 *129 * @return array Named configuration parameters130 */131 function rcmail_load_config()132 {133 // load config file134 include_once('config/main.inc.php');135 $conf = is_array($rcmail_config) ? $rcmail_config : array();136 137 // load host-specific configuration138 rcmail_load_host_config($conf);139 140 $conf['skin_path'] = $conf['skin_path'] ? unslashify($conf['skin_path']) : 'skins/default';141 142 // load db conf143 include_once('config/db.inc.php');144 $conf = array_merge($conf, $rcmail_config);145 146 if (empty($conf['log_dir']))147 $conf['log_dir'] = INSTALL_PATH.'logs';148 else149 $conf['log_dir'] = unslashify($conf['log_dir']);150 151 // set PHP error logging according to config152 if ($conf['debug_level'] & 1)153 {154 ini_set('log_errors', 1);155 ini_set('error_log', $conf['log_dir'].'/errors');156 }157 if ($conf['debug_level'] & 4)158 ini_set('display_errors', 1);159 else160 ini_set('display_errors', 0);161 162 return $conf;163 }164 165 166 /**167 * Load a host-specific config file if configured168 * This will merge the host specific configuration with the given one169 *170 * @param array Global configuration parameters171 */172 function rcmail_load_host_config(&$config)173 {174 $fname = NULL;175 176 if (is_array($config['include_host_config']))177 $fname = $config['include_host_config'][$_SERVER['HTTP_HOST']];178 else if (!empty($config['include_host_config']))179 $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';180 181 if ($fname && is_file('config/'.$fname))182 {183 include('config/'.$fname);184 $config = array_merge($config, $rcmail_config);185 }186 }187 188 189 /**190 43 * Create unique authorization hash 191 44 * … … 247 100 248 101 249 /**250 * Create global IMAP object and connect to server251 *252 * @param boolean True if connection should be established253 */254 function rcmail_imap_init($connect=FALSE)255 {256 global $CONFIG, $DB, $IMAP, $OUTPUT;257 258 $IMAP = new rcube_imap($DB);259 $IMAP->debug_level = $CONFIG['debug_level'];260 $IMAP->skip_deleted = $CONFIG['skip_deleted'];261 262 263 // connect with stored session data264 if ($connect)265 {266 if (!($conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'])))267 $OUTPUT->show_message('imaperror', 'error');268 269 rcmail_set_imap_prop();270 }271 272 // enable caching of imap data273 if ($CONFIG['enable_caching']===TRUE)274 $IMAP->set_caching(TRUE);275 276 // set pagesize from config277 if (isset($CONFIG['pagesize']))278 $IMAP->set_pagesize($CONFIG['pagesize']);279 }280 281 282 /**283 * Set root dir and last stored mailbox284 * This must be done AFTER connecting to the server!285 */286 function rcmail_set_imap_prop()287 {288 global $CONFIG, $IMAP;289 290 if (!empty($CONFIG['default_charset']))291 $IMAP->set_charset($CONFIG['default_charset']);292 293 // set root dir from config294 if (!empty($CONFIG['imap_root']))295 $IMAP->set_rootdir($CONFIG['imap_root']);296 297 if (is_array($CONFIG['default_imap_folders']))298 $IMAP->set_default_mailboxes($CONFIG['default_imap_folders']);299 300 if (!empty($_SESSION['mbox']))301 $IMAP->set_mailbox($_SESSION['mbox']);302 if (isset($_SESSION['page']))303 $IMAP->set_page($_SESSION['page']);304 }305 306 307 /**308 * Do these things on script shutdown309 */310 function rcmail_shutdown()311 {312 global $IMAP, $CONTACTS;313 314 if (is_object($IMAP))315 {316 $IMAP->close();317 $IMAP->write_cache();318 }319 320 if (is_object($CONTACTS))321 $CONTACTS->close();322 323 // before closing the database connection, write session data324 session_write_close();325 }326 327 102 328 103 /** … … 340 115 } 341 116 342 $_SESSION = array(' user_lang' => $GLOBALS['sess_user_lang'], 'auth_time' => time(), 'temp' => true);117 $_SESSION = array('language' => $USER->language, 'auth_time' => time(), 'temp' => true); 343 118 setcookie('sessauth', '-del-', time()-60); 344 119 $USER->reset(); 345 120 } 346 121 122 347 123 /** 348 124 * Do server side actions on logout … … 350 126 function rcmail_logout_actions() 351 127 { 352 global $CONFIG, $IMAP ;128 global $CONFIG, $IMAP, $RCMAIL; 353 129 354 130 // on logout action we're not connected to imap server … … 359 135 return; 360 136 361 rcmail_imap_init(true);137 $RCMAIL->imap_init(true); 362 138 } 363 139 … … 408 184 409 185 return $sequence; 410 }411 412 413 /**414 * Check the given string and returns language properties415 *416 * @param string Language code417 * @param string Peropert name418 * @return string Property value419 */420 function rcube_language_prop($lang, $prop='lang')421 {422 static $rcube_languages, $rcube_language_aliases, $rcube_charsets;423 424 if (empty($rcube_languages))425 @include(INSTALL_PATH.'program/localization/index.inc');426 427 // check if we have an alias for that language428 if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang]))429 $lang = $rcube_language_aliases[$lang];430 431 // try the first two chars432 if (!isset($rcube_languages[$lang]) && strlen($lang)>2)433 {434 $lang = substr($lang, 0, 2);435 $lang = rcube_language_prop($lang);436 }437 438 if (!isset($rcube_languages[$lang]))439 $lang = 'en_US';440 441 // language has special charset configured442 if (isset($rcube_charsets[$lang]))443 $charset = $rcube_charsets[$lang];444 else445 $charset = 'UTF-8';446 447 448 if ($prop=='charset')449 return $charset;450 else451 return $lang;452 }453 454 455 /**456 * Init output object for GUI and add common scripts.457 * This will instantiate a rcmail_template object and set458 * environment vars according to the current session and configuration459 */460 function rcmail_load_gui()461 {462 global $CONFIG, $OUTPUT, $sess_user_lang;463 464 // init output page465 $OUTPUT = new rcube_template($CONFIG, $GLOBALS['_task']);466 $OUTPUT->set_env('comm_path', $GLOBALS['COMM_PATH']);467 468 foreach (array('flag_for_deletion') as $js_config_var)469 $OUTPUT->set_env($js_config_var, $CONFIG[$js_config_var]);470 471 if (!empty($GLOBALS['_framed']))472 $OUTPUT->set_env('framed', true);473 474 // set locale setting475 rcmail_set_locale($sess_user_lang);476 477 // set user-selected charset478 if (!empty($CONFIG['charset']))479 $OUTPUT->set_charset($CONFIG['charset']);480 481 // add some basic label to client482 $OUTPUT->add_label('loading');483 }484 485 /**486 * Create an output object for JSON responses487 */488 function rcmail_init_json()489 {490 global $CONFIG, $OUTPUT;491 492 // init output object493 $OUTPUT = new rcube_json_output($CONFIG, $GLOBALS['_task']);494 495 // set locale setting496 rcmail_set_locale($sess_user_lang);497 }498 499 /**500 * Set localization charset based on the given language.501 * This also creates a global property for mbstring usage.502 */503 function rcmail_set_locale($lang)504 {505 global $OUTPUT, $MBSTRING;506 static $s_mbstring_loaded = NULL;507 508 // settings for mbstring module (by Tadashi Jokagi)509 if (is_null($s_mbstring_loaded))510 $MBSTRING = $s_mbstring_loaded = extension_loaded("mbstring");511 else512 $MBSTRING = $s_mbstring_loaded = FALSE;513 514 if ($MBSTRING)515 mb_internal_encoding(RCMAIL_CHARSET);516 517 $OUTPUT->set_charset(rcube_language_prop($lang, 'charset'));518 186 } 519 187 … … 552 220 553 221 /** 554 * Perfom login to the IMAP server and to the webmail service.555 * This will also create a new user entry if auto_create_user is configured.556 *557 * @param string IMAP user name558 * @param string IMAP password559 * @param string IMAP host560 * @return boolean True on success, False on failure561 */562 function rcmail_login($user, $pass, $host=NULL)563 {564 global $CONFIG, $IMAP, $DB, $USER, $sess_user_lang;565 $user_id = NULL;566 567 if (!$host)568 $host = $CONFIG['default_host'];569 570 // Validate that selected host is in the list of configured hosts571 if (is_array($CONFIG['default_host']))572 {573 $allowed = FALSE;574 foreach ($CONFIG['default_host'] as $key => $host_allowed)575 {576 if (!is_numeric($key))577 $host_allowed = $key;578 if ($host == $host_allowed)579 {580 $allowed = TRUE;581 break;582 }583 }584 if (!$allowed)585 return FALSE;586 }587 else if (!empty($CONFIG['default_host']) && $host != $CONFIG['default_host'])588 return FALSE;589 590 // parse $host URL591 $a_host = parse_url($host);592 if ($a_host['host'])593 {594 $host = $a_host['host'];595 $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;596 $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);597 }598 else599 $imap_port = $CONFIG['default_port'];600 601 602 /* Modify username with domain if required603 Inspired by Marco <P0L0_notspam_binware.org>604 */605 // Check if we need to add domain606 if (!empty($CONFIG['username_domain']) && !strpos($user, '@'))607 {608 if (is_array($CONFIG['username_domain']) && isset($CONFIG['username_domain'][$host]))609 $user .= '@'.$CONFIG['username_domain'][$host];610 else if (is_string($CONFIG['username_domain']))611 $user .= '@'.$CONFIG['username_domain'];612 }613 614 // try to resolve email address from virtuser table615 if (!empty($CONFIG['virtuser_file']) && strpos($user, '@'))616 $user = rcube_user::email2user($user);617 618 // lowercase username if it's an e-mail address (#1484473)619 if (strpos($user, '@'))620 $user = strtolower($user);621 622 // query if user already registered623 if ($existing = rcube_user::query($user, $host))624 $USER = $existing;625 626 // user already registered -> overwrite username627 if ($USER->ID)628 {629 $user_id = $USER->ID;630 $user = $USER->data['username'];631 }632 633 // exit if IMAP login failed634 if (!($imap_login = $IMAP->connect($host, $user, $pass, $imap_port, $imap_ssl)))635 return false;636 637 // user already registered638 if ($USER->ID)639 {640 // get user prefs641 $CONFIG = array_merge($CONFIG, (array)$USER->get_prefs());642 643 // set user specific language644 if (!empty($USER->data['language']))645 $sess_user_lang = $_SESSION['user_lang'] = $USER->data['language'];646 647 // update user's record648 $USER->touch();649 }650 // create new system user651 else if ($CONFIG['auto_create_user'])652 {653 if ($created = rcube_user::create($user, $host))654 {655 $USER = $created;656 657 // get existing mailboxes658 $a_mailboxes = $IMAP->list_mailboxes();659 }660 }661 else662 {663 raise_error(array(664 'code' => 600,665 'type' => 'php',666 'file' => "config/main.inc.php",667 'message' => "Acces denied for new user $user. 'auto_create_user' is disabled"668 ), true, false);669 }670 671 if ($USER->ID)672 {673 $_SESSION['user_id'] = $USER->ID;674 $_SESSION['username'] = $USER->data['username'];675 $_SESSION['imap_host'] = $host;676 $_SESSION['imap_port'] = $imap_port;677 $_SESSION['imap_ssl'] = $imap_ssl;678 $_SESSION['user_lang'] = $sess_user_lang;679 $_SESSION['password'] = encrypt_passwd($pass);680 $_SESSION['login_time'] = mktime();681 682 // force reloading complete list of subscribed mailboxes683 rcmail_set_imap_prop();684 $IMAP->clear_cache('mailboxes');685 686 if ($CONFIG['create_default_folders'])687 $IMAP->create_default_folders();688 689 return TRUE;690 }691 692 return FALSE;693 }694 695 696 /**697 222 * Load virtuser table in array 698 223 * … … 746 271 function rcmail_overwrite_action($action) 747 272 { 748 global $OUTPUT;749 $ GLOBALS['_action']= $action;750 $ OUTPUT->set_env('action', $action);273 $app = rcmail::get_instance(); 274 $app->action = $action; 275 $app->output->set_env('action', $action); 751 276 } 752 277 … … 762 287 function rcmail_url($action, $p=array(), $task=null) 763 288 { 764 global $MAIN_TASKS, $COMM_PATH; 289 $app = rcmail::get_instance(); 290 765 291 $qstring = ''; 766 $base = $ COMM_PATH;767 768 if ($task && in_array($task, $MAIN_TASKS))769 $base = ereg_replace('_task=[a-z]+', '_task='.$task, $ COMM_PATH);292 $base = $app->comm_path; 293 294 if ($task && in_array($task, rcmail::$main_tasks)) 295 $base = ereg_replace('_task=[a-z]+', '_task='.$task, $app->comm_path); 770 296 771 297 if (is_array($p)) … … 965 491 function rcube_charset_convert($str, $from, $to=NULL) 966 492 { 967 global $MBSTRING; 968 static $convert_warning = false; 493 static $mbstring_loaded = null, $convert_warning = false; 969 494 970 495 $from = strtoupper($from); … … 990 515 } 991 516 992 // convert charset using mbstring module 993 if ($MBSTRING) 517 // settings for mbstring module (by Tadashi Jokagi) 518 if (is_null($mbstring_loaded)) { 519 if ($mbstring_loaded = extension_loaded("mbstring")) 520 mb_internal_encoding(RCMAIL_CHARSET); 521 } 522 523 // convert charset using mbstring module 524 if ($mbstring_loaded) 994 525 { 995 526 $aliases['UTF-7'] = 'UTF7-IMAP'; … … 1060 591 function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE) 1061 592 { 1062 global $OUTPUT _TYPE, $OUTPUT;593 global $OUTPUT; 1063 594 static $html_encode_arr = false; 1064 595 static $js_rep_table = false; … … 1514 1045 function format_date($date, $format=NULL) 1515 1046 { 1516 global $CONFIG , $sess_user_lang;1047 global $CONFIG; 1517 1048 1518 1049 $ts = NULL; … … 1525 1056 { 1526 1057 // if we have a date in non-rfc format 1527 // remove token from the end and try again1058 // remove token from the end and try again 1528 1059 $d = explode(' ', $date); 1529 array_pop($d);1530 if (!$d) break;1531 $date = implode(' ', $d);1060 array_pop($d); 1061 if (!$d) break; 1062 $date = implode(' ', $d); 1532 1063 } 1533 1064 } … … 1628 1159 if (!($GLOBALS['CONFIG']['debug_level'] & 4)) 1629 1160 write_log('console', $msg); 1630 else if ($GLOBALS[' REMOTE_REQUEST'])1161 else if ($GLOBALS['OUTPUT']->ajax_call) 1631 1162 print "/*\n $msg \n*/\n"; 1632 1163 else -
program/include/rcube_imap.php
r2577821 r197601e 466 466 return $a_mailbox_cache[$mailbox][$mode]; 467 467 468 // RECENT count is fetched a bit different468 // RECENT count is fetched a bit different 469 469 if ($mode == 'RECENT') 470 470 $count = iil_C_CheckForRecent($this->conn, $mailbox); -
program/include/rcube_json_output.php
r47fab0a r197601e 42 42 * Constructor 43 43 */ 44 public function __construct( &$config,$task)44 public function __construct($task) 45 45 { 46 46 $this->task = $task; 47 $this->config = $config;47 $this->config = rcmail::get_instance()->config; 48 48 } 49 49 -
program/include/rcube_shared.inc
r2577821 r197601e 92 92 function rcube_label($attrib) 93 93 { 94 global $ sess_user_lang, $OUTPUT;94 global $OUTPUT; 95 95 static $sa_text_data = false; 96 96 static $s_language, $utf8_decode; 97 98 $sess_user_lang = $_SESSION['language']; 97 99 98 100 // extract attributes -
program/include/rcube_template.php
rae0c82b0 r197601e 31 31 class rcube_template extends rcube_html_page 32 32 { 33 var $app; 33 34 var $config; 34 35 var $task = ''; … … 46 47 * 47 48 * @todo Use jQuery's $(document).ready() here. 48 */ 49 public function __construct(&$config, $task) 49 * @todo Replace $this->config with the real rcube_config object 50 */ 51 public function __construct($task, $framed = false) 50 52 { 51 53 parent::__construct(); 52 54 55 $this->app = rcmail::get_instance(); 56 $this->config = $this->app->config->all(); 57 58 //$this->framed = $framed; 53 59 $this->task = $task; 54 $this->config = $config;55 60 56 61 // add common javascripts … … 349 354 private function parse_with_globals($input) 350 355 { 351 $GLOBALS['__comm_path'] = Q($ GLOBALS['COMM_PATH']);356 $GLOBALS['__comm_path'] = Q($this->app->comm_path); 352 357 return preg_replace('/\$(__[a-z0-9_\-]+)/e', '$GLOBALS["\\1"]', $input); 353 358 } … … 610 615 private function button($attrib) 611 616 { 612 global $CONFIG, $OUTPUT, $MAIN_TASKS;613 617 static $sa_buttons = array(); 614 618 static $s_button_count = 100; … … 693 697 694 698 // make valid href to specific buttons 695 if (in_array($attrib['command'], $MAIN_TASKS)) {699 if (in_array($attrib['command'], rcmail::$main_tasks)) { 696 700 $attrib['href'] = Q(rcmail_url(null, null, $attrib['command'])); 697 701 } … … 796 800 797 801 /** 802 * Create a form tag with the necessary hidden fields 803 * 804 * @param array Named tag parameters 805 * @return string HTML code for the form 806 */ 807 public function form_tag($attrib, $content = null) 808 { 809 if ($this->framed) { 810 $hiddenfield = new html_hiddenfield(array('name' => '_framed', 'value' => '1')); 811 $hidden = $hiddenfield->show(); 812 } 813 814 if (!$content) 815 $attrib['noclose'] = true; 816 817 return html::tag('form', 818 $attrib + array('action' => "./", 'method' => "get"), 819 $hidden . $content); 820 } 821 822 823 /** 798 824 * GUI object 'username' 799 825 * Showing IMAP username of the current session … … 802 828 * @return string HTML code for the gui object 803 829 */ 804 static function current_username($attrib)830 public function current_username($attrib) 805 831 { 806 832 global $USER; … … 836 862 private function login_form($attrib) 837 863 { 838 global $CONFIG, $SESS_HIDDEN_FIELD; 839 $default_host = $CONFIG['default_host']; 864 $default_host = $this->config['default_host']; 840 865 841 866 $_SESSION['temp'] = true; … … 881 906 } 882 907 883 $out = $SESS_HIDDEN_FIELD; 884 $out .= $input_action->show(); 908 $out = $input_action->show(); 885 909 $out .= $table->show(); 886 910 887 911 // surround html output with a form tag 888 912 if (empty($attrib['form'])) { 889 $out = html::tag( 890 'form', 891 array( 892 'name' => $form_name, 893 'action' => "./", 894 'method' => "post" 895 ), 896 $out); 913 $out = $this->form_tag(array('name' => $form_name, 'method' => "post"), $out); 897 914 } 898 915 … … 925 942 // add form tag around text field 926 943 if (empty($attrib['form'])) { 927 $out = html::tag( 928 'form', 929 array( 930 'name' => "rcmqsearchform", 931 'action' => "./", 932 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 933 'style' => "display:inline", 934 ), 935 $out); 944 $out = $this->form_tag(array( 945 'name' => "rcmqsearchform", 946 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 947 'style' => "display:inline"), 948 $out); 936 949 } 937 950 -
program/include/rcube_user.php
r47124c22 r197601e 30 30 class rcube_user 31 31 { 32 var $ID = null; 33 var $data = null; 32 public $ID = null; 33 public $data = null; 34 public $language = 'en_US'; 35 36 private $db = null; 34 37 35 38 … … 41 44 function __construct($id = null, $sql_arr = null) 42 45 { 43 global $DB;46 $this->db = rcmail::get_instance()->get_dbh(); 44 47 45 48 if ($id && !$sql_arr) 46 49 { 47 $sql_result = $ DB->query("SELECT * FROM ".get_table_name('users')." WHERE user_id=?", $id);48 $sql_arr = $ DB->fetch_assoc($sql_result);50 $sql_result = $this->db->query("SELECT * FROM ".get_table_name('users')." WHERE user_id=?", $id); 51 $sql_arr = $this->db->fetch_assoc($sql_result); 49 52 } 50 53 … … 53 56 $this->ID = $sql_arr['user_id']; 54 57 $this->data = $sql_arr; 58 $this->language = $sql_arr['language']; 55 59 } 56 60 } … … 86 90 { 87 91 if ($this->ID && $this->data['preferences']) 88 return unserialize($this->data['preferences']);92 return array('language' => $this->language) + unserialize($this->data['preferences']); 89 93 else 90 94 return array(); … … 100 104 function save_prefs($a_user_prefs) 101 105 { 102 global $DB, $CONFIG, $sess_user_lang;103 104 106 if (!$this->ID) 105 107 return false; … … 107 109 // merge (partial) prefs array with existing settings 108 110 $a_user_prefs += (array)$this->get_prefs(); 109 110 $DB->query( 111 unset($a_user_prefs['language']); 112 113 $this->db->query( 111 114 "UPDATE ".get_table_name('users')." 112 115 SET preferences=?, … … 114 117 WHERE user_id=?", 115 118 serialize($a_user_prefs), 116 $ sess_user_lang,119 $_SESSION['language'], 117 120 $this->ID); 118 121 119 if ($DB->affected_rows()) 120 { 121 $CONFIG = array_merge($CONFIG, $a_user_prefs); 122 $this->language = $_SESSION['language']; 123 if ($this->db->affected_rows()) 124 { 125 rcmail::get_instance()->config->merge($a_user_prefs); 122 126 return true; 123 127 } … … 135 139 function get_identity($id = null) 136 140 { 137 global $DB;138 139 141 $sql_result = $this->list_identities($id ? sprintf('AND identity_id=%d', $id) : ''); 140 return $ DB->fetch_assoc($sql_result);142 return $this->db->fetch_assoc($sql_result); 141 143 } 142 144 … … 149 151 function list_identities($sql_add = '') 150 152 { 151 global $DB;152 153 153 // get contacts from DB 154 $sql_result = $ DB->query(154 $sql_result = $this->db->query( 155 155 "SELECT * FROM ".get_table_name('identities')." 156 156 WHERE del<>1 157 157 AND user_id=? 158 158 $sql_add 159 ORDER BY ".$ DB->quoteIdentifier('standard')." DESC, name ASC",159 ORDER BY ".$this->db->quoteIdentifier('standard')." DESC, name ASC", 160 160 $this->ID); 161 161 … … 173 173 function update_identity($iid, $data) 174 174 { 175 global $DB;176 177 175 if (!$this->ID) 178 176 return false; … … 183 181 { 184 182 $write_sql[] = sprintf("%s=%s", 185 $ DB->quoteIdentifier($col),186 $ DB->quote($value));187 } 188 189 $ DB->query(183 $this->db->quoteIdentifier($col), 184 $this->db->quote($value)); 185 } 186 187 $this->db->query( 190 188 "UPDATE ".get_table_name('identities')." 191 189 SET ".join(', ', $write_sql)." … … 196 194 $this->ID); 197 195 198 return $ DB->affected_rows();196 return $this->db->affected_rows(); 199 197 } 200 198 … … 208 206 function insert_identity($data) 209 207 { 210 global $DB;211 212 208 if (!$this->ID) 213 209 return false; … … 216 212 foreach ((array)$data as $col => $value) 217 213 { 218 $insert_cols[] = $ DB->quoteIdentifier($col);219 $insert_values[] = $ DB->quote($value);220 } 221 222 $ DB->query(214 $insert_cols[] = $this->db->quoteIdentifier($col); 215 $insert_values[] = $this->db->quote($value); 216 } 217 218 $this->db->query( 223 219 "INSERT INTO ".get_table_name('identities')." 224 220 (user_id, ".join(', ', $insert_cols).") … … 226 222 $this->ID); 227 223 228 return $ DB->insert_id(get_sequence_name('identities'));224 return $this->db->insert_id(get_sequence_name('identities')); 229 225 } 230 226 … … 238 234 function delete_identity($iid) 239 235 { 240 global $DB;241 242 236 if (!$this->ID) 243 237 return false; … … 246 240 return false; 247 241 248 $sql_result = $ DB->query("SELECT count(*) AS ident_count FROM " .242 $sql_result = $this->db->query("SELECT count(*) AS ident_count FROM " . 249 243 get_table_name('identities') . 250 244 " WHERE user_id = ? AND del <> 1", 251 245 $this->ID); 252 246 253 $sql_arr = $ DB->fetch_assoc($sql_result);247 $sql_arr = $this->db->fetch_assoc($sql_result); 254 248 if ($sql_arr['ident_count'] <= 1) 255 249 return false; 256 250 257 $ DB->query(251 $this->db->query( 258 252 "UPDATE ".get_table_name('identities')." 259 253 SET del=1 … … 263 257 $iid); 264 258 265 return $ DB->affected_rows();259 return $this->db->affected_rows(); 266 260 } 267 261 … … 274 268 function set_default($iid) 275 269 { 276 global $DB;277 278 270 if ($this->ID && $iid) 279 271 { 280 $ DB->query(272 $this->db->query( 281 273 "UPDATE ".get_table_name('identities')." 282 SET ".$ DB->quoteIdentifier('standard')."='0'274 SET ".$this->db->quoteIdentifier('standard')."='0' 283 275 WHERE user_id=? 284 276 AND identity_id<>? … … 295 287 function touch() 296 288 { 297 global $DB;298 299 289 if ($this->ID) 300 290 { 301 $ DB->query(291 $this->db->query( 302 292 "UPDATE ".get_table_name('users')." 303 SET last_login=".$ DB->now()."293 SET last_login=".$this->db->now()." 304 294 WHERE user_id=?", 305 295 $this->ID); … … 324 314 * @param string IMAP host name 325 315 * @return object rcube_user New user instance 326 * @static 327 */ 328 function query($user, $host) 329 { 330 global $DB; 316 */ 317 static function query($user, $host) 318 { 319 $dbh = rcmail::get_instance()->get_dbh(); 331 320 332 321 // query if user already registered 333 $sql_result = $ DB->query(322 $sql_result = $dbh->query( 334 323 "SELECT * FROM ".get_table_name('users')." 335 324 WHERE mail_host=? AND (username=? OR alias=?)", … … 339 328 340 329 // user already registered -> overwrite username 341 if ($sql_arr = $ DB->fetch_assoc($sql_result))330 if ($sql_arr = $dbh->fetch_assoc($sql_result)) 342 331 return new rcube_user($sql_arr['user_id'], $sql_arr); 343 332 else … … 352 341 * @param string IMAP host 353 342 * @return object rcube_user New user instance 354 * @static 355 */ 356 function create($user, $host) 357 { 358 global $DB, $CONFIG; 359 343 */ 344 static function create($user, $host) 345 { 360 346 $user_email = ''; 347 $rcmail = rcmail::get_instance(); 348 $dbh = $rcmail->get_dbh(); 361 349 362 350 // try to resolve user in virtusertable 363 if ( !empty($CONFIG['virtuser_file']) && !strpos($user, '@'))351 if ($rcmail->config->get('virtuser_file') && !strpos($user, '@')) 364 352 $user_email = rcube_user::user2email($user); 365 353 366 $ DB->query(354 $dbh->query( 367 355 "INSERT INTO ".get_table_name('users')." 368 356 (created, last_login, username, mail_host, alias, language) 369 VALUES (".$ DB->now().", ".$DB->now().", ?, ?, ?, ?)",357 VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?, ?)", 370 358 strip_newlines($user), 371 359 strip_newlines($host), 372 360 strip_newlines($user_email), 373 $_SESSION[' user_lang']);374 375 if ($user_id = $ DB->insert_id(get_sequence_name('users')))361 $_SESSION['language']); 362 363 if ($user_id = $dbh->insert_id(get_sequence_name('users'))) 376 364 { 377 365 $mail_domain = rcmail_mail_domain($host); … … 383 371 384 372 // try to resolve the e-mail address from the virtuser table 385 if ( !empty($CONFIG['virtuser_query']) &&386 ($sql_result = $ DB->query(preg_replace('/%u/', $DB->escapeSimple($user), $CONFIG['virtuser_query']))) &&387 ($ DB->num_rows()>0))373 if ($virtuser_query = $rcmail->config->get('virtuser_query') && 374 ($sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($user), $virtuser_query))) && 375 ($dbh->num_rows() > 0)) 388 376 { 389 while ($sql_arr = $ DB->fetch_array($sql_result))377 while ($sql_arr = $dbh->fetch_array($sql_result)) 390 378 { 391 $ DB->query(379 $dbh->query( 392 380 "INSERT INTO ".get_table_name('identities')." 393 381 (user_id, del, standard, name, email) … … 401 389 { 402 390 // also create new identity records 403 $ DB->query(391 $dbh->query( 404 392 "INSERT INTO ".get_table_name('identities')." 405 393 (user_id, del, standard, name, email) … … 429 417 * @param string E-mail address to resolve 430 418 * @return string Resolved IMAP username 431 * @static 432 */ 433 function email2user($email) 419 */ 420 static function email2user($email) 434 421 { 435 422 $user = $email; … … 456 443 * @param string User name 457 444 * @return string Resolved e-mail address 458 * @static 459 */ 460 function user2email($user) 445 */ 446 static function user2email($user) 461 447 { 462 448 $email = ""; … … 480 466 481 467 482 ?> -
program/steps/addressbook/edit.inc
r47124c22 r197601e 34 34 function rcmail_contact_editform($attrib) 35 35 { 36 global $ CONTACTS, $OUTPUT;36 global $RCMAIL, $CONTACTS, $OUTPUT; 37 37 38 38 // check if we have a valid result 39 if ($ GLOBALS['_action']!= 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first())))39 if ($RCMAIL->action != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first()))) 40 40 { 41 41 $OUTPUT->show_message('contactnotfound'); … … 84 84 function get_form_tags($attrib) 85 85 { 86 global $CONTACTS, $ OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;86 global $CONTACTS, $EDIT_FORM, $RCMAIL; 87 87 88 88 $result = $CONTACTS->get_result(); … … 90 90 if (!strlen($EDIT_FORM)) 91 91 { 92 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $ GLOBALS['_task']));92 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); 93 93 $hiddenfields->add(array('name' => '_action', 'value' => 'save', 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); 94 94 … … 96 96 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 97 97 98 $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 99 $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 98 $form_start = !strlen($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; 100 99 $form_start .= $hiddenfields->show(); 101 100 } … … 105 104 106 105 if (!strlen($EDIT_FORM)) 107 $ OUTPUT->add_gui_object('editform', $form_name);106 $RCMAIL->output->add_gui_object('editform', $form_name); 108 107 109 108 $EDIT_FORM = $form_name; 110 109 111 return array($form_start, $form_end); 110 return array($form_start, $form_end); 112 111 } 113 112 -
program/steps/addressbook/save.inc
r3fc00e6 r197601e 29 29 30 30 // check input 31 if ((!get_input_value('_name', RCUBE_INPUT_POST) || !get_input_value('_email', RCUBE_INPUT_POST)) && $ _framed)31 if ((!get_input_value('_name', RCUBE_INPUT_POST) || !get_input_value('_email', RCUBE_INPUT_POST)) && $OUTPUT->action) 32 32 { 33 33 $OUTPUT->show_message('formincomplete', 'warning'); … … 55 55 if ($CONTACTS->update($cid, $a_record)) 56 56 { 57 if ($ _framed)57 if ($OUTPUT->action) 58 58 { 59 59 // define list of cols to be displayed … … 97 97 if ($insert_id = $CONTACTS->insert($a_record)) 98 98 { 99 if ($ _framed)99 if ($OUTPUT->action) 100 100 { 101 101 // add contact row or jump to the page where it should appear -
program/steps/mail/compose.inc
r3dd0f25 r197601e 27 27 28 28 // remove an attachment 29 if ($ _action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs))29 if ($RCMAIL->action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs)) 30 30 { 31 31 $id = $regs[1]; … … 40 40 } 41 41 42 if ($ _action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs))42 if ($RCMAIL->action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs)) 43 43 { 44 44 $id = $regs[1]; … … 338 338 function rcmail_compose_body($attrib) 339 339 { 340 global $ CONFIG, $OUTPUT, $MESSAGE, $compose_mode;340 global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode; 341 341 342 342 list($form_start, $form_end) = get_form_tags($attrib); … … 411 411 } 412 412 413 $tinylang = substr($_SESSION[' user_lang'], 0, 2);413 $tinylang = substr($_SESSION['language'], 0, 2); 414 414 if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js')) 415 415 { … … 456 456 "googie.decorateTextarea('%s');\n". 457 457 "%s.set_env('spellcheck', googie);", 458 $ GLOBALS['COMM_PATH'],458 $RCMAIL->comm_path, 459 459 JQ(Q(rcube_label('checkspelling'))), 460 460 JQ(Q(rcube_label('resumeediting'))), … … 463 463 JQ(Q(rcube_label('nospellerrors'))), 464 464 $lang_set, 465 substr($_SESSION[' user_lang'], 0, 2),465 substr($_SESSION['language'], 0, 2), 466 466 $attrib['id'], 467 467 JS_OBJECT_NAME), 'foot'); … … 705 705 function rcmail_compose_attachment_form($attrib) 706 706 { 707 global $OUTPUT , $SESS_HIDDEN_FIELD;707 global $OUTPUT; 708 708 709 709 // add ID if not given … … 711 711 $attrib['id'] = 'rcmUploadbox'; 712 712 713 // allow the following attributes to be added to the <div> tag 714 $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); 715 $input_field = rcmail_compose_attachment_field(array()); 716 $label_send = rcube_label('upload'); 717 $label_close = rcube_label('close'); 718 $js_instance = JS_OBJECT_NAME; 719 720 $out = <<<EOF 721 <div$attrib_str> 722 <form action="./" method="post" enctype="multipart/form-data"> 723 $SESS_HIDDEN_FIELD 724 $input_field<br /> 725 <input type="button" value="$label_close" class="button" onclick="document.getElementById('$attrib[id]').style.visibility='hidden'" /> 726 <input type="button" value="$label_send" class="button" onclick="$js_instance.command('send-attachment', this.form)" /> 727 </form> 728 </div> 729 EOF; 730 713 $button = new html_inputfield(array('type' => "button", 'class' => "button")); 714 715 $out = html::div($attrib, 716 $OUTPUT->form_tag(array('name' => "form", 'method' => "post")) . 717 rcmail_compose_attachment_field(array()) . html::br() . 718 $button->show(rcube_label('close'), array('onclick' => "document.getElementById('$attrib[id]').style.visibility='hidden'")) . 719 $button->show(rcube_label('upload'), array('onclick' => JS_OBJECT_NAME . ".command('send-attachment', this.form)")) 720 ); 721 731 722 732 723 $OUTPUT->add_gui_object('uploadbox', $attrib['id']); … … 844 835 function get_form_tags($attrib) 845 836 { 846 global $ CONFIG, $OUTPUT, $MESSAGE_FORM, $SESS_HIDDEN_FIELD;837 global $RCMAIL, $MESSAGE_FORM; 847 838 848 839 $form_start = ''; 849 840 if (!strlen($MESSAGE_FORM)) 850 841 { 851 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $ GLOBALS['_task']));842 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); 852 843 $hiddenfields->add(array('name' => '_action', 'value' => 'send')); 853 844 854 $form_start = empty($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 855 $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 845 $form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; 856 846 $form_start .= $hiddenfields->show(); 857 847 } … … 861 851 862 852 if (!strlen($MESSAGE_FORM)) 863 $ OUTPUT->add_gui_object('messageform', $form_name);853 $RCMAIL->output->add_gui_object('messageform', $form_name); 864 854 865 855 $MESSAGE_FORM = $form_name; -
program/steps/mail/folders.inc
ra02d486 r197601e 22 22 23 23 // send EXPUNGE command 24 if ($ _action=='expunge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)))24 if ($RCMAIL->action=='expunge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))) 25 25 { 26 26 $success = $IMAP->expunge($mbox); … … 30 30 { 31 31 $OUTPUT->command('message_list.clear'); 32 $ _action = 'list';32 $RCMAIL->action = 'list'; 33 33 return; 34 34 } … … 38 38 39 39 // clear mailbox 40 else if ($ _action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)))40 else if ($RCMAIL->action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))) 41 41 { 42 42 // we should only be purging trash and junk -
program/steps/mail/func.inc
re3902eb r197601e 75 75 76 76 // set page title 77 if (empty($ _action) || $_action == 'list')77 if (empty($RCMAIL->action) || $RCMAIL->action == 'list') 78 78 $OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->get_mailbox_name())); 79 79 -
program/steps/mail/move_del.inc
r6d2714b r197601e 25 25 26 26 // move messages 27 if ($ _action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox']))27 if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) 28 28 { 29 29 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); … … 42 42 43 43 // delete messages 44 else if ($ _action=='delete' && !empty($_POST['_uid']))44 else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) 45 45 { 46 46 $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); … … 90 90 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX')); 91 91 92 if ($ _action=='moveto' && $target)92 if ($RCMAIL->action=='moveto' && $target) 93 93 $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); 94 94 -
program/steps/mail/sendmail.inc
r47124c22 r197601e 314 314 315 315 // encoding subject header with mb_encode provides better results with asian characters 316 if ( $MBSTRING &&function_exists("mb_encode_mimeheader"))316 if (function_exists("mb_encode_mimeheader")) 317 317 { 318 318 mb_internal_encoding($message_charset); -
program/steps/mail/show.inc
r3f5cef86 r197601e 20 20 */ 21 21 22 $PRINT_MODE = $ _action=='print' ? TRUE : FALSE;22 $PRINT_MODE = $RCMAIL->action=='print' ? TRUE : FALSE; 23 23 24 24 // similar code as in program/steps/mail/get.inc … … 36 36 { 37 37 $OUTPUT->show_message('messageopenerror', 'error'); 38 if ($ _action=='preview' && template_exists('messagepreview'))38 if ($RCMAIL->action=='preview' && template_exists('messagepreview')) 39 39 $OUTPUT->send('messagepreview'); 40 40 else 41 41 { 42 $ _action = 'list';42 $RCMAIL->action = 'list'; 43 43 return; 44 44 } … … 79 79 { 80 80 $marked = $IMAP->set_flag($MESSAGE['UID'], 'SEEN'); 81 if($ _action == 'preview' && $marked != -1)81 if($RCMAIL->action == 'preview' && $marked != -1) 82 82 { 83 83 $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); … … 204 204 205 205 206 if ($ _action=='print' && template_exists('printmessage'))206 if ($RCMAIL->action=='print' && template_exists('printmessage')) 207 207 $OUTPUT->send('printmessage'); 208 else if ($ _action=='preview' && template_exists('messagepreview'))208 else if ($RCMAIL->action=='preview' && template_exists('messagepreview')) 209 209 $OUTPUT->send('messagepreview'); 210 210 else -
program/steps/settings/edit_identity.inc
r140d6e9 r197601e 20 20 */ 21 21 22 if (($_GET['_iid'] || $_POST['_iid']) && $ _action=='edit-identity')22 if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') 23 23 { 24 24 $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); … … 38 38 function rcube_identity_form($attrib) 39 39 { 40 global $IDENTITY_RECORD, $ OUTPUT;40 global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; 41 41 42 $tinylang = substr($_SESSION[' user_lang'], 0, 2);42 $tinylang = substr($_SESSION['language'], 0, 2); 43 43 if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js')) 44 44 { … … 59 59 "theme_advanced_buttons3 : '' });"); 60 60 61 if (!$IDENTITY_RECORD && $ GLOBALS['_action']!='add-identity')61 if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity') 62 62 return rcube_label('notfound'); 63 63 … … 139 139 $OUTPUT->add_handler('identityform', 'rcube_identity_form'); 140 140 141 if ($ _action=='add-identity' && template_exists('addidentity'))141 if ($RCMAIL->action=='add-identity' && template_exists('addidentity')) 142 142 $OUTPUT->send('addidentity'); 143 143 -
program/steps/settings/func.inc
r4c84dda r197601e 28 28 function rcmail_user_prefs_form($attrib) 29 29 { 30 global $DB, $CONFIG , $sess_user_lang;30 global $DB, $CONFIG; 31 31 32 32 $no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array(); … … 57 57 $field_id, 58 58 Q(rcube_label('language')), 59 $select_lang->show($ sess_user_lang));59 $select_lang->show($_SESSION['language'])); 60 60 } 61 61 … … 252 252 function get_form_tags($attrib, $action, $add_hidden=array()) 253 253 { 254 global $ OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;254 global $EDIT_FORM, $RCMAIL; 255 255 256 256 $form_start = ''; 257 257 if (!strlen($EDIT_FORM)) 258 258 { 259 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $ GLOBALS['_task']));259 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); 260 260 $hiddenfields->add(array('name' => '_action', 'value' => $action)); 261 261 … … 263 263 $hiddenfields->add($add_hidden); 264 264 265 $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 266 $form_start .= "\n$SESS_HIDDEN_FIELD\n"; 265 $form_start = !strlen($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; 267 266 $form_start .= $hiddenfields->show(); 268 267 } … … 272 271 273 272 if (!strlen($EDIT_FORM)) 274 $ OUTPUT->add_gui_object('editform', $form_name);273 $RCMAIL->output->add_gui_object('editform', $form_name); 275 274 276 275 $EDIT_FORM = $form_name; 277 276 278 return array($form_start, $form_end); 277 return array($form_start, $form_end); 279 278 } 280 279 -
program/steps/settings/manage_folders.inc
r09c1a37 r197601e 21 21 22 22 // init IMAP connection 23 rcmail_imap_init(TRUE);23 $RCMAIL->imap_init(true); 24 24 25 25 // subscribe to one or more mailboxes 26 if ($ _action=='subscribe')26 if ($RCMAIL->action=='subscribe') 27 27 { 28 28 if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)) … … 34 34 35 35 // unsubscribe one or more mailboxes 36 else if ($ _action=='unsubscribe')36 else if ($RCMAIL->action=='unsubscribe') 37 37 { 38 38 if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)) … … 44 44 45 45 // create a new mailbox 46 else if ($ _action=='create-folder')46 else if ($RCMAIL->action=='create-folder') 47 47 { 48 48 if (!empty($_POST['_name'])) … … 63 63 64 64 // rename a mailbox 65 else if ($ _action=='rename-folder')65 else if ($RCMAIL->action=='rename-folder') 66 66 { 67 67 if (!empty($_POST['_folder_oldname']) && !empty($_POST['_folder_newname'])) … … 98 98 99 99 // delete an existing IMAP mailbox 100 else if ($ _action=='delete-folder')100 else if ($RCMAIL->action=='delete-folder') 101 101 { 102 102 $a_mboxes = array_merge($IMAP->list_mailboxes(), $IMAP->list_unsubscribed()); -
program/steps/settings/save_identity.inc
rfba1f5a r197601e 108 108 109 109 // go to next step 110 rcmail_overwrite_action($ _framed? 'edit-identity' : 'identities');110 rcmail_overwrite_action($OUTPUT->action ? 'edit-identity' : 'identities'); 111 111 112 112 ?> -
program/steps/settings/save_prefs.inc
rccb412f r197601e 40 40 // switch UI language 41 41 if (isset($_POST['_language'])) 42 { 43 $sess_user_lang = $_SESSION['user_lang'] = get_input_value('_language', RCUBE_INPUT_POST); 44 rcmail_set_locale($sess_user_lang); 45 } 42 $_SESSION['language'] = get_input_value('_language', RCUBE_INPUT_POST); 46 43 47 44 // force min size
Note: See TracChangeset
for help on using the changeset viewer.
