Annotation of loncom/interface/lonmenu.pm, revision 1.55
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.55 ! www 4: # $Id: lonmenu.pm,v 1.54 2003/04/03 21:32:23 www Exp $
1.11 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 www 28: #
1.48 www 29: # There are two parameters controlling the action of this module:
30: #
31: # browser.interface - if this is 'textual', it overrides the second parameter
32: # and goes to screen reader PDA mode
33: #
34: # environment.remote - if this is 'on', the routines controll the remote
35: # control, otherwise they render the main window controls; ignored it
36: # browser.interface is 'textual'
1.1 www 37: #
38:
39: package Apache::lonmenu;
40:
41: use strict;
1.2 www 42: use Apache::lonnet;
1.33 www 43: use Apache::Constants qw(:common);
1.47 matthew 44: use Apache::lonhtmlcommon();
1.33 www 45: use Apache::loncommon;
1.2 www 46: use Apache::File;
47: use vars qw(@desklines $readdesk);
1.38 www 48:
1.40 www 49: # ============================= This gets called at the top of the body section
1.38 www 50:
51: sub menubuttons {
52: my $forcereg=shift;
53: my $target =shift;
1.40 www 54: my $registration=shift;
1.55 ! www 55: my $navmaps='';
! 56: my $escurl=&Apache::lonnet::escape($ENV{'REQUEST_URI'});
! 57: my $escsymb=&Apache::lonnet::escape($ENV{'request.symb'});
1.48 www 58: if ($ENV{'browser.interface'} eq 'textual') {
1.41 www 59: # Textual display only
1.55 ! www 60: if ($ENV{'request.course.id'}) {
! 61: $navmaps=(<<ENDNAV);
! 62: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">Navigate Contents</a>
! 63: ENDNAV
! 64: }
1.48 www 65: my $output=(<<ENDMAINMENU);
1.44 www 66: <script>
67: // BEGIN LON-CAPA Internal
68: </script>
1.55 ! www 69: <a href="/adm/menu" target="_top">Main Menu</a>
! 70: $navmaps<br />
1.44 www 71: <script>
72: // END LON-CAPA Internal
73: </script>
74: ENDMAINMENU
1.48 www 75: if ($registration) { $output.=&innerregister($forcereg,$target); }
76: return $output."<hr />";
77: } elsif ($ENV{'environment.remote'} eq 'off') {
78: # Remote Control is switched off
1.55 ! www 79: if ($ENV{'request.course.id'}) {
! 80: $navmaps=(<<ENDNAVREM);
! 81: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">Navigate Contents</a>
! 82: ENDNAVREM
! 83: }
1.48 www 84: my $output=(<<ENDINLINEMENU);
85: <script>
86: // BEGIN LON-CAPA Internal
87: </script>
1.54 www 88: <table bgcolor="#AAAAAA" width="100%" border="2"><tr><td>
1.48 www 89: <a href="/adm/menu" target="_top">Main Menu</a>
1.55 ! www 90: $navmaps
1.54 www 91: <a href="/adm/remote?action=launch&url=$escurl" target="_top">Launch Remote Control</a>
1.53 www 92: <br />
1.48 www 93: <script>
94: // END LON-CAPA Internal
95: </script>
96: ENDINLINEMENU
97: if ($registration) { $output.=&innerregister($forcereg,$target); }
1.54 www 98: return $output."</td></tr></table>";
1.48 www 99: } else {
100: return '';
101: }
1.38 www 102: }
103:
1.40 www 104: # ====================================== This gets called in the header section
1.38 www 105:
106: sub registerurl {
107: my $forcereg=shift;
108: my $target = shift;
109: my $result = '';
110:
111: if ($target eq 'edit') {
1.45 www 112: $result .="<script type=\"text/javascript\">\n".
1.38 www 113: "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
114: &Apache::loncommon::browser_and_searcher_javascript().
115: "\n</script>\n";
116: }
117: if (($ENV{'browser.interface'} eq 'textual') ||
1.53 www 118: ($ENV{'environment.remote'} eq 'off') ||
1.38 www 119: ((($ENV{'request.publicaccess'}) ||
120: (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) &&
121: (!$forcereg))) {
122: return $result.
123: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>';
124: }
1.41 www 125: # Graphical display after login only
1.38 www 126: if ($Apache::lonxml::registered && !$forcereg) { return ''; }
1.40 www 127: $result.=&innerregister($forcereg,$target);
128: return $result;
129: }
130:
131: # =========== This gets called in order to register a URL, both with the Remote
132: # =========== and in the body of the document
133:
134: sub innerregister {
135: my $forcereg=shift;
136: my $target = shift;
137: my $result = '';
138:
1.38 www 139: $Apache::lonxml::registered=1;
1.40 www 140:
1.49 www 141: my $textinter=($ENV{'browser.interface'} eq 'textual');
142: my $noremote=($ENV{'environment.remote'} eq 'off');
143:
144: my $textual=($textinter || $noremote);
145:
1.38 www 146: my $reopen=&Apache::lonmenu::reopenmenu();
1.40 www 147:
1.38 www 148: my $newmail='';
149: if (&Apache::lonmsg::newmail()) {
1.41 www 150: $newmail=($textual?
151: '<b><a href="/adm/communicate">You have new messages</a></b><br />':
1.40 www 152: 'swmenu.setstatus("you have","messages");');
1.38 www 153: }
1.40 www 154: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
1.41 www 155: # =============================================================================
156: # ============================ This is for URLs that actually can be registered
1.38 www 157: if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
1.40 www 158: # -- This applies to homework problems for users with grading privileges
1.38 www 159: my $hwkadd='';
1.40 www 160: if
161: ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
1.38 www 162: if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
1.40 www 163: $hwkadd.=&switch('','',7,1,'subm.gif','view sub','missions',
164: "gocmd('/adm/grades','submission')",
165: 'View user submissions for this assessment resource');
1.38 www 166: }
167: if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
1.40 www 168: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades',
169: "gocmd('/adm/grades','gradingmenu')",
170: 'Modify user grades for this assessment resource');
1.38 www 171: }
172: if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
1.40 www 173: $hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms',
174: "gocmd('/adm/parmset','set')",
175: 'Modify deadlines, etc, for this assessment resource');
1.38 www 176: }
177: }
1.40 www 178: # -- End Homework
1.38 www 179: ###
180: ### Determine whether or not to display the 'cstr' button for this
181: ### resource
182: ###
183: my $editbutton = '';
184: if ($ENV{'user.author'}) {
185: if ($ENV{'request.role'}=~/^(ca|au)/) {
186: # Set defaults for authors
187: my ($top,$bottom) = ('con-','struct');
188: my $action = "go('/priv/".$ENV{'user.name'}."');";
189: my $cadom = $ENV{'request.role.domain'};
190: my $caname = $ENV{'user.name'};
191: my $desc = "Enter my resource construction space";
192: # Set defaults for co-authors
193: if ($ENV{'request.role'} =~ /^ca/) {
194: ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
195: ($top,$bottom) = ('co con-','struct');
196: $action = "go('/priv/".$caname."');";
197: $desc = "Enter construction space as co-author";
198: }
199: # Check that we are on the correct machine
200: my $home = &Apache::lonnet::homeserver($caname,$cadom);
201: if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.40 www 202: $editbutton=&switch
1.38 www 203: ('','',6,1,$top,,$bottom,$action,$desc);
204: }
205: }
206: ##
207: ## Determine if user can edit url.
208: ##
209: my $cfile='';
210: my $cfuname='';
211: my $cfudom='';
212: if ($ENV{'request.filename'}) {
213: my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
214: $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
215: # Chech that the user has permission to edit this resource
216: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
217: if (defined($cfudom)) {
218: if (&Apache::lonnet::homeserver($cfuname,$cfudom)
219: eq $Apache::lonnet::perlvar{'lonHostID'}) {
220: $cfile=$file;
221: }
222: }
223: }
224: # Finally, turn the button on or off
225: if ($cfile) {
1.40 www 226: $editbutton=&switch
1.38 www 227: ('','',6,1,'cstr.gif','edit','resource',
228: "go('".$cfile."');","Edit this resource");
229: } elsif ($editbutton eq '') {
1.40 www 230: $editbutton=&clear(6,1);
1.38 www 231: }
232: }
233: ###
234: ###
1.41 www 235: # Prepare the rest of the buttons
236: my $menuitems=(<<ENDMENUITEMS);
237: c&3&1
238: s&2&1&back.gif&backward&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
239: s&2&3&forw.gif&forward&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&1
240: s&6&3&catalog.gif&catalog&info&catalog_info()&Show catalog information
241: s&8&1&eval.gif&evaluate&this&gopost('/adm/evaluate',currentURL)&Provide my evaluation of this resource
242: s&8&2&fdbk.gif&feedback&discuss&gopost('/adm/feedback',currentURL)&Provide feedback messages or contribute to the course discussion about this resource
243: s&8&3&prt.gif&prepare&printout&gopost('/adm/printout',currentURL)&Prepare a printable document
244: s&9&1&sbkm.gif&set&bookmark&set_bookmark()&Set a bookmark for this resource&2
245: s&9&2&vbkm.gif&view&bookmark&edit_bookmarks()&Use or edit my bookmark collection&2
246: s&9&3&anot.gif&anno-&tations&annotate()&Make notes and annotations about this resource&2
247: ENDMENUITEMS
248: my $buttons='';
249: foreach (split(/\n/,$menuitems)) {
250: my ($command,@rest)=split(/\&/,$_);
251: if ($command eq 's') {
252: $buttons.=&switch('','',@rest);
253: } else {
254: $buttons.=&clear(@rest);
255: }
256: }
257: if ($textual) {
258: # Registered, textual output
1.42 www 259: my $utility=&utilityfunctions();
260: my $form=&serverform();
1.41 www 261: $result =(<<ENDREGTEXT);
1.42 www 262: <script>
263: // BEGIN LON-CAPA Internal
264: $utility
265: </script>
1.41 www 266: $timesync
267: $newmail
268: $buttons
269: $hwkadd
270: $editbutton
1.42 www 271: $form
272: <script>
273: //END LON-CAPA Internal
274: </script>
275:
1.41 www 276: ENDREGTEXT
277: # Registered, graphical output
278: } else {
279: $result = (<<ENDREGTHIS);
1.38 www 280:
281: <script language="JavaScript">
282: // BEGIN LON-CAPA Internal
1.42 www 283: var swmenu=null;
1.38 www 284:
285: function LONCAPAreg() {
286: swmenu=$reopen;
287: swmenu.clearTimeout(swmenu.menucltim);
288: $timesync
289: $newmail
1.41 www 290: $buttons
1.38 www 291: swmenu.currentURL=window.location.pathname;
1.46 www 292: swmenu.reloadURL=window.location.pathname+window.location.search;
1.38 www 293: swmenu.currentSymb="$ENV{'request.symb'}";
294: swmenu.reloadSymb="$ENV{'request.symb'}";
295: swmenu.currentStale=0;
296: $hwkadd
297: $editbutton
298: }
299:
300: function LONCAPAstale() {
301: swmenu=$reopen
302: swmenu.currentStale=1;
303: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
304: swmenu.switchbutton
305: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
306: }
307: swmenu.clearbut(7,1);
308: swmenu.clearbut(7,2);
309: swmenu.clearbut(7,3);
310: swmenu.menucltim=swmenu.setTimeout(
311: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
312: 'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3);clearbut(6,1)',
313: 2000);
314:
315: }
316:
317: // END LON-CAPA Internal
318: </script>
319: ENDREGTHIS
1.41 www 320: }
321: # =============================================================================
1.38 www 322: } else {
1.41 www 323: # ========================================== This can or will not be registered
324: if ($textual) {
325: # Not registered, textual
326: $result= (<<ENDDONOTREGTEXT);
327: ENDDONOTREGTEXT
328: } else {
329: # Not registered, graphical
330: $result = (<<ENDDONOTREGTHIS);
1.38 www 331:
332: <script language="JavaScript">
333: // BEGIN LON-CAPA Internal
1.42 www 334: var swmenu=null;
1.38 www 335:
336: function LONCAPAreg() {
337: swmenu=$reopen
338: $timesync
339: swmenu.currentStale=1;
340: swmenu.clearbut(2,1);
341: swmenu.clearbut(2,3);
342: swmenu.clearbut(8,1);
343: swmenu.clearbut(8,2);
344: swmenu.clearbut(8,3);
345: if (swmenu.currentURL) {
346: swmenu.switchbutton
347: (3,1,'reload.gif','return','location','go(currentURL)');
348: } else {
349: swmenu.clearbut(3,1);
350: }
351: }
352:
353: function LONCAPAstale() {
354: }
355:
356: // END LON-CAPA Internal
357: </script>
358: ENDDONOTREGTHIS
1.41 www 359: }
360: # =============================================================================
1.38 www 361: }
362: return $result;
363: }
364:
365: sub loadevents() {
366: return 'LONCAPAreg();';
367: }
368:
369: sub unloadevents() {
370: return 'LONCAPAstale();';
371: }
1.30 www 372:
1.32 www 373: # ============================================================= Start up remote
374:
375: sub startupremote {
376: my ($lowerurl)=@_;
1.49 www 377: if (($ENV{'browser.interface'} eq 'textual') ||
378: ($ENV{'environment.remote'} eq 'off')) {
1.34 www 379: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
380: }
1.49 www 381: #
382: # The Remote actually gets launched!
383: #
1.32 www 384: my $configmenu=&rawconfig();
1.52 www 385: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
386:
1.32 www 387: return(<<ENDREMOTESTARTUP);
388: <script>
389:
1.35 www 390: function wheelswitch() {
391: if (window.status=='|') {
392: window.status='/';
393: } else {
394: if (window.status=='/') {
395: window.status='-';
396: } else {
397: if (window.status=='-') {
398: window.status='\\\\';
399: } else {
400: if (window.status=='\\\\') { window.status='|'; }
401: }
402: }
403: }
404: }
405:
1.32 www 406: // ---------------------------------------------------------- The wait function
407: var canceltim;
408: function wait() {
409: if ((menuloaded==1) || (tim==1)) {
1.35 www 410: window.status='Done.';
1.32 www 411: if (tim==0) {
412: clearTimeout(canceltim);
413: $configmenu
414: window.location='$lowerurl';
415: } else {
1.52 www 416: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32 www 417: }
418: } else {
1.35 www 419: wheelswitch();
420: setTimeout('wait();',200);
1.32 www 421: }
422: }
423:
424: function main() {
1.52 www 425: canceltim=setTimeout('tim=1;',30000);
1.35 www 426: window.status='-';
1.32 www 427: wait();
428: }
429:
430: </script>
431: ENDREMOTESTARTUP
432: }
433:
434: sub setflags() {
435: return(<<ENDSETFLAGS);
436: <script>
437: menuloaded=0;
438: tim=0;
439: </script>
440: ENDSETFLAGS
441: }
442:
443: sub maincall() {
1.49 www 444: if (($ENV{'browser.interface'} eq 'textual') ||
445: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.32 www 446: return(<<ENDMAINCALL);
447: <script>
448: main();
449: </script>
450: ENDMAINCALL
451: }
1.30 www 452: # ================================================================= Reopen menu
453:
454: sub reopenmenu {
1.49 www 455: if (($ENV{'browser.interface'} eq 'textual') ||
456: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 457: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.47 matthew 458: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
459: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30 www 460: }
461:
1.1 www 462: # =============================================================== Open the menu
463:
464: sub open {
1.22 www 465: my $returnval='';
1.49 www 466: if (($ENV{'browser.interface'} eq 'textual') ||
467: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 468: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.22 www 469: unless (shift eq 'unix') {
470: # resizing does not work on linux because of virtual desktop sizes
471: $returnval.=(<<ENDRESIZE);
472: if (window.screen) {
1.28 www 473: self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1.22 www 474: self.moveTo(190,15);
475: }
476: ENDRESIZE
477: }
478: $returnval.=(<<ENDOPEN);
1.35 www 479: window.status='Opening LON-CAPA Remote Control';
1.30 www 480: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.14 www 481: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.1 www 482: ENDOPEN
1.22 www 483: return '<script>'.$returnval.'</script>';
1.1 www 484: }
485:
1.2 www 486:
487: # ================================================================== Raw Config
488:
1.3 www 489: sub clear {
490: my ($row,$col)=@_;
1.49 www 491: unless (($ENV{'browser.interface'} eq 'textual') ||
492: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 493: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.34 www 494: } else { return ''; }
1.3 www 495: }
496:
1.40 www 497: # ============================================ Switch a button or create a link
1.25 matthew 498: # Switch acts on the javascript that is executed when a button is clicked.
499: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 500:
1.2 www 501: sub switch {
1.40 www 502: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
1.2 www 503: $act=~s/\$uname/$uname/g;
504: $act=~s/\$udom/$udom/g;
1.49 www 505: unless (($ENV{'browser.interface'} eq 'textual') ||
506: ($ENV{'environment.remote'} eq 'off')) {
1.50 www 507: # Remote
1.34 www 508: return "\n".
1.35 www 509: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.50 www 510: } elsif ($ENV{'browser.interface'} eq 'textual') {
511: # Accessibility
512: if ($nobreak==2) { return ''; }
513: my $text=$top.' '.$bot;
514: $text=~s/\- //;
515: return "\n".($nobreak?' ':'<br />').
516: '<a href="javascript:'.$act.';" target="_top">'.$text.'</a> '.
517: ($nobreak?'':$desc);
1.34 www 518: } else {
1.50 www 519: # Inline Remote
1.41 www 520: if ($nobreak==2) { return ''; }
1.34 www 521: my $text=$top.' '.$bot;
522: $text=~s/\- //;
1.42 www 523: return "\n".($nobreak?' ':'<br />').
1.43 www 524: '<a href="javascript:'.$act.';" target="_top">'.$text.'</a> '.
525: ($nobreak?'':$desc);
1.34 www 526: }
1.2 www 527: }
528:
529: sub secondlevel {
530: my $output='';
531: my
1.27 www 532: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
1.2 www 533: if ($prt eq 'any') {
1.27 www 534: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 535: } elsif ($prt=~/^r(\w+)/) {
536: if ($rol eq $1) {
1.27 www 537: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 538: }
539: }
540: return $output;
541: }
542:
1.18 www 543: sub openmenu {
1.30 www 544: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.49 www 545: if (($ENV{'browser.interface'} eq 'textual') ||
546: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.47 matthew 547: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
548: return "window.open(".$nothing.",'".$menuname."');";
1.18 www 549: }
550:
1.2 www 551: sub rawconfig {
1.34 www 552: my $textualoverride=shift;
553: my $output='';
1.49 www 554: unless (($ENV{'browser.interface'} eq 'textual') ||
555: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 556: $output.=
557: "window.status='Opening Remote Control';var swmenu=".&openmenu().
558: "\nwindow.status='Configuring Remote Control ';";
1.34 www 559: } else {
560: unless ($textualoverride) { return ''; }
561: }
1.2 www 562: my $uname=$ENV{'user.name'};
563: my $udom=$ENV{'user.domain'};
564: my $adv=$ENV{'user.adv'};
1.4 www 565: my $author=$ENV{'user.author'};
1.5 www 566: my $crs='';
567: if ($ENV{'request.course.id'}) {
568: $crs='/'.$ENV{'request.course.id'};
1.7 www 569: if ($ENV{'request.course.sec'}) {
570: $crs.='_'.$ENV{'request.course.sec'};
571: }
1.8 www 572: $crs=~s/\_/\//g;
1.5 www 573: }
1.2 www 574: my $pub=($ENV{'request.state'} eq 'published');
575: my $con=($ENV{'request.state'} eq 'construct');
576: my $rol=$ENV{'request.role'};
1.25 matthew 577: my $requested_domain = $ENV{'request.role.domain'};
1.13 harris41 578: foreach (@desklines) {
1.27 www 579: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
1.3 www 580: $prt=~s/\$uname/$uname/g;
581: $prt=~s/\$udom/$udom/g;
1.5 www 582: $prt=~s/\$crs/$crs/g;
1.25 matthew 583: $prt=~s/\$requested_domain/$requested_domain/g;
1.3 www 584: if ($pro eq 'clear') {
1.4 www 585: $output.=&clear($row,$col);
1.3 www 586: } elsif ($pro eq 'any') {
1.2 www 587: $output.=&secondlevel(
1.27 www 588: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 589: } elsif ($pro eq 'smp') {
590: unless ($adv) {
591: $output.=&secondlevel(
1.27 www 592: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 593: }
594: } elsif ($pro eq 'adv') {
595: if ($adv) {
596: $output.=&secondlevel(
1.27 www 597: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 598: }
599: } elsif (($pro=~/p(\w+)/) && ($prt)) {
600: if (&Apache::lonnet::allowed($1,$prt)) {
1.27 www 601: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.4 www 602: }
1.26 www 603: } elsif ($pro eq 'course') {
604: if ($ENV{'request.course.fn'}) {
1.27 www 605: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.26 www 606: }
1.4 www 607: } elsif ($pro eq 'author') {
608: if ($author) {
1.29 matthew 609: if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
610: (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
1.19 matthew 611: # Check that we are on the correct machine
1.29 matthew 612: my $cadom=$requested_domain;
613: my $caname=$ENV{'user.name'};
614: if ($prt eq 'rca') {
615: ($cadom,$caname)=
1.6 www 616: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.29 matthew 617: }
618: $act =~ s/\$caname/$caname/g;
1.19 matthew 619: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.32 www 620: if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.19 matthew 621: $output.=switch($caname,$cadom,
1.27 www 622: $row,$col,$img,$top,$bot,$act,$desc);
1.19 matthew 623: }
1.6 www 624: }
1.2 www 625: }
626: }
1.13 harris41 627: }
1.49 www 628: unless (($ENV{'browser.interface'} eq 'textual') ||
629: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 630: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.34 www 631: }
1.2 www 632: return $output;
633: }
634:
635: # ======================================================================= Close
1.1 www 636:
637: sub close {
1.49 www 638: if (($ENV{'browser.interface'} eq 'textual') ||
639: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 640: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.1 www 641: return(<<ENDCLOSE);
642: <script>
1.35 www 643: window.status='Accessing Remote Control';
1.30 www 644: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 645: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 646: window.status='Disabling Remote Control';
647: menu.active=0;
1.31 www 648: menu.autologout=0;
1.35 www 649: window.status='Closing Remote Control';
1.1 www 650: menu.close();
1.35 www 651: window.status='Done.';
1.1 www 652: </script>
653: ENDCLOSE
654: }
655:
656: # ====================================================================== Footer
657:
658: sub footer {
659:
1.33 www 660: }
661:
1.42 www 662: sub utilityfunctions {
1.51 www 663: unless (($ENV{'browser.interface'} eq 'textual') ||
664: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.42 www 665: my $currenturl=$ENV{'REQUEST_URI'};
666: my $currentsymb=$ENV{'request.symb'};
667: return (<<ENDUTILITY)
668:
669: var currentURL="$currenturl";
670: var reloadURL="$currenturl";
671: var currentSymb="$currentsymb";
672:
673: function go(url) {
674: if (url!='' && url!= null) {
675: currentURL = null;
676: currentSymb= null;
677: window.location.href=url;
678: }
679: }
680:
681: function gopost(url,postdata) {
682: if (url!='') {
683: this.document.server.action=url;
684: this.document.server.postdata.value=postdata;
685: this.document.server.command.value='';
686: this.document.server.url.value='';
687: this.document.server.symb.value='';
688: this.document.server.submit();
689: }
690: }
691:
692: function gocmd(url,cmd) {
693: if (url!='') {
694: this.document.server.action=url;
695: this.document.server.postdata.value='';
696: this.document.server.command.value=cmd;
697: this.document.server.url.value=currentURL;
698: this.document.server.symb.value=currentSymb;
699: this.document.server.submit();
700: }
701: }
702: ENDUTILITY
703: }
704:
705: sub serverform {
706: return(<<ENDSERVERFORM);
707:
708: <form name="server" action="/adm/logout" method="post">
709: <input type="hidden" name="postdata" value="none" />
710: <input type="hidden" name="command" value="none" />
711: <input type="hidden" name="url" value="none" />
712: <input type="hidden" name="symb" value="none" />
713: </form>
714: ENDSERVERFORM
715: }
1.33 www 716: # ================================================ Handler when called directly
717:
718:
719: sub handler {
720: my $r = shift;
721: $r->content_type('text/html');
722: $r->send_http_header;
723: return OK if $r->header_only;
724:
1.42 www 725: my $form=&serverform();
1.34 www 726: my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1.53 www 727: # ---- Print the screen, pretent to be in text mode to generate text-based menu
728: unless ($ENV{'brower.interface'} eq 'textual') {
729: $ENV{'environment.remote'}='off';
730: }
731: my $utility=&utilityfunctions();
1.36 www 732: $r->print(<<ENDHEADER);
733: <html><head>
734: <title>LON-CAPA Main Menu</title>
735: <script>
1.42 www 736: $utility
1.36 www 737: </script>
738: </head>
739: $bodytag
740: ENDHEADER
1.42 www 741: $r->print(&rawconfig(1).$form);
1.33 www 742: $r->print('</body></html>');
743: return OK;
1.1 www 744: }
745:
1.2 www 746: # ================================================================ Main Program
747:
1.16 harris41 748: BEGIN {
1.15 matthew 749: if (! defined($readdesk)) {
1.14 www 750: {
1.10 albertel 751: my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
752: '/mydesk.tab');
753: while (my $configline=<$config>) {
1.14 www 754: $configline=(split(/\#/,$configline))[0];
755: $configline=~s/^\s+//;
1.10 albertel 756: chomp($configline);
1.14 www 757: if ($configline) {
758: $desklines[$#desklines+1]=$configline;
759: }
1.2 www 760: }
1.14 www 761: }
762: $readdesk='done';
1.10 albertel 763: }
1.2 www 764: }
1.30 www 765:
1.1 www 766: 1;
767: __END__
768:
769:
770:
771:
772:
773:
774:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>