--- loncom/interface/lonmenu.pm	2011/11/27 20:55:58	1.362
+++ loncom/interface/lonmenu.pm	2012/05/13 23:45:07	1.369.2.1
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.362 2011/11/27 20:55:58 www Exp $
+# $Id: lonmenu.pm,v 1.369.2.1 2012/05/13 23:45:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -428,7 +428,7 @@ sub innerregister {
 			     "gocmd('/adm/parmset','set')",
 			     'Content Settings');
 	}
-        if ($env{'request.symb'} ne '' &&
+        if ($env{'request.symb'}=~/^uploaded/ &&
             &Apache::lonnet::allowed('mdc',$crs)) {
             $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]',
                              "gocmd('/adm/coursedocs','direct')",
@@ -761,6 +761,164 @@ sub edit_course_upload {
     return $cfile;
 }
 
+sub startupremote {
+    my ($lowerurl)=@_;
+    if ($env{'environment.remote'} eq 'off') {
+     return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
+    }
+#
+# The Remote actually gets launched!
+#
+    my $configmenu=&rawconfig();
+    my $esclowerurl=&escape($lowerurl);
+    my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
+    return(<<ENDREMOTESTARTUP);
+<script type="text/javascript">
+// <![CDATA[
+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 (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();
+}
+
+// ]]>
+</script>
+ENDREMOTESTARTUP
+}
+
+sub setflags() {
+    return(<<ENDSETFLAGS);
+<script type="text/javascript">
+// <![CDATA[
+    menuloaded=0;
+    tim=0;
+// ]]>
+</script>
+ENDSETFLAGS
+}
+
+sub maincall() {
+    if ($env{'environment.remote'} eq 'off') { return ''; }
+    return(<<ENDMAINCALL);
+<script type="text/javascript">
+// <![CDATA[
+    main();
+// ]]>
+</script>
+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'
+                ,'<a href="/adm/remote?action=collapse&amp;url='.$esclowerurl.'">'
+                ,'</a>');
+    return(<<ENDREMOTEFORM);
+<p>
+<form name="wheel">
+<input name="spin" type="text" size="60" />
+</form>
+</p>
+<p>$link</p>
+ENDREMOTEFORM
+}
+
+sub get_menu_name {
+    my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
+    $hostid =~ s/\W//g;
+    return 'LCmenu'.$hostid;
+}
+
+
+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
+        '<script type="text/javascript">'."\n"
+       .'// <![CDATA['."\n"
+       .'self.name="loncapaclient";'."\n"
+       .'// ]]>'."\n"
+       .'</script>';
+    }
+    my $menuname = &get_menu_name();
+
+#    unless (shift eq 'unix') {
+# resizing does not work on linux because of virtual desktop sizes
+#       $returnval.=(<<ENDRESIZE);
+#if (window.screen) {
+#    self.resizeTo(screen.availWidth-215,screen.availHeight-55);
+#    self.moveTo(190,15);
+#}
+#ENDRESIZE
+#    }
+    $returnval=(<<ENDOPEN);
+// <![CDATA[
+window.status='Opening LON-CAPA Remote Control';
+var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
+"height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
+self.name='loncapaclient';
+// ]]>
+ENDOPEN
+    return '<script type="text/javascript">'.$returnval.'</script>';
+}
+
+
 # ================================================================== Raw Config
 
 sub clear {
@@ -1076,6 +1234,28 @@ sub check_for_rcrs {
     return $showreqcrs;
 }
 
+# ======================================================================= Close
+
+sub close {
+    if ($env{'environment.remote'} eq 'off') { return ''; }
+    my $menuname = &get_menu_name();
+    return(<<ENDCLOSE);
+<script type="text/javascript">
+// <![CDATA[
+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.';
+// ]]>
+</script>
+ENDCLOSE
+}
+
 sub dc_popup_js {
     my %lt = &Apache::lonlocal::texthash(
                                           more => '(More ...)',
@@ -1087,13 +1267,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 ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
+    document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
     return;
 }
 
 function hideCourseID() {
     document.getElementById('dccid').style.display='none';
-    document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
+    document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
     return;
 }
 
@@ -1132,12 +1312,14 @@ sub utilityfunctions {
     my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
                          &mt('Switch server?');
 
+    my $esc_url=&escape($currenturl);
+    my $esc_symb=&escape($currentsymb);
 
 return (<<ENDUTILITY)
 
-    var currentURL="$currenturl";
-    var reloadURL="$currenturl";
-    var currentSymb="$currentsymb";
+    var currentURL=unescape("$esc_url");
+    var reloadURL=unescape("$esc_url");
+    var currentSymb=unescape("$esc_symb");
 
 $dc_popup_cid
 
@@ -1230,7 +1412,7 @@ function golist(url) {
 
 
 function catalog_info() {
-   loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
+   openMyModal(window.location.pathname+'.meta',500,400,'yes');
 }
 
 function chat_win() {
@@ -1256,18 +1438,6 @@ function annotate() {
    annotator.document.close();
 }
 
-function set_wishlistlink(title, path) {
-    if (!title) {
-        title = document.title;
-        title = title.replace(/^LON-CAPA /,'');
-    }
-    if (!path) {
-        path = location.pathname;
-    }
-    Win = window.open('/adm/wishlist?mode=newLink&setTitle='+title+'&setPath='+path,
-                      'wishlistNewLink','width=560,height=350,scrollbars=0');
-}
-
 function open_Wishlist_Import(rat) {
    var newWin;
    if (rat) {
@@ -1668,11 +1838,13 @@ sub required_privs {
              '/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';
+        $privs->{'/adm/classcalc'}   = 'vgr',
+        $privs->{'/adm/assesscalc'}  = 'vgr',
+        $privs->{'/adm/studentcalc'} = 'vgr';
     }
     return $privs;
 }