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