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