version 1.269.2.14, 2013/09/21 23:42:59
|
version 1.269.2.19, 2014/05/05 11:44:18
|
Line 294 sub handler {
|
Line 294 sub handler {
|
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
# Check if user is a DC trying to enter a course or author space and needs privs to be created |
if ($numdc > 0) { |
if ($numdc > 0) { |
foreach my $envkey (keys %env) { |
foreach my $envkey (keys(%env)) { |
# Is this an ad-hoc Coordinator role? |
# Is this an ad-hoc Coordinator role? |
if (my ($ccrole,$domain,$coursenum) = |
if (my ($ccrole,$domain,$coursenum) = |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { |
Line 364 sub handler {
|
Line 364 sub handler {
|
} |
} |
} |
} |
|
|
foreach $envkey (keys %env) { |
foreach $envkey (keys(%env)) { |
next if ($envkey!~/^user\.role\./); |
next if ($envkey!~/^user\.role\./); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
my ($where,$trolecode,$role,$tstatus,$tend,$tstart); |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, |
Line 551 ENDENTERKEY
|
Line 551 ENDENTERKEY
|
} |
} |
} |
} |
if (($env{'form.orgurl'}) && |
if (($env{'form.orgurl'}) && |
($env{'form.orgurl'}!~/^\/adm\/flip/)) { |
($env{'form.orgurl'}!~/^\/adm\/flip/) && |
|
($env{'form.orgurl'} ne '/adm/roles')) { |
my $dest=$env{'form.orgurl'}; |
my $dest=$env{'form.orgurl'}; |
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
if ($dest =~ /\?/) { |
if ($dest =~ /\?/) { |
$dest .= '&'; |
$dest .= '&'; |
} else { |
} else { |
$dest .= '?' |
$dest .= '?'; |
} |
} |
$dest .= 'symb='.$env{'form.symb'}; |
$dest .= 'symb='.$env{'form.symb'}; |
} |
} |
Line 596 ENDENTERKEY
|
Line 597 ENDENTERKEY
|
} else { |
} else { |
# Check to see if the user is a CC entering a course |
# Check to see if the user is a CC entering a course |
# for the first time |
# for the first time |
my (undef, undef, $role, $courseid) = split(/\./, $envkey); |
|
if (substr($courseid, 0, 1) eq '/') { |
|
$courseid = substr($courseid, 1); |
|
} |
|
$courseid =~ s/\//_/; |
|
if ((($role eq 'cc') || ($role eq 'co')) |
if ((($role eq 'cc') || ($role eq 'co')) |
&& ($env{'course.' . $courseid .'.course.helper.not.run'})) { |
&& ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) { |
$furl = "/adm/helper/course.initialization.helper"; |
$furl = "/adm/helper/course.initialization.helper"; |
# Send the user to the course they selected |
# Send the user to the course they selected |
} elsif ($env{'request.course.id'}) { |
} elsif ($env{'request.course.id'}) { |
Line 654 ENDENTERKEY
|
Line 650 ENDENTERKEY
|
} |
} |
} |
} |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$env{'request.course.id'}.'.description'}), |
$dest, $msg); |
$dest, $msg); |
return OK; |
return OK; |
} |
} |
Line 664 ENDENTERKEY
|
Line 660 ENDENTERKEY
|
$env{'request.course.id'}.'/' |
$env{'request.course.id'}.'/' |
.$env{'request.course.sec'}) |
.$env{'request.course.sec'}) |
) { |
) { |
my $startpage = &courseloadpage($courseid); |
my $startpage = &courseloadpage($env{'request.course.id'}); |
unless ($startpage eq 'firstres') { |
unless ($startpage eq 'firstres') { |
$msg = &mt('Entering [_1] ...', |
$msg = &mt('Entering [_1] ...', |
$env{'course.'.$courseid.'.description'}); |
$env{'course.'.$env{'request.course.id'}.'.description'}); |
&redirect_user($r, &mt('New in course'), |
&redirect_user($r, &mt('New in course'), |
'/adm/whatsnew?refpage=start', $msg); |
'/adm/whatsnew?refpage=start', $msg); |
return OK; |
return OK; |
} |
} |
} |
} |
} |
} |
# Are we allowed to look at the first resource? |
# Are we allowed to look at the first resource? |
if ($furl !~ m|^/adm/|) { |
if ($furl =~ m{^(/adm/wrapper|)/ext/}) { |
# Guess not ... |
# If it's an external resource, |
$furl=&Apache::lonpageflip::first_accessible_resource(); |
# strip off the symb argument and possible query |
} |
my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$}); |
|
# Unencode $symb |
|
$symb = &unescape($symb); |
|
# Then check for permission |
|
if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
} |
|
# For other resources just check for permission |
|
} elsif (!&Apache::lonnet::allowed('bre',$furl)) { |
|
$furl = &Apache::lonpageflip::first_accessible_resource(); |
|
} |
|
|
$msg = &mt('Entering [_1] ...', |
$msg = &mt('Entering [_1] ...', |
$env{'course.'.$courseid.'.description'}); |
$env{'course.'.$cdom.'_'.$cnum.'.description'}); |
&redirect_user($r, &mt('Entering [_1]', |
&redirect_user($r, &mt('Entering [_1]', |
$env{'course.'.$courseid.'.description'}), |
$env{'course.'.$cdom.'_'.$cnum.'.description'}), |
$furl, $msg); |
$furl, $msg); |
} |
} |
return OK; |
return OK; |
Line 745 ENDENTERKEY
|
Line 752 ENDENTERKEY
|
|
|
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); |
my $funcs = &get_roles_functions($showcount); |
my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
|
my $cattype = 'std'; |
|
if ($domdefs{'catauth'}) { |
|
$cattype = $domdefs{'catauth'}; |
|
} |
|
my $funcs = &get_roles_functions($showcount,$cattype); |
$standby=~s/\n/\\n/g; |
$standby=~s/\n/\\n/g; |
my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />'; |
my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />'; |
|
|
Line 888 ENDHEADER
|
Line 900 ENDHEADER
|
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev); |
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev); |
$refresh = $now; |
$refresh = $now; |
&Apache::lonnet::appenv({'user.refresh.time' => $refresh}); |
&Apache::lonnet::appenv({'user.refresh.time' => $refresh}); |
unless ($env{'user.adv'}) { |
if ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'})) { |
if ($countactive > 0) { |
if ($countactive > 0) { |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print( |
$r->print( |
'<p>' |
'<p>' |
.&mt('[_1]Visit the [_2]Course/Community Catalog[_3]' |
.&mt('[_1]Visit the [_2]Course/Community Catalog[_3][_4]' |
.' to view all [_4] LON-CAPA courses and communities.' |
.' to view all [_5] LON-CAPA courses and communities.' |
,'<b>' |
,'<b>' |
,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">' |
,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">' |
,'</a></b>',$domdesc) |
,'</a>' |
|
,'</b>' |
|
,'"'.$domdesc.'"') |
.'<br />' |
.'<br />' |
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,' |
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,' |
.' you may be able to enroll if self-enrollment is permitted.' |
.' you may be able to enroll if self-enrollment is permitted.' |
Line 915 ENDHEADER
|
Line 929 ENDHEADER
|
} else { |
} else { |
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
$r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>'); |
} |
} |
&findcourse_advice($r); |
&requestcourse_advice($r,$cattype); |
&requestcourse_advice($r); |
|
$r->print('</form>'); |
$r->print('</form>'); |
if ($countfuture) { |
if ($countfuture) { |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); |
Line 1145 sub gather_roles {
|
Line 1158 sub gather_roles {
|
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
if ($tremark) { $tremark.='<br />'; } |
if ($tremark) { $tremark.='<br />'; } |
$tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
$tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my $ttype; |
my $ttype; |
Line 1404 sub print_rolerows {
|
Line 1417 sub print_rolerows {
|
} |
} |
|
|
sub findcourse_advice { |
sub findcourse_advice { |
my ($r) = @_; |
my ($r,$cattype) = @_; |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { |
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { |
Line 1419 sub findcourse_advice {
|
Line 1432 sub findcourse_advice {
|
} else { |
} else { |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />'); |
} |
} |
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'. |
if (($cattype eq 'std') || ($cattype eq 'domonly')) { |
'<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />'); |
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'. |
$r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'. |
'<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />'); |
&Apache::loncoursequeueadmin::queued_selfenrollment()); |
$r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'. |
|
&Apache::loncoursequeueadmin::queued_selfenrollment()); |
|
} |
return; |
return; |
} |
} |
|
|
sub requestcourse_advice { |
sub requestcourse_advice { |
my ($r) = @_; |
my ($r,$cattype) = @_; |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my (%can_request,%request_doms); |
my (%can_request,%request_doms); |
Line 1475 sub requestcourse_advice {
|
Line 1490 sub requestcourse_advice {
|
} |
} |
$r->print('</ul>'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','<a href="'.$requrl.'">','</a>').'</p>'); |
$r->print('</ul>'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','<a href="'.$requrl.'">','</a>').'</p>'); |
} |
} |
|
} elsif (!$env{'user.adv'}) { |
|
&findcourse_advice($r,$cattype); |
} |
} |
return; |
return; |
} |
} |
Line 1607 sub build_roletext {
|
Line 1624 sub build_roletext {
|
return ($roletext,$roletext_end); |
return ($roletext,$roletext_end); |
} |
} |
|
|
sub check_needs_switchserver { |
|
my ($possiblerole) = @_; |
|
my $needs_switchserver; |
|
my ($role,$where) = split(/\./,$possiblerole,2); |
|
my (undef,$tdom,$twho) = split(/\//,$where); |
|
my ($server_status,$home); |
|
if (($role eq 'ca') || ($role eq 'aa')) { |
|
($server_status,$home) = &check_author_homeserver($twho,$tdom); |
|
} else { |
|
($server_status,$home) = &check_author_homeserver($env{'user.name'}, |
|
$env{'user.domain'}); |
|
} |
|
if ($server_status eq 'switchserver') { |
|
$needs_switchserver = 1; |
|
} |
|
return $needs_switchserver; |
|
} |
|
|
|
sub check_author_homeserver { |
sub check_author_homeserver { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
if (($uname eq '') || ($udom eq '')) { |
if (($uname eq '') || ($udom eq '')) { |
Line 1690 sub adhoc_course_role {
|
Line 1689 sub adhoc_course_role {
|
} |
} |
} |
} |
if ($setprivs) { |
if ($setprivs) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)(.*?)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
my $role = $1; |
my $role = $1; |
my $custom_role = $2; |
my $custom_role = $2; |
my $usec = $3; |
my $usec = $3; |
Line 1765 sub check_release_required {
|
Line 1764 sub check_release_required {
|
my $otherserver; |
my $otherserver; |
if (($major eq '' && $minor eq '') || |
if (($major eq '' && $minor eq '') || |
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'}); |
my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required,1); |
my $switchlcrev = |
my $switchlcrev = |
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
&Apache::lonnet::get_server_loncaparev($env{'user.domain'}, |
$userdomserver); |
$userdomserver); |
Line 1774 sub check_release_required {
|
Line 1773 sub check_release_required {
|
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) { |
my $cdom = $env{'course.'.$tcourseid.'.domain'}; |
my $cdom = $env{'course.'.$tcourseid.'.domain'}; |
if ($cdom ne $env{'user.domain'}) { |
if ($cdom ne $env{'user.domain'}) { |
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom); |
my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
Line 2236 sub update_session_roles {
|
Line 2235 sub update_session_roles {
|
my $status_in_env = |
my $status_in_env = |
&curr_role_status($currstart,$currend,$refresh,$update); |
&curr_role_status($currstart,$currend,$refresh,$update); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/); |
my ($role,$rest)=split(/\./,$rolekey,2); |
my ($role,$rest)=split(m{\./},$rolekey,2); |
|
$rest = '/'.$rest; |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if (&Apache::lonnet::delenv($envkey,undef,[$role])) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'gr') { |
if ($role eq 'gr') { |
Line 2472 sub update_session_roles {
|
Line 2472 sub update_session_roles {
|
if ($desc) { |
if ($desc) { |
$newmsg .= '<li>'. |
$newmsg .= '<li>'. |
&mt('[_1] with status: [_2].', |
&mt('[_1] with status: [_2].', |
$desc,$newrole{$item}).'</li>'; |
$desc,&mt($newrole{$item})).'</li>'; |
} |
} |
} |
} |
if ($newmsg) { |
if ($newmsg) { |
Line 2606 sub role_desc {
|
Line 2606 sub role_desc {
|
return unless ($role); |
return unless ($role); |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); |
$tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain); |
$tremark = &mt('Custom role defined by [_1].',$rauthor.':'.$rdomain); |
} |
} |
$trole=Apache::lonnet::plaintext($role); |
$trole=Apache::lonnet::plaintext($role); |
my ($tdom,$trest,$tsection)= |
my ($tdom,$trest,$tsection)= |
Line 2718 sub is_active_course {
|
Line 2718 sub is_active_course {
|
} |
} |
|
|
sub get_roles_functions { |
sub get_roles_functions { |
my ($rolescount) = @_; |
my ($rolescount,$cattype) = @_; |
my @links; |
my @links; |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]); |
if ($env{'environment.canrequest.author'}) { |
if ($env{'environment.canrequest.author'}) { |
Line 2744 sub get_roles_functions {
|
Line 2744 sub get_roles_functions {
|
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]); |
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]); |
} |
} |
} |
} |
if (&Apache::loncommon::designparm('login.coursecatalog',$env{'user.domain'})) { |
unless ($cattype eq 'none') { |
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]); |
} |
} |
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
my $funcs = &Apache::lonhtmlcommon::start_funclist(); |
Line 2765 sub get_queued {
|
Line 2765 sub get_queued {
|
$env{'user.name'},'^status:'); |
$env{'user.name'},'^status:'); |
foreach my $key (keys(%statusinfo)) { |
foreach my $key (keys(%statusinfo)) { |
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
(undef,my($cdom,$cnum)) = split(':',$key); |
(undef,my($cdom,$cnum)) = split(/:/,$key); |
my $requestkey = $cdom.'_'.$cnum; |
my $requestkey = $cdom.'_'.$cnum; |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
Line 2815 sub get_queued {
|
Line 2815 sub get_queued {
|
if (($status eq 'approval') || ($status eq 'approved')) { |
if (($status eq 'approval') || ($status eq 'approved')) { |
$output .= '<p><b>'.&mt('Author role request').'</b><br />'; |
$output .= '<p><b>'.&mt('Author role request').'</b><br />'; |
if ($status eq 'approval') { |
if ($status eq 'approval') { |
$output .= &mt('A request for authoring space submitted on [_1] is awaiting approval', |
$output .= &mt('A request for Authoring Space submitted on [_1] is awaiting approval', |
&Apache::lonlocal::locallocaltime($timestamp)); |
&Apache::lonlocal::locallocaltime($timestamp)); |
} elsif ($status eq 'approved') { |
} elsif ($status eq 'approved') { |
my %roleshash = |
my %roleshash = |