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