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