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