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 314515 Details for
Bug 458870
Need to have updatePerms() ported to bz3.2
[?]
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]
v2 for webservice function bugzilla.updatePerms
updatePerms.patch (text/plain), 8.09 KB, created by
Noura El hawary
on 2008-08-19 07:37:43 UTC
(
hide
)
Description:
v2 for webservice function bugzilla.updatePerms
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-08-19 07:37:43 UTC
Size:
8.09 KB
patch
obsolete
>Index: extensions/compat_xmlrpc/code/webservice.pl >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/extensions/compat_xmlrpc/code/webservice.pl,v >retrieving revision 1.50 >diff -p -u -r1.50 webservice.pl >--- extensions/compat_xmlrpc/code/webservice.pl 19 Aug 2008 03:59:10 -0000 1.50 >+++ extensions/compat_xmlrpc/code/webservice.pl 19 Aug 2008 07:30:47 -0000 >@@ -34,6 +34,7 @@ use base qw(Bugzilla::WebService); > import SOAP::Data qw(type); > use Bugzilla; > use Bugzilla::Constants; >+use Bugzilla::Field; > use Bugzilla::WebService::Constants; > > # Basic info that is needed before logins >@@ -2344,90 +2345,112 @@ sub idToName { > } > > # Update Bugzilla permissions >-#sub updatePerms { >-# shift if $_[0] eq 'bugzilla'; >-# my ( $user, $cmd, $groups, $username, $password ) = @_; >-# my $return = ""; >-# my $userid = 0; >-# >-# if ( !$user || !$cmd || !$username || !$password ) { >-# ThrowUserError('perms_data_missing'); >-# } >-# >-# Bugzilla->login( RPC_AUTH_TYPE, $username, $password ); >-# >-# $logger->debug("Starting: $user, $cmd, $groups, $username"); >-# >-# $userid = $::userid; >-# >-# if ( !&::UserInGroup( 'editusers', $userid ) ) { >-# ThrowUserError('permission_denied'); >-# } >-# >-# # Return if user does not exist >-# my $uid = &::DBname_to_id($user); >-# if ( !$uid ) { >-# ThrowUserError('non_existing_user'); >-# } >-# >-# my @added; >-# my @removed; >-# foreach my $group ( @{$groups} ) { >-# my $query >-# = "SELECT id FROM groups WHERE name = " . &::SqlQuote($group); >-# &::SendSQL($query); >-# my $groupid = &::FetchOneColumn(); >-# next if !$groupid; >-# >-# if ( $cmd =~ 'add' ) { >-# my $query >-# = "SELECT group_id FROM user_group_map WHERE user_id = $uid " >-# . "AND group_id = $groupid AND isbless = 0"; >-# &::SendSQL($query); >-# my $result = &::FetchOneColumn(); >-# if ( !$result ) { >-# $query >-# = "INSERT INTO user_group_map (user_id,group_id,isbless,grant_type) " >-# . "VALUES ($uid,$groupid,0," . GRANT_DIRECT . ")"; >-# &::SendSQL($query); >-# } >-# push( @added, $group ); >-# } >-# if ( $cmd =~ 'rem' ) { >-# my $query >-# = "SELECT group_id FROM user_group_map WHERE user_id = $uid " >-# . "AND group_id = $groupid AND isbless = 0 AND grant_type = " . GRANT_DIRECT; >-# &::SendSQL($query); >-# my $result = &::FetchOneColumn(); >-# if ($result) { >-# $query = "DELETE FROM user_group_map WHERE user_id = $uid " >-# . "AND group_id = $groupid AND isbless = 0 AND grant_type = " . GRANT_DIRECT; >-# &::SendSQL($query); >-# } >-# push( @removed, $group ); >-# } >-# } >-# >-# my %groups; >-# my $query = " >-# SELECT >-# groups.name, groups.description >-# FROM >-# groups JOIN user_group_map ON groups.id = user_group_map.group_id >-# WHERE >-# user_group_map.user_id = $uid >-# AND isbless = 0"; >-# &::SendSQL($query); >-# while ( my @row = &::FetchSQLData() ) { >-# $groups{ $row[0] } = $row[1]; >-# } >-# >-# # Go ahead and derive their group permissions >-# my $changeduser = Bugzilla::User->new_from_login($user); >-# $changeduser->derive_groups(); >-# >-# return \%groups; >-#} >+sub updatePerms { >+ my ($self, $user, $cmd, $groups, $username, $password ) = @_; >+ >+ $user || ThrowCodeError('param_required', { param => 'user' }); >+ $cmd || ThrowCodeError('param_required', { param => 'command' }); >+ >+ if ($cmd ne 'add' && $cmd ne 'rem') { >+ ThrowUserError('invalid_update_perms_action'); >+ } >+ >+ # Try to login if $username and $password provided. >+ xmlrpc_client_login($username, $password, LOGIN_REQUIRED); >+ >+ $logger->debug("Starting: $user, $cmd, $groups, $username"); >+ >+ my $userid = Bugzilla->user->id; >+ my $editusers = Bugzilla->user->in_group('editusers'); >+ >+ # Reject access if there is no sense in continuing. >+ $editusers >+ || Bugzilla->user->can_bless() >+ || ThrowUserError("auth_failure", {group => "editusers", >+ reason => "cant_bless", >+ action => "edit", >+ object => "users"}); >+ >+ # Return if user does not exist >+ my $uid = Bugzilla::User::login_to_id($user); >+ my $dbh = Bugzilla->dbh; >+ >+ # Lock tables during the checkupdate session. >+ $dbh->bz_start_transaction(); >+ >+ my @groupsAddedTo; >+ my @groupsRemovedFrom; >+ >+ foreach my $group ( @{$groups} ) { >+ my $sth = $dbh->prepare("SELECT id FROM groups WHERE name = " . $dbh->quote($group)); >+ $sth->execute(); >+ my $groupid = $sth->fetchrow; >+ next if ((!$groupid) || (!Bugzilla->user->can_bless($groupid))); >+ >+ if ( $cmd =~ 'add' ) { >+ my $sth2 = >+ $dbh->prepare("SELECT group_id FROM user_group_map WHERE user_id = $uid " >+ . "AND group_id = $groupid AND isbless = 0"); >+ $sth2->execute(); >+ my $result = $sth2->fetchrow; >+ if ( !$result ) { >+ $dbh->do("INSERT INTO user_group_map (user_id,group_id,isbless,grant_type) " >+ . "VALUES ($uid,$groupid,0," . GRANT_DIRECT . ")"); >+ push(@groupsAddedTo, $group); >+ } >+ } >+ if ( $cmd =~ 'rem' ) { >+ my $sth3 = >+ $dbh->prepare("SELECT group_id FROM user_group_map WHERE user_id = $uid " >+ . "AND group_id = $groupid AND isbless = 0 AND grant_type = " . GRANT_DIRECT); >+ $sth3->execute(); >+ my $result = $sth3->fetchrow; >+ if ($result) { >+ $dbh->do("DELETE FROM user_group_map WHERE user_id = $uid " >+ . "AND group_id = $groupid AND isbless = 0 AND grant_type = " . GRANT_DIRECT); >+ push(@groupsRemovedFrom, $group); >+ } >+ } >+ } >+ >+ if (@groupsAddedTo || @groupsRemovedFrom) { >+ $dbh->do(qq{INSERT INTO profiles_activity ( >+ userid, who, >+ profiles_when, fieldid, >+ oldvalue, newvalue >+ ) VALUES ( >+ ?, ?, now(), ?, ?, ? >+ ) >+ }, >+ undef, >+ ($uid, $userid, >+ get_field_id('bug_group'), >+ join(', ', @groupsRemovedFrom), join(', ', @groupsAddedTo))); >+ } >+ >+ >+ my %groups; >+ my $query = " >+ SELECT >+ groups.name, groups.description >+ FROM >+ groups JOIN user_group_map ON groups.id = user_group_map.group_id >+ WHERE >+ user_group_map.user_id = $uid >+ AND isbless = 0"; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(); >+ while ( my @row = $sth->fetchrow) { >+ $groups{ $row[0] } = $row[1]; >+ } >+ >+ my $changeduser = Bugzilla::User->new($uid); >+ $changeduser->derive_regexp_groups; >+ >+ $dbh->bz_commit_transaction(); >+ >+ return \%groups; >+} > > # Create new bugzilla user > sub addUser { >Index: extensions/compat_xmlrpc/template/en/global/user-error-errors.html.tmpl >=================================================================== >RCS file: /cvs/qa/rh_bugzilla_3/extensions/compat_xmlrpc/template/en/global/user-error-errors.html.tmpl,v >retrieving revision 1.1 >diff -p -u -r1.1 user-error-errors.html.tmpl >--- extensions/compat_xmlrpc/template/en/global/user-error-errors.html.tmpl 13 Mar 2008 15:26:54 -0000 1.1 >+++ extensions/compat_xmlrpc/template/en/global/user-error-errors.html.tmpl 19 Aug 2008 07:30:58 -0000 >@@ -1,4 +1,8 @@ > [% IF error == "update_flags_invalid_flag_name" %] > [% title = "Invalid or No Flag Name Provided" %] > No data given for change or flag name invalid. >+[% ELSIF error == "invalid_update_perms_action" %] >+ [% title = "Invalid Action" %] >+ The action you specified is invalid. Valid actions >+ are 'add' and 'rem'. > [% END %]
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
Flags:
dkl
: review+
Actions:
View
|
Diff
Attachments on
bug 458870
:
314372
| 314515