1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.162 2005/11/08 14:45:44 albertel Exp $
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: #
28: #
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'
37: #
38:
39: package Apache::lonmenu;
40:
41: use strict;
42: use Apache::lonnet;
43: use Apache::Constants qw(:common);
44: use Apache::lonhtmlcommon();
45: use Apache::loncommon();
46: use Apache::lonenc();
47: use Apache::lonlocal;
48:
49: use vars qw(@desklines $readdesk);
50:
51:
52: my @inlineremote;
53: my $font;
54: my $tabbg;
55: my $pgbg;
56:
57: # ================================================================ Little texts
58:
59: sub initlittle {
60: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
61: 'nav' => 'Navigate Contents',
62: 'main' => 'Main Menu',
63: 'roles' => ($env{'user.adv'}?
64: 'Roles':'Courses'),
65: 'docs' => 'Course Documents',
66: 'exit' => 'Exit',
67: 'launch' => 'Launch Remote Control');
68: }
69:
70: # ============================= This gets called at the top of the body section
71:
72: sub menubuttons {
73: my $forcereg=shift;
74: my $target =shift;
75: my $registration=shift;
76: my $titletable=shift;
77: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
78: ['inhibitmenu']);
79: if (($env{'form.inhibitmenu'} eq 'yes') ||
80: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
81:
82: my $navmaps='';
83: my $reloadlink='';
84: my $docs='';
85: my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
86: my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
87: my $face= 'face="Arial,Helvetica,sans-serif"';
88: if ($env{'request.state'} eq 'construct') {
89: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
90: my $returnurl = $env{'request.filename'};
91: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
92: $escurl = &Apache::lonnet::escape($returnurl);
93: }
94: }
95: if ($env{'browser.interface'} eq 'textual') {
96: # Textual display only
97: my %lt=&initlittle();
98: $pgbg='#FFFFFF';
99: $tabbg='#FFFFFF';
100: $font='#000000';
101: if ($env{'request.course.id'}) {
102: $navmaps=(<<ENDNAV);
103: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
104: ENDNAV
105: if (($env{'request.noversionuri'}=~/^\/adm\//) &&
106: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
107: ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
108: my $escreload=&Apache::lonnet::escape('return:');
109: $reloadlink=(<<ENDRELOAD);
110: <a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a>
111: ENDRELOAD
112: }
113: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
114: $docs=(<<ENDDOCS);
115: <a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a>
116: ENDDOCS
117: }
118: }
119: my $form=&serverform();
120: my $utility=&utilityfunctions();
121: my $output=(<<ENDMAINMENU);
122: <script type="text/javascript">
123: // BEGIN LON-CAPA Internal
124: $utility
125: </script>
126: <a href="/adm/menu" target="_top">$lt{'main'}</a>
127: $reloadlink $navmaps $docs
128: <a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a>
129: <a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a>
130: <br />
131: <script type="text/javascript">
132: // END LON-CAPA Internal
133: </script>
134: $form
135: ENDMAINMENU
136: if ($registration) { $output.=&innerregister($forcereg,$target); }
137: return $output."<hr />";
138: } elsif ($env{'environment.remote'} eq 'off') {
139: # Remote Control is switched off
140: # figure out colors
141: my %lt=&initlittle();
142: my $function='student';
143: if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
144: $function='coordinator';
145: }
146: if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
147: $function='admin';
148: }
149: if (($env{'request.role'}=~/^(au|ca)/) ||
150: ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) {
151: $function='author';
152: }
153: my $domain=&Apache::loncommon::determinedomain();
154: $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
155: $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
156: $font=&Apache::loncommon::designparm($function.'.font',$domain);
157: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
158: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
159: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
160: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
161: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
162: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
163: return (<<ENDINLINEMENU);
164: <font face="Arial,Helvetica,sans-serif">
165: <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1">
166: <tr>
167: <td bgcolor="$tabbg">
168: <a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a>
169: </td>
170: <td align="right" bgcolor="$tabbg">
171: <img align="right" src="$logo" alt="Logo" />
172: <b>LON-CAPA</b>
173: </td>
174: </tr>
175: </table>
176: </font>
177: ENDINLINEMENU
178: }
179: # Do we have a NAV link?
180: if ($env{'request.course.id'}) {
181: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
182: $escsymb;
183: if ($env{'environment.remotenavmap'} eq 'on') {
184: $link="javascript:gonav('".$link."')";
185: }
186: $navmaps=(<<ENDNAV);
187: <td bgcolor="$tabbg">
188: <a href="$link" target="_top"><font $face color="$font">$lt{'nav'}</font></a></td>
189: ENDNAV
190: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
191: $docs=(<<ENDDOCS);
192: <td bgcolor="$tabbg">
193: <a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a></td>
194: ENDDOCS
195: }
196: if (
197: ($env{'request.noversionuri'}=~m[^/(res|public)/] &&
198: $env{'request.symb'} eq '')
199: ||
200: (($env{'request.noversionuri'}=~/^\/adm\//) &&
201: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
202: ($env{'request.noversionuri'}!~
203: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
204: )
205: ) {
206: my $escreload=&Apache::lonnet::escape('return:');
207: $reloadlink=(<<ENDRELOAD);
208: <td bgcolor="$tabbg">
209: <a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td>
210: ENDRELOAD
211: }
212: }
213: my $reg='';
214: if ($registration) {
215: $reg=&innerregister($forcereg,$target,$titletable);
216: }
217: my $form=&serverform();
218: my $utility=&utilityfunctions();
219: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
220:
221: return (<<ENDINLINEMENU);
222: <script type="text/javascript">
223: // BEGIN LON-CAPA Internal
224: // <![CDATA[
225: $utility
226: // ]]>
227: </script>
228: <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1">
229: <tr>
230: <td bgcolor="$tabbg">
231: <a href="/adm/menu" target="_top"><font $face color="$font">$lt{'main'}</font></a>
232: </td>
233: $reloadlink
234: $navmaps
235: $docs
236: <td bgcolor="$tabbg">
237: <a href="/adm/remote?action=launch&url=$escurl" target="_top">
238: <font $face color="$font">$lt{'launch'}</font></a></td>
239: <td bgcolor="$tabbg">
240: <a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a>
241: </td>
242: <td bgcolor="$tabbg">
243: <a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a>
244: </td>
245: <td bgcolor="$tabbg">
246: <img align="right" src="$logo" alt="Logo" />
247: <b>LON-CAPA</b></td>
248: $form
249: </tr>
250: </table>
251: <script type="text/javascript">
252: // END LON-CAPA Internal
253: </script>
254: $reg
255: ENDINLINEMENU
256: } else {
257: return '';
258: }
259: }
260:
261: # ====================================== This gets called in the header section
262:
263: sub registerurl {
264: my $forcereg=shift;
265: my $target = shift;
266: my $result = '';
267: if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
268: my $force_title='';
269: if ($env{'request.state'} eq 'construct') {
270: $force_title=&Apache::lonxml::display_title();
271: }
272: if ($target eq 'edit') {
273: $result .="<script type=\"text/javascript\">\n".
274: "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
275: &Apache::loncommon::browser_and_searcher_javascript().
276: "\n</script>\n";
277: }
278: if (($env{'browser.interface'} eq 'textual') ||
279: ($env{'environment.remote'} eq 'off') ||
280: ((($env{'request.publicaccess'}) ||
281: (!&Apache::lonnet::is_on_map(
282: &Apache::lonnet::unescape($env{'request.noversionuri'})))) &&
283: (!$forcereg))) {
284: return $result.
285: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
286: }
287: # Graphical display after login only
288: if ($Apache::lonxml::registered && !$forcereg) { return ''; }
289: if ($target ne 'edit') {
290: $result.=&innerregister($forcereg,$target);
291: }
292: return $result.$force_title;
293: }
294:
295: # =========== This gets called in order to register a URL, both with the Remote
296: # =========== and in the body of the document
297:
298: sub innerregister {
299: my $forcereg=shift;
300: my $target = shift;
301: my $titletable = shift;
302: my $result = '';
303: my ($uname,$thisdisfn);
304: my $const_space = ($env{'request.state'} eq 'construct');
305: my $is_const_dir = 0;
306:
307: if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
308:
309: $Apache::lonxml::registered=1;
310:
311: my $textinter=($env{'browser.interface'} eq 'textual');
312: my $noremote=($env{'environment.remote'} eq 'off');
313:
314: my $textual=($textinter || $noremote);
315:
316: @inlineremote=();
317: undef @inlineremote;
318:
319: my $reopen=&Apache::lonmenu::reopenmenu();
320:
321: my $newmail='';
322: if ($noremote) {
323: $newmail='<table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'"><font face="Arial,Helvetica,sans-serif">';
324: }
325: if (($textual) && ($env{'request.symb'}) && ($env{'request.course.id'})) {
326: my ($mapurl,$rid,$resurl)=
327: &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
328: $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
329: my $maptitle=&Apache::lonnet::gettitle($mapurl);
330: my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
331: if ($maptitle && $maptitle ne 'default.sequence') {
332: $newmail.=', '.$maptitle;
333: }
334: if ($restitle) {
335: $newmail.=': '.$restitle;
336: }
337: $newmail.=' ';
338: }
339: if (&Apache::lonmsg::newmail()) {
340: $newmail=($textual?
341: '<b><a href="/adm/communicate" target="_top">You have new messages</a></b><br />':
342: 'swmenu.setstatus("you have","messages");');
343: }
344: if ($env{'request.state'} eq 'construct') {
345: $newmail = $titletable;
346: } else {
347: if ($noremote) {
348: $newmail.='</font></td></tr></table>';
349: }
350: }
351: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
352: my $tablestart=($noremote?'<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%">':'').($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
353: my $tableend=($noremote?'</table></font>':'').($textinter?'<a name="content" />':'');
354: # =============================================================================
355: # ============================ This is for URLs that actually can be registered
356: if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
357: # -- This applies to homework problems for users with grading privileges
358: my $crs='/'.$env{'request.course.id'};
359: if ($env{'request.course.sec'}) {
360: $crs.='_'.$env{'request.course.sec'};
361: }
362: $crs=~s/\_/\//g;
363:
364: my $hwkadd='';
365: if ($env{'request.symb'} ne '' &&
366: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
367: if (&Apache::lonnet::allowed('mgr',$crs)) {
368: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
369: "gocmd('/adm/grades','gradingmenu')",
370: 'Modify user grades for this assessment resource');
371: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
372: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
373: "gocmd('/adm/grades','submission')",
374: 'View user submissions for this assessment resource');
375: }
376: }
377: if ($env{'request.symb'} ne '' &&
378: &Apache::lonnet::allowed('opa',$crs)) {
379: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
380: "gocmd('/adm/parmset','set')",
381: 'Modify deadlines, etc, for this resource');
382: }
383: # -- End Homework
384: ###
385: ### Determine whether or not to display the 'cstr' button for this
386: ### resource
387: ###
388: my $editbutton = '';
389: if ($env{'user.author'}) {
390: if ($env{'request.role'}=~/^(ca|au)/) {
391: # Set defaults for authors
392: my ($top,$bottom) = ('con-','struct');
393: my $action = "go('/priv/".$env{'user.name'}."');";
394: my $cadom = $env{'request.role.domain'};
395: my $caname = $env{'user.name'};
396: my $desc = "Enter my resource construction space";
397: # Set defaults for co-authors
398: if ($env{'request.role'} =~ /^ca/) {
399: ($cadom,$caname)=($env{'request.role'}=~/(\w+)\/(\w+)$/);
400: ($top,$bottom) = ('co con-','struct');
401: $action = "go('/priv/".$caname."');";
402: $desc = "Enter construction space as co-author";
403: }
404: # Check that we are on the correct machine
405: my $home = &Apache::lonnet::homeserver($caname,$cadom);
406: my $allowed=0;
407: my @ids=&Apache::lonnet::current_machine_ids();
408: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
409: if (!$allowed) {
410: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
411: }
412: }
413: ##
414: ## Determine if user can edit url.
415: ##
416: my $cfile='';
417: my $cfuname='';
418: my $cfudom='';
419: if ($env{'request.filename'}) {
420: my $file=&Apache::lonnet::declutter($env{'request.filename'});
421: $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
422: # Check that the user has permission to edit this resource
423: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
424: if (defined($cfudom)) {
425: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
426: my $allowed=0;
427: my @ids=&Apache::lonnet::current_machine_ids();
428: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
429: if ($allowed) {
430: $cfile=$file;
431: }
432: }
433: }
434: # Finally, turn the button on or off
435: if ($cfile && !$const_space) {
436: $editbutton=&switch
437: ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',
438: "go('".$cfile."');","Edit this resource");
439: } elsif ($editbutton eq '') {
440: $editbutton=&switch('','',6,1,'port.gif',
441: 'port-[_1]','folio[_1]',
442: "go('/adm/portfolio');",
443: "Enter my portfolio space");
444: }
445: }
446: ###
447: ###
448: # Prepare the rest of the buttons
449: my $menuitems;
450: if ($const_space) {
451: my ($uname,$thisdisfn) =
452: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
453: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
454: if ($currdir =~ m-/$-) {
455: $is_const_dir = 1;
456: } else {
457: $currdir =~ s#[^/]+$##;
458: $menuitems=(<<ENDMENUITEMS);
459: s&6&1&list.gif&list[_1]&dir[_1]&golist('$currdir')&List current directory
460: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$thisdisfn')&Retrieve old version
461: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$thisdisfn')&Publish this resource
462: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$thisdisfn')&Delete this resource
463: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$thisdisfn')&Prepare a printable document
464: ENDMENUITEMS
465: }
466: } elsif (defined($env{'request.course.id'}) &&
467: $env{'request.symb'} ne '') {
468: $menuitems=(<<ENDMENUITEMS);
469: c&3&1
470: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
471: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&3
472: c&6&3
473: c&8&1
474: c&8&2
475: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
476: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&2
477: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2
478: ENDMENUITEMS
479: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
480: $menuitems.=(<<ENDREALRES);
481: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
482: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
483: s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
484: ENDREALRES
485: }
486: }
487: my $buttons='';
488: foreach (split(/\n/,$menuitems)) {
489: my ($command,@rest)=split(/\&/,$_);
490: if ($command eq 's') {
491: $buttons.=&switch('','',@rest);
492: } else {
493: $buttons.=&clear(@rest);
494: }
495: }
496:
497: if ($textual) {
498: my $addremote=0;
499: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
500: my $inlinebuttons='';
501: if ($addremote) {
502: # Registered, textual output
503:
504: if ($env{'browser.interface'} eq 'textual') {
505: $inlinebuttons=
506: join('',map { (defined($_)?$_:'') } @inlineremote);
507: } else {
508: $inlinebuttons=(<<ENDINLINE);
509: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
510: <tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr>
511: <tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr>
512: <tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr>
513: <tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr>
514: ENDINLINE
515: }
516: }
517: $result =(<<ENDREGTEXT);
518: <script type="text/javascript">
519: // BEGIN LON-CAPA Internal
520: </script>
521: $timesync
522: $newmail
523: $tablestart
524: $inlinebuttons
525: $tableend
526: <script type="text/javascript">
527: // END LON-CAPA Internal
528: </script>
529:
530: ENDREGTEXT
531: # Registered, graphical output
532: } else {
533: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
534: $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri));
535: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
536: my $navstatus=&get_nav_status();
537: my $clearcstr;
538:
539: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
540: $result = (<<ENDREGTHIS);
541:
542: <script type="text/javascript">
543: // BEGIN LON-CAPA Internal
544: var swmenu=null;
545:
546: function LONCAPAreg() {
547: swmenu=$reopen;
548: swmenu.clearTimeout(swmenu.menucltim);
549: $timesync
550: $newmail
551: $buttons
552: swmenu.currentURL="$requri";
553: swmenu.reloadURL=swmenu.currentURL+window.location.search;
554: swmenu.currentSymb="$cursymb";
555: swmenu.reloadSymb="$cursymb";
556: swmenu.currentStale=0;
557: $navstatus
558: $hwkadd
559: $editbutton
560: }
561:
562: function LONCAPAstale() {
563: swmenu=$reopen
564: swmenu.currentStale=1;
565: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
566: swmenu.switchbutton
567: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
568: }
569: swmenu.clearbut(7,2);
570: swmenu.clearbut(7,3);
571: swmenu.menucltim=swmenu.setTimeout(
572: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
573: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
574: 2000);
575: }
576:
577: // END LON-CAPA Internal
578: </script>
579: ENDREGTHIS
580: }
581: # =============================================================================
582: } else {
583: # ========================================== This can or will not be registered
584: if ($textual) {
585: # Not registered, textual
586: $result= (<<ENDDONOTREGTEXT);
587: ENDDONOTREGTEXT
588: } else {
589: # Not registered, graphical
590: $result = (<<ENDDONOTREGTHIS);
591:
592: <script type="text/javascript">
593: // BEGIN LON-CAPA Internal
594: var swmenu=null;
595:
596: function LONCAPAreg() {
597: swmenu=$reopen
598: $timesync
599: swmenu.currentStale=1;
600: swmenu.clearbut(2,1);
601: swmenu.clearbut(2,3);
602: swmenu.clearbut(8,1);
603: swmenu.clearbut(8,2);
604: swmenu.clearbut(8,3);
605: if (swmenu.currentURL) {
606: swmenu.switchbutton
607: (3,1,'reload.gif','return','location','go(currentURL)');
608: } else {
609: swmenu.clearbut(3,1);
610: }
611: }
612:
613: function LONCAPAstale() {
614: }
615:
616: // END LON-CAPA Internal
617: </script>
618: ENDDONOTREGTHIS
619: }
620: # =============================================================================
621: }
622: return $result;
623: }
624:
625: sub loadevents() {
626: if ($env{'request.state'} eq 'construct' ||
627: $env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
628: return 'LONCAPAreg();';
629: }
630:
631: sub unloadevents() {
632: if ($env{'request.state'} eq 'construct' ||
633: $env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
634: return 'LONCAPAstale();';
635: }
636:
637: # ============================================================= Start up remote
638:
639: sub startupremote {
640: my ($lowerurl)=@_;
641: if (($env{'browser.interface'} eq 'textual') ||
642: ($env{'environment.remote'} eq 'off')) {
643: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
644: }
645: #
646: # The Remote actually gets launched!
647: #
648: my $configmenu=&rawconfig();
649: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
650: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
651: return(<<ENDREMOTESTARTUP);
652: <script type="text/javascript">
653: var timestart;
654: function wheelswitch() {
655: if (typeof(document.wheel) != 'undefined') {
656: if (typeof(document.wheel.spin) != 'undefined') {
657: var date=new Date();
658: var waited=Math.round(30-((date.getTime()-timestart)/1000));
659: document.wheel.spin.value=$message;
660: }
661: }
662: if (window.status=='|') {
663: window.status='/';
664: } else {
665: if (window.status=='/') {
666: window.status='-';
667: } else {
668: if (window.status=='-') {
669: window.status='\\\\';
670: } else {
671: if (window.status=='\\\\') { window.status='|'; }
672: }
673: }
674: }
675: }
676:
677: // ---------------------------------------------------------- The wait function
678: var canceltim;
679: function wait() {
680: if ((menuloaded==1) || (tim==1)) {
681: window.status='Done.';
682: if (tim==0) {
683: clearTimeout(canceltim);
684: $configmenu
685: window.location='$lowerurl';
686: } else {
687: window.location='/adm/remote?action=collapse&url=$esclowerurl';
688: }
689: } else {
690: wheelswitch();
691: setTimeout('wait();',200);
692: }
693: }
694:
695: function main() {
696: canceltim=setTimeout('tim=1;',30000);
697: window.status='-';
698: var date=new Date();
699: timestart=date.getTime();
700: wait();
701: }
702:
703: </script>
704: ENDREMOTESTARTUP
705: }
706:
707: sub setflags() {
708: return(<<ENDSETFLAGS);
709: <script type="text/javascript">
710: menuloaded=0;
711: tim=0;
712: </script>
713: ENDSETFLAGS
714: }
715:
716: sub maincall() {
717: if (($env{'browser.interface'} eq 'textual') ||
718: ($env{'environment.remote'} eq 'off')) { return ''; }
719: return(<<ENDMAINCALL);
720: <script type="text/javascript">
721: main();
722: </script>
723: ENDMAINCALL
724: }
725:
726: sub load_remote_msg {
727: my ($lowerurl)=@_;
728:
729: if (($env{'browser.interface'} eq 'textual') ||
730: ($env{'environment.remote'} eq 'off')) { return ''; }
731:
732: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
733: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
734: "/adm/remote?action=collapse?url=$esclowerurl");
735: return(<<ENDREMOTEFORM);
736: <p>
737: <form name="wheel">
738: <input name="spin" type="text" size="60" />
739: </form>
740: </p>
741: <p>$link</p>
742: ENDREMOTEFORM
743: }
744: # ================================================================= Reopen menu
745:
746: sub reopenmenu {
747: if (($env{'browser.interface'} eq 'textual') ||
748: ($env{'environment.remote'} eq 'off')) { return ''; }
749: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
750: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
751: return('window.open('.$nothing.',"'.$menuname.'","",false);');
752: }
753:
754: # =============================================================== Open the menu
755:
756: sub open {
757: my $returnval='';
758: if (($env{'browser.interface'} eq 'textual') ||
759: ($env{'environment.remote'} eq 'off')) {
760: return '<script type="text/javascript">self.name="loncapaclient";</script>';
761: }
762: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
763: unless (shift eq 'unix') {
764: # resizing does not work on linux because of virtual desktop sizes
765: $returnval.=(<<ENDRESIZE);
766: if (window.screen) {
767: self.resizeTo(screen.availWidth-215,screen.availHeight-55);
768: self.moveTo(190,15);
769: }
770: ENDRESIZE
771: }
772: $returnval.=(<<ENDOPEN);
773: window.status='Opening LON-CAPA Remote Control';
774: var menu=window.open("/res/adm/pages/menu.html","$menuname",
775: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
776: self.name='loncapaclient';
777: ENDOPEN
778: return '<script type="text/javascript">'.$returnval.'</script>';
779: }
780:
781:
782: # ================================================================== Raw Config
783:
784: sub clear {
785: my ($row,$col)=@_;
786: unless (($env{'browser.interface'} eq 'textual') ||
787: ($env{'environment.remote'} eq 'off')) {
788: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
789: } else {
790: $inlineremote[10*$row+$col]='';
791: return '';
792: }
793: }
794:
795: # ============================================ Switch a button or create a link
796: # Switch acts on the javascript that is executed when a button is clicked.
797: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
798:
799: sub switch {
800: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
801: $act=~s/\$uname/$uname/g;
802: $act=~s/\$udom/$udom/g;
803: $top=&mt($top);
804: $bot=&mt($bot);
805: $desc=&mt($desc);
806: $img=&mt($img);
807: unless (($env{'browser.interface'} eq 'textual') ||
808: ($env{'environment.remote'} eq 'off')) {
809: # Remote
810: return "\n".
811: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
812: } elsif ($env{'browser.interface'} eq 'textual') {
813: # Accessibility
814: if ($nobreak==2) { return ''; }
815: my $text=$top.' '.$bot;
816: $text=~s/\s*\-\s*//gs;
817: if ($nobreak) {
818: $inlineremote[10*$row+$col]=
819: '<a href="javascript:'.$act.';">'.$text.'</a>';
820: } else {
821: $inlineremote[10*$row+$col]="\n<br />".
822: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
823: }
824: } else {
825: # Inline Remote
826: if ($nobreak==2) { return ''; }
827: my $text=$top.' '.$bot;
828: $text=~s/\s*\-\s*//gs;
829:
830: my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
831: if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
832: my $pic=
833: '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.
834: ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.
835: ($nobreak==3?'right':'left').'" />';
836: if (($env{'browser.interface'} eq 'textual') || ($env{'browser.interface'} eq 'faketextual')) {
837: # Accessibility
838: if ($nobreak==3) {
839: $inlineremote[10*$row+$col]="\n".
840: '<td width="40%" align="right"><font color="'.$font.'" size="+1">'.$text.
841: '</font></td><td width="10%" align="right" bgcolor="'.$tabbg.'">'.
842: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
843: } elsif ($nobreak) {
844: $inlineremote[10*$row+$col]="\n<tr>".
845: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
846: '<a href="javascript:'.$act.';">'.$pic.
847: '</a></td><td width="40%" align="left"><font color="'.$font.'" size="+1">'.$text.'</font></td>';
848: } else {
849: $inlineremote[10*$row+$col]="\n<tr>".
850: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
851: '<a href="javascript:'.$act.';">'.$pic.
852: '</a></td><td colspan="3"><font color="'.$font.'">'.$desc.
853: '</font></td></tr>';
854: }
855: } else {
856: # Inline Menu
857: $inlineremote[10*$row+$col]=
858: '<a href="javascript:'.$act.';">'.$pic.
859: '</a><font color="'.$font.'" size="2">'.$desc.
860: '</font>';
861: }
862: }
863: return '';
864: }
865:
866: sub secondlevel {
867: my $output='';
868: my
869: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
870: if ($prt eq 'any') {
871: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
872: } elsif ($prt=~/^r(\w+)/) {
873: if ($rol eq $1) {
874: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
875: }
876: }
877: return $output;
878: }
879:
880: sub openmenu {
881: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
882: if (($env{'browser.interface'} eq 'textual') ||
883: ($env{'environment.remote'} eq 'off')) { return ''; }
884: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
885: return "window.open(".$nothing.",'".$menuname."');";
886: }
887:
888: sub inlinemenu {
889: @inlineremote=();
890: undef @inlineremote;
891: &rawconfig(1);
892: return join('',map { (defined($_)?$_:'') } @inlineremote);
893: }
894:
895: sub rawconfig {
896: my $textualoverride=shift;
897: my $output='';
898: unless (($env{'browser.interface'} eq 'textual') ||
899: ($env{'environment.remote'} eq 'off')) {
900: $output.=
901: "window.status='Opening Remote Control';var swmenu=".&openmenu().
902: "\nwindow.status='Configuring Remote Control ';";
903: } else {
904: unless ($textualoverride) { return ''; }
905: }
906: my $uname=$env{'user.name'};
907: my $udom=$env{'user.domain'};
908: my $adv=$env{'user.adv'};
909: my $author=$env{'user.author'};
910: my $crs='';
911: if ($env{'request.course.id'}) {
912: $crs='/'.$env{'request.course.id'};
913: if ($env{'request.course.sec'}) {
914: $crs.='_'.$env{'request.course.sec'};
915: }
916: $crs=~s/\_/\//g;
917: }
918: my $pub=($env{'request.state'} eq 'published');
919: my $con=($env{'request.state'} eq 'construct');
920: my $rol=$env{'request.role'};
921: my $requested_domain = $env{'request.role.domain'};
922: foreach (@desklines) {
923: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
924: $prt=~s/\$uname/$uname/g;
925: $prt=~s/\$udom/$udom/g;
926: $prt=~s/\$crs/$crs/g;
927: $prt=~s/\$requested_domain/$requested_domain/g;
928: if ($pro eq 'clear') {
929: $output.=&clear($row,$col);
930: } elsif ($pro eq 'any') {
931: $output.=&secondlevel(
932: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
933: } elsif ($pro eq 'smp') {
934: unless ($adv) {
935: $output.=&secondlevel(
936: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
937: }
938: } elsif ($pro eq 'adv') {
939: if ($adv) {
940: $output.=&secondlevel(
941: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
942: }
943: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
944: if (&Apache::lonnet::allowed($1,$prt)) {
945: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
946: }
947: } elsif ($pro eq 'course') {
948: if ($env{'request.course.fn'}) {
949: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
950: }
951: } elsif ($pro =~ /^courseenv_(.*)$/) {
952: my $key = $1;
953: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
954: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
955: }
956: } elsif ($pro =~ /^course_(.*)$/) {
957: # Check for permissions inside of a course
958: if (($env{'request.course.id'}) &&
959: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
960: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
961: )) {
962: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
963: }
964: } elsif ($pro eq 'author') {
965: if ($author) {
966: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
967: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
968: # Check that we are on the correct machine
969: my $cadom=$requested_domain;
970: my $caname=$env{'user.name'};
971: if ($prt eq 'rca') {
972: ($cadom,$caname)=
973: ($env{'request.role'}=~/(\w+)\/(\w+)$/);
974: }
975: $act =~ s/\$caname/$caname/g;
976: my $home = &Apache::lonnet::homeserver($caname,$cadom);
977: my $allowed=0;
978: my @ids=&Apache::lonnet::current_machine_ids();
979: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
980: if ($allowed) {
981: $output.=switch($caname,$cadom,
982: $row,$col,$img,$top,$bot,$act,$desc);
983: }
984: }
985: }
986: }
987: }
988: unless (($env{'browser.interface'} eq 'textual') ||
989: ($env{'environment.remote'} eq 'off')) {
990: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
991: if (&Apache::lonmsg::newmail()) {
992: $output.='swmenu.setstatus("you have","messages");';
993: }
994: }
995:
996: return $output;
997: }
998:
999: # ======================================================================= Close
1000:
1001: sub close {
1002: if (($env{'browser.interface'} eq 'textual') ||
1003: ($env{'environment.remote'} eq 'off')) { return ''; }
1004: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1005: return(<<ENDCLOSE);
1006: <script type="text/javascript">
1007: window.status='Accessing Remote Control';
1008: menu=window.open("/adm/rat/empty.html","$menuname",
1009: "height=350,width=150,scrollbars=no,menubar=no");
1010: window.status='Disabling Remote Control';
1011: menu.active=0;
1012: menu.autologout=0;
1013: window.status='Closing Remote Control';
1014: menu.close();
1015: window.status='Done.';
1016: </script>
1017: ENDCLOSE
1018: }
1019:
1020: # ====================================================================== Footer
1021:
1022: sub footer {
1023:
1024: }
1025:
1026: sub nav_control_js {
1027: my $nav=($env{'environment.remotenavmap'} eq 'on');
1028: return (<<NAVCONTROL);
1029: var w_loncapanav_flag="$nav";
1030:
1031:
1032: function gonav(url) {
1033: if (w_loncapanav_flag != 1) {
1034: gopost(url,'');
1035: } else {
1036: navwindow=window.open(url,
1037: "loncapanav","height=600,width=400,scrollbars=1");
1038: }
1039: }
1040: NAVCONTROL
1041: }
1042:
1043: sub utilityfunctions {
1044: my $caller = shift;
1045: unless (($env{'browser.interface'} eq 'textual') ||
1046: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1047: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1048: $currenturl=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($currenturl));
1049:
1050: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1051: my $nav_control=&nav_control_js();
1052: return (<<ENDUTILITY)
1053:
1054: var currentURL="$currenturl";
1055: var reloadURL="$currenturl";
1056: var currentSymb="$currentsymb";
1057:
1058: $nav_control
1059:
1060: function go(url) {
1061: if (url!='' && url!= null) {
1062: currentURL = null;
1063: currentSymb= null;
1064: window.location.href=url;
1065: }
1066: }
1067:
1068: function gopost(url,postdata) {
1069: if (url!='') {
1070: this.document.server.action=url;
1071: this.document.server.postdata.value=postdata;
1072: this.document.server.command.value='';
1073: this.document.server.url.value='';
1074: this.document.server.symb.value='';
1075: this.document.server.submit();
1076: }
1077: }
1078:
1079: function gocmd(url,cmd) {
1080: if (url!='') {
1081: this.document.server.action=url;
1082: this.document.server.postdata.value='';
1083: this.document.server.command.value=cmd;
1084: this.document.server.url.value=currentURL;
1085: this.document.server.symb.value=currentSymb;
1086: this.document.server.submit();
1087: }
1088: }
1089:
1090: function gocstr(url,filename) {
1091: if (url == '/adm/cfile?action=delete') {
1092: this.document.cstrdelete.filename.value = filename
1093: this.document.cstrdelete.submit();
1094: return;
1095: }
1096: if (url == '/adm/printout') {
1097: this.document.cstrprint.postdata.value = filename
1098: this.document.cstrprint.curseed.value = 0;
1099: this.document.cstrprint.problemtype.value = 0;
1100: if (this.document.lonhomework) {
1101: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1102: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1103: }
1104: if (this.document.lonhomework.problemtype) {
1105: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1106: if (this.document.lonhomework.problemtype.options[i].selected) {
1107: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1108: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1109: }
1110: }
1111: }
1112: }
1113: }
1114: this.document.cstrprint.submit();
1115: return;
1116: }
1117: if (url !='') {
1118: this.document.constspace.filename.value = filename;
1119: this.document.constspace.action = url;
1120: this.document.constspace.submit();
1121: }
1122: }
1123:
1124: function golist(url) {
1125: if (url!='' && url!= null) {
1126: currentURL = null;
1127: currentSymb= null;
1128: top.location.href=url;
1129: }
1130: }
1131:
1132:
1133:
1134: function catalog_info() {
1135: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1136: }
1137:
1138: function chat_win() {
1139: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1140: }
1141: ENDUTILITY
1142: }
1143:
1144: sub serverform {
1145: return(<<ENDSERVERFORM);
1146: <form name="server" action="/adm/logout" method="post" target="_top">
1147: <input type="hidden" name="postdata" value="none" />
1148: <input type="hidden" name="command" value="none" />
1149: <input type="hidden" name="url" value="none" />
1150: <input type="hidden" name="symb" value="none" />
1151: </form>
1152: ENDSERVERFORM
1153: }
1154:
1155: sub constspaceform {
1156: return(<<ENDCONSTSPACEFORM);
1157: <form name="constspace" action="/adm/logout" method="post" target="_top">
1158: <input type="hidden" name="filename" value="" />
1159: </form>
1160: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1161: <input type="hidden" name="action" value="delete" />
1162: <input type="hidden" name="filename" value="" />
1163: </form>
1164: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1165: <input type="hidden" name="postdata" value="" />
1166: <input type="hidden" name="curseed" value="" />
1167: <input type="hidden" name="problemtype" value="" />
1168: </form>
1169:
1170: ENDCONSTSPACEFORM
1171: }
1172:
1173:
1174: sub get_nav_status {
1175: my $navstatus="swmenu.w_loncapanav_flag=";
1176: if ($env{'environment.remotenavmap'} eq 'on') {
1177: $navstatus.="1";
1178: } else {
1179: $navstatus.="-1";
1180: }
1181: return $navstatus;
1182: }
1183:
1184: # ================================================ Handler when called directly
1185:
1186:
1187: sub handler {
1188: my $r = shift;
1189: &Apache::loncommon::no_cache($r);
1190: &Apache::loncommon::content_type($r,'text/html');
1191: $r->send_http_header;
1192: return OK if $r->header_only;
1193:
1194: my $form;
1195: if ($env{'environment.remote'} ne 'off' &&
1196: $env{'browser.interface'} ne 'textual') {
1197: $form=&serverform();
1198: }
1199: my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1200: my $function='student';
1201: if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
1202: $function='coordinator';
1203: }
1204: if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
1205: $function='admin';
1206: }
1207: if (($env{'request.role'}=~/^(au|ca)/) ||
1208: ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) {
1209: $function='author';
1210: }
1211: my $domain=&Apache::loncommon::determinedomain();
1212: $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
1213: $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
1214: $font=&Apache::loncommon::designparm($function.'.font',$domain);
1215: my $script_tag;
1216: if ($env{'environment.remote'} ne 'off') {
1217: my $utility=&utilityfunctions('/adm/menu');
1218: $script_tag=(<<ENDSCRIPT);
1219: <script type="text/javascript">
1220: $utility
1221: </script>
1222: ENDSCRIPT
1223: }
1224: # ---- Print the screen, pretend to be in text mode to generate text-based menu
1225: unless ($env{'browser.interface'} eq 'textual') {
1226: $env{'browser.interface'}='faketextual';
1227: $env{'environment.remote'}='off';
1228: }
1229: my $html=&Apache::lonxml::xmlbegin();
1230: $r->print(<<ENDHEADER);
1231: $html
1232: <head>
1233: <title>LON-CAPA Main Menu</title>
1234: $script_tag
1235: </head>
1236: $bodytag
1237: ENDHEADER
1238: $r->print('<table>'.&inlinemenu().'</table>'.$form);
1239: $r->print('</body></html>');
1240: return OK;
1241: }
1242:
1243: # ================================================================ Main Program
1244:
1245: BEGIN {
1246: if (! defined($readdesk)) {
1247: {
1248: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1249: if ( CORE::open( my $config,"<$tabfile") ) {
1250: while (my $configline=<$config>) {
1251: $configline=(split(/\#/,$configline))[0];
1252: $configline=~s/^\s+//;
1253: chomp($configline);
1254: if ($configline) {
1255: $desklines[$#desklines+1]=$configline;
1256: }
1257: }
1258: CORE::close($config);
1259: }
1260: }
1261: $readdesk='done';
1262: }
1263: }
1264:
1265: 1;
1266: __END__
1267:
1268:
1269:
1270:
1271:
1272:
1273:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>