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