';
+ 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.=" ";
+ return $output;
}
sub rawconfig {
+#
+# This evaluates mydesk.tab
+# Need to add more positions and more privileges to deal with all
+# menu items.
+#
my $textualoverride=shift;
my $output='';
- unless ($ENV{'browser.interface'} eq 'textual') {
- $output.=
- "window.status='Opening Remote Control';var swmenu=".&openmenu().
-"\nwindow.status='Configuring Remote Control ';";
- } else {
- unless ($textualoverride) { return ''; }
- }
- my $uname=$ENV{'user.name'};
- my $udom=$ENV{'user.domain'};
- my $adv=$ENV{'user.adv'};
- my $author=$ENV{'user.author'};
+ return '' unless $textualoverride;
+ my $uname=$env{'user.name'};
+ my $udom=$env{'user.domain'};
+ my $adv=$env{'user.adv'};
+ my $show_course=&Apache::loncommon::show_course();
+ my $author=$env{'user.author'};
my $crs='';
- if ($ENV{'request.course.id'}) {
- $crs='/'.$ENV{'request.course.id'};
- if ($ENV{'request.course.sec'}) {
- $crs.='_'.$ENV{'request.course.sec'};
+ my $crstype='';
+ if ($env{'request.course.id'}) {
+ $crs='/'.$env{'request.course.id'};
+ if ($env{'request.course.sec'}) {
+ $crs.='_'.$env{'request.course.sec'};
}
$crs=~s/\_/\//g;
+ $crstype = &Apache::loncommon::course_type();
}
- 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'};
- foreach (@desklines) {
- my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
+ 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'};
+ foreach my $line (@desklines) {
+ my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
$prt=~s/\$uname/$uname/g;
$prt=~s/\$udom/$udom/g;
- $prt=~s/\$crs/$crs/g;
+ if ($prt =~ /\$crs/) {
+ next unless ($env{'request.course.id'});
+ next if ($crstype eq 'Community');
+ $prt=~s/\$crs/$crs/g;
+ } elsif ($prt =~ /\$cmty/) {
+ next unless ($env{'request.course.id'});
+ next if ($crstype ne 'Community');
+ $prt=~s/\$cmty/$crs/g;
+ }
$prt=~s/\$requested_domain/$requested_domain/g;
+ if ($category_names{$cat}!~/\w/) { $cat='oth'; }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
} elsif ($pro eq 'smp') {
unless ($adv) {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro eq 'adv') {
if ($adv) {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
+ }
+ } elsif ($pro eq 'shc') {
+ if ($show_course) {
+ $output.=&secondlevel(
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
+ }
+ } elsif ($pro eq 'nsc') {
+ if (!$show_course) {
+ $output.=&secondlevel(
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
- } elsif (($pro=~/p(\w+)/) && ($prt)) {
- if (&Apache::lonnet::allowed($1,$prt)) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
- }
- } elsif ($pro eq 'course') {
- if ($ENV{'request.course.fn'}) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ } elsif (($pro=~/^p(\w+)/) && ($prt)) {
+ my $priv = $1;
+ if ($priv =~ /^mdc(Course|Community)/) {
+ if ($crstype eq $1) {
+ $priv = 'mdc';
+ } else {
+ next;
+ }
+ }
+ if (&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')) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
+ } elsif ($pro eq 'community') {
+ if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ } elsif ($pro =~ /^courseenv_(.*)$/) {
+ my $key = $1;
+ if ($crstype ne 'Community') {
+ my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
+ if ($key eq 'canuse_pdfforms') {
+ if ($env{'request.course.id'} && $coursepref eq '') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+ $coursepref = $domdefs{'canuse_pdfforms'};
+ }
+ }
+ if ($coursepref) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ }
+ } elsif ($pro =~ /^communityenv_(.*)$/) {
+ my $key = $1;
+ if ($crstype eq 'Community') {
+ my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
+ if ($key eq 'canuse_pdfforms') {
+ if ($env{'request.course.id'} && $coursepref eq '') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+ $coursepref = $domdefs{'canuse_pdfforms'};
+ }
+ }
+ if ($coursepref) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ }
+ } elsif ($pro =~ /^course_(.*)$/) {
+ # Check for permissions inside of a course
+ if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
+ (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
+ )) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ } elsif ($pro =~ /^community_(.*)$/) {
+ # Check for permissions inside of a community
+ if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
+ (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
+ )) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
} elsif ($pro eq 'author') {
if ($author) {
- if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
- (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
+ if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
+ (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
+ (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
# Check that we are on the correct machine
my $cadom=$requested_domain;
- my $caname=$ENV{'user.name'};
- if ($prt eq 'rca') {
+ my $caname=$env{'user.name'};
+ if (($prt eq 'rca') || ($prt eq 'raa')) {
($cadom,$caname)=
- ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
+ ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
}
$act =~ s/\$caname/$caname/g;
my $home = &Apache::lonnet::homeserver($caname,$cadom);
- if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
- $output.=switch($caname,$cadom,
- $row,$col,$img,$top,$bot,$act,$desc);
+ my $allowed=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ if ($allowed) {
+ $output.=&switch($caname,$cadom,
+ $row,$col,$img,$top,$bot,$act,$desc,$cat);
}
}
}
+ } elsif ($pro eq 'tools') {
+ my @tools = ('aboutme','blog','portfolio');
+ if (grep(/^\Q$prt\E$/,@tools)) {
+ if (!&Apache::lonnet::usertools_access($env{'user.name'},
+ $env{'user.domain'},
+ $prt,undef,'tools')) {
+ $output.=&clear($row,$col);
+ next;
+ }
+ } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
+ if (($prt eq 'reqcrsnsc') && ($show_course)) {
+ next;
+ }
+ if (($prt eq 'reqcrsshc') && (!$show_course)) {
+ next;
+ }
+ my $showreqcrs = &check_for_rcrs();
+ if (!$showreqcrs) {
+ $output.=&clear($row,$col);
+ next;
+ }
+ }
+ $prt='any';
+ $output.=&secondlevel(
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
}
- unless ($ENV{'browser.interface'} eq 'textual') {
- $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
- }
return $output;
}
-# ======================================================================= Close
+sub check_for_rcrs {
+ my $showreqcrs = 0;
+ my @reqtypes = ('official','unofficial','community');
+ foreach my $type (@reqtypes) {
+ if (&Apache::lonnet::usertools_access($env{'user.name'},
+ $env{'user.domain'},
+ $type,undef,'requestcourses')) {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ if (!$showreqcrs) {
+ foreach my $type (@reqtypes) {
+ if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ }
+ return $showreqcrs;
+}
-sub close {
- if ($ENV{'browser.interface'} eq 'textual') { return ''; }
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
- return(<
-window.status='Accessing Remote Control';
-menu=window.open("/adm/rat/empty.html","$menuname",
- "height=350,width=150,scrollbars=no,menubar=no");
-window.status='Disabling Remote Control';
-menu.active=0;
-menu.autologout=0;
-window.status='Closing Remote Control';
-menu.close();
-window.status='Done.';
-
-ENDCLOSE
+sub dc_popup_js {
+ my %lt = &Apache::lonlocal::texthash(
+ more => '(More ...)',
+ less => '(Less ...)',
+ );
+ return <<"END";
+
+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'}';
+ return;
}
-# ====================================================================== Footer
+function hideCourseID() {
+ document.getElementById('dccid').style.display='none';
+ document.getElementById('dccidtext').innerHTML ='$lt{'more'}';
+ return;
+}
-sub footer {
+END
}
-# ================================================ Handler when called directly
+sub utilityfunctions {
+ my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
+ 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 $dc_popup_cid;
+ if ($env{'user.adv'} && exists($env{'user.role.dc./'.
+ $env{'course.'.$env{'request.course.id'}.
+ '.domain'}.'/'})) {
+ $dc_popup_cid = &dc_popup_js();
+ }
+ my $start_page_annotate =
+ &Apache::loncommon::start_page('Annotator',undef,
+ {'only_body' => 1,
+ 'js_ready' => 1,
+ 'bgcolor' => '#BBBBBB',
+ 'add_entries' => {
+ 'onload' => 'javascript:document.goannotate.submit();'}});
+
+ 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 $end_page_bookmark =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
+return (<content_type('text/html');
- $r->send_http_header;
- return OK if $r->header_only;
+function gotop(url) {
+ if (url!='' && url!= null) {
+ top.location.href = url;
+ }
+}
- my $bodytag=&Apache::loncommon::bodytag('Main Menu');
-# ------------------------------------------------------------ Print the screen
- $r->print('LON-CAPA Main Menu'.$bodytag);
- $r->print(&rawconfig(1));
- $r->print(' |