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