summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2009-05-14 19:26:34 +0000
committerthomascube <thomas@roundcube.net>2009-05-14 19:26:34 +0000
commitf879f4e2f8c81f67b0a0c471c94ebed686939c49 (patch)
tree579b1b9c06dfbe8ee23b66831db46dc6ff2fb145 /program
parente54f6c7a9efa28633616064bea68a3d2b4468272 (diff)
Trigger 'create_identity' when creating a new user; Allow 'create_user' hook to abort the operation
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail.php7
-rw-r--r--program/include/rcube_user.php29
-rw-r--r--program/steps/settings/save_identity.inc2
3 files changed, 29 insertions, 9 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 6ed095062..06f50a13f 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -491,6 +491,13 @@ class rcmail
// get existing mailboxes (but why?)
// $a_mailboxes = $this->imap->list_mailboxes();
}
+ else {
+ raise_error(array(
+ 'code' => 600,
+ 'type' => 'php',
+ 'message' => "Failed to create a user record. Maybe aborted by a plugin?"
+ ), true, false);
+ }
}
else {
raise_error(array(
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index 79721d51b..da819c7c0 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -353,6 +353,10 @@ class rcube_user
$data = $rcmail->plugins->exec_hook('create_user', array('user'=>$user, 'user_name'=>$user_name, 'user_email'=>$user_email));
$user_name = $data['user_name'];
$user_email = $data['user_email'];
+
+ // plugin aborted this operation
+ if ($data['abort'])
+ return false;
$dbh = $rcmail->get_dbh();
@@ -392,14 +396,23 @@ class rcube_user
// create new identities records
$standard = 1;
foreach ($email_list as $email) {
- $dbh->query(
- "INSERT INTO ".get_table_name('identities')."
- (user_id, del, standard, name, email)
- VALUES (?, 0, ?, ?, ?)",
- $user_id,
- $standard,
- strip_newlines($user_name),
- preg_replace('/^@/', $user . '@', $email));
+ $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('record' => array(
+ 'login' => true,
+ 'user_id' => $user_id,
+ 'name' => strip_newlines($user_name),
+ 'email' => $email,
+ 'standard' => $standard)));
+
+ if (!$plugin['abort'] && $plugin['record']['name'] && $plugin['record']['email']) {
+ $dbh->query(
+ "INSERT INTO ".get_table_name('identities')."
+ (user_id, del, standard, name, email)
+ VALUES (?, 0, ?, ?, ?)",
+ $user_id,
+ $plugin['record']['standard'],
+ $plugin['record']['name'],
+ $plugin['record']['email']);
+ }
$standard = 0;
}
}
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index 754e86c55..900c2d3d9 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -92,7 +92,7 @@ else if (IDENTITIES_LEVEL < 2)
if (IDENTITIES_LEVEL == 1)
$save_data['email'] = $RCMAIL->user->get_username();
- $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('id' => $iid, 'record' => $save_data));
+ $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('record' => $save_data));
$save_data = $plugin['record'];
if (!$plugin['abort'] && $save_data['email'] && ($insert_id = $USER->insert_identity($save_data)))