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