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