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