version 1.108, 2004/11/12 15:33:32
|
version 1.115, 2004/12/17 21:44:19
|
Line 100 sub handler {
|
Line 100 sub handler {
|
"request.role.adv" => $ENV{'user.adv'}, |
"request.role.adv" => $ENV{'user.adv'}, |
"request.role.domain" => $ENV{'user.domain'}); |
"request.role.domain" => $ENV{'user.domain'}); |
|
|
# Check to see if the user is a DC trying to enter a course and needs privs to be created |
# Check if user is a DC trying to enter a course and needs privs to be created |
if ($numdc > 0) { |
if ($numdc > 0) { |
foreach my $envkey (keys %ENV) { |
foreach my $envkey (keys %ENV) { |
if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) { |
if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) { |
if ($dcroles{$1}) { |
if ($dcroles{$1}) { |
unless ($ENV{'user.role.cc./'.$1.'/'.$2}) { |
my $cckey = 'user.role.cc./'.$1.'/'.$2; |
&set_privileges($1,$2); |
&check_privs($cckey,$then,$now); |
} |
|
} |
} |
last; |
last; |
} |
} |
Line 122 sub handler {
|
Line 121 sub handler {
|
if ($tstatus eq 'is') { |
if ($tstatus eq 'is') { |
$where=~s/^\///; |
$where=~s/^\///; |
my ($cdom,$cnum,$csec)=split(/\//,$where); |
my ($cdom,$cnum,$csec)=split(/\//,$where); |
|
# store role if recent_role list being kept |
|
if ($ENV{'environment.recentroles'}) { |
|
&Apache::lonhtmlcommon::store_recent('roles', |
|
$trolecode,' '); |
|
} |
|
|
|
|
# check for keyed access |
# check for keyed access |
if (($role eq 'st') && |
if (($role eq 'st') && |
($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { |
($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { |
Line 256 ENDENTERKEY
|
Line 262 ENDENTERKEY
|
'.course.helper.not.run'}) { |
'.course.helper.not.run'}) { |
$furl = "/adm/helper/course.initialization.helper"; |
$furl = "/adm/helper/course.initialization.helper"; |
} |
} |
# Check to see if the user is a DC selecting a course |
|
if (($numdc > 0) && ($role eq 'cc')) { |
|
my $formaction = '/adm/roles/'; |
|
my ($dcdom,$pickedcourse) = split/_/,$courseid; |
|
if ($ENV{'user.role.dc./'.$dcdom.'/'}) { |
|
&Apache::lonhtmlcommon::store_recent('recent_roles', |
|
$courseid,$formaction); |
|
} |
|
} |
|
# |
|
# Send the user to the course they selected |
# Send the user to the course they selected |
&redirect_user($r,&mt('Entering Course'), |
&redirect_user($r,&mt('Entering Course'), |
$furl,$msg, |
$furl,$msg, |
Line 343 ENDHEADER
|
Line 339 ENDHEADER
|
$r->print("<h1>LON-CAPA Access Control</h1>"); |
$r->print("<h1>LON-CAPA Access Control</h1>"); |
$r->print("<hr><pre>Access : ". |
$r->print("<hr><pre>Access : ". |
Apache::lonnet::plaintext($priv)."\n"); |
Apache::lonnet::plaintext($priv)."\n"); |
$r->print("Resource: $fn\n"); |
$r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n"); |
$r->print("Action : $msg\n</pre><hr>"); |
$r->print("Action : $msg\n</pre><hr>"); |
} else { |
} else { |
if ($ENV{'user.error.msg'}) { |
if ($ENV{'user.error.msg'}) { |
Line 543 ENDHEADER
|
Line 539 ENDHEADER
|
$sortkey=$role.$twhere; |
$sortkey=$role.$twhere; |
} |
} |
|
|
$roletext.='<tr bgcolor='.$tbg.'>'; |
$roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver); |
unless ($nochoose) { |
|
if (!$button) { |
|
if ($switchserver) { |
|
$roletext.='<td><a href="/adm/logout?handover='. |
|
$switchserver.'">'.&mt('Switch Server').'</a></td>'; |
|
} else { |
|
$roletext.=('<td> </td>'); |
|
} |
|
} elsif ($tstatus eq 'is') { |
|
$roletext.=('<td><input type=submit value="'. |
|
&mt('Select').'" name="'. |
|
$trolecode.'"></td>'); |
|
} elsif ($tryagain) { |
|
$roletext.= |
|
'<td><input type=submit value="'. |
|
&mt('Try Selecting Again').'" name="'.$trolecode.'"></td>'; |
|
} elsif ($advanced) { |
|
$roletext.= |
|
'<td><input type=submit value="'. |
|
&mt('Re-Initialize').'" name="'.$trolecode.'"></td>'; |
|
} else { |
|
$roletext.='<td> </td>'; |
|
} |
|
} |
|
$tremark.=&Apache::lonannounce::showday(time,1, |
|
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
|
|
|
$roletext.='<td><font color="'.$tfont.'">'.$trole. |
|
'</font></td><td><font color="'.$tfont.'">'.$ttype. |
|
'</font></td><td><font color="'.$tfont.'">'.$twhere. |
|
'</font></td><td><font color="'.$tfont.'">'.$tpstart. |
|
'</font></td><td><font color="'.$tfont.'">'.$tpend. |
|
'</font></td><td><font color="'.$tfont.'">'.$tremark. |
|
' </font></td></tr>'."\n"; |
|
$roletext{$envkey}=$roletext; |
$roletext{$envkey}=$roletext; |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;} |
$sortrole{$sortkey}=$envkey; |
$sortrole{$sortkey}=$envkey; |
Line 624 ENDHEADER
|
Line 586 ENDHEADER
|
} |
} |
if ($haverole) { $doheaders++; } |
if ($haverole) { $doheaders++; } |
} |
} |
|
|
|
if ($ENV{'environment.recentroles'}) { |
|
my %recent_roles = |
|
&Apache::lonhtmlcommon::get_recent('roles',$ENV{'environment.recentrolesn'}); |
|
my $output=''; |
|
foreach (sort(keys(%recent_roles))) { |
|
if (defined($roletext{'user.role.'.$_})) { |
|
$output.=$roletext{'user.role.'.$_}; |
|
} elsif ($numdc > 0) { |
|
unless ($_ =~/^error\:/) { |
|
$output.=&display_cc_role('user.role.'.$_); |
|
} |
|
} |
|
} |
|
if ($output) { |
|
$r->print("<tr bgcolor='#BBffBB'><td align='center' colspan='7'>". |
|
&mt('Recent Roles')."</td>"); |
|
$r->print($output); |
|
$r->print("</tr>"); |
|
$doheaders ++; |
|
} |
|
} |
|
|
if ($numdc > 0) { |
if ($numdc > 0) { |
&select_recent_courses($r,\%roletext); |
$r->print(&coursepick_jscript()); |
|
$r->print(&Apache::loncommon::coursebrowser_javascript()); |
} |
} |
foreach my $type ('Construction Space','Course','Domain','System') { |
foreach my $type ('Construction Space','Course','Domain','System') { |
my $output; |
my $output; |
Line 642 ENDHEADER
|
Line 628 ENDHEADER
|
if ($output) { |
if ($output) { |
if ($doheaders > 0) { |
if ($doheaders > 0) { |
$r->print("<tr bgcolor='#BBffBB'>". |
$r->print("<tr bgcolor='#BBffBB'>". |
"<td align='center' colspan='7'>".&mt($type)."</td>"); |
"<td align='center' colspan='7'>".&mt($type)."</td></tr>"); |
} |
} |
$r->print($output); |
$r->print($output); |
} |
} |
Line 761 sub role_status {
|
Line 747 sub role_status {
|
} |
} |
} |
} |
|
|
sub dc_script { |
sub build_roletext { |
my $response = (<<"END"); |
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_; |
function setDCchoice(caller) { |
my $roletext='<tr bgcolor="'.$tbg.'">'; |
var dcname = "dc./"+caller+"/" |
unless ($nochoose) { |
document.rolechoice.dcselected.value = caller |
if (!$button) { |
document.rolechoice.elements[3].name = dcname |
if ($switchserver) { |
document.rolechoice.submit() |
$roletext.='<td><a href="/adm/logout?handover='. |
|
$switchserver.'">'.&mt('Switch Server').'</a></td>'; |
|
} else { |
|
$roletext.=('<td> </td>'); |
|
} |
|
} elsif ($tstatus eq 'is') { |
|
$roletext.=('<td><input type=submit value="'. |
|
&mt('Select').'" name="'. |
|
$trolecode.'"></td>'); |
|
} elsif ($tryagain) { |
|
$roletext.= |
|
'<td><input type=submit value="'. |
|
&mt('Try Selecting Again').'" name="'.$trolecode.'"></td>'; |
|
} elsif ($advanced) { |
|
$roletext.= |
|
'<td><input type=submit value="'. |
|
&mt('Re-Initialize').'" name="'.$trolecode.'"></td>'; |
|
} else { |
|
$roletext.='<td> </td>'; |
|
} |
|
} |
|
$tremark.=&Apache::lonannounce::showday(time,1, |
|
&Apache::lonannounce::readcalendar($tdom.'_'.$trest)); |
|
|
|
|
|
$roletext.='<td><font color="'.$tfont.'">'.$trole. |
|
'</font></td><td><font color="'.$tfont.'">'.$ttype. |
|
'</font></td><td><font color="'.$tfont.'">'.$twhere. |
|
'</font></td><td><font color="'.$tfont.'">'.$tpstart. |
|
'</font></td><td><font color="'.$tfont.'">'.$tpend. |
|
'</font></td><td><font color="'.$tfont.'">'.$tremark. |
|
' </font></td></tr>'."\n"; |
|
return $roletext; |
} |
} |
END |
|
return $response; |
sub check_privs { |
|
my ($cckey,$then,$now) = @_; |
|
if ($ENV{$cckey}) { |
|
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); |
|
&role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); |
|
unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) { |
|
&set_privileges($1,$2); |
|
} |
|
} else { |
|
&set_privileges($1,$2); |
|
} |
} |
} |
|
|
sub check_fordc { |
sub check_fordc { |
my ($dcroles,$then) = @_; |
my ($dcroles,$then) = @_; |
my $numdc = 0; |
my $numdc = 0; |
Line 796 sub check_fordc {
|
Line 824 sub check_fordc {
|
|
|
sub courselink { |
sub courselink { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'dom'); |
my $courseform=&Apache::loncommon::selectcourse_link |
|
('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom); |
|
my $hiddenitems = '<input type="hidden" name="dcdomain_'.$dcdom.'" value="'.$dcdom.'" />'. |
|
'<input type="hidden" name="origdom_'.$dcdom.'" value="'.$dcdom.'" />'. |
|
'<input type="hidden" name="dccourse_'.$dcdom.'" value="" />'. |
|
'<input type="hidden" name="coursedesc_'.$dcdom.'" value="" />'; |
|
return $courseform.$hiddenitems; |
|
} |
|
|
|
sub coursepick_jscript { |
my $verify_script = <<"END"; |
my $verify_script = <<"END"; |
<script> |
<script> |
function verifyCoursePick(caller) { |
function verifyCoursePick(caller) { |
var numbutton = getIndex(caller) |
var numbutton = getIndex(caller) |
var pickedCourse = document.rolechoice.dccourse.value |
var pickedCourse = document.rolechoice.elements[numbutton+4].value |
var pickedDomain = document.rolechoice.dcdomain.value |
var pickedDomain = document.rolechoice.elements[numbutton+2].value |
if (document.rolechoice.dcdomain.value == document.rolechoice.origdom.value) { |
if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) { |
if (pickedCourse != '') { |
if (pickedCourse != '') { |
if (numbutton != -1) { |
if (numbutton != -1) { |
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
Line 812 function verifyCoursePick(caller) {
|
Line 849 function verifyCoursePick(caller) {
|
} |
} |
} |
} |
else { |
else { |
alert("You must use the 'Select Course' link to open a separate pick course window which you can use to select the course you wish to enter"); |
alert("Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter."); |
} |
} |
} |
} |
else { |
else { |
alert("You can only use this screen to select courses in the current domain") |
alert("You can only use this screen to select courses in the current domain") |
} |
} |
} |
} |
|
function getIndex(caller) { |
function getIndex(what) { |
|
for (var i=0;i<document.rolechoice.elements.length;i++) { |
for (var i=0;i<document.rolechoice.elements.length;i++) { |
if (what == document.rolechoice.elements[i]) { |
if (document.rolechoice.elements[i] == caller) { |
return i; |
return i; |
} |
} |
} |
} |
Line 830 function getIndex(what) {
|
Line 866 function getIndex(what) {
|
} |
} |
</script> |
</script> |
END |
END |
my $courseform=&Apache::loncommon::selectcourse_link |
return $verify_script; |
('rolechoice','dccourse','dcdomain','coursedesc'); |
|
my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'. |
|
'<input type="hidden" name="origdom" value="'.$dcdom.'" />'. |
|
'<input type="hidden" name="dccourse" value="" />'. |
|
'<input type="hidden" name="coursedesc" value="" />'; |
|
return $cb_jscript.$verify_script.$courseform.$hiddenitems; |
|
} |
} |
|
|
|
sub processpick { |
|
my $dcdom = shift; |
|
my $process_pick = <<"END"; |
|
<script> |
|
function process_pick(dom) { |
|
var numbutton = getIndex(dom) |
|
var pickedCourse = opener.document.rolechoice.dccourse_$dcdom.value |
|
var pickedDomain = opener.document.rolechoice.dcdomain_$dcdom.value |
|
if (opener.document.rolechoice.dcdomain_$dcdom.value == opener.document.rolechoice.origdom_$dcdom.value) { |
|
if (pickedCourse != '') { |
|
if (numbutton != -1) { |
|
var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse |
|
opener.document.rolechoice.elements[numbutton+1].name = courseTarget |
|
opener.document.rolechoice.submit() |
|
} |
|
} |
|
} |
|
} |
|
|
|
function getIndex(dom) { |
|
var callername = 'ccpick_'+dom |
|
for (var i=0;i<opener.document.rolechoice.elements.length;i++) { |
|
var elemname = opener.document.rolechoice.elements[i].name |
|
if (elemname == callername) { |
|
return i; |
|
} |
|
} |
|
return -1; |
|
} |
|
</script> |
|
END |
|
return $process_pick; |
|
} |
|
|
sub select_recent_courses { |
sub display_cc_role { |
my ($r,$roletext)=@_; |
my $rolekey = shift; |
|
my $roletext; |
my $advanced = $ENV{'user.adv'}; |
my $advanced = $ENV{'user.adv'}; |
my $tryagain = $ENV{'form.tryagain'}; |
my $tryagain = $ENV{'form.tryagain'}; |
my %recent=&Apache::lonnet::dump(&recent_filename('recent_roles')); |
unless ($rolekey =~/^error\:/) { |
my $numrecent = 0; |
if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) { |
my $roledisplay = '<tr bgcolor="#BBffBB">'. |
my $tcourseid = $1.'_'.$2; |
'<td align="center" colspan="7">'. |
my $trolecode = 'cc./'.$1.'/'.$2; |
&mt('Recent courses accessed by DC'). |
my $trole = Apache::lonnet::plaintext('cc'); |
'</td></tr>'."\n"; |
my $twhere; |
foreach my $courseid (sort keys %recent) { |
my $tbg='#77FF77'; |
unless ($courseid =~/^error\:/) { |
my $tfont='#003300'; |
my ($dom,$crs) = split/_/,$courseid; |
my %newhash=&Apache::lonnet::coursedescription($tcourseid); |
$numrecent ++; |
if (%newhash) { |
my $crskey = 'user.role.cc./'.$dom.'/'.$crs; |
$twhere=$newhash{'description'}. |
$roledisplay.=$$roletext{$crskey}; |
' <font size="-2">'. |
|
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). |
|
'</font>'; |
|
} else { |
|
$twhere=&mt('Currently not available'); |
|
$ENV{'course.'.$tcourseid.'.description'}=$twhere; |
|
} |
|
$twhere.="<br />".&mt('Domain').":".$1; |
|
$roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,''); |
} |
} |
} |
} |
if ($numrecent > 0) { |
return $roletext; |
$r->print("$roledisplay\n"); |
|
} |
|
} |
} |
|
|
sub allcourses_row { |
sub allcourses_row { |
my ($dcdom) = @_; |
my $dcdom = shift; |
my $ccrole = Apache::lonnet::plaintext('cc'); |
my $ccrole = Apache::lonnet::plaintext('cc'); |
my $selectlink = &courselink($dcdom); |
my $selectlink = &courselink($dcdom); |
my $output = '<tr bgcolor="#77FF77">'. |
my $output = '<tr bgcolor="#77FF77">'. |
'<td><input type="button" value="'. |
'<td><input type="button" value="'. |
&mt('Select').'" name="ccpick_'.$dcdom.'/" '. |
&mt('Select').'" name="ccpick_'.$dcdom.'"'. |
'onClick="verifyCoursePick(this)">'. |
'onClick="verifyCoursePick(this)">'. |
'<input type="hidden" name="pick_'.$dcdom.'" value="1"></td>'. |
'<input type="hidden" name="pick_'.$dcdom.'" value="1"></td>'. |
'<td><font color="#002200">'. |
'<td><font color="#002200">'. |