--- loncom/interface/loncreateuser.pm 2009/08/27 13:00:59 1.310
+++ loncom/interface/loncreateuser.pm 2009/12/15 16:40:31 1.330
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.310 2009/08/27 13:00:59 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.330 2009/12/15 16:40:31 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,13 +51,14 @@ In LON-CAPA, roles are actually collecti
Assistant", "Course Coordinator", and other such roles are really just
collection of privileges that are useful in many circumstances.
-Creating custom roles can be done by the Domain Coordinator through
-the Create User functionality. That screen will show all privileges
-that can be assigned to users. For a complete list of privileges,
-please see C.
+Custom roles can be defined by a Domain Coordinator, Course Coordinator
+or Community Coordinator via the Manage User functionality.
+The custom role editor screen will show all privileges which can be
+assigned to users. For a complete list of privileges, please see
+C.
-Custom role definitions are stored in the C ';
- if (($curr{'page'} > 1) || ($more_records)) {
- if ($curr{'page'} > 1) {
- $nav_links .= ' ';
- }
- if ($more_records) {
- $nav_links .= '';
+ # Navigation Buttons
+ $nav_links = ' ';
+ if (($curr->{'page'} > 1) || ($more_records)) {
+ if ($curr->{'page'} > 1) {
+ $nav_links .= ' ';
+ }
+ if ($more_records) {
+ $nav_links .= '';
+ }
}
+ $nav_links .= '
'.
+ $reqtitles{'unlimited'};
+ } else {
+ $custdisp .= '';
}
- $custdisp .= '';
+ $custdisp .= '';
}
$custdisp .= '';
$custradio = ''.&mt('Custom setting').'
'.$custdisp;
} else {
$currdisp = ($curr_access?&mt('Yes'):&mt('No'));
$custdisp = ' ';
@@ -379,22 +388,27 @@ sub coursereq_externaluser {
my ($curroption,$currlimit,$tooloff);
if ($userenv{'reqcrsotherdom.'.$item} ne '') {
my @curr = split(',',$userenv{'reqcrsotherdom.'.$item});
- if (grep(/^\Q$cdom\E:($optregex)=?(\d*)$/,@curr)) {
- $curroption = $1;
- $currlimit = $2;
- if (!$curroption) {
- $curroption = 'norequest';
+ foreach my $req (@curr) {
+ if ($req =~ /^\Q$cdom\E\:($optregex)=?(\d*)$/) {
+ $curroption = $1;
+ $currlimit = $2;
+ last;
}
}
+ if (!$curroption) {
+ $curroption = 'norequest';
+ $tooloff = ' checked="checked"';
+ }
} else {
$curroption = 'norequest';
$tooloff = ' checked="checked"';
}
$output.= &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{$item}.': '.
+ ' '.$lt{$item}.': '.
+ ' '."\n".
&Apache::loncommon::end_data_table_row()."\n";
}
return $output;
@@ -435,6 +452,7 @@ sub courserequest_titles {
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
autolimit => 'Numerical limit',
+ unlimited => '(blank for unlimited)',
);
return %titles;
}
@@ -451,7 +469,7 @@ sub courserequest_display {
# =================================================================== Phase one
sub print_username_entry_form {
- my ($r,$context,$response,$srch,$forcenewuser) = @_;
+ my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -470,10 +488,15 @@ sub print_username_entry_form {
'// ]]>'."\n".
''."\n";
+ my %existingroles=&Apache::lonuserutils::my_custom_roles($crstype);
+ if (($env{'form.action'} eq 'custom') && (keys(%existingroles) > 0)
+ && (&Apache::lonnet::allowed('mcr','/'))) {
+ $jscript .= &customrole_javascript();
+ }
my %loaditems = (
'onload' => "javascript:setFormElements(document.$formtoset)",
);
- my %breadcrumb_text = &singleuser_breadcrumb();
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype);
my $start_page =
&Apache::loncommon::start_page('User Management',
$jscript,{'add_entries' => \%loaditems,});
@@ -495,48 +518,112 @@ sub print_username_entry_form {
}
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
$helpitem);
- my %existingroles=&Apache::lonuserutils::my_custom_roles();
- my $choice=&Apache::loncommon::select_form('make new role','rolename',
- ('make new role' => 'Generate new role ...',%existingroles));
my %lt=&Apache::lonlocal::texthash(
'srst' => 'Search for a user and enroll as a student',
+ 'srme' => 'Search for a user and enroll as a member',
'srad' => 'Search for a user and modify/add user information or roles',
'usr' => "Username",
'dom' => "Domain",
- 'ecrp' => "Edit Custom Role Privileges",
- 'nr' => "Name of Role",
+ 'ecrp' => "Define or Edit Custom Role",
+ 'nr' => "role name",
'cre' => "Next",
);
$r->print($start_page."\n".$crumbs);
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
- $r->print(<'."\n".
' ';
+ '" value=""'.$tooloff.' />'.$reqtitles{'norequest'}.
+ ' ';
foreach my $option (@options) {
if ($option eq 'validate') {
my $canvalidate = 0;
@@ -409,18 +423,21 @@ sub coursereq_externaluser {
if ($option eq $curroption) {
$checked = ' checked="checked"';
}
- $output .= ''."\n".
+ $output .= '$lt{'ecrp'}
-$choice $lt{'nr'}:
-
-
-ENDCUSTOM
+ my $newroletext = &mt('Define new custom role:');
+ $r->print('');
}
} else {
my $actiontext = $lt{'srad'};
if ($env{'form.action'} eq 'singlestudent') {
- $actiontext = $lt{'srst'};
+ if ($crstype eq 'Community') {
+ $actiontext = $lt{'srme'};
+ } else {
+ $actiontext = $lt{'srst'};
+ }
}
- $r->print("
-$actiontext
");
+ $r->print("$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
- $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response));
+ $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
}
$r->print(&Apache::loncommon::end_page());
}
+sub customrole_javascript {
+ my $js = <<"END";
+
+END
+ return $js;
+}
+
sub entry_form {
- my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
+ my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
@@ -576,6 +663,7 @@ ENDBLOCK
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
'enro' => 'Enroll one student',
+ 'enrm' => 'Enroll one member',
'admo' => 'Add/modify a single user',
'crea' => 'create new user if required',
'uskn' => "username is known",
@@ -587,8 +675,12 @@ ENDBLOCK
);
my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
my ($title,$buttontext,$showresponse);
- if ($env{'form.action'} eq 'singlestudent') {
- $title = $lt{'enro'};
+ if ($env{'form.action'} eq 'singlestudent') {
+ if ($crstype eq 'Community') {
+ $title = $lt{'enrm'};
+ } else {
+ $title = $lt{'enro'};
+ }
$buttontext = $lt{'enrl'};
} else {
$title = $lt{'admo'};
@@ -635,6 +727,7 @@ sub user_modification_js {
return <
");
- $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
+ $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype));
$r->print(''.$lt{'usel'}.'
');
} elsif ($env{'form.action'} eq 'singlestudent') {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
'Course_Add_Student'));
- $r->print($jscript."$lt{'stusrch'}
");
- $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
- $r->print(''.$lt{'stusel'}.'
');
+ $r->print($jscript."");
+ if ($crstype eq 'Community') {
+ $r->print($lt{'memsrch'});
+ } else {
+ $r->print($lt{'stusrch'});
+ }
+ $r->print("
");
+ $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype));
+ $r->print('');
+ if ($crstype eq 'Community') {
+ $r->print($lt{'memsel'});
+ } else {
+ $r->print($lt{'stusel'});
+ }
+ $r->print('
');
}
}
$r->print('');
+ return;
+}
- # Create Navigation:
- # Navigation Script
- my $nav_script = <<"ENDSCRIPT";
+sub userlogdisplay_nav {
+ my ($formname,$curr,$more_records) = @_;
+ my ($nav_script,$nav_links);
+ if (ref($curr) eq 'HASH') {
+ # Create Navigation:
+ # Navigation Script
+ $nav_script = <<"ENDSCRIPT";
ENDSCRIPT
- # Navigation Buttons
- my $nav_links;
- $nav_links = '
'.
''.&mt('Changes/page:').' '. @@ -5081,7 +5455,7 @@ sub role_display_filter { &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date', $curr->{'rolelog_end_date'},undef, undef,undef,undef,undef,undef,undef,$nolink); - my %lt = &rolechg_contexts(); + my %lt = &rolechg_contexts($crstype); $output .= ' | '.&mt('Window during which changes occurred:').' '. '
| ';
$otheritems .= <$lt{'ssd'} |
-+ | $lt{'sed'} |
ENDTIMEENTRY
@@ -6183,6 +6574,21 @@ sub get_selfenroll_titles {
return (\@row,\%lt);
}
+sub is_courseowner {
+ my ($thiscourse,$courseowner) = @_;
+ if ($courseowner eq '') {
+ if ($env{'request.course.id'} eq $thiscourse) {
+ $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
+ }
+ }
+ if ($courseowner ne '') {
+ if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) {
+ return 1;
+ }
+ }
+ return;
+}
+
#---------------------------------------------- end functions for &phase_two
#--------------------------------- functions for &phase_two and &phase_three