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