From f879f4e2f8c81f67b0a0c471c94ebed686939c49 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 14 May 2009 15:26:34 -0400
Subject: [PATCH] Trigger 'create_identity' when creating a new user; Allow 'create_user' hook to abort the operation
---
program/include/rcube_plugin.php | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/program/include/rcube_plugin.php b/program/include/rcube_plugin.php
index 62f65a9..365ef28 100644
--- a/program/include/rcube_plugin.php
+++ b/program/include/rcube_plugin.php
@@ -101,11 +101,29 @@
* @return string Localized text
* @see rcmail::gettext()
*/
- function gettext($p)
+ public function gettext($p)
{
return rcmail::get_instance()->gettext($p, $this->ID);
}
-
+
+ /**
+ * Register this plugin to be responsible for a specific task
+ *
+ * @param string Task name (only characters [a-z0-9_.-] are allowed)
+ */
+ public function register_task($task)
+ {
+ if ($task != asciiwords($task)) {
+ raise_error(array('code' => 526, 'type' => 'php', 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false);
+ }
+ else if (in_array(rcmail::$main_tasks, $task)) {
+ raise_error(array('code' => 526, 'type' => 'php', 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false);
+ }
+ else {
+ rcmail::$main_tasks[] = $task;
+ }
+ }
+
/**
* Register a handler for a specific client-request action
*
@@ -177,7 +195,7 @@
*/
private function ressource_url($fn)
{
- if ($fn[0] != '/' && !eregi('^https?://', $fn))
+ if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn))
return $this->ID . '/' . $fn;
else
return $fn;
--
Gitblit v1.9.1