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