Annotation of loncom/interface/lonmenu.pm, revision 1.369.2.32
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.369.2.32! raeburn 4: # $Id: lonmenu.pm,v 1.369.2.31 2012/12/28 17:26:15 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.369.2.3 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.369.2.3 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.369.2.3 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.369.2.6 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:
1.369.2.17 raeburn 134: =item loadevents()
135:
136: =item unloadevents()
137:
138: =item startupremote()
139:
140: =item setflags()
141:
142: =item maincall()
143:
144: =item load_remote_msg()
145:
146: =item get_menu_name()
147:
148: =item reopenmenu()
149:
150: =item open()
151:
152: Open the menu
153:
1.244 jms 154: =item clear()
155:
156: =item switch()
157:
158: Switch a button or create a link
159: Switch acts on the javascript that is executed when a button is clicked.
160: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
161:
162: =item secondlevel()
163:
164: =item openmenu()
165:
166: =item inlinemenu()
167:
168: =item rawconfig()
169:
170: =item utilityfunctions()
171:
1.369.2.6 raeburn 172: Output from this routine is a number of javascript functions called by
173: items in the inline menu, and in some cases items in the Main Menu page.
174:
1.244 jms 175: =item serverform()
176:
177: =item constspaceform()
178:
179: =item get_nav_status()
180:
181: =item hidden_button_check()
182:
183: =item roles_selector()
184:
185: =item jump_to_role()
186:
187: =back
188:
189: =cut
190:
1.1 www 191: package Apache::lonmenu;
192:
193: use strict;
1.152 albertel 194: use Apache::lonnet;
1.47 matthew 195: use Apache::lonhtmlcommon();
1.115 albertel 196: use Apache::loncommon();
1.127 albertel 197: use Apache::lonenc();
1.88 www 198: use Apache::lonlocal;
1.361 raeburn 199: use Apache::lonmsg();
1.207 foxr 200: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 201: use HTML::Entities();
1.369.2.8 raeburn 202: use Apache::lonwishlist();
1.88 www 203:
1.283 droeschl 204: use vars qw(@desklines %category_names %category_members %category_positions
1.369.2.5 raeburn 205: $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
1.88 www 206:
1.56 www 207: my @inlineremote;
1.38 www 208:
1.283 droeschl 209: sub prep_menuitem {
1.291 raeburn 210: my ($menuitem) = @_;
211: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 212: my $link;
213: if ($$menuitem[1]) { # graphical Link
214: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 215: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
216: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 217: } else { # textual Link
1.291 raeburn 218: $link = &mt($$menuitem[3]);
219: }
1.316 droeschl 220: return '<li><a'
221: # highlighting for new messages
222: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
1.325 droeschl 223: . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
1.283 droeschl 224: }
225:
226: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
227: # that contains following links:
1.369.2.3 raeburn 228: # About, Message, Personal, Roles, Help, Logout
1.283 droeschl 229: # @primary_menu is filled within the BEGIN block of this module with
230: # entries from mydesk.tab
231: sub primary_menu {
232: my $menu;
233: # each element of @primary contains following array:
234: # (link url, icon path, alt text, link text, condition)
1.319 raeburn 235: my $public;
236: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
237: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
238: $public = 1;
239: }
1.283 droeschl 240: foreach my $menuitem (@primary_menu) {
241: # evaluate conditions
1.296 droeschl 242: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 243: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 244: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 245: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 246: && !&Apache::lonmsg::mynewmail(); #
1.319 raeburn 247: next if $$menuitem[4] !~ /public/ ##we've a public user,
248: && $public; ##who should not see all
249: ##links
1.283 droeschl 250: next if $$menuitem[4] eq 'onlypublic'# hide links which are
1.319 raeburn 251: && !$public; # only visible to public
252: # users
1.283 droeschl 253: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 254: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 255: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 256: && !&Apache::loncommon::show_course(); ##
257:
1.369.2.3 raeburn 258: my $title = $menuitem->[3];
259: if (defined($primary_submenu{$title})) {
1.369.2.6 raeburn 260: my ($link,$target);
1.369.2.3 raeburn 261: if ($menuitem->[0] ne '') {
262: $link = $menuitem->[0];
263: $target = '_top';
264: } else {
265: $link = '#';
266: }
1.369.2.6 raeburn 267: my @primsub;
1.369.2.3 raeburn 268: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.369.2.6 raeburn 269: foreach my $item (@{$primary_submenu{$title}}) {
1.369.2.16 raeburn 270: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.369.2.6 raeburn 271: next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
272: next if ((($item->[2] eq 'portfolio') ||
273: ($item->[2] eq 'blog')) &&
274: (!&Apache::lonnet::usertools_access('','',$item->[2],
275: undef,'tools')));
276: push(@primsub,$item);
277: }
278: if (@primsub > 0) {
279: $menu .= &create_submenu($link,$target,$title,\@primsub);
280: } elsif ($link) {
1.369.2.7 raeburn 281: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.369.2.3 raeburn 282: }
283: }
284: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.340 raeburn 285: if ($public) {
286: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
287: my $defdom = &Apache::lonnet::default_login_domain();
288: my $to = &Apache::loncommon::build_recipient_list(undef,
289: 'helpdeskmail',
290: $defdom,$origmail);
291: if ($to ne '') {
292: $menu .= &prep_menuitem($menuitem);
293: }
294: } else {
295: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
296: }
1.283 droeschl 297: } else {
1.325 droeschl 298: $menu .= prep_menuitem($menuitem);
1.283 droeschl 299: }
1.291 raeburn 300: }
1.325 droeschl 301: $menu =~ s/\[domain\]/$env{'user.domain'}/g;
302: $menu =~ s/\[user\]/$env{'user.name'}/g;
1.283 droeschl 303:
1.291 raeburn 304: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 305: }
306:
1.329 droeschl 307: #returns hashref {user=>'',dom=>''} containing:
308: # own name, domain if user is au
309: # name, domain of parent author if user is ca or aa
310: #empty return if user is not an author or not on homeserver
311: #
312: #TODO this should probably be moved somewhere more central
313: #since it can be used by different parts of the system
314: sub getauthor{
315: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
316:
317: #co- or assistent author?
318: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
319: ? ($1, $2) #domain, username of the parent author
320: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
321:
322: # current server == home server?
323: my $home = &Apache::lonnet::homeserver($user,$dom);
324: foreach (&Apache::lonnet::current_machine_ids()){
325: return {user => $user, dom => $dom} if $_ eq $home;
326: }
327:
328: # if wrong server
329: return;
330: }
1.283 droeschl 331:
332: sub secondary_menu {
333: my $menu;
334:
1.286 raeburn 335: my $crstype = &Apache::loncommon::course_type();
1.327 droeschl 336: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
337: ? "/$env{'request.course.sec'}"
338: : '');
339: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
1.369.2.5 raeburn 340: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
341: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
342: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
343: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
1.341 www 344: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
1.343 www 345: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
1.369.2.5 raeburn 346: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
1.343 www 347: my $author = &getauthor();
1.327 droeschl 348:
1.369.2.31 raeburn 349: my ($canmodifycoauthor);
350: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
351: my $extent = "$env{'user.domain'}/$env{'user.name'}";
352: if ((&Apache::lonnet::allowed('cca',$extent)) ||
353: (&Apache::lonnet::allowed('caa',$extent))) {
354: $canmodifycoauthor = 1;
355: }
356: }
357:
1.286 raeburn 358: my %groups = &Apache::lonnet::get_active_groups(
359: $env{'user.domain'}, $env{'user.name'},
360: $env{'course.' . $env{'request.course.id'} . '.domain'},
361: $env{'course.' . $env{'request.course.id'} . '.num'});
1.327 droeschl 362:
1.369.2.30 raeburn 363: my ($roleswitcher_js,$roleswitcher_form);
364:
1.283 droeschl 365: foreach my $menuitem (@secondary_menu) {
366: # evaluate conditions
1.296 droeschl 367: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 368: next if $$menuitem[4] ne 'always'
1.369.2.31 raeburn 369: && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
1.283 droeschl 370: && !$env{'request.course.id'};
371: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 372: && !$canedit;
1.369.2.5 raeburn 373: next if $$menuitem[4] eq 'mdcCourse'
374: && ($crstype eq 'Community');
375: next if $$menuitem[4] eq 'mdcCommunity'
376: && ($crstype eq 'Course');
1.341 www 377: next if $$menuitem[4] eq 'nvgr'
378: && $canvgr;
379: next if $$menuitem[4] eq 'vgr'
380: && !$canvgr;
1.327 droeschl 381: next if $$menuitem[4] eq 'cst'
382: && !$canmodifyuser;
1.343 www 383: next if $$menuitem[4] eq 'ncst'
1.369.2.5 raeburn 384: && ($canmodifyuser || !$canviewroster);
1.343 www 385: next if $$menuitem[4] eq 'mgr'
386: && !$canmgr;
387: next if $$menuitem[4] eq 'nmgr'
388: && $canmgr;
1.327 droeschl 389: next if $$menuitem[4] eq 'whn'
390: && !$canviewwnew;
391: next if $$menuitem[4] eq 'opa'
392: && !$canmodpara;
1.369.2.5 raeburn 393: next if $$menuitem[4] eq 'nvcg'
394: && ($canviewgrps || !%groups);
1.329 droeschl 395: next if $$menuitem[4] eq 'author'
396: && !$author;
1.369.2.31 raeburn 397: next if $$menuitem[4] eq 'cca'
398: && !$canmodifycoauthor;
1.283 droeschl 399:
1.369.2.5 raeburn 400: my $title = $menuitem->[3];
401: if (defined($secondary_submenu{$title})) {
1.369.2.6 raeburn 402: my ($link,$target);
1.369.2.5 raeburn 403: if ($menuitem->[0] ne '') {
404: $link = $menuitem->[0];
405: $target = '_top';
406: } else {
407: $link = '#';
408: }
409: my @scndsub;
410: if (ref($secondary_submenu{$title}) eq 'ARRAY') {
411: foreach my $item (@{$secondary_submenu{$title}}) {
412: if (ref($item) eq 'ARRAY') {
413: next if ($item->[2] eq 'vgr' && !$canvgr);
414: next if ($item->[2] eq 'opa' && !$canmodpara);
415: next if ($item->[2] eq 'cst' && !$canmodifyuser);
416: next if ($item->[2] eq 'mgr' && !$canmgr);
417: next if ($item->[2] eq 'vcg' && !$canviewgrps);
418: push(@scndsub,$item);
419: }
420: }
1.369.2.6 raeburn 421: if (@scndsub > 0) {
422: $menu .= &create_submenu($link,$target,$title,\@scndsub);
423: } elsif ($link) {
1.369.2.7 raeburn 424: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.369.2.5 raeburn 425: }
426: }
427: } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 428: # special treatment for role selector
1.369.2.30 raeburn 429: ($roleswitcher_js,$roleswitcher_form,my $switcher) =
430: &roles_selector(
1.283 droeschl 431: $env{'course.' . $env{'request.course.id'} . '.domain'},
1.369.2.30 raeburn 432: $env{'course.' . $env{'request.course.id'} . '.num'}
433: );
434: $menu .= $switcher;
1.296 droeschl 435: } else {
436: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 437: }
438: }
439: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 440: my $escurl = &escape( &Apache::lonenc::check_encrypt(
441: $env{'request.noversionuri'}));
1.283 droeschl 442:
1.291 raeburn 443: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
444: $env{'request.symb'}));
1.283 droeschl 445:
446: if ( $env{'request.state'} eq 'construct'
447: and ( $env{'request.noversionuri'} eq ''
448: || !defined($env{'request.noversionuri'})))
449: {
1.359 raeburn 450: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
451: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 452: $escurl = &escape($escurl);
1.283 droeschl 453: }
454: $menu =~ s/\[url\]/$escurl/g;
455: $menu =~ s/\[symb\]/$escsymb/g;
456: }
1.329 droeschl 457: $menu =~ s/\[uname\]/$$author{user}/g;
458: $menu =~ s/\[udom\]/$$author{dom}/g;
1.369.2.22 raeburn 459: if ($menu) {
460: $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
461: }
1.369.2.30 raeburn 462: if ($roleswitcher_form) {
463: $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
464: }
1.369.2.22 raeburn 465: return $menu;
1.283 droeschl 466: }
467:
1.369.2.6 raeburn 468: sub create_submenu {
469: my ($link,$target,$title,$submenu) = @_;
470: return unless (ref($submenu) eq 'ARRAY');
1.369.2.11 raeburn 471: my $disptarget;
472: if ($target ne '') {
473: $disptarget = ' target="'.$target.'"';
474: }
1.369.2.6 raeburn 475: my $menu = '<li class="LC_hoverable">'.
1.369.2.11 raeburn 476: '<a href="'.$link.'"'.$disptarget.'>'.
1.369.2.7 raeburn 477: '<span class="LC_nobreak">'.&mt($title).
1.369.2.6 raeburn 478: '<span class="LC_fontsize_small" style="font-weight:normal;">'.
479: ' ▼</span></span></a>'.
480: '<ul>';
481: my $count = 0;
482: my $numsub = scalar(@{$submenu});
483: foreach my $item (@{$submenu}) {
484: $count ++;
485: if (ref($item) eq 'ARRAY') {
486: my $borderbot;
487: if ($count == $numsub) {
488: $borderbot = 'border-bottom:1px solid black;';
489: }
490: $menu .= '<li style="margin:0;padding:0;'.
491: $borderbot.'"><a href="'.$item->[0].'">'.
1.369.2.7 raeburn 492: &mt($item->[1]).'</a></li>';
1.369.2.6 raeburn 493: }
494: }
495: $menu .= '</ul></li>';
496: return $menu;
497: }
498:
1.369.2.17 raeburn 499: sub registerurl {
500: my ($forcereg) = @_;
501: my $result = '';
502: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
503: my $force_title='';
504: if ($env{'request.state'} eq 'construct') {
505: $force_title=&Apache::lonxml::display_title();
506: }
1.369.2.25 raeburn 507: if (($env{'environment.remote'} ne 'on') ||
1.369.2.17 raeburn 508: ((($env{'request.publicaccess'}) ||
509: (!&Apache::lonnet::is_on_map(
510: &unescape($env{'request.noversionuri'})))) &&
511: (!$forcereg))) {
512: return
513: $result
514: .'<script type="text/javascript">'."\n"
515: .'// <![CDATA['."\n"
516: .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
517: .'// ]]>'."\n"
518: .'</script>'
519: .$force_title;
520: }
521: # Graphical display after login only
522: if ($env{'request.registered'} && !$forcereg) { return ''; }
523: $result.=&innerregister($forcereg);
524: return $result.$force_title;
525: }
526:
1.40 www 527: sub innerregister {
1.369.2.26 raeburn 528: my ($forcereg,$bread_crumbs,$group) = @_;
1.152 albertel 529: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 530: my $is_const_dir = 0;
1.120 raeburn 531:
1.175 albertel 532: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 533:
1.174 albertel 534: $env{'request.registered'} = 1;
1.40 www 535:
1.369.2.25 raeburn 536: my $noremote = ($env{'environment.remote'} ne 'on');
1.369.2.17 raeburn 537:
1.177 albertel 538: undef(@inlineremote);
1.56 www 539:
1.369.2.17 raeburn 540: my $reopen=&Apache::lonmenu::reopenmenu();
541:
542: my $newmail='';
543:
544: if (&Apache::lonmsg::newmail() && !$noremote) {
545: # We have new mail and remote is up
546: $newmail= 'swmenu.setstatus("you have","messages");';
547: }
548:
1.369.2.27 raeburn 549: my ($mapurl,$resurl);
1.369.2.26 raeburn 550:
1.369.2.27 raeburn 551: if ($env{'request.course.id'}) {
552: if ($env{'request.symb'}) {
553: ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
554: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
1.267 droeschl 555:
1.369.2.27 raeburn 556: my $maptitle = &Apache::lonnet::gettitle($mapurl);
557: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.267 droeschl 558:
1.318 droeschl 559:
560: #SD
561: #course_type only Course and Community?
562: #
1.369.2.27 raeburn 563: my @crumbs;
564: unless (($forcereg) &&
565: ($env{'request.noversionuri'} eq '/adm/navmaps') &&
566: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
567: @crumbs = ({text => Apache::loncommon::course_type()
568: . ' Contents',
569: href => "Javascript:gopost('/adm/navmaps','')"});
570: }
571: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
572: push(@crumbs, {text => '...',
573: no_mt => 1});
574: }
575:
576: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
577: && $maptitle ne 'default.sequence'
578: && $maptitle ne $coursetitle);
579:
580: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
581: &Apache::lonhtmlcommon::clear_breadcrumbs();
582: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
583: } else {
584: $resurl = $env{'request.noversionuri'};
585: my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
586: my $crstype = &Apache::loncommon::course_type();
587: my $title = &mt('View Resource');
588: if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
589: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
590: &Apache::lonhtmlcommon::clear_breadcrumbs();
591: if ($env{'form.title'}) {
592: $title = $env{'form.title'};
593: }
594: my $trail;
595: if ($env{'form.folderpath'}) {
1.369.2.29 raeburn 596: &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
1.369.2.27 raeburn 597: ($trail) =
598: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
599: } else {
600: &Apache::lonhtmlcommon::add_breadcrumb(
601: {text => "Supplemental $crstype Content",
602: href => "javascript:gopost('/adm/supplemental','')"});
603: $title = &mt('View Resource');
604: ($trail) =
605: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
606: }
607: return $trail;
608: }
609: unless ($env{'request.state'} eq 'construct') {
610: &Apache::lonhtmlcommon::clear_breadcrumbs();
611: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
612: }
613: }
1.369.2.26 raeburn 614: } elsif (! $const_space){
1.328 droeschl 615: #a situation when we're looking at a resource outside of context of a
616: #course or construction space (e.g. with cumulative rights)
617: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.369.2.26 raeburn 618: unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
619: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
620: }
1.65 www 621: }
1.369.2.17 raeburn 622: my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
1.41 www 623: # =============================================================================
624: # ============================ This is for URLs that actually can be registered
1.369.2.18 raeburn 625: if ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
1.369.2.17 raeburn 626: || ($forcereg)) {
1.369.2.28 raeburn 627:
628: my %swtext;
629: if ($noremote) {
630: %swtext = &get_inline_text();
631: } else {
632: %swtext = &get_rc_text();
633: }
634: my $hwkadd='';
635:
636: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
637: $forceview,$editbutton);
638: if (($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) ||
639: ($env{'request.role'} !~/^(aa|ca|au)/)) {
640: $editbutton = &prepare_functions($resurl,$forcereg,$group);
641: }
642: if ($editbutton eq '') {
1.369.2.29 raeburn 643: $editbutton = &clear(6,1);
1.369.2.28 raeburn 644: }
1.369.2.26 raeburn 645:
646: #
647: # This applies in course context
648: #
1.369.2.28 raeburn 649: if ($env{'request.course.id'}) {
650: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
651: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
652: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
653: my @privs;
654: if ($env{'request.symb'} ne '') {
655: if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
656: push(@privs,('mgr','vgr'));
657: }
658: push(@privs,'opa');
659: }
660: foreach my $priv (@privs) {
661: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
662: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
663: $perms{$priv} =
664: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
665: }
1.258 raeburn 666: }
1.369.2.26 raeburn 667: #
668: # Determine whether or not to show Grades and Submissions buttons
669: #
1.369.2.28 raeburn 670: if ($env{'request.symb'} ne '' &&
671: $env{'request.filename'}=~/$LONCAPA::assess_re/) {
672: if ($perms{'mgr'}) {
673: $hwkadd.= &switch('','',7,2,'pgrd.png','Content Grades',
674: 'grades[_4]',
675: "gocmd('/adm/grades','gradingmenu')",
676: 'Content Grades');
677: } elsif ($perms{'vgr'}) {
678: $hwkadd .= &switch('','',7,2,'subm.png','Content Submissions',
679: 'missions[_1]',
680: "gocmd('/adm/grades','submission')",
681: 'Content Submissions');
682: }
683: }
684: if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
685: $hwkadd .= &switch('','',7,3,'pparm.png','Content Settings',
686: 'parms[_2]',"gocmd('/adm/parmset','set')",
687: 'Content Settings');
688: }
1.369.2.26 raeburn 689: # End grades/submissions check
690:
691: #
692: # This applies to items inside a folder/page modifiable in the course.
693: #
1.369.2.28 raeburn 694: if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
695: my $text = 'Edit Folder';
696: if (($mapurl =~ /\.page$/) ||
697: ($env{'request.symb'}=~
698: m{uploaded/$cdom/$cnum/default_\d+\.page$})) {
699: $text = 'Edit Page';
700: }
701: $hwkadd .= &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
702: "gocmd('/adm/coursedocs','direct')",
703: 'Folder/Page Content');
704: }
1.369.2.26 raeburn 705: # End modifiable folder/page container check
1.369.2.28 raeburn 706: }
1.369.2.26 raeburn 707: # End course context
708:
1.41 www 709: # Prepare the rest of the buttons
1.369.2.21 raeburn 710: my ($menuitems,$got_prt,$got_wishlist,$cstritems);
1.120 raeburn 711: if ($const_space) {
1.274 www 712: #
713: # We are in construction space
714: #
1.353 www 715:
1.355 raeburn 716: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 717: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 718: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.353 www 719: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 720: if ($currdir =~ m-/$-) {
721: $is_const_dir = 1;
722: } else {
1.267 droeschl 723: $currdir =~ s|[^/]+$||;
1.200 foxr 724: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 725: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 726: #
727: # Probably should be in mydesk.tab
728: #
1.131 raeburn 729: $menuitems=(<<ENDMENUITEMS);
1.369.2.21 raeburn 730: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
731: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
732: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
733: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
734: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 735: ENDMENUITEMS
1.369.2.21 raeburn 736: unless ($noremote) {
737: $cstritems = $menuitems;
738: undef($menuitems);
739: }
1.131 raeburn 740: }
1.369.2.28 raeburn 741: if (ref($bread_crumbs) eq 'ARRAY') {
742: &Apache::lonhtmlcommon::clear_breadcrumbs();
743: foreach my $crumb (@{$bread_crumbs}){
744: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
1.308 raeburn 745: }
1.369.2.28 raeburn 746: }
1.203 foxr 747: } elsif ( defined($env{'request.course.id'}) &&
748: $env{'request.symb'} ne '' ) {
1.274 www 749: #
1.369.2.16 raeburn 750: # We are in a course and looking at a registered URL
1.274 www 751: # Should probably be in mydesk.tab
752: #
1.369.2.19 raeburn 753:
1.120 raeburn 754: $menuitems=(<<ENDMENUITEMS);
1.41 www 755: c&3&1
1.369.2.19 raeburn 756: s&2&1&back.png&$swtext{'back'}&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
757: s&2&3&forw.png&$swtext{'forw'}&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
1.77 www 758: c&6&3
759: c&8&1
760: c&8&2
1.369.2.19 raeburn 761: s&8&3&prt.png&$swtext{'prt'}&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 762: ENDMENUITEMS
1.369.2.16 raeburn 763: $got_prt = 1;
764: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
765: && (!$env{'request.enc'})) {
1.369.2.8 raeburn 766: # wishlist is only available for users with access to resource-pool
767: # and links can only be set for resources within the resource-pool
768: $menuitems .= (<<ENDMENUITEMS);
1.369.2.19 raeburn 769: s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
1.369.2.8 raeburn 770: ENDMENUITEMS
1.369.2.16 raeburn 771: $got_wishlist = 1;
1.369.2.8 raeburn 772: }
1.216 albertel 773:
1.243 tempelho 774: my $currentURL = &Apache::loncommon::get_symb();
775: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
776: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
777: $menuitems.="s&9&3&";
778: if(length($annotation) > 0){
1.317 droeschl 779: $menuitems.="anot2.png";
1.243 tempelho 780: }else{
1.317 droeschl 781: $menuitems.="anot.png";
1.243 tempelho 782: }
1.369.2.19 raeburn 783: $menuitems.="&$swtext{'anot'}&tations[_1]&annotate()&";
1.243 tempelho 784: $menuitems.="Make notes and annotations about this resource&&1\n";
785:
1.323 raeburn 786: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.369.2.15 raeburn 787: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
1.216 albertel 788: $menuitems.=(<<ENDREALRES);
1.369.2.19 raeburn 789: s&6&3&catalog.png&$swtext{'catalog'}&info[_1]&catalog_info()&Show Metadata
1.216 albertel 790: ENDREALRES
791: }
1.369.2.14 raeburn 792: unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
793: $menuitems.=(<<ENDREALRES);
1.369.2.19 raeburn 794: s&8&1&eval.png&$swtext{'eval'}&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.369.2.14 raeburn 795: ENDREALRES
796: }
797: $menuitems.=(<<ENDREALRES);
1.369.2.19 raeburn 798: s&8&2&fdbk.png&$swtext{'fdbk'}&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77 www 799: ENDREALRES
1.120 raeburn 800: }
801: }
1.203 foxr 802: if ($env{'request.uri'} =~ /^\/res/) {
1.369.2.16 raeburn 803: unless ($got_prt) {
804: $menuitems .= (<<ENDMENUITEMS);
1.369.2.19 raeburn 805: s&8&3&prt.png&$swtext{'prt'}&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 806: ENDMENUITEMS
1.369.2.16 raeburn 807: $got_prt = 1;
808: }
809: unless ($got_wishlist) {
810: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
811: # wishlist is only available for users with access to resource-pool
812: $menuitems .= (<<ENDMENUITEMS);
1.369.2.19 raeburn 813: s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
1.369.2.8 raeburn 814: ENDMENUITEMS
1.369.2.16 raeburn 815: $got_wishlist = 1;
1.369.2.17 raeburn 816: }
1.369.2.8 raeburn 817: }
1.203 foxr 818: }
1.369.2.20 raeburn 819: unless ($got_prt) {
820: $menuitems .= (<<ENDMENUITEMS);
821: c&8&3
822: ENDMENUITEMS
823: }
824: unless ($got_wishlist) {
825: $menuitems .= (<<ENDMENUITEMS);
826: c&9&1
827: ENDMENUITEMS
828: }
1.41 www 829: my $buttons='';
830: foreach (split(/\n/,$menuitems)) {
831: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 832: my $idx=10*$rest[0]+$rest[1];
833: if (&hidden_button_check() eq 'yes') {
834: if ($idx == 21 ||$idx == 23) {
835: $buttons.=&switch('','',@rest);
836: } else {
837: $buttons.=&clear(@rest);
838: }
839: } else {
840: if ($command eq 's') {
841: $buttons.=&switch('','',@rest);
842: } else {
843: $buttons.=&clear(@rest);
844: }
1.41 www 845: }
846: }
1.369.2.17 raeburn 847: if ($noremote) {
1.148 albertel 848: my $addremote=0;
1.267 droeschl 849: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.369.2.17 raeburn 850: if ($addremote) {
1.301 droeschl 851:
1.369.2.17 raeburn 852: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 853:
1.369.2.17 raeburn 854: &Apache::lonhtmlcommon::add_breadcrumb_tool(
855: 'navigation', @inlineremote[21,23]);
856:
857: my $countdown = &countdown_timer();
858: if (&hidden_button_check() eq 'yes') {
859: if ($countdown) {
860: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
861: }
862: } else {
863: my @tools = @inlineremote[93,91,81,82,83];
864: if ($countdown) {
865: unshift(@tools,$countdown);
866: }
867: &Apache::lonhtmlcommon::add_breadcrumb_tool(
868: 'tools',@tools);
1.312 droeschl 869:
1.369.2.17 raeburn 870: #publish button in construction space
871: if ($env{'request.state'} eq 'construct'){
872: &Apache::lonhtmlcommon::add_breadcrumb_tool(
873: 'advtools', $inlineremote[63]);
874: } else {
875: &Apache::lonhtmlcommon::add_breadcrumb_tool(
876: 'tools', $inlineremote[63]);
877: }
1.369.2.26 raeburn 878: &advtools_crumbs(@inlineremote);
1.369.2.17 raeburn 879: }
1.369.2.10 raeburn 880: }
1.369.2.18 raeburn 881: return &Apache::lonhtmlcommon::scripttag('', 'start')
882: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
883: . &Apache::lonhtmlcommon::scripttag('', 'end');
884:
1.369.2.10 raeburn 885: } else {
1.369.2.21 raeburn 886: my $cstrcrumbs;
887: if ($const_space) {
888: foreach (split(/\n/,$cstritems)) {
889: my ($command,@rest)=split(/\&/,$_);
890: my $idx=10*$rest[0]+$rest[1];
891: &switch('','',@rest);
892: }
893: &Apache::lonhtmlcommon::add_breadcrumb_tool('advtools',
894: @inlineremote[63,61,71,72]);
895:
896: $cstrcrumbs = &Apache::lonhtmlcommon::scripttag('', 'start')
897: .&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
898: .&Apache::lonhtmlcommon::scripttag('', 'end');
899: }
1.369.2.17 raeburn 900: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
901: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
902: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
903: my $navstatus=&get_nav_status();
904: my $clearcstr;
1.313 droeschl 905:
1.369.2.17 raeburn 906: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
907: return <<ENDREGTHIS;
908:
909: <script type="text/javascript">
910: // <![CDATA[
911: // BEGIN LON-CAPA Internal
912: var swmenu=null;
913:
914: function LONCAPAreg() {
915: swmenu=$reopen;
916: swmenu.clearTimeout(swmenu.menucltim);
917: $timesync
918: $newmail
919: $buttons
920: swmenu.currentURL="$requri";
921: swmenu.reloadURL=swmenu.currentURL+window.location.search;
922: swmenu.currentSymb="$cursymb";
923: swmenu.reloadSymb="$cursymb";
924: swmenu.currentStale=0;
925: $navstatus
926: $hwkadd
927: $editbutton
928: }
929:
930: function LONCAPAstale() {
931: swmenu=$reopen
932: swmenu.currentStale=1;
933: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
934: swmenu.switchbutton
935: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
936: }
937: swmenu.clearbut(7,2);
938: swmenu.clearbut(7,3);
939: swmenu.menucltim=swmenu.setTimeout(
940: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
941: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
942: 2000);
943: }
944:
945: // END LON-CAPA Internal
946: // ]]>
947: </script>
1.369.2.21 raeburn 948:
949: $cstrcrumbs
1.369.2.17 raeburn 950: ENDREGTHIS
1.301 droeschl 951: }
1.369.2.18 raeburn 952: } else {
953: unless ($noremote) {
954: # Not registered, graphical
955: return (<<ENDDONOTREGTHIS);
956:
957: <script type="text/javascript">
958: // <![CDATA[
959: // BEGIN LON-CAPA Internal
960: var swmenu=null;
1.38 www 961:
1.369.2.18 raeburn 962: function LONCAPAreg() {
963: swmenu=$reopen
964: $timesync
965: swmenu.currentStale=1;
966: swmenu.clearbut(2,1);
967: swmenu.clearbut(2,3);
968: swmenu.clearbut(8,1);
969: swmenu.clearbut(8,2);
970: swmenu.clearbut(8,3);
1.369.2.20 raeburn 971: swmenu.clearbut(9,1);
1.369.2.18 raeburn 972: if (swmenu.currentURL) {
973: swmenu.switchbutton
974: (3,1,'reload.gif','return','location','go(currentURL)');
975: } else {
976: swmenu.clearbut(3,1);
977: }
978: }
979:
980: function LONCAPAstale() {
981: }
982:
983: // END LON-CAPA Internal
984: // ]]>
985: </script>
986: ENDDONOTREGTHIS
987:
988: }
989: return '';
990: }
1.38 www 991: }
992:
1.369.2.19 raeburn 993: sub get_inline_text {
994: my %text = (
995: pgrd => 'Content Grades',
996: subm => 'Content Submissions',
997: pparm => 'Content Settings',
998: docs => 'Folder/Page Content',
999: pcstr => 'Edit',
1000: prt => 'Print',
1001: alnk => 'Stored Links',
1002: anot => 'Notes',
1003: catalog => 'Info',
1004: eval => 'Evaluate',
1005: fdbk => 'Feedback',
1006: );
1007: return %text;
1008: }
1009:
1010: sub get_rc_text {
1011: my %text = (
1012: pgrd => 'problem[_1]',
1013: subm => 'view sub-[_1]',
1014: pparm => 'problem[_2]',
1015: pcstr => 'edit[_1]',
1016: prt => 'prepare[_1]',
1017: back => 'backward[_1]',
1018: forw => 'forward[_1]',
1019: alnk => 'add to[_1]',
1020: anot => 'anno-[_1]',
1021: catalog => 'catalog[_2]',
1022: eval => 'evaluate[_1]',
1023: fdbk => 'feedback[_1]',
1024: );
1025: return %text;
1026: }
1027:
1.369.2.17 raeburn 1028: sub loadevents() {
1029: if ($env{'request.state'} eq 'construct' ||
1030: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1031: return 'LONCAPAreg();';
1032: }
1033:
1034: sub unloadevents() {
1035: if ($env{'request.state'} eq 'construct' ||
1036: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1037: return 'LONCAPAstale();';
1038: }
1039:
1.369.2.1 raeburn 1040: sub startupremote {
1041: my ($lowerurl)=@_;
1.369.2.17 raeburn 1042: unless ($env{'environment.remote'} eq 'on') {
1043: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
1.369.2.1 raeburn 1044: }
1045: #
1046: # The Remote actually gets launched!
1047: #
1048: my $configmenu=&rawconfig();
1049: my $esclowerurl=&escape($lowerurl);
1050: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1051: return(<<ENDREMOTESTARTUP);
1052: <script type="text/javascript">
1053: // <![CDATA[
1054: var timestart;
1055: function wheelswitch() {
1056: if (typeof(document.wheel) != 'undefined') {
1057: if (typeof(document.wheel.spin) != 'undefined') {
1058: var date=new Date();
1059: var waited=Math.round(30-((date.getTime()-timestart)/1000));
1060: document.wheel.spin.value=$message;
1061: }
1062: }
1063: if (window.status=='|') {
1064: window.status='/';
1065: } else {
1066: if (window.status=='/') {
1067: window.status='-';
1068: } else {
1069: if (window.status=='-') {
1070: window.status='\\\\';
1071: } else {
1072: if (window.status=='\\\\') { window.status='|'; }
1073: }
1074: }
1075: }
1076: }
1077:
1078: // ---------------------------------------------------------- The wait function
1079: var canceltim;
1080: function wait() {
1081: if ((menuloaded==1) || (tim==1)) {
1082: window.status='Done.';
1083: if (tim==0) {
1084: clearTimeout(canceltim);
1085: $configmenu
1086: window.location='$lowerurl';
1087: } else {
1088: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1089: }
1090: } else {
1091: wheelswitch();
1092: setTimeout('wait();',200);
1093: }
1094: }
1095:
1096: function main() {
1097: canceltim=setTimeout('tim=1;',30000);
1098: window.status='-';
1099: var date=new Date();
1100: timestart=date.getTime();
1101: wait();
1102: }
1103:
1104: // ]]>
1105: </script>
1106: ENDREMOTESTARTUP
1107: }
1108:
1109: sub setflags() {
1110: return(<<ENDSETFLAGS);
1111: <script type="text/javascript">
1112: // <![CDATA[
1113: menuloaded=0;
1114: tim=0;
1115: // ]]>
1116: </script>
1117: ENDSETFLAGS
1118: }
1119:
1120: sub maincall() {
1.369.2.17 raeburn 1121: unless ($env{'environment.remote'} eq 'on') { return ''; }
1.369.2.1 raeburn 1122: return(<<ENDMAINCALL);
1123: <script type="text/javascript">
1124: // <![CDATA[
1125: main();
1126: // ]]>
1127: </script>
1128: ENDMAINCALL
1129: }
1130:
1131: sub load_remote_msg {
1132: my ($lowerurl)=@_;
1133:
1.369.2.17 raeburn 1134: unless ($env{'environment.remote'} eq 'on') { return ''; }
1.369.2.1 raeburn 1135:
1136: my $esclowerurl=&escape($lowerurl);
1137: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
1138: ,'<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">'
1139: ,'</a>');
1140: return(<<ENDREMOTEFORM);
1141: <p>
1142: <form name="wheel">
1143: <input name="spin" type="text" size="60" />
1144: </form>
1145: </p>
1146: <p>$link</p>
1147: ENDREMOTEFORM
1148: }
1149:
1150: sub get_menu_name {
1151: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
1152: $hostid =~ s/\W//g;
1153: return 'LCmenu'.$hostid;
1154: }
1155:
1156:
1157: sub reopenmenu {
1.369.2.17 raeburn 1158: unless ($env{'environment.remote'} eq 'on') { return ''; }
1.369.2.1 raeburn 1159: my $menuname = &get_menu_name();
1160: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1161: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1162: }
1163:
1164:
1165: sub open {
1166: my $returnval='';
1.369.2.17 raeburn 1167: unless ($env{'environment.remote'} eq 'on') {
1.369.2.1 raeburn 1168: return
1169: '<script type="text/javascript">'."\n"
1170: .'// <![CDATA['."\n"
1171: .'self.name="loncapaclient";'."\n"
1172: .'// ]]>'."\n"
1173: .'</script>';
1174: }
1175: my $menuname = &get_menu_name();
1176:
1177: # unless (shift eq 'unix') {
1178: # resizing does not work on linux because of virtual desktop sizes
1179: # $returnval.=(<<ENDRESIZE);
1180: #if (window.screen) {
1181: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1182: # self.moveTo(190,15);
1183: #}
1184: #ENDRESIZE
1185: # }
1186: $returnval=(<<ENDOPEN);
1187: // <![CDATA[
1188: window.status='Opening LON-CAPA Remote Control';
1189: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
1190: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1191: self.name='loncapaclient';
1192: // ]]>
1193: ENDOPEN
1194: return '<script type="text/javascript">'.$returnval.'</script>';
1195: }
1196:
1.369.2.26 raeburn 1197: sub get_editbutton {
1198: my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
1.369.2.27 raeburn 1199: my $jscall;
1200: if (($forceview) && ($env{'form.todocs'})) {
1201: my ($folderpath,$command);
1202: if ($env{'request.symb'}) {
1203: $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
1204: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
1205: $folderpath = $env{'form.folderpath'};
1206: $command = '&forcesupplement=1';
1207: }
1208: $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
1209: $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
1210: } else {
1211: $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
1212: $forceedit,$forcereg,$env{'request.symb'},
1213: &escape($env{'form.folderpath'}),
1214: &escape($env{'form.title'}),$env{'form.idx'},
1215: &escape($env{'form.suppurl'},$env{'form.todocs'}));
1216: }
1.369.2.26 raeburn 1217: if ($jscall) {
1218: my $icon = 'pcstr.png';
1219: my $label = 'Edit';
1220: if ($forceview) {
1221: $icon = 'tolastloc.png';
1222: $label = 'Exit Editing';
1223: }
1224: &switch('','',6,1,$icon,$label,'resource[_2]',
1225: $jscall,"Edit this resource");
1226: return 1;
1227: }
1228: return;
1229: }
1230:
1231: sub prepare_functions {
1.369.2.27 raeburn 1232: my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
1.369.2.26 raeburn 1233: unless ($env{'request.registered'}) {
1234: undef(@inlineremote);
1235: }
1236: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
1237: $forceview);
1238:
1239: if ($env{'request.course.id'}) {
1240: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1241: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1242: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1243: }
1244:
1245: my $editbutton = '';
1246: #
1247: # Determine whether or not to display 'Edit' icon/button
1248: #
1249: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1250: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.369.2.27 raeburn 1251: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1252: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1253: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1254: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
1255: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.369.2.26 raeburn 1256: $forceedit,$forceview,$forcereg);
1257: }
1.369.2.27 raeburn 1258: } elsif ((!$env{'request.course.id'}) &&
1.369.2.26 raeburn 1259: ($env{'user.author'}) && ($env{'request.filename'}) &&
1260: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1261: #
1262: # Currently do not have the role of author or co-author.
1263: # Do we have authoring privileges for the resource?
1264: #
1265: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1266: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1267: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1268: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1269: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
1270: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1271: $forceedit,$forceview,$forcereg);
1272: }
1273: } elsif ($env{'request.course.id'}) {
1274: #
1275: # This applies in course context
1276: #
1277: if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) {
1278: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
1279: &switch('','',6,1,'pcstr.png','Edit',
1280: 'resource[_2]',
1281: "go('/adm/courseprefs?phase=display&actions=courseinfo')",
1282: 'Edit this resource');
1283: $editbutton = 1;
1284: } else {
1285: $cfile = $resurl;
1286: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1287: if ($env{'form.forceedit'}) {
1288: $forceview = 1;
1289: } else {
1290: $forceedit = 1;
1291: }
1292: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1293: $forceedit,$forceview,$forcereg);
1294: }
1.369.2.27 raeburn 1295: } elsif (($resurl eq '/adm/extresedit') &&
1296: (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
1297: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1298: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
1299: $env{'form.symb'});
1300: if ($cfile ne '') {
1301: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1302: $forceedit,$forceview,$forcereg,
1303: $env{'form.title'},$env{'form.suppurl'});
1304: }
1.369.2.32! raeburn 1305: } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
! 1306: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
! 1307: ($cfile,$home,$switchserver,$forceedit,$forceview) =
! 1308: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
! 1309: $env{'form.symb'});
! 1310: $editbutton = &get_editbutton($cfile,$home,$switchserver,
! 1311: $forceedit,$forceview,$forcereg);
1.369.2.31 raeburn 1312: } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
1313: ($resurl ne '/cgi-bin/printout.pl')) {
1.369.2.26 raeburn 1314: if ($env{'request.filename'}) {
1315: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1316: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1317: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1318: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1319: if ($cfile ne '') {
1320: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1321: $forceedit,$forceview,$forcereg);
1322: }
1323: }
1324: }
1325: }
1326: # End determination of 'Edit' icon/button display
1327:
1328: if ($env{'request.course.id'}) {
1.369.2.27 raeburn 1329: # This applies to about me page for users in a course
1.369.2.29 raeburn 1330: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.369.2.26 raeburn 1331: my ($sdom,$sname) = ($1,$2);
1332: unless (&Apache::lonnet::is_course($sdom,$sname)) {
1333: &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
1334: '',
1335: "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
1336: 'Send message to specific user');
1337: }
1.369.2.27 raeburn 1338: my $hideprivileged = 1;
1339: if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
1340: $hideprivileged)) {
1.369.2.26 raeburn 1341: foreach my $priv ('vsa','vgr','srm') {
1342: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
1343: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
1344: $perms{$priv} =
1345: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
1346: }
1347: }
1348: if ($perms{'vsa'}) {
1349: &switch('','',6,5,'trck-22x22.png','Activity',
1350: '',
1351: "go('/adm/trackstudent?selected_student=$sname:$sdom')",
1352: 'View recent activity by this person');
1353: }
1354: if ($perms{'vgr'}) {
1355: &switch('','',6,6,'rsrv-22x22.png','Reservations',
1356: '',
1357: "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
1358: 'Slot reservation history');
1359: }
1360: if ($perms{'srm'}) {
1361: &switch('','',6,7,'contact-new-22x22.png','Records',
1362: '',
1363: "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
1364: 'Add records');
1365: }
1366: }
1.369.2.27 raeburn 1367: }
1368: if (($env{'form.folderpath'} =~ /^supplemental/) &&
1369: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
1370: (($resurl =~ m{^/adm/wrapper/ext/}) ||
1371: ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
1372: ($resurl eq '/adm/supplemental') ||
1373: ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
1374: ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
1375: my @folders=split('&',$env{'form.folderpath'});
1376: if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
1377: my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
1378: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
1379: "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
1380: 'Folder/Page Content');
1381: }
1.369.2.26 raeburn 1382: }
1383: }
1384:
1385: # End checking for items for about me page for users in a course
1.369.2.27 raeburn 1386: if ($docscrumbs) {
1387: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1388: &advtools_crumbs(@inlineremote);
1389: return $editbutton;
1390: } elsif ($env{'request.registered'}) {
1.369.2.26 raeburn 1391: return $editbutton;
1392: } else {
1393: if (ref($bread_crumbs) eq 'ARRAY') {
1394: if (@inlineremote > 0) {
1395: if (ref($advtools) eq 'ARRAY') {
1396: @{$advtools} = @inlineremote;
1397: }
1398: }
1399: return;
1400: } elsif (@inlineremote > 0) {
1401: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1402: &advtools_crumbs(@inlineremote);
1403: return &Apache::lonhtmlcommon::scripttag('', 'start')
1404: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
1405: . &Apache::lonhtmlcommon::scripttag('', 'end');
1406: }
1407: }
1408: }
1409:
1410: sub advtools_crumbs {
1411: my @funcs = @_;
1412: if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
1413: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1414: 'advtools', @funcs[61,64,65,66,67,74]);
1415: } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
1416: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1417: 'advtools', @funcs[61,71,72,73,74,92]);
1.369.2.27 raeburn 1418: } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
1419: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.369.2.32! raeburn 1420: 'advtools', @funcs[61]);
1.369.2.26 raeburn 1421: }
1422: }
1.369.2.1 raeburn 1423:
1.2 www 1424: # ================================================================== Raw Config
1425:
1.3 www 1426: sub clear {
1427: my ($row,$col)=@_;
1.369.2.17 raeburn 1428: if ($env{'environment.remote'} eq 'on') {
1429: if (($row<1) || ($row>13)) { return ''; }
1430: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1431: } else {
1432: $inlineremote[10*$row+$col]='';
1433: return '';
1434: }
1.3 www 1435: }
1436:
1.40 www 1437: # ============================================ Switch a button or create a link
1.25 matthew 1438: # Switch acts on the javascript that is executed when a button is clicked.
1439: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1440:
1.2 www 1441: sub switch {
1.209 www 1442: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1443: $act=~s/\$uname/$uname/g;
1444: $act=~s/\$udom/$udom/g;
1.88 www 1445: $top=&mt($top);
1446: $bot=&mt($bot);
1447: $desc=&mt($desc);
1.209 www 1448: my $idx=10*$row+$col;
1449: $category_members{$cat}.=':'.$idx;
1450:
1.369.2.17 raeburn 1451: if ($env{'environment.remote'} eq 'on') {
1452: if (($row<1) || ($row>13)) { return ''; }
1.369.2.21 raeburn 1453: if ($env{'request.state'} eq 'construct') {
1454: my $text = $top.' '.$bot;
1455: $text=~s/\s*\-\s*//gs;
1456: my $pic = '<img alt="'.$text.'" src="'.
1457: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1458: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1459: $inlineremote[$idx] =
1460: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.
1461: $pic.'<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1462: }
1.369.2.17 raeburn 1463: # Remote
1464: $img=~s/\.png$/\.gif/;
1465: return "\n".
1466: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1467: }
1468:
1.320 droeschl 1469: # Inline Menu
1.317 droeschl 1470: if ($nobreak==2) { return ''; }
1471: my $text=$top.' '.$bot;
1472: $text=~s/\s*\-\s*//gs;
1.105 www 1473:
1.317 droeschl 1474: my $pic=
1.225 albertel 1475: '<img alt="'.$text.'" src="'.
1476: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1477: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 1478: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1479: # Main Menu
1.103 www 1480: if ($nobreak==3) {
1.209 www 1481: $inlineremote[$idx]="\n".
1.177 albertel 1482: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1483: '</td><td align="left">'.
1.103 www 1484: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1485: } elsif ($nobreak) {
1.209 www 1486: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1487: '<td align="left">'.
1.177 albertel 1488: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1489: <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 1490: } else {
1.209 www 1491: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1492: '<td align="left">'.
1.103 www 1493: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1494: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1495: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1496: }
1.317 droeschl 1497: } else {
1.103 www 1498: # Inline Menu
1.369.2.10 raeburn 1499: my @tools = (93,91,81,82,83);
1500: unless ($env{'request.state'} eq 'construct') {
1501: push(@tools,63);
1502: }
1503: if (($env{'environment.icons'} eq 'iconsonly') &&
1504: (grep(/^$idx$/,@tools))) {
1505: $inlineremote[$idx] =
1506: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
1507: } else {
1508: $inlineremote[$idx] =
1.317 droeschl 1509: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.344 www 1510: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1.369.2.10 raeburn 1511: }
1.317 droeschl 1512: }
1.56 www 1513: return '';
1.2 www 1514: }
1515:
1516: sub secondlevel {
1517: my $output='';
1518: my
1.209 www 1519: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1520: if ($prt eq 'any') {
1.209 www 1521: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1522: } elsif ($prt=~/^r(\w+)/) {
1523: if ($rol eq $1) {
1.209 www 1524: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1525: }
1526: }
1527: return $output;
1528: }
1529:
1.369.2.17 raeburn 1530: sub openmenu {
1531: my $menuname = &get_menu_name();
1532: unless ($env{'environment.remote'} eq 'on') { return ''; }
1533: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1534: return "window.open(".$nothing.",'".$menuname."');";
1535: }
1536:
1.56 www 1537: sub inlinemenu {
1.210 albertel 1538: undef(@inlineremote);
1539: undef(%category_members);
1.275 www 1540: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1541: &rawconfig(1);
1.309 bisitz 1542: my $output='<table><tr>';
1.209 www 1543: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1544: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1545: for (my $row=1; $row<=8; $row++) {
1546: foreach my $cat (keys(%category_members)) {
1547: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1548: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1549: $output.='<div class="LC_Box LC_400Box">';
1550: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1551: $output.='<table>';
1.240 riegler 1552: my %active=();
1553: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1554: if ($inlineremote[$menu_item]) {
1555: $active{$menu_item}=1;
1556: }
1557: }
1558: foreach my $item (sort(keys(%active))) {
1559: $output.=$inlineremote[$item];
1560: }
1561: $output.='</table>';
1.245 harmsja 1562: $output.='</div>';
1.240 riegler 1563: }
1564: }
1565: $output.="</td>";
1566: }
1567: $output.="</tr></table>";
1568: return $output;
1569: }
1570:
1.2 www 1571: sub rawconfig {
1.274 www 1572: #
1573: # This evaluates mydesk.tab
1574: # Need to add more positions and more privileges to deal with all
1575: # menu items.
1576: #
1.34 www 1577: my $textualoverride=shift;
1578: my $output='';
1.369.2.17 raeburn 1579: if ($env{'environment.remote'} eq 'on') {
1580: $output.=
1581: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1582: "\nwindow.status='Configuring Remote Control ';";
1583: } else {
1584: unless ($textualoverride) { return ''; }
1585: }
1.152 albertel 1586: my $uname=$env{'user.name'};
1587: my $udom=$env{'user.domain'};
1588: my $adv=$env{'user.adv'};
1.266 raeburn 1589: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1590: my $author=$env{'user.author'};
1.5 www 1591: my $crs='';
1.295 raeburn 1592: my $crstype='';
1.152 albertel 1593: if ($env{'request.course.id'}) {
1594: $crs='/'.$env{'request.course.id'};
1595: if ($env{'request.course.sec'}) {
1596: $crs.='_'.$env{'request.course.sec'};
1.7 www 1597: }
1.8 www 1598: $crs=~s/\_/\//g;
1.295 raeburn 1599: $crstype = &Apache::loncommon::course_type();
1.5 www 1600: }
1.152 albertel 1601: my $pub=($env{'request.state'} eq 'published');
1602: my $con=($env{'request.state'} eq 'construct');
1603: my $rol=$env{'request.role'};
1604: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1605: foreach my $line (@desklines) {
1.209 www 1606: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1607: $prt=~s/\$uname/$uname/g;
1608: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1609: if ($prt =~ /\$crs/) {
1610: next unless ($env{'request.course.id'});
1611: next if ($crstype eq 'Community');
1612: $prt=~s/\$crs/$crs/g;
1613: } elsif ($prt =~ /\$cmty/) {
1614: next unless ($env{'request.course.id'});
1615: next if ($crstype ne 'Community');
1616: $prt=~s/\$cmty/$crs/g;
1617: }
1.25 matthew 1618: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1619: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1620: if ($pro eq 'clear') {
1.4 www 1621: $output.=&clear($row,$col);
1.3 www 1622: } elsif ($pro eq 'any') {
1.2 www 1623: $output.=&secondlevel(
1.209 www 1624: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1625: } elsif ($pro eq 'smp') {
1626: unless ($adv) {
1627: $output.=&secondlevel(
1.209 www 1628: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1629: }
1630: } elsif ($pro eq 'adv') {
1631: if ($adv) {
1632: $output.=&secondlevel(
1.209 www 1633: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1634: }
1.231 albertel 1635: } elsif ($pro eq 'shc') {
1636: if ($show_course) {
1637: $output.=&secondlevel(
1638: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1639: }
1640: } elsif ($pro eq 'nsc') {
1641: if (!$show_course) {
1642: $output.=&secondlevel(
1643: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1644: }
1.81 matthew 1645: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1646: my $priv = $1;
1647: if ($priv =~ /^mdc(Course|Community)/) {
1648: if ($crstype eq $1) {
1649: $priv = 'mdc';
1650: } else {
1651: next;
1652: }
1653: }
1654: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1655: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1656: }
1.295 raeburn 1657: } elsif ($pro eq 'course') {
1658: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1659: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1660: }
1.295 raeburn 1661: } elsif ($pro eq 'community') {
1662: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1663: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1664: }
1.124 matthew 1665: } elsif ($pro =~ /^courseenv_(.*)$/) {
1666: my $key = $1;
1.307 raeburn 1667: if ($crstype ne 'Community') {
1668: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1669: if ($key eq 'canuse_pdfforms') {
1670: if ($env{'request.course.id'} && $coursepref eq '') {
1671: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1672: $coursepref = $domdefs{'canuse_pdfforms'};
1673: }
1674: }
1675: if ($coursepref) {
1676: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1677: }
1.295 raeburn 1678: }
1679: } elsif ($pro =~ /^communityenv_(.*)$/) {
1680: my $key = $1;
1.307 raeburn 1681: if ($crstype eq 'Community') {
1682: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1683: if ($key eq 'canuse_pdfforms') {
1684: if ($env{'request.course.id'} && $coursepref eq '') {
1685: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1686: $coursepref = $domdefs{'canuse_pdfforms'};
1687: }
1688: }
1689: if ($coursepref) {
1690: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1691: }
1.124 matthew 1692: }
1.81 matthew 1693: } elsif ($pro =~ /^course_(.*)$/) {
1694: # Check for permissions inside of a course
1.295 raeburn 1695: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1696: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1697: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1698: )) {
1.209 www 1699: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1700: }
1.295 raeburn 1701: } elsif ($pro =~ /^community_(.*)$/) {
1702: # Check for permissions inside of a community
1703: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1704: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1705: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1706: )) {
1707: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1708: }
1.4 www 1709: } elsif ($pro eq 'author') {
1710: if ($author) {
1.152 albertel 1711: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1712: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1713: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1714: # Check that we are on the correct machine
1.29 matthew 1715: my $cadom=$requested_domain;
1.152 albertel 1716: my $caname=$env{'user.name'};
1.234 raeburn 1717: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1718: ($cadom,$caname)=
1.206 albertel 1719: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1720: }
1721: $act =~ s/\$caname/$caname/g;
1.353 www 1722: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 1723: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1724: my $allowed=0;
1725: my @ids=&Apache::lonnet::current_machine_ids();
1726: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1727: if ($allowed) {
1.209 www 1728: $output.=&switch($caname,$cadom,
1729: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1730: }
1.6 www 1731: }
1.2 www 1732: }
1.248 raeburn 1733: } elsif ($pro eq 'tools') {
1734: my @tools = ('aboutme','blog','portfolio');
1735: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1736: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1737: $env{'user.domain'},
1738: $prt,undef,'tools')) {
1739: $output.=&clear($row,$col);
1740: next;
1741: }
1.278 raeburn 1742: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1743: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1744: next;
1745: }
1746: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1747: next;
1748: }
1.279 raeburn 1749: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1750: if (!$showreqcrs) {
1.248 raeburn 1751: $output.=&clear($row,$col);
1752: next;
1753: }
1754: }
1755: $prt='any';
1756: $output.=&secondlevel(
1757: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1758: }
1.13 harris41 1759: }
1.369.2.17 raeburn 1760: if ($env{'environment.remote'} eq 'on') {
1761: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1762: if (&Apache::lonmsg::newmail()) {
1763: $output.='swmenu.setstatus("you have","messages");';
1764: }
1765: }
1.2 www 1766: return $output;
1767: }
1768:
1.279 raeburn 1769: sub check_for_rcrs {
1770: my $showreqcrs = 0;
1.280 raeburn 1771: my @reqtypes = ('official','unofficial','community');
1772: foreach my $type (@reqtypes) {
1.279 raeburn 1773: if (&Apache::lonnet::usertools_access($env{'user.name'},
1774: $env{'user.domain'},
1775: $type,undef,'requestcourses')) {
1776: $showreqcrs = 1;
1777: last;
1778: }
1779: }
1.280 raeburn 1780: if (!$showreqcrs) {
1781: foreach my $type (@reqtypes) {
1782: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1783: $showreqcrs = 1;
1784: last;
1785: }
1786: }
1787: }
1.279 raeburn 1788: return $showreqcrs;
1789: }
1790:
1.369.2.1 raeburn 1791: # ======================================================================= Close
1792:
1793: sub close {
1.369.2.17 raeburn 1794: unless ($env{'environment.remote'} eq 'on') { return ''; }
1.369.2.1 raeburn 1795: my $menuname = &get_menu_name();
1796: return(<<ENDCLOSE);
1797: <script type="text/javascript">
1798: // <![CDATA[
1799: window.status='Accessing Remote Control';
1800: menu=window.open("/adm/rat/empty.html","$menuname",
1801: "height=350,width=150,scrollbars=no,menubar=no");
1802: window.status='Disabling Remote Control';
1803: menu.active=0;
1804: menu.autologout=0;
1805: window.status='Closing Remote Control';
1806: menu.close();
1807: window.status='Done.';
1808: // ]]>
1809: </script>
1810: ENDCLOSE
1811: }
1812:
1.306 raeburn 1813: sub dc_popup_js {
1814: my %lt = &Apache::lonlocal::texthash(
1815: more => '(More ...)',
1816: less => '(Less ...)',
1817: );
1818: return <<"END";
1819:
1820: function showCourseID() {
1821: document.getElementById('dccid').style.display='block';
1822: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1823: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 1824: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 1825: return;
1826: }
1827:
1828: function hideCourseID() {
1829: document.getElementById('dccid').style.display='none';
1.369 raeburn 1830: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 1831: return;
1832: }
1833:
1834: END
1835:
1836: }
1837:
1.369.2.10 raeburn 1838: sub countdown_toggle_js {
1839: return <<"END";
1840:
1841: function toggleCountdown() {
1842: var countdownid = document.getElementById('duedatecountdown');
1843: var currstyle = countdownid.style.display;
1844: if (currstyle == 'inline') {
1845: countdownid.style.display = 'none';
1846: document.getElementById('ddcountcollapse').innerHTML='';
1847: document.getElementById('ddcountexpand').innerHTML='◄ ';
1848: } else {
1849: countdownid.style.display = 'inline';
1850: document.getElementById('ddcountcollapse').innerHTML='► ';
1851: document.getElementById('ddcountexpand').innerHTML='';
1852: }
1853: return;
1854: }
1855:
1856: END
1857: }
1858:
1.42 www 1859: sub utilityfunctions {
1.152 albertel 1860: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 droeschl 1861: if ($currenturl =~ m{^/adm/wrapper/ext/}
1862: && $env{'request.external.querystring'} ) {
1.293 raeburn 1863: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1864: }
1.183 www 1865: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1866:
1.152 albertel 1867: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.175 albertel 1868:
1.306 raeburn 1869: my $dc_popup_cid;
1870: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1871: $env{'course.'.$env{'request.course.id'}.
1872: '.domain'}.'/'})) {
1873: $dc_popup_cid = &dc_popup_js();
1874: }
1875:
1.175 albertel 1876: my $start_page_annotate =
1877: &Apache::loncommon::start_page('Annotator',undef,
1878: {'only_body' => 1,
1879: 'js_ready' => 1,
1880: 'bgcolor' => '#BBBBBB',
1881: 'add_entries' => {
1882: 'onload' => 'javascript:document.goannotate.submit();'}});
1883:
1.205 albertel 1884: my $end_page_annotate =
1885: &Apache::loncommon::end_page({'js_ready' => 1});
1886:
1.369.2.26 raeburn 1887: my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
1.336 raeburn 1888:
1.368 www 1889: my $esc_url=&escape($currenturl);
1890: my $esc_symb=&escape($currentsymb);
1.332 wenzelju 1891:
1.369.2.10 raeburn 1892: my $countdown = &countdown_toggle_js();
1893:
1.42 www 1894: return (<<ENDUTILITY)
1895:
1.368 www 1896: var currentURL=unescape("$esc_url");
1897: var reloadURL=unescape("$esc_url");
1898: var currentSymb=unescape("$esc_symb");
1.42 www 1899:
1.306 raeburn 1900: $dc_popup_cid
1.114 albertel 1901:
1.42 www 1902: function go(url) {
1903: if (url!='' && url!= null) {
1904: currentURL = null;
1905: currentSymb= null;
1906: window.location.href=url;
1907: }
1908: }
1909:
1.369.2.26 raeburn 1910: $jumptores
1.336 raeburn 1911:
1.42 www 1912: function gopost(url,postdata) {
1913: if (url!='') {
1914: this.document.server.action=url;
1915: this.document.server.postdata.value=postdata;
1916: this.document.server.command.value='';
1917: this.document.server.url.value='';
1918: this.document.server.symb.value='';
1919: this.document.server.submit();
1920: }
1921: }
1922:
1923: function gocmd(url,cmd) {
1924: if (url!='') {
1925: this.document.server.action=url;
1926: this.document.server.postdata.value='';
1927: this.document.server.command.value=cmd;
1928: this.document.server.url.value=currentURL;
1929: this.document.server.symb.value=currentSymb;
1930: this.document.server.submit();
1931: }
1.57 www 1932: }
1933:
1.121 raeburn 1934: function gocstr(url,filename) {
1935: if (url == '/adm/cfile?action=delete') {
1936: this.document.cstrdelete.filename.value = filename
1937: this.document.cstrdelete.submit();
1938: return;
1939: }
1.137 raeburn 1940: if (url == '/adm/printout') {
1941: this.document.cstrprint.postdata.value = filename
1942: this.document.cstrprint.curseed.value = 0;
1943: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1944: if (this.document.lonhomework) {
1945: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1946: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1947: }
1948: if (this.document.lonhomework.problemtype) {
1.164 albertel 1949: if (this.document.lonhomework.problemtype.value) {
1950: this.document.cstrprint.problemtype.value =
1951: this.document.lonhomework.problemtype.value;
1952: } else if (this.document.lonhomework.problemtype.options) {
1953: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1954: if (this.document.lonhomework.problemtype.options[i].selected) {
1955: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1956: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1957: }
1958: }
1959: }
1960: }
1961: }
1962: }
1.137 raeburn 1963: this.document.cstrprint.submit();
1964: return;
1965: }
1.121 raeburn 1966: if (url !='') {
1967: this.document.constspace.filename.value = filename;
1968: this.document.constspace.action = url;
1969: this.document.constspace.submit();
1970: }
1971: }
1972:
1.131 raeburn 1973: function golist(url) {
1974: if (url!='' && url!= null) {
1975: currentURL = null;
1976: currentSymb= null;
1977: top.location.href=url;
1978: }
1979: }
1980:
1981:
1.121 raeburn 1982:
1.57 www 1983: function catalog_info() {
1.365 www 1984: openMyModal(window.location.pathname+'.meta',500,400,'yes');
1.57 www 1985: }
1986:
1987: function chat_win() {
1.290 raeburn 1988: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1989: }
1.169 raeburn 1990:
1991: function group_chat(group) {
1992: var url = '/adm/groupchat?group='+group;
1993: var winName = 'LONchat_'+group;
1994: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1995: }
1.175 albertel 1996:
1997: function annotate() {
1998: w_Annotator_flag=1;
1999: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
2000: annotator.document.write(
2001: '$start_page_annotate'
2002: +"<form name='goannotate' target='Annotator' method='post' "
2003: +"action='/adm/annotations'>"
1.217 albertel 2004: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 2005: +"<\\/form>"
1.205 albertel 2006: +'$end_page_annotate');
1.175 albertel 2007: annotator.document.close();
2008: }
2009:
1.369.2.8 raeburn 2010: function open_StoredLinks_Import(rat) {
2011: var newWin;
2012: if (rat) {
2013: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
2014: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
2015: }
2016: else {
2017: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
2018: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
2019: }
2020: newWin.focus();
2021: }
2022:
1.369.2.4 raeburn 2023: (function (\$) {
2024: \$(document).ready(function () {
2025: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
2026: /*\@cc_on
2027: if (!window.XMLHttpRequest) {
2028: \$('.LC_hoverable').each(function () {
2029: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
2030: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
2031: });
2032: }
2033: \@*/
2034: });
2035: }(jQuery));
2036:
1.369.2.10 raeburn 2037: $countdown
2038:
1.42 www 2039: ENDUTILITY
2040: }
2041:
2042: sub serverform {
2043: return(<<ENDSERVERFORM);
1.181 albertel 2044: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 2045: <input type="hidden" name="postdata" value="none" />
2046: <input type="hidden" name="command" value="none" />
2047: <input type="hidden" name="url" value="none" />
2048: <input type="hidden" name="symb" value="none" />
2049: </form>
2050: ENDSERVERFORM
2051: }
1.113 albertel 2052:
1.121 raeburn 2053: sub constspaceform {
2054: return(<<ENDCONSTSPACEFORM);
1.181 albertel 2055: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 2056: <input type="hidden" name="filename" value="" />
2057: </form>
1.181 albertel 2058: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 2059: <input type="hidden" name="action" value="delete" />
2060: <input type="hidden" name="filename" value="" />
2061: </form>
1.181 albertel 2062: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 2063: <input type="hidden" name="postdata" value="" />
2064: <input type="hidden" name="curseed" value="" />
2065: <input type="hidden" name="problemtype" value="" />
2066: </form>
2067:
1.121 raeburn 2068: ENDCONSTSPACEFORM
2069: }
2070:
1.369.2.17 raeburn 2071: sub get_nav_status {
2072: my $navstatus="swmenu.w_loncapanav_flag=";
2073: if ($env{'environment.remotenavmap'} eq 'on') {
2074: $navstatus.="1";
2075: } else {
2076: $navstatus.="-1";
2077: }
2078: return $navstatus;
2079: }
2080:
1.220 raeburn 2081: sub hidden_button_check {
1.317 droeschl 2082: if ( $env{'request.course.id'} eq ''
2083: || $env{'request.role.adv'} ) {
2084:
1.220 raeburn 2085: return;
2086: }
1.232 raeburn 2087: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
2088: return $buttonshide;
1.220 raeburn 2089: }
1.184 raeburn 2090:
1.235 raeburn 2091: sub roles_selector {
2092: my ($cdom,$cnum) = @_;
1.298 raeburn 2093: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 2094: my $now = time;
1.350 raeburn 2095: my (%courseroles,%seccount,%courseprivs);
1.235 raeburn 2096: my $is_cc;
1.369.2.30 raeburn 2097: my ($js,$form,$switcher,$switchtext);
1.298 raeburn 2098: my $ccrole;
2099: if ($crstype eq 'Community') {
2100: $ccrole = 'co';
2101: } else {
2102: $ccrole = 'cc';
1.350 raeburn 2103: }
1.369.2.23 raeburn 2104: my ($priv,$gotsymb,$destsymb);
1.350 raeburn 2105: my $destinationurl = $ENV{'REQUEST_URI'};
1.369.2.23 raeburn 2106: if ($destinationurl =~ /\?symb=/) {
2107: $gotsymb = 1;
2108: } elsif ($destinationurl =~ m{^/enc/}) {
2109: my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
2110: if ($plainurl =~ /\?symb=/) {
2111: $gotsymb = 1;
2112: }
2113: }
2114: unless ($gotsymb) {
2115: $destsymb = &Apache::lonnet::symbread();
2116: if ($destsymb ne '') {
2117: $destsymb = &Apache::lonenc::check_encrypt($destsymb);
2118: }
2119: }
1.350 raeburn 2120: my $reqprivs = &required_privs();
2121: if (ref($reqprivs) eq 'HASH') {
2122: my $destination = $destinationurl;
2123: $destination =~ s/(\?.*)$//;
2124: if (exists($reqprivs->{$destination})) {
2125: $priv = $reqprivs->{$destination};
2126: }
2127: }
1.298 raeburn 2128: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
2129: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 2130:
2131: if ((($start) && ($start<0)) ||
2132: (($end) && ($end<$now)) ||
2133: (($start) && ($now<$start))) {
2134: $is_cc = 0;
2135: } else {
2136: $is_cc = 1;
2137: }
2138: }
2139: if ($is_cc) {
1.350 raeburn 2140: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
1.235 raeburn 2141: } else {
1.262 raeburn 2142: my %gotnosection;
1.235 raeburn 2143: foreach my $item (keys(%env)) {
1.239 raeburn 2144: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 2145: my $role = $1;
2146: my $sec = $2;
2147: next if ($role eq 'gr');
2148: my ($start,$end) = split(/\./,$env{$item});
2149: next if (($start && $start > $now) || ($end && $end < $now));
2150: if ($sec eq '') {
1.239 raeburn 2151: if (!$gotnosection{$role}) {
2152: $seccount{$role} ++;
2153: $gotnosection{$role} = 1;
2154: }
1.235 raeburn 2155: }
1.350 raeburn 2156: if ($priv ne '') {
2157: my $cnumsec = $cnum;
2158: if ($sec ne '') {
2159: $cnumsec .= "/$sec";
2160: }
2161: $courseprivs{"$role./$cdom/$cnumsec./"} =
2162: $env{"user.priv.$role./$cdom/$cnumsec./"};
2163: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
2164: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
2165: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
2166: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
2167: }
1.235 raeburn 2168: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 2169: if ($sec ne '') {
1.264 raeburn 2170: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 2171: push(@{$courseroles{$role}},$sec);
2172: $seccount{$role} ++;
2173: }
2174: }
2175: } else {
2176: @{$courseroles{$role}} = ();
2177: if ($sec ne '') {
2178: $seccount{$role} ++;
1.235 raeburn 2179: push(@{$courseroles{$role}},$sec);
2180: }
2181: }
2182: }
2183: }
2184: }
1.286 raeburn 2185: my $switchtext;
2186: if ($crstype eq 'Community') {
1.369.2.30 raeburn 2187: $switchtext = &mt('Switch community role')
1.286 raeburn 2188: } else {
1.369.2.30 raeburn 2189: $switchtext = &mt('Switch course role')
1.286 raeburn 2190: }
1.298 raeburn 2191: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.369.2.30 raeburn 2192: my $numdiffsec;
2193: if (keys(%seccount) == 1) {
2194: foreach my $key (keys(%seccount)) {
2195: $numdiffsec = $seccount{$key};
2196: }
2197: }
2198: if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
2199: my @submenu;
2200: $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
2201: $form =
2202: '<form name="rolechooser" method="post" action="/adm/roles">'."\n".
2203: ' <input type="hidden" name="destinationurl" value="'.
2204: &HTML::Entities::encode($destinationurl).'" />'."\n".
2205: ' <input type="hidden" name="gotorole" value="1" />'."\n".
2206: ' <input type="hidden" name="selectrole" value="" />'."\n".
2207: ' <input type="hidden" name="switchrole" value="" />'."\n";
2208: if ($destsymb ne '') {
2209: $form .= ' <input type="hidden" name="destsymb" value="'.
2210: &HTML::Entities::encode($destsymb).'" />'."\n";
2211: }
2212: $form .= '</form>'."\n";
1.235 raeburn 2213: foreach my $role (@roles_order) {
1.369.2.30 raeburn 2214: my $include;
1.235 raeburn 2215: if (defined($courseroles{$role})) {
1.369.2.30 raeburn 2216: if ($env{'request.role'} =~ m{^\Q$role\E}) {
2217: if ($seccount{$role} > 1) {
2218: $include = 1;
2219: }
2220: } else {
2221: $include = 1;
2222: }
2223: }
2224: if ($include) {
2225: push(@submenu,['javascript:adhocRole('."'$role'".')',
2226: &Apache::lonnet::plaintext($role,$crstype)]);
1.235 raeburn 2227: }
2228: }
2229: foreach my $role (sort(keys(%courseroles))) {
2230: if ($role =~ /^cr/) {
1.369.2.30 raeburn 2231: my $include;
2232: if ($env{'request.role'} =~ m{^\Q$role\E}) {
2233: if ($seccount{$role} > 1) {
2234: $include = 1;
2235: }
2236: } else {
2237: $include = 1;
2238: }
2239: if ($include) {
2240: push(@submenu,['javascript:adhocRole('."'$role'".')',
2241: &Apache::lonnet::plaintext($role)]);
2242: }
1.235 raeburn 2243: }
2244: }
1.369.2.30 raeburn 2245: if (@submenu > 0) {
2246: $switcher = &create_submenu('','',$switchtext,\@submenu);
1.369.2.23 raeburn 2247: }
1.235 raeburn 2248: }
1.369.2.30 raeburn 2249: return ($js,$form,$switcher);
1.235 raeburn 2250: }
2251:
1.262 raeburn 2252: sub get_all_courseroles {
1.350 raeburn 2253: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 2254: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 2255: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 2256: return;
2257: }
2258: my ($result,$cached) =
2259: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
2260: if (defined($cached)) {
2261: if (ref($result) eq 'HASH') {
2262: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 2263: (ref($result->{'seccount'}) eq 'HASH') &&
2264: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 2265: %{$courseroles} = %{$result->{'roles'}};
2266: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 2267: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 2268: return;
2269: }
2270: }
2271: }
2272: my %gotnosection;
2273: my %adv_roles =
2274: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2275: foreach my $role (keys(%adv_roles)) {
2276: my ($urole,$usec) = split(/:/,$role);
2277: if (!$gotnosection{$urole}) {
2278: $seccount->{$urole} ++;
2279: $gotnosection{$urole} = 1;
2280: }
2281: if (ref($courseroles->{$urole}) eq 'ARRAY') {
2282: if ($usec ne '') {
2283: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
2284: push(@{$courseroles->{$urole}},$usec);
2285: $seccount->{$urole} ++;
2286: }
2287: }
2288: } else {
2289: @{$courseroles->{$urole}} = ();
2290: if ($usec ne '') {
2291: $seccount->{$urole} ++;
2292: push(@{$courseroles->{$urole}},$usec);
2293: }
2294: }
1.350 raeburn 2295: my $area = '/'.$cdom.'/'.$cnum;
2296: if ($usec ne '') {
2297: $area .= '/'.$usec;
2298: }
2299: if ($role =~ /^cr\//) {
2300: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
2301: } else {
2302: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
2303: }
1.262 raeburn 2304: }
2305: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
2306: @{$courseroles->{'st'}} = ();
1.350 raeburn 2307: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 2308: if (keys(%sections_count) > 0) {
2309: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 2310: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 2311: }
2312: my $rolehash = {
2313: 'roles' => $courseroles,
2314: 'seccount' => $seccount,
1.350 raeburn 2315: 'privs' => $courseprivs,
1.262 raeburn 2316: };
2317: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
2318: return;
2319: }
2320:
1.235 raeburn 2321: sub jump_to_role {
1.350 raeburn 2322: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
1.239 raeburn 2323: my %lt = &Apache::lonlocal::texthash(
2324: this => 'This role has section(s) associated with it.',
2325: ente => 'Enter a specific section.',
2326: orlb => 'Enter a specific section, or leave blank for no section.',
2327: avai => 'Available sections are:',
2328: youe => 'You entered an invalid section choice:',
1.352 raeburn 2329: plst => 'Please try again.',
1.350 raeburn 2330: role => 'The role you selected is not permitted to view the current page.',
2331: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 2332: );
2333: my $js;
2334: if (ref($courseroles) eq 'HASH') {
2335: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
2336: ' var numsec = new Array();'."\n".
2337: ' var rolesections = new Array();'."\n".
2338: ' var rolenames = new Array();'."\n".
2339: ' var roleseclist = new Array();'."\n";
2340: my @items = keys(%{$courseroles});
2341: for (my $i=0; $i<@items; $i++) {
2342: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
2343: my ($secs,$secstr);
2344: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
2345: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
2346: $secs = join('","',@sections);
2347: $secstr = join(', ',@sections);
2348: }
2349: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
2350: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
2351: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
2352: }
2353: }
1.350 raeburn 2354: my $checkroles = 0;
2355: if ($priv && ref($courseprivs) eq 'HASH') {
2356: my (%disallowed,%allowed,@disallow);
2357: foreach my $role (sort(keys(%{$courseprivs}))) {
2358: my $trole;
2359: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
2360: $trole = $1;
2361: }
2362: if (($trole ne '') && ($trole ne 'cm')) {
2363: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
2364: $allowed{$trole} = 1;
2365: } else {
2366: $disallowed{$trole} = 1;
2367: }
2368: }
2369: }
2370: foreach my $trole (keys(%disallowed)) {
2371: unless ($allowed{$trole}) {
2372: push(@disallow,$trole);
2373: }
2374: }
2375: if (@disallow > 0) {
2376: $checkroles = 1;
2377: $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
2378: " var rolecheck = 1;\n";
2379: }
2380: }
2381: if (!$checkroles) {
2382: $js .= " var disallow = new Array();\n".
2383: " rolecheck = 0;\n";
2384: }
1.273 droeschl 2385: return <<"END";
1.235 raeburn 2386: <script type="text/javascript">
1.273 droeschl 2387: //<![CDATA[
1.369.2.30 raeburn 2388: function adhocRole(newrole) {
1.239 raeburn 2389: $js
1.235 raeburn 2390: if (newrole == '') {
1.350 raeburn 2391: return;
1.235 raeburn 2392: }
1.239 raeburn 2393: var fullrole = newrole+'./$cdom/$cnum';
2394: var selidx = '';
2395: for (var i=0; i<rolenames.length; i++) {
2396: if (rolenames[i] == newrole) {
2397: selidx = i;
2398: }
2399: }
1.350 raeburn 2400: if (rolecheck > 0) {
2401: for (var i=0; i<disallow.length; i++) {
2402: if (disallow[i] == newrole) {
2403: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
2404: document.rolechooser.destinationurl.value = '/adm/menu';
2405: } else {
2406: return;
2407: }
2408: }
2409: }
2410: }
1.239 raeburn 2411: var secok = 1;
2412: var secchoice = '';
2413: if (selidx >= 0) {
2414: if (numsec[selidx] > 1) {
2415: secok = 0;
2416: var numrolesec = rolesections[selidx].length;
2417: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 2418: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 2419: if (secchoice == '') {
2420: if (msgidx > 0) {
2421: secok = 1;
2422: }
2423: } else {
2424: for (var j=0; j<rolesections[selidx].length; j++) {
2425: if (rolesections[selidx][j] == secchoice) {
2426: secok = 1;
2427: }
2428: }
2429: }
2430: } else {
2431: if (rolesections[selidx].length == 1) {
2432: secchoice = rolesections[selidx][0];
2433: }
2434: }
2435: }
2436: if (secok == 1) {
2437: if (secchoice != '') {
2438: fullrole += '/'+secchoice;
2439: }
2440: } else {
2441: document.rolechooser.elements[roleitem].selectedIndex = 0;
2442: if (secchoice != null) {
2443: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
2444: }
2445: return;
2446: }
2447: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 2448: return;
2449: }
2450: itemid = retrieveIndex('gotorole');
2451: if (itemid != -1) {
1.239 raeburn 2452: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 2453: }
1.369.2.30 raeburn 2454: document.rolechooser.switchrole.value = fullrole;
1.235 raeburn 2455: document.rolechooser.selectrole.value = '1';
2456: document.rolechooser.submit();
2457: return;
2458: }
2459:
2460: function retrieveIndex(item) {
2461: for (var i=0;i<document.rolechooser.elements.length;i++) {
2462: if (document.rolechooser.elements[i].name == item) {
2463: return i;
2464: }
2465: }
2466: return -1;
2467: }
1.273 droeschl 2468: // ]]>
1.235 raeburn 2469: </script>
2470: END
2471: }
2472:
1.350 raeburn 2473: sub required_privs {
2474: my $privs = {
2475: '/adm/parmset' => 'opa',
2476: '/adm/courseprefs' => 'opa',
2477: '/adm/whatsnew' => 'whn',
2478: '/adm/populate' => 'cst',
2479: '/adm/trackstudent' => 'vsa',
2480: '/adm/statistics' => 'vgr',
1.366 raeburn 2481: '/adm/setblock' => 'dcm',
1.367 raeburn 2482: '/adm/coursedocs' => 'mdc',
1.350 raeburn 2483: };
2484: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 2485: $privs->{'/adm/classcalc'} = 'vgr',
2486: $privs->{'/adm/assesscalc'} = 'vgr',
2487: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 2488: }
2489: return $privs;
2490: }
1.235 raeburn 2491:
1.369.2.10 raeburn 2492: sub countdown_timer {
2493: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
1.369.2.24 raeburn 2494: ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
2495: my ($type,$hastimeleft,$slothastime);
2496: my $now = time;
2497: if ($env{'request.filename'} =~ /\.task$/) {
2498: $type = 'Task';
2499: } else {
2500: $type = 'problem';
2501: }
2502: my ($status,$accessmsg,$slot_name,$slot) =
2503: &Apache::lonhomework::check_slot_access('0',$type);
2504: if ($slot_name ne '') {
2505: if (ref($slot) eq 'HASH') {
2506: if (($slot->{'starttime'} < $now) &&
2507: ($slot->{'endtime'} > $now)) {
2508: $slothastime = 1;
2509: }
2510: }
2511: }
2512: if ($status ne 'CAN_ANSWER') {
2513: return;
2514: }
1.369.2.10 raeburn 2515: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.369.2.12 raeburn 2516: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.369.2.13 raeburn 2517: my $hastimeleft;
2518: if (@interval > 1) {
2519: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
2520: if ($first_access > 0) {
2521: if ($first_access+$interval[0] > time) {
2522: $hastimeleft = 1;
2523: }
2524: }
2525: }
1.369.2.12 raeburn 2526: if (($duedate && $duedate > time) ||
1.369.2.24 raeburn 2527: (!$duedate && $hastimeleft) ||
2528: ($slot_name ne '' && $slothastime)) {
1.369.2.11 raeburn 2529: my ($collapse,$expand,$alttxt,$title,$currdisp);
1.369.2.24 raeburn 2530: if ((@interval > 1 && $hastimeleft) ||
2531: ($type eq 'Task' && $slothastime)) {
1.369.2.10 raeburn 2532: $currdisp = 'inline';
2533: $collapse = '► ';
2534: } else {
2535: $currdisp = 'none';
2536: $expand = '◄ ';
2537: }
2538: unless ($env{'environment.icons'} eq 'iconsonly') {
1.369.2.11 raeburn 2539: $alttxt = &mt('Timer');
2540: $title = $alttxt.' ';
1.369.2.10 raeburn 2541: }
2542: my $desc = &mt('Countdown to due date/time');
2543: return <<END;
2544:
2545: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2546: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
2547: $collapse
1.369.2.11 raeburn 2548: </span></a>
1.369.2.10 raeburn 2549: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
2550: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2551: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.369.2.11 raeburn 2552: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1.369.2.10 raeburn 2553: END
2554: }
2555: }
2556: return;
2557: }
2558:
1.2 www 2559: # ================================================================ Main Program
2560:
1.16 harris41 2561: BEGIN {
1.166 albertel 2562: if (! defined($readdesk)) {
1.283 droeschl 2563: {
2564: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2565: if ( CORE::open( my $config,"<$tabfile") ) {
2566: while (my $configline=<$config>) {
2567: $configline=(split(/\#/,$configline))[0];
2568: $configline=~s/^\s+//;
2569: chomp($configline);
1.209 www 2570: if ($configline=~/^cat\:/) {
1.283 droeschl 2571: my @entries=split(/\:/,$configline);
2572: $category_positions{$entries[2]}=$entries[1];
2573: $category_names{$entries[2]}=$entries[3];
2574: } elsif ($configline=~/^prim\:/) {
2575: my @entries = (split(/\:/, $configline))[1..5];
1.369.2.30 raeburn 2576: push(@primary_menu,\@entries);
1.369.2.3 raeburn 2577: } elsif ($configline=~/^primsub\:/) {
2578: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
1.369.2.30 raeburn 2579: push(@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 2580: } elsif ($configline=~/^scnd\:/) {
2581: my @entries = (split(/\:/, $configline))[1..5];
1.369.2.30 raeburn 2582: push(@secondary_menu,\@entries);
1.369.2.5 raeburn 2583: } elsif ($configline=~/^scndsub\:/) {
2584: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
1.369.2.30 raeburn 2585: push(@{$secondary_submenu{$parent}},\@entries);
1.283 droeschl 2586: } elsif ($configline) {
2587: push(@desklines,$configline);
2588: }
2589: }
2590: CORE::close($config);
2591: }
2592: }
2593: $readdesk='done';
1.2 www 2594: }
2595: }
1.30 www 2596:
1.1 www 2597: 1;
2598: __END__
2599:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>