--- loncom/interface/lonuserutils.pm 2007/12/21 15:22:01 1.19 +++ loncom/interface/lonuserutils.pm 2007/12/21 17:27:57 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.19 2007/12/21 15:22:01 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.20 2007/12/21 17:27:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3810,6 +3810,61 @@ sub can_create_user { return $cancreate; } +sub can_modify_userinfo { + my ($context,$dom,$fields,$userroles) = @_; + my %domconfig = + &Apache::lonnet::get_dom('configuration',['usermodification'], + $dom); + my %canmodify; + if (ref($fields) eq 'ARRAY') { + foreach my $field (@{$fields}) { + $canmodify{$field} = 0; + if (&Apache::lonnet::allowed('mau',$dom)) { + $canmodify{$field} = 1; + } else { + if (ref($domconfig{'usermodification'}) eq 'HASH') { + if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { + if (ref($userroles) eq 'ARRAY') { + foreach my $role (@{$userroles}) { + my $testrole; + if ($role =~ /^cr\//) { + $testrole = 'cr'; + } else { + $testrole = $role; + } + if (ref($domconfig{'usermodification'}{$context}{$testrole}) eq 'HASH') { + if ($domconfig{'usermodification'}{$context}{$testrole}{$field}) { + $canmodify{$field} = 1; + last; + } + } + } + } else { + foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { + if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { + if ($domconfig{'usermodification'}{$context}{$key}{$field}) { + $canmodify{$field} = 1; + last; + } + } + } + } + } + } elsif ($context eq 'course') { + if (ref($userroles) eq 'ARRAY') { + if (grep(/^st$/,@{$userroles})) { + $canmodify{$field} = 1; + } + } else { + $canmodify{$field} = 1; + } + } + } + } + } + return %canmodify; +} + sub check_usertype { my ($dom,$uname,$rules) = @_; my $usertype;