Commit 8afe2070 authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic
Browse files

Bug 1774554: Throw WebserviceInvalidParameterException error



Instead of the MaharaException when doing user delete via webservices

behatnotneeded

Change-Id: I71db2ab3a3552918992a66310cdc3244f8d7c3a1
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 7c8f5f5b)
parent 80a04af0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -391,3 +391,5 @@ $string['membersinvalidaction'] = 'invalid action "%s" for user "%s" on group "%
$string['passwordmustbechangedviawebsite'] = 'You need to change your password. Please log in via a web browser in order to update your password.';
$string['featuredisabled'] = 'This web services feature is not enabled. Please contact your site administrator for more information.';
$string['institutionunknown'] = '- unknown -';
$string['unabletodeleteadmin'] = 'Unable to delete user with ID: "%s" as they are an admin';
$string['notuserblog'] = 'The journal is not owned by "%s"';
+6 −4
Original line number Diff line number Diff line
@@ -397,6 +397,10 @@ class mahara_user_external extends external_api {
                throw new WebserviceInvalidParameterException('delete_users | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $user->id));
            }

            if ($USER->get('id') == $user->id) {
                throw new WebserviceInvalidParameterException('delete_users | ' . get_string('unabletodeleteself1', 'admin'));
            }

            // only allow deletion of users that have not signed in
            if (!empty($user->lastlogin) && !$user->suspendedcusr) {
                throw new WebserviceInvalidParameterException('delete_users | ' . get_string('cannotdeleteaccount', 'auth.webservice', $user->id));
@@ -404,11 +408,9 @@ class mahara_user_external extends external_api {

            // must not allow deleting of admins or self!!!
            if ($user->admin) {
                throw new MaharaException('useradminodelete', 'error');
            }
            if ($USER->get('id') == $user->id) {
                throw new MaharaException('usernotdeletederror', 'error');
                throw new WebserviceInvalidParameterException('delete_users | ' . get_string('unabletodeleteadmin', 'auth.webservice', $user->id));
            }

            delete_user($user->id);
        }
        db_commit();