rcube

Base class of the Roundcube Framework implemented as singleton

package

Framework

subpackage

Core

Methods

Private constructor

__construct( $env = '') 

Arguments

$env

Registers shutdown function to be executed on shutdown.

add_shutdown_function(callback $function) 

The functions will be executed before destroying any objects like smtp, imap, session, etc.

Arguments

$function

callback

Function callback

Check if the current request contains a valid token.

check_request(integer $mode = \rcube_utils::INPUT_POST) : boolean

Empty requests aren't checked until use_secure_urls is set.

Arguments

$mode

integer

Request method

Response

boolean

True if request token is valid false if not

Print or write debug messages

console() 
static

Write debug info to the log

debug(string $engine, string $data, boolean $result = null) 
static

Arguments

$engine

string

Engine type - file name (memcache, apc)

$data

string

Data string to log

$result

boolean

Operation result

Decrypt a string

decrypt(string $cipher, string $key = 'des_key', boolean $base64 = true) : string

Arguments

$cipher

string

Encrypted text

$key

string

Encryption key to retrieve from the configuration, defaults to 'des_key'

$base64

boolean

Whether or not input is base64-encoded

Response

string

Decrypted text

Send the given message using the configured method.

deliver_message(object &$message, string $from, array $mailto, array &$error, string &$body_file = null, array $options = null, boolean $disconnect = false) : boolean

Arguments

$message

object

Reference to Mail_MIME object

$from

string

Sender address string

$mailto

array

Array of recipient address strings

$error

array

SMTP error array (reference)

$body_file

string

Location of file with saved message body (reference), used when delay_file_io is enabled

$options

array

SMTP options (e.g. DSN request)

$disconnect

boolean

Close SMTP connection ASAP

Response

boolean

Send status.

Encrypt a string

encrypt(string $clear, string $key = 'des_key', boolean $base64 = true) : string

Arguments

$clear

string

Clear text input

$key

string

Encryption key to retrieve from the configuration, defaults to 'des_key'

$base64

boolean

Whether or not to base64_encode() the result before returning

Response

string

Encrypted text

Construct shell command, execute it and return output as string.

exec() : \output
static

Keywords {keyword} are replaced with arguments

Response

\output

of command. shell errors not detectable

Garbage collector - cache/temp cleaner

gc() 

Runs garbage collector with probability based on session settings. This is intended for environments without a session.

gc_run() 

Garbage collector function for temp files.

gc_temp() 

Remove temp files older than two days

Unique Message-ID generator.

gen_message_id(string $sender = null) : string

Arguments

$sender

string

Optional sender e-mail address

Response

string

Message-ID

Initialize and get cache object

get_cache(string $name, string $type = 'db', string $ttl, boolean $packed = true) : \rcube_cache

Arguments

$name

string

Cache identifier

$type

string

Cache type ('db', 'apc' or 'memcache')

$ttl

string

Expiration time for cache items

$packed

boolean

Enables/disables data serialization

Response

\rcube_cache

Cache object

Initialize and get shared cache object

get_cache_shared(string $name, boolean $packed = true) : \rcube_cache_shared

Arguments

$name

string

Cache identifier

$packed

boolean

Enables/disables data serialization

Response

\rcube_cache_shared

Cache object

Get the current database connection

get_dbh() : \rcube_db

Response

\rcube_db

Database object

This implements the 'singleton' design pattern

get_instance(integer $mode, string $env = '') : \rcube
static

Arguments

$mode

integer

Options to initialize with this instance. See rcube::INITWITH* constants

$env

string

Environment name to run (e.g. live, dev, test)

Response

\rcube

The one and only instance

Get global handle for memcache access

get_memcache() : object

Response

object

Memcache

Generate a unique token to be used in a form request

get_request_token() : string

Response

string

The request token

Returns session token for secure URLs

get_secure_url_token(boolean $generate = false) : string|boolean

Arguments

$generate

boolean

Generate token if not exists in session yet

Response

string|boolean

Token string, False when disabled

Initialize and get storage object

get_storage() : \rcube_storage

Response

\rcube_storage

Storage object

Getter for logged user email (derived from user name not identity).

get_user_email() : string

Response

string

User email address

Getter for logged user ID.

get_user_id() : mixed

Response

mixed

User identifier

Getter for logged user language code.

get_user_language() : string

Response

string

User language code

Get the per-user log directory

get_user_log_dir() 

Getter for logged user name.

get_user_name() : string

Response

string

User name

Getter for logged user password.

get_user_password() : string

Response

string

User password

Get localized text in the desired language

gettext(mixed $attrib, string $domain = null) : string

Arguments

$attrib

mixed

Named parameters array or label name

$domain

string

Label domain (plugin) name

Response

string

Localized text

Initial startup function

init( $mode) 

Arguments

$mode

Quote a given string for javascript output.

JQ( $str) : string
static

Shortcut function for rcube_utils::rep_specialchars_output()

Arguments

$str

Response

string

JS-quoted string

Check the given string and return a valid language code

language_prop(string $lang) : string

Arguments

$lang

string

Language code

Response

string

Valid language code

Read directory program/localization and return a list of available languages

list_languages() : array

Response

array

List of available localizations

Load a localization package

load_language(string $lang = null, array $add = array(), array $merge = array()) 

Arguments

$lang

string

Language ID

$add

array

Additional text labels/messages

$merge

array

Additional text labels/messages to merge

Report error according to configured debug_level

log_bug(array $arg_arr) 
static
see \rcube::raise_error()

Arguments

$arg_arr

array

Named parameters

Callback for memcache failure

memcache_failure( $host,  $port) 

Arguments

$host

$port

Get global handle for memcache access

memcache_init() : object

Response

object

Memcache

Logs time difference according to provided timer

print_timer(float $timer, string $label = 'Timer', string $dest = 'console') 
static
see \rcube::timer()

Arguments

$timer

float

Timer (self::timer() result)

$label

string

Log line prefix

$dest

string

Log file name

Quote a given string.

Q( $str,  $mode = 'strict',  $newlines = true) : string
static

Shortcut function for rcube_utils::rep_specialchars_output()

Arguments

$str

$mode

$newlines

Response

string

HTML-quoted string

Throw system error (and show error page).

raise_error(array $arg = array(), boolean $log = false, boolean $terminate = false) 
static

Arguments

$arg

array

Named parameters

  • code: Error code (required)
  • type: Error type [php|db|imap|javascript]
  • message: Error message
  • file: File where error occurred
  • line: Line where error occurred

$log

boolean

True to log the error

$terminate

boolean

Terminate script execution

Create session object and start the session.

session_init() 

Set special folders type association.

set_special_folders() 

This must be done AFTER connecting to the server!

Set storage parameters.

set_storage_prop() 

Setter for system user object

set_user( $user) 

Arguments

$user

Function to be executed in script shutdown Registered with register_shutdown_function()

shutdown() 

When you're going to sleep the script execution for a longer time it is good to close all external connections (sql, memcache, SMTP, IMAP).

sleep() 

No action is required on wake up, all connections will be re-established automatically.

Create SMTP object and connect to server

smtp_init(boolean $connect = false) 

Arguments

$connect

boolean

True if connection should be established

Initialize storage object

storage_init() 

Callback for IMAP connection events to log session identifiers

storage_log_session( $args) 

Arguments

$args

Check if the given text label exists

text_exists(string $name, string $domain = null, string &$ref_domain = null) : boolean

Arguments

$name

string

Label name

$domain

string

Label domain (plugin) name or '*' for all domains

$ref_domain

string

Sets domain name if label is found

Response

boolean

True if text exists (either in the current language or in en_US)

Returns current time (with microseconds).

timer() : float
static

Response

float

Current time in seconds since the Unix

Build a valid URL to this instance of Roundcube

url(mixed $p) : string

Arguments

$p

mixed

Either a string with the action or url parameters as key-value pairs

Response

string

Valid application URL

Append a line to a logfile in the logs directory.

write_log(string $name, mixed $line) : boolean
static

Date will be added automatically to the line.

Arguments

$name

string

Name of the log file

$line

mixed

Line to append

Response

boolean

True on success, False on failure

Constants

INIT_WITH_DB

INIT_WITH_DB

INIT_WITH_PLUGINS

INIT_WITH_PLUGINS

REQUEST_VALID

REQUEST_VALID

REQUEST_ERROR_URL

REQUEST_ERROR_URL

REQUEST_ERROR_TOKEN

REQUEST_ERROR_TOKEN

DEBUG_LINE_LENGTH

DEBUG_LINE_LENGTH

Properties

Singleton instance of rcube

instance : \rcube
static
var

Type(s)

\rcube

Stores instance of rcube_config.

config : \rcube_config
var

Type(s)

\rcube_config

Instance of database class.

db : \rcube_db
var

Type(s)

\rcube_db

Instance of Memcache class.

memcache : \Memcache
var

Type(s)

\Memcache

Instance of rcube_session class.

session : \rcube_session
var

Type(s)

\rcube_session

Instance of rcube_smtp class.

smtp : \rcube_smtp
var

Type(s)

\rcube_smtp

Instance of rcube_storage class.

storage : \rcube_storage
var

Type(s)

\rcube_storage

Instance of rcube_output class.

output : \rcube_output
var

Type(s)

\rcube_output

Instance of rcube_plugin_api.

plugins : \rcube_plugin_api
var

Type(s)

\rcube_plugin_api

Instance of rcube_user class.

user : \rcube_user
var

Type(s)

\rcube_user

Request status

request_status : integer
var

Type(s)

integer

texts

texts : 

Type(s)

caches

caches : 

Type(s)

shutdown_functions

shutdown_functions : 

Type(s)