summaryrefslogtreecommitdiff
path: root/roundcubemail
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-10 08:26:41 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-10 08:26:41 +0000
commit5009dfd1d02e53560fc30d1afac8e625bc44365a (patch)
tree9bb67f4def86c322509877150450e44946ee5653 /roundcubemail
parent4e127e85e286c6407afdedc321fd930ef6aa00be (diff)
- Add add_shutdown_function() method. Make possible to call user function before destoying all objects (e.g. session)
git-svn-id: https://svn.roundcube.net/trunk@4923 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail')
-rw-r--r--roundcubemail/program/include/rcmail.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/roundcubemail/program/include/rcmail.php b/roundcubemail/program/include/rcmail.php
index fe2d99475..dba846dd2 100644
--- a/roundcubemail/program/include/rcmail.php
+++ b/roundcubemail/program/include/rcmail.php
@@ -124,6 +124,7 @@ class rcmail
private $address_books = array();
private $caches = array();
private $action_map = array();
+ private $shutdown_functions = array();
/**
@@ -1142,6 +1143,9 @@ class rcmail
*/
public function shutdown()
{
+ foreach ($this->shutdown_functions as $function)
+ call_user_func($function);
+
if (is_object($this->smtp))
$this->smtp->disconnect();
@@ -1183,6 +1187,19 @@ class rcmail
/**
+ * Registers shutdown function to be executed on shutdown.
+ * The functions will be executed before destroying any
+ * objects like smtp, imap, session, etc.
+ *
+ * @param callback Function callback
+ */
+ public function add_shutdown_function($function)
+ {
+ $this->shutdown_functions[] = $function;
+ }
+
+
+ /**
* Generate a unique token to be used in a form request
*
* @return string The request token