Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 296309 Details for
Bug 427912
XMLRPC function disableAccount will be replaced with User.update()
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Bugzlla::WebService::User::update()
patch.diff (text/plain), 7.61 KB, created by
Noura El hawary
on 2008-02-29 05:46:49 UTC
(
hide
)
Description:
Bugzlla::WebService::User::update()
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-02-29 05:46:49 UTC
Size:
7.61 KB
patch
obsolete
>Index: Bugzilla/WebService/User.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/WebService/User.pm,v >retrieving revision 1.2 >diff -u -r1.2 User.pm >--- Bugzilla/WebService/User.pm 29 Feb 2008 05:03:57 -0000 1.2 >+++ Bugzilla/WebService/User.pm 29 Feb 2008 05:42:42 -0000 >@@ -114,6 +114,9 @@ > return { id => type('int')->value($user->id) }; > } > >+############ >+# User Get # >+############ > > # function to return user information by passing either user ids or > # login names or both together: >@@ -185,6 +188,92 @@ > return { users => \@users }; > } > >+############### >+# User Update # >+############### >+ >+# function to update user information by passing either user ids or >+# login name or both together. >+# $call = $rpc->call('User.update', { ids => [1,2,3], >+# names => ['testusera@redhat.com', 'testuserb@redhat.com'], >+# update => {disabled_text => 'user is disabled', email_enabled => 1} }); >+sub update { >+ my ($self, $params) = @_; >+ >+ my $user = Bugzilla->login(LOGIN_REQUIRED); >+ my $editusers = $user->in_group('editusers'); >+ >+ # Reject access if there is no sense in continuing. >+ $editusers >+ || ThrowUserError("auth_failure", {group => "editusers", >+ action => "edit", >+ object => "users"}); >+ >+ my @names = ref($params->{names}) ? @{$params->{names}} : >+ ($params->{names}); >+ >+ my @user_objects; >+ @user_objects = map { Bugzilla::User->check($_) } @names >+ if $params->{names}; >+ >+ my @ids = ref($params->{ids}) ? @{$params->{ids}} : ($params->{ids}); >+ >+ my $obj_by_ids; >+ $obj_by_ids = Bugzilla::User->new_from_list(\@ids) if $params->{ids}; >+ >+ my %unique_users; >+ map { $unique_users{$_->id} = $_ } @user_objects; >+ @user_objects = values %unique_users; >+ >+ foreach my $obj (@$obj_by_ids){ >+ push (@user_objects, $obj) if !$unique_users{$obj->id}; >+ } >+ >+ my %changes; >+ >+ my %methods = ( >+ name => 'set_login', >+ real_name => 'set_name', >+ disabled_text => 'set_disabledtext', >+ email_enabled => 'set_disable_mail', >+ ); >+ >+ my %mapped_returns = ( >+ realname => 'real_name', >+ login_name => 'name', >+ disable_mail => 'email_enabled', >+ disabledtext => 'disabled_text', >+ >+ ); >+ >+ # throw an error is user tries to update password or login for several users >+ if (scalar @user_objects > 1 && ( (grep {$_ =~ /^name$/ } keys %{$params->{update}}) || (grep {$_ =~ /password/ } keys %{$params->{update}}) )) >+ { >+ ThrowUserError("multiple_users_update_not_allowed"); >+ } >+ else{ >+ foreach my $otheruser (@user_objects){ >+ if ($editusers) { >+ foreach my $field (keys %{$params->{update}}) { >+ my $method = $methods{$field}; >+ $method ||= "set_" . $field; >+ $otheruser->$method($params->{update}{$field}); >+ } >+ } >+ } >+ foreach my $otheruser (@user_objects){ >+ my $returned_changes = $otheruser->update(); >+ foreach my $changed_field (keys %{$returned_changes}){ >+ my $mapped_field = $mapped_returns{$changed_field} >+ || $changed_field; >+ $changes{$otheruser->id}{$mapped_field} = $returned_changes->{$changed_field}; >+ } >+ } >+ } >+ >+ return { users_updates => \%changes }; >+} >+ > 1; > > __END__ >@@ -471,3 +560,115 @@ > =back > > =back >+ >+=head2 Update Accounts >+ >+=over >+ >+=item C<update> B<UNSTABLE> >+ >+=over >+ >+=item B<Description> >+ >+Updates user accounts in Bugzilla. >+ >+=item B<Params> >+ >+=over >+ >+=item C<ids> (array) B<Optional> - An array of integers, representing user ids. >+ >+=item C<names> (array) B<Optional> - An array of login names (strings). >+ >+=item C<update> (hash) B<Required> - A hash containing user account fields >+and the new values it will be updated to. The hash may contain any of the following: >+ >+=over >+ >+=item real_name >+ >+C<string> The actual name of the user. >+ >+=item name >+ >+C<string> The login name of the user. Note that in some situations this is >+different than their email. Also note that you can only do single >+user update when passing name in the update hash. >+ >+=item password >+ >+C<string> The password of the user. Note that you can only do single >+user update when passing password in the update hash. >+ >+=item email_enabled >+ >+C<boolean> A boolean value to enable/disable sending bug-related mail to the user. >+ >+=item disabled_text >+ >+C<string> A text field that holds the reason for disabling a user from logging >+into bugzilla, if empty then the user account is enabled otherwise it is >+disabled/closed. >+ >+=back >+ >+=back >+ >+=item B<Returns> >+ >+A hash containing one item, C<updated_users>, which is a hash of hashes, >+with user ids as the hash keys pointing to hashes that contains >+the changes that were made to the users accounts. The hash may contain >+any of the following: >+ >+=over >+ >+=item real_name >+ >+C<array> An array of (strings) that holds the old real name of the user and the new one. >+ >+=item name >+ >+C<array> An array of (strings) that holds the old and the new login names of the user. >+ >+=item password >+ >+C<array> An array with the Encrypted old and new passwords of the user. >+ >+=item email_enabled >+ >+C<array> An array of (booleans) values to represent the old and the new status of >+sending bug-related mail to the user wether enabled/disabled. >+ >+=item disabled_text >+ >+C<array> An array of (strings) that holds reason for disabling a user from logging >+into bugzilla, if empty then the user account is enabled otherwise it is >+disbaled/closed. >+ >+=back >+ >+=item B<Errors> >+ >+=over >+ >+=item 51 (Bad Login Name) >+ >+You passed an invalid login name in the "names" array. >+ >+=item 304 (Authorization Required) >+ >+Logged-in users are either not authorized to edit other users, or they >+can not see user's account. >+ >+=item 505 (Multiple Users Updates Not Allowed) >+ >+Can not do mass users updates for login names or user passwords. >+ >+=back >+ >+=back >+ >+=back >+ >Index: Bugzilla/WebService/Constants.pm >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/Bugzilla/WebService/Constants.pm,v >retrieving revision 1.6 >diff -u -r1.6 Constants.pm >--- Bugzilla/WebService/Constants.pm 29 Feb 2008 05:05:02 -0000 1.6 >+++ Bugzilla/WebService/Constants.pm 29 Feb 2008 05:42:56 -0000 >@@ -100,6 +100,7 @@ > # This is from strict_isolation, but it also basically means > # "invalid user." > invalid_user_group => 504, >+ multiple_users_update_not_allowed => 505, > }; > > # These are the fallback defaults for errors not in ERROR_CODE. >Index: template/en/default/global/user-error.html.tmpl >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/template/en/default/global/user-error.html.tmpl,v >retrieving revision 1.14 >diff -u -r1.14 user-error.html.tmpl >--- template/en/default/global/user-error.html.tmpl 29 Feb 2008 05:06:53 -0000 1.14 >+++ template/en/default/global/user-error.html.tmpl 29 Feb 2008 05:43:04 -0000 >@@ -1610,7 +1610,13 @@ > [% title = "User Info Access Denied" %] > Logged-out users cannot use the "ids" argument to this function > to access any user information. >- >+ >+ [% ELSIF error == "multiple_users_update_not_allowed" %] >+ [% title = "Multiple Users Updates Not Allowed" %] >+ You can not change users password or login info when changing >+ several users at once, as these values need to be unique for >+ each user. >+ > [% ELSE %] > > [%# Try to find hooked error messages %]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 427912
:
295589
|
295909
|
296211
| 296309