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