-#$inlineremote[21] $inlineremote[23]
-#ENDARROWSINLINE
-# if ( &hidden_button_check() ne 'yes' ) {
-# $inlinebuttons .= (<
-#ENDINLINEICONS
-# }
-# } else { # not iconsonly
-# 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
-# }
-# }
-# }
-# }
- }
- #SD see below
- $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
- $result =(<
-// BEGIN LON-CAPA Internal
-
-$timesync
-$breadcrumb
-
-
-
-$newmail
-
-
+ &Apache::lonhtmlcommon::clear_breadcrumb_tools();
-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 = (<
-//
-
-ENDREGTHIS
- }
-# =============================================================================
- } else {
-# ========================================== This can or will not be registered
- if ($noremote) {
-# Not registered
- $result= (<
-//
-
-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();';
-}
+ my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
+ $forceview);
-sub unloadevents() {
- if ($env{'request.state'} eq 'construct' ||
- $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
- return 'LONCAPAstale();';
-}
-
-
-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(<
-//
-
-ENDREMOTESTARTUP
-}
-
-sub setflags() {
- return(<
-//
-
-ENDSETFLAGS
-}
-
-sub maincall() {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- return(<
-//
-
-ENDMAINCALL
-}
+# End determination of 'Edit' icon/button display
-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.=(<
-ENDOPEN
- return '';
}
-
# ================================================================== Raw Config
sub clear {
my ($row,$col)=@_;
- unless ($env{'environment.remote'} eq 'off') {
- if (($row<1) || ($row>13)) { return ''; }
- 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
@@ -1298,31 +1012,19 @@ 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') {
- if (($row<1) || ($row>13)) { return ''; }
-# 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') {
+ if ($env{'browser.interface'} eq 'faketextual') {
# Main Menu
if ($nobreak==3) {
$inlineremote[$idx]="\n".
@@ -1341,17 +1043,22 @@ sub switch {
' | ';
}
- } 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 '';
}
@@ -1369,100 +1076,37 @@ 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 {
- my ($context,$switcher) = @_;
undef(@inlineremote);
undef(%category_members);
- my $output;
- if (($context eq 'gcicustom') || ($context eq 'gcistudent') ||
- ($context eq 'gcinorole')) {
- $output=''.
- ''.
- ' | '.
- ''.
- ' | ';
- } else {
- my $navtext = &mt('Table of Contents');
- if ($env{'request.role.domain'} eq 'gcitest') {
- $navtext = &mt('Display Test Contents');
- }
- $output .= '
|
';
- }
- } else {
- $output.='';
- }
- if ($context eq 'gcinorole') {
- my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle');
- if ($queued) {
- $output .= ''.
- ' '.
- ' '.&mt('Pending Enrollment Requests').''.
- $queued.
- ' | ';
+# 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.=' ';
- } else {
- # calling rawconfig with "1" will evaluate mydesk.tab,
- # even if there is no active remote control
- &rawconfig(1);
- $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.=' '.&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;
}
@@ -1474,13 +1118,7 @@ sub rawconfig {
#
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'};
@@ -1617,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();
@@ -1654,13 +1293,6 @@ 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;
}
@@ -1686,51 +1318,6 @@ sub check_for_rcrs {
return $showreqcrs;
}
-# ======================================================================= Close
-
-sub close {
- if ($env{'environment.remote'} eq 'off') { return ''; }
- my $menuname = &get_menu_name();
- return(<
-//
-
-ENDCLOSE
-}
-
-# ====================================================================== Footer
-
-sub footer {
-
-}
-
-sub nav_control_js {
- my $nav=($env{'environment.remotenavmap'} eq 'on');
- return (< '(More ...)',
@@ -1742,13 +1329,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;
}
@@ -1756,62 +1343,36 @@ 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';
+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 $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./'.
@@ -1831,39 +1392,22 @@ 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);
+
+ 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
}
@@ -2024,27 +1568,12 @@ 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;
-}
-
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;
}
@@ -2053,15 +1582,39 @@ 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;
+ 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});
@@ -2074,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)) {
@@ -2090,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}})) {
@@ -2107,42 +1672,76 @@ sub roles_selector {
}
}
}
- my $switchtext;
if ($crstype eq 'Community') {
- $switchtext = &mt('Switch community role to...')
+ $switchtext = &mt('Switch community role')
} else {
- $switchtext = &mt('Switch course role to...')
+ $switchtext = &mt('Switch course role')
}
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) =
@@ -2150,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;
}
}
@@ -2180,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') {
@@ -2226,14 +1840,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";