Annotation of loncom/interface/lonmenu.pm, revision 1.135
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.135 ! albertel 4: # $Id: lonmenu.pm,v 1.134 2004/12/03 06:51:50 raeburn 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
396: s&7&2&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout','/~$uname/$thisdisfn')&Prepare a printable document
1.120 raeburn 397: ENDMENUITEMS
1.131 raeburn 398: }
1.120 raeburn 399: } else {
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.97 www 463: my $requri=(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.41 www 467: $result = (<<ENDREGTHIS);
1.38 www 468:
1.129 albertel 469: <script type="text/javascript">
1.38 www 470: // BEGIN LON-CAPA Internal
1.42 www 471: var swmenu=null;
1.38 www 472:
473: function LONCAPAreg() {
474: swmenu=$reopen;
475: swmenu.clearTimeout(swmenu.menucltim);
476: $timesync
477: $newmail
1.41 www 478: $buttons
1.84 www 479: swmenu.currentURL="$requri";
1.85 www 480: swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125 albertel 481: swmenu.currentSymb="$cursymb";
482: swmenu.reloadSymb="$cursymb";
1.38 www 483: swmenu.currentStale=0;
1.113 albertel 484: $navstatus
1.38 www 485: $hwkadd
486: $editbutton
487: }
488:
489: function LONCAPAstale() {
490: swmenu=$reopen
491: swmenu.currentStale=1;
492: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
493: swmenu.switchbutton
494: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
495: }
496: swmenu.clearbut(7,1);
497: swmenu.clearbut(7,2);
498: swmenu.clearbut(7,3);
499: swmenu.menucltim=swmenu.setTimeout(
500: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.108 www 501: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);clearbut(6,1)',
1.38 www 502: 2000);
503: }
504:
505: // END LON-CAPA Internal
506: </script>
507: ENDREGTHIS
1.41 www 508: }
509: # =============================================================================
1.38 www 510: } else {
1.41 www 511: # ========================================== This can or will not be registered
512: if ($textual) {
513: # Not registered, textual
514: $result= (<<ENDDONOTREGTEXT);
515: ENDDONOTREGTEXT
516: } else {
517: # Not registered, graphical
518: $result = (<<ENDDONOTREGTHIS);
1.38 www 519:
1.129 albertel 520: <script type="text/javascript">
1.38 www 521: // BEGIN LON-CAPA Internal
1.42 www 522: var swmenu=null;
1.38 www 523:
524: function LONCAPAreg() {
525: swmenu=$reopen
526: $timesync
527: swmenu.currentStale=1;
528: swmenu.clearbut(2,1);
529: swmenu.clearbut(2,3);
530: swmenu.clearbut(8,1);
531: swmenu.clearbut(8,2);
532: swmenu.clearbut(8,3);
533: if (swmenu.currentURL) {
534: swmenu.switchbutton
535: (3,1,'reload.gif','return','location','go(currentURL)');
536: } else {
537: swmenu.clearbut(3,1);
538: }
539: }
540:
541: function LONCAPAstale() {
542: }
543:
544: // END LON-CAPA Internal
545: </script>
546: ENDDONOTREGTHIS
1.41 www 547: }
548: # =============================================================================
1.38 www 549: }
550: return $result;
551: }
552:
553: sub loadevents() {
1.135 ! albertel 554: if ($ENV{'request.state'} eq 'construct' ||
! 555: $ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.38 www 556: return 'LONCAPAreg();';
557: }
558:
559: sub unloadevents() {
1.135 ! albertel 560: if ($ENV{'request.state'} eq 'construct' ||
! 561: $ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.38 www 562: return 'LONCAPAstale();';
563: }
1.30 www 564:
1.32 www 565: # ============================================================= Start up remote
566:
567: sub startupremote {
568: my ($lowerurl)=@_;
1.49 www 569: if (($ENV{'browser.interface'} eq 'textual') ||
570: ($ENV{'environment.remote'} eq 'off')) {
1.34 www 571: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
572: }
1.49 www 573: #
574: # The Remote actually gets launched!
575: #
1.32 www 576: my $configmenu=&rawconfig();
1.52 www 577: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
1.119 www 578: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32 www 579: return(<<ENDREMOTESTARTUP);
1.129 albertel 580: <script type="text/javascript">
1.118 albertel 581: var timestart;
1.35 www 582: function wheelswitch() {
1.118 albertel 583: if (typeof(document.wheel) != 'undefined') {
584: if (typeof(document.wheel.spin) != 'undefined') {
585: var date=new Date();
586: var waited=Math.round(30-((date.getTime()-timestart)/1000));
587: document.wheel.spin.value=$message;
588: }
589: }
1.35 www 590: if (window.status=='|') {
591: window.status='/';
592: } else {
593: if (window.status=='/') {
594: window.status='-';
595: } else {
596: if (window.status=='-') {
597: window.status='\\\\';
598: } else {
599: if (window.status=='\\\\') { window.status='|'; }
600: }
601: }
602: }
603: }
604:
1.32 www 605: // ---------------------------------------------------------- The wait function
606: var canceltim;
607: function wait() {
608: if ((menuloaded==1) || (tim==1)) {
1.35 www 609: window.status='Done.';
1.32 www 610: if (tim==0) {
611: clearTimeout(canceltim);
612: $configmenu
613: window.location='$lowerurl';
614: } else {
1.52 www 615: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32 www 616: }
617: } else {
1.35 www 618: wheelswitch();
619: setTimeout('wait();',200);
1.32 www 620: }
621: }
622:
623: function main() {
1.52 www 624: canceltim=setTimeout('tim=1;',30000);
1.35 www 625: window.status='-';
1.118 albertel 626: var date=new Date();
627: timestart=date.getTime();
1.32 www 628: wait();
629: }
630:
631: </script>
632: ENDREMOTESTARTUP
633: }
634:
635: sub setflags() {
636: return(<<ENDSETFLAGS);
1.129 albertel 637: <script type="text/javascript">
1.32 www 638: menuloaded=0;
639: tim=0;
640: </script>
641: ENDSETFLAGS
642: }
643:
644: sub maincall() {
1.49 www 645: if (($ENV{'browser.interface'} eq 'textual') ||
646: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.32 www 647: return(<<ENDMAINCALL);
1.129 albertel 648: <script type="text/javascript">
1.32 www 649: main();
650: </script>
651: ENDMAINCALL
652: }
1.118 albertel 653:
654: sub load_remote_msg {
655: my ($lowerurl)=@_;
656:
657: if (($ENV{'browser.interface'} eq 'textual') ||
658: ($ENV{'environment.remote'} eq 'off')) { return ''; }
659:
660: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
1.119 www 661: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
1.118 albertel 662: "/adm/remote?action=collapse?url=$esclowerurl");
663: return(<<ENDREMOTEFORM);
664: <p>
665: <form name="wheel">
1.119 www 666: <input name="spin" type="text" size="60" />
1.118 albertel 667: </form>
668: </p>
669: <p>$link</p>
670: ENDREMOTEFORM
671: }
1.30 www 672: # ================================================================= Reopen menu
673:
674: sub reopenmenu {
1.49 www 675: if (($ENV{'browser.interface'} eq 'textual') ||
676: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 677: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.47 matthew 678: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
679: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30 www 680: }
681:
1.1 www 682: # =============================================================== Open the menu
683:
684: sub open {
1.22 www 685: my $returnval='';
1.49 www 686: if (($ENV{'browser.interface'} eq 'textual') ||
1.111 albertel 687: ($ENV{'environment.remote'} eq 'off')) {
688: return '<script type="text/javascript">self.name="loncapaclient";</script>';
689: }
1.30 www 690: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.22 www 691: unless (shift eq 'unix') {
692: # resizing does not work on linux because of virtual desktop sizes
693: $returnval.=(<<ENDRESIZE);
694: if (window.screen) {
1.28 www 695: self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1.22 www 696: self.moveTo(190,15);
697: }
698: ENDRESIZE
699: }
700: $returnval.=(<<ENDOPEN);
1.35 www 701: window.status='Opening LON-CAPA Remote Control';
1.30 www 702: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.14 www 703: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71 www 704: self.name='loncapaclient';
1.1 www 705: ENDOPEN
1.129 albertel 706: return '<script type="text/javascript">'.$returnval.'</script>';
1.1 www 707: }
708:
1.2 www 709:
710: # ================================================================== Raw Config
711:
1.3 www 712: sub clear {
713: my ($row,$col)=@_;
1.49 www 714: unless (($ENV{'browser.interface'} eq 'textual') ||
715: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 716: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56 www 717: } else {
718: $inlineremote[10*$row+$col]='';
719: return '';
720: }
1.3 www 721: }
722:
1.40 www 723: # ============================================ Switch a button or create a link
1.25 matthew 724: # Switch acts on the javascript that is executed when a button is clicked.
725: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 726:
1.2 www 727: sub switch {
1.40 www 728: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
1.2 www 729: $act=~s/\$uname/$uname/g;
730: $act=~s/\$udom/$udom/g;
1.88 www 731: $top=&mt($top);
732: $bot=&mt($bot);
733: $desc=&mt($desc);
1.105 www 734: $img=&mt($img);
1.49 www 735: unless (($ENV{'browser.interface'} eq 'textual') ||
736: ($ENV{'environment.remote'} eq 'off')) {
1.50 www 737: # Remote
1.34 www 738: return "\n".
1.35 www 739: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.50 www 740: } elsif ($ENV{'browser.interface'} eq 'textual') {
741: # Accessibility
742: if ($nobreak==2) { return ''; }
743: my $text=$top.' '.$bot;
1.78 www 744: $text=~s/\s*\-\s*//gs;
1.94 www 745: if ($nobreak) {
746: $inlineremote[10*$row+$col]=
747: '<a href="javascript:'.$act.';">'.$text.'</a>';
748: } else {
749: $inlineremote[10*$row+$col]="\n<br />".
1.100 www 750: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
1.94 www 751: }
1.34 www 752: } else {
1.50 www 753: # Inline Remote
1.41 www 754: if ($nobreak==2) { return ''; }
1.34 www 755: my $text=$top.' '.$bot;
1.78 www 756: $text=~s/\s*\-\s*//gs;
1.105 www 757:
758: my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
759: if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
1.99 www 760: my $pic=
1.105 www 761: '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.
762: ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.
1.103 www 763: ($nobreak==3?'right':'left').'" />';
764: if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'browser.interface'} eq 'faketextual')) {
765: # Accessibility
766: if ($nobreak==3) {
767: $inlineremote[10*$row+$col]="\n".
768: '<td width="40%" align="right"><font color="'.$font.'" size="+1">'.$text.
769: '</font></td><td width="10%" align="right" bgcolor="'.$tabbg.'">'.
770: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
771: } elsif ($nobreak) {
772: $inlineremote[10*$row+$col]="\n<tr>".
773: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
774: '<a href="javascript:'.$act.';">'.$pic.
775: '</a></td><td width="40%" align="left"><font color="'.$font.'" size="+1">'.$text.'</font></td>';
776: } else {
777: $inlineremote[10*$row+$col]="\n<tr>".
778: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
779: '<a href="javascript:'.$act.';">'.$pic.
780: '</a></td><td colspan="3"><font color="'.$font.'">'.$desc.
781: '</font></td></tr>';
782: }
1.94 www 783: } else {
1.103 www 784: # Inline Menu
785: $inlineremote[10*$row+$col]=
786: '<a href="javascript:'.$act.';">'.$pic.
787: '</a><font color="'.$font.'" size="2">'.$desc.
788: '</font>';
1.94 www 789: }
1.34 www 790: }
1.56 www 791: return '';
1.2 www 792: }
793:
794: sub secondlevel {
795: my $output='';
796: my
1.27 www 797: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
1.2 www 798: if ($prt eq 'any') {
1.27 www 799: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 800: } elsif ($prt=~/^r(\w+)/) {
801: if ($rol eq $1) {
1.27 www 802: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 803: }
804: }
805: return $output;
806: }
807:
1.18 www 808: sub openmenu {
1.30 www 809: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.49 www 810: if (($ENV{'browser.interface'} eq 'textual') ||
811: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.47 matthew 812: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
813: return "window.open(".$nothing.",'".$menuname."');";
1.18 www 814: }
815:
1.56 www 816: sub inlinemenu {
817: @inlineremote=();
818: undef @inlineremote;
819: &rawconfig(1);
820: return join('',map { (defined($_)?$_:'') } @inlineremote);
821: }
822:
1.2 www 823: sub rawconfig {
1.34 www 824: my $textualoverride=shift;
825: my $output='';
1.49 www 826: unless (($ENV{'browser.interface'} eq 'textual') ||
827: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 828: $output.=
829: "window.status='Opening Remote Control';var swmenu=".&openmenu().
830: "\nwindow.status='Configuring Remote Control ';";
1.34 www 831: } else {
832: unless ($textualoverride) { return ''; }
833: }
1.2 www 834: my $uname=$ENV{'user.name'};
835: my $udom=$ENV{'user.domain'};
836: my $adv=$ENV{'user.adv'};
1.4 www 837: my $author=$ENV{'user.author'};
1.5 www 838: my $crs='';
839: if ($ENV{'request.course.id'}) {
840: $crs='/'.$ENV{'request.course.id'};
1.7 www 841: if ($ENV{'request.course.sec'}) {
842: $crs.='_'.$ENV{'request.course.sec'};
843: }
1.8 www 844: $crs=~s/\_/\//g;
1.5 www 845: }
1.2 www 846: my $pub=($ENV{'request.state'} eq 'published');
847: my $con=($ENV{'request.state'} eq 'construct');
848: my $rol=$ENV{'request.role'};
1.25 matthew 849: my $requested_domain = $ENV{'request.role.domain'};
1.13 harris41 850: foreach (@desklines) {
1.27 www 851: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
1.3 www 852: $prt=~s/\$uname/$uname/g;
853: $prt=~s/\$udom/$udom/g;
1.5 www 854: $prt=~s/\$crs/$crs/g;
1.25 matthew 855: $prt=~s/\$requested_domain/$requested_domain/g;
1.3 www 856: if ($pro eq 'clear') {
1.4 www 857: $output.=&clear($row,$col);
1.3 www 858: } elsif ($pro eq 'any') {
1.2 www 859: $output.=&secondlevel(
1.27 www 860: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 861: } elsif ($pro eq 'smp') {
862: unless ($adv) {
863: $output.=&secondlevel(
1.27 www 864: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 865: }
866: } elsif ($pro eq 'adv') {
867: if ($adv) {
868: $output.=&secondlevel(
1.27 www 869: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 870: }
1.81 matthew 871: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.2 www 872: if (&Apache::lonnet::allowed($1,$prt)) {
1.27 www 873: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.4 www 874: }
1.26 www 875: } elsif ($pro eq 'course') {
876: if ($ENV{'request.course.fn'}) {
1.27 www 877: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.81 matthew 878: }
1.124 matthew 879: } elsif ($pro =~ /^courseenv_(.*)$/) {
880: my $key = $1;
881: if ($ENV{'course.'.$ENV{'request.course.id'}.'.'.$key}) {
882: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
883: }
1.81 matthew 884: } elsif ($pro =~ /^course_(.*)$/) {
885: # Check for permissions inside of a course
886: if (($ENV{'request.course.id'}) &&
887: (&Apache::lonnet::allowed($1,$ENV{'request.course.id'}.
888: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))
889: )) {
890: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.26 www 891: }
1.4 www 892: } elsif ($pro eq 'author') {
893: if ($author) {
1.29 matthew 894: if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
895: (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
1.19 matthew 896: # Check that we are on the correct machine
1.29 matthew 897: my $cadom=$requested_domain;
898: my $caname=$ENV{'user.name'};
899: if ($prt eq 'rca') {
900: ($cadom,$caname)=
1.6 www 901: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.29 matthew 902: }
903: $act =~ s/\$caname/$caname/g;
1.19 matthew 904: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 905: my $allowed=0;
906: my @ids=&Apache::lonnet::current_machine_ids();
907: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
908: if ($allowed) {
1.19 matthew 909: $output.=switch($caname,$cadom,
1.27 www 910: $row,$col,$img,$top,$bot,$act,$desc);
1.19 matthew 911: }
1.6 www 912: }
1.2 www 913: }
914: }
1.13 harris41 915: }
1.49 www 916: unless (($ENV{'browser.interface'} eq 'textual') ||
917: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 918: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123 www 919: if (&Apache::lonmsg::newmail()) {
920: $output.='swmenu.setstatus("you have","messages");';
921: }
1.34 www 922: }
1.123 www 923:
1.2 www 924: return $output;
925: }
926:
927: # ======================================================================= Close
1.1 www 928:
929: sub close {
1.49 www 930: if (($ENV{'browser.interface'} eq 'textual') ||
931: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 932: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.1 www 933: return(<<ENDCLOSE);
1.129 albertel 934: <script type="text/javascript">
1.35 www 935: window.status='Accessing Remote Control';
1.30 www 936: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 937: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 938: window.status='Disabling Remote Control';
939: menu.active=0;
1.31 www 940: menu.autologout=0;
1.35 www 941: window.status='Closing Remote Control';
1.1 www 942: menu.close();
1.35 www 943: window.status='Done.';
1.1 www 944: </script>
945: ENDCLOSE
946: }
947:
948: # ====================================================================== Footer
949:
950: sub footer {
951:
1.33 www 952: }
953:
1.122 albertel 954: sub nav_control_js {
955: my $nav=($ENV{'environment.remotenavmap'} eq 'on');
956: return (<<NAVCONTROL);
957: var w_loncapanav_flag="$nav";
958:
959:
960: function gonav(url) {
961: if (w_loncapanav_flag != 1) {
962: gopost(url,'');
963: } else {
964: navwindow=window.open(url,
965: "loncapanav","height=600,width=400,scrollbars=1");
966: }
967: }
968: NAVCONTROL
969: }
970:
1.42 www 971: sub utilityfunctions {
1.132 raeburn 972: my $caller = shift;
1.51 www 973: unless (($ENV{'browser.interface'} eq 'textual') ||
1.132 raeburn 974: ($ENV{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1.126 albertel 975: my $currenturl=&Apache::lonenc::check_encrypt($ENV{'request.noversionuri'});
1.125 albertel 976:
1.126 albertel 977: my $currentsymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'});
1.122 albertel 978: my $nav_control=&nav_control_js();
1.42 www 979: return (<<ENDUTILITY)
980:
981: var currentURL="$currenturl";
982: var reloadURL="$currenturl";
983: var currentSymb="$currentsymb";
984:
1.114 albertel 985: $nav_control
986:
1.42 www 987: function go(url) {
988: if (url!='' && url!= null) {
989: currentURL = null;
990: currentSymb= null;
991: window.location.href=url;
992: }
993: }
994:
995: function gopost(url,postdata) {
996: if (url!='') {
997: this.document.server.action=url;
998: this.document.server.postdata.value=postdata;
999: this.document.server.command.value='';
1000: this.document.server.url.value='';
1001: this.document.server.symb.value='';
1002: this.document.server.submit();
1003: }
1004: }
1005:
1006: function gocmd(url,cmd) {
1007: if (url!='') {
1008: this.document.server.action=url;
1009: this.document.server.postdata.value='';
1010: this.document.server.command.value=cmd;
1011: this.document.server.url.value=currentURL;
1012: this.document.server.symb.value=currentSymb;
1013: this.document.server.submit();
1014: }
1.57 www 1015: }
1016:
1.121 raeburn 1017: function gocstr(url,filename) {
1018: if (url == '/adm/cfile?action=delete') {
1019: this.document.cstrdelete.filename.value = filename
1020: this.document.cstrdelete.submit();
1021: return;
1022: }
1023: if (url !='') {
1024: this.document.constspace.filename.value = filename;
1025: this.document.constspace.action = url;
1026: this.document.constspace.submit();
1027: }
1028: }
1029:
1.131 raeburn 1030: function golist(url) {
1031: if (url!='' && url!= null) {
1032: currentURL = null;
1033: currentSymb= null;
1034: top.location.href=url;
1035: }
1036: }
1037:
1038:
1.121 raeburn 1039:
1.57 www 1040: function catalog_info() {
1.102 albertel 1041: 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 1042: }
1043:
1044: function chat_win() {
1.102 albertel 1045: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1046: }
1047: ENDUTILITY
1048: }
1049:
1050: sub serverform {
1051: return(<<ENDSERVERFORM);
1052:
1.62 www 1053: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1054: <input type="hidden" name="postdata" value="none" />
1055: <input type="hidden" name="command" value="none" />
1056: <input type="hidden" name="url" value="none" />
1057: <input type="hidden" name="symb" value="none" />
1058: </form>
1059: ENDSERVERFORM
1060: }
1.113 albertel 1061:
1.121 raeburn 1062: sub constspaceform {
1063: return(<<ENDCONSTSPACEFORM);
1064: <form name="constspace" action="/adm/logout" method="post" target="_top">
1065: <input type="hidden" name="filename" value="" />
1066: </form>
1067: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1068: <input type="hidden" name="action" value="delete" />
1069: <input type="hidden" name="filename" value="" />
1070: </form>
1071: ENDCONSTSPACEFORM
1072: }
1073:
1074:
1.113 albertel 1075: sub get_nav_status {
1076: my $navstatus="swmenu.w_loncapanav_flag=";
1077: if ($ENV{'environment.remotenavmap'} eq 'on') {
1078: $navstatus.="1";
1079: } else {
1080: $navstatus.="-1";
1081: }
1082: return $navstatus;
1083: }
1084:
1.33 www 1085: # ================================================ Handler when called directly
1086:
1087:
1088: sub handler {
1089: my $r = shift;
1.93 www 1090: &Apache::loncommon::content_type($r,'text/html');
1.33 www 1091: $r->send_http_header;
1092: return OK if $r->header_only;
1093:
1.130 albertel 1094: my $form;
1095: if ($ENV{'environment.remote'} ne 'off' &&
1096: $ENV{'browser.interface'} ne 'textual') {
1097: $form=&serverform();
1098: }
1.34 www 1099: my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1.58 www 1100: my $function='student';
1101: if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
1102: $function='coordinator';
1103: }
1104: if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
1105: $function='admin';
1106: }
1107: if (($ENV{'request.role'}=~/^(au|ca)/) ||
1.97 www 1108: ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
1.58 www 1109: $function='author';
1110: }
1111: my $domain=&Apache::loncommon::determinedomain();
1112: $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
1113: $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
1114: $font=&Apache::loncommon::designparm($function.'.font',$domain);
1.132 raeburn 1115: my $script_tag;
1116: if ($ENV{'environment.remote'} eq 'on') {
1117: my $utility=&utilityfunctions('/adm/menu');
1118: $script_tag=(<<ENDSCRIPT);
1119: <script type="text/javascript">
1120: $utility
1121: </script>
1122: ENDSCRIPT
1123: }
1124: # ---- Print the screen, pretend to be in text mode to generate text-based menu
1.103 www 1125: unless ($ENV{'browser.interface'} eq 'textual') {
1126: $ENV{'browser.interface'}='faketextual';
1.53 www 1127: $ENV{'environment.remote'}='off';
1128: }
1.36 www 1129: $r->print(<<ENDHEADER);
1130: <html><head>
1131: <title>LON-CAPA Main Menu</title>
1.132 raeburn 1132: $script_tag
1.36 www 1133: </head>
1134: $bodytag
1135: ENDHEADER
1.58 www 1136: $r->print('<table>'.&inlinemenu().'</table>'.$form);
1.33 www 1137: $r->print('</body></html>');
1138: return OK;
1.1 www 1139: }
1140:
1.2 www 1141: # ================================================================ Main Program
1142:
1.16 harris41 1143: BEGIN {
1.15 matthew 1144: if (! defined($readdesk)) {
1.14 www 1145: {
1.104 raeburn 1146: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1147: if ( CORE::open( my $config,"<$tabfile") ) {
1148: while (my $configline=<$config>) {
1149: $configline=(split(/\#/,$configline))[0];
1150: $configline=~s/^\s+//;
1151: chomp($configline);
1152: if ($configline) {
1153: $desklines[$#desklines+1]=$configline;
1154: }
1155: }
1156: CORE::close($config);
1.2 www 1157: }
1.14 www 1158: }
1159: $readdesk='done';
1.10 albertel 1160: }
1.2 www 1161: }
1.30 www 1162:
1.1 www 1163: 1;
1164: __END__
1165:
1166:
1167:
1168:
1169:
1170:
1171:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>