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