-$inlineremote[21] $inlineremote[23]
-ENDARROWSINLINE
- if (&hidden_button_check() ne 'yes') {
- $inlinebuttons .= (<
-ENDINLINEICONS
- }
- } else {
- if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
- $inlinebuttons=(<$inlineremote[21] | | $inlineremote[23] |
-ENDFIRSTLINE
- }
- if (&hidden_button_check() ne 'yes') {
- foreach my $row (6..9) {
- if ($inlineremote[${row}.'1'] ne ''
- || $inlineremote[$row.'2'] ne ''
- || $inlineremote[$row.'3'] ne '') {
- $inlinebuttons .= <<"ENDLINE";
-$inlineremote["${row}1"] | $inlineremote["${row}2"] | $inlineremote["${row}3"] |
-ENDLINE
- }
- }
- }
- }
- }
- $result =(<
-// BEGIN LON-CAPA Internal
-
-$timesync
-$breadcrumb
-$tablestart
-$inlinebuttons
-$tableend
-$newmail
-
+ if ($addremote) {
-ENDREGTEXT
-# Registered, graphical output
- } else {
- my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
- my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
- my $navstatus=&get_nav_status();
- my $clearcstr;
-
- if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
- $result = (<
-// BEGIN LON-CAPA Internal
-var swmenu=null;
+ &Apache::lonhtmlcommon::clear_breadcrumb_tools();
- function LONCAPAreg() {
- swmenu=$reopen;
- swmenu.clearTimeout(swmenu.menucltim);
- $timesync
- $newmail
- $buttons
- swmenu.currentURL="$requri";
- swmenu.reloadURL=swmenu.currentURL+window.location.search;
- swmenu.currentSymb="$cursymb";
- swmenu.reloadSymb="$cursymb";
- swmenu.currentStale=0;
- $navstatus
- $hwkadd
- $editbutton
- }
-
- function LONCAPAstale() {
- swmenu=$reopen
- swmenu.currentStale=1;
- if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
- swmenu.switchbutton
- (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
- }
- swmenu.clearbut(7,2);
- swmenu.clearbut(7,3);
- swmenu.menucltim=swmenu.setTimeout(
- 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
- 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
- 2000);
- }
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'navigation', @inlineremote[21,23]);
-// END LON-CAPA Internal
-
-ENDREGTHIS
- }
-# =============================================================================
- } else {
-# ========================================== This can or will not be registered
- if ($noremote) {
-# Not registered
- $result= (<
-// BEGIN LON-CAPA Internal
-var swmenu=null;
-
- function LONCAPAreg() {
- swmenu=$reopen
- $timesync
- swmenu.currentStale=1;
- swmenu.clearbut(2,1);
- swmenu.clearbut(2,3);
- swmenu.clearbut(8,1);
- swmenu.clearbut(8,2);
- swmenu.clearbut(8,3);
- if (swmenu.currentURL) {
- swmenu.switchbutton
- (3,1,'reload.gif','return','location','go(currentURL)');
- } else {
- swmenu.clearbut(3,1);
- }
- }
-
- function LONCAPAstale() {
+ my @tools = @inlineremote[93,91,81,82,83];
+ if ($countdown) {
+ unshift(@tools,$countdown);
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'tools',@tools);
+
+ #publish button in construction space
+ if ($env{'request.state'} eq 'construct'){
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'advtools', $inlineremote[63]);
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'tools', $inlineremote[63]);
+ }
+ &advtools_crumbs(@inlineremote);
+ }
}
-// END LON-CAPA Internal
-
-ENDDONOTREGTHIS
- }
-# =============================================================================
- }
- return $result;
+ return &Apache::lonhtmlcommon::scripttag('', 'start')
+ . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
+ . &Apache::lonhtmlcommon::scripttag('', 'end');
}
-sub is_course_upload {
- my ($file,$cnum,$cdom) = @_;
- my $uploadpath = &LONCAPA::propath($cdom,$cnum);
- $uploadpath =~ s{^\/}{};
- if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
- ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
+sub get_editbutton {
+ my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
+ my $jscall;
+ if (($forceview) && ($env{'form.todocs'})) {
+ my ($folderpath,$command);
+ if ($env{'request.symb'}) {
+ $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
+ } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
+ $folderpath = $env{'form.folderpath'};
+ $command = '&forcesupplement=1';
+ }
+ $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
+ $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
+ } else {
+ $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
+ $forceedit,$forcereg,$env{'request.symb'},
+ &escape($env{'form.folderpath'}),
+ &escape($env{'form.title'}),$env{'form.idx'},
+ &escape($env{'form.suppurl'},$env{'form.todocs'}));
+ }
+ if ($jscall) {
+ my $icon = 'pcstr.png';
+ my $label = 'Edit';
+ if ($forceview) {
+ $icon = 'tolastloc.png';
+ $label = 'Exit Editing';
+ }
+ &switch('','',6,1,$icon,$label,'resource[_2]',
+ $jscall,"Edit this resource");
return 1;
}
return;
}
-sub edit_course_upload {
- my ($file,$cnum,$cdom) = @_;
- my $cfile;
- if ($file =~/\.(htm|html|css|js|txt)$/) {
- my $ext = $1;
- my $url = &Apache::lonnet::hreflocation('',$file);
- my $home = &Apache::lonnet::homeserver($cnum,$cdom);
- my @ids=&Apache::lonnet::current_machine_ids();
- my $dest;
- if ($home && grep(/^\Q$home\E$/,@ids)) {
- $dest = $url.'?forceedit=1';
- } else {
- unless (&Apache::lonnet::get_locks()) {
- $dest = '/adm/switchserver?otherserver='.
- $home.'&role='.$env{'request.role'}.
- '&url='.$url.'&forceedit=1';
- }
- }
- if ($dest) {
- $cfile = &HTML::Entities::encode($dest,'"<>&');
- }
+sub prepare_functions {
+ my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
+ unless ($env{'request.registered'}) {
+ undef(@inlineremote);
}
- return $cfile;
-}
-
-sub loadevents() {
- if ($env{'request.state'} eq 'construct' ||
- $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
- return 'LONCAPAreg();';
-}
-
-sub unloadevents() {
- if ($env{'request.state'} eq 'construct' ||
- $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
- return 'LONCAPAstale();';
-}
-
+ my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
+ $forceview);
-sub startupremote {
- my ($lowerurl)=@_;
- if ($env{'environment.remote'} eq 'off') {
- return ('');
+ if ($env{'request.course.id'}) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
}
+
+ my $editbutton = '';
#
-# The Remote actually gets launched!
+# Determine whether or not to display 'Edit' icon/button
#
- my $configmenu=&rawconfig();
- my $esclowerurl=&escape($lowerurl);
- my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
- return(<
-var timestart;
-function wheelswitch() {
- if (typeof(document.wheel) != 'undefined') {
- if (typeof(document.wheel.spin) != 'undefined') {
- var date=new Date();
- var waited=Math.round(30-((date.getTime()-timestart)/1000));
- document.wheel.spin.value=$message;
- }
+ if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
+ my $file=&Apache::lonnet::declutter($env{'request.filename'});
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
+ &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
+ if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg);
+ }
+ } elsif ((!$env{'request.course.id'}) &&
+ ($env{'user.author'}) && ($env{'request.filename'}) &&
+ ($env{'request.role'} !~/^(aa|ca|au)/)) {
+#
+# Currently do not have the role of author or co-author.
+# Do we have authoring privileges for the resource?
+#
+ my $file=&Apache::lonnet::declutter($env{'request.filename'});
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
+ &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
+ if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg);
+ }
+ } elsif ($env{'request.course.id'}) {
+#
+# This applies in course context
+#
+ if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) {
+ if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
+ &switch('','',6,1,'pcstr.png','Edit',
+ 'resource[_2]',
+ "go('/adm/courseprefs?phase=display&actions=courseinfo')",
+ 'Edit this resource');
+ $editbutton = 1;
+ } else {
+ $cfile = $resurl;
+ $home = &Apache::lonnet::homeserver($cnum,$cdom);
+ if ($env{'form.forceedit'}) {
+ $forceview = 1;
+ } else {
+ $forceedit = 1;
+ }
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg);
+ }
+ } elsif (($resurl eq '/adm/extresedit') &&
+ (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
+ $env{'form.symb'});
+ if ($cfile ne '') {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg,
+ $env{'form.title'},$env{'form.suppurl'});
+ }
+ } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
+ (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
+ $env{'form.symb'});
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg);
+ } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
+ ($resurl ne '/cgi-bin/printout.pl')) {
+ if ($env{'request.filename'}) {
+ my $file=&Apache::lonnet::declutter($env{'request.filename'});
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
+ &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
+ if ($cfile ne '') {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg);
+ }
+ }
+ }
}
- if (window.status=='|') {
- window.status='/';
- } else {
- if (window.status=='/') {
- window.status='-';
- } else {
- if (window.status=='-') {
- window.status='\\\\';
- } else {
- if (window.status=='\\\\') { window.status='|'; }
- }
- }
- }
-}
-
-// ---------------------------------------------------------- The wait function
-var canceltim;
-function wait() {
- if ((menuloaded==1) || (tim==1)) {
- window.status='Done.';
- if (tim==0) {
- clearTimeout(canceltim);
- $configmenu
- window.location='$lowerurl';
- } else {
- window.location='/adm/remote?action=collapse&url=$esclowerurl';
- }
- } else {
- wheelswitch();
- setTimeout('wait();',200);
- }
-}
-
-function main() {
- canceltim=setTimeout('tim=1;',30000);
- window.status='-';
- var date=new Date();
- timestart=date.getTime();
- wait();
-}
+# End determination of 'Edit' icon/button display
-
-ENDREMOTESTARTUP
-}
-
-sub setflags() {
- return(<
- menuloaded=0;
- tim=0;
-
-ENDSETFLAGS
-}
-
-sub maincall() {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- return(<
- main();
-
-ENDMAINCALL
-}
-
-sub load_remote_msg {
- my ($lowerurl)=@_;
-
- if ($env{'environment.remote'} eq 'off') { return ''; }
-
- my $esclowerurl=&escape($lowerurl);
- my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
- ,''
- ,'');
- return(<
-
-
-$link
-ENDREMOTEFORM
-}
+ if ($env{'request.course.id'}) {
+# This applies to about me page for users in a course
+ if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
+ my ($sdom,$sname) = ($1,$2);
+ unless (&Apache::lonnet::is_course($sdom,$sname)) {
+ &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
+ '',
+ "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
+ 'Send message to specific user');
+ }
+ my $hideprivileged = 1;
+ if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
+ $hideprivileged)) {
+ foreach my $priv ('vsa','vgr','srm') {
+ $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
+ if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
+ $perms{$priv} =
+ &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
+ }
+ }
+ if ($perms{'vsa'}) {
+ &switch('','',6,5,'trck-22x22.png','Activity',
+ '',
+ "go('/adm/trackstudent?selected_student=$sname:$sdom')",
+ 'View recent activity by this person');
+ }
+ if ($perms{'vgr'}) {
+ &switch('','',6,6,'rsrv-22x22.png','Reservations',
+ '',
+ "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
+ 'Slot reservation history');
+ }
+ if ($perms{'srm'}) {
+ &switch('','',6,7,'contact-new-22x22.png','Records',
+ '',
+ "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
+ 'Add records');
+ }
+ }
+ }
+ if (($env{'form.folderpath'} =~ /^supplemental/) &&
+ (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
+ (($resurl =~ m{^/adm/wrapper/ext/}) ||
+ ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
+ ($resurl eq '/adm/supplemental') ||
+ ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
+ ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
+ my @folders=split('&',$env{'form.folderpath'});
+ if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
+ my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
+ &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
+ "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+ 'Folder/Page Content');
+ }
+ }
+ }
-sub get_menu_name {
- my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
- $hostid =~ s/\W//g;
- return 'LCmenu'.$hostid;
+# End checking for items for about me page for users in a course
+ if ($docscrumbs) {
+ &Apache::lonhtmlcommon::clear_breadcrumb_tools();
+ &advtools_crumbs(@inlineremote);
+ return $editbutton;
+ } elsif ($env{'request.registered'}) {
+ return $editbutton;
+ } else {
+ if (ref($bread_crumbs) eq 'ARRAY') {
+ if (@inlineremote > 0) {
+ if (ref($advtools) eq 'ARRAY') {
+ @{$advtools} = @inlineremote;
+ }
+ }
+ return;
+ } elsif (@inlineremote > 0) {
+ &Apache::lonhtmlcommon::clear_breadcrumb_tools();
+ &advtools_crumbs(@inlineremote);
+ return &Apache::lonhtmlcommon::scripttag('', 'start')
+ . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
+ . &Apache::lonhtmlcommon::scripttag('', 'end');
+ }
+ }
}
-
-sub reopenmenu {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
- return('window.open('.$nothing.',"'.$menuname.'","",false);');
-}
-
-
-sub open {
- my $returnval='';
- if ($env{'environment.remote'} eq 'off') {
- return '';
+sub advtools_crumbs {
+ my @funcs = @_;
+ if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'advtools', @funcs[61,64,65,66,67,74]);
+ } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'advtools', @funcs[61,71,72,73,74,92]);
+ } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'advtools', $funcs[61]);
}
- my $menuname = &get_menu_name();
-
-# unless (shift eq 'unix') {
-# resizing does not work on linux because of virtual desktop sizes
-# $returnval.=(<'.$returnval.'';
}
-
# ================================================================== Raw Config
sub clear {
my ($row,$col)=@_;
- unless ($env{'environment.remote'} eq 'off') {
- return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
- } else {
- $inlineremote[10*$row+$col]='';
- return '';
- }
+ $inlineremote[10*$row+$col]='';
+ return '';
}
# ============================================ Switch a button or create a link
@@ -985,31 +1012,20 @@ sub switch {
$top=&mt($top);
$bot=&mt($bot);
$desc=&mt($desc);
- if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
- $img=&mt($img);
- }
my $idx=10*$row+$col;
$category_members{$cat}.=':'.$idx;
- unless ($env{'environment.remote'} eq 'off') {
-# Remote
- return "\n".
- qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
- } else {
-# Inline Remote
- if ($env{'environment.icons'} ne 'classic') {
- $img=~s/\.gif$/\.png/;
- }
- if ($nobreak==2) { return ''; }
- my $text=$top.' '.$bot;
- $text=~s/\s*\-\s*//gs;
+# Inline Menu
+ if ($nobreak==2) { return ''; }
+ my $text=$top.' '.$bot;
+ $text=~s/\s*\-\s*//gs;
- my $pic=
+ my $pic=
'';
- if ($env{'browser.interface'} eq 'faketextual') {
-# Accessibility
+ '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
+ if ($env{'browser.interface'} eq 'faketextual') {
+# Main Menu
if ($nobreak==3) {
$inlineremote[$idx]="\n".
'';
}
- } else {
+ } else {
# Inline Menu
- if ($env{'environment.icons'} eq 'iconsonly') {
- $inlineremote[$idx]=''.$pic.'';
- } else {
- $inlineremote[$idx]=
- '';
- }
- }
- }
+ my @tools = (93,91,81,82,83);
+ unless ($env{'request.state'} eq 'construct') {
+ push(@tools,63);
+ }
+ if (($env{'environment.icons'} eq 'iconsonly') &&
+ (grep(/^$idx$/,@tools))) {
+ $inlineremote[$idx] =
+ '';
+ } else {
+ $inlineremote[$idx] =
+ '';
+ }
+ }
return '';
}
@@ -1055,26 +1076,20 @@ sub secondlevel {
return $output;
}
-sub openmenu {
- my $menuname = &get_menu_name();
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
- return "window.open(".$nothing.",'".$menuname."');";
-}
-
sub inlinemenu {
undef(@inlineremote);
undef(%category_members);
+# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
&rawconfig(1);
- my $output='';
+ 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.=' ';
+ $output.=' '.&mt($category_names{$cat}).'';
$output.=' ';
my %active=();
foreach my $menu_item (split(/\:/,$category_members{$cat})) {
@@ -1096,27 +1111,28 @@ sub inlinemenu {
}
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{'environment.remote'} eq 'off') {
- $output.=
- "window.status='Opening Remote Control';var swmenu=".&openmenu().
-"\nwindow.status='Configuring Remote Control ';";
- } else {
- unless ($textualoverride) { return ''; }
- }
+ 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='';
+ 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');
@@ -1126,13 +1142,17 @@ sub rawconfig {
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'; }
- my $type = &Apache::loncommon::course_type();
- if ($type eq 'Group') {
- $desc = &convert_menu_function($desc,$type);
- }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
@@ -1159,26 +1179,69 @@ sub rawconfig {
$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)) {
+ 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'}) {
+ } 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 ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
- $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ 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'}) &&
+ 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/)) ||
@@ -1192,6 +1255,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();
@@ -1211,16 +1275,14 @@ sub rawconfig {
$output.=&clear($row,$col);
next;
}
- } elsif ($prt eq 'reqcrs') {
- my $showreqcrs = 0;
- foreach my $type ('official','unofficial') {
- if (&Apache::lonnet::usertools_access($env{'user.name'},
- $env{'user.domain'},
- $type,undef,'requestcourses')) {
- $showreqcrs = 1;
- last;
- }
+ } 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;
@@ -1231,70 +1293,93 @@ 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");';
- }
- }
-
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{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- 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 ='';
+ return;
}
-# ====================================================================== Footer
+function hideCourseID() {
+ document.getElementById('dccid').style.display='none';
+ document.getElementById('dccidtext').innerHTML ='';
+ return;
+}
-sub footer {
+END
}
-sub nav_control_js {
- my $nav=($env{'environment.remotenavmap'} eq 'on');
- return (< 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);
+
+ my $countdown = &countdown_toggle_js();
return (<'
- +'$end_page_bookmark' );
- bmquery.document.close();
+function open_StoredLinks_Import(rat) {
+ var newWin;
+ if (rat) {
+ newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
+ 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
+ }
+ else {
+ newWin = window.open('/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
}
@@ -1491,36 +1568,10 @@ sub constspaceform {
ENDCONSTSPACEFORM
}
-
-sub get_nav_status {
- my $navstatus="swmenu.w_loncapanav_flag=";
- if ($env{'environment.remotenavmap'} eq 'on') {
- $navstatus.="1";
- } else {
- $navstatus.="-1";
- }
- return $navstatus;
-}
-
-#FIXME this needs to move into mydesktab and the other locations
-# the text is generated
-sub convert_menu_function {
- my ($rolename,$type) = @_;
- if ($type eq 'Group') {
- $rolename =~ s/student/member/g;
- $rolename =~ s/group/team/g;
- $rolename =~ s/course/group/g;
- $rolename =~ s/Course/Group/g;
- }
- return $rolename;
-}
-
sub hidden_button_check {
- my $hidden;
- if ($env{'request.course.id'} eq '') {
- return;
- }
- if ($env{'request.role.adv'}) {
+ if ( $env{'request.course.id'} eq ''
+ || $env{'request.role.adv'} ) {
+
return;
}
my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
@@ -1529,12 +1580,43 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
+ my $crstype = &Apache::loncommon::course_type();
my $now = time;
- my (%courseroles,%seccount);
+ my (%courseroles,%seccount,%courseprivs);
my $is_cc;
- my $role_selector;
- if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
- my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum});
+ 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});
if ((($start) && ($start<0)) ||
(($end) && ($end<$now)) ||
@@ -1545,7 +1627,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)) {
@@ -1561,6 +1643,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}})) {
@@ -1578,36 +1672,76 @@ sub roles_selector {
}
}
}
- my @roles_order = ('cc','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) =
@@ -1615,9 +1749,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;
}
}
@@ -1645,30 +1781,43 @@ 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));
}
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') {
@@ -1691,13 +1840,44 @@ sub jump_to_role {
' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
}
}
- my $output = <<"END";
+ 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";
END
- return $output;
}
+sub required_privs {
+ my $privs = {
+ '/adm/parmset' => 'opa',
+ '/adm/courseprefs' => 'opa',
+ '/adm/whatsnew' => 'whn',
+ '/adm/populate' => 'cst',
+ '/adm/trackstudent' => 'vsa',
+ '/adm/statistics' => 'vgr',
+ '/adm/setblock' => 'dcm',
+ '/adm/coursedocs' => 'mdc',
+ };
+ unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
+ $privs->{'/adm/classcalc'} = 'vgr',
+ $privs->{'/adm/assesscalc'} = 'vgr',
+ $privs->{'/adm/studentcalc'} = 'vgr';
+ }
+ return $privs;
+}
+
+sub countdown_timer {
+ if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
+ ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
+ my ($type,$hastimeleft,$slothastime);
+ my $now = time;
+ if ($env{'request.filename'} =~ /\.task$/) {
+ $type = 'Task';
+ } else {
+ $type = 'problem';
+ }
+ my ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0',$type);
+ if ($slot_name ne '') {
+ if (ref($slot) eq 'HASH') {
+ if (($slot->{'starttime'} < $now) &&
+ ($slot->{'endtime'} > $now)) {
+ $slothastime = 1;
+ }
+ }
+ }
+ if ($status ne 'CAN_ANSWER') {
+ return;
+ }
+ my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ if (@interval > 1) {
+ my $first_access=&Apache::lonnet::get_first_access($interval[1]);
+ if ($first_access > 0) {
+ if ($first_access+$interval[0] > time) {
+ $hastimeleft = 1;
+ }
+ }
+ }
+ if (($duedate && $duedate > time) ||
+ (!$duedate && $hastimeleft) ||
+ ($slot_name ne '' && $slothastime)) {
+ my ($collapse,$expand,$alttxt,$title,$currdisp);
+ if ((@interval > 1 && $hastimeleft) ||
+ ($type eq 'Task' && $slothastime)) {
+ $currdisp = 'inline';
+ $collapse = '► ';
+ } else {
+ $currdisp = 'none';
+ $expand = '◄ ';
+ }
+ unless ($env{'environment.icons'} eq 'iconsonly') {
+ $alttxt = &mt('Timer');
+ $title = $alttxt.' ';
+ }
+ my $desc = &mt('Countdown to due date/time');
+ return <
|
|