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