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