version 1.262, 2011/10/21 16:28:49
|
version 1.273, 2012/08/15 16:56:52
|
Line 221 sub handler {
|
Line 221 sub handler {
|
} else { |
} else { |
$checkingtxt = &mt('Checking for new roles ...'); |
$checkingtxt = &mt('Checking for new roles ...'); |
} |
} |
$updateresult = '<div class="LC_info">'.$checkingtxt.'</div>'; |
$updateresult = '<span class="LC_info">'.$checkingtxt.'</span>'; |
$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 266 sub handler {
|
Line 273 sub handler {
|
"request.course.fn" => '', |
"request.course.fn" => '', |
"request.course.uri" => '', |
"request.course.uri" => '', |
"request.course.sec" => '', |
"request.course.sec" => '', |
|
"request.course.tied" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.role.domain" => $env{'user.domain'}}); |
"request.role.domain" => $env{'user.domain'}}); |
Line 519 ENDENTERKEY
|
Line 527 ENDENTERKEY
|
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($dest =~ m{^/adm/coursedocs\?folderpath}) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
&update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum); |
&Apache::loncommon::update_content_constraints($cdom,$cnum,$chome, |
|
$cdom.'_'.$cnum); |
} |
} |
} |
} |
$r->internal_redirect($dest); |
$r->internal_redirect($dest); |
Line 603 ENDENTERKEY
|
Line 612 ENDENTERKEY
|
if ($role eq 'au') { |
if ($role eq 'au') { |
$redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'}; |
$redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'}; |
} else { |
} else { |
$where =~ /\/(.*)$/; |
$redirect_url .= $where; |
$redirect_url .= $1; |
|
} |
} |
$redirect_url .= '/'; |
$redirect_url .= '/'; |
&redirect_user($r,&mt('Entering Construction Space'), |
&redirect_user($r,&mt('Entering Construction Space'), |
Line 683 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 749 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 777 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 (&Apache::loncoursequeueadmin::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'}) { |
$showall .= ' checked="checked" '; |
$showall .= ' checked="checked" '; |
} |
} |
$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 955 ENDHEADER
|
Line 1029 ENDHEADER
|
$r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>'); |
$r->print('<hr /><h2>'.&mt('Current Privileges').'</h2>'); |
$r->print(&privileges_info()); |
$r->print(&privileges_info()); |
} |
} |
$r->print(&Apache::lonnet::getannounce()); |
my $announcements = &Apache::lonnet::getannounce(); |
|
$r->print( |
|
'<br />'. |
|
'<h2>'.&mt('Announcements').'</h2>'. |
|
$announcements |
|
) unless (!$announcements); |
if ($advanced) { |
if ($advanced) { |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); |
$r->print('<p><small><i>' |
$r->print('<p><small><i>' |
Line 1614 sub check_forcc {
|
Line 1693 sub check_forcc {
|
} else { |
} else { |
$ccrole = 'cc'; |
$ccrole = 'cc'; |
} |
} |
if ($cdom ne '' && $cnum ne '') { |
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; |
my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; |
if (defined($env{$envkey})) { |
if (defined($env{$envkey})) { |
$is_cc = 1; |
$is_cc = 1; |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my ($tstart,$tend)=split(/\./,$env{$envkey}); |
my $limit = $update; |
my $limit = $update; |
if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { |
if ($env{'request.role'} eq $ccrole.'./'.$cdom.'/'.$cnum) { |
$limit = $then; |
$limit = $then; |
|
} |
|
if ($tstart && $tstart>$refresh) { $is_cc = 0; } |
|
if ($tend && $tend <$limit) { $is_cc = 0; } |
|
} |
} |
|
if ($tstart && $tstart>$refresh) { $is_cc = 0; } |
|
if ($tend && $tend <$limit) { $is_cc = 0; } |
} |
} |
} |
} |
return $is_cc; |
return $is_cc; |
Line 1684 sub check_release_required {
|
Line 1761 sub check_release_required {
|
return ($switchserver,$warning); |
return ($switchserver,$warning); |
} |
} |
|
|
sub update_content_constraints { |
|
my ($cdom,$cnum,$chome,$cid) = @_; |
|
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
|
my ($reqdmajor,$reqdminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'}); |
|
my %checkresponsetypes; |
|
foreach my $key (keys(%Apache::lonnet::needsrelease)) { |
|
my ($item,$name,$value) = split(/:/,$key); |
|
if ($item eq 'resourcetag') { |
|
if ($name eq 'responsetype') { |
|
$checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key} |
|
} |
|
} |
|
} |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (defined($navmap)) { |
|
my %allresponses; |
|
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) { |
|
my %responses = $res->responseTypes(); |
|
foreach my $key (keys(%responses)) { |
|
next unless(exists($checkresponsetypes{$key})); |
|
$allresponses{$key} += $responses{$key}; |
|
} |
|
} |
|
foreach my $key (keys(%allresponses)) { |
|
my ($major,$minor) = split(/\./,$checkresponsetypes{$key}); |
|
if (($major > $reqdmajor) || ($major == $reqdmajor && $minor > $reqdminor)) { |
|
($reqdmajor,$reqdminor) = ($major,$minor); |
|
} |
|
} |
|
undef($navmap); |
|
} |
|
unless (($reqdmajor eq '') && ($reqdminor eq '')) { |
|
&Apache::lonnet::update_released_required($reqdmajor.'.'.$reqdminor,$cdom,$cnum,$chome,$cid); |
|
} |
|
return; |
|
} |
|
|
|
sub courselink { |
sub courselink { |
my ($dcdom,$rowtype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
Line 1872 sub update_session_roles {
|
Line 1912 sub update_session_roles {
|
['active','future','previous'], |
['active','future','previous'], |
undef,undef,1); |
undef,undef,1); |
my ($msg,@newsec,$oldsec,$currrole_expired,@changed_roles, |
my ($msg,@newsec,$oldsec,$currrole_expired,@changed_roles, |
%changed_groups,%dbroles, %deletedroles,%allroles,%allgroups, |
%changed_groups,%dbroles,%deletedroles,%allroles,%allgroups, |
%userroles,%checkedgroup,%crprivs,$hasgroups,%rolechange, |
%userroles,%checkedgroup,%crprivs,$hasgroups,%rolechange, |
%groupchange,%newrole,%newgroup,%customprivchg,%groups_roles, |
%groupchange,%newrole,%newgroup,%customprivchg,%groups_roles, |
@rolecodes); |
@rolecodes); |
Line 1922 sub update_session_roles {
|
Line 1962 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 1966 sub update_session_roles {
|
Line 2006 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 2109 sub update_session_roles {
|
Line 2149 sub update_session_roles {
|
foreach my $priv (@privs) { |
foreach my $priv (@privs) { |
my ($blank,@prv) = split(/:/,$priv); |
my ($blank,@prv) = split(/:/,$priv); |
@prv = map { $_ .= (/\&\w+$/ ? '':'&F') } @prv; |
@prv = map { $_ .= (/\&\w+$/ ? '':'&F') } @prv; |
$priv = ':'.join(':',sort(@prv)); |
if (@prv) { |
|
$priv = ':'.join(':',sort(@prv)); |
|
} |
$crprivs{$rest}{$scopes[$i]} = $priv; |
$crprivs{$rest}{$scopes[$i]} = $priv; |
$i++; |
$i++; |
} |
} |
Line 2213 sub update_session_roles {
|
Line 2255 sub update_session_roles {
|
$msg .= '<br />'.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'</div>'; |
$msg .= '<br />'.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'</div>'; |
} |
} |
if (!@changed_roles || !(keys(%changed_groups))) { |
if (!@changed_roles || !(keys(%changed_groups))) { |
$msg .= '<ul>'; |
my ($rolesmsg,$groupsmsg); |
if (!@changed_roles) { |
if (!@changed_roles) { |
$msg .= '<li>'; |
|
if (&Apache::loncommon::show_course()) { |
if (&Apache::loncommon::show_course()) { |
$msg .= &mt('No new courses or communities'); |
$rolesmsg = &mt('No new courses or communities'); |
} else { |
} else { |
$msg .= &mt('No role changes'); |
$rolesmsg = &mt('No role changes'); |
} |
} |
$msg .= '</li>'; |
|
} |
} |
if ($hasgroups && !(keys(%changed_groups)) && !(grep(/gr/,@changed_roles))) { |
if ($hasgroups && !(keys(%changed_groups)) && !(grep(/gr/,@changed_roles))) { |
$msg .= '<li>'.&mt('No changes in course/community groups').'</li>'; |
$groupsmsg = &mt('No changes in course/community groups'); |
} |
} |
$msg .= '</ul>'; |
|
if (!@changed_roles && !(keys(%changed_groups))) { |
if (!@changed_roles && !(keys(%changed_groups))) { |
|
if (($msg ne '') || ($groupsmsg ne '')) { |
|
$msg .= '<ul>'; |
|
if ($rolesmsg) { |
|
$msg .= '<li>'.$rolesmsg.'</li>'; |
|
} |
|
if ($groupsmsg) { |
|
$msg .= '<li>'.$groupsmsg.'</li>'; |
|
} |
|
$msg .= '</ul>'; |
|
} else { |
|
$msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br />'; |
|
} |
return $msg; |
return $msg; |
} |
} |
} |
} |
Line 2280 sub update_session_roles {
|
Line 2331 sub update_session_roles {
|
} |
} |
if (keys(%deletedroles) > 0) { |
if (keys(%deletedroles) > 0) { |
$changemsg .= '<li>'. |
$changemsg .= '<li>'. |
&mt('Existing roles deleted').'</li>'. |
&mt('Existing roles now expired').'</li>'. |
'<ul>'; |
'<ul>'; |
foreach my $item (sort(keys(%deletedroles))) { |
foreach my $item (sort(keys(%deletedroles))) { |
$changemsg .= '<li>'.$item.'</li>'; |
$changemsg .= '<li>'.$item.'</li>'; |