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