File:
[LON-CAPA] /
loncom /
interface /
lonmenu.pm
Revision
1.371:
download - view:
text,
annotated -
select for diffs
Fri May 18 14:27:11 2012 UTC (12 years, 3 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Primary menu.
- replace separate 'Preferences, Portfolio, Feeds' items with sub-menu
(uses :hover pseudo-class; works for IE7+,FF,Safari,Chrome,Opera)
shown when hovering over 'Personal' item.
- To do: add support for IE6 via jQuery.
- Shorter menu can accommodate longer course titles without need for
wrapping.
1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.371 2012/05/18 14:27:11 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:
30: =head1 NAME
31:
32: Apache::lonmenu
33:
34: =head1 SYNOPSIS
35:
36: Loads contents of /home/httpd/lonTabs/mydesk.tab,
37: used to generate inline menu, and Main Menu page.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
42: =head1 GLOBAL VARIABLES
43:
44: =over
45:
46: =item @desklines
47:
48: Each element of this array contains a line of mydesk.tab that doesn't start with
49: cat, prim or scnd.
50: It gets filled in the BEGIN block of this module.
51:
52: =item %category_names
53:
54: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
55: start with cat, the values are strings representing titles.
56: It gets filled in the BEGIN block of this module.
57:
58: =item %category_members
59:
60: TODO
61:
62: =item %category_positions
63:
64: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
65: start with cat, its values are position vectors (column, row).
66: It gets filled in the BEGIN block of this module.
67:
68: =item $readdesk
69:
70: Indicates that mydesk.tab has been read.
71: It is set to 'done' in the BEGIN block of this module.
72:
73: =item @primary_menu
74:
75: The elements of this array reference arrays that are made up of the components
76: of those lines of mydesk.tab that start with prim:.
77: It is used by primary_menu() to generate the corresponding menu.
78: It gets filled in the BEGIN block of this module.
79:
80: =item %primary_sub_menu
81:
82: The keys of this hash reference are the names of items in the primary_menu array
83: which have sub-menus. For each key, the corresponding value is a reference to
84: an array containing components extracted from lines in mydesk.tab which begin
85: with primsub:.
86: This hash, which is used by primary_menu to generate sub-menus, is populated in
87: the BEGIN block.
88:
89: =item @secondary_menu
90:
91: The elements of this array reference arrays that are made up of the components
92: of those lines of mydesk.tab that start with scnd.
93: It is used by secondary_menu() to generate the corresponding menu.
94: It gets filled in the BEGIN block of this module.
95:
96: =back
97:
98: =head1 SUBROUTINES
99:
100: =over
101:
102: =item prep_menuitems(\@menuitem)
103:
104: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
105: secondary_menu().
106:
107: =item primary_menu()
108:
109: This routine evaluates @primary_menu and returns XHTML for the menu
110: that contains following links: About, Message, Roles, Help, Logout
111: @primary_menu is filled within the BEGIN block of this module with
112: entries from mydesk.tab
113:
114: =item secondary_menu()
115:
116: Same as primary_menu() but operates on @secondary_menu.
117:
118: =item innerregister()
119:
120: This gets called in order to register a URL in the body of the document
121:
122: =item clear()
123:
124: =item switch()
125:
126: Switch a button or create a link
127: Switch acts on the javascript that is executed when a button is clicked.
128: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
129:
130: =item secondlevel()
131:
132: =item openmenu()
133:
134: =item inlinemenu()
135:
136: =item rawconfig()
137:
138: =item utilityfunctions()
139:
140: Output from this routine is a number of javascript functions called by
141: items in the inline menu, and in some cases items in the Main Menu page.
142:
143: =item serverform()
144:
145: =item constspaceform()
146:
147: =item get_nav_status()
148:
149: =item hidden_button_check()
150:
151: =item roles_selector()
152:
153: =item jump_to_role()
154:
155: =back
156:
157: =cut
158:
159: package Apache::lonmenu;
160:
161: use strict;
162: use Apache::lonnet;
163: use Apache::lonhtmlcommon();
164: use Apache::loncommon();
165: use Apache::lonenc();
166: use Apache::lonlocal;
167: use Apache::lonmsg();
168: use LONCAPA qw(:DEFAULT :match);
169: use HTML::Entities();
170: use Apache::lonwishlist();
171:
172: use vars qw(@desklines %category_names %category_members %category_positions
173: $readdesk @primary_menu %primary_submenu @secondary_menu);
174:
175: my @inlineremote;
176:
177: sub prep_menuitem {
178: my ($menuitem) = @_;
179: return '' unless(ref($menuitem) eq 'ARRAY');
180: my $link;
181: if ($$menuitem[1]) { # graphical Link
182: $link = "<img class=\"LC_noBorder\""
183: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
184: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
185: } else { # textual Link
186: $link = &mt($$menuitem[3]);
187: }
188: return '<li><a'
189: # highlighting for new messages
190: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
191: . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
192: }
193:
194: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
195: # that contains following links:
196: # About, Message, Personal, Roles, Help, Logout
197: # @primary_menu is filled within the BEGIN block of this module with
198: # entries from mydesk.tab
199: sub primary_menu {
200: my $menu;
201: # each element of @primary contains following array:
202: # (link url, icon path, alt text, link text, condition)
203: my $public;
204: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
205: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
206: $public = 1;
207: }
208: foreach my $menuitem (@primary_menu) {
209: # evaluate conditions
210: next if ref($menuitem) ne 'ARRAY'; #
211: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
212: && &Apache::lonmsg::mynewmail(); # whether a new msg
213: next if $$menuitem[4] eq 'newmsg' # arrived or not
214: && !&Apache::lonmsg::mynewmail(); #
215: next if $$menuitem[4] !~ /public/ ##we've a public user,
216: && $public; ##who should not see all
217: ##links
218: next if $$menuitem[4] eq 'onlypublic'# hide links which are
219: && !$public; # only visible to public
220: # users
221: next if $$menuitem[4] eq 'roles' ##show links depending on
222: && &Apache::loncommon::show_course(); ##term 'Courses' or
223: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
224: && !&Apache::loncommon::show_course(); ##
225:
226: my $title = $menuitem->[3];
227: if (defined($primary_submenu{$title})) {
228: my ($link,$target,$numsub);
229: if ($menuitem->[0] ne '') {
230: $link = $menuitem->[0];
231: $target = '_top';
232: } else {
233: $link = '#';
234: }
235: if (ref($primary_submenu{$title}) eq 'ARRAY') {
236: $numsub = @{$primary_submenu{$title}};
237: if ($numsub) {
238: $title =
239: '<span class="LC_nobreak">'.$title.
240: '<span class="LC_fontsize_small">'.
241: '▼</span></span>';
242: }
243: }
244: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.$title.'</a>';
245: if ($numsub) {
246: $menu .= '<ul>';
247: foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
248: if (ref($item) eq 'ARRAY') {
249: if ($item->[2] eq 'wishlist') {
250: next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
251: (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
252: } elsif ($item->[2] eq 'reqcrs') {
253: next unless(&check_for_rcrs());
254: } elsif (($item->[2] eq 'portfolio') ||
255: ($item->[2] eq 'blog')) {
256: if (!&Apache::lonnet::usertools_access(
257: $env{'user.name'},
258: $env{'user.domain'},
259: $item->[2],undef,'tools')) {
260: next;
261: }
262: }
263: $menu .= '<li style="margin:0;padding:0">'.
264: '<a href="'.$item->[0].
265: '" style="padding:0 0 0 10px">'.
266: $item->[1].'</a></li>';
267: }
268: }
269: $menu .= '</ul>';
270: }
271: $menu .= '</li>';
272: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
273: if ($public) {
274: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
275: my $defdom = &Apache::lonnet::default_login_domain();
276: my $to = &Apache::loncommon::build_recipient_list(undef,
277: 'helpdeskmail',
278: $defdom,$origmail);
279: if ($to ne '') {
280: $menu .= &prep_menuitem($menuitem);
281: }
282: } else {
283: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
284: }
285: } else {
286: $menu .= prep_menuitem($menuitem);
287: }
288: }
289: $menu =~ s/\[domain\]/$env{'user.domain'}/g;
290: $menu =~ s/\[user\]/$env{'user.name'}/g;
291:
292: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
293: }
294:
295: #returns hashref {user=>'',dom=>''} containing:
296: # own name, domain if user is au
297: # name, domain of parent author if user is ca or aa
298: #empty return if user is not an author or not on homeserver
299: #
300: #TODO this should probably be moved somewhere more central
301: #since it can be used by different parts of the system
302: sub getauthor{
303: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
304:
305: #co- or assistent author?
306: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
307: ? ($1, $2) #domain, username of the parent author
308: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
309:
310: # current server == home server?
311: my $home = &Apache::lonnet::homeserver($user,$dom);
312: foreach (&Apache::lonnet::current_machine_ids()){
313: return {user => $user, dom => $dom} if $_ eq $home;
314: }
315:
316: # if wrong server
317: return;
318: }
319:
320: sub secondary_menu {
321: my $menu;
322:
323: my $crstype = &Apache::loncommon::course_type();
324: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
325: ? "/$env{'request.course.sec'}"
326: : '');
327: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
328: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
329: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
330: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
331: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
332: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
333: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
334: my $author = &getauthor();
335:
336: my %groups = &Apache::lonnet::get_active_groups(
337: $env{'user.domain'}, $env{'user.name'},
338: $env{'course.' . $env{'request.course.id'} . '.domain'},
339: $env{'course.' . $env{'request.course.id'} . '.num'});
340:
341: foreach my $menuitem (@secondary_menu) {
342: # evaluate conditions
343: next if ref($menuitem) ne 'ARRAY';
344: next if $$menuitem[4] ne 'always'
345: && $$menuitem[4] ne 'author'
346: && !$env{'request.course.id'};
347: next if $$menuitem[4] =~ /^mdc/
348: && !$canedit;
349: next if $$menuitem[4] eq 'nvgr'
350: && $canvgr;
351: next if $$menuitem[4] eq 'vgr'
352: && !$canvgr;
353: next if $$menuitem[4] eq 'cst'
354: && !$canmodifyuser;
355: next if $$menuitem[4] eq 'ncst'
356: && $canmodifyuser;
357: next if $$menuitem[4] eq 'mgr'
358: && !$canmgr;
359: next if $$menuitem[4] eq 'nmgr'
360: && $canmgr;
361: next if $$menuitem[4] eq 'whn'
362: && !$canviewwnew;
363: next if $$menuitem[4] eq 'opa'
364: && !$canmodpara;
365: next if $$menuitem[4] =~ /showgroups$/
366: && !$canviewgrps
367: && !%groups;
368: next if $$menuitem[4] eq 'author'
369: && !$author;
370:
371: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
372: # special treatment for role selector
373: my $roles_selector = &roles_selector(
374: $env{'course.' . $env{'request.course.id'} . '.domain'},
375: $env{'course.' . $env{'request.course.id'} . '.num'} );
376:
377: $menu .= $roles_selector ? "<li>$roles_selector</li>"
378: : '';
379: } else {
380: $menu .= &prep_menuitem(\@$menuitem);
381: }
382: }
383: if ($menu =~ /\[url\].*\[symb\]/) {
384: my $escurl = &escape( &Apache::lonenc::check_encrypt(
385: $env{'request.noversionuri'}));
386:
387: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
388: $env{'request.symb'}));
389:
390: if ( $env{'request.state'} eq 'construct'
391: and ( $env{'request.noversionuri'} eq ''
392: || !defined($env{'request.noversionuri'})))
393: {
394: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
395: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
396: $escurl = &escape($escurl);
397: }
398: $menu =~ s/\[url\]/$escurl/g;
399: $menu =~ s/\[symb\]/$escsymb/g;
400: }
401: $menu =~ s/\[uname\]/$$author{user}/g;
402: $menu =~ s/\[udom\]/$$author{dom}/g;
403:
404: return "<ul id=\"LC_secondary_menu\">$menu</ul>";
405: }
406:
407: sub innerregister {
408: my ($forcereg,$bread_crumbs) = @_;
409: my $const_space = ($env{'request.state'} eq 'construct');
410: my $is_const_dir = 0;
411:
412: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
413:
414: $env{'request.registered'} = 1;
415:
416: undef(@inlineremote);
417:
418: my $resurl;
419: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
420:
421: (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
422: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
423:
424: my $maptitle = &Apache::lonnet::gettitle($mapurl);
425: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
426:
427: #SD
428: #course_type only Course and Community?
429: #
430: my @crumbs;
431: unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
432: && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
433: @crumbs = ({text => Apache::loncommon::course_type()
434: . ' Contents',
435: href => "Javascript:gopost('/adm/navmaps','')"});
436: }
437: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
438: push(@crumbs, {text => '...',
439: no_mt => 1});
440: }
441:
442: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
443: && $maptitle ne 'default.sequence'
444: && $maptitle ne $coursetitle);
445:
446: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
447:
448: &Apache::lonhtmlcommon::clear_breadcrumbs();
449: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
450: }elsif (! $const_space){
451: #a situation when we're looking at a resource outside of context of a
452: #course or construction space (e.g. with cumulative rights)
453: &Apache::lonhtmlcommon::clear_breadcrumbs();
454: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
455: }
456: # =============================================================================
457: # ============================ This is for URLs that actually can be registered
458: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
459: || $forcereg );
460:
461: # -- This applies to homework problems for users with grading privileges
462: my $crs='/'.$env{'request.course.id'};
463: if ($env{'request.course.sec'}) {
464: $crs.='_'.$env{'request.course.sec'};
465: }
466: $crs=~s/\_/\//g;
467:
468: my $hwkadd='';
469: if ($env{'request.symb'} ne '' &&
470: $env{'request.filename'}=~/$LONCAPA::assess_re/) {
471: if (&Apache::lonnet::allowed('mgr',$crs)) {
472: $hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
473: "gocmd('/adm/grades','gradingmenu')",
474: 'Content Grades');
475: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
476: $hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
477: "gocmd('/adm/grades','submission')",
478: 'Content Submissions');
479: }
480: }
481: if ($env{'request.symb'} ne '' &&
482: &Apache::lonnet::allowed('opa',$crs)) {
483: $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
484: "gocmd('/adm/parmset','set')",
485: 'Content Settings');
486: }
487: if ($env{'request.symb'}=~/^uploaded/ &&
488: &Apache::lonnet::allowed('mdc',$crs)) {
489: $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]',
490: "gocmd('/adm/coursedocs','direct')",
491: 'Folder/Page Content');
492: }
493: # -- End Homework
494: ###
495: ### Determine whether or not to display the 'cstr' button for this
496: ### resource
497: ###
498: my $editbutton = '';
499: my $noeditbutton = 1;
500: my ($cnum,$cdom);
501: if ($env{'request.course.id'}) {
502: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
503: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
504: }
505: if ($env{'user.author'}) {
506: if ($env{'request.role'}=~/^(aa|ca|au)/) {
507: #
508: # We have the role of an author
509: #
510: # Set defaults for authors
511: my ($top,$bottom) = ('con-','struct');
512: my $action = "go('/priv/".$env{'user.domain'}.'/'.$env{'user.name'}."');";
513: my $cadom = $env{'request.role.domain'};
514: my $caname = $env{'user.name'};
515: my $desc = "Enter my construction space";
516: # Set defaults for co-authors
517: if ($env{'request.role'} =~ /^ca/) {
518: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
519: ($top,$bottom) = ('co con-','struct');
520: $action = "go('/priv/".$cadom.'/'.$caname."');";
521: $desc = "Enter construction space as co-author";
522: } elsif ($env{'request.role'} =~ /^aa/) {
523: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
524: ($top,$bottom) = ('co con-','struct');
525: $action = "go('/priv/".$cadom.'/'.$caname."');";
526: $desc = "Enter construction space as assistant co-author";
527: }
528: # Check that we are on the correct machine
529: my $home = &Apache::lonnet::homeserver($caname,$cadom);
530: my $allowed=0;
531: my @ids=&Apache::lonnet::current_machine_ids();
532: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
533: if (!$allowed) {
534: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
535: $noeditbutton = 0;
536: }
537: }
538: #
539: # We are an author for some stuff, but currently do not have the role of author.
540: # Figure out if we have authoring privileges for the resource we are looking at.
541: # This should maybe become a privilege check in lonnet
542: #
543: ##
544: ## Determine if user can edit url.
545: ##
546: my $cfile='';
547: my $cfuname='';
548: my $cfudom='';
549: my $uploaded;
550: my $switchserver='';
551: my $home;
552: if ($env{'request.filename'}) {
553: my $file=&Apache::lonnet::declutter($env{'request.filename'});
554: if (defined($cnum) && defined($cdom)) {
555: $uploaded = &is_course_upload($file,$cnum,$cdom);
556: }
557: if (!$uploaded) {
558:
559: $file=~s{^(priv/$match_domain/$match_username)}{/$1};
560: $file=~s{^($match_domain/$match_username)}{/priv/$1};
561:
562: # Check that the user has permission to edit this resource
563: my $setpriv = 1;
564: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$setpriv);
565: if (defined($cfudom)) {
566: $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
567: my $allowed=0;
568: my @ids=&Apache::lonnet::current_machine_ids();
569: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
570: if ($allowed) {
571: $cfile=$file;
572: } else {
573: $switchserver=$file;
574: }
575: }
576: }
577: }
578: # Finally, turn the button on or off
579: if (($cfile || $switchserver) && !$const_space) {
580: my $nocrsedit;
581: # Suppress display where CC has switched to student role.
582: if ($env{'request.course.id'}) {
583: unless(&Apache::lonnet::allowed('mdc',
584: $env{'request.course.id'})) {
585: $nocrsedit = 1;
586: }
587: }
588: if ($nocrsedit) {
589: $editbutton=&clear(6,1);
590: } else {
591: my $bot = "go('$cfile')";
592: if ($switchserver) {
593: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
594: $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
595: &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='.
596: &HTML::Entities::encode($env{'request.symb'},'"<>&');
597: $bot = "need_switchserver('$cfile');";
598: }
599: }
600: $editbutton=&switch
601: ('','',6,1,'pcstr.png','Edit','resource[_2]',
602: $bot,"Edit this resource");
603: $noeditbutton = 0;
604: }
605: } elsif ($editbutton eq '') {
606: $editbutton=&clear(6,1);
607: }
608: }
609: if (($noeditbutton) && ($env{'request.filename'})) {
610: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
611: my $file=&Apache::lonnet::declutter($env{'request.filename'});
612: if (defined($cnum) && defined($cdom)) {
613: if (&is_course_upload($file,$cnum,$cdom)) {
614: my $cfile = &edit_course_upload($file,$cnum,$cdom);
615: if ($cfile) {
616: $editbutton=&switch
617: ('','',6,1,'pcstr.png','Edit',
618: 'resource[_2]',"go('".$cfile."');",
619: 'Edit this resource');
620: }
621: }
622: }
623: }
624: }
625: if ($env{'request.course.id'}) {
626: if ($resurl eq "public/$cdom/$cnum/syllabus") {
627: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
628: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
629: $editbutton=&switch('','',6,1,'pcstr.png','Edit',
630: 'resource[_2]',
631: "go('/adm/courseprefs?phase=display&actions=courseinfo')",
632: 'Edit this resource');
633: }
634: }
635: }
636: }
637: ###
638: ###
639: # Prepare the rest of the buttons
640: my $menuitems;
641: if ($const_space) {
642: #
643: # We are in construction space
644: #
645:
646: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
647: my ($udom,$uname,$thisdisfn) =
648: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
649: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
650: if ($currdir =~ m-/$-) {
651: $is_const_dir = 1;
652: } else {
653: $currdir =~ s|[^/]+$||;
654: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
655: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
656: #
657: # Probably should be in mydesk.tab
658: #
659: $menuitems=(<<ENDMENUITEMS);
660: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
661: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
662: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
663: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
664: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
665: ENDMENUITEMS
666: }
667: if (ref($bread_crumbs) eq 'ARRAY') {
668: &Apache::lonhtmlcommon::clear_breadcrumbs();
669: foreach my $crumb (@{$bread_crumbs}){
670: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
671: }
672: }
673: } elsif ( defined($env{'request.course.id'}) &&
674: $env{'request.symb'} ne '' ) {
675: #
676: # We are in a course and looking at a registred URL
677: # Should probably be in mydesk.tab
678: #
679: $menuitems=(<<ENDMENUITEMS);
680: c&3&1
681: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
682: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
683: c&6&3
684: c&8&1
685: c&8&2
686: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
687: ENDMENUITEMS
688: if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F' && $env{'request.uri'} =~ /^\/res/) {
689: # wishlist is only available for users with access to resource-pool
690: # and links can only be set for resources within the resource-pool
691: $menuitems .= (<<ENDMENUITEMS);
692: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
693: ENDMENUITEMS
694: }
695:
696: my $currentURL = &Apache::loncommon::get_symb();
697: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
698: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
699: $menuitems.="s&9&3&";
700: if(length($annotation) > 0){
701: $menuitems.="anot2.png";
702: }else{
703: $menuitems.="anot.png";
704: }
705: $menuitems.="&Notes&&annotate()&";
706: $menuitems.="Make notes and annotations about this resource&&1\n";
707:
708: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
709: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
710: $menuitems.=(<<ENDREALRES);
711: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
712: ENDREALRES
713: }
714: $menuitems.=(<<ENDREALRES);
715: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
716: s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
717: ENDREALRES
718: }
719: }
720: if ($env{'request.uri'} =~ /^\/res/) {
721: $menuitems .= (<<ENDMENUITEMS);
722: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
723: ENDMENUITEMS
724: if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F') {
725: # wishlist is only available for users with access to resource-pool
726: $menuitems .= (<<ENDMENUITEMS);
727: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in in your personal Stored Links repository&&1
728: ENDMENUITEMS
729: }
730: }
731: my $buttons='';
732: foreach (split(/\n/,$menuitems)) {
733: my ($command,@rest)=split(/\&/,$_);
734: my $idx=10*$rest[0]+$rest[1];
735: if (&hidden_button_check() eq 'yes') {
736: if ($idx == 21 ||$idx == 23) {
737: $buttons.=&switch('','',@rest);
738: } else {
739: $buttons.=&clear(@rest);
740: }
741: } else {
742: if ($command eq 's') {
743: $buttons.=&switch('','',@rest);
744: } else {
745: $buttons.=&clear(@rest);
746: }
747: }
748: }
749:
750: my $addremote=0;
751: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
752: if ($addremote) {
753:
754: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
755:
756: &Apache::lonhtmlcommon::add_breadcrumb_tool(
757: 'navigation', @inlineremote[21,23]);
758:
759: if(hidden_button_check() ne 'yes') {
760: &Apache::lonhtmlcommon::add_breadcrumb_tool(
761: 'tools', @inlineremote[93,91,81,82,83]);
762:
763: #publish button in construction space
764: if ($env{'request.state'} eq 'construct'){
765: &Apache::lonhtmlcommon::add_breadcrumb_tool(
766: 'advtools', $inlineremote[63]);
767: } else {
768: &Apache::lonhtmlcommon::add_breadcrumb_tool(
769: 'tools', $inlineremote[63]);
770: }
771:
772: unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
773: &Apache::lonhtmlcommon::add_breadcrumb_tool(
774: 'advtools', @inlineremote[61,71,72,73,74,92]);
775: }
776: }
777: }
778:
779: return &Apache::lonhtmlcommon::scripttag('', 'start')
780: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
781: . &Apache::lonhtmlcommon::scripttag('', 'end');
782: }
783:
784: sub is_course_upload {
785: my ($file,$cnum,$cdom) = @_;
786: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
787: $uploadpath =~ s{^\/}{};
788: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
789: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
790: return 1;
791: }
792: return;
793: }
794:
795: sub edit_course_upload {
796: my ($file,$cnum,$cdom) = @_;
797: my $cfile;
798: if ($file =~/\.(htm|html|css|js|txt)$/) {
799: my $ext = $1;
800: my $url = &Apache::lonnet::hreflocation('',$file);
801: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
802: my @ids=&Apache::lonnet::current_machine_ids();
803: my $dest;
804: if ($home && grep(/^\Q$home\E$/,@ids)) {
805: $dest = $url.'?forceedit=1';
806: } else {
807: unless (&Apache::lonnet::get_locks()) {
808: $dest = '/adm/switchserver?otherserver='.
809: $home.'&role='.$env{'request.role'}.
810: '&url='.$url.'&forceedit=1';
811: }
812: }
813: if ($dest) {
814: $cfile = &HTML::Entities::encode($dest,'"<>&');
815: }
816: }
817: return $cfile;
818: }
819:
820: # ================================================================== Raw Config
821:
822: sub clear {
823: my ($row,$col)=@_;
824: $inlineremote[10*$row+$col]='';
825: return '';
826: }
827:
828: # ============================================ Switch a button or create a link
829: # Switch acts on the javascript that is executed when a button is clicked.
830: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
831:
832: sub switch {
833: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
834: $act=~s/\$uname/$uname/g;
835: $act=~s/\$udom/$udom/g;
836: $top=&mt($top);
837: $bot=&mt($bot);
838: $desc=&mt($desc);
839: my $idx=10*$row+$col;
840: $category_members{$cat}.=':'.$idx;
841:
842: # Inline Menu
843: if ($nobreak==2) { return ''; }
844: my $text=$top.' '.$bot;
845: $text=~s/\s*\-\s*//gs;
846:
847: my $pic=
848: '<img alt="'.$text.'" src="'.
849: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
850: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
851: if ($env{'browser.interface'} eq 'faketextual') {
852: # Main Menu
853: if ($nobreak==3) {
854: $inlineremote[$idx]="\n".
855: '<td class="LC_menubuttons_text" align="right">'.$text.
856: '</td><td align="left">'.
857: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
858: } elsif ($nobreak) {
859: $inlineremote[$idx]="\n<tr>".
860: '<td align="left">'.
861: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
862: <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>';
863: } else {
864: $inlineremote[$idx]="\n<tr>".
865: '<td align="left">'.
866: '<a href="javascript:'.$act.';">'.$pic.
867: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
868: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
869: }
870: } else {
871: # Inline Menu
872: $inlineremote[$idx]=
873: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
874: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
875: }
876: return '';
877: }
878:
879: sub secondlevel {
880: my $output='';
881: my
882: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
883: if ($prt eq 'any') {
884: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
885: } elsif ($prt=~/^r(\w+)/) {
886: if ($rol eq $1) {
887: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
888: }
889: }
890: return $output;
891: }
892:
893: sub inlinemenu {
894: undef(@inlineremote);
895: undef(%category_members);
896: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
897: &rawconfig(1);
898: my $output='<table><tr>';
899: for (my $col=1; $col<=2; $col++) {
900: $output.='<td class="LC_mainmenu_col_fieldset">';
901: for (my $row=1; $row<=8; $row++) {
902: foreach my $cat (keys(%category_members)) {
903: if ($category_positions{$cat} ne "$col,$row") { next; }
904: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
905: $output.='<div class="LC_Box LC_400Box">';
906: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
907: $output.='<table>';
908: my %active=();
909: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
910: if ($inlineremote[$menu_item]) {
911: $active{$menu_item}=1;
912: }
913: }
914: foreach my $item (sort(keys(%active))) {
915: $output.=$inlineremote[$item];
916: }
917: $output.='</table>';
918: $output.='</div>';
919: }
920: }
921: $output.="</td>";
922: }
923: $output.="</tr></table>";
924: return $output;
925: }
926:
927: sub rawconfig {
928: #
929: # This evaluates mydesk.tab
930: # Need to add more positions and more privileges to deal with all
931: # menu items.
932: #
933: my $textualoverride=shift;
934: my $output='';
935: return '' unless $textualoverride;
936: my $uname=$env{'user.name'};
937: my $udom=$env{'user.domain'};
938: my $adv=$env{'user.adv'};
939: my $show_course=&Apache::loncommon::show_course();
940: my $author=$env{'user.author'};
941: my $crs='';
942: my $crstype='';
943: if ($env{'request.course.id'}) {
944: $crs='/'.$env{'request.course.id'};
945: if ($env{'request.course.sec'}) {
946: $crs.='_'.$env{'request.course.sec'};
947: }
948: $crs=~s/\_/\//g;
949: $crstype = &Apache::loncommon::course_type();
950: }
951: my $pub=($env{'request.state'} eq 'published');
952: my $con=($env{'request.state'} eq 'construct');
953: my $rol=$env{'request.role'};
954: my $requested_domain = $env{'request.role.domain'};
955: foreach my $line (@desklines) {
956: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
957: $prt=~s/\$uname/$uname/g;
958: $prt=~s/\$udom/$udom/g;
959: if ($prt =~ /\$crs/) {
960: next unless ($env{'request.course.id'});
961: next if ($crstype eq 'Community');
962: $prt=~s/\$crs/$crs/g;
963: } elsif ($prt =~ /\$cmty/) {
964: next unless ($env{'request.course.id'});
965: next if ($crstype ne 'Community');
966: $prt=~s/\$cmty/$crs/g;
967: }
968: $prt=~s/\$requested_domain/$requested_domain/g;
969: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
970: if ($pro eq 'clear') {
971: $output.=&clear($row,$col);
972: } elsif ($pro eq 'any') {
973: $output.=&secondlevel(
974: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
975: } elsif ($pro eq 'smp') {
976: unless ($adv) {
977: $output.=&secondlevel(
978: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
979: }
980: } elsif ($pro eq 'adv') {
981: if ($adv) {
982: $output.=&secondlevel(
983: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
984: }
985: } elsif ($pro eq 'shc') {
986: if ($show_course) {
987: $output.=&secondlevel(
988: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
989: }
990: } elsif ($pro eq 'nsc') {
991: if (!$show_course) {
992: $output.=&secondlevel(
993: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
994: }
995: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
996: my $priv = $1;
997: if ($priv =~ /^mdc(Course|Community)/) {
998: if ($crstype eq $1) {
999: $priv = 'mdc';
1000: } else {
1001: next;
1002: }
1003: }
1004: if (&Apache::lonnet::allowed($priv,$prt)) {
1005: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1006: }
1007: } elsif ($pro eq 'course') {
1008: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1009: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1010: }
1011: } elsif ($pro eq 'community') {
1012: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1013: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1014: }
1015: } elsif ($pro =~ /^courseenv_(.*)$/) {
1016: my $key = $1;
1017: if ($crstype ne 'Community') {
1018: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1019: if ($key eq 'canuse_pdfforms') {
1020: if ($env{'request.course.id'} && $coursepref eq '') {
1021: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1022: $coursepref = $domdefs{'canuse_pdfforms'};
1023: }
1024: }
1025: if ($coursepref) {
1026: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1027: }
1028: }
1029: } elsif ($pro =~ /^communityenv_(.*)$/) {
1030: my $key = $1;
1031: if ($crstype eq 'Community') {
1032: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1033: if ($key eq 'canuse_pdfforms') {
1034: if ($env{'request.course.id'} && $coursepref eq '') {
1035: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1036: $coursepref = $domdefs{'canuse_pdfforms'};
1037: }
1038: }
1039: if ($coursepref) {
1040: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1041: }
1042: }
1043: } elsif ($pro =~ /^course_(.*)$/) {
1044: # Check for permissions inside of a course
1045: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1046: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1047: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1048: )) {
1049: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1050: }
1051: } elsif ($pro =~ /^community_(.*)$/) {
1052: # Check for permissions inside of a community
1053: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1054: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1055: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1056: )) {
1057: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1058: }
1059: } elsif ($pro eq 'author') {
1060: if ($author) {
1061: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1062: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1063: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1064: # Check that we are on the correct machine
1065: my $cadom=$requested_domain;
1066: my $caname=$env{'user.name'};
1067: if (($prt eq 'rca') || ($prt eq 'raa')) {
1068: ($cadom,$caname)=
1069: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1070: }
1071: $act =~ s/\$caname/$caname/g;
1072: $act =~ s/\$cadom/$cadom/g;
1073: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1074: my $allowed=0;
1075: my @ids=&Apache::lonnet::current_machine_ids();
1076: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1077: if ($allowed) {
1078: $output.=&switch($caname,$cadom,
1079: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1080: }
1081: }
1082: }
1083: } elsif ($pro eq 'tools') {
1084: my @tools = ('aboutme','blog','portfolio');
1085: if (grep(/^\Q$prt\E$/,@tools)) {
1086: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1087: $env{'user.domain'},
1088: $prt,undef,'tools')) {
1089: $output.=&clear($row,$col);
1090: next;
1091: }
1092: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1093: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1094: next;
1095: }
1096: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1097: next;
1098: }
1099: my $showreqcrs = &check_for_rcrs();
1100: if (!$showreqcrs) {
1101: $output.=&clear($row,$col);
1102: next;
1103: }
1104: }
1105: $prt='any';
1106: $output.=&secondlevel(
1107: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1108: }
1109: }
1110: return $output;
1111: }
1112:
1113: sub check_for_rcrs {
1114: my $showreqcrs = 0;
1115: my @reqtypes = ('official','unofficial','community');
1116: foreach my $type (@reqtypes) {
1117: if (&Apache::lonnet::usertools_access($env{'user.name'},
1118: $env{'user.domain'},
1119: $type,undef,'requestcourses')) {
1120: $showreqcrs = 1;
1121: last;
1122: }
1123: }
1124: if (!$showreqcrs) {
1125: foreach my $type (@reqtypes) {
1126: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1127: $showreqcrs = 1;
1128: last;
1129: }
1130: }
1131: }
1132: return $showreqcrs;
1133: }
1134:
1135: sub dc_popup_js {
1136: my %lt = &Apache::lonlocal::texthash(
1137: more => '(More ...)',
1138: less => '(Less ...)',
1139: );
1140: return <<"END";
1141:
1142: function showCourseID() {
1143: document.getElementById('dccid').style.display='block';
1144: document.getElementById('dccid').style.textAlign='left';
1145: document.getElementById('dccid').style.textFace='normal';
1146: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1147: return;
1148: }
1149:
1150: function hideCourseID() {
1151: document.getElementById('dccid').style.display='none';
1152: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1153: return;
1154: }
1155:
1156: END
1157:
1158: }
1159:
1160: sub utilityfunctions {
1161: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1162: if ($currenturl =~ m{^/adm/wrapper/ext/}
1163: && $env{'request.external.querystring'} ) {
1164: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1165: }
1166: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1167:
1168: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1169:
1170: my $dc_popup_cid;
1171: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1172: $env{'course.'.$env{'request.course.id'}.
1173: '.domain'}.'/'})) {
1174: $dc_popup_cid = &dc_popup_js();
1175: }
1176:
1177: my $start_page_annotate =
1178: &Apache::loncommon::start_page('Annotator',undef,
1179: {'only_body' => 1,
1180: 'js_ready' => 1,
1181: 'bgcolor' => '#BBBBBB',
1182: 'add_entries' => {
1183: 'onload' => 'javascript:document.goannotate.submit();'}});
1184:
1185: my $end_page_annotate =
1186: &Apache::loncommon::end_page({'js_ready' => 1});
1187:
1188: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
1189: &mt('Switch server?');
1190:
1191: my $esc_url=&escape($currenturl);
1192: my $esc_symb=&escape($currentsymb);
1193:
1194: return (<<ENDUTILITY)
1195:
1196: var currentURL=unescape("$esc_url");
1197: var reloadURL=unescape("$esc_url");
1198: var currentSymb=unescape("$esc_symb");
1199:
1200: $dc_popup_cid
1201:
1202: function go(url) {
1203: if (url!='' && url!= null) {
1204: currentURL = null;
1205: currentSymb= null;
1206: window.location.href=url;
1207: }
1208: }
1209:
1210: function need_switchserver(url) {
1211: if (url!='' && url!= null) {
1212: if (confirm("$confirm_switch")) {
1213: go(url);
1214: }
1215: }
1216: return;
1217: }
1218:
1219: function gopost(url,postdata) {
1220: if (url!='') {
1221: this.document.server.action=url;
1222: this.document.server.postdata.value=postdata;
1223: this.document.server.command.value='';
1224: this.document.server.url.value='';
1225: this.document.server.symb.value='';
1226: this.document.server.submit();
1227: }
1228: }
1229:
1230: function gocmd(url,cmd) {
1231: if (url!='') {
1232: this.document.server.action=url;
1233: this.document.server.postdata.value='';
1234: this.document.server.command.value=cmd;
1235: this.document.server.url.value=currentURL;
1236: this.document.server.symb.value=currentSymb;
1237: this.document.server.submit();
1238: }
1239: }
1240:
1241: function gocstr(url,filename) {
1242: if (url == '/adm/cfile?action=delete') {
1243: this.document.cstrdelete.filename.value = filename
1244: this.document.cstrdelete.submit();
1245: return;
1246: }
1247: if (url == '/adm/printout') {
1248: this.document.cstrprint.postdata.value = filename
1249: this.document.cstrprint.curseed.value = 0;
1250: this.document.cstrprint.problemtype.value = 0;
1251: if (this.document.lonhomework) {
1252: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1253: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1254: }
1255: if (this.document.lonhomework.problemtype) {
1256: if (this.document.lonhomework.problemtype.value) {
1257: this.document.cstrprint.problemtype.value =
1258: this.document.lonhomework.problemtype.value;
1259: } else if (this.document.lonhomework.problemtype.options) {
1260: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1261: if (this.document.lonhomework.problemtype.options[i].selected) {
1262: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1263: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1264: }
1265: }
1266: }
1267: }
1268: }
1269: }
1270: this.document.cstrprint.submit();
1271: return;
1272: }
1273: if (url !='') {
1274: this.document.constspace.filename.value = filename;
1275: this.document.constspace.action = url;
1276: this.document.constspace.submit();
1277: }
1278: }
1279:
1280: function golist(url) {
1281: if (url!='' && url!= null) {
1282: currentURL = null;
1283: currentSymb= null;
1284: top.location.href=url;
1285: }
1286: }
1287:
1288:
1289:
1290: function catalog_info() {
1291: openMyModal(window.location.pathname+'.meta',500,400,'yes');
1292: }
1293:
1294: function chat_win() {
1295: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1296: }
1297:
1298: function group_chat(group) {
1299: var url = '/adm/groupchat?group='+group;
1300: var winName = 'LONchat_'+group;
1301: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1302: }
1303:
1304: function annotate() {
1305: w_Annotator_flag=1;
1306: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1307: annotator.document.write(
1308: '$start_page_annotate'
1309: +"<form name='goannotate' target='Annotator' method='post' "
1310: +"action='/adm/annotations'>"
1311: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1312: +"<\\/form>"
1313: +'$end_page_annotate');
1314: annotator.document.close();
1315: }
1316:
1317: function open_StoredLinks_Import(rat) {
1318: var newWin;
1319: if (rat) {
1320: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1321: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1322: }
1323: else {
1324: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
1325: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1326: }
1327: newWin.focus();
1328: }
1329:
1330: ENDUTILITY
1331: }
1332:
1333: sub serverform {
1334: return(<<ENDSERVERFORM);
1335: <form name="server" action="/adm/logout" method="post" target="_top">
1336: <input type="hidden" name="postdata" value="none" />
1337: <input type="hidden" name="command" value="none" />
1338: <input type="hidden" name="url" value="none" />
1339: <input type="hidden" name="symb" value="none" />
1340: </form>
1341: ENDSERVERFORM
1342: }
1343:
1344: sub constspaceform {
1345: return(<<ENDCONSTSPACEFORM);
1346: <form name="constspace" action="/adm/logout" method="post" target="_top">
1347: <input type="hidden" name="filename" value="" />
1348: </form>
1349: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1350: <input type="hidden" name="action" value="delete" />
1351: <input type="hidden" name="filename" value="" />
1352: </form>
1353: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1354: <input type="hidden" name="postdata" value="" />
1355: <input type="hidden" name="curseed" value="" />
1356: <input type="hidden" name="problemtype" value="" />
1357: </form>
1358:
1359: ENDCONSTSPACEFORM
1360: }
1361:
1362: sub hidden_button_check {
1363: if ( $env{'request.course.id'} eq ''
1364: || $env{'request.role.adv'} ) {
1365:
1366: return;
1367: }
1368: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1369: return $buttonshide;
1370: }
1371:
1372: sub roles_selector {
1373: my ($cdom,$cnum) = @_;
1374: my $crstype = &Apache::loncommon::course_type();
1375: my $now = time;
1376: my (%courseroles,%seccount,%courseprivs);
1377: my $is_cc;
1378: my $role_selector;
1379: my $ccrole;
1380: if ($crstype eq 'Community') {
1381: $ccrole = 'co';
1382: } else {
1383: $ccrole = 'cc';
1384: }
1385: my $priv;
1386: my $destinationurl = $ENV{'REQUEST_URI'};
1387: my $reqprivs = &required_privs();
1388: if (ref($reqprivs) eq 'HASH') {
1389: my $destination = $destinationurl;
1390: $destination =~ s/(\?.*)$//;
1391: if (exists($reqprivs->{$destination})) {
1392: $priv = $reqprivs->{$destination};
1393: }
1394: }
1395: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1396: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1397:
1398: if ((($start) && ($start<0)) ||
1399: (($end) && ($end<$now)) ||
1400: (($start) && ($now<$start))) {
1401: $is_cc = 0;
1402: } else {
1403: $is_cc = 1;
1404: }
1405: }
1406: if ($is_cc) {
1407: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
1408: } else {
1409: my %gotnosection;
1410: foreach my $item (keys(%env)) {
1411: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1412: my $role = $1;
1413: my $sec = $2;
1414: next if ($role eq 'gr');
1415: my ($start,$end) = split(/\./,$env{$item});
1416: next if (($start && $start > $now) || ($end && $end < $now));
1417: if ($sec eq '') {
1418: if (!$gotnosection{$role}) {
1419: $seccount{$role} ++;
1420: $gotnosection{$role} = 1;
1421: }
1422: }
1423: if ($priv ne '') {
1424: my $cnumsec = $cnum;
1425: if ($sec ne '') {
1426: $cnumsec .= "/$sec";
1427: }
1428: $courseprivs{"$role./$cdom/$cnumsec./"} =
1429: $env{"user.priv.$role./$cdom/$cnumsec./"};
1430: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
1431: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
1432: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
1433: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
1434: }
1435: if (ref($courseroles{$role}) eq 'ARRAY') {
1436: if ($sec ne '') {
1437: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1438: push(@{$courseroles{$role}},$sec);
1439: $seccount{$role} ++;
1440: }
1441: }
1442: } else {
1443: @{$courseroles{$role}} = ();
1444: if ($sec ne '') {
1445: $seccount{$role} ++;
1446: push(@{$courseroles{$role}},$sec);
1447: }
1448: }
1449: }
1450: }
1451: }
1452: my $switchtext;
1453: if ($crstype eq 'Community') {
1454: $switchtext = &mt('Switch community role to...')
1455: } else {
1456: $switchtext = &mt('Switch course role to...')
1457: }
1458: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1459: if (keys(%courseroles) > 1) {
1460: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
1461: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1462: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1463: $role_selector .= '<option value="">'.$switchtext.'</option>';
1464: foreach my $role (@roles_order) {
1465: if (defined($courseroles{$role})) {
1466: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1467: }
1468: }
1469: foreach my $role (sort(keys(%courseroles))) {
1470: if ($role =~ /^cr/) {
1471: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1472: }
1473: }
1474: $role_selector .= '</select>'."\n".
1475: '<input type="hidden" name="destinationurl" value="'.
1476: &HTML::Entities::encode($destinationurl).'" />'."\n".
1477: '<input type="hidden" name="gotorole" value="1" />'."\n".
1478: '<input type="hidden" name="selectrole" value="" />'."\n".
1479: '<input type="hidden" name="switch" value="1" />'."\n".
1480: '</form>';
1481: }
1482: return $role_selector;
1483: }
1484:
1485: sub get_all_courseroles {
1486: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1487: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1488: (ref($courseprivs) eq 'HASH')) {
1489: return;
1490: }
1491: my ($result,$cached) =
1492: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1493: if (defined($cached)) {
1494: if (ref($result) eq 'HASH') {
1495: if ((ref($result->{'roles'}) eq 'HASH') &&
1496: (ref($result->{'seccount'}) eq 'HASH') &&
1497: (ref($result->{'privs'}) eq 'HASH')) {
1498: %{$courseroles} = %{$result->{'roles'}};
1499: %{$seccount} = %{$result->{'seccount'}};
1500: %{$courseprivs} = %{$result->{'privs'}};
1501: return;
1502: }
1503: }
1504: }
1505: my %gotnosection;
1506: my %adv_roles =
1507: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1508: foreach my $role (keys(%adv_roles)) {
1509: my ($urole,$usec) = split(/:/,$role);
1510: if (!$gotnosection{$urole}) {
1511: $seccount->{$urole} ++;
1512: $gotnosection{$urole} = 1;
1513: }
1514: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1515: if ($usec ne '') {
1516: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1517: push(@{$courseroles->{$urole}},$usec);
1518: $seccount->{$urole} ++;
1519: }
1520: }
1521: } else {
1522: @{$courseroles->{$urole}} = ();
1523: if ($usec ne '') {
1524: $seccount->{$urole} ++;
1525: push(@{$courseroles->{$urole}},$usec);
1526: }
1527: }
1528: my $area = '/'.$cdom.'/'.$cnum;
1529: if ($usec ne '') {
1530: $area .= '/'.$usec;
1531: }
1532: if ($role =~ /^cr\//) {
1533: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
1534: } else {
1535: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
1536: }
1537: }
1538: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1539: @{$courseroles->{'st'}} = ();
1540: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1541: if (keys(%sections_count) > 0) {
1542: push(@{$courseroles->{'st'}},keys(%sections_count));
1543: $seccount->{'st'} = scalar(keys(%sections_count));
1544: }
1545: my $rolehash = {
1546: 'roles' => $courseroles,
1547: 'seccount' => $seccount,
1548: 'privs' => $courseprivs,
1549: };
1550: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1551: return;
1552: }
1553:
1554: sub jump_to_role {
1555: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
1556: my %lt = &Apache::lonlocal::texthash(
1557: this => 'This role has section(s) associated with it.',
1558: ente => 'Enter a specific section.',
1559: orlb => 'Enter a specific section, or leave blank for no section.',
1560: avai => 'Available sections are:',
1561: youe => 'You entered an invalid section choice:',
1562: plst => 'Please try again.',
1563: role => 'The role you selected is not permitted to view the current page.',
1564: swit => 'Switch role, but display Main Menu page instead?',
1565: );
1566: my $js;
1567: if (ref($courseroles) eq 'HASH') {
1568: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1569: ' var numsec = new Array();'."\n".
1570: ' var rolesections = new Array();'."\n".
1571: ' var rolenames = new Array();'."\n".
1572: ' var roleseclist = new Array();'."\n";
1573: my @items = keys(%{$courseroles});
1574: for (my $i=0; $i<@items; $i++) {
1575: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1576: my ($secs,$secstr);
1577: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1578: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1579: $secs = join('","',@sections);
1580: $secstr = join(', ',@sections);
1581: }
1582: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1583: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1584: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1585: }
1586: }
1587: my $checkroles = 0;
1588: if ($priv && ref($courseprivs) eq 'HASH') {
1589: my (%disallowed,%allowed,@disallow);
1590: foreach my $role (sort(keys(%{$courseprivs}))) {
1591: my $trole;
1592: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
1593: $trole = $1;
1594: }
1595: if (($trole ne '') && ($trole ne 'cm')) {
1596: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
1597: $allowed{$trole} = 1;
1598: } else {
1599: $disallowed{$trole} = 1;
1600: }
1601: }
1602: }
1603: foreach my $trole (keys(%disallowed)) {
1604: unless ($allowed{$trole}) {
1605: push(@disallow,$trole);
1606: }
1607: }
1608: if (@disallow > 0) {
1609: $checkroles = 1;
1610: $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
1611: " var rolecheck = 1;\n";
1612: }
1613: }
1614: if (!$checkroles) {
1615: $js .= " var disallow = new Array();\n".
1616: " rolecheck = 0;\n";
1617: }
1618: return <<"END";
1619: <script type="text/javascript">
1620: //<![CDATA[
1621: function adhocRole(roleitem) {
1622: $js
1623: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1624: if (newrole == '') {
1625: return;
1626: }
1627: var fullrole = newrole+'./$cdom/$cnum';
1628: var selidx = '';
1629: for (var i=0; i<rolenames.length; i++) {
1630: if (rolenames[i] == newrole) {
1631: selidx = i;
1632: }
1633: }
1634: if (rolecheck > 0) {
1635: for (var i=0; i<disallow.length; i++) {
1636: if (disallow[i] == newrole) {
1637: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
1638: document.rolechooser.destinationurl.value = '/adm/menu';
1639: } else {
1640: document.rolechooser.elements[roleitem].selectedIndex = 0;
1641: return;
1642: }
1643: }
1644: }
1645: }
1646: var secok = 1;
1647: var secchoice = '';
1648: if (selidx >= 0) {
1649: if (numsec[selidx] > 1) {
1650: secok = 0;
1651: var numrolesec = rolesections[selidx].length;
1652: var msgidx = numsec[selidx] - numrolesec;
1653: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1654: if (secchoice == '') {
1655: if (msgidx > 0) {
1656: secok = 1;
1657: }
1658: } else {
1659: for (var j=0; j<rolesections[selidx].length; j++) {
1660: if (rolesections[selidx][j] == secchoice) {
1661: secok = 1;
1662: }
1663: }
1664: }
1665: } else {
1666: if (rolesections[selidx].length == 1) {
1667: secchoice = rolesections[selidx][0];
1668: }
1669: }
1670: }
1671: if (secok == 1) {
1672: if (secchoice != '') {
1673: fullrole += '/'+secchoice;
1674: }
1675: } else {
1676: document.rolechooser.elements[roleitem].selectedIndex = 0;
1677: if (secchoice != null) {
1678: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1679: }
1680: return;
1681: }
1682: if (fullrole == "$env{'request.role'}") {
1683: document.rolechooser.elements[roleitem].selectedIndex = 0;
1684: return;
1685: }
1686: itemid = retrieveIndex('gotorole');
1687: if (itemid != -1) {
1688: document.rolechooser.elements[itemid].name = fullrole;
1689: }
1690: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1691: document.rolechooser.selectrole.value = '1';
1692: document.rolechooser.submit();
1693: return;
1694: }
1695:
1696: function retrieveIndex(item) {
1697: for (var i=0;i<document.rolechooser.elements.length;i++) {
1698: if (document.rolechooser.elements[i].name == item) {
1699: return i;
1700: }
1701: }
1702: return -1;
1703: }
1704: // ]]>
1705: </script>
1706: END
1707: }
1708:
1709: sub required_privs {
1710: my $privs = {
1711: '/adm/parmset' => 'opa',
1712: '/adm/courseprefs' => 'opa',
1713: '/adm/whatsnew' => 'whn',
1714: '/adm/populate' => 'cst',
1715: '/adm/trackstudent' => 'vsa',
1716: '/adm/statistics' => 'vgr',
1717: '/adm/setblock' => 'dcm',
1718: '/adm/coursedocs' => 'mdc',
1719: };
1720: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1721: $privs->{'/adm/classcalc'} = 'vgr',
1722: $privs->{'/adm/assesscalc'} = 'vgr',
1723: $privs->{'/adm/studentcalc'} = 'vgr';
1724: }
1725: return $privs;
1726: }
1727:
1728: # ================================================================ Main Program
1729:
1730: BEGIN {
1731: if (! defined($readdesk)) {
1732: {
1733: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1734: if ( CORE::open( my $config,"<$tabfile") ) {
1735: while (my $configline=<$config>) {
1736: $configline=(split(/\#/,$configline))[0];
1737: $configline=~s/^\s+//;
1738: chomp($configline);
1739: if ($configline=~/^cat\:/) {
1740: my @entries=split(/\:/,$configline);
1741: $category_positions{$entries[2]}=$entries[1];
1742: $category_names{$entries[2]}=$entries[3];
1743: } elsif ($configline=~/^prim\:/) {
1744: my @entries = (split(/\:/, $configline))[1..5];
1745: push @primary_menu, \@entries;
1746: } elsif ($configline=~/^primsub\:/) {
1747: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
1748: push (@{$primary_submenu{$parent}},\@entries);
1749: } elsif ($configline=~/^scnd\:/) {
1750: my @entries = (split(/\:/, $configline))[1..5];
1751: push @secondary_menu, \@entries;
1752: } elsif ($configline) {
1753: push(@desklines,$configline);
1754: }
1755: }
1756: CORE::close($config);
1757: }
1758: }
1759: $readdesk='done';
1760: }
1761: }
1762:
1763: 1;
1764: __END__
1765:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>