Common PHP functions
The include file program/include/main.inc provides some commonly used functions which are listed below.
get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL)
Read a specific GET/POST value and convert it for (safe) internal use. Performs stripslashes() and charset conversion if necessary. Use one of the following constants to specify $source: RCUBE_INPUT_GET, RCUBE_INPUT_POST, RCUBE_INPUT_GPC
rcube_charset_convert($str, $from, $to=NULL)
This function converts a string from one charset to another. This is mostly used for converting mail contents into the internally used UTF-8 charset. It invokes mbstring or iconv function if available. The third parameter defaults to the internal chars which is UTF-8.
Q($str, $mode='strict', $newlines=TRUE)
HTML encodes a string similar to htmlentities(). This should be used wherever a variable is written to the HTML output. $mode accepts the following values: 'strict' (encode all entities), 'show' (leave <>"&), 'remove' (executes strip_tags()).
Delivers response content to the client. This will automatically decide whether it's an AJAX call or a regular request and then send the commands and contents accordingly. The specified JS code (usually added with $OUTPUT->command()) will be evaled and executed on the client.
Used for debug output. Depending on the debug_level it will dump the given value to the HTML page or write it to logs/console.
Append a line to a logfile ($name) in the logs directory. The current date will be added automatically to the line.
Get a localized text. $attrib can be the label/message name or an array with the following keys: 'name', 'vars' (hash array of variables to replace in text), 'uppercase' (boolean), 'lowercase' (boolean).
Global objects and vars
The main application object holding instances of all the 'global' objects like config, database and imap connections. It's and instance of the rcmail class and can be obtained by calling rcmail::get_instance()
$IMAP (deprecated, use $RCMAIL->imap instead)
This is a global instance of the rcube_imap class. It is created and initialized by Roundcube's startup function.
$OUTPUT (deprecated, use $RCMAIL->output instead)
A global instance of the rcube_template class. Use it to collect all kind of response data to be sent to the client after processing the script.
$DB (deprecated, use $RCMAIL->get_dbh() instead)
Use this global instance of the rcube_db class for all database communication. It is initialized by Roundcube's startup function.
$CONFIG (deprecated, use $RCMAIL->config instead)
Global array containing all config parameters. It is loaded from the local config files and extended by the user specific settings.