version 1.269.2.1, 2012/08/03 17:35:39
|
version 1.272, 2012/08/15 14:37:23
|
Line 149 sub redirect_user {
|
Line 149 sub redirect_user {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
my $swinfo=&Apache::lonmenu::rawconfig(); |
|
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => $url, |
my $brcrum = [{'href' => $url, |
Line 164 sub redirect_user {
|
Line 163 sub redirect_user {
|
$url=~s/ /\%20/g; |
$url=~s/ /\%20/g; |
$r->print(<<ENDREDIR); |
$r->print(<<ENDREDIR); |
$start_page |
$start_page |
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$swinfo |
|
// ]]> |
|
</script> |
|
<p>$msg</p> |
<p>$msg</p> |
$end_page |
$end_page |
ENDREDIR |
ENDREDIR |
Line 231 sub handler {
|
Line 225 sub handler {
|
$updateresult .= &update_session_roles(); |
$updateresult .= &update_session_roles(); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
$update = $now; |
$update = $now; |
|
&Apache::loncoursequeueadmin::reqauthor_check(); |
|
} |
|
|
|
# -------------------------------------------------- Check for author requests |
|
my $reqauthor; |
|
if ($env{'form.requestauthor'}) { |
|
$reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update); |
} |
} |
|
|
my $envkey; |
my $envkey; |
Line 690 function setToUpdate(thisform) {
|
Line 691 function setToUpdate(thisform) {
|
thisform.submit(); |
thisform.submit(); |
} |
} |
|
|
|
function setToRequestAuthor(thisform) { |
|
thisform.requestauthor.value='1'; |
|
thisform.selectrole.value=''; |
|
thisform.submit(); |
|
} |
|
|
// ]]> |
// ]]> |
</script> |
</script> |
ENDHEADER |
ENDHEADER |
Line 756 ENDHEADER
|
Line 763 ENDHEADER
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
$r->print($updateresult); |
if ($updateresult || $reqauthor) { |
|
$r->print('<div>'. |
|
$updateresult. |
|
$reqauthor. |
|
'</div>'); |
|
} |
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; |
} |
} |
Line 784 ENDHEADER
|
Line 796 ENDHEADER
|
'<input type="button" name="update" value="'. |
'<input type="button" name="update" value="'. |
$updatebutton.'" onclick="javascript:setToUpdate(this.form)" />'; |
$updatebutton.'" onclick="javascript:setToUpdate(this.form)" />'; |
} |
} |
|
my ($requestauthor,$requestcrs); |
|
unless ($reqauthor) { |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&is_active_author()) { |
|
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
|
if ($status eq 'approval') { |
|
$requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp)); |
|
} elsif (($status eq 'approved') && ($do_update)) { |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash)) { |
|
$requestauthor = &mt('Your request for an author role has been approved.').'<br />'; |
|
if ($show_course) { |
|
$requestauthor .= &mt('Use the "Check for new courses" button to update your list of roles.'); |
|
} else { |
|
$requestauthor .= &mt('Use the "Check for new roles" button to update your list of roles.'); |
|
} |
|
$requestauthor = '<span class="LC_info">'.$requestauthor.'</span>'; |
|
} |
|
} |
|
unless ($requestauthor) { |
|
$requestauthor = |
|
'<input type="hidden" name="requestauthor" value="" />'. |
|
'<input type="button" name="reqauthor" value="'. |
|
&mt('Request author space').'" '. |
|
'onclick="javascript:setToRequestAuthor(this.form)" />'; |
|
} |
|
} |
|
} |
|
} |
|
my $do_update; |
|
unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) { |
|
$do_update = '<input type="hidden" name="doupdate" value="" />'. |
|
'<input type="button" name="update" value="'. |
|
$updatebutton.'" onclick="javascript:setToUpdate(this.form)" />'; |
|
} |
if ($env{'user.adv'}) { |
if ($env{'user.adv'}) { |
my $showall = '<label><input type="checkbox" name="showall"'; |
my $showall = '<label><input type="checkbox" name="showall"'; |
if ($env{'form.showall'}) { |
if ($env{'form.showall'}) { |
Line 791 ENDHEADER
|
Line 839 ENDHEADER
|
} |
} |
$showall .= ' />'.&mt('Show all roles').'</label> '. |
$showall .= ' />'.&mt('Show all roles').'</label> '. |
'<input type="submit" value="'.&mt('Update display').'" />'; |
'<input type="submit" value="'.&mt('Update display').'" />'; |
if ($do_update) { |
if ($do_update || $requestauthor) { |
$r->print('<div class="LC_left_float"><fieldset>'. |
$r->print('<div class="LC_left_float"><fieldset>'. |
'<legend>'. &mt('Display').'</legend>'. |
'<legend>'. &mt('Display').'</legend>'. |
$showall.'</fieldset></div>'. |
$showall.'</fieldset></div>'); |
'<div class="LC_left_float"><fieldset><legend>'. |
if ($do_update) { |
&mt('Changes?').'</legend>'. |
$r->print('<div class="LC_left_float">'. |
$do_update.'</fieldset></div><br clear="all" />'); |
'<fieldset><legend>'.&mt('Changes?').'</legend>'. |
|
$do_update.'</fieldset></div>'); |
|
} |
|
if ($requestauthor) { |
|
$r->print('<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Add author role').'</legend>'. |
|
$requestauthor.'</fieldset>'); |
|
} |
|
$r->print('</div><br clear="all" />'); |
} else { |
} else { |
$r->print($showall); |
$r->print($showall); |
} |
} |
} else { |
} else { |
$r->print('<p>'.$do_update.'</p>'); |
if ($do_update && $requestauthor) { |
|
$r->print('<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Changes?').'</legend>'. |
|
$do_update.'</fieldset></div>'. |
|
'<div class="LC_left_float">'. |
|
'<fieldset><legend>'.&mt('Add author role').'</legend>'. |
|
$requestauthor.'</fieldset></div><br clear="all" />'); |
|
} elsif ($do_update) { |
|
$r->print('<p>'.$do_update.'</p>'); |
|
} elsif ($requestauthor) { |
|
$r->print('<p>'.$requestauthor.'</p>'); |
|
} |
if ($countactive > 0) { |
if ($countactive > 0) { |
$r->print(&Apache::loncoursequeueadmin::queued_selfenrollment()); |
$r->print(&Apache::loncoursequeueadmin::queued_selfenrollment()); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
Line 982 ENDHEADER
|
Line 1049 ENDHEADER
|
return OK; |
return OK; |
} |
} |
|
|
|
sub is_active_author { |
|
if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) { |
|
if ((!$1 || $1 < time) && |
|
(!$2 || $2 > time)) { |
|
return 1; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub reqauthor_check { |
|
my $queued = $env{'environment.requestauthorqueued'}; |
|
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
|
$env{'user.domain'},$env{'user.name'}); |
|
my $reqstatus = $reqauthor{'author_status'}; |
|
if (($reqstatus eq '' && $queued ne '') || |
|
($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) { |
|
if (ref($reqauthor{'author'}) eq 'HASH') { |
|
$queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'}; |
|
} else { |
|
undef($queued); |
|
} |
|
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued}); |
|
} |
|
return $queued; |
|
} |
|
|
sub gather_roles { |
sub gather_roles { |
my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_; |
my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_; |
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,''); |
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,''); |
Line 1895 sub update_session_roles {
|
Line 1989 sub update_session_roles {
|
} |
} |
if ($env{$envkey} eq '') { |
if ($env{$envkey} eq '') { |
my $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$now,$now); |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
&gather_roleprivs(\%allroles,\%allgroups,\%userroles,$where,$role,$tstart,$tend,$status_in_db); |
if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) { |
if (($role eq 'st') && ($env{'request.role'} =~ m{^\Q$role\E\.\Q/$udom/$uname\E})) { |
if ($status_in_db eq 'active') { |
if ($status_in_db eq 'active') { |
Line 1939 sub update_session_roles {
|
Line 2033 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 $status_in_db = |
my $status_in_db = |
&curr_role_status($tstart,$tend,$refresh,$now); |
&curr_role_status($tstart,$tend,$now,$now); |
if ($status_in_env ne $status_in_db) { |
if ($status_in_env ne $status_in_db) { |
if ($status_in_env eq 'active') { |
if ($status_in_env eq 'active') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
Line 2210 sub update_session_roles {
|
Line 2304 sub update_session_roles {
|
} |
} |
$msg .= '</ul>'; |
$msg .= '</ul>'; |
} else { |
} else { |
$msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br /><br />'; |
$msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br />'; |
} |
} |
return $msg; |
return $msg; |
} |
} |