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