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