[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm
raeburn
raeburn at source.lon-capa.org
Tue Jan 1 14:53:26 EST 2013
raeburn Tue Jan 1 19:53:26 2013 EDT
Modified files:
/loncom/interface loncreateuser.pm loncommon.pm
Log:
- Modifying user role(s)/user information.
- &cid_to_cname() routine added to loncreateuser.pm in rev. 1.367 expanded,
and moved to loncommon.pm to facilitate re-use.
- Output appropriate role modification message where role changed is not
in a course (i.e., interface used by author or domain ccordinator).
- Display information that user information is unchanged, if no changes made.
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.371 loncom/interface/loncreateuser.pm:1.372
--- loncom/interface/loncreateuser.pm:1.371 Mon Dec 31 15:28:36 2012
+++ loncom/interface/loncreateuser.pm Tue Jan 1 19:53:26 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.371 2012/12/31 15:28:36 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.372 2013/01/01 19:53:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3062,7 +3062,7 @@
ref($newsetting) eq 'HASH' &&
ref($newsettingtext) eq 'HASH');
my %lt=&Apache::lonlocal::texthash(
- 'ui' => 'User Information (unchanged)',
+ 'ui' => 'User Information',
'uic' => 'User Information Changed',
'firstname' => 'First Name',
'middlename' => 'Middle Name',
@@ -3083,10 +3083,8 @@
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
);
- my $title = $lt{'ui'};
if ($changed) {
- $title = $lt{'uic'};
- $r->print('<h4>'.$title.'</h4>'.
+ $r->print('<h3>'.$lt{'uic'}.'</h3>'.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
$r->print("<th> </th>\n");
@@ -3145,6 +3143,9 @@
}
}
$r->print(&Apache::loncommon::end_data_table().'<br />');
+ } else {
+ $r->print('<h3>'.$lt{'ui'}.'</h3>'.
+ '<p>'.&mt('No changes made to user information').'</p>');
}
return;
}
@@ -3345,7 +3346,7 @@
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Revoking [_1] in [_2]',
&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($scope).'"'),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
$result ne "ok").'<br />');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).'<br />');
@@ -3367,7 +3368,7 @@
$env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Revoking custom role [_1] by [_2] in [_3]',
- $4,$3.':'.$2,'"'.&cid_to_cname($1).'"'),
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne 'ok').'<br />');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).'<br />');
@@ -3388,7 +3389,7 @@
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Deleting [_1] in [_2]',
&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($scope).'"'),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
$result ne 'ok').'<br />');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).'<br />');
@@ -3413,7 +3414,7 @@
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
0,1,$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"'),
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne "ok").'<br />');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).'<br />');
@@ -3442,8 +3443,10 @@
$output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($url).'"',&Apache::lonlocal::locallocaltime($now))).'<br />'.$logmsg.'<br />';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).'<br />'.$logmsg.'<br />';
}
}
} else {
@@ -3451,7 +3454,8 @@
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
$output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
- &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($url).'"'),$result ne "ok").'<br />';
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'<br />';
if ($result ne "ok") {
$output .= &mt('Error: [_1]',$result).'<br />';
}
@@ -3469,7 +3473,7 @@
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Re-enabling custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"'),
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne "ok").'<br />');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).'<br />');
@@ -3613,7 +3617,7 @@
# Flush the course logs so reverse user roles immediately updated
$r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print('<p>'.&mt('No roles to modify').'</p>');
}
return @rolechanges;
}
@@ -6976,12 +6980,7 @@
#--------------------------------- functions for &phase_two and &phase_three
#--------------------------end of functions for &phase_two and &phase_three
-sub cid_to_cname(){
- my $courseid = shift;
- $courseid =~ s/^\///;
- $courseid =~ s/\//_/;
- return $env{'course.'.$courseid.'.description'};
-}
+
1;
__END__
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1107 loncom/interface/loncommon.pm:1.1108
--- loncom/interface/loncommon.pm:1.1107 Thu Dec 27 00:00:23 2012
+++ loncom/interface/loncommon.pm Tue Jan 1 19:53:26 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1107 2012/12/27 00:00:23 raeburn Exp $
+# $Id: loncommon.pm,v 1.1108 2013/01/01 19:53:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -67,6 +67,7 @@
use Apache::loncoursedata();
use Apache::lontexconvert();
use Apache::lonclonecourse();
+use Apache::lonuserutils();
use LONCAPA qw(:DEFAULT :match);
use DateTime::TimeZone;
use DateTime::Locale::Catalog;
@@ -13317,6 +13318,26 @@
return $result;
}
+sub show_role_extent {
+ my ($scope,$context,$role) = @_;
+ $scope =~ s{^/}{};
+ my @courseroles = &Apache::lonuserutils::roles_by_context('course',1);
+ push(@courseroles,'co');
+ my @authorroles = &Apache::lonuserutils::roles_by_context('author');
+ if (($context eq 'course') || (grep(/^\Q$role\E/, at courseroles))) {
+ $scope =~ s{/}{_};
+ return '<span class="LC_cusr_emph">'.$env{'course.'.$scope.'.description'}.'</span>';
+ } elsif (($context eq 'author') || (grep(/^\Q$role\E/, at authorroles))) {
+ my ($audom,$auname) = split(/\//,$scope);
+ return &mt('[_1] Author Space','<span class="LC_cusr_emph">'.
+ &Apache::loncommon::plainname($auname,$audom).'</span>');
+ } else {
+ $scope =~ s{/$}{};
+ return &mt('Domain: [_1]','<span class="LC_cusr_emph">'.
+ &Apache::lonnet::domain($scope,'description').'</span>');
+ }
+}
+
############################################################
############################################################
More information about the LON-CAPA-cvs
mailing list