diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-05-14 19:26:34 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-05-14 19:26:34 +0000 |
| commit | a5e39d3f44dec5686b1e9035dca18ed52cee3105 (patch) | |
| tree | 2b0cfec36d00d591c7d90c2d2f624d8ad9f7d265 /roundcubemail/program/include/rcube_user.php | |
| parent | d0553956fda180f534de3a928f688c3d4e242d15 (diff) | |
Trigger 'create_identity' when creating a new user; Allow 'create_user' hook to abort the operation
git-svn-id: https://svn.roundcube.net/trunk@2481 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_user.php')
| -rw-r--r-- | roundcubemail/program/include/rcube_user.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/roundcubemail/program/include/rcube_user.php b/roundcubemail/program/include/rcube_user.php index 79721d51b..da819c7c0 100644 --- a/roundcubemail/program/include/rcube_user.php +++ b/roundcubemail/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; } } |
