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