From 04f18502befec8efa8ae5c2cf254d156d316c21a Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sun, 24 Jan 2016 07:45:24 +0000 Subject: [PATCH] Add plugin events for user accounts lifecycle - EVENT_MANAGE_USER_CREATE_FORM - EVENT_MANAGE_USER_CREATE - EVENT_MANAGE_USER_UPDATE_FORM - EVENT_MANAGE_USER_UPDATE - EVENT_MANAGE_USER_DELETE - EVENT_MANAGE_USER_PAGE Fixes #8779 --- core/events_inc.php | 10 ++ core/user_api.php | 4 + .../en-US/Events_Reference_Manage.xml | 111 ++++++++++++++++++ manage_user_create_page.php | 3 + manage_user_edit_page.php | 5 + manage_user_update.php | 2 + 6 files changed, 135 insertions(+) diff --git a/core/events_inc.php b/core/events_inc.php index a56e9a6769c..73e5439b227 100644 --- a/core/events_inc.php +++ b/core/events_inc.php @@ -76,6 +76,16 @@ 'EVENT_MANAGE_VERSION_UPDATE' => EVENT_TYPE_EXECUTE, 'EVENT_MANAGE_VERSION_DELETE' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_CREATE_FORM' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_CREATE' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_UPDATE_FORM' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_UPDATE' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_DELETE' => EVENT_TYPE_EXECUTE, + 'EVENT_MANAGE_USER_PAGE' => EVENT_TYPE_EXECUTE, + + # TODO: Should we use jquery to insert elements on view page and on forms + # rather than having events that restrict where to insert such elements? + # User account pages 'EVENT_ACCOUNT_PREF_UPDATE_FORM' => EVENT_TYPE_EXECUTE, 'EVENT_ACCOUNT_PREF_UPDATE' => EVENT_TYPE_EXECUTE, diff --git a/core/user_api.php b/core/user_api.php index 56bea4e602e..7452eb01ca4 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -557,6 +557,8 @@ function user_create( $p_username, $p_password, $p_email = '', email_signup( $t_user_id, $t_confirm_hash, $p_admin_name ); } + event_signal( 'EVENT_MANAGE_USER_CREATE', array( $t_user_id ) ); + return $t_cookie_string; } @@ -649,6 +651,8 @@ function user_delete( $p_user_id ) { user_ensure_unprotected( $p_user_id ); + event_signal( 'EVENT_MANAGE_USER_DELETE', array( $p_user_id ) ); + # Remove associated profiles user_delete_profiles( $p_user_id ); diff --git a/docbook/Developers_Guide/en-US/Events_Reference_Manage.xml b/docbook/Developers_Guide/en-US/Events_Reference_Manage.xml index cd69fb5003c..667ee35a50a 100644 --- a/docbook/Developers_Guide/en-US/Events_Reference_Manage.xml +++ b/docbook/Developers_Guide/en-US/Events_Reference_Manage.xml @@ -212,6 +212,117 @@ + +
+ EVENT_MANAGE_USER_CREATE_FORM (Execute) + +
+ + This event allows plugins to do processing or display form elements on + the Create User page. It is triggered immediately before the submit + button. + + + + Any output here should follow the format found in manage_user_create_page.php. + +
+
+ +
+ EVENT_MANAGE_USER_CREATE (Execute) + +
+ + This event allows plugins to do post-processing of newly-created + users. This event is triggered for each user created. The + Manage Users create form is one possible case for triggering + such events, but there can be other ways users can be created. + + + + Parameters + <Integer>: User ID + +
+
+ +
+ EVENT_MANAGE_USER_UPDATE_FORM (Execute) + +
+ + This event allows plugins to do processing or display form + elements in the Manage User page. It is triggered immediately + before the submit button. + + + + Any output here should follow the format found in + manage_user_edit_page.php. + + + + Parameters + <Integer>: User ID + +
+
+ +
+ EVENT_MANAGE_USER_UPDATE (Execute) + +
+ + This event allows plugins to do post-processing of modified + users. This may be triggered by the Manage User page or some + other path. + + + + Parameters + <Integer>: User ID + +
+
+ +
+ EVENT_MANAGE_USER_DELETE (Execute) + +
+ + This event allows plugins to do pre-processing of user + deletion. + + + + Parameters + <Integer>: User ID + +
+
+ +
+ EVENT_MANAGE_USER_PAGE (Execute) + +
+ + This event allows plugins to do processing or display information on + the View User page. It is triggered immediately after the reset password + segment. + + + + Any output here should be contained within its own container. + + + + Parameters + <Integer>: User ID + +
+
+ diff --git a/manage_user_create_page.php b/manage_user_create_page.php index 624354b0851..ea63c285a87 100644 --- a/manage_user_create_page.php +++ b/manage_user_create_page.php @@ -113,6 +113,9 @@ + + + diff --git a/manage_user_edit_page.php b/manage_user_edit_page.php index 9bf165824da..c6c4f701bef 100644 --- a/manage_user_edit_page.php +++ b/manage_user_edit_page.php @@ -172,6 +172,9 @@ echo ''; echo ''; } ?> + + + @@ -230,6 +233,8 @@ + +