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