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