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