File:
[LON-CAPA] /
loncom /
interface /
lonmenu.pm
Revision
1.244.2.1:
download - view:
text,
annotated -
select for diffs
Wed May 20 20:11:35 2009 UTC (15 years, 3 months ago) by
raeburn
Branches:
version_2_9_X
- Backport 1.248, 1.249, 1.251, 1.252, 1.255, 1.257, 1.258, 1.259,
1.261, 1.262, 1.264, 1.266
1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.244.2.1 2009/05/20 20:11:35 raeburn Exp $
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: #
28: #
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'
37: #
38:
39: =head1 NAME
40:
41: Apache::lonmenu
42:
43: =head1 SYNOPSIS
44:
45: Coordinates the response to clicking an image.
46:
47: This is part of the LearningOnline Network with CAPA project
48: described at http://www.lon-capa.org.
49:
50: =head1 SUBROUTINES
51:
52: =over
53:
54: =item show_course()
55:
56: Little texts
57:
58: =item initlittle()
59:
60: =item menubuttons()
61:
62: This gets called at the top of the body section
63:
64: =item show_return_link()
65:
66: =item registerurl()
67:
68: This gets called in the header section
69:
70: =item innerregister()
71:
72: This gets called in order to register a URL, both with the Remote
73: and in the body of the document
74:
75: =item loadevents()
76:
77: =item unloadevents()
78:
79: =item startupremote()
80:
81: =item setflags()
82:
83: =item maincall()
84:
85: =item load_remote_msg()
86:
87: =item get_menu_name()
88:
89: =item reopenmenu()
90:
91: =item open()
92:
93: Open the menu
94:
95: =item clear()
96:
97: =item switch()
98:
99: Switch a button or create a link
100: Switch acts on the javascript that is executed when a button is clicked.
101: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
102:
103: =item secondlevel()
104:
105: =item openmenu()
106:
107: =item inlinemenu()
108:
109: =item rawconfig()
110:
111: =item close()
112:
113: =item footer()
114:
115: =item utilityfunctions()
116:
117: =item serverform()
118:
119: =item constspaceform()
120:
121: =item get_nav_status()
122:
123: =item convert_menu_function()
124:
125: FIXME this needs to move into mydesktab and the other locations
126: the text is generated
127:
128: =item hidden_button_check()
129:
130: =item roles_selector()
131:
132: =item jump_to_role()
133:
134: =back
135:
136: =cut
137:
138: package Apache::lonmenu;
139:
140: use strict;
141: use Apache::lonnet;
142: use Apache::lonhtmlcommon();
143: use Apache::loncommon();
144: use Apache::lonenc();
145: use Apache::lonlocal;
146: use LONCAPA qw(:DEFAULT :match);
147:
148: use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
149:
150:
151: my @inlineremote;
152:
153:
154:
155: sub show_course {
156: my $course = !$env{'user.adv'};
157: if (!$env{'user.adv'}) {
158: foreach my $env (keys(%env)) {
159: next if ($env !~ m/^user\.priv\./);
160: if ($env !~ m/^user\.priv\.(?:st|cm)/) {
161: $course = 0;
162: last;
163: }
164: }
165: }
166: return $course;
167: }
168:
169: sub initlittle {
170: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
171: 'nav' => 'Navigate Contents',
172: 'main' => 'Main Menu',
173: 'roles' => (&Apache::loncommon::show_course()?
174: 'Courses':'Roles'),
175: 'other' => 'Other Roles',
176: 'docs' => 'Edit Course',
177: 'exit' => 'Logout',
178: 'login' => 'Log In',
179: 'launch' => 'Launch Remote Control',
180: 'groups' => 'Groups',
181: 'gdoc' => 'Group Documents',
182: );
183: }
184:
185: sub menubuttons {
186: my $forcereg=shift;
187: my $registration=shift;
188: my $titletable=shift;
189: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
190: ['inhibitmenu']);
191: if (($env{'form.inhibitmenu'} eq 'yes') ||
192: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
193:
194: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
195:
196: my %lt=&initlittle();
197: my $navmaps='';
198: my $reloadlink='';
199: my $docs='';
200: my $groups='';
201: my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
202: my $role_selector;
203: my $showgroups=0;
204: my ($cnum,$cdom);
205: my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
206: my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
207:
208: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
209: $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.
210: $logo.'" alt="LON-CAPA Logo" /></a></td>';
211:
212: if ($env{'request.state'} eq 'construct') {
213: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
214: my $returnurl = $env{'request.filename'};
215: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
216: $escurl = &escape($returnurl);
217: }
218: }
219: if ($env{'request.course.id'}) {
220: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
221: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
222: my %coursegroups;
223: my $viewgrps_permission =
224: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
225: if (!$viewgrps_permission) {
226: %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
227: }
228: if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
229: $showgroups = 1;
230: }
231: $role_selector = &roles_selector($cdom,$cnum);
232: if ($role_selector) {
233: $roles = '<span class="LC_nobreak">'.$role_selector.' <a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>';
234: }
235: }
236:
237: if ($env{'browser.interface'} eq 'textual') {
238: # Textual display only
239: if ($env{'request.course.id'}) {
240: $navmaps=(<<ENDNAV);
241: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
242: ENDNAV
243: if (&show_return_link()) {
244: my $escreload=&escape('return:');
245: $reloadlink=(<<ENDRELOAD);
246: <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
247: ENDRELOAD
248: }
249: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
250: $docs=(<<ENDDOCS);
251: <a href="/adm/coursedocs" target="_top">$lt{'docs'}</a>
252: ENDDOCS
253: }
254: if ($showgroups) {
255: $groups =(<<ENDGROUPS);
256: <a href="/adm/coursegroups" target="_top">$lt{'groups'}</a>
257: ENDGROUPS
258: }
259: }
260: my $form=&serverform();
261: my $utility=&utilityfunctions();
262: my $output=(<<ENDMAINMENU);
263: <script type="text/javascript">
264: // BEGIN LON-CAPA Internal
265: $utility
266: </script>
267: <div id="LC_top_nav">
268: <a href="/adm/menu" target="_top">$lt{'main'}</a>
269: $reloadlink $navmaps $docs $groups $roles
270: <a href="/adm/logout" target="_top">$lt{'exit'}</a>
271: </div>
272: <br />
273: <script type="text/javascript">
274: // END LON-CAPA Internal
275: </script>
276: $form
277: ENDMAINMENU
278: if ($registration) { $output.=&innerregister($forcereg); }
279: return $output."<hr />";
280: } elsif ($env{'environment.remote'} eq 'off') {
281: # Remote Control is switched off
282: # figure out colors
283: my %lt=&initlittle();
284:
285: my $domain=&Apache::loncommon::determinedomain();
286: my $function =&Apache::loncommon::get_users_function();
287: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
288: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
289: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
290: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
291: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
292: return (<<ENDINLINEMENU);
293: <table id="LC_top_nav">
294: <tr>
295: $logo
296: <td></td>
297: <td class="LC_top_nav_login">
298: <a href="/adm/roles" target="_top">$lt{'login'}</a>
299: </td>
300: </tr>
301: </table>
302: </font>
303: ENDINLINEMENU
304: }
305: $roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>';
306: # Do we have a NAV link?
307: if ($env{'request.course.id'}) {
308: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
309: $escsymb;
310: if ($env{'environment.remotenavmap'} eq 'on') {
311: $link="javascript:gonav('".$link."')";
312: }
313: $navmaps=(<<ENDNAV);
314: <td><a href="$link" target="_top">$lt{'nav'}</a></td>
315: ENDNAV
316: my $is_group = (&Apache::loncommon::course_type() eq 'Group');
317: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
318: my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
319: $docs=(<<ENDDOCS);
320: <td><a href="/adm/coursedocs" target="_top">$text</a></td>
321: ENDDOCS
322: }
323: if ($showgroups) {
324: $groups =(<<ENDGROUPS);
325: <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>
326: ENDGROUPS
327: }
328: if (&show_return_link()) {
329: my $escreload=&escape('return:');
330: $reloadlink=(<<ENDRELOAD);
331: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
332: ENDRELOAD
333: }
334: if ($role_selector) {
335: $roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
336: }
337: }
338: if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
339: my $escreload=&escape('return:');
340: $reloadlink=(<<ENDCRELOAD);
341: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
342: ENDCRELOAD
343: }
344: my $reg='';
345: if ($registration) {
346: $reg=&innerregister($forcereg,$titletable);
347: }
348: my $form=&serverform();
349: my $utility=&utilityfunctions();
350:
351: my $helplink=&Apache::loncommon::top_nav_help('Help');
352: return (<<ENDINLINEMENU);
353: <script type="text/javascript">
354: // BEGIN LON-CAPA Internal
355: // <![CDATA[
356: $utility
357: // ]]>
358: </script>
359: <table id="LC_top_nav">
360: <tr>
361: $logo
362: <td><a href="/adm/menu" target="_top">$lt{'main'}</a></td>
363: $reloadlink
364: $navmaps
365: $docs
366: $groups
367: $roles
368: <td class="LC_top_nav_help">$helplink</td>
369: <td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
370: </tr>
371: </table>
372: $form
373: <script type="text/javascript">
374: // END LON-CAPA Internal
375: </script>
376: $reg
377: ENDINLINEMENU
378: } else {
379: return '';
380: }
381: }
382:
383: sub show_return_link {
384: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
385: $env{'request.symb'} eq '')
386: ||
387: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
388: ||
389: (($env{'request.noversionuri'}=~/^\/adm\//) &&
390: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
391: ($env{'request.noversionuri'}!~
392: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
393: ));
394: }
395:
396:
397: sub registerurl {
398: my ($forcereg) = @_;
399: my $result = '';
400: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
401: my $force_title='';
402: if ($env{'request.state'} eq 'construct') {
403: $force_title=&Apache::lonxml::display_title();
404: }
405: if (($env{'browser.interface'} eq 'textual') ||
406: ($env{'environment.remote'} eq 'off') ||
407: ((($env{'request.publicaccess'}) ||
408: (!&Apache::lonnet::is_on_map(
409: &unescape($env{'request.noversionuri'})))) &&
410: (!$forcereg))) {
411: return $result.
412: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
413: }
414: # Graphical display after login only
415: if ($env{'request.registered'} && !$forcereg) { return ''; }
416: $result.=&innerregister($forcereg);
417: return $result.$force_title;
418: }
419:
420: sub innerregister {
421: my ($forcereg, $titletable) = @_;
422: my $result = '';
423: my ($uname,$thisdisfn);
424: my $const_space = ($env{'request.state'} eq 'construct');
425: my $is_const_dir = 0;
426:
427: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
428:
429: $env{'request.registered'} = 1;
430:
431: my $textinter=($env{'browser.interface'} eq 'textual');
432: my $noremote=($env{'environment.remote'} eq 'off');
433:
434: my $textual=($textinter || $noremote);
435:
436: undef(@inlineremote);
437:
438: my $reopen=&Apache::lonmenu::reopenmenu();
439:
440: my $newmail='';
441: if ($noremote) {
442: $newmail='<table id="LC_nav_location"><tr>';
443: }
444: if (&Apache::lonmsg::newmail()) {
445: if ($textual) {
446: $newmail.= '<td class="LC_new_mail">
447: <a href="/adm/communicate" target="_top">'.
448: &mt('You have new messages').'</a></td>';
449: } else {
450: $newmail= 'swmenu.setstatus("you have","messages");';
451: }
452: }
453: if (($textual)
454: && ($env{'request.symb'})
455: && ($env{'request.course.id'})) {
456: $newmail.= '<td class="LC_current_location">';
457: my ($mapurl,$rid,$resurl)=
458: &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
459: my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
460: $newmail.=$coursetitle;
461: my $maptitle=&Apache::lonnet::gettitle($mapurl);
462: my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
463: if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
464: $newmail.=', '.$maptitle;
465: }
466: if ($restitle) {
467: $newmail.=': '.$restitle;
468: }
469: $newmail.=' </td>';
470: }
471: if ($env{'request.state'} eq 'construct') {
472: $newmail = $titletable;
473: } else {
474: if ($noremote) {
475: $newmail.='</tr></table>';
476: }
477: }
478: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
479: my $tablestart=($noremote?'<table id="LC_menubuttons">':'').
480: ($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
481: my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':'');
482: # =============================================================================
483: # ============================ This is for URLs that actually can be registered
484: if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
485: # -- This applies to homework problems for users with grading privileges
486: my $crs='/'.$env{'request.course.id'};
487: if ($env{'request.course.sec'}) {
488: $crs.='_'.$env{'request.course.sec'};
489: }
490: $crs=~s/\_/\//g;
491:
492: my $hwkadd='';
493: if ($env{'request.symb'} ne '' &&
494: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
495: if (&Apache::lonnet::allowed('mgr',$crs)) {
496: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
497: "gocmd('/adm/grades','gradingmenu')",
498: 'Modify user grades for this assessment resource');
499: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
500: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
501: "gocmd('/adm/grades','submission')",
502: 'View user submissions for this assessment resource');
503: }
504: }
505: if ($env{'request.symb'} ne '' &&
506: &Apache::lonnet::allowed('opa',$crs)) {
507: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
508: "gocmd('/adm/parmset','set')",
509: 'Modify parameter settings for this resource');
510: }
511: # -- End Homework
512: ###
513: ### Determine whether or not to display the 'cstr' button for this
514: ### resource
515: ###
516: my $editbutton = '';
517: my $noeditbutton = 1;
518: my ($cnum,$cdom);
519: if ($env{'request.course.id'}) {
520: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
521: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
522: }
523: if ($env{'user.author'}) {
524: if ($env{'request.role'}=~/^(aa|ca|au)/) {
525: # Set defaults for authors
526: my ($top,$bottom) = ('con-','struct');
527: my $action = "go('/priv/".$env{'user.name'}."');";
528: my $cadom = $env{'request.role.domain'};
529: my $caname = $env{'user.name'};
530: my $desc = "Enter my construction space";
531: # Set defaults for co-authors
532: if ($env{'request.role'} =~ /^ca/) {
533: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
534: ($top,$bottom) = ('co con-','struct');
535: $action = "go('/priv/".$caname."');";
536: $desc = "Enter construction space as co-author";
537: } elsif ($env{'request.role'} =~ /^aa/) {
538: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
539: ($top,$bottom) = ('co con-','struct');
540: $action = "go('/priv/".$caname."');";
541: $desc = "Enter construction space as assistant co-author";
542: }
543: # Check that we are on the correct machine
544: my $home = &Apache::lonnet::homeserver($caname,$cadom);
545: my $allowed=0;
546: my @ids=&Apache::lonnet::current_machine_ids();
547: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
548: if (!$allowed) {
549: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
550: $noeditbutton = 0;
551: }
552: }
553: ##
554: ## Determine if user can edit url.
555: ##
556: my $cfile='';
557: my $cfuname='';
558: my $cfudom='';
559: my $uploaded;
560: if ($env{'request.filename'}) {
561: my $file=&Apache::lonnet::declutter($env{'request.filename'});
562: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
563: # Check that the user has permission to edit this resource
564: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
565: if (defined($cfudom)) {
566: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
567: my $allowed=0;
568: my @ids=&Apache::lonnet::current_machine_ids();
569: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
570: if ($allowed) {
571: $cfile=$file;
572: }
573: }
574: }
575: # Finally, turn the button on or off
576: if ($cfile && !$const_space) {
577: $editbutton=&switch
578: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
579: "go('".$cfile."');","Edit this resource");
580: $noeditbutton = 0;
581: } elsif ($editbutton eq '') {
582: $editbutton=&clear(6,1);
583: }
584: }
585: if (($noeditbutton) && ($env{'request.filename'})) {
586: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
587: my $file=&Apache::lonnet::declutter($env{'request.filename'});
588: if (defined($cnum) && defined($cdom)) {
589: if (&is_course_upload($file,$cnum,$cdom)) {
590: my $cfile = &edit_course_upload($file,$cnum,$cdom);
591: if ($cfile) {
592: $editbutton=&switch
593: ('','',6,1,'pcstr.gif','edit[_1]',
594: 'resource[_2]',"go('".$cfile."');",
595: 'Edit this resource');
596: }
597: }
598: }
599: }
600: }
601: ###
602: ###
603: # Prepare the rest of the buttons
604: my $menuitems;
605: if ($const_space) {
606: my ($uname,$thisdisfn) =
607: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
608: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
609: if ($currdir =~ m-/$-) {
610: $is_const_dir = 1;
611: } else {
612: $currdir =~ s#[^/]+$##;
613: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
614: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
615: $menuitems=(<<ENDMENUITEMS);
616: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
617: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
618: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
619: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
620: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
621: ENDMENUITEMS
622: }
623: } elsif ( defined($env{'request.course.id'}) &&
624: $env{'request.symb'} ne '' ) {
625: $menuitems=(<<ENDMENUITEMS);
626: c&3&1
627: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
628: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
629: c&6&3
630: c&8&1
631: c&8&2
632: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
633: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
634: ENDMENUITEMS
635:
636: my $currentURL = &Apache::loncommon::get_symb();
637: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
638: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
639: $menuitems.="s&9&3&";
640: if(length($annotation) > 0){
641: $menuitems.="anot2.gif";
642: }else{
643: $menuitems.="anot.gif";
644: }
645: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
646: $menuitems.="Make notes and annotations about this resource&&1\n";
647:
648: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
649: if (!$env{'request.enc'}) {
650: $menuitems.=(<<ENDREALRES);
651: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
652: ENDREALRES
653: }
654: $menuitems.=(<<ENDREALRES);
655: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
656: 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
657: ENDREALRES
658: }
659: }
660: if ($env{'request.uri'} =~ /^\/res/) {
661: $menuitems .= (<<ENDMENUITEMS);
662: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
663: ENDMENUITEMS
664: }
665: my $buttons='';
666: foreach (split(/\n/,$menuitems)) {
667: my ($command,@rest)=split(/\&/,$_);
668: my $idx=10*$rest[0]+$rest[1];
669: if (&hidden_button_check() eq 'yes') {
670: if ($idx == 21 ||$idx == 23) {
671: $buttons.=&switch('','',@rest);
672: } else {
673: $buttons.=&clear(@rest);
674: }
675: } else {
676: if ($command eq 's') {
677: $buttons.=&switch('','',@rest);
678: } else {
679: $buttons.=&clear(@rest);
680: }
681: }
682: }
683:
684: if ($textual) {
685: my $addremote=0;
686: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
687: my $inlinebuttons='';
688: if ($addremote) {
689: # Registered, textual output
690: if ($env{'browser.interface'} eq 'textual') {
691: $inlinebuttons=
692: join('',map { (defined($_)?$_:'') } @inlineremote);
693: } else {
694: if ($env{'environment.icons'} eq 'iconsonly') {
695: $inlinebuttons=(<<ENDARROWSINLINE);
696: <tr><td>
697: $inlineremote[21] $inlineremote[23]
698: ENDARROWSINLINE
699: if (&hidden_button_check() ne 'yes') {
700: $inlinebuttons .= (<<ENDINLINEICONS);
701: $inlineremote[61] $inlineremote[63]
702: $inlineremote[71] $inlineremote[72] $inlineremote[73]
703: $inlineremote[81] $inlineremote[82] $inlineremote[83]
704: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
705: ENDINLINEICONS
706: }
707: } else {
708: if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
709: $inlinebuttons=(<<ENDFIRSTLINE);
710: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
711: ENDFIRSTLINE
712: }
713: if (&hidden_button_check() ne 'yes') {
714: foreach my $row (6..9) {
715: if ($inlineremote[${row}.'1'] ne ''
716: || $inlineremote[$row.'2'] ne ''
717: || $inlineremote[$row.'3'] ne '') {
718: $inlinebuttons .= <<"ENDLINE";
719: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
720: ENDLINE
721: }
722: }
723: }
724: }
725: }
726: }
727: $result =(<<ENDREGTEXT);
728: <script type="text/javascript">
729: // BEGIN LON-CAPA Internal
730: </script>
731: $timesync
732: $tablestart
733: $inlinebuttons
734: $tableend
735: $newmail
736: <script type="text/javascript">
737: // END LON-CAPA Internal
738: </script>
739:
740: ENDREGTEXT
741: # Registered, graphical output
742: } else {
743: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
744: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
745: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
746: my $navstatus=&get_nav_status();
747: my $clearcstr;
748:
749: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
750: $result = (<<ENDREGTHIS);
751:
752: <script type="text/javascript">
753: // BEGIN LON-CAPA Internal
754: var swmenu=null;
755:
756: function LONCAPAreg() {
757: swmenu=$reopen;
758: swmenu.clearTimeout(swmenu.menucltim);
759: $timesync
760: $newmail
761: $buttons
762: swmenu.currentURL="$requri";
763: swmenu.reloadURL=swmenu.currentURL+window.location.search;
764: swmenu.currentSymb="$cursymb";
765: swmenu.reloadSymb="$cursymb";
766: swmenu.currentStale=0;
767: $navstatus
768: $hwkadd
769: $editbutton
770: }
771:
772: function LONCAPAstale() {
773: swmenu=$reopen
774: swmenu.currentStale=1;
775: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
776: swmenu.switchbutton
777: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
778: }
779: swmenu.clearbut(7,2);
780: swmenu.clearbut(7,3);
781: swmenu.menucltim=swmenu.setTimeout(
782: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
783: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
784: 2000);
785: }
786:
787: // END LON-CAPA Internal
788: </script>
789: ENDREGTHIS
790: }
791: # =============================================================================
792: } else {
793: # ========================================== This can or will not be registered
794: if ($textual) {
795: # Not registered, textual
796: $result= (<<ENDDONOTREGTEXT);
797: ENDDONOTREGTEXT
798: } else {
799: # Not registered, graphical
800: $result = (<<ENDDONOTREGTHIS);
801:
802: <script type="text/javascript">
803: // BEGIN LON-CAPA Internal
804: var swmenu=null;
805:
806: function LONCAPAreg() {
807: swmenu=$reopen
808: $timesync
809: swmenu.currentStale=1;
810: swmenu.clearbut(2,1);
811: swmenu.clearbut(2,3);
812: swmenu.clearbut(8,1);
813: swmenu.clearbut(8,2);
814: swmenu.clearbut(8,3);
815: if (swmenu.currentURL) {
816: swmenu.switchbutton
817: (3,1,'reload.gif','return','location','go(currentURL)');
818: } else {
819: swmenu.clearbut(3,1);
820: }
821: }
822:
823: function LONCAPAstale() {
824: }
825:
826: // END LON-CAPA Internal
827: </script>
828: ENDDONOTREGTHIS
829: }
830: # =============================================================================
831: }
832: return $result;
833: }
834:
835: sub is_course_upload {
836: my ($file,$cnum,$cdom) = @_;
837: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
838: $uploadpath =~ s{^\/}{};
839: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
840: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
841: return 1;
842: }
843: return;
844: }
845:
846: sub edit_course_upload {
847: my ($file,$cnum,$cdom) = @_;
848: my $cfile;
849: if ($file =~/\.(htm|html|css|js|txt)$/) {
850: my $ext = $1;
851: my $url = &Apache::lonnet::hreflocation('',$file);
852: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
853: my @ids=&Apache::lonnet::current_machine_ids();
854: my $dest;
855: if ($home && grep(/^\Q$home\E$/,@ids)) {
856: $dest = $url.'?forceedit=1';
857: } else {
858: unless (&Apache::lonnet::get_locks()) {
859: $dest = '/adm/switchserver?otherserver='.
860: $home.'&role='.$env{'request.role'}.
861: '&url='.$url.'&forceedit=1';
862: }
863: }
864: if ($dest) {
865: $cfile = &HTML::Entities::encode($dest,'"<>&');
866: }
867: }
868: return $cfile;
869: }
870:
871: sub loadevents() {
872: if ($env{'request.state'} eq 'construct' ||
873: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
874: return 'LONCAPAreg();';
875: }
876:
877: sub unloadevents() {
878: if ($env{'request.state'} eq 'construct' ||
879: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
880: return 'LONCAPAstale();';
881: }
882:
883:
884: sub startupremote {
885: my ($lowerurl)=@_;
886: if (($env{'browser.interface'} eq 'textual') ||
887: ($env{'environment.remote'} eq 'off')) {
888: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
889: }
890: #
891: # The Remote actually gets launched!
892: #
893: my $configmenu=&rawconfig();
894: my $esclowerurl=&escape($lowerurl);
895: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
896: return(<<ENDREMOTESTARTUP);
897: <script type="text/javascript">
898: var timestart;
899: function wheelswitch() {
900: if (typeof(document.wheel) != 'undefined') {
901: if (typeof(document.wheel.spin) != 'undefined') {
902: var date=new Date();
903: var waited=Math.round(30-((date.getTime()-timestart)/1000));
904: document.wheel.spin.value=$message;
905: }
906: }
907: if (window.status=='|') {
908: window.status='/';
909: } else {
910: if (window.status=='/') {
911: window.status='-';
912: } else {
913: if (window.status=='-') {
914: window.status='\\\\';
915: } else {
916: if (window.status=='\\\\') { window.status='|'; }
917: }
918: }
919: }
920: }
921:
922: // ---------------------------------------------------------- The wait function
923: var canceltim;
924: function wait() {
925: if ((menuloaded==1) || (tim==1)) {
926: window.status='Done.';
927: if (tim==0) {
928: clearTimeout(canceltim);
929: $configmenu
930: window.location='$lowerurl';
931: } else {
932: window.location='/adm/remote?action=collapse&url=$esclowerurl';
933: }
934: } else {
935: wheelswitch();
936: setTimeout('wait();',200);
937: }
938: }
939:
940: function main() {
941: canceltim=setTimeout('tim=1;',30000);
942: window.status='-';
943: var date=new Date();
944: timestart=date.getTime();
945: wait();
946: }
947:
948: </script>
949: ENDREMOTESTARTUP
950: }
951:
952: sub setflags() {
953: return(<<ENDSETFLAGS);
954: <script type="text/javascript">
955: menuloaded=0;
956: tim=0;
957: </script>
958: ENDSETFLAGS
959: }
960:
961: sub maincall() {
962: if (($env{'browser.interface'} eq 'textual') ||
963: ($env{'environment.remote'} eq 'off')) { return ''; }
964: return(<<ENDMAINCALL);
965: <script type="text/javascript">
966: main();
967: </script>
968: ENDMAINCALL
969: }
970:
971: sub load_remote_msg {
972: my ($lowerurl)=@_;
973:
974: if (($env{'browser.interface'} eq 'textual') ||
975: ($env{'environment.remote'} eq 'off')) { return ''; }
976:
977: my $esclowerurl=&escape($lowerurl);
978: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode',
979: '<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">',
980: '</a>');
981: return(<<ENDREMOTEFORM);
982: <p>
983: <form name="wheel">
984: <input name="spin" type="text" size="60" />
985: </form>
986: </p>
987: <p>$link</p>
988: ENDREMOTEFORM
989: }
990:
991: sub get_menu_name {
992: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
993: $hostid =~ s/\W//g;
994: return 'LCmenu'.$hostid;
995: }
996:
997:
998: sub reopenmenu {
999: if (($env{'browser.interface'} eq 'textual') ||
1000: ($env{'environment.remote'} eq 'off')) { return ''; }
1001: my $menuname = &get_menu_name();
1002: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1003: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1004: }
1005:
1006:
1007: sub open {
1008: my $returnval='';
1009: if (($env{'browser.interface'} eq 'textual') ||
1010: ($env{'environment.remote'} eq 'off')) {
1011: return '<script type="text/javascript">self.name="loncapaclient";</script>';
1012: }
1013: my $menuname = &get_menu_name();
1014:
1015: # unless (shift eq 'unix') {
1016: # resizing does not work on linux because of virtual desktop sizes
1017: # $returnval.=(<<ENDRESIZE);
1018: #if (window.screen) {
1019: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1020: # self.moveTo(190,15);
1021: #}
1022: #ENDRESIZE
1023: # }
1024: $returnval.=(<<ENDOPEN);
1025: window.status='Opening LON-CAPA Remote Control';
1026: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1027: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1028: self.name='loncapaclient';
1029: ENDOPEN
1030: return '<script type="text/javascript">'.$returnval.'</script>';
1031: }
1032:
1033:
1034: # ================================================================== Raw Config
1035:
1036: sub clear {
1037: my ($row,$col)=@_;
1038: unless (($env{'browser.interface'} eq 'textual') ||
1039: ($env{'environment.remote'} eq 'off')) {
1040: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1041: } else {
1042: $inlineremote[10*$row+$col]='';
1043: return '';
1044: }
1045: }
1046:
1047: # ============================================ Switch a button or create a link
1048: # Switch acts on the javascript that is executed when a button is clicked.
1049: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1050:
1051: sub switch {
1052: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1053: $act=~s/\$uname/$uname/g;
1054: $act=~s/\$udom/$udom/g;
1055: $top=&mt($top);
1056: $bot=&mt($bot);
1057: $desc=&mt($desc);
1058: if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
1059: $img=&mt($img);
1060: }
1061: my $idx=10*$row+$col;
1062: $category_members{$cat}.=':'.$idx;
1063:
1064: unless (($env{'browser.interface'} eq 'textual') ||
1065: ($env{'environment.remote'} eq 'off')) {
1066: # Remote
1067: return "\n".
1068: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1069: } elsif ($env{'browser.interface'} eq 'textual') {
1070: # Accessibility
1071: if ($nobreak==2) { return ''; }
1072: my $text=$top.' '.$bot;
1073: $text=~s/\s*\-\s*//gs;
1074: if ($nobreak) {
1075: $inlineremote[$idx]=
1076: '<a href="javascript:'.$act.';">'.$text.'</a>';
1077: } else {
1078: $inlineremote[$idx]="\n<br />".
1079: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
1080: }
1081: } else {
1082: # Inline Remote
1083: if ($env{'environment.icons'} ne 'classic') {
1084: $img=~s/\.gif$/\.png/;
1085: }
1086: if ($nobreak==2) { return ''; }
1087: my $text=$top.' '.$bot;
1088: $text=~s/\s*\-\s*//gs;
1089:
1090: my $pic=
1091: '<img alt="'.$text.'" src="'.
1092: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1093: '" align="'.($nobreak==3?'right':'left').'" />';
1094: if ($env{'browser.interface'} eq 'faketextual') {
1095: # Accessibility
1096: if ($nobreak==3) {
1097: $inlineremote[$idx]="\n".
1098: '<td class="LC_menubuttons_text" align="right">'.$text.
1099: '</td><td class="LC_menubuttons_img" align="left">'.
1100: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1101: } elsif ($nobreak) {
1102: $inlineremote[$idx]="\n<tr>".
1103: '<td class="LC_menubuttons_img" align="left">'.
1104: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1105: <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';
1106: } else {
1107: $inlineremote[$idx]="\n<tr>".
1108: '<td class="LC_menubuttons_img" align="left">'.
1109: '<a href="javascript:'.$act.';">'.$pic.
1110: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1111: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1112: }
1113: } else {
1114: # Inline Menu
1115: if ($env{'environment.icons'} eq 'iconsonly') {
1116: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
1117: } else {
1118: $inlineremote[$idx]=
1119: '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1120: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1121: }
1122: }
1123: }
1124: return '';
1125: }
1126:
1127: sub secondlevel {
1128: my $output='';
1129: my
1130: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1131: if ($prt eq 'any') {
1132: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1133: } elsif ($prt=~/^r(\w+)/) {
1134: if ($rol eq $1) {
1135: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1136: }
1137: }
1138: return $output;
1139: }
1140:
1141: sub openmenu {
1142: my $menuname = &get_menu_name();
1143: if (($env{'browser.interface'} eq 'textual') ||
1144: ($env{'environment.remote'} eq 'off')) { return ''; }
1145: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1146: return "window.open(".$nothing.",'".$menuname."');";
1147: }
1148:
1149: sub inlinemenu {
1150: undef(@inlineremote);
1151: undef(%category_members);
1152: &rawconfig(1);
1153: my $output='<table id="LC_mainmenu"><tr>';
1154: for (my $col=1; $col<=2; $col++) {
1155: $output.='<td class="LC_mainmenu_col_fieldset">';
1156: for (my $row=1; $row<=8; $row++) {
1157: foreach my $cat (keys(%category_members)) {
1158: if ($category_positions{$cat} ne "$col,$row") { next; }
1159: #$output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1160: $output.='<fieldset id="LC_mainmenu_fieldset">';
1161: $output.='<legend class="LC_mainmenu_fieldset_category">'.&mt($category_names{$cat}).'</legend>';
1162: $output.='<table id="LC_menubuttons_mainmenu">';
1163: my %active=();
1164: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1165: if ($inlineremote[$menu_item]) {
1166: $active{$menu_item}=1;
1167: }
1168: }
1169: foreach my $item (sort(keys(%active))) {
1170: $output.=$inlineremote[$item];
1171: &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]");
1172: }
1173: $output.='</table>';
1174: $output.='</fieldset>';
1175: }
1176: }
1177: $output.="</td>";
1178: }
1179: $output.="</tr></table>";
1180: return $output;
1181: }
1182:
1183: sub rawconfig {
1184: my $textualoverride=shift;
1185: my $output='';
1186: unless (($env{'browser.interface'} eq 'textual') ||
1187: ($env{'environment.remote'} eq 'off')) {
1188: $output.=
1189: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1190: "\nwindow.status='Configuring Remote Control ';";
1191: } else {
1192: unless ($textualoverride) { return ''; }
1193: }
1194: my $uname=$env{'user.name'};
1195: my $udom=$env{'user.domain'};
1196: my $adv=$env{'user.adv'};
1197: my $show_course=&Apache::loncommon::show_course();
1198: my $author=$env{'user.author'};
1199: my $crs='';
1200: if ($env{'request.course.id'}) {
1201: $crs='/'.$env{'request.course.id'};
1202: if ($env{'request.course.sec'}) {
1203: $crs.='_'.$env{'request.course.sec'};
1204: }
1205: $crs=~s/\_/\//g;
1206: }
1207: my $pub=($env{'request.state'} eq 'published');
1208: my $con=($env{'request.state'} eq 'construct');
1209: my $rol=$env{'request.role'};
1210: my $requested_domain = $env{'request.role.domain'};
1211: foreach my $line (@desklines) {
1212: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1213: $prt=~s/\$uname/$uname/g;
1214: $prt=~s/\$udom/$udom/g;
1215: $prt=~s/\$crs/$crs/g;
1216: $prt=~s/\$requested_domain/$requested_domain/g;
1217: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1218: my $type = &Apache::loncommon::course_type();
1219: if ($type eq 'Group') {
1220: $desc = &convert_menu_function($desc,$type);
1221: }
1222: if ($pro eq 'clear') {
1223: $output.=&clear($row,$col);
1224: } elsif ($pro eq 'any') {
1225: $output.=&secondlevel(
1226: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1227: } elsif ($pro eq 'smp') {
1228: unless ($adv) {
1229: $output.=&secondlevel(
1230: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1231: }
1232: } elsif ($pro eq 'adv') {
1233: if ($adv) {
1234: $output.=&secondlevel(
1235: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1236: }
1237: } elsif ($pro eq 'shc') {
1238: if ($show_course) {
1239: $output.=&secondlevel(
1240: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1241: }
1242: } elsif ($pro eq 'nsc') {
1243: if (!$show_course) {
1244: $output.=&secondlevel(
1245: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1246: }
1247: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1248: if (&Apache::lonnet::allowed($1,$prt)) {
1249: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1250: }
1251: } elsif ($pro eq 'course') {
1252: if ($env{'request.course.fn'}) {
1253: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1254: }
1255: } elsif ($pro =~ /^courseenv_(.*)$/) {
1256: my $key = $1;
1257: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1258: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1259: }
1260: } elsif ($pro =~ /^course_(.*)$/) {
1261: # Check for permissions inside of a course
1262: if (($env{'request.course.id'}) &&
1263: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1264: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1265: )) {
1266: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1267: }
1268: } elsif ($pro eq 'author') {
1269: if ($author) {
1270: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1271: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1272: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1273: # Check that we are on the correct machine
1274: my $cadom=$requested_domain;
1275: my $caname=$env{'user.name'};
1276: if (($prt eq 'rca') || ($prt eq 'raa')) {
1277: ($cadom,$caname)=
1278: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1279: }
1280: $act =~ s/\$caname/$caname/g;
1281: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1282: my $allowed=0;
1283: my @ids=&Apache::lonnet::current_machine_ids();
1284: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1285: if ($allowed) {
1286: $output.=&switch($caname,$cadom,
1287: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1288: }
1289: }
1290: }
1291: } elsif ($pro eq 'tools') {
1292: my @tools = ('aboutme','blog','portfolio');
1293: if (grep(/^\Q$prt\E$/,@tools)) {
1294: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1295: $env{'user.domain'},
1296: $prt,undef,'tools')) {
1297: $output.=&clear($row,$col);
1298: next;
1299: }
1300: } elsif ($prt eq 'reqcrs') {
1301: my $showreqcrs = 0;
1302: foreach my $type ('official','unofficial') {
1303: if (&Apache::lonnet::usertools_access($env{'user.name'},
1304: $env{'user.domain'},
1305: $type,undef,'requestcourses')) {
1306: $showreqcrs = 1;
1307: last;
1308: }
1309: }
1310: if (!$showreqcrs) {
1311: $output.=&clear($row,$col);
1312: next;
1313: }
1314: }
1315: $prt='any';
1316: $output.=&secondlevel(
1317: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1318:
1319: }
1320: }
1321: unless (($env{'browser.interface'} eq 'textual') ||
1322: ($env{'environment.remote'} eq 'off')) {
1323: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1324: if (&Apache::lonmsg::newmail()) {
1325: $output.='swmenu.setstatus("you have","messages");';
1326: }
1327: }
1328:
1329: return $output;
1330: }
1331:
1332: # ======================================================================= Close
1333:
1334: sub close {
1335: if (($env{'browser.interface'} eq 'textual') ||
1336: ($env{'environment.remote'} eq 'off')) { return ''; }
1337: my $menuname = &get_menu_name();
1338: return(<<ENDCLOSE);
1339: <script type="text/javascript">
1340: window.status='Accessing Remote Control';
1341: menu=window.open("/adm/rat/empty.html","$menuname",
1342: "height=350,width=150,scrollbars=no,menubar=no");
1343: window.status='Disabling Remote Control';
1344: menu.active=0;
1345: menu.autologout=0;
1346: window.status='Closing Remote Control';
1347: menu.close();
1348: window.status='Done.';
1349: </script>
1350: ENDCLOSE
1351: }
1352:
1353: # ====================================================================== Footer
1354:
1355: sub footer {
1356:
1357: }
1358:
1359: sub nav_control_js {
1360: my $nav=($env{'environment.remotenavmap'} eq 'on');
1361: return (<<NAVCONTROL);
1362: var w_loncapanav_flag="$nav";
1363:
1364:
1365: function gonav(url) {
1366: if (w_loncapanav_flag != 1) {
1367: gopost(url,'');
1368: } else {
1369: navwindow=window.open(url,
1370: "loncapanav","height=600,width=400,scrollbars=1");
1371: }
1372: }
1373: NAVCONTROL
1374: }
1375:
1376: sub utilityfunctions {
1377: my $caller = shift;
1378: unless (($env{'browser.interface'} eq 'textual') ||
1379: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1380: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1381: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1382:
1383: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1384: my $nav_control=&nav_control_js();
1385:
1386: my $start_page_annotate =
1387: &Apache::loncommon::start_page('Annotator',undef,
1388: {'only_body' => 1,
1389: 'js_ready' => 1,
1390: 'bgcolor' => '#BBBBBB',
1391: 'add_entries' => {
1392: 'onload' => 'javascript:document.goannotate.submit();'}});
1393:
1394: my $end_page_annotate =
1395: &Apache::loncommon::end_page({'js_ready' => 1});
1396:
1397: my $start_page_bookmark =
1398: &Apache::loncommon::start_page('Bookmarks',undef,
1399: {'only_body' => 1,
1400: 'js_ready' => 1,
1401: 'bgcolor' => '#BBBBBB',});
1402:
1403: my $end_page_bookmark =
1404: &Apache::loncommon::end_page({'js_ready' => 1});
1405:
1406: return (<<ENDUTILITY)
1407:
1408: var currentURL="$currenturl";
1409: var reloadURL="$currenturl";
1410: var currentSymb="$currentsymb";
1411:
1412: $nav_control
1413:
1414: function go(url) {
1415: if (url!='' && url!= null) {
1416: currentURL = null;
1417: currentSymb= null;
1418: window.location.href=url;
1419: }
1420: }
1421:
1422: function gopost(url,postdata) {
1423: if (url!='') {
1424: this.document.server.action=url;
1425: this.document.server.postdata.value=postdata;
1426: this.document.server.command.value='';
1427: this.document.server.url.value='';
1428: this.document.server.symb.value='';
1429: this.document.server.submit();
1430: }
1431: }
1432:
1433: function gocmd(url,cmd) {
1434: if (url!='') {
1435: this.document.server.action=url;
1436: this.document.server.postdata.value='';
1437: this.document.server.command.value=cmd;
1438: this.document.server.url.value=currentURL;
1439: this.document.server.symb.value=currentSymb;
1440: this.document.server.submit();
1441: }
1442: }
1443:
1444: function gocstr(url,filename) {
1445: if (url == '/adm/cfile?action=delete') {
1446: this.document.cstrdelete.filename.value = filename
1447: this.document.cstrdelete.submit();
1448: return;
1449: }
1450: if (url == '/adm/printout') {
1451: this.document.cstrprint.postdata.value = filename
1452: this.document.cstrprint.curseed.value = 0;
1453: this.document.cstrprint.problemtype.value = 0;
1454: if (this.document.lonhomework) {
1455: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1456: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1457: }
1458: if (this.document.lonhomework.problemtype) {
1459: if (this.document.lonhomework.problemtype.value) {
1460: this.document.cstrprint.problemtype.value =
1461: this.document.lonhomework.problemtype.value;
1462: } else if (this.document.lonhomework.problemtype.options) {
1463: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1464: if (this.document.lonhomework.problemtype.options[i].selected) {
1465: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1466: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1467: }
1468: }
1469: }
1470: }
1471: }
1472: }
1473: this.document.cstrprint.submit();
1474: return;
1475: }
1476: if (url !='') {
1477: this.document.constspace.filename.value = filename;
1478: this.document.constspace.action = url;
1479: this.document.constspace.submit();
1480: }
1481: }
1482:
1483: function golist(url) {
1484: if (url!='' && url!= null) {
1485: currentURL = null;
1486: currentSymb= null;
1487: top.location.href=url;
1488: }
1489: }
1490:
1491:
1492:
1493: function catalog_info() {
1494: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1495: }
1496:
1497: function chat_win() {
1498: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1499: }
1500:
1501: function group_chat(group) {
1502: var url = '/adm/groupchat?group='+group;
1503: var winName = 'LONchat_'+group;
1504: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1505: }
1506:
1507: function edit_bookmarks() {
1508: go('');
1509: w_BookmarkPal_flag=1;
1510: bookmarkpal=window.open("/adm/bookmarks",
1511: "BookmarkPal", "width=400,height=505,scrollbars=0");
1512: }
1513:
1514: function annotate() {
1515: w_Annotator_flag=1;
1516: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1517: annotator.document.write(
1518: '$start_page_annotate'
1519: +"<form name='goannotate' target='Annotator' method='post' "
1520: +"action='/adm/annotations'>"
1521: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1522: +"<\\/form>"
1523: +'$end_page_annotate');
1524: annotator.document.close();
1525: }
1526:
1527: function set_bookmark() {
1528: go('');
1529: clienttitle=document.title;
1530: clienthref=location.pathname;
1531: w_bmquery_flag=1;
1532: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1533: bmquery.document.write(
1534: '$start_page_bookmark'
1535: +'<center><form method="post"'
1536: +' name="newlink" action="/adm/bookmarks" target="bmquery" '
1537: +'> <table width="340" height="150" '
1538: +'bgcolor="ffffff" align="center"><tr><td>Link Name:<br /><input '
1539: +'type="text" name="title" size="45" value="'+clienttitle+'" />'
1540: +'<br />Address:<br /><input type="text" name="address" size="45" '
1541: +'value="'+clienthref+'" /><br /><center><input type="submit" '
1542: +'value="Save" /> <input type="button" value="Close" '
1543: +'onclick="javascript:window.close();" /></center></td>'
1544: +'</tr></table></form></center>'
1545: +'$end_page_bookmark' );
1546: bmquery.document.close();
1547: }
1548:
1549: ENDUTILITY
1550: }
1551:
1552: sub serverform {
1553: return(<<ENDSERVERFORM);
1554: <form name="server" action="/adm/logout" method="post" target="_top">
1555: <input type="hidden" name="postdata" value="none" />
1556: <input type="hidden" name="command" value="none" />
1557: <input type="hidden" name="url" value="none" />
1558: <input type="hidden" name="symb" value="none" />
1559: </form>
1560: ENDSERVERFORM
1561: }
1562:
1563: sub constspaceform {
1564: return(<<ENDCONSTSPACEFORM);
1565: <form name="constspace" action="/adm/logout" method="post" target="_top">
1566: <input type="hidden" name="filename" value="" />
1567: </form>
1568: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1569: <input type="hidden" name="action" value="delete" />
1570: <input type="hidden" name="filename" value="" />
1571: </form>
1572: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1573: <input type="hidden" name="postdata" value="" />
1574: <input type="hidden" name="curseed" value="" />
1575: <input type="hidden" name="problemtype" value="" />
1576: </form>
1577:
1578: ENDCONSTSPACEFORM
1579: }
1580:
1581:
1582: sub get_nav_status {
1583: my $navstatus="swmenu.w_loncapanav_flag=";
1584: if ($env{'environment.remotenavmap'} eq 'on') {
1585: $navstatus.="1";
1586: } else {
1587: $navstatus.="-1";
1588: }
1589: return $navstatus;
1590: }
1591:
1592: #FIXME this needs to move into mydesktab and the other locations
1593: # the text is generated
1594: sub convert_menu_function {
1595: my ($rolename,$type) = @_;
1596: if ($type eq 'Group') {
1597: $rolename =~ s/student/member/g;
1598: $rolename =~ s/group/team/g;
1599: $rolename =~ s/course/group/g;
1600: $rolename =~ s/Course/Group/g;
1601: }
1602: return $rolename;
1603: }
1604:
1605: sub hidden_button_check {
1606: my $hidden;
1607: if ($env{'request.course.id'} eq '') {
1608: return;
1609: }
1610: if ($env{'request.role.adv'}) {
1611: return;
1612: }
1613: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1614: return $buttonshide;
1615: }
1616:
1617: sub roles_selector {
1618: my ($cdom,$cnum) = @_;
1619: my $now = time;
1620: my (%courseroles,%seccount);
1621: my $is_cc;
1622: my $role_selector;
1623: if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
1624: my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum});
1625:
1626: if ((($start) && ($start<0)) ||
1627: (($end) && ($end<$now)) ||
1628: (($start) && ($now<$start))) {
1629: $is_cc = 0;
1630: } else {
1631: $is_cc = 1;
1632: }
1633: }
1634: if ($is_cc) {
1635: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1636: } else {
1637: my %gotnosection;
1638: foreach my $item (keys(%env)) {
1639: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1640: my $role = $1;
1641: my $sec = $2;
1642: next if ($role eq 'gr');
1643: my ($start,$end) = split(/\./,$env{$item});
1644: next if (($start && $start > $now) || ($end && $end < $now));
1645: if ($sec eq '') {
1646: if (!$gotnosection{$role}) {
1647: $seccount{$role} ++;
1648: $gotnosection{$role} = 1;
1649: }
1650: }
1651: if (ref($courseroles{$role}) eq 'ARRAY') {
1652: if ($sec ne '') {
1653: if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) {
1654: push(@{$courseroles{$role}},$sec);
1655: $seccount{$role} ++;
1656: }
1657: }
1658: } else {
1659: @{$courseroles{$role}} = ();
1660: if ($sec ne '') {
1661: $seccount{$role} ++;
1662: push(@{$courseroles{$role}},$sec);
1663: }
1664: }
1665: }
1666: }
1667: }
1668: my @roles_order = ('cc','in','ta','ep','ad','st');
1669: if (keys(%courseroles) > 1) {
1670: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1671: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1672: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1673: $role_selector .= '<option value="">'.&mt('Switch course role to...').'</option>';
1674: foreach my $role (@roles_order) {
1675: if (defined($courseroles{$role})) {
1676: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1677: }
1678: }
1679: foreach my $role (sort(keys(%courseroles))) {
1680: if ($role =~ /^cr/) {
1681: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1682: }
1683: }
1684: $role_selector .= '</select>'."\n".
1685: '<input type="hidden" name="destinationurl" value="'.
1686: $ENV{'REQUEST_URI'}.'" />'."\n".
1687: '<input type="hidden" name="gotorole" value="1" />'."\n".
1688: '<input type="hidden" name="selectrole" value="" />'."\n".
1689: '<input type="hidden" name="switch" value="1" />'."\n".
1690: '</form>';
1691: }
1692: return $role_selector;
1693: }
1694:
1695: sub get_all_courseroles {
1696: my ($cdom,$cnum,$courseroles,$seccount) = @_;
1697: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
1698: return;
1699: }
1700: my ($result,$cached) =
1701: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1702: if (defined($cached)) {
1703: if (ref($result) eq 'HASH') {
1704: if ((ref($result->{'roles'}) eq 'HASH') &&
1705: (ref($result->{'seccount'}) eq 'HASH')) {
1706: %{$courseroles} = %{$result->{'roles'}};
1707: %{$seccount} = %{$result->{'seccount'}};
1708: return;
1709: }
1710: }
1711: }
1712: my %gotnosection;
1713: my %adv_roles =
1714: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1715: foreach my $role (keys(%adv_roles)) {
1716: my ($urole,$usec) = split(/:/,$role);
1717: if (!$gotnosection{$urole}) {
1718: $seccount->{$urole} ++;
1719: $gotnosection{$urole} = 1;
1720: }
1721: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1722: if ($usec ne '') {
1723: if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) {
1724: push(@{$courseroles->{$urole}},$usec);
1725: $seccount->{$urole} ++;
1726: }
1727: }
1728: } else {
1729: @{$courseroles->{$urole}} = ();
1730: if ($usec ne '') {
1731: $seccount->{$urole} ++;
1732: push(@{$courseroles->{$urole}},$usec);
1733: }
1734: }
1735: }
1736: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1737: @{$courseroles->{'st'}} = ();
1738: if (keys(%sections_count) > 0) {
1739: push(@{$courseroles->{'st'}},keys(%sections_count));
1740: $seccount->{'st'} = scalar(keys(%sections_count));
1741: }
1742: my $rolehash = {
1743: 'roles' => $courseroles,
1744: 'seccount' => $seccount,
1745: };
1746: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1747: return;
1748: }
1749:
1750: sub jump_to_role {
1751: my ($cdom,$cnum,$seccount,$courseroles) = @_;
1752: my %lt = &Apache::lonlocal::texthash(
1753: this => 'This role has section(s) associated with it.',
1754: ente => 'Enter a specific section.',
1755: orlb => 'Enter a specific section, or leave blank for no section.',
1756: avai => 'Available sections are:',
1757: youe => 'You entered an invalid section choice:',
1758: plst => 'Please try again',
1759: );
1760: my $js;
1761: if (ref($courseroles) eq 'HASH') {
1762: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1763: ' var numsec = new Array();'."\n".
1764: ' var rolesections = new Array();'."\n".
1765: ' var rolenames = new Array();'."\n".
1766: ' var roleseclist = new Array();'."\n";
1767: my @items = keys(%{$courseroles});
1768: for (my $i=0; $i<@items; $i++) {
1769: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1770: my ($secs,$secstr);
1771: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1772: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1773: $secs = join('","',@sections);
1774: $secstr = join(', ',@sections);
1775: }
1776: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1777: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1778: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1779: }
1780: }
1781: my $output = <<"END";
1782: <script type="text/javascript">
1783: function adhocRole(roleitem) {
1784: $js
1785: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1786: if (newrole == '') {
1787: return;
1788: }
1789: var fullrole = newrole+'./$cdom/$cnum';
1790: var selidx = '';
1791: for (var i=0; i<rolenames.length; i++) {
1792: if (rolenames[i] == newrole) {
1793: selidx = i;
1794: }
1795: }
1796: var secok = 1;
1797: var secchoice = '';
1798: if (selidx >= 0) {
1799: if (numsec[selidx] > 1) {
1800: secok = 0;
1801: var numrolesec = rolesections[selidx].length;
1802: var msgidx = numsec[selidx] - numrolesec;
1803: secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1804: if (secchoice == '') {
1805: if (msgidx > 0) {
1806: secok = 1;
1807: }
1808: } else {
1809: for (var j=0; j<rolesections[selidx].length; j++) {
1810: if (rolesections[selidx][j] == secchoice) {
1811: secok = 1;
1812: }
1813: }
1814: }
1815: } else {
1816: if (rolesections[selidx].length == 1) {
1817: secchoice = rolesections[selidx][0];
1818: }
1819: }
1820: }
1821: if (secok == 1) {
1822: if (secchoice != '') {
1823: fullrole += '/'+secchoice;
1824: }
1825: } else {
1826: document.rolechooser.elements[roleitem].selectedIndex = 0;
1827: if (secchoice != null) {
1828: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1829: }
1830: return;
1831: }
1832: if (fullrole == "$env{'request.role'}") {
1833: return;
1834: }
1835: itemid = retrieveIndex('gotorole');
1836: if (itemid != -1) {
1837: document.rolechooser.elements[itemid].name = fullrole;
1838: }
1839: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1840: document.rolechooser.selectrole.value = '1';
1841: document.rolechooser.submit();
1842: return;
1843: }
1844:
1845: function retrieveIndex(item) {
1846: for (var i=0;i<document.rolechooser.elements.length;i++) {
1847: if (document.rolechooser.elements[i].name == item) {
1848: return i;
1849: }
1850: }
1851: return -1;
1852: }
1853:
1854:
1855: </script>
1856: END
1857: return $output;
1858: }
1859:
1860:
1861: # ================================================================ Main Program
1862:
1863: BEGIN {
1864: if (! defined($readdesk)) {
1865: {
1866: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1867: if ( CORE::open( my $config,"<$tabfile") ) {
1868: while (my $configline=<$config>) {
1869: $configline=(split(/\#/,$configline))[0];
1870: $configline=~s/^\s+//;
1871: chomp($configline);
1872: if ($configline=~/^cat\:/) {
1873: my @entries=split(/\:/,$configline);
1874: $category_positions{$entries[2]}=$entries[1];
1875: $category_names{$entries[2]}=$entries[3];
1876: } elsif ($configline) {
1877: push(@desklines,$configline);
1878: }
1879: }
1880: CORE::close($config);
1881: }
1882: }
1883: $readdesk='done';
1884: }
1885: }
1886:
1887: 1;
1888: __END__
1889:
1890:
1891:
1892:
1893:
1894:
1895:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>