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