Annotation of loncom/interface/lonmenu.pm, revision 1.394
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.394 ! raeburn 4: # $Id: lonmenu.pm,v 1.393 2012/11/27 23:45:08 raeburn Exp $
1.11 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 www 28: #
29:
1.244 jms 30: =head1 NAME
31:
32: Apache::lonmenu
33:
34: =head1 SYNOPSIS
35:
1.371 raeburn 36: Loads contents of /home/httpd/lonTabs/mydesk.tab,
37: used to generate inline menu, and Main Menu page.
1.244 jms 38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.314 droeschl 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
1.371 raeburn 76: of those lines of mydesk.tab that start with prim:.
1.314 droeschl 77: It is used by primary_menu() to generate the corresponding menu.
78: It gets filled in the BEGIN block of this module.
79:
1.371 raeburn 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:
1.314 droeschl 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:
1.244 jms 98: =head1 SUBROUTINES
99:
100: =over
101:
1.314 droeschl 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:
1.375 raeburn 118: =item create_submenu()
119:
120: Creates XHTML for unordered list of sub-menu items which belong to a
121: particular top-level menu item. Uses hover pseudo class in css to display
122: dropdown list when mouse hovers over top-level item. Support for IE6
123: (no hover psuedo class) via LC_hoverable class for <li> tag for top-
124: level item, which employs jQuery to handle behavior on mouseover.
125:
126: Inputs: 4 - (a) link and (b) target for anchor href in top level item,
127: (c) title for text wrapped by anchor tag in top level item.
128: (d) reference to array of arrays of sub-menu items.
129:
1.244 jms 130: =item innerregister()
131:
1.320 droeschl 132: This gets called in order to register a URL in the body of the document
1.244 jms 133:
134: =item clear()
135:
136: =item switch()
137:
138: Switch a button or create a link
139: Switch acts on the javascript that is executed when a button is clicked.
140: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
141:
142: =item secondlevel()
143:
144: =item openmenu()
145:
146: =item inlinemenu()
147:
148: =item rawconfig()
149:
150: =item utilityfunctions()
151:
1.371 raeburn 152: Output from this routine is a number of javascript functions called by
153: items in the inline menu, and in some cases items in the Main Menu page.
154:
1.244 jms 155: =item serverform()
156:
157: =item constspaceform()
158:
159: =item get_nav_status()
160:
161: =item hidden_button_check()
162:
163: =item roles_selector()
164:
165: =item jump_to_role()
166:
167: =back
168:
169: =cut
170:
1.1 www 171: package Apache::lonmenu;
172:
173: use strict;
1.152 albertel 174: use Apache::lonnet;
1.47 matthew 175: use Apache::lonhtmlcommon();
1.115 albertel 176: use Apache::loncommon();
1.127 albertel 177: use Apache::lonenc();
1.88 www 178: use Apache::lonlocal;
1.361 raeburn 179: use Apache::lonmsg();
1.207 foxr 180: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 181: use HTML::Entities();
1.346 wenzelju 182: use Apache::lonwishlist();
1.88 www 183:
1.283 droeschl 184: use vars qw(@desklines %category_names %category_members %category_positions
1.371 raeburn 185: $readdesk @primary_menu %primary_submenu @secondary_menu);
1.88 www 186:
1.56 www 187: my @inlineremote;
1.38 www 188:
1.283 droeschl 189: sub prep_menuitem {
1.291 raeburn 190: my ($menuitem) = @_;
191: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 192: my $link;
193: if ($$menuitem[1]) { # graphical Link
194: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 195: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
196: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 197: } else { # textual Link
1.291 raeburn 198: $link = &mt($$menuitem[3]);
199: }
1.316 droeschl 200: return '<li><a'
201: # highlighting for new messages
202: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
1.325 droeschl 203: . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
1.283 droeschl 204: }
205:
206: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
207: # that contains following links:
1.371 raeburn 208: # About, Message, Personal, Roles, Help, Logout
1.283 droeschl 209: # @primary_menu is filled within the BEGIN block of this module with
210: # entries from mydesk.tab
211: sub primary_menu {
212: my $menu;
213: # each element of @primary contains following array:
214: # (link url, icon path, alt text, link text, condition)
1.319 raeburn 215: my $public;
216: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
217: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
218: $public = 1;
219: }
1.283 droeschl 220: foreach my $menuitem (@primary_menu) {
221: # evaluate conditions
1.296 droeschl 222: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 223: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 224: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 225: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 226: && !&Apache::lonmsg::mynewmail(); #
1.319 raeburn 227: next if $$menuitem[4] !~ /public/ ##we've a public user,
228: && $public; ##who should not see all
229: ##links
1.283 droeschl 230: next if $$menuitem[4] eq 'onlypublic'# hide links which are
1.319 raeburn 231: && !$public; # only visible to public
232: # users
1.283 droeschl 233: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 234: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 235: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 236: && !&Apache::loncommon::show_course(); ##
237:
1.371 raeburn 238: my $title = $menuitem->[3];
239: if (defined($primary_submenu{$title})) {
1.375 raeburn 240: my ($link,$target);
1.371 raeburn 241: if ($menuitem->[0] ne '') {
242: $link = $menuitem->[0];
243: $target = '_top';
244: } else {
245: $link = '#';
246: }
1.375 raeburn 247: my @primsub;
1.371 raeburn 248: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.375 raeburn 249: foreach my $item (@{$primary_submenu{$title}}) {
1.383 raeburn 250: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.375 raeburn 251: next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
252: next if ((($item->[2] eq 'portfolio') ||
253: ($item->[2] eq 'blog')) &&
254: (!&Apache::lonnet::usertools_access('','',$item->[2],
255: undef,'tools')));
256: push(@primsub,$item);
257: }
258: if (@primsub > 0) {
259: $menu .= &create_submenu($link,$target,$title,\@primsub);
260: } elsif ($link) {
1.377 raeburn 261: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.371 raeburn 262: }
263: }
264: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.340 raeburn 265: if ($public) {
266: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
267: my $defdom = &Apache::lonnet::default_login_domain();
268: my $to = &Apache::loncommon::build_recipient_list(undef,
269: 'helpdeskmail',
270: $defdom,$origmail);
271: if ($to ne '') {
272: $menu .= &prep_menuitem($menuitem);
273: }
274: } else {
275: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
276: }
1.283 droeschl 277: } else {
1.325 droeschl 278: $menu .= prep_menuitem($menuitem);
1.283 droeschl 279: }
1.291 raeburn 280: }
1.325 droeschl 281: $menu =~ s/\[domain\]/$env{'user.domain'}/g;
282: $menu =~ s/\[user\]/$env{'user.name'}/g;
1.283 droeschl 283:
1.291 raeburn 284: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 285: }
286:
1.329 droeschl 287: #returns hashref {user=>'',dom=>''} containing:
288: # own name, domain if user is au
289: # name, domain of parent author if user is ca or aa
290: #empty return if user is not an author or not on homeserver
291: #
292: #TODO this should probably be moved somewhere more central
293: #since it can be used by different parts of the system
294: sub getauthor{
295: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
296:
297: #co- or assistent author?
298: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
299: ? ($1, $2) #domain, username of the parent author
300: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
301:
302: # current server == home server?
303: my $home = &Apache::lonnet::homeserver($user,$dom);
304: foreach (&Apache::lonnet::current_machine_ids()){
305: return {user => $user, dom => $dom} if $_ eq $home;
306: }
307:
308: # if wrong server
309: return;
310: }
1.283 droeschl 311:
312: sub secondary_menu {
313: my $menu;
314:
1.286 raeburn 315: my $crstype = &Apache::loncommon::course_type();
1.327 droeschl 316: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
317: ? "/$env{'request.course.sec'}"
318: : '');
319: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
1.376 raeburn 320: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
1.327 droeschl 321: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
322: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
323: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
1.341 www 324: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
1.343 www 325: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
326: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
327: my $author = &getauthor();
1.327 droeschl 328:
1.286 raeburn 329: my %groups = &Apache::lonnet::get_active_groups(
330: $env{'user.domain'}, $env{'user.name'},
331: $env{'course.' . $env{'request.course.id'} . '.domain'},
332: $env{'course.' . $env{'request.course.id'} . '.num'});
1.327 droeschl 333:
1.283 droeschl 334: foreach my $menuitem (@secondary_menu) {
335: # evaluate conditions
1.296 droeschl 336: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 337: next if $$menuitem[4] ne 'always'
1.329 droeschl 338: && $$menuitem[4] ne 'author'
1.283 droeschl 339: && !$env{'request.course.id'};
340: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 341: && !$canedit;
1.341 www 342: next if $$menuitem[4] eq 'nvgr'
343: && $canvgr;
344: next if $$menuitem[4] eq 'vgr'
345: && !$canvgr;
1.327 droeschl 346: next if $$menuitem[4] eq 'cst'
347: && !$canmodifyuser;
1.343 www 348: next if $$menuitem[4] eq 'ncst'
1.376 raeburn 349: && ($canmodifyuser || !$canviewroster);
1.343 www 350: next if $$menuitem[4] eq 'mgr'
351: && !$canmgr;
352: next if $$menuitem[4] eq 'nmgr'
353: && $canmgr;
1.327 droeschl 354: next if $$menuitem[4] eq 'whn'
355: && !$canviewwnew;
356: next if $$menuitem[4] eq 'opa'
357: && !$canmodpara;
1.283 droeschl 358: next if $$menuitem[4] =~ /showgroups$/
1.300 raeburn 359: && !$canviewgrps
1.286 raeburn 360: && !%groups;
1.329 droeschl 361: next if $$menuitem[4] eq 'author'
362: && !$author;
1.283 droeschl 363:
1.286 raeburn 364: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 365: # special treatment for role selector
1.298 raeburn 366: my $roles_selector = &roles_selector(
1.283 droeschl 367: $env{'course.' . $env{'request.course.id'} . '.domain'},
368: $env{'course.' . $env{'request.course.id'} . '.num'} );
369:
370: $menu .= $roles_selector ? "<li>$roles_selector</li>"
371: : '';
1.296 droeschl 372: } else {
373: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 374: }
375: }
376: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 377: my $escurl = &escape( &Apache::lonenc::check_encrypt(
378: $env{'request.noversionuri'}));
1.283 droeschl 379:
1.291 raeburn 380: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
381: $env{'request.symb'}));
1.283 droeschl 382:
383: if ( $env{'request.state'} eq 'construct'
384: and ( $env{'request.noversionuri'} eq ''
385: || !defined($env{'request.noversionuri'})))
386: {
1.359 raeburn 387: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
388: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 389: $escurl = &escape($escurl);
1.283 droeschl 390: }
391: $menu =~ s/\[url\]/$escurl/g;
392: $menu =~ s/\[symb\]/$escsymb/g;
393: }
1.329 droeschl 394: $menu =~ s/\[uname\]/$$author{user}/g;
395: $menu =~ s/\[udom\]/$$author{dom}/g;
1.385 raeburn 396: if ($menu) {
397: $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
398: }
399: return $menu;
1.283 droeschl 400: }
401:
1.375 raeburn 402: sub create_submenu {
403: my ($link,$target,$title,$submenu) = @_;
404: return unless (ref($submenu) eq 'ARRAY');
1.379 raeburn 405: my $disptarget;
406: if ($target ne '') {
407: $disptarget = ' target="'.$target.'"';
408: }
1.375 raeburn 409: my $menu = '<li class="LC_hoverable">'.
1.379 raeburn 410: '<a href="'.$link.'"'.$disptarget.'>'.
1.377 raeburn 411: '<span class="LC_nobreak">'.&mt($title).
1.375 raeburn 412: '<span class="LC_fontsize_small" style="font-weight:normal;">'.
413: ' ▼</span></span></a>'.
414: '<ul>';
415: my $count = 0;
416: my $numsub = scalar(@{$submenu});
417: foreach my $item (@{$submenu}) {
418: $count ++;
419: if (ref($item) eq 'ARRAY') {
420: my $borderbot;
421: if ($count == $numsub) {
422: $borderbot = 'border-bottom:1px solid black;';
423: }
424: $menu .= '<li style="margin:0;padding:0;'.
425: $borderbot.'"><a href="'.$item->[0].'">'.
1.377 raeburn 426: &mt($item->[1]).'</a></li>';
1.375 raeburn 427: }
428: }
429: $menu .= '</ul></li>';
430: return $menu;
431: }
432:
1.40 www 433: sub innerregister {
1.390 raeburn 434: my ($forcereg,$bread_crumbs,$group) = @_;
1.152 albertel 435: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 436: my $is_const_dir = 0;
1.120 raeburn 437:
1.175 albertel 438: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 439:
1.174 albertel 440: $env{'request.registered'} = 1;
1.40 www 441:
1.177 albertel 442: undef(@inlineremote);
1.56 www 443:
1.393 raeburn 444: my ($mapurl,$resurl);
1.390 raeburn 445:
1.393 raeburn 446: if ($env{'request.course.id'}) {
447: if ($env{'request.symb'}) {
448: ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
449: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
1.267 droeschl 450:
1.393 raeburn 451: my $maptitle = &Apache::lonnet::gettitle($mapurl);
452: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.318 droeschl 453:
454: #SD
455: #course_type only Course and Community?
456: #
1.393 raeburn 457: my @crumbs;
458: unless (($forcereg) &&
459: ($env{'request.noversionuri'} eq '/adm/navmaps') &&
460: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
461: @crumbs = ({text => Apache::loncommon::course_type()
462: . ' Contents',
463: href => "Javascript:gopost('/adm/navmaps','')"});
464: }
465: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
466: push(@crumbs, {text => '...',
467: no_mt => 1});
468: }
469:
470: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
471: && $maptitle ne 'default.sequence'
472: && $maptitle ne $coursetitle);
1.268 droeschl 473:
1.393 raeburn 474: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
475: &Apache::lonhtmlcommon::clear_breadcrumbs();
476: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
477: } else {
478: $resurl = $env{'request.noversionuri'};
479: my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
480: my $crstype = &Apache::loncommon::course_type();
481: my $title = &mt('View Resource');
482: if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
483: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
1.392 raeburn 484: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.393 raeburn 485: if ($env{'form.title'}) {
486: $title = $env{'form.title'};
487: }
1.394 ! raeburn 488: my $trail;
1.393 raeburn 489: if ($env{'form.folderpath'}) {
490: my $editbutton =
491: &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
1.394 ! raeburn 492: ($trail) =
1.393 raeburn 493: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
494: } else {
495: &Apache::lonhtmlcommon::add_breadcrumb(
1.392 raeburn 496: {text => "Supplemental $crstype Content",
497: href => "javascript:gopost('/adm/supplemental','')"});
1.393 raeburn 498: $title = &mt('View Resource');
1.394 ! raeburn 499: ($trail) =
! 500: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
1.392 raeburn 501: }
1.394 ! raeburn 502: return $trail;
1.392 raeburn 503: }
504: &Apache::lonhtmlcommon::clear_breadcrumbs();
505: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
506: }
1.390 raeburn 507: } elsif (! $const_space){
1.328 droeschl 508: #a situation when we're looking at a resource outside of context of a
509: #course or construction space (e.g. with cumulative rights)
510: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.390 raeburn 511: unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
512: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
513: }
1.65 www 514: }
1.41 www 515: # =============================================================================
516: # ============================ This is for URLs that actually can be registered
1.316 droeschl 517: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
518: || $forcereg );
1.390 raeburn 519: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
520: $forceview,$editbutton);
1.391 raeburn 521: if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
522: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1.390 raeburn 523: $editbutton = &prepare_functions($resurl,$forcereg,$group);
524: }
525: if ($editbutton eq '') {
526: &clear(6,1);
527: }
1.317 droeschl 528:
1.390 raeburn 529: #
530: # This applies in course context
531: #
532: if ($env{'request.course.id'}) {
533: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
534: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
535: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
536: my @privs;
537: if ($env{'request.symb'} ne '') {
538: if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
539: push(@privs,('mgr','vgr'));
540: }
541: push(@privs,'opa');
542: }
543: foreach my $priv (@privs) {
544: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
545: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
546: $perms{$priv} =
547: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
548: }
549: }
550: #
551: # Determine whether or not to show Grades and Submissions buttons
552: #
553: if ($env{'request.symb'} ne '' &&
554: $env{'request.filename'}=~/$LONCAPA::assess_re/) {
555: if ($perms{'mgr'}) {
556: &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
557: "gocmd('/adm/grades','gradingmenu')",
558: 'Content Grades');
559: } elsif ($perms{'vgr'}) {
560: &switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
561: "gocmd('/adm/grades','submission')",
562: 'Content Submissions');
563: }
564: }
565: if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
566: &switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
567: "gocmd('/adm/parmset','set')",
568: 'Content Settings');
1.107 albertel 569: }
1.393 raeburn 570: # End grades/submissions check
1.107 albertel 571:
1.274 www 572: #
1.393 raeburn 573: # This applies to items inside a folder/page modifiable in the course.
1.274 www 574: #
1.390 raeburn 575: if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
1.393 raeburn 576: my $text = 'Edit Folder';
577: if ($mapurl =~ /\.page$/) {
578: $text = 'Edit Page';
579: }
580: &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
1.390 raeburn 581: "gocmd('/adm/coursedocs','direct')",
582: 'Folder/Page Content');
1.258 raeburn 583: }
1.390 raeburn 584: # End modifiable folder/page container check
585: }
586: # End course context
587:
1.41 www 588: # Prepare the rest of the buttons
1.383 raeburn 589: my ($menuitems,$got_prt,$got_wishlist);
1.120 raeburn 590: if ($const_space) {
1.274 www 591: #
592: # We are in construction space
593: #
1.353 www 594:
1.355 raeburn 595: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 596: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 597: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.353 www 598: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 599: if ($currdir =~ m-/$-) {
600: $is_const_dir = 1;
601: } else {
1.267 droeschl 602: $currdir =~ s|[^/]+$||;
1.200 foxr 603: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 604: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 605: #
606: # Probably should be in mydesk.tab
607: #
1.131 raeburn 608: $menuitems=(<<ENDMENUITEMS);
1.344 www 609: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1.353 www 610: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
611: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
612: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
613: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 614: ENDMENUITEMS
1.131 raeburn 615: }
1.308 raeburn 616: if (ref($bread_crumbs) eq 'ARRAY') {
617: &Apache::lonhtmlcommon::clear_breadcrumbs();
618: foreach my $crumb (@{$bread_crumbs}){
619: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
620: }
621: }
1.203 foxr 622: } elsif ( defined($env{'request.course.id'}) &&
623: $env{'request.symb'} ne '' ) {
1.274 www 624: #
1.383 raeburn 625: # We are in a course and looking at a registered URL
1.274 www 626: # Should probably be in mydesk.tab
627: #
1.120 raeburn 628: $menuitems=(<<ENDMENUITEMS);
1.41 www 629: c&3&1
1.344 www 630: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
631: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
1.77 www 632: c&6&3
633: c&8&1
634: c&8&2
1.344 www 635: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 636: ENDMENUITEMS
1.383 raeburn 637: $got_prt = 1;
638: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
639: && (!$env{'request.enc'})) {
1.332 wenzelju 640: # wishlist is only available for users with access to resource-pool
641: # and links can only be set for resources within the resource-pool
642: $menuitems .= (<<ENDMENUITEMS);
1.370 raeburn 643: 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
1.332 wenzelju 644: ENDMENUITEMS
1.383 raeburn 645: $got_wishlist = 1;
1.332 wenzelju 646: }
1.216 albertel 647:
1.243 tempelho 648: my $currentURL = &Apache::loncommon::get_symb();
649: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
650: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
651: $menuitems.="s&9&3&";
652: if(length($annotation) > 0){
1.317 droeschl 653: $menuitems.="anot2.png";
1.243 tempelho 654: }else{
1.317 droeschl 655: $menuitems.="anot.png";
1.243 tempelho 656: }
1.344 www 657: $menuitems.="&Notes&&annotate()&";
1.243 tempelho 658: $menuitems.="Make notes and annotations about this resource&&1\n";
659:
1.323 raeburn 660: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.382 raeburn 661: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
1.216 albertel 662: $menuitems.=(<<ENDREALRES);
1.344 www 663: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
1.216 albertel 664: ENDREALRES
665: }
1.382 raeburn 666: unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
667: $menuitems.=(<<ENDREALRES);
1.344 www 668: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.382 raeburn 669: ENDREALRES
670: }
671: $menuitems.=(<<ENDREALRES);
1.344 www 672: 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
1.77 www 673: ENDREALRES
1.120 raeburn 674: }
675: }
1.203 foxr 676: if ($env{'request.uri'} =~ /^\/res/) {
1.383 raeburn 677: unless ($got_prt) {
678: $menuitems .= (<<ENDMENUITEMS);
1.344 www 679: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 680: ENDMENUITEMS
1.384 raeburn 681: $got_prt = 1;
1.383 raeburn 682: }
683: unless ($got_wishlist) {
684: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
685: # wishlist is only available for users with access to resource-pool
686: $menuitems .= (<<ENDMENUITEMS);
1.374 bisitz 687: 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
1.332 wenzelju 688: ENDMENUITEMS
1.383 raeburn 689: $got_wishlist = 1;
690: }
691: }
692: }
1.41 www 693: my $buttons='';
694: foreach (split(/\n/,$menuitems)) {
695: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 696: my $idx=10*$rest[0]+$rest[1];
697: if (&hidden_button_check() eq 'yes') {
698: if ($idx == 21 ||$idx == 23) {
699: $buttons.=&switch('','',@rest);
700: } else {
701: $buttons.=&clear(@rest);
702: }
703: } else {
704: if ($command eq 's') {
705: $buttons.=&switch('','',@rest);
706: } else {
707: $buttons.=&clear(@rest);
708: }
1.41 www 709: }
710: }
1.148 albertel 711:
712: my $addremote=0;
1.267 droeschl 713: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.301 droeschl 714: if ($addremote) {
715:
1.342 www 716: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 717:
1.342 www 718: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.312 droeschl 719: 'navigation', @inlineremote[21,23]);
720:
1.378 raeburn 721: my $countdown = &countdown_timer();
722: if (&hidden_button_check() eq 'yes') {
723: if ($countdown) {
724: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
725: }
726: } else {
727: my @tools = @inlineremote[93,91,81,82,83];
728: if ($countdown) {
729: unshift(@tools,$countdown);
730: }
1.342 www 731: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.378 raeburn 732: 'tools',@tools);
1.313 droeschl 733:
734: #publish button in construction space
735: if ($env{'request.state'} eq 'construct'){
1.342 www 736: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 737: 'advtools', $inlineremote[63]);
1.342 www 738: } else {
739: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 740: 'tools', $inlineremote[63]);
1.313 droeschl 741: }
1.390 raeburn 742: &advtools_crumbs(@inlineremote);
1.301 droeschl 743: }
1.38 www 744: }
745:
1.342 www 746: return &Apache::lonhtmlcommon::scripttag('', 'start')
747: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
748: . &Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 749: }
750:
1.389 raeburn 751: sub get_editbutton {
1.390 raeburn 752: my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
753: my $jscall =
754: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
1.393 raeburn 755: $forceedit,$forcereg,$env{'request.symb'},
756: &escape($env{'form.folderpath'}),
757: &escape($env{'form.title'}),$env{'form.idx'},
758: &escape($env{'form.suppurl'}));
1.389 raeburn 759: if ($jscall) {
1.390 raeburn 760: my $icon = 'pcstr.png';
761: my $label = 'Edit';
762: if ($forceview) {
763: $icon = 'tolastloc.png';
764: $label = 'Exit Editing';
765: }
766: &switch('','',6,1,$icon,$label,'resource[_2]',
767: $jscall,"Edit this resource");
768: return 1;
769: }
770: return;
771: }
772:
773: sub prepare_functions {
1.393 raeburn 774: my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
1.390 raeburn 775: unless ($env{'request.registered'}) {
776: undef(@inlineremote);
777: }
778: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
779: $forceview);
780:
781: if ($env{'request.course.id'}) {
782: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
783: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
784: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
785: }
786:
787: my $editbutton = '';
788: #
789: # Determine whether or not to display 'Edit' icon/button
790: #
791: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
792: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.391 raeburn 793: ($cfile,$home,$switchserver,$forceedit,$forceview) =
794: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
795: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
796: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
797: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.390 raeburn 798: $forceedit,$forceview,$forcereg);
799: }
1.391 raeburn 800: } elsif ((!$env{'request.course.id'}) &&
1.390 raeburn 801: ($env{'user.author'}) && ($env{'request.filename'}) &&
802: ($env{'request.role'} !~/^(aa|ca|au)/)) {
803: #
804: # Currently do not have the role of author or co-author.
805: # Do we have authoring privileges for the resource?
806: #
807: my $file=&Apache::lonnet::declutter($env{'request.filename'});
808: ($cfile,$home,$switchserver,$forceedit,$forceview) =
809: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
810: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
811: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
812: $editbutton = &get_editbutton($cfile,$home,$switchserver,
813: $forceedit,$forceview,$forcereg);
814: }
815: } elsif ($env{'request.course.id'}) {
816: #
817: # This applies in course context
818: #
819: if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) {
820: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
821: &switch('','',6,1,'pcstr.png','Edit',
822: 'resource[_2]',
823: "go('/adm/courseprefs?phase=display&actions=courseinfo')",
824: 'Edit this resource');
825: $editbutton = 1;
826: } else {
827: $cfile = $resurl;
828: $home = &Apache::lonnet::homeserver($cnum,$cdom);
829: if ($env{'form.forceedit'}) {
830: $forceview = 1;
831: } else {
832: $forceedit = 1;
833: }
834: $editbutton = &get_editbutton($cfile,$home,$switchserver,
835: $forceedit,$forceview,$forcereg);
836: }
1.393 raeburn 837: } elsif (($resurl eq '/adm/extresedit') &&
838: (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
839: ($cfile,$home,$switchserver,$forceedit,$forceview) =
840: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
841: $env{'form.symb'});
842: if ($cfile ne '') {
843: $editbutton = &get_editbutton($cfile,$home,$switchserver,
844: $forceedit,$forceview,$forcereg,
845: $env{'form.title'},$env{'form.suppurl'});
846: }
1.390 raeburn 847: } elsif ($resurl !~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
848: if ($env{'request.filename'}) {
849: my $file=&Apache::lonnet::declutter($env{'request.filename'});
850: ($cfile,$home,$switchserver,$forceedit,$forceview) =
851: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
852: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
853: if ($cfile ne '') {
854: $editbutton = &get_editbutton($cfile,$home,$switchserver,
855: $forceedit,$forceview,$forcereg);
856: }
857: }
858: }
859: }
860: # End determination of 'Edit' icon/button display
861:
1.393 raeburn 862: if ($env{'request.course.id'}) {
1.390 raeburn 863: # This applies to about me page for users in a course
1.391 raeburn 864: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.390 raeburn 865: my ($sdom,$sname) = ($1,$2);
866: unless (&Apache::lonnet::is_course($sdom,$sname)) {
867: &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
868: '',
869: "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
870: 'Send message to specific user');
871: }
1.391 raeburn 872: my $hideprivileged = 1;
873: if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
874: $hideprivileged)) {
1.390 raeburn 875: foreach my $priv ('vsa','vgr','srm') {
876: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
877: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
878: $perms{$priv} =
879: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
880: }
881: }
882: if ($perms{'vsa'}) {
883: &switch('','',6,5,'trck-22x22.png','Activity',
884: '',
885: "go('/adm/trackstudent?selected_student=$sname:$sdom')",
886: 'View recent activity by this person');
887: }
888: if ($perms{'vgr'}) {
889: &switch('','',6,6,'rsrv-22x22.png','Reservations',
890: '',
891: "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
892: 'Slot reservation history');
893: }
894: if ($perms{'srm'}) {
895: &switch('','',6,7,'contact-new-22x22.png','Records',
896: '',
897: "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
898: 'Add records');
899: }
900: }
1.393 raeburn 901: } elsif ($resurl =~ m{^/?adm/viewclasslist}) {
902: # This applies to viewclasslist page for users in a course
903: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
904: &switch('','',6,4,'pparm.png','Settings',
905: '',
906: "go('/adm/courseprefs?actions=classlists&phase=display')",
907: 'Student-viewable classlist options');
908: }
909: }
910: if (($env{'form.folderpath'} =~ /^supplemental/) &&
911: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
912: (($resurl =~ m{^/adm/wrapper/ext/}) ||
913: ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
914: ($resurl eq '/adm/supplemental'))) {
915: my @folders=split('&',$env{'form.folderpath'});
1.394 ! raeburn 916: if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
1.393 raeburn 917: my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
918: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
919: "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
920: 'Folder/Page Content');
921: }
1.390 raeburn 922: }
923: }
924:
925: # End checking for items for about me page for users in a course
1.393 raeburn 926: if ($docscrumbs) {
927: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
928: &advtools_crumbs(@inlineremote);
929: return $editbutton;
930: } elsif ($env{'request.registered'}) {
1.390 raeburn 931: return $editbutton;
932: } else {
933: if (ref($bread_crumbs) eq 'ARRAY') {
934: if (@inlineremote > 0) {
935: if (ref($advtools) eq 'ARRAY') {
936: @{$advtools} = @inlineremote;
937: }
938: }
939: return;
940: } elsif (@inlineremote > 0) {
941: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
942: &advtools_crumbs(@inlineremote);
943: return &Apache::lonhtmlcommon::scripttag('', 'start')
944: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
945: . &Apache::lonhtmlcommon::scripttag('', 'end');
946: }
947: }
948: }
949:
950: sub advtools_crumbs {
951: my @funcs = @_;
952: if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
953: &Apache::lonhtmlcommon::add_breadcrumb_tool(
954: 'advtools', @funcs[61,64,65,66,67,74]);
955: } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
956: &Apache::lonhtmlcommon::add_breadcrumb_tool(
957: 'advtools', @funcs[61,71,72,73,74,92]);
1.393 raeburn 958: } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
959: &Apache::lonhtmlcommon::add_breadcrumb_tool(
960: 'advtools', @funcs[64]);
961: }
1.258 raeburn 962: }
963:
1.2 www 964: # ================================================================== Raw Config
965:
1.3 www 966: sub clear {
967: my ($row,$col)=@_;
1.316 droeschl 968: $inlineremote[10*$row+$col]='';
969: return '';
1.3 www 970: }
971:
1.40 www 972: # ============================================ Switch a button or create a link
1.25 matthew 973: # Switch acts on the javascript that is executed when a button is clicked.
974: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 975:
1.2 www 976: sub switch {
1.209 www 977: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 978: $act=~s/\$uname/$uname/g;
979: $act=~s/\$udom/$udom/g;
1.88 www 980: $top=&mt($top);
981: $bot=&mt($bot);
982: $desc=&mt($desc);
1.209 www 983: my $idx=10*$row+$col;
984: $category_members{$cat}.=':'.$idx;
985:
1.320 droeschl 986: # Inline Menu
1.317 droeschl 987: if ($nobreak==2) { return ''; }
988: my $text=$top.' '.$bot;
989: $text=~s/\s*\-\s*//gs;
1.105 www 990:
1.317 droeschl 991: my $pic=
1.225 albertel 992: '<img alt="'.$text.'" src="'.
993: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 994: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 995: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 996: # Main Menu
1.103 www 997: if ($nobreak==3) {
1.209 www 998: $inlineremote[$idx]="\n".
1.177 albertel 999: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1000: '</td><td align="left">'.
1.103 www 1001: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1002: } elsif ($nobreak) {
1.209 www 1003: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1004: '<td align="left">'.
1.177 albertel 1005: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1006: <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>';
1.103 www 1007: } else {
1.209 www 1008: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1009: '<td align="left">'.
1.103 www 1010: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1011: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1012: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1013: }
1.317 droeschl 1014: } else {
1.103 www 1015: # Inline Menu
1.378 raeburn 1016: my @tools = (93,91,81,82,83);
1017: unless ($env{'request.state'} eq 'construct') {
1018: push(@tools,63);
1019: }
1020: if (($env{'environment.icons'} eq 'iconsonly') &&
1021: (grep(/^$idx$/,@tools))) {
1022: $inlineremote[$idx] =
1023: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
1024: } else {
1025: $inlineremote[$idx] =
1.317 droeschl 1026: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.344 www 1027: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1.378 raeburn 1028: }
1.317 droeschl 1029: }
1.56 www 1030: return '';
1.2 www 1031: }
1032:
1033: sub secondlevel {
1034: my $output='';
1035: my
1.209 www 1036: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1037: if ($prt eq 'any') {
1.209 www 1038: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1039: } elsif ($prt=~/^r(\w+)/) {
1040: if ($rol eq $1) {
1.209 www 1041: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1042: }
1043: }
1044: return $output;
1045: }
1046:
1.56 www 1047: sub inlinemenu {
1.210 albertel 1048: undef(@inlineremote);
1049: undef(%category_members);
1.275 www 1050: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1051: &rawconfig(1);
1.309 bisitz 1052: my $output='<table><tr>';
1.209 www 1053: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1054: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1055: for (my $row=1; $row<=8; $row++) {
1056: foreach my $cat (keys(%category_members)) {
1057: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1058: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1059: $output.='<div class="LC_Box LC_400Box">';
1060: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1061: $output.='<table>';
1.240 riegler 1062: my %active=();
1063: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1064: if ($inlineremote[$menu_item]) {
1065: $active{$menu_item}=1;
1066: }
1067: }
1068: foreach my $item (sort(keys(%active))) {
1069: $output.=$inlineremote[$item];
1070: }
1071: $output.='</table>';
1.245 harmsja 1072: $output.='</div>';
1.240 riegler 1073: }
1074: }
1075: $output.="</td>";
1076: }
1077: $output.="</tr></table>";
1078: return $output;
1079: }
1080:
1.2 www 1081: sub rawconfig {
1.274 www 1082: #
1083: # This evaluates mydesk.tab
1084: # Need to add more positions and more privileges to deal with all
1085: # menu items.
1086: #
1.34 www 1087: my $textualoverride=shift;
1088: my $output='';
1.316 droeschl 1089: return '' unless $textualoverride;
1.152 albertel 1090: my $uname=$env{'user.name'};
1091: my $udom=$env{'user.domain'};
1092: my $adv=$env{'user.adv'};
1.266 raeburn 1093: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1094: my $author=$env{'user.author'};
1.5 www 1095: my $crs='';
1.295 raeburn 1096: my $crstype='';
1.152 albertel 1097: if ($env{'request.course.id'}) {
1098: $crs='/'.$env{'request.course.id'};
1099: if ($env{'request.course.sec'}) {
1100: $crs.='_'.$env{'request.course.sec'};
1.7 www 1101: }
1.8 www 1102: $crs=~s/\_/\//g;
1.295 raeburn 1103: $crstype = &Apache::loncommon::course_type();
1.5 www 1104: }
1.152 albertel 1105: my $pub=($env{'request.state'} eq 'published');
1106: my $con=($env{'request.state'} eq 'construct');
1107: my $rol=$env{'request.role'};
1108: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1109: foreach my $line (@desklines) {
1.209 www 1110: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1111: $prt=~s/\$uname/$uname/g;
1112: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1113: if ($prt =~ /\$crs/) {
1114: next unless ($env{'request.course.id'});
1115: next if ($crstype eq 'Community');
1116: $prt=~s/\$crs/$crs/g;
1117: } elsif ($prt =~ /\$cmty/) {
1118: next unless ($env{'request.course.id'});
1119: next if ($crstype ne 'Community');
1120: $prt=~s/\$cmty/$crs/g;
1121: }
1.25 matthew 1122: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1123: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1124: if ($pro eq 'clear') {
1.4 www 1125: $output.=&clear($row,$col);
1.3 www 1126: } elsif ($pro eq 'any') {
1.2 www 1127: $output.=&secondlevel(
1.209 www 1128: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1129: } elsif ($pro eq 'smp') {
1130: unless ($adv) {
1131: $output.=&secondlevel(
1.209 www 1132: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1133: }
1134: } elsif ($pro eq 'adv') {
1135: if ($adv) {
1136: $output.=&secondlevel(
1.209 www 1137: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1138: }
1.231 albertel 1139: } elsif ($pro eq 'shc') {
1140: if ($show_course) {
1141: $output.=&secondlevel(
1142: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1143: }
1144: } elsif ($pro eq 'nsc') {
1145: if (!$show_course) {
1146: $output.=&secondlevel(
1147: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1148: }
1.81 matthew 1149: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1150: my $priv = $1;
1151: if ($priv =~ /^mdc(Course|Community)/) {
1152: if ($crstype eq $1) {
1153: $priv = 'mdc';
1154: } else {
1155: next;
1156: }
1157: }
1158: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1159: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1160: }
1.295 raeburn 1161: } elsif ($pro eq 'course') {
1162: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1163: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1164: }
1.295 raeburn 1165: } elsif ($pro eq 'community') {
1166: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1167: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1168: }
1.124 matthew 1169: } elsif ($pro =~ /^courseenv_(.*)$/) {
1170: my $key = $1;
1.307 raeburn 1171: if ($crstype ne 'Community') {
1172: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1173: if ($key eq 'canuse_pdfforms') {
1174: if ($env{'request.course.id'} && $coursepref eq '') {
1175: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1176: $coursepref = $domdefs{'canuse_pdfforms'};
1177: }
1178: }
1179: if ($coursepref) {
1180: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1181: }
1.295 raeburn 1182: }
1183: } elsif ($pro =~ /^communityenv_(.*)$/) {
1184: my $key = $1;
1.307 raeburn 1185: if ($crstype eq 'Community') {
1186: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1187: if ($key eq 'canuse_pdfforms') {
1188: if ($env{'request.course.id'} && $coursepref eq '') {
1189: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1190: $coursepref = $domdefs{'canuse_pdfforms'};
1191: }
1192: }
1193: if ($coursepref) {
1194: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1195: }
1.124 matthew 1196: }
1.81 matthew 1197: } elsif ($pro =~ /^course_(.*)$/) {
1198: # Check for permissions inside of a course
1.295 raeburn 1199: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1200: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1201: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1202: )) {
1.209 www 1203: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1204: }
1.295 raeburn 1205: } elsif ($pro =~ /^community_(.*)$/) {
1206: # Check for permissions inside of a community
1207: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1208: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1209: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1210: )) {
1211: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1212: }
1.4 www 1213: } elsif ($pro eq 'author') {
1214: if ($author) {
1.152 albertel 1215: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1216: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1217: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1218: # Check that we are on the correct machine
1.29 matthew 1219: my $cadom=$requested_domain;
1.152 albertel 1220: my $caname=$env{'user.name'};
1.234 raeburn 1221: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1222: ($cadom,$caname)=
1.206 albertel 1223: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1224: }
1225: $act =~ s/\$caname/$caname/g;
1.353 www 1226: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 1227: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1228: my $allowed=0;
1229: my @ids=&Apache::lonnet::current_machine_ids();
1230: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1231: if ($allowed) {
1.209 www 1232: $output.=&switch($caname,$cadom,
1233: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1234: }
1.6 www 1235: }
1.2 www 1236: }
1.248 raeburn 1237: } elsif ($pro eq 'tools') {
1238: my @tools = ('aboutme','blog','portfolio');
1239: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1240: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1241: $env{'user.domain'},
1242: $prt,undef,'tools')) {
1243: $output.=&clear($row,$col);
1244: next;
1245: }
1.278 raeburn 1246: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1247: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1248: next;
1249: }
1250: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1251: next;
1252: }
1.279 raeburn 1253: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1254: if (!$showreqcrs) {
1.248 raeburn 1255: $output.=&clear($row,$col);
1256: next;
1257: }
1258: }
1259: $prt='any';
1260: $output.=&secondlevel(
1261: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1262: }
1.13 harris41 1263: }
1.2 www 1264: return $output;
1265: }
1266:
1.279 raeburn 1267: sub check_for_rcrs {
1268: my $showreqcrs = 0;
1.280 raeburn 1269: my @reqtypes = ('official','unofficial','community');
1270: foreach my $type (@reqtypes) {
1.279 raeburn 1271: if (&Apache::lonnet::usertools_access($env{'user.name'},
1272: $env{'user.domain'},
1273: $type,undef,'requestcourses')) {
1274: $showreqcrs = 1;
1275: last;
1276: }
1277: }
1.280 raeburn 1278: if (!$showreqcrs) {
1279: foreach my $type (@reqtypes) {
1280: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1281: $showreqcrs = 1;
1282: last;
1283: }
1284: }
1285: }
1.279 raeburn 1286: return $showreqcrs;
1287: }
1288:
1.306 raeburn 1289: sub dc_popup_js {
1290: my %lt = &Apache::lonlocal::texthash(
1291: more => '(More ...)',
1292: less => '(Less ...)',
1293: );
1294: return <<"END";
1295:
1296: function showCourseID() {
1297: document.getElementById('dccid').style.display='block';
1298: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1299: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 1300: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 1301: return;
1302: }
1303:
1304: function hideCourseID() {
1305: document.getElementById('dccid').style.display='none';
1.369 raeburn 1306: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 1307: return;
1308: }
1309:
1310: END
1311:
1312: }
1313:
1.378 raeburn 1314: sub countdown_toggle_js {
1315: return <<"END";
1316:
1317: function toggleCountdown() {
1318: var countdownid = document.getElementById('duedatecountdown');
1319: var currstyle = countdownid.style.display;
1320: if (currstyle == 'inline') {
1321: countdownid.style.display = 'none';
1322: document.getElementById('ddcountcollapse').innerHTML='';
1323: document.getElementById('ddcountexpand').innerHTML='◄ ';
1324: } else {
1325: countdownid.style.display = 'inline';
1326: document.getElementById('ddcountcollapse').innerHTML='► ';
1327: document.getElementById('ddcountexpand').innerHTML='';
1328: }
1329: return;
1330: }
1331:
1332: END
1333: }
1334:
1.42 www 1335: sub utilityfunctions {
1.152 albertel 1336: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 droeschl 1337: if ($currenturl =~ m{^/adm/wrapper/ext/}
1338: && $env{'request.external.querystring'} ) {
1.293 raeburn 1339: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1340: }
1.183 www 1341: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1342:
1.152 albertel 1343: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.175 albertel 1344:
1.306 raeburn 1345: my $dc_popup_cid;
1346: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1347: $env{'course.'.$env{'request.course.id'}.
1348: '.domain'}.'/'})) {
1349: $dc_popup_cid = &dc_popup_js();
1350: }
1351:
1.175 albertel 1352: my $start_page_annotate =
1353: &Apache::loncommon::start_page('Annotator',undef,
1354: {'only_body' => 1,
1355: 'js_ready' => 1,
1356: 'bgcolor' => '#BBBBBB',
1357: 'add_entries' => {
1358: 'onload' => 'javascript:document.goannotate.submit();'}});
1359:
1.205 albertel 1360: my $end_page_annotate =
1361: &Apache::loncommon::end_page({'js_ready' => 1});
1362:
1.389 raeburn 1363: my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
1.336 raeburn 1364:
1.368 www 1365: my $esc_url=&escape($currenturl);
1366: my $esc_symb=&escape($currentsymb);
1.332 wenzelju 1367:
1.378 raeburn 1368: my $countdown = &countdown_toggle_js();
1369:
1.42 www 1370: return (<<ENDUTILITY)
1371:
1.368 www 1372: var currentURL=unescape("$esc_url");
1373: var reloadURL=unescape("$esc_url");
1374: var currentSymb=unescape("$esc_symb");
1.42 www 1375:
1.306 raeburn 1376: $dc_popup_cid
1.114 albertel 1377:
1.389 raeburn 1378: $jumptores
1.336 raeburn 1379:
1.42 www 1380: function gopost(url,postdata) {
1381: if (url!='') {
1382: this.document.server.action=url;
1383: this.document.server.postdata.value=postdata;
1384: this.document.server.command.value='';
1385: this.document.server.url.value='';
1386: this.document.server.symb.value='';
1387: this.document.server.submit();
1388: }
1389: }
1390:
1391: function gocmd(url,cmd) {
1392: if (url!='') {
1393: this.document.server.action=url;
1394: this.document.server.postdata.value='';
1395: this.document.server.command.value=cmd;
1396: this.document.server.url.value=currentURL;
1397: this.document.server.symb.value=currentSymb;
1398: this.document.server.submit();
1399: }
1.57 www 1400: }
1401:
1.121 raeburn 1402: function gocstr(url,filename) {
1403: if (url == '/adm/cfile?action=delete') {
1404: this.document.cstrdelete.filename.value = filename
1405: this.document.cstrdelete.submit();
1406: return;
1407: }
1.137 raeburn 1408: if (url == '/adm/printout') {
1409: this.document.cstrprint.postdata.value = filename
1410: this.document.cstrprint.curseed.value = 0;
1411: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1412: if (this.document.lonhomework) {
1413: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1414: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1415: }
1416: if (this.document.lonhomework.problemtype) {
1.164 albertel 1417: if (this.document.lonhomework.problemtype.value) {
1418: this.document.cstrprint.problemtype.value =
1419: this.document.lonhomework.problemtype.value;
1420: } else if (this.document.lonhomework.problemtype.options) {
1421: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1422: if (this.document.lonhomework.problemtype.options[i].selected) {
1423: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1424: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1425: }
1426: }
1427: }
1428: }
1429: }
1430: }
1.137 raeburn 1431: this.document.cstrprint.submit();
1432: return;
1433: }
1.121 raeburn 1434: if (url !='') {
1435: this.document.constspace.filename.value = filename;
1436: this.document.constspace.action = url;
1437: this.document.constspace.submit();
1438: }
1439: }
1440:
1.131 raeburn 1441: function golist(url) {
1442: if (url!='' && url!= null) {
1443: currentURL = null;
1444: currentSymb= null;
1445: top.location.href=url;
1446: }
1447: }
1448:
1449:
1.121 raeburn 1450:
1.57 www 1451: function catalog_info() {
1.365 www 1452: openMyModal(window.location.pathname+'.meta',500,400,'yes');
1.57 www 1453: }
1454:
1455: function chat_win() {
1.290 raeburn 1456: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1457: }
1.169 raeburn 1458:
1459: function group_chat(group) {
1460: var url = '/adm/groupchat?group='+group;
1461: var winName = 'LONchat_'+group;
1462: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1463: }
1.175 albertel 1464:
1465: function annotate() {
1466: w_Annotator_flag=1;
1467: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1468: annotator.document.write(
1469: '$start_page_annotate'
1470: +"<form name='goannotate' target='Annotator' method='post' "
1471: +"action='/adm/annotations'>"
1.217 albertel 1472: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1473: +"<\\/form>"
1.205 albertel 1474: +'$end_page_annotate');
1.175 albertel 1475: annotator.document.close();
1476: }
1477:
1.370 raeburn 1478: function open_StoredLinks_Import(rat) {
1.335 wenzelju 1479: var newWin;
1480: if (rat) {
1481: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1.334 wenzelju 1482: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1.335 wenzelju 1483: }
1484: else {
1485: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
1486: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1487: }
1.334 wenzelju 1488: newWin.focus();
1489: }
1490:
1.372 raeburn 1491: (function (\$) {
1492: \$(document).ready(function () {
1493: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
1494: /*\@cc_on
1495: if (!window.XMLHttpRequest) {
1496: \$('.LC_hoverable').each(function () {
1497: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
1498: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
1499: });
1500: }
1501: \@*/
1502: });
1503: }(jQuery));
1504:
1.378 raeburn 1505: $countdown
1506:
1.42 www 1507: ENDUTILITY
1508: }
1509:
1510: sub serverform {
1511: return(<<ENDSERVERFORM);
1.181 albertel 1512: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1513: <input type="hidden" name="postdata" value="none" />
1514: <input type="hidden" name="command" value="none" />
1515: <input type="hidden" name="url" value="none" />
1516: <input type="hidden" name="symb" value="none" />
1517: </form>
1518: ENDSERVERFORM
1519: }
1.113 albertel 1520:
1.121 raeburn 1521: sub constspaceform {
1522: return(<<ENDCONSTSPACEFORM);
1.181 albertel 1523: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 1524: <input type="hidden" name="filename" value="" />
1525: </form>
1.181 albertel 1526: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 1527: <input type="hidden" name="action" value="delete" />
1528: <input type="hidden" name="filename" value="" />
1529: </form>
1.181 albertel 1530: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 1531: <input type="hidden" name="postdata" value="" />
1532: <input type="hidden" name="curseed" value="" />
1533: <input type="hidden" name="problemtype" value="" />
1534: </form>
1535:
1.121 raeburn 1536: ENDCONSTSPACEFORM
1537: }
1538:
1.220 raeburn 1539: sub hidden_button_check {
1.317 droeschl 1540: if ( $env{'request.course.id'} eq ''
1541: || $env{'request.role.adv'} ) {
1542:
1.220 raeburn 1543: return;
1544: }
1.232 raeburn 1545: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1546: return $buttonshide;
1.220 raeburn 1547: }
1.184 raeburn 1548:
1.235 raeburn 1549: sub roles_selector {
1550: my ($cdom,$cnum) = @_;
1.298 raeburn 1551: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 1552: my $now = time;
1.350 raeburn 1553: my (%courseroles,%seccount,%courseprivs);
1.235 raeburn 1554: my $is_cc;
1555: my $role_selector;
1.298 raeburn 1556: my $ccrole;
1557: if ($crstype eq 'Community') {
1558: $ccrole = 'co';
1559: } else {
1560: $ccrole = 'cc';
1.350 raeburn 1561: }
1.386 raeburn 1562: my ($priv,$gotsymb,$destsymb);
1.350 raeburn 1563: my $destinationurl = $ENV{'REQUEST_URI'};
1.386 raeburn 1564: if ($destinationurl =~ /\?symb=/) {
1565: $gotsymb = 1;
1566: } elsif ($destinationurl =~ m{^/enc/}) {
1567: my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
1568: if ($plainurl =~ /\?symb=/) {
1569: $gotsymb = 1;
1570: }
1571: }
1572: unless ($gotsymb) {
1573: $destsymb = &Apache::lonnet::symbread();
1574: if ($destsymb ne '') {
1575: $destsymb = &Apache::lonenc::check_encrypt($destsymb);
1576: }
1577: }
1.350 raeburn 1578: my $reqprivs = &required_privs();
1579: if (ref($reqprivs) eq 'HASH') {
1580: my $destination = $destinationurl;
1581: $destination =~ s/(\?.*)$//;
1582: if (exists($reqprivs->{$destination})) {
1583: $priv = $reqprivs->{$destination};
1584: }
1585: }
1.298 raeburn 1586: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1587: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 1588:
1589: if ((($start) && ($start<0)) ||
1590: (($end) && ($end<$now)) ||
1591: (($start) && ($now<$start))) {
1592: $is_cc = 0;
1593: } else {
1594: $is_cc = 1;
1595: }
1596: }
1597: if ($is_cc) {
1.350 raeburn 1598: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
1.235 raeburn 1599: } else {
1.262 raeburn 1600: my %gotnosection;
1.235 raeburn 1601: foreach my $item (keys(%env)) {
1.239 raeburn 1602: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 1603: my $role = $1;
1604: my $sec = $2;
1605: next if ($role eq 'gr');
1606: my ($start,$end) = split(/\./,$env{$item});
1607: next if (($start && $start > $now) || ($end && $end < $now));
1608: if ($sec eq '') {
1.239 raeburn 1609: if (!$gotnosection{$role}) {
1610: $seccount{$role} ++;
1611: $gotnosection{$role} = 1;
1612: }
1.235 raeburn 1613: }
1.350 raeburn 1614: if ($priv ne '') {
1615: my $cnumsec = $cnum;
1616: if ($sec ne '') {
1617: $cnumsec .= "/$sec";
1618: }
1619: $courseprivs{"$role./$cdom/$cnumsec./"} =
1620: $env{"user.priv.$role./$cdom/$cnumsec./"};
1621: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
1622: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
1623: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
1624: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
1625: }
1.235 raeburn 1626: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 1627: if ($sec ne '') {
1.264 raeburn 1628: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 1629: push(@{$courseroles{$role}},$sec);
1630: $seccount{$role} ++;
1631: }
1632: }
1633: } else {
1634: @{$courseroles{$role}} = ();
1635: if ($sec ne '') {
1636: $seccount{$role} ++;
1.235 raeburn 1637: push(@{$courseroles{$role}},$sec);
1638: }
1639: }
1640: }
1641: }
1642: }
1.286 raeburn 1643: my $switchtext;
1644: if ($crstype eq 'Community') {
1645: $switchtext = &mt('Switch community role to...')
1646: } else {
1647: $switchtext = &mt('Switch course role to...')
1648: }
1.298 raeburn 1649: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235 raeburn 1650: if (keys(%courseroles) > 1) {
1.350 raeburn 1651: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
1.235 raeburn 1652: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1653: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286 raeburn 1654: $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235 raeburn 1655: foreach my $role (@roles_order) {
1656: if (defined($courseroles{$role})) {
1.298 raeburn 1657: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1.235 raeburn 1658: }
1659: }
1660: foreach my $role (sort(keys(%courseroles))) {
1661: if ($role =~ /^cr/) {
1662: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1663: }
1664: }
1.386 raeburn 1665: $role_selector .= '</select>'."\n";
1666: if ($destsymb ne '') {
1667: $role_selector .= '<input type="hidden" name="destsymb" value="'.
1668: &HTML::Entities::encode($destsymb).'" />'."\n";
1669: }
1670: $role_selector .=
1.235 raeburn 1671: '<input type="hidden" name="destinationurl" value="'.
1.350 raeburn 1672: &HTML::Entities::encode($destinationurl).'" />'."\n".
1.235 raeburn 1673: '<input type="hidden" name="gotorole" value="1" />'."\n".
1674: '<input type="hidden" name="selectrole" value="" />'."\n".
1675: '<input type="hidden" name="switch" value="1" />'."\n".
1676: '</form>';
1677: }
1678: return $role_selector;
1679: }
1680:
1.262 raeburn 1681: sub get_all_courseroles {
1.350 raeburn 1682: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 1683: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 1684: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 1685: return;
1686: }
1687: my ($result,$cached) =
1688: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1689: if (defined($cached)) {
1690: if (ref($result) eq 'HASH') {
1691: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 1692: (ref($result->{'seccount'}) eq 'HASH') &&
1693: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 1694: %{$courseroles} = %{$result->{'roles'}};
1695: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 1696: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 1697: return;
1698: }
1699: }
1700: }
1701: my %gotnosection;
1702: my %adv_roles =
1703: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1704: foreach my $role (keys(%adv_roles)) {
1705: my ($urole,$usec) = split(/:/,$role);
1706: if (!$gotnosection{$urole}) {
1707: $seccount->{$urole} ++;
1708: $gotnosection{$urole} = 1;
1709: }
1710: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1711: if ($usec ne '') {
1712: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1713: push(@{$courseroles->{$urole}},$usec);
1714: $seccount->{$urole} ++;
1715: }
1716: }
1717: } else {
1718: @{$courseroles->{$urole}} = ();
1719: if ($usec ne '') {
1720: $seccount->{$urole} ++;
1721: push(@{$courseroles->{$urole}},$usec);
1722: }
1723: }
1.350 raeburn 1724: my $area = '/'.$cdom.'/'.$cnum;
1725: if ($usec ne '') {
1726: $area .= '/'.$usec;
1727: }
1728: if ($role =~ /^cr\//) {
1729: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
1730: } else {
1731: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
1732: }
1.262 raeburn 1733: }
1734: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1735: @{$courseroles->{'st'}} = ();
1.350 raeburn 1736: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 1737: if (keys(%sections_count) > 0) {
1738: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 1739: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 1740: }
1741: my $rolehash = {
1742: 'roles' => $courseroles,
1743: 'seccount' => $seccount,
1.350 raeburn 1744: 'privs' => $courseprivs,
1.262 raeburn 1745: };
1746: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1747: return;
1748: }
1749:
1.235 raeburn 1750: sub jump_to_role {
1.350 raeburn 1751: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
1.239 raeburn 1752: my %lt = &Apache::lonlocal::texthash(
1753: this => 'This role has section(s) associated with it.',
1754: ente => 'Enter a specific section.',
1755: orlb => 'Enter a specific section, or leave blank for no section.',
1756: avai => 'Available sections are:',
1757: youe => 'You entered an invalid section choice:',
1.352 raeburn 1758: plst => 'Please try again.',
1.350 raeburn 1759: role => 'The role you selected is not permitted to view the current page.',
1760: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 1761: );
1762: my $js;
1763: if (ref($courseroles) eq 'HASH') {
1764: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1765: ' var numsec = new Array();'."\n".
1766: ' var rolesections = new Array();'."\n".
1767: ' var rolenames = new Array();'."\n".
1768: ' var roleseclist = new Array();'."\n";
1769: my @items = keys(%{$courseroles});
1770: for (my $i=0; $i<@items; $i++) {
1771: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1772: my ($secs,$secstr);
1773: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1774: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1775: $secs = join('","',@sections);
1776: $secstr = join(', ',@sections);
1777: }
1778: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1779: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1780: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1781: }
1782: }
1.350 raeburn 1783: my $checkroles = 0;
1784: if ($priv && ref($courseprivs) eq 'HASH') {
1785: my (%disallowed,%allowed,@disallow);
1786: foreach my $role (sort(keys(%{$courseprivs}))) {
1787: my $trole;
1788: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
1789: $trole = $1;
1790: }
1791: if (($trole ne '') && ($trole ne 'cm')) {
1792: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
1793: $allowed{$trole} = 1;
1794: } else {
1795: $disallowed{$trole} = 1;
1796: }
1797: }
1798: }
1799: foreach my $trole (keys(%disallowed)) {
1800: unless ($allowed{$trole}) {
1801: push(@disallow,$trole);
1802: }
1803: }
1804: if (@disallow > 0) {
1805: $checkroles = 1;
1806: $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
1807: " var rolecheck = 1;\n";
1808: }
1809: }
1810: if (!$checkroles) {
1811: $js .= " var disallow = new Array();\n".
1812: " rolecheck = 0;\n";
1813: }
1.273 droeschl 1814: return <<"END";
1.235 raeburn 1815: <script type="text/javascript">
1.273 droeschl 1816: //<![CDATA[
1.235 raeburn 1817: function adhocRole(roleitem) {
1.239 raeburn 1818: $js
1.235 raeburn 1819: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1820: if (newrole == '') {
1.350 raeburn 1821: return;
1.235 raeburn 1822: }
1.239 raeburn 1823: var fullrole = newrole+'./$cdom/$cnum';
1824: var selidx = '';
1825: for (var i=0; i<rolenames.length; i++) {
1826: if (rolenames[i] == newrole) {
1827: selidx = i;
1828: }
1829: }
1.350 raeburn 1830: if (rolecheck > 0) {
1831: for (var i=0; i<disallow.length; i++) {
1832: if (disallow[i] == newrole) {
1833: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
1834: document.rolechooser.destinationurl.value = '/adm/menu';
1835: } else {
1836: document.rolechooser.elements[roleitem].selectedIndex = 0;
1837: return;
1838: }
1839: }
1840: }
1841: }
1.239 raeburn 1842: var secok = 1;
1843: var secchoice = '';
1844: if (selidx >= 0) {
1845: if (numsec[selidx] > 1) {
1846: secok = 0;
1847: var numrolesec = rolesections[selidx].length;
1848: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 1849: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 1850: if (secchoice == '') {
1851: if (msgidx > 0) {
1852: secok = 1;
1853: }
1854: } else {
1855: for (var j=0; j<rolesections[selidx].length; j++) {
1856: if (rolesections[selidx][j] == secchoice) {
1857: secok = 1;
1858: }
1859: }
1860: }
1861: } else {
1862: if (rolesections[selidx].length == 1) {
1863: secchoice = rolesections[selidx][0];
1864: }
1865: }
1866: }
1867: if (secok == 1) {
1868: if (secchoice != '') {
1869: fullrole += '/'+secchoice;
1870: }
1871: } else {
1872: document.rolechooser.elements[roleitem].selectedIndex = 0;
1873: if (secchoice != null) {
1874: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1875: }
1876: return;
1877: }
1878: if (fullrole == "$env{'request.role'}") {
1.350 raeburn 1879: document.rolechooser.elements[roleitem].selectedIndex = 0;
1.235 raeburn 1880: return;
1881: }
1882: itemid = retrieveIndex('gotorole');
1883: if (itemid != -1) {
1.239 raeburn 1884: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 1885: }
1.239 raeburn 1886: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235 raeburn 1887: document.rolechooser.selectrole.value = '1';
1888: document.rolechooser.submit();
1889: return;
1890: }
1891:
1892: function retrieveIndex(item) {
1893: for (var i=0;i<document.rolechooser.elements.length;i++) {
1894: if (document.rolechooser.elements[i].name == item) {
1895: return i;
1896: }
1897: }
1898: return -1;
1899: }
1.273 droeschl 1900: // ]]>
1.235 raeburn 1901: </script>
1902: END
1903: }
1904:
1.350 raeburn 1905: sub required_privs {
1906: my $privs = {
1907: '/adm/parmset' => 'opa',
1908: '/adm/courseprefs' => 'opa',
1909: '/adm/whatsnew' => 'whn',
1910: '/adm/populate' => 'cst',
1911: '/adm/trackstudent' => 'vsa',
1912: '/adm/statistics' => 'vgr',
1.366 raeburn 1913: '/adm/setblock' => 'dcm',
1.367 raeburn 1914: '/adm/coursedocs' => 'mdc',
1.350 raeburn 1915: };
1916: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 1917: $privs->{'/adm/classcalc'} = 'vgr',
1918: $privs->{'/adm/assesscalc'} = 'vgr',
1919: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 1920: }
1921: return $privs;
1922: }
1.235 raeburn 1923:
1.378 raeburn 1924: sub countdown_timer {
1925: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
1.387 raeburn 1926: ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
1927: my ($type,$hastimeleft,$slothastime);
1928: my $now = time;
1929: if ($env{'request.filename'} =~ /\.task$/) {
1930: $type = 'Task';
1931: } else {
1932: $type = 'problem';
1933: }
1934: my ($status,$accessmsg,$slot_name,$slot) =
1935: &Apache::lonhomework::check_slot_access('0',$type);
1936: if ($slot_name ne '') {
1937: if (ref($slot) eq 'HASH') {
1938: if (($slot->{'starttime'} < $now) &&
1939: ($slot->{'endtime'} > $now)) {
1940: $slothastime = 1;
1941: }
1942: }
1943: }
1944: if ($status ne 'CAN_ANSWER') {
1945: return;
1946: }
1.378 raeburn 1947: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.380 raeburn 1948: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.381 raeburn 1949: my $hastimeleft;
1950: if (@interval > 1) {
1951: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
1952: if ($first_access > 0) {
1953: if ($first_access+$interval[0] > time) {
1954: $hastimeleft = 1;
1955: }
1956: }
1957: }
1.380 raeburn 1958: if (($duedate && $duedate > time) ||
1.387 raeburn 1959: (!$duedate && $hastimeleft) ||
1960: ($slot_name ne '' && $slothastime)) {
1.379 raeburn 1961: my ($collapse,$expand,$alttxt,$title,$currdisp);
1.387 raeburn 1962: if ((@interval > 1 && $hastimeleft) ||
1963: ($type eq 'Task' && $slothastime)) {
1.378 raeburn 1964: $currdisp = 'inline';
1965: $collapse = '► ';
1966: } else {
1967: $currdisp = 'none';
1968: $expand = '◄ ';
1969: }
1970: unless ($env{'environment.icons'} eq 'iconsonly') {
1.379 raeburn 1971: $alttxt = &mt('Timer');
1972: $title = $alttxt.' ';
1.378 raeburn 1973: }
1974: my $desc = &mt('Countdown to due date/time');
1975: return <<END;
1976:
1977: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
1978: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
1979: $collapse
1.379 raeburn 1980: </span></a>
1.378 raeburn 1981: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
1982: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
1983: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.379 raeburn 1984: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1.378 raeburn 1985: END
1986: }
1987: }
1988: return;
1989: }
1990:
1.2 www 1991: # ================================================================ Main Program
1992:
1.16 harris41 1993: BEGIN {
1.166 albertel 1994: if (! defined($readdesk)) {
1.283 droeschl 1995: {
1996: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1997: if ( CORE::open( my $config,"<$tabfile") ) {
1998: while (my $configline=<$config>) {
1999: $configline=(split(/\#/,$configline))[0];
2000: $configline=~s/^\s+//;
2001: chomp($configline);
1.209 www 2002: if ($configline=~/^cat\:/) {
1.283 droeschl 2003: my @entries=split(/\:/,$configline);
2004: $category_positions{$entries[2]}=$entries[1];
2005: $category_names{$entries[2]}=$entries[3];
2006: } elsif ($configline=~/^prim\:/) {
2007: my @entries = (split(/\:/, $configline))[1..5];
2008: push @primary_menu, \@entries;
1.371 raeburn 2009: } elsif ($configline=~/^primsub\:/) {
2010: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
2011: push (@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 2012: } elsif ($configline=~/^scnd\:/) {
2013: my @entries = (split(/\:/, $configline))[1..5];
2014: push @secondary_menu, \@entries;
2015: } elsif ($configline) {
2016: push(@desklines,$configline);
2017: }
2018: }
2019: CORE::close($config);
2020: }
2021: }
2022: $readdesk='done';
1.2 www 2023: }
2024: }
1.30 www 2025:
1.1 www 2026: 1;
2027: __END__
2028:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>