--- loncom/interface/loncreateuser.pm 2009/08/14 17:09:38 1.295.2.8
+++ loncom/interface/loncreateuser.pm 2010/09/08 02:16:07 1.347
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.295.2.8 2009/08/14 17:09:38 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.347 2010/09/08 02:16:07 raeburn 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
'.
+ $reqtitles{'unlimited'};
+ } else {
+ $custdisp .= '';
}
- $custdisp .= '';
+ $custdisp .= '';
}
$custdisp .= '';
$custradio = ''.&mt('Custom setting').'
'.$custdisp;
@@ -369,7 +390,7 @@ sub coursereq_externaluser {
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
'reqcrsotherdom.community');
@usertools = ('official','unofficial','community');
- @options = ('approve','validate','autolimit');
+ @options = ('approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($cdom);
my $optregex = join('|',@options);
my %reqtitles = &courserequest_titles();
@@ -377,22 +398,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;
@@ -430,26 +459,27 @@ sub courserequest_titles {
unofficial => 'Unofficial',
community => 'Communities',
norequest => 'Not allowed',
- approve => 'Approval by Dom. Coord.',
+ approval => 'Approval by Dom. Coord.',
validate => 'With validation',
autolimit => 'Numerical limit',
+ unlimited => '(blank for unlimited)',
);
- return %titles;
-}
-
+ return %titles;
+}
+
sub courserequest_display {
my %titles = &Apache::lonlocal::texthash (
- approve => 'Yes, need approval',
+ approval => 'Yes, need approval',
validate => 'Yes, with validation',
norequest => 'No',
- );
+ );
return %titles;
}
# =================================================================== 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'})) {
@@ -468,10 +498,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,});
@@ -493,48 +528,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;
@@ -407,18 +433,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') {
@@ -574,6 +673,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",
@@ -585,8 +685,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'};
@@ -657,7 +761,7 @@ END
# =================================================================== Phase two
sub print_user_selection_page {
- my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements) = @_;
+ my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype) = @_;
my @fields = ('username','domain','lastname','firstname','permanentemail');
my $sortby = $env{'form.sortby'};
@@ -685,8 +789,10 @@ ENDSCRIPT
my %lt=&Apache::lonlocal::texthash(
'usrch' => "User Search to add/modify roles",
'stusrch' => "User Search to enroll student",
+ 'memsrch' => "User Search to enroll member",
'usel' => "Select a user to add/modify roles",
- 'stusel' => "Select a user to enroll as a student",
+ 'stusel' => "Select a user to enroll as a student",
+ 'memsel' => "Select a user to enroll as a member",
'username' => "username",
'domain' => "domain",
'lastname' => "last name",
@@ -698,7 +804,7 @@ ENDSCRIPT
} else {
$r->print(&Apache::loncommon::start_page('User Management',$jscript));
- my %breadcrumb_text = &singleuser_breadcrumb();
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype);
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.usersrchform,'','')",
text=>$breadcrumb_text{'search'},
@@ -708,16 +814,28 @@ ENDSCRIPT
faq=>282,bug=>'Instructor Interface',});
if ($env{'form.action'} eq 'singleuser') {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
- 'Course_Change_Privileges'));
+ 'Course_Change_Privileges'));
$r->print("$lt{'usrch'}
");
- $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'}.'
');
+ 'Course_Add_Student'));
+ $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('
'.
''.&mt('Changes/page:').' '. @@ -4982,23 +5469,27 @@ 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(); - $output .= ' | '.&mt('Window during which changes occurred:').'
| '. + my %lt = &rolechg_contexts($crstype); + $output .= ' | '.&mt('Window during which changes occurred:').' '. + '
| '.
+ ''. ' | '.&mt('Role:').' '. ' | '. + $output .= ' | '. + ''. + ' | '.
&mt('Context:').' | '."\n".
' '.$plrole.' | '."\n". ''.$area.' Domain: '.$domain.' | '."\n";
- if ($role eq 'cc') {
+ if (($role eq 'cc') || ($role eq 'co')) {
$row .= ''; } elsif ($env{'request.course.sec'} ne '') { $row .= ' | '.
'';
my $courseform=''.&Apache::loncommon::selectcourse_link
- ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'';
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu');
+ ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course/Community','crstype').'';
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser');
my %lt=&Apache::lonlocal::texthash(
'rol' => "Role",
'grs' => "Section",
@@ -5669,14 +6187,14 @@ sub course_level_dc {
'ssd' => "Set Start Date",
'sed' => "Set End Date"
);
- my $header = ''.&mt('Course Level').''. + my $header = ''.&mt('Course/Community Level').''. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ' | '.$courseform.' | '.$lt{'rol'}.' | '.$lt{'grs'}.' | '.$lt{'sta'}.' | '.$lt{'end'}.' | '. &Apache::loncommon::end_data_table_header_row(); my $otheritems = &Apache::loncommon::start_data_table_row()."\n". - ''."\n". - ' |
---|