';
- for (my $col=1; $col<=2; $col++) {
- $output.='';
- for (my $row=1; $row<=8; $row++) {
- foreach my $cat (keys(%category_members)) {
- if ($category_positions{$cat} ne "$col,$row") { next; }
- $output.='';
- $output.=' '.&mt($category_names{$cat}).'';
- $output.=' ';
- my %active=();
- foreach my $menu_item (split(/\:/,$category_members{$cat})) {
- if ($inlineremote[$menu_item]) {
- $active{$menu_item}=1;
- }
- }
- foreach my $item (sort(keys(%active))) {
- $output.=$inlineremote[$item];
- }
- $output.=' ';
- $output.=' ';
- }
+# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
+ &rawconfig(1);
+ my $output='';
+ for (my $col=1; $col<=2; $col++) {
+ $output.='';
+ for (my $row=1; $row<=8; $row++) {
+ foreach my $cat (keys(%category_members)) {
+ if ($category_positions{$cat} ne "$col,$row") { next; }
+ #$output.=' ';
+ $output.='';
+ $output.=' '.&mt($category_names{$cat}).'';
+ $output.=' ';
+ my %active=();
+ foreach my $menu_item (split(/\:/,$category_members{$cat})) {
+ if ($inlineremote[$menu_item]) {
+ $active{$menu_item}=1;
+ }
+ }
+ foreach my $item (sort(keys(%active))) {
+ $output.=$inlineremote[$item];
+ }
+ $output.=' ';
+ $output.=' ';
}
- $output.="";
- }
- $output.=" ";
+ }
+ $output.=" | ";
}
+ $output.=" ";
return $output;
}
@@ -1596,12 +1704,12 @@ sub rawconfig {
#
my $textualoverride=shift;
my $output='';
- unless ($env{'environment.remote'} eq 'off') {
+ if ($env{'environment.remote'} eq 'on') {
$output.=
"window.status='Opening Remote Control';var swmenu=".&openmenu().
"\nwindow.status='Configuring Remote Control ';";
} else {
- unless ($textualoverride) { return ''; }
+ unless ($textualoverride) { return ''; }
}
my $uname=$env{'user.name'};
my $udom=$env{'user.domain'};
@@ -1621,7 +1729,10 @@ sub rawconfig {
my $pub=($env{'request.state'} eq 'published');
my $con=($env{'request.state'} eq 'construct');
my $rol=$env{'request.role'};
- my $requested_domain = $env{'request.role.domain'};
+ my $requested_domain;
+ if ($rol) {
+ $requested_domain = $env{'request.role.domain'};
+ }
foreach my $line (@desklines) {
my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
$prt=~s/\$uname/$uname/g;
@@ -1635,7 +1746,13 @@ sub rawconfig {
next if ($crstype ne 'Community');
$prt=~s/\$cmty/$crs/g;
}
- $prt=~s/\$requested_domain/$requested_domain/g;
+ if ($prt =~ m/\$requested_domain/) {
+ if ((!$requested_domain) && ($pro eq 'pbre') && ($env{'user.adv'})) {
+ $prt=~s/\$requested_domain/$env{'user.domain'}/g;
+ } else {
+ $prt=~s/\$requested_domain/$requested_domain/g;
+ }
+ }
if ($category_names{$cat}!~/\w/) { $cat='oth'; }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
@@ -1671,8 +1788,9 @@ sub rawconfig {
next;
}
}
- if (&Apache::lonnet::allowed($priv,$prt)) {
- $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
+ (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro eq 'course') {
if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
@@ -1739,6 +1857,7 @@ sub rawconfig {
($env{'request.role'}=~/($match_domain)\/($match_username)$/);
}
$act =~ s/\$caname/$caname/g;
+ $act =~ s/\$cadom/$cadom/g;
my $home = &Apache::lonnet::homeserver($caname,$cadom);
my $allowed=0;
my @ids=&Apache::lonnet::current_machine_ids();
@@ -1776,19 +1895,18 @@ sub rawconfig {
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
}
- unless ($env{'environment.remote'} eq 'off') {
- $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
- if (&Apache::lonmsg::newmail()) {
- $output.='swmenu.setstatus("you have","messages");';
- }
+ if ($env{'environment.remote'} eq 'on') {
+ $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
+ if (&Apache::lonmsg::newmail()) {
+ $output.='swmenu.setstatus("you have","messages");';
+ }
}
-
return $output;
}
sub check_for_rcrs {
my $showreqcrs = 0;
- my @reqtypes = ('official','unofficial','community');
+ my @reqtypes = ('official','unofficial','community','textbook');
foreach my $type (@reqtypes) {
if (&Apache::lonnet::usertools_access($env{'user.name'},
$env{'user.domain'},
@@ -1811,7 +1929,7 @@ sub check_for_rcrs {
# ======================================================================= Close
sub close {
- if ($env{'environment.remote'} eq 'off') { return ''; }
+ unless ($env{'environment.remote'} eq 'on') { return ''; }
my $menuname = &get_menu_name();
return(<
@@ -1830,29 +1948,6 @@ window.status='Done.';
ENDCLOSE
}
-# ====================================================================== Footer
-
-sub footer {
-
-}
-
-sub nav_control_js {
- my $nav=($env{'environment.remotenavmap'} eq 'on');
- return (< '(More ...)',
@@ -1864,13 +1959,13 @@ function showCourseID() {
document.getElementById('dccid').style.display='block';
document.getElementById('dccid').style.textAlign='left';
document.getElementById('dccid').style.textFace='normal';
- document.getElementById('dccidtext').innerHTML ='$lt{'less'}';
+ document.getElementById('dccidtext').innerHTML ='';
return;
}
function hideCourseID() {
document.getElementById('dccid').style.display='none';
- document.getElementById('dccidtext').innerHTML ='$lt{'more'}';
+ document.getElementById('dccidtext').innerHTML ='';
return;
}
@@ -1878,65 +1973,37 @@ END
}
-sub utilityfunctions {
- my ($caller,$custommenu) = @_;
- unless ($env{'environment.remote'} eq 'off' ||
- $caller eq '/adm/menu') {
- return ''; }
-
- my $gcimenujs;
- if ($custommenu) {
- my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc');
- my $managetesturl = '/adm/menu';
- my $createtesturl = '/adm/requestcourse';
- if (($env{'request.course.id'}) &&
- ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) {
- my @items = keys(%concepttests);
- if (@items== 1) {
- my $newrole = $items[0];
- $newrole =~ s{_}{/};
- $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
- } else {
- $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
- }
- }
- if ($env{'request.course.id'}) {
- $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
- }
- $gcimenujs = <<"ENDCUSTOM";
+sub countdown_toggle_js {
+ return <<"END";
-function switchpage(caller) {
- if (caller == 'review') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1';
- }
- if (caller == 'submit') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1';
- }
- if (caller == 'createtest') {
- document.location.href = '$createtesturl';
- }
- if (caller == 'managetest') {
- document.location.href = '$managetesturl';
- }
- if (caller == 'tutorial') {
- document.location.href = '/adm/roles?selectrole=1&st./gci/5422913620b814c90gcil1=1';
+function toggleCountdown() {
+ var countdownid = document.getElementById('duedatecountdown');
+ var currstyle = countdownid.style.display;
+ if (currstyle == 'inline') {
+ countdownid.style.display = 'none';
+ document.getElementById('ddcountcollapse').innerHTML='';
+ document.getElementById('ddcountexpand').innerHTML='◄ ';
+ } else {
+ countdownid.style.display = 'inline';
+ document.getElementById('ddcountcollapse').innerHTML='► ';
+ document.getElementById('ddcountexpand').innerHTML='';
}
return;
}
-ENDCUSTOM
- }
-
+END
+}
+
+sub utilityfunctions {
+ my ($httphost) = @_;
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- if ($currenturl =~ m{^/adm/wrapper/ext/}) {
- if ($env{'request.external.querystring'}) {
+ if ($currenturl =~ m{^/adm/wrapper/ext/}
+ && $env{'request.external.querystring'} ) {
$currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
- }
}
$currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
- my $nav_control=&nav_control_js();
my $dc_popup_cid;
if ($env{'user.adv'} && exists($env{'user.role.dc./'.
@@ -1956,37 +2023,54 @@ ENDCUSTOM
my $end_page_annotate =
&Apache::loncommon::end_page({'js_ready' => 1});
- my $start_page_bookmark =
- &Apache::loncommon::start_page('Bookmarks',undef,
- {'only_body' => 1,
- 'js_ready' => 1,
- 'bgcolor' => '#BBBBBB',});
+ my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
- my $end_page_bookmark =
- &Apache::loncommon::end_page({'js_ready' => 1});
+ my $esc_url=&escape($currenturl);
+ my $esc_symb=&escape($currentsymb);
-return (<'
- +'$end_page_bookmark' );
- bmquery.document.close();
+function open_StoredLinks_Import(rat) {
+ var newWin;
+ var lcHostname = setLCHost();
+ if (rat) {
+ newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
+ 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
+ }
+ else {
+ newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import',
+ 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
+ }
+ newWin.focus();
}
+(function (\$) {
+ \$(document).ready(function () {
+ \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
+ /*\@cc_on
+ if (!window.XMLHttpRequest) {
+ \$('.LC_hoverable').each(function () {
+ this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
+ this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
+ });
+ }
+ \@*/
+ });
+}(jQuery));
+
+$countdown
+
ENDUTILITY
}
@@ -2143,44 +2236,63 @@ sub constspaceform {
ENDCONSTSPACEFORM
}
-
sub get_nav_status {
my $navstatus="swmenu.w_loncapanav_flag=";
if ($env{'environment.remotenavmap'} eq 'on') {
- $navstatus.="1";
+ $navstatus.="1";
} else {
- $navstatus.="-1";
+ $navstatus.="-1";
}
return $navstatus;
}
sub hidden_button_check {
- my $hidden;
- if ($env{'request.course.id'} eq '') {
+ if ( $env{'request.course.id'} eq ''
+ || $env{'request.role.adv'} ) {
+
return;
}
- if ($env{'request.role.adv'}) {
- unless (&Apache::loncommon::needs_gci_custom()) {
- return;
- }
- }
my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
return $buttonshide;
}
sub roles_selector {
- my ($cdom,$cnum) = @_;
+ my ($cdom,$cnum,$httphost) = @_;
my $crstype = &Apache::loncommon::course_type();
my $now = time;
- my (%courseroles,%seccount);
+ my (%courseroles,%seccount,%courseprivs);
my $is_cc;
- my $role_selector;
+ my ($js,$form,$switcher,$switchtext);
my $ccrole;
if ($crstype eq 'Community') {
$ccrole = 'co';
} else {
$ccrole = 'cc';
- }
+ }
+ my ($priv,$gotsymb,$destsymb);
+ my $destinationurl = $ENV{'REQUEST_URI'};
+ if ($destinationurl =~ /\?symb=/) {
+ $gotsymb = 1;
+ } elsif ($destinationurl =~ m{^/enc/}) {
+ my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
+ if ($plainurl =~ /\?symb=/) {
+ $gotsymb = 1;
+ }
+ }
+ unless ($gotsymb) {
+ $destsymb = &Apache::lonnet::symbread();
+ if ($destsymb ne '') {
+ $destsymb = &Apache::lonenc::check_encrypt($destsymb);
+ }
+ }
+ my $reqprivs = &required_privs();
+ if (ref($reqprivs) eq 'HASH') {
+ my $destination = $destinationurl;
+ $destination =~ s/(\?.*)$//;
+ if (exists($reqprivs->{$destination})) {
+ $priv = $reqprivs->{$destination};
+ }
+ }
if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
@@ -2193,7 +2305,7 @@ sub roles_selector {
}
}
if ($is_cc) {
- &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
+ &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
} else {
my %gotnosection;
foreach my $item (keys(%env)) {
@@ -2209,6 +2321,18 @@ sub roles_selector {
$gotnosection{$role} = 1;
}
}
+ if ($priv ne '') {
+ my $cnumsec = $cnum;
+ if ($sec ne '') {
+ $cnumsec .= "/$sec";
+ }
+ $courseprivs{"$role./$cdom/$cnumsec./"} =
+ $env{"user.priv.$role./$cdom/$cnumsec./"};
+ $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
+ $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
+ $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
+ $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
+ }
if (ref($courseroles{$role}) eq 'ARRAY') {
if ($sec ne '') {
if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
@@ -2226,42 +2350,72 @@ sub roles_selector {
}
}
}
- my $switchtext;
- if ($crstype eq 'Community') {
- $switchtext = &mt('Switch community role to...')
- } else {
- $switchtext = &mt('Switch course role to...')
- }
+ $switchtext = 'Switch role'; # do not translate here
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
- if (keys(%courseroles) > 1) {
- $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
- $role_selector .= '';
+ if (@submenu > 0) {
+ $switcher = &create_submenu('','',$switchtext,\@submenu);
+ }
}
- return $role_selector;
+ return ($js,$form,$switcher);
}
sub get_all_courseroles {
- my ($cdom,$cnum,$courseroles,$seccount) = @_;
- unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
+ my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
+ unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
+ (ref($courseprivs) eq 'HASH')) {
return;
}
my ($result,$cached) =
@@ -2269,9 +2423,11 @@ sub get_all_courseroles {
if (defined($cached)) {
if (ref($result) eq 'HASH') {
if ((ref($result->{'roles'}) eq 'HASH') &&
- (ref($result->{'seccount'}) eq 'HASH')) {
+ (ref($result->{'seccount'}) eq 'HASH') &&
+ (ref($result->{'privs'}) eq 'HASH')) {
%{$courseroles} = %{$result->{'roles'}};
%{$seccount} = %{$result->{'seccount'}};
+ %{$courseprivs} = %{$result->{'privs'}};
return;
}
}
@@ -2299,30 +2455,44 @@ sub get_all_courseroles {
push(@{$courseroles->{$urole}},$usec);
}
}
+ my $area = '/'.$cdom.'/'.$cnum;
+ if ($usec ne '') {
+ $area .= '/'.$usec;
+ }
+ if ($role =~ /^cr\//) {
+ &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
+ } else {
+ &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
+ }
}
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
@{$courseroles->{'st'}} = ();
+ &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
if (keys(%sections_count) > 0) {
push(@{$courseroles->{'st'}},keys(%sections_count));
- $seccount->{'st'} = scalar(keys(%sections_count));
+ $seccount->{'st'} = scalar(keys(%sections_count));
}
+ $seccount->{'st'} ++; # Increment for a section-less student role.
my $rolehash = {
'roles' => $courseroles,
'seccount' => $seccount,
+ 'privs' => $courseprivs,
};
&Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
return;
}
sub jump_to_role {
- my ($cdom,$cnum,$seccount,$courseroles) = @_;
+ my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
my %lt = &Apache::lonlocal::texthash(
this => 'This role has section(s) associated with it.',
ente => 'Enter a specific section.',
orlb => 'Enter a specific section, or leave blank for no section.',
avai => 'Available sections are:',
youe => 'You entered an invalid section choice:',
- plst => 'Please try again',
+ plst => 'Please try again.',
+ role => 'The role you selected is not permitted to view the current page.',
+ swit => 'Switch role, but display Main Menu page instead?',
);
my $js;
if (ref($courseroles) eq 'HASH') {
@@ -2345,14 +2515,44 @@ sub jump_to_role {
' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
}
}
+ my $checkroles = 0;
+ if ($priv && ref($courseprivs) eq 'HASH') {
+ my (%disallowed,%allowed,@disallow);
+ foreach my $role (sort(keys(%{$courseprivs}))) {
+ my $trole;
+ if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
+ $trole = $1;
+ }
+ if (($trole ne '') && ($trole ne 'cm')) {
+ if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
+ $allowed{$trole} = 1;
+ } else {
+ $disallowed{$trole} = 1;
+ }
+ }
+ }
+ foreach my $trole (keys(%disallowed)) {
+ unless ($allowed{$trole}) {
+ push(@disallow,$trole);
+ }
+ }
+ if (@disallow > 0) {
+ $checkroles = 1;
+ $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
+ " var rolecheck = 1;\n";
+ }
+ }
+ if (!$checkroles) {
+ $js .= " var disallow = new Array();\n".
+ " rolecheck = 0;\n";
+ }
return <<"END";
|