Annotation of loncom/interface/lonmenu.pm, revision 1.561
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.561 ! raeburn 4: # $Id: lonmenu.pm,v 1.560 2025/01/07 22:21:56 raeburn Exp $
1.11 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 www 28: #
29:
1.244 jms 30: =head1 NAME
31:
32: Apache::lonmenu
33:
34: =head1 SYNOPSIS
35:
1.371 raeburn 36: Loads contents of /home/httpd/lonTabs/mydesk.tab,
37: used to generate inline menu, and Main Menu page.
1.244 jms 38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.314 droeschl 42: =head1 GLOBAL VARIABLES
43:
44: =over
45:
46: =item @desklines
47:
48: Each element of this array contains a line of mydesk.tab that doesn't start with
49: cat, prim or scnd.
50: It gets filled in the BEGIN block of this module.
51:
52: =item %category_names
53:
54: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
55: start with cat, the values are strings representing titles.
56: It gets filled in the BEGIN block of this module.
57:
58: =item %category_members
59:
60: TODO
61:
62: =item %category_positions
63:
64: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
65: start with cat, its values are position vectors (column, row).
66: It gets filled in the BEGIN block of this module.
67:
68: =item $readdesk
69:
70: Indicates that mydesk.tab has been read.
71: It is set to 'done' in the BEGIN block of this module.
72:
73: =item @primary_menu
74:
75: The elements of this array reference arrays that are made up of the components
1.371 raeburn 76: of those lines of mydesk.tab that start with prim:.
1.314 droeschl 77: It is used by primary_menu() to generate the corresponding menu.
78: It gets filled in the BEGIN block of this module.
79:
1.371 raeburn 80: =item %primary_sub_menu
81:
82: The keys of this hash reference are the names of items in the primary_menu array
83: which have sub-menus. For each key, the corresponding value is a reference to
84: an array containing components extracted from lines in mydesk.tab which begin
85: with primsub:.
86: This hash, which is used by primary_menu to generate sub-menus, is populated in
87: the BEGIN block.
88:
1.314 droeschl 89: =item @secondary_menu
90:
91: The elements of this array reference arrays that are made up of the components
92: of those lines of mydesk.tab that start with scnd.
93: It is used by secondary_menu() to generate the corresponding menu.
94: It gets filled in the BEGIN block of this module.
95:
96: =back
97:
1.244 jms 98: =head1 SUBROUTINES
99:
100: =over
101:
1.521 raeburn 102: =item prep_menuitems(\@menuitem,$target,$listclass,$linkattr)
1.314 droeschl 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:
1.415 raeburn 109: This routine evaluates @primary_menu and returns a two item array,
110: with the array elements containing XHTML for the left and right sides of
111: the menu that contains the following links: About, Message, Roles, Help, Logout
1.314 droeschl 112: @primary_menu is filled within the BEGIN block of this module with
1.415 raeburn 113: entries from mydesk.tab
1.314 droeschl 114:
115: =item secondary_menu()
116:
117: Same as primary_menu() but operates on @secondary_menu.
118:
1.375 raeburn 119: =item create_submenu()
120:
121: Creates XHTML for unordered list of sub-menu items which belong to a
122: particular top-level menu item. Uses hover pseudo class in css to display
123: dropdown list when mouse hovers over top-level item. Support for IE6
124: (no hover psuedo class) via LC_hoverable class for <li> tag for top-
125: level item, which employs jQuery to handle behavior on mouseover.
126:
1.447 raeburn 127: Inputs: 6 - (a) link and (b) target for anchor href in top level item,
128: (c) title for text wrapped by anchor tag in top level item,
129: (d) reference to array of arrays of sub-menu items,
130: (e) boolean to indicate whether to call &mt() to translate
131: name of menu item,
132: (f) optional class for <li> element in primary menu, for which
133: sub menu is being generated.
1.375 raeburn 134:
1.431 golterma 135: The underlying datastructure used in (d) contains data from mydesk.tab.
136: It consists of an array which has an array for each item appearing in
137: the menu (e.g. [["link", "title", "condition"]] for a single-item menu).
138: create_submenu() supports also the creation of XHTML for nested dropdown
139: menus represented by unordered lists. This is done by replacing the
140: scalar used for the link with an arrayreference containing the menuitems
141: for the nested menu. This can be done recursively so that the next menu
142: may also contain nested submenus.
143:
144: Example:
145: [ # begin of datastructure
146: ["/home/", "Home", "condition1"], # 1st item of the 1st layer menu
147: [ # 2nd item of the 1st layer menu
148: [ # anon. array for nested menu
149: ["/path1", "Path1", undef], # 1st item of the 2nd layer menu
150: ["/path2", "Path2", undef], # 2nd item of the 2nd layer menu
151: [ # 3rd item of the 2nd layer menu
152: [[...], [...], ..., [...]], # containing another menu layer
153: "Sub-Sub-Menu", # title for this container
154: undef
155: ]
156: ], # end of array/nested menu
157: "Sub-Menu", # title for the container item
158: undef
159: ] # end of 2nd item of the 1st layer menu
160: ]
161:
1.244 jms 162: =item innerregister()
163:
1.320 droeschl 164: This gets called in order to register a URL in the body of the document
1.244 jms 165:
166: =item clear()
167:
168: =item switch()
169:
170: Switch a button or create a link
171: Switch acts on the javascript that is executed when a button is clicked.
172: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
173:
174: =item secondlevel()
175:
176: =item openmenu()
177:
178: =item inlinemenu()
179:
180: =item rawconfig()
181:
182: =item utilityfunctions()
183:
1.371 raeburn 184: Output from this routine is a number of javascript functions called by
185: items in the inline menu, and in some cases items in the Main Menu page.
186:
1.244 jms 187: =item serverform()
188:
189: =item constspaceform()
190:
191: =item get_nav_status()
192:
193: =item hidden_button_check()
194:
195: =item roles_selector()
196:
197: =item jump_to_role()
198:
199: =back
200:
201: =cut
202:
1.1 www 203: package Apache::lonmenu;
204:
205: use strict;
1.152 albertel 206: use Apache::lonnet;
1.47 matthew 207: use Apache::lonhtmlcommon();
1.115 albertel 208: use Apache::loncommon();
1.127 albertel 209: use Apache::lonenc();
1.88 www 210: use Apache::lonlocal;
1.361 raeburn 211: use Apache::lonmsg();
1.207 foxr 212: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 213: use HTML::Entities();
1.346 wenzelju 214: use Apache::lonwishlist();
1.88 www 215:
1.283 droeschl 216: use vars qw(@desklines %category_names %category_members %category_positions
1.482 raeburn 217: $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
1.88 www 218:
1.56 www 219: my @inlineremote;
1.38 www 220:
1.283 droeschl 221: sub prep_menuitem {
1.521 raeburn 222: my ($menuitem,$target,$listclass,$linkattr) = @_;
1.291 raeburn 223: return '' unless(ref($menuitem) eq 'ARRAY');
1.521 raeburn 224: my ($link,$targetattr);
1.283 droeschl 225: if ($$menuitem[1]) { # graphical Link
226: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 227: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
228: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 229: } else { # textual Link
1.291 raeburn 230: $link = &mt($$menuitem[3]);
231: }
1.521 raeburn 232: if ($target ne '') {
233: $targetattr = ' target="'.$target.'"';
1.486 raeburn 234: }
1.511 raeburn 235: return ($listclass?'<li class="'.$listclass.'">':'<li>').'<a'
1.316 droeschl 236: # highlighting for new messages
237: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
1.521 raeburn 238: . qq| href="$$menuitem[0]"$targetattr $linkattr>$link</a></li>|;
1.283 droeschl 239: }
240:
1.415 raeburn 241: # primary_menu() evaluates @primary_menu and returns a two item array,
242: # with the array elements containing XHTML for the left and right sides of
243: # the menu that contains the following links:
244: # Personal, About, Message, Roles, Help, Logout
1.283 droeschl 245: # @primary_menu is filled within the BEGIN block of this module with
246: # entries from mydesk.tab
247: sub primary_menu {
1.542 raeburn 248: my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target,$collapsible) = @_;
1.507 raeburn 249: my (%menu,%ltiexc,%menuopts);
1.283 droeschl 250: # each element of @primary contains following array:
1.415 raeburn 251: # (link url, icon path, alt text, link text, condition, position)
1.319 raeburn 252: my $public;
253: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
254: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
255: $public = 1;
256: }
1.443 raeburn 257: my $rolecount;
258: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
259: my $update=$env{'user.update.time'};
260: if (!$update) {
261: $update = $env{'user.login.time'};
262: }
263: my %roles_in_env;
264: $rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
265: }
1.521 raeburn 266: my $lti;
1.486 raeburn 267: if ($env{'request.lti.login'}) {
1.491 raeburn 268: $lti = 1;
269: if (ref($ltimenu) eq 'HASH') {
270: foreach my $item ('fullname','logout') {
271: unless ($ltimenu->{$item}) {
272: $ltiexc{$item} = 1;
273: }
274: }
275: }
1.486 raeburn 276: }
1.521 raeburn 277: my ($listclass,$linkattr,$target);
278: if ($links_disabled) {
279: $listclass = 'LCisDisabled';
280: $linkattr = 'aria-disabled="true"';
281: }
282: if ($links_target ne '') {
283: $target = $links_target;
284: } else {
285: my ($ltitarget,$deeplinktarget);
286: if ($env{'request.lti.login'}) {
287: $ltitarget = $env{'request.lti.target'};
288: }
289: if ($env{'request.deeplink.login'}) {
290: $deeplinktarget = $env{'request.deeplink.target'};
291: }
292: if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
293: $target = '_self';
294: } else {
295: $target = '_top';
296: }
1.516 raeburn 297: }
1.507 raeburn 298: if (($menucoll) && (ref($menuref) eq 'HASH')) {
299: %menuopts = %{$menuref};
300: }
1.283 droeschl 301: foreach my $menuitem (@primary_menu) {
302: # evaluate conditions
1.296 droeschl 303: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 304: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 305: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 306: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 307: && !&Apache::lonmsg::mynewmail(); #
1.319 raeburn 308: next if $$menuitem[4] !~ /public/ ##we've a public user,
309: && $public; ##who should not see all
310: ##links
1.283 droeschl 311: next if $$menuitem[4] eq 'onlypublic'# hide links which are
1.319 raeburn 312: && !$public; # only visible to public
313: # users
1.283 droeschl 314: next if $$menuitem[4] eq 'roles' ##show links depending on
1.491 raeburn 315: && (&Apache::loncommon::show_course() ##term 'Courses' or
1.509 raeburn 316: || $lti); ##'Roles' wanted
1.491 raeburn 317: next if $$menuitem[4] eq 'courses' ##and not LTI access
318: && (!&Apache::loncommon::show_course()
1.509 raeburn 319: || $lti);
1.491 raeburn 320: next if $$menuitem[4] eq 'notlti'
321: && $lti;
322: next if $$menuitem[4] eq 'ltiexc'
323: && exists($ltiexc{lc($menuitem->[3])});
1.371 raeburn 324: my $title = $menuitem->[3];
1.443 raeburn 325: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
326: if ($menuitem->[4] eq 'courses') {
327: next unless ($rolecount>1);
328: } else {
329: next unless (($title eq 'Personal') || ($title eq 'Logout'));
330: }
331: }
1.415 raeburn 332: my $position = $menuitem->[5];
333: if ($position eq '') {
334: $position = 'right';
335: }
1.507 raeburn 336: if ($env{'request.course.id'} && $menucoll) {
1.508 raeburn 337: if (($menuitem->[6]) && (!$menuopts{$menuitem->[6]})) {
338: if ($menuitem->[6] eq 'pers') {
339: if ($menuopts{'name'} && !$ltiexc{'fullname'} &&
340: $env{'user.name'} && $env{'user.domain'}) {
341: $menu{$position} .= '<li><a href="#">'.
342: &Apache::loncommon::plainname($env{'user.name'},
343: $env{'user.domain'}).'</a></li>';
344: next;
345: } else {
346: next;
347: }
348: } else {
349: next;
350: }
351: }
1.507 raeburn 352: }
1.371 raeburn 353: if (defined($primary_submenu{$title})) {
1.521 raeburn 354: my $link;
1.371 raeburn 355: if ($menuitem->[0] ne '') {
356: $link = $menuitem->[0];
357: } else {
358: $link = '#';
359: }
1.375 raeburn 360: my @primsub;
1.371 raeburn 361: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.375 raeburn 362: foreach my $item (@{$primary_submenu{$title}}) {
1.443 raeburn 363: next if (($crstype eq 'Placement') && (!$env{'request.role.adv'}));
1.383 raeburn 364: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.375 raeburn 365: next if ((($item->[2] eq 'portfolio') ||
366: ($item->[2] eq 'blog')) &&
367: (!&Apache::lonnet::usertools_access('','',$item->[2],
368: undef,'tools')));
1.543 raeburn 369: if (($item->[2] eq 'browsepub') && ($item->[0] eq '/res/')) {
370: if ($env{'request.role'} =~ /^au\./) {
371: $item->[0] .= $env{'request.role.domain'}.'/?launch=1';
372: } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
373: $item->[0] .= $1.'/'.$2.'/?launch=1';
374: } elsif (&Apache::lonnet::allowed('bre',$env{'user.domain'})) {
375: $item->[0] .= $env{'user.domain'}.'/?launch=1';
376: } elsif (&Apache::lonnet::allowed('bro','/res/')) {
377: $item->[0] .= '?launch=1';
378: } else {
379: next;
380: }
1.546 raeburn 381: }
1.507 raeburn 382: if ($env{'request.course.id'} && $menucoll) {
383: next if ($item->[3]) && (!$menuopts{$item->[3]});
384: }
1.375 raeburn 385: push(@primsub,$item);
386: }
1.508 raeburn 387: if ($title eq 'Personal') {
388: if ($env{'user.name'} && $env{'user.domain'} && !$ltiexc{'fullname'}) {
389: unless (($env{'request.course.id'}) && ($menucoll) && (!$menuopts{'name'})) {
390: $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
391: }
1.491 raeburn 392: }
1.508 raeburn 393: next if (($env{'request.course.id'}) && ($menucoll) && ($title eq 'Personal') &&
394: (!@primsub));
1.511 raeburn 395: if ($title eq 'Personal') {
396: $title = &mt($title);
397: }
1.443 raeburn 398: } else {
399: $title = &mt($title);
400: }
1.375 raeburn 401: if (@primsub > 0) {
1.511 raeburn 402: $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1,undef,$listclass,$linkattr);
1.375 raeburn 403: } elsif ($link) {
1.511 raeburn 404: $menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>').
405: '<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'.$title.'</a></li>';
1.371 raeburn 406: }
407: }
408: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.443 raeburn 409: next if ($crstype eq 'Placement');
1.340 raeburn 410: if ($public) {
411: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
412: my $defdom = &Apache::lonnet::default_login_domain();
413: my $to = &Apache::loncommon::build_recipient_list(undef,
414: 'helpdeskmail',
415: $defdom,$origmail);
416: if ($to ne '') {
1.521 raeburn 417: $menu{$position} .= &prep_menuitem($menuitem,$target,$listclass,$linkattr);
1.340 raeburn 418: }
419: } else {
1.511 raeburn 420: $menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>').
421: &Apache::loncommon::top_nav_help('Help',$linkattr).
422: '</li>';
1.340 raeburn 423: }
1.510 raeburn 424: } elsif ($$menuitem[3] eq 'Log In') {
425: if ($public) {
426: if (&Apache::lonnet::get_saml_landing()) {
427: $$menuitem[0] = '/adm/login';
428: }
429: }
1.521 raeburn 430: $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
1.283 droeschl 431: } else {
1.521 raeburn 432: $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
1.283 droeschl 433: }
1.291 raeburn 434: }
1.423 raeburn 435: my @output = ('','');
436: if ($menu{'left'} ne '') {
1.542 raeburn 437: if ($collapsible) {
438: $menu{'left'} = ($listclass?'<li class="'.$listclass.'">':'<li>').
439: ' </li>'.$menu{'left'};
440: }
1.423 raeburn 441: $output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>";
442: }
443: if ($menu{'right'} ne '') {
444: $output[1] = "<ol class=\"LC_primary_menu LC_floatright LC_right\">$menu{'right'}</ol>";
445: }
446: return @output;
1.283 droeschl 447: }
448:
1.329 droeschl 449: #returns hashref {user=>'',dom=>''} containing:
450: # own name, domain if user is au
451: # name, domain of parent author if user is ca or aa
452: #empty return if user is not an author or not on homeserver
453: #
454: #TODO this should probably be moved somewhere more central
455: #since it can be used by different parts of the system
1.541 raeburn 456: sub getauthor {
1.329 droeschl 457: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
458:
1.541 raeburn 459: #co- or assistant author?
1.329 droeschl 460: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
461: ? ($1, $2) #domain, username of the parent author
462: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
463:
464: # current server == home server?
465: my $home = &Apache::lonnet::homeserver($user,$dom);
466: foreach (&Apache::lonnet::current_machine_ids()){
467: return {user => $user, dom => $dom} if $_ eq $home;
468: }
469:
470: # if wrong server
471: return;
472: }
1.283 droeschl 473:
474: sub secondary_menu {
1.521 raeburn 475: my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,
476: $links_disabled,$links_target) = @_;
1.283 droeschl 477: my $menu;
478:
1.286 raeburn 479: my $crstype = &Apache::loncommon::course_type();
1.327 droeschl 480: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
481: ? "/$env{'request.course.sec'}"
482: : '');
483: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
1.464 raeburn 484: my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'});
1.376 raeburn 485: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
1.418 raeburn 486: if ($canviewroster eq 'disabled') {
487: undef($canviewroster);
488: }
1.327 droeschl 489: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
1.453 raeburn 490: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
491: my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec);
1.327 droeschl 492: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
1.454 raeburn 493: my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec);
1.341 www 494: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
1.343 www 495: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
496: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
1.489 raeburn 497: my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
1.343 www 498: my $author = &getauthor();
1.327 droeschl 499:
1.541 raeburn 500: my ($is_author,$is_coauthor);
501: if ($author) {
502: if ($env{'request.role'} =~ /^au\./) {
503: $is_author = 1;
504: } elsif ($env{'request.role'} =~ /^ca\./) {
505: $is_coauthor = 1;
506: }
507: }
508:
1.507 raeburn 509: my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,
510: $lti,$ltimapres,%ltiexc,%menuopts);
1.439 raeburn 511: $grouptools = 0;
1.413 raeburn 512: if ($env{'request.course.id'}) {
513: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
514: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.482 raeburn 515: unless ($canedit || $canvieweditor) {
1.414 raeburn 516: unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) {
517: if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) ||
518: ($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) ||
519: ($env{'course.'.$env{'request.course.id'}.'.updatedsyllabus'}) ||
520: ($env{'request.course.syllabustime'})) {
521: $showsyllabus = 1;
522: }
523: }
524: if ($env{'request.course.feeds'}) {
525: $showfeeds = 1;
1.413 raeburn 526: }
527: }
1.464 raeburn 528: unless ($canmgr || $canvgr) {
1.417 raeburn 529: my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
530: if (keys(%slots) > 0) {
531: $showresv = 1;
532: }
533: }
1.497 raeburn 534: if ($env{'request.course.groups'} ne '') {
1.499 raeburn 535: foreach my $group (split(/:/,$env{'request.course.groups'})) {
1.498 raeburn 536: next unless ($group =~ /^\w+$/);
1.439 raeburn 537: my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"});
538: shift(@privs);
539: if (@privs) {
540: $grouptools ++;
541: }
542: }
543: }
1.491 raeburn 544: if ($env{'request.lti.login'}) {
545: $lti = 1;
546: if (ref($ltimenu) eq 'HASH') {
547: foreach my $item ('fullname','coursetitle','role','logout','grades') {
548: unless ($ltimenu->{$item}) {
549: $ltiexc{$item} = 1;
550: }
551: }
552: }
553: if (($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
554: $ltimapres = 1;
555: }
556: }
1.413 raeburn 557: }
1.507 raeburn 558: if (($menucoll) && (ref($menuref) eq 'HASH')) {
559: %menuopts = %{$menuref};
560: }
1.413 raeburn 561:
1.521 raeburn 562: my ($listclass,$linkattr,$target);
1.511 raeburn 563: if ($links_disabled) {
564: $listclass = 'LCisDisabled';
565: $linkattr = 'aria-disabled="true"';
566: }
567:
1.541 raeburn 568: my ($canlistcoauthors,$canmodifycoauthor);
1.404 raeburn 569: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
570: my $extent = "$env{'user.domain'}/$env{'user.name'}";
571: if ((&Apache::lonnet::allowed('cca',$extent)) ||
572: (&Apache::lonnet::allowed('caa',$extent))) {
573: $canmodifycoauthor = 1;
574: }
1.541 raeburn 575: } elsif ($env{'request.role'} =~ m{^(aa|ca)\./($match_domain/$match_username)$}) {
576: my ($role,$extent) = ($1,$2);
577: if (&Apache::lonnet::allowed('vca',$extent)) {
578: if ($env{"environment.internal.manager./$extent"}) {
579: $canmodifycoauthor = 1;
580: } else {
581: $canlistcoauthors = 1;
582: }
583: } elsif (&Apache::lonnet::allowed('vaa',$extent)) {
584: $canlistcoauthors = 1;
585: }
1.404 raeburn 586: }
1.521 raeburn 587: my ($roleswitcher_js,$roleswitcher_form);
588: if ($links_target ne '') {
589: $target = $links_target;
590: } else {
591: my ($ltitarget,$deeplinktarget);
592: if ($env{'request.lti.login'}) {
593: $ltitarget = $env{'request.lti.target'};
594: }
595: if ($env{'request.deeplink.login'}) {
596: $deeplinktarget = $env{'request.deeplink.target'};
597: }
598: if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
599: $target = '_self';
600: } else {
601: $target = '_top';
602: }
1.516 raeburn 603: }
1.401 raeburn 604:
1.283 droeschl 605: foreach my $menuitem (@secondary_menu) {
606: # evaluate conditions
1.296 droeschl 607: next if ref($menuitem) ne 'ARRAY';
1.443 raeburn 608: next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));
1.541 raeburn 609: next if $$menuitem[4] ne 'always'
610: && $$menuitem[4] ne 'coauthor'
611: && $$menuitem[4] ne 'author'
612: && $$menuitem[4] ne 'authorspace'
613: && $$menuitem[4] ne 'vca'
614: && $$menuitem[4] ne 'mca'
1.283 droeschl 615: && !$env{'request.course.id'};
1.464 raeburn 616: next if $$menuitem[4] =~ /^crsedit/
617: && (!$canedit && !$canvieweditor);
1.559 raeburn 618: next if $$menuitem[4] eq 'crseditCourse'
619: && ($crstype eq 'Community');
620: next if $$menuitem[4] eq 'crseditCommunity'
1.560 raeburn 621: && ($crstype ne 'Community');
1.341 www 622: next if $$menuitem[4] eq 'nvgr'
1.491 raeburn 623: && ($canvgr || $ltiexc{'grades'});
1.341 www 624: next if $$menuitem[4] eq 'vgr'
625: && !$canvgr;
1.456 raeburn 626: next if $$menuitem[4] eq 'viewusers'
1.453 raeburn 627: && !$canmodifyuser && !$canviewusers;
1.456 raeburn 628: next if $$menuitem[4] eq 'noviewusers'
1.453 raeburn 629: && ($canmodifyuser || $canviewusers || !$canviewroster);
1.343 www 630: next if $$menuitem[4] eq 'mgr'
631: && !$canmgr;
1.417 raeburn 632: next if $$menuitem[4] eq 'showresv'
633: && !$showresv;
1.327 droeschl 634: next if $$menuitem[4] eq 'whn'
635: && !$canviewwnew;
1.454 raeburn 636: next if $$menuitem[4] eq 'params'
637: && (!$canmodpara && !$canviewpara);
1.482 raeburn 638: next if $$menuitem[4] eq 'showgroups'
639: && ($canviewgrps || !$grouptools);
1.413 raeburn 640: next if $$menuitem[4] eq 'showsyllabus'
641: && !$showsyllabus;
642: next if $$menuitem[4] eq 'showfeeds'
643: && !$showfeeds;
1.489 raeburn 644: next if $$menuitem[4] eq 'plc'
645: && !$canplc;
1.541 raeburn 646: next if $$menuitem[4] eq 'authorspace'
1.329 droeschl 647: && !$author;
1.541 raeburn 648: next if $$menuitem[4] eq 'author'
649: && !$is_author;
650: next if $$menuitem[4] eq 'coauthor'
651: && !$is_coauthor;
652: next if $$menuitem[4] eq 'vca'
653: && (!$canlistcoauthors || $canmodifycoauthor);
654: next if $$menuitem[4] eq 'vaa'
655: && (!$canlistcoauthors || $canmodifycoauthor);
656: next if $$menuitem[4] eq 'mca'
1.404 raeburn 657: && !$canmodifycoauthor;
1.490 raeburn 658: next if $$menuitem[4] eq 'notltimapres'
1.491 raeburn 659: && $ltimapres;
660: next if $$menuitem[4] eq 'notlti'
661: && $lti;
662: next if $$menuitem[4] eq 'lti'
663: && (!$lti || !$noprimary);
664: next if $$menuitem[3] eq 'Logout'
665: && $ltiexc{'logout'};
1.283 droeschl 666:
1.482 raeburn 667: my $title = $menuitem->[3];
1.507 raeburn 668: if ($env{'request.course.id'} && $menucoll) {
669: unless ($$menuitem[5] eq 'roles') {
670: next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]}));
671: }
672: }
1.482 raeburn 673: if (defined($secondary_submenu{$title})) {
1.521 raeburn 674: my $link;
1.482 raeburn 675: if ($menuitem->[0] ne '') {
676: $link = $menuitem->[0];
677: } else {
678: $link = '#';
679: }
680: my @scndsub;
681: if (ref($secondary_submenu{$title}) eq 'ARRAY') {
682: foreach my $item (@{$secondary_submenu{$title}}) {
683: if (ref($item) eq 'ARRAY') {
684: next if ($item->[2] eq 'vgr' && !$canvgr);
685: next if ($item->[2] eq 'opa' && !$canmodpara);
686: next if ($item->[2] eq 'vpa' && !$canviewpara);
687: next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers));
688: next if ($item->[2] eq 'mgr' && !$canmgr);
689: next if ($item->[2] eq 'vcg' && !$canviewgrps);
690: next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);
691: next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
1.541 raeburn 692: next if ($item->[2] eq 'author' && !$is_author);
693: next if ($item->[2] eq 'vca' && !$canlistcoauthors);
1.491 raeburn 694: next if ($item->[2] eq 'lti' && !$lti);
695: if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
696: my $tool = $1;
697: next if !$lti;
698: next if (!&Apache::lonnet::usertools_access('','',$tool,
699: undef,'tools'));
700: }
1.482 raeburn 701: push(@scndsub,$item);
702: }
703: }
1.507 raeburn 704: if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'}) {
1.491 raeburn 705: unless ($ltiexc{'fullname'}) {
706: $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
707: }
708: }
1.482 raeburn 709: if (@scndsub > 0) {
1.511 raeburn 710: $menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1,undef,
711: $listclass,$linkattr);
1.482 raeburn 712: } elsif ($link ne '#') {
1.512 raeburn 713: $menu .= ($listclass?'<li class="'.$listclass.'">':'<li>').
1.511 raeburn 714: '<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'.
715: &mt($title).'</a></li>';
1.482 raeburn 716: }
717: }
718: } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 719: # special treatment for role selector
1.507 raeburn 720: my ($switcher,$has_opa_priv);
721: ($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) =
1.491 raeburn 722: &roles_selector(
723: $env{'course.' . $env{'request.course.id'} . '.domain'},
724: $env{'course.' . $env{'request.course.id'} . '.num'},
1.521 raeburn 725: $httphost,$target,$menucoll,$menuref
1.491 raeburn 726: );
1.507 raeburn 727: if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
728: next unless ($has_opa_priv);
729: }
1.491 raeburn 730: $menu .= $switcher;
731: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
732: next if ($crstype eq 'Placement');
733: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.296 droeschl 734: } else {
1.414 raeburn 735: if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
736: my $url = $$menuitem[0];
737: $url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum};
738: if (&Apache::lonnet::is_on_map($url)) {
1.468 raeburn 739: unless ($$menuitem[0] =~ /(\?|\&)register=1/) {
740: $$menuitem[0] .= (($$menuitem[0]=~/\?/)? '&' : '?').'register=1';
1.414 raeburn 741: }
742: } else {
1.468 raeburn 743: $$menuitem[0] =~ s{\&?register=1}{};
1.414 raeburn 744: }
1.468 raeburn 745: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
746: if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) {
1.506 raeburn 747: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) {
1.493 raeburn 748: unless ($$menuitem[0] =~ m{^https?://}) {
749: $$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
750: }
751: unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) {
752: $$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1';
753: }
1.468 raeburn 754: }
755: }
1.467 raeburn 756: }
1.473 raeburn 757: $$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
1.414 raeburn 758: }
1.521 raeburn 759: $menu .= &prep_menuitem(\@$menuitem,$target,$listclass,$linkattr);
1.283 droeschl 760: }
761: }
762: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 763: my $escurl = &escape( &Apache::lonenc::check_encrypt(
764: $env{'request.noversionuri'}));
1.283 droeschl 765:
1.291 raeburn 766: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
767: $env{'request.symb'}));
1.283 droeschl 768:
769: if ( $env{'request.state'} eq 'construct'
770: and ( $env{'request.noversionuri'} eq ''
771: || !defined($env{'request.noversionuri'})))
772: {
1.359 raeburn 773: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
774: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 775: $escurl = &escape($escurl);
1.473 raeburn 776: }
1.283 droeschl 777: $menu =~ s/\[url\]/$escurl/g;
778: $menu =~ s/\[symb\]/$escsymb/g;
1.541 raeburn 779: } elsif (($menu =~ m{/adm/preferences\?}) && ($menu =~ /\[returnurl\]/)) {
780: my $returnurl = $ENV{'REQUEST_URI'};
781: if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=authorsettings\&returnurl=([^\&]+)$}) {
782: $returnurl = $1;
783: }
784: if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
785: ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
786: ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
787: $returnurl =~ s{\?.*$}{};
788: $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
789: } else {
790: undef($returnurl);
791: }
792: $menu =~ s/\[returnurl\]/$returnurl/;
1.283 droeschl 793: }
1.329 droeschl 794: $menu =~ s/\[uname\]/$$author{user}/g;
795: $menu =~ s/\[udom\]/$$author{dom}/g;
1.491 raeburn 796: $menu =~ s/\[javascript\]/javascript:/g;
1.482 raeburn 797: if ($env{'request.course.id'}) {
1.413 raeburn 798: $menu =~ s/\[cnum\]/$cnum/g;
799: $menu =~ s/\[cdom\]/$cdom/g;
800: }
1.385 raeburn 801: if ($menu) {
802: $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
803: }
1.401 raeburn 804: if ($roleswitcher_form) {
805: $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
806: }
1.385 raeburn 807: return $menu;
1.283 droeschl 808: }
809:
1.375 raeburn 810: sub create_submenu {
1.511 raeburn 811: my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_;
1.375 raeburn 812: return unless (ref($submenu) eq 'ARRAY');
1.521 raeburn 813: my $targetattr;
814: if (($target ne '') && ($link ne '#')) {
815: $targetattr = ' target="'.$target.'"';
1.379 raeburn 816: }
1.447 raeburn 817: my $menu = '<li class="LC_hoverable '.$addclass.'">'.
1.521 raeburn 818: '<a href="'.$link.'"'.$targetattr.'>'.
1.432 droeschl 819: '<span class="LC_nobreak">'.$title.
1.561 ! raeburn 820: '<span class="LC_fontsize_medium" style="font-weight:normal;">'.
1.375 raeburn 821: ' ▼</span></span></a>'.
822: '<ul>';
1.431 golterma 823:
824: # $link and $title are only used in the initial string written in $menu
825: # as seen above, not needed for nested submenus
1.511 raeburn 826: $menu .= &build_submenu($target, $submenu, $translate, '1', $listclass, $linkattr);
1.431 golterma 827: $menu .= '</ul></li>';
828:
829: return $menu;
830: }
831:
832: # helper routine for create_submenu
833: # build the dropdown (and nested submenus) recursively
834: # see perldoc create_submenu documentation for further information
835: sub build_submenu {
1.511 raeburn 836: my ($target, $submenu, $translate, $first_level, $listclass, $linkattr) = @_;
1.446 raeburn 837: unless (@{$submenu}) {
1.431 golterma 838: return '';
839: }
840:
841: my $menu = '';
1.375 raeburn 842: my $count = 0;
843: my $numsub = scalar(@{$submenu});
844: foreach my $item (@{$submenu}) {
845: $count ++;
846: if (ref($item) eq 'ARRAY') {
1.416 raeburn 847: my $href = $item->[0];
1.431 golterma 848: my $bordertop;
849: my $borderbot;
850: my $title;
851:
852: if ($translate) {
853: $title = &mt($item->[1]);
854: } else {
855: $title = $item->[1];
856: }
857:
858: if ($count == 1 && !$first_level) {
859: $bordertop = 'border-top: 1px solid black;';
1.416 raeburn 860: }
1.375 raeburn 861: if ($count == $numsub) {
1.431 golterma 862: $borderbot = 'border-bottom: 1px solid black;';
1.375 raeburn 863: }
1.431 golterma 864:
865: # href is a reference to another submenu
866: if (ref($href) eq 'ARRAY') {
867: $menu .= '<li style="margin:0;padding:0;'.$bordertop . $borderbot . '">';
868: $menu .= '<p><span class="LC_primary_menu_innertitle">'
869: . $title . '</span><span class="LC_primary_menu_innerarrow">▶</span></p>';
870: $menu .= '<ul>';
871: $menu .= &build_submenu($target, $href, $translate);
872: $menu .= '</ul>';
873: $menu .= '</li>';
874: } else { # href is the actual hyperlink and does not represent another submenu
875: # for the current menu title
876: if ($href =~ /(aboutme|rss\.html)$/) {
877: next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne ''));
878: $href =~ s/\[domain\]/$env{'user.domain'}/g;
879: $href =~ s/\[user\]/$env{'user.name'}/g;
1.488 raeburn 880: } elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) {
881: my $returnurl = $ENV{'REQUEST_URI'};
882: if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) {
883: $returnurl = $1;
884: }
885: if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
886: ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
887: ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
888: $returnurl =~ s{\?.*$}{};
889: $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
890: } else {
891: undef($returnurl);
892: }
893: $href =~ s/\[returnurl\]/$returnurl/;
1.431 golterma 894: }
1.521 raeburn 895: my $targetattr;
1.431 golterma 896: unless (($href eq '') || ($href =~ /^\#/)) {
1.521 raeburn 897: if ($target ne '') {
898: $targetattr = ' target="'.$target.'"';
1.486 raeburn 899: }
1.431 golterma 900: }
901:
1.513 raeburn 902: $menu .= '<li ';
1.511 raeburn 903: $menu .= ($listclass?'class="'.$listclass.'" ':'');
904: $menu .= 'style="margin:0;padding:0;'. $bordertop . $borderbot .'">';
1.521 raeburn 905: $menu .= '<a href="'.$href.'"'.$targetattr.' '.$linkattr.'>' . $title . '</a>';
1.431 golterma 906: $menu .= '</li>';
1.425 raeburn 907: }
1.375 raeburn 908: }
909: }
910: return $menu;
911: }
912:
1.40 www 913: sub innerregister {
1.524 raeburn 914: my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,
915: $ltiscope,$ltiuri,$showncrumbsref) = @_;
1.152 albertel 916: my $const_space = ($env{'request.state'} eq 'construct');
1.549 raeburn 917: my $in_daxe = 0;
1.120 raeburn 918:
1.175 albertel 919: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 920:
1.174 albertel 921: $env{'request.registered'} = 1;
1.40 www 922:
1.177 albertel 923: undef(@inlineremote);
1.56 www 924:
1.490 raeburn 925: my ($mapurl,$resurl,$crstype,$navmap);
1.390 raeburn 926:
1.393 raeburn 927: if ($env{'request.course.id'}) {
1.443 raeburn 928: #
929: #course_type: Course, Community, or Placement
930: #
931: $crstype = &Apache::loncommon::course_type();
1.393 raeburn 932: if ($env{'request.symb'}) {
1.476 raeburn 933: my $ignorenull;
934: unless ($env{'request.noversionuri'} eq '/adm/navmaps') {
935: $ignorenull = 1;
936: }
937: my $symb = &Apache::lonnet::symbread('','',$ignorenull);
938: ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb);
1.393 raeburn 939: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
1.267 droeschl 940:
1.393 raeburn 941: my $maptitle = &Apache::lonnet::gettitle($mapurl);
1.476 raeburn 942: my $restitle = &Apache::lonnet::gettitle($symb);
1.475 raeburn 943: my (@crumbs,@mapcrumbs);
1.478 raeburn 944: if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') &&
945: (!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) {
1.486 raeburn 946: unless ($ltiscope eq 'resource') {
947: if (($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) &&
948: !(($ltiscope eq 'map') && (&Apache::lonnet::clutter($resurl) eq $ltiuri))) {
949: $navmap = Apache::lonnavmaps::navmap->new();
950: if (ref($navmap)) {
951: @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
952: }
953: }
1.475 raeburn 954: }
955: }
1.523 raeburn 956: unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
1.486 raeburn 957: ($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
1.443 raeburn 958: @crumbs = ({text => $crstype.' Contents',
1.393 raeburn 959: href => "Javascript:gopost('/adm/navmaps','')"});
960: }
961: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
1.475 raeburn 962: if (@mapcrumbs) {
963: push(@crumbs,@mapcrumbs);
1.486 raeburn 964: } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'})) &&
965: ($ltiscope ne 'map') && ($ltiscope ne 'resource')) {
1.475 raeburn 966: push(@crumbs, {text => '...',
967: no_mt => 1});
968: }
1.393 raeburn 969: }
970:
1.475 raeburn 971: unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) ||
972: (!$maptitle) || ($maptitle eq 'default.sequence') ||
1.486 raeburn 973: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
974: ($ltiscope eq 'resource')) {
975: push @crumbs, {text => $maptitle, no_mt => 1,
976: href => &Apache::lonnet::clutter($mapurl).'?navmap=1'};
1.443 raeburn 977: }
1.479 raeburn 978: if ($restitle && !@mapcrumbs) {
979: push(@crumbs,{text => $restitle, no_mt => 1});
980: }
1.436 raeburn 981: my @tools;
982: if ($env{'request.filename'} =~ /\.page$/) {
983: my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
984: if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
985: @tools = @{$breadcrumb_tools{'tools'}};
986: }
987: }
1.393 raeburn 988: &Apache::lonhtmlcommon::clear_breadcrumbs();
989: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.436 raeburn 990: if (@tools) {
991: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',@tools);
992: }
1.393 raeburn 993: } else {
994: $resurl = $env{'request.noversionuri'};
995: my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
996: my $title = &mt('View Resource');
997: if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
998: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
1.392 raeburn 999: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.393 raeburn 1000: if ($env{'form.title'}) {
1001: $title = $env{'form.title'};
1002: }
1.528 raeburn 1003: my ($trail,$cnum,$cdom);
1004: if ($env{'form.folderpath'}) {
1005: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1006: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1007: &Apache::loncommon::validate_folderpath(1,'',$cnum,$cdom);
1008: }
1.393 raeburn 1009: if ($env{'form.folderpath'}) {
1.468 raeburn 1010: &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
1.529 raeburn 1011: $title = &HTML::Entities::encode($title,'\'"<>&');
1.394 raeburn 1012: ($trail) =
1.524 raeburn 1013: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
1.393 raeburn 1014: } else {
1015: &Apache::lonhtmlcommon::add_breadcrumb(
1.392 raeburn 1016: {text => "Supplemental $crstype Content",
1017: href => "javascript:gopost('/adm/supplemental','')"});
1.529 raeburn 1018: $title = &HTML::Entities::encode(&mt('View Resource'),'\'"<>&');
1.394 raeburn 1019: ($trail) =
1.524 raeburn 1020: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
1021: }
1022: if (ref($showncrumbsref)) {
1023: $$showncrumbsref = 1;
1.392 raeburn 1024: }
1.394 raeburn 1025: return $trail;
1.412 raeburn 1026: } elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
1027: &Apache::lonhtmlcommon::clear_breadcrumbs();
1028: &prepare_functions('/public'.$courseurl."/syllabus",
1.468 raeburn 1029: $forcereg,$group,undef,undef,1,$hostname);
1.529 raeburn 1030: $title = &HTML::Entities::encode(&mt('Syllabus File'),'\'"<>&');
1.412 raeburn 1031: my ($trail) =
1.524 raeburn 1032: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
1033: if (ref($showncrumbsref)) {
1034: $$showncrumbsref = 1;
1035: }
1.412 raeburn 1036: return $trail;
1.537 raeburn 1037: } elsif (($resurl eq '/public'.$courseurl.'/syllabus') &&
1038: ($env{'form.folderpath'})) {
1039: if ($env{'form.title'}) {
1040: $title = $env{'form.title'};
1041: } else {
1042: $title = 'Syllabus';
1043: }
1044: &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
1045: $title = &HTML::Entities::encode($title,'\'"<>&');
1046: my ($trail) =
1047: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
1048: return $trail;
1.392 raeburn 1049: }
1.395 raeburn 1050: unless ($env{'request.state'} eq 'construct') {
1051: &Apache::lonhtmlcommon::clear_breadcrumbs();
1052: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
1053: }
1.392 raeburn 1054: }
1.390 raeburn 1055: } elsif (! $const_space){
1.328 droeschl 1056: #a situation when we're looking at a resource outside of context of a
1057: #course or construction space (e.g. with cumulative rights)
1058: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.390 raeburn 1059: unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
1060: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
1061: }
1.65 www 1062: }
1.41 www 1063: # =============================================================================
1064: # ============================ This is for URLs that actually can be registered
1.316 droeschl 1065: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
1066: || $forcereg );
1.390 raeburn 1067: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
1068: $forceview,$editbutton);
1.391 raeburn 1069: if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
1070: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1.468 raeburn 1071: $editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname);
1.390 raeburn 1072: }
1073: if ($editbutton eq '') {
1.399 raeburn 1074: $editbutton = &clear(6,1);
1.390 raeburn 1075: }
1.317 droeschl 1076:
1.390 raeburn 1077: #
1078: # This applies in course context
1079: #
1080: if ($env{'request.course.id'}) {
1081: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1082: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1083: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1.462 raeburn 1084: $perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'});
1.390 raeburn 1085: my @privs;
1.484 raeburn 1086: my $gradable_exttool;
1.390 raeburn 1087: if ($env{'request.symb'} ne '') {
1.484 raeburn 1088: if ($env{'request.noversionuri'} =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
1089: if (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i) {
1090: $gradable_exttool = 1;
1091: push(@privs,('mgr','vgr'));
1092: }
1093: } elsif ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
1.390 raeburn 1094: push(@privs,('mgr','vgr'));
1095: }
1.455 raeburn 1096: push(@privs,('opa','vpa'));
1.390 raeburn 1097: }
1098: foreach my $priv (@privs) {
1099: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
1100: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
1101: $perms{$priv} =
1102: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
1103: }
1104: }
1105: #
1106: # Determine whether or not to show Grades and Submissions buttons
1107: #
1.484 raeburn 1108: if (($env{'request.symb'} ne '') &&
1109: (($env{'request.filename'}=~/$LONCAPA::assess_re/) || ($gradable_exttool))) {
1.390 raeburn 1110: if ($perms{'mgr'}) {
1111: &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
1112: "gocmd('/adm/grades','gradingmenu')",
1.561 ! raeburn 1113: 'Grading for Resource/Folder');
1.390 raeburn 1114: } elsif ($perms{'vgr'}) {
1115: &switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
1116: "gocmd('/adm/grades','submission')",
1.561 ! raeburn 1117: 'Submissions for Resource/Folder');
1.390 raeburn 1118: }
1119: }
1.455 raeburn 1120: if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) {
1.390 raeburn 1121: &switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
1122: "gocmd('/adm/parmset','set')",
1.561 ! raeburn 1123: 'Content Settings for Resource/Folder');
1.107 albertel 1124: }
1.393 raeburn 1125: # End grades/submissions check
1.107 albertel 1126:
1.274 www 1127: #
1.393 raeburn 1128: # This applies to items inside a folder/page modifiable in the course.
1.274 www 1129: #
1.462 raeburn 1130: if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) {
1.393 raeburn 1131: my $text = 'Edit Folder';
1.395 raeburn 1132: if (($mapurl =~ /\.page$/) ||
1133: ($env{'request.symb'}=~
1.396 raeburn 1134: m{uploaded/$cdom/$cnum/default_\d+\.page$})) {
1.393 raeburn 1135: $text = 'Edit Page';
1136: }
1137: &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
1.390 raeburn 1138: "gocmd('/adm/coursedocs','direct')",
1139: 'Folder/Page Content');
1.258 raeburn 1140: }
1.390 raeburn 1141: # End modifiable folder/page container check
1.530 raeburn 1142:
1143: #
1144: # Determine whether to show View As button for shortcut to display problem, answer, and submissions
1145: #
1146:
1147: if (($env{'request.symb'} ne '') &&
1148: ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
1149: (($perms{'mgr'}) || ($perms{'vgr'}))) {
1.561 ! raeburn 1150: my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$rightvis,
! 1151: $defdom,$domselector,$righticon);
1.530 raeburn 1152: my %lt = &Apache::lonlocal::texthash(
1153: view => 'View',
1154: upda => 'Update',
1.561 ! raeburn 1155: user => 'View as user',
! 1156: choo => 'Choose user',
1.530 raeburn 1157: );
1.539 raeburn 1158: my $possdomstr = $env{'course.'.$env{'request.course.id'}.'.internal.userdomains'};
1159: if ($possdomstr =~ /,/) {
1160: my @possdoms = split(/,/,$possdomstr);
1161: if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
1162: $defdom = $1;
1163: } elsif (grep(/^\Q$cdom\E$/,@possdoms)) {
1164: $defdom = $cdom;
1165: } elsif (&Apache::lonnet::domain($possdoms[0]) ne '') {
1166: $defdom = $possdoms[0];
1167: }
1.561 ! raeburn 1168: $domselector = &Apache::loncommon::select_dom_form($defdom,'vudom','','','',
! 1169: \@possdoms,'','','vudom').
! 1170: '<span class="LC_visually_hidden"><label for="vudom">'.
! 1171: &mt("user's domain").'</label></span>';
1.539 raeburn 1172: } elsif (($possdomstr ne '') && (&Apache::lonnet::domain($possdomstr) ne '')) {
1173: if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
1174: $defdom = $1;
1175: } else {
1176: $defdom = $possdomstr;
1177: }
1178: }
1.530 raeburn 1179: if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) {
1180: ($vuname,$vudom) = ($1,$2);
1.531 raeburn 1181: unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) {
1182: $vid = (&Apache::lonnet::idrget($vudom,$vuname))[1];
1183: }
1.530 raeburn 1184: $viewas = $env{'request.user_in_effect'};
1185: $text = $lt{'upda'};
1186: $change = 'off';
1187: $visibility = 'inline';
1188: $leftvis = 'none';
1.561 ! raeburn 1189: $rightvis = 'inline';
1.530 raeburn 1190: $defdom = $vudom;
1191: $righticon = '✖';
1192: } else {
1193: $text = $lt{'view'};
1194: $change = 'on';
1195: $visibility = 'none';
1196: $leftvis = 'inline';
1.561 ! raeburn 1197: $rightvis = 'none';
! 1198: $righticon = '◄';
1.540 raeburn 1199: if ($defdom eq '') {
1.539 raeburn 1200: $defdom = $cdom;
1201: }
1.530 raeburn 1202: }
1.538 raeburn 1203: my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier');
1.530 raeburn 1204: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1205: my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"');
1.539 raeburn 1206: my $input;
1207: my @items = (
1208: '<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />',
1209: '</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />',
1210: '<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />',
1211: '</label><input name="vid" type="hidden" size="6" value="'.$vid.'" id="LC_vid" />'
1212: );
1213: if ($domselector) {
1214: push(@items,$domselector);
1215: $input = &mt('[_1]User:[_2] or [_3]ID:[_4] at [_5] | ',@items);
1216: } else {
1217: $input = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',@items).
1218: '<input name="vudom" type="hidden" value="'.$defdom.'" />';
1219: }
1220: $input .= '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',
1221: '<input name="symb" type="hidden" value="'.$shownsymb.'" />';
1.530 raeburn 1222: my $chooser = <<END;
1.561 ! raeburn 1223: <span class="LC_visually_hidden">
! 1224: <label for="LC_vuname" id="LC_vuidentifier">$lt{'user'}</label>
! 1225: </span>
1.530 raeburn 1226: $selscript
1.561 ! raeburn 1227: <a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link" id="usexpand" style="display:$leftvis;">
! 1228: <span class="LC_menubuttons_inline_text">► </span>
1.530 raeburn 1229: </a>
1.561 ! raeburn 1230: <fieldset id="LC_selectuser" style="display:$visibility;"><legend class="LC_visually_hidden">$lt{'choo'}</legend>
1.530 raeburn 1231: <form name="userview" action="" method="post" onsubmit="event.preventDefault(); return validCourseUser(this,'$change');">
1232: <span class="LC_menubuttons_inline_text LC_nobreak">
1233: $input
1234: $sellink
1235: </span>
1236: <input type="submit" value="$text" />
1237: </form>
1238: </fieldset>
1.561 ! raeburn 1239: <a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link" id="uscollapse" style="display:$rightvis">
! 1240: <span class="LC_menubuttons_inline_text">$righticon</span>
1.530 raeburn 1241: </a>
1242: END
1243: &switch('','',7,5,'viewuser.png','View As','user[_1]',
1244: 'toggleViewAsUser('."'$change'".')',
1.561 ! raeburn 1245: 'View resource as user','','',$chooser);
1.530 raeburn 1246: }
1247: # End view as user check
1248:
1.390 raeburn 1249: }
1250: # End course context
1251:
1.41 www 1252: # Prepare the rest of the buttons
1.550 raeburn 1253: my ($menuitems,$got_prt,$got_wishlist,$crsauthor,$toplevel_cstr,$crsauthor_cstr);
1254: if ($const_space) {
1.274 www 1255: #
1256: # We are in construction space
1257: #
1.353 www 1258:
1.355 raeburn 1259: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 1260: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 1261: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.534 raeburn 1262: if (($env{'request.course.id'}) &&
1263: ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
1264: ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
1.550 raeburn 1265: $crsauthor_cstr = 1;
1.534 raeburn 1266: }
1.353 www 1267: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 1268: if ($currdir =~ m-/$-) {
1.550 raeburn 1269: if ($thisdisfn eq '') {
1270: $toplevel_cstr = 1;
1.433 raeburn 1271: }
1.532 raeburn 1272: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1273: $menuitems=(<<ENDMENUITEMS);
1274: s&6&3&pub.png&Publish&dir[_2]&gocstr('/adm/publish','$esc_currdir')&Publish this Directory
1275: s&7&4&docs-22x22.png&Edit Metadata&defaults[_1]&gopost('${esc_currdir}default.meta','')&Edit metadata for this Directory
1276: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','$esc_currdir')&Print contents of directory
1277: s&7&1&del.png&Delete&dir[_3]&gocstr('/adm/cfile?action=delete','$esc_currdir')&Delete this Directory
1278: ENDMENUITEMS
1.552 raeburn 1279: unless ($crsauthor_cstr) {
1.556 raeburn 1280: if (($env{'environment.canarchive'}) &&
1281: ($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) {
1.552 raeburn 1282: $menuitems .= (<<ENDMENUITEMS);
1.553 raeburn 1283: s&7&7&archive.png&Export&dir[_1]&gocstr('/adm/cfile?action=archive','$esc_currdir')&Export Authoring Space Archive
1.552 raeburn 1284: ENDMENUITEMS
1285: }
1286: }
1.131 raeburn 1287: } else {
1.267 droeschl 1288: $currdir =~ s|[^/]+$||;
1.200 foxr 1289: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 1290: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.515 raeburn 1291: my $pubfile = "/res/$udom/$uname/$thisdisfn";
1292: my $candelete = 1;
1293: if (-e $londocroot.$pubfile) {
1294: unless (&Apache::lonnet::metadata($pubfile,'obsolete')) {
1295: undef($candelete);
1296: }
1297: }
1.274 www 1298: #
1299: # Probably should be in mydesk.tab
1300: #
1.550 raeburn 1301: if (($crsauthor_cstr) && ($pubfile eq "/res/$udom/$uname/default.rights")) {
1.534 raeburn 1302: $menuitems=(<<ENDMENUITEMS);
1303: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1304: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
1305: ENDMENUITEMS
1306: } else {
1307: $menuitems=(<<ENDMENUITEMS);
1.344 www 1308: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1.353 www 1309: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
1310: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
1.515 raeburn 1311: s&7&3©.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource
1312: ENDMENUITEMS
1.534 raeburn 1313: }
1.515 raeburn 1314: #
1315: # Rename and Delete only available if obsolete or unpublished
1316: #
1317: if ($candelete) {
1318: $menuitems .= (<<ENDMENUITEMS);
1319: s&7&4&rename.png&Rename&resource[_5]&gocstr('/adm/cfile?action=rename','/priv/$udom/$uname/$cleandisfn')&Rename this resource
1.353 www 1320: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
1.515 raeburn 1321: ENDMENUITEMS
1322: }
1.544 raeburn 1323: #
1324: # Print only makes sense for certain mime types
1325: #
1326: if ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm|tex)$/ || $thisdisfn=~/$LONCAPA::assess_re/) {
1327: $menuitems .= (<<ENDMENUITEMS);
1.353 www 1328: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 1329: ENDMENUITEMS
1.544 raeburn 1330: }
1.548 raeburn 1331: #
1.549 raeburn 1332: # "Exit Daxe" in Functions menu when using Daxe
1333: #
1334: if ((($env{'form.editmode'} eq 'daxe') &&
1335: ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm)$/)) ||
1336: (($env{'form.problemmode'} eq 'daxe') &&
1337: ($thisdisfn=~/$LONCAPA::assess_re/))) {
1338: my %editors = &Apache::loncommon::permitted_editors();
1339: if ($editors{'daxe'}) {
1340: my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
1341: $in_daxe = 1;
1342: $menuitems .= (<<ENDMENUITEMS);
1343: my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
1344: s&7&6&tolastloc.png&Exit Daxe&resource[_1]&go('$privfile')&Exit editing this resource
1345: ENDMENUITEMS
1346: }
1347: }
1.551 raeburn 1348: }
1.549 raeburn 1349: #
1.548 raeburn 1350: # Editing options usually accessed via "Settings" in inline menu need to be
1351: # accessed in a different way, when Authoring Space is accessed in course
1352: # context
1353: #
1354: if ($env{'request.role'} !~/^(aa|ca|au)/) {
1355: my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
1356: $menuitems .= (<<ENDMENUITEMS);
1357: s&7&5&editops.png&Options&edit[_1]&gocstr('/adm/preferences?action=authorsettings','$privfile')&Authoring Space Options
1358: ENDMENUITEMS
1359: }
1.308 raeburn 1360: if (ref($bread_crumbs) eq 'ARRAY') {
1361: &Apache::lonhtmlcommon::clear_breadcrumbs();
1362: foreach my $crumb (@{$bread_crumbs}){
1363: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
1364: }
1365: }
1.203 foxr 1366: } elsif ( defined($env{'request.course.id'}) &&
1367: $env{'request.symb'} ne '' ) {
1.274 www 1368: #
1.383 raeburn 1369: # We are in a course and looking at a registered URL
1.274 www 1370: # Should probably be in mydesk.tab
1371: #
1.443 raeburn 1372: $menuitems = "c&3&1";
1.486 raeburn 1373: if ($ltiscope eq 'resource') {
1374: # Suppress display of backward arrow for LTI Provider if scope is resource.
1375: # Suppress display of forward arrow for LTI Provider if scope is resource.
1376: } elsif ($ltiscope eq 'map') {
1377: # Suppress display of backward arrow for LTI Provider if scope is map and this is first resource.
1378: # Suppress display of forward arrow for LTI Provider if scope is map and this is the last resource.
1379: my $showforw = 1;
1380: my $showback = 1;
1381: my $navmap = Apache::lonnavmaps::navmap->new();
1382: if (ref($navmap)) {
1383: my $mapres = $navmap->getResourceByUrl($ltiuri);
1384: if (ref($mapres)) {
1385: if ($navmap->isLastResource($mapres,$env{'request.symb'})) {
1386: $showforw = 0;
1387: }
1388: if ($navmap->isFirstResource($mapres,$env{'request.symb'})) {
1389: $showback = 0;
1390: }
1391: }
1392: }
1393: if ($showback) {
1394: $menuitems.="
1395: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1";
1396: }
1397: if ($showforw) {
1398: $menuitems.="
1399: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
1400: }
1401: } elsif (($crstype ne 'Placement') || ($env{'request.role.adv'})) {
1.443 raeburn 1402: $menuitems.="
1.444 raeburn 1403: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
1404: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
1405: } else {
1406: # Suppress display of backward arrow for Placement Tests
1407: # Suppress display of forward arrow for Placement Tests if this is the last resource.
1408: my $showforw = 1;
1409: if ($env{'request.symb'}) {
1410: my $navmap = Apache::lonnavmaps::navmap->new();
1411: if (ref($navmap)) {
1412: if (&Apache::lonplacementtest::is_lastres($env{'request.symb'},$navmap)) {
1413: $showforw = 0;
1414: }
1415: }
1416: }
1417: if ($showforw) {
1418: $menuitems.="
1419: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
1420: }
1.443 raeburn 1421: }
1422: $menuitems .= (<<ENDMENUITEMS);
1423:
1.77 www 1424: c&6&3
1425: c&8&1
1426: c&8&2
1.344 www 1427: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 1428: ENDMENUITEMS
1.383 raeburn 1429: $got_prt = 1;
1430: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
1431: && (!$env{'request.enc'})) {
1.535 raeburn 1432: my $privurl = $env{'request.uri'};
1433: $privurl =~ s{^/res/}{/priv/};
1434: my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($privurl);
1435: if ($cnum) {
1436: $crsauthor = 1;
1437: } else {
1.452 raeburn 1438: # wishlist is only available for users with access to resource-pool
1439: # and links can only be set for resources within the resource-pool
1440: $menuitems .= (<<ENDMENUITEMS);
1.431 golterma 1441: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in my personal Stored Links repository&&1
1.332 wenzelju 1442: ENDMENUITEMS
1.452 raeburn 1443: $got_wishlist = 1;
1444: }
1.332 wenzelju 1445: }
1.216 albertel 1446:
1.243 tempelho 1447: my $currentURL = &Apache::loncommon::get_symb();
1448: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
1449: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
1450: $menuitems.="s&9&3&";
1451: if(length($annotation) > 0){
1.317 droeschl 1452: $menuitems.="anot2.png";
1.243 tempelho 1453: }else{
1.317 droeschl 1454: $menuitems.="anot.png";
1.243 tempelho 1455: }
1.344 www 1456: $menuitems.="&Notes&&annotate()&";
1.243 tempelho 1457: $menuitems.="Make notes and annotations about this resource&&1\n";
1.428 raeburn 1458: my $is_mobile;
1459: if ($env{'browser.mobile'}) {
1460: $is_mobile = 1;
1461: }
1.243 tempelho 1462:
1.484 raeburn 1463: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.502 raeburn 1464: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) &&
1465: ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)}) &&
1466: ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) {
1.216 albertel 1467: $menuitems.=(<<ENDREALRES);
1.496 raeburn 1468: s&6&3&catalog.png&Info&info[_1]&catalog_info(currentURL,'$is_mobile')&Show Metadata
1.216 albertel 1469: ENDREALRES
1470: }
1.502 raeburn 1471: unless (($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)}) ||
1.484 raeburn 1472: ($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/}) ||
1473: ($env{'request.noversionuri'} =~ m{^/adm/.+/ext\.tool$})) {
1.382 raeburn 1474: $menuitems.=(<<ENDREALRES);
1.344 www 1475: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.382 raeburn 1476: ENDREALRES
1477: }
1.422 raeburn 1478: unless ($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/}) {
1479: $menuitems.=(<<ENDREALRES);
1.344 www 1480: s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77 www 1481: ENDREALRES
1.422 raeburn 1482: }
1.120 raeburn 1483: }
1484: }
1.203 foxr 1485: if ($env{'request.uri'} =~ /^\/res/) {
1.383 raeburn 1486: unless ($got_prt) {
1487: $menuitems .= (<<ENDMENUITEMS);
1.344 www 1488: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 1489: ENDMENUITEMS
1.384 raeburn 1490: $got_prt = 1;
1.383 raeburn 1491: }
1.535 raeburn 1492: unless (($got_wishlist) || ($crsauthor)) {
1.383 raeburn 1493: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
1494: # wishlist is only available for users with access to resource-pool
1495: $menuitems .= (<<ENDMENUITEMS);
1.431 golterma 1496: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
1.332 wenzelju 1497: ENDMENUITEMS
1.383 raeburn 1498: $got_wishlist = 1;
1499: }
1500: }
1501: }
1.41 www 1502: my $buttons='';
1503: foreach (split(/\n/,$menuitems)) {
1504: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 1505: my $idx=10*$rest[0]+$rest[1];
1506: if (&hidden_button_check() eq 'yes') {
1507: if ($idx == 21 ||$idx == 23) {
1508: $buttons.=&switch('','',@rest);
1509: } else {
1510: $buttons.=&clear(@rest);
1511: }
1512: } else {
1513: if ($command eq 's') {
1514: $buttons.=&switch('','',@rest);
1515: } else {
1516: $buttons.=&clear(@rest);
1517: }
1.41 www 1518: }
1519: }
1.524 raeburn 1520: my ($showprogress,$linkprotout);
1.445 raeburn 1521: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
1522: $showprogress = &placement_progress();
1523: }
1.524 raeburn 1524: if ($env{'request.deeplink.login'}) {
1525: $linkprotout = &linkprot_exit();
1526: }
1.445 raeburn 1527:
1528: my $addremote=0;
1529: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.148 albertel 1530:
1.301 droeschl 1531: if ($addremote) {
1.458 raeburn 1532: my ($countdown,$buttonshide);
1.436 raeburn 1533: if ($env{'request.filename'} =~ /\.page$/) {
1534: my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
1535: if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
1.458 raeburn 1536: $countdown = $breadcrumb_tools{'tools'}->[0];
1.436 raeburn 1537: }
1.458 raeburn 1538: $buttonshide = $pagebuttonshide;
1.436 raeburn 1539: } else {
1540: $countdown = &countdown_timer();
1.458 raeburn 1541: $buttonshide = &hidden_button_check();
1.436 raeburn 1542: }
1.342 www 1543: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 1544:
1.342 www 1545: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.312 droeschl 1546: 'navigation', @inlineremote[21,23]);
1547:
1.458 raeburn 1548: if ($buttonshide eq 'yes') {
1.378 raeburn 1549: if ($countdown) {
1550: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
1551: }
1.524 raeburn 1552: if ($linkprotout) {
1553: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
1554: }
1.445 raeburn 1555: if ($showprogress) {
1556: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
1557: }
1.378 raeburn 1558: } else {
1559: my @tools = @inlineremote[93,91,81,82,83];
1560: if ($countdown) {
1561: unshift(@tools,$countdown);
1562: }
1.524 raeburn 1563: if ($linkprotout) {
1564: unshift(@tools,$linkprotout);
1565: }
1.342 www 1566: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.378 raeburn 1567: 'tools',@tools);
1.313 droeschl 1568:
1.549 raeburn 1569: #exit editing link/icon when using daxe in construction space
1.313 droeschl 1570: #publish button in construction space
1571: if ($env{'request.state'} eq 'construct'){
1.549 raeburn 1572: if ($in_daxe) {
1573: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1574: 'advtools', $inlineremote[76]);
1575: }
1.342 www 1576: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 1577: 'advtools', $inlineremote[63]);
1.342 www 1578: } else {
1579: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 1580: 'tools', $inlineremote[63]);
1.313 droeschl 1581: }
1.390 raeburn 1582: &advtools_crumbs(@inlineremote);
1.549 raeburn 1583: #options link/icon in constructions space viewed with course role
1.548 raeburn 1584: if (($env{'request.state'} eq 'construct') &&
1585: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1586: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1587: 'advtools', $inlineremote[75]);
1588: }
1.301 droeschl 1589: }
1.445 raeburn 1590: } else {
1591: if ($showprogress) {
1592: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
1593: }
1.524 raeburn 1594: if ($linkprotout) {
1595: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
1596: }
1.38 www 1597: }
1.433 raeburn 1598: my ($topic_help,$topic_help_text);
1.550 raeburn 1599: if ($toplevel_cstr && !$crsauthor_cstr) {
1.434 raeburn 1600: if ((($ENV{'SERVER_PORT'} == 443) ||
1601: ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) &&
1602: (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {
1.433 raeburn 1603: $topic_help = 'Authoring_WebDAV,Authoring_WebDAV_Mac_10v6,Authoring_WebDAV_Mac_10v10,'.
1604: 'Authoring_WebDAV_Windows_v7,Authoring_WebDAV_Linux_Centos';
1605: $topic_help_text = 'About WebDAV access';
1606: }
1607: }
1.524 raeburn 1608: if (ref($showncrumbsref)) {
1609: $$showncrumbsref = 1;
1610: }
1.342 www 1611: return &Apache::lonhtmlcommon::scripttag('', 'start')
1.433 raeburn 1612: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text)
1.342 www 1613: . &Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 1614: }
1615:
1.389 raeburn 1616: sub get_editbutton {
1.468 raeburn 1617: my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg,$hostname) = @_;
1.398 raeburn 1618: my $jscall;
1619: if (($forceview) && ($env{'form.todocs'})) {
1.463 raeburn 1620: my ($folderpath,$command,$navmap);
1.398 raeburn 1621: if ($env{'request.symb'}) {
1.463 raeburn 1622: $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap);
1.398 raeburn 1623: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
1624: $folderpath = $env{'form.folderpath'};
1625: $command = '&forcesupplement=1';
1626: }
1627: $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
1628: $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
1629: } else {
1.459 raeburn 1630: my $suppanchor;
1631: if ($env{'form.folderpath'}) {
1632: $suppanchor = $env{'form.anchor'};
1633: }
1.527 raeburn 1634: my $shownsymb;
1635: if ($env{'request.symb'}) {
1636: $shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'});
1637: }
1.398 raeburn 1638: $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
1.527 raeburn 1639: $forceedit,$forcereg,$env{'request.symb'},$shownsymb,
1.393 raeburn 1640: &escape($env{'form.folderpath'}),
1.468 raeburn 1641: &escape($env{'form.title'}),$hostname,
1642: $env{'form.idx'},&escape($env{'form.suppurl'}),
1643: $env{'form.todocs'},$suppanchor);
1.398 raeburn 1644: }
1.389 raeburn 1645: if ($jscall) {
1.390 raeburn 1646: my $icon = 'pcstr.png';
1647: my $label = 'Edit';
1648: if ($forceview) {
1649: $icon = 'tolastloc.png';
1650: $label = 'Exit Editing';
1651: }
1652: &switch('','',6,1,$icon,$label,'resource[_2]',
1653: $jscall,"Edit this resource");
1654: return 1;
1655: }
1656: return;
1657: }
1658:
1659: sub prepare_functions {
1.468 raeburn 1660: my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$hostname) = @_;
1.390 raeburn 1661: unless ($env{'request.registered'}) {
1662: undef(@inlineremote);
1663: }
1664: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
1665: $forceview);
1666:
1667: if ($env{'request.course.id'}) {
1668: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1669: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1670: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1671: }
1672:
1673: my $editbutton = '';
1.480 raeburn 1674: my $viewsrcbutton = '';
1.514 raeburn 1675: my $clientip = &Apache::lonnet::get_requestor_ip();
1.390 raeburn 1676: #
1.480 raeburn 1677: # Determine whether or not to display 'Edit' or 'View Source' icon/button
1.390 raeburn 1678: #
1679: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.514 raeburn 1680: my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$2,$1);
1.390 raeburn 1681: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.391 raeburn 1682: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1683: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1684: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1.504 raeburn 1685: if (($cfile) && ($home ne '') && ($home ne 'no_host') && (!$blocked)) {
1.391 raeburn 1686: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.390 raeburn 1687: $forceedit,$forceview,$forcereg);
1688: }
1.541 raeburn 1689: } elsif (!$env{'request.course.id'}) {
1690: if (($env{'user.author'}) && ($resurl eq '/adm/viewcoauthors')) {
1691: if ($env{'request.role'} =~/^(ca|au)/) {
1692: my ($audom,$auname);
1693: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
1694: ($audom,$auname) = ($env{'user.domain'},$env{'user.name'});
1695: } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)}) {
1696: ($audom,$auname) = ($1,$2);
1697: }
1698: if (($audom ne '') && ($auname ne '')) {
1699: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1700: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1701: &Apache::lonnet::can_edit_resource($file,$auname,$audom,
1702: $resurl);
1703: if ($cfile) {
1704: $editbutton = &get_editbutton($resurl,'','',$forceedit,
1705: $forceview);
1706: }
1707: }
1708: }
1709: } elsif (($env{'user.author'}) && ($env{'request.filename'}) &&
1710: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1.390 raeburn 1711: #
1712: # Currently do not have the role of author or co-author.
1713: # Do we have authoring privileges for the resource?
1714: #
1.541 raeburn 1715: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1716: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1717: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1718: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1719: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
1720: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1721: $forceedit,$forceview,$forcereg);
1722: }
1.390 raeburn 1723: }
1724: } elsif ($env{'request.course.id'}) {
1725: #
1726: # This applies in course context
1727: #
1.412 raeburn 1728: if (($perms{'mdc'}) &&
1.469 raeburn 1729: (($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) ||
1.477 raeburn 1730: ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) ||
1731: (($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) {
1.470 raeburn 1732: if ($resurl =~ m{^/}) {
1733: $cfile = $resurl;
1734: } else {
1735: $cfile = "/$resurl";
1736: }
1.411 raeburn 1737: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1738: if ($env{'form.forceedit'}) {
1739: $forceview = 1;
1.390 raeburn 1740: } else {
1.411 raeburn 1741: $forceedit = 1;
1.390 raeburn 1742: }
1.477 raeburn 1743: if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) {
1744: my $text = 'Edit Folder';
1745: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
1746: "gocmd('/adm/coursedocs','direct')",
1747: 'Folder/Page Content');
1748: $editbutton = 1;
1749: } else {
1750: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1751: $forceedit,$forceview,$forcereg,
1752: $hostname);
1753: }
1.393 raeburn 1754: } elsif (($resurl eq '/adm/extresedit') &&
1755: (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
1756: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1757: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
1758: $env{'form.symb'});
1759: if ($cfile ne '') {
1760: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.468 raeburn 1761: $forceedit,$forceview,$forcereg);
1.393 raeburn 1762: }
1.406 raeburn 1763: } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
1764: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
1765: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1766: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
1767: $env{'form.symb'});
1768: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1769: $forceedit,$forceview,$forcereg);
1.405 raeburn 1770: } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
1771: ($resurl ne '/cgi-bin/printout.pl')) {
1.390 raeburn 1772: if ($env{'request.filename'}) {
1.547 raeburn 1773: my $file;
1774: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1775: if ($env{'request.filename'} =~ m{^\Q$londocroot\E/priv/}) {
1776: $file = $env{'request.filename'};
1777: $file =~ s{^\Q$londocroot\E/}{};
1778: } else {
1779: $file=&Apache::lonnet::declutter($env{'request.filename'});
1780: }
1.390 raeburn 1781: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1782: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1783: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1784: if ($cfile ne '') {
1785: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.468 raeburn 1786: $forceedit,$forceview,$forcereg,
1787: $hostname);
1.390 raeburn 1788: }
1.480 raeburn 1789: if ((($cfile eq '') || (!$editbutton)) &&
1790: ($resurl =~ /$LONCAPA::assess_re/)) {
1791: my $showurl = &Apache::lonnet::clutter($resurl);
1.501 raeburn 1792: my $crs_sec = $env{'request.course.id'} . (($env{'request.course.sec'} ne '')
1793: ? "/$env{'request.course.sec'}"
1794: : '');
1.480 raeburn 1795: if ((&Apache::lonnet::allowed('cre','/')) &&
1796: (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) {
1797: $viewsrcbutton = 1;
1.501 raeburn 1798: } elsif (&Apache::lonnet::allowed('vxc',$crs_sec)) {
1.480 raeburn 1799: if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) {
1800: my $auname = $1;
1801: if (($env{'request.course.adhocsrcaccess'} ne '') &&
1802: (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
1803: $viewsrcbutton = 1;
1.481 raeburn 1804: } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') &&
1.501 raeburn 1805: (&Apache::lonnet::allowed('bre',$crs_sec))) {
1.481 raeburn 1806: $viewsrcbutton = 1;
1.480 raeburn 1807: }
1808: }
1809: }
1810: if ($viewsrcbutton) {
1811: &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()',
1812: 'View source code');
1813: }
1814: }
1.390 raeburn 1815: }
1816: }
1817: }
1818: # End determination of 'Edit' icon/button display
1819:
1.393 raeburn 1820: if ($env{'request.course.id'}) {
1.390 raeburn 1821: # This applies to about me page for users in a course
1.391 raeburn 1822: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.390 raeburn 1823: my ($sdom,$sname) = ($1,$2);
1824: unless (&Apache::lonnet::is_course($sdom,$sname)) {
1.514 raeburn 1825: my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$sname,$sdom);
1.504 raeburn 1826: unless ($blocked) {
1827: &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
1828: '',
1829: "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
1830: 'Send message to specific user');
1831: }
1.390 raeburn 1832: }
1.391 raeburn 1833: my $hideprivileged = 1;
1834: if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
1835: $hideprivileged)) {
1.390 raeburn 1836: foreach my $priv ('vsa','vgr','srm') {
1837: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
1838: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
1839: $perms{$priv} =
1840: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
1841: }
1842: }
1843: if ($perms{'vsa'}) {
1844: &switch('','',6,5,'trck-22x22.png','Activity',
1845: '',
1846: "go('/adm/trackstudent?selected_student=$sname:$sdom')",
1847: 'View recent activity by this person');
1848: }
1849: if ($perms{'vgr'}) {
1850: &switch('','',6,6,'rsrv-22x22.png','Reservations',
1851: '',
1.415 raeburn 1852: "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
1.390 raeburn 1853: 'Slot reservation history');
1854: }
1855: if ($perms{'srm'}) {
1856: &switch('','',6,7,'contact-new-22x22.png','Records',
1857: '',
1.415 raeburn 1858: "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
1.390 raeburn 1859: 'Add records');
1860: }
1861: }
1.393 raeburn 1862: }
1863: if (($env{'form.folderpath'} =~ /^supplemental/) &&
1864: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
1865: (($resurl =~ m{^/adm/wrapper/ext/}) ||
1.472 raeburn 1866: ($resurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) ||
1.393 raeburn 1867: ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
1.397 raeburn 1868: ($resurl eq '/adm/supplemental') ||
1869: ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
1870: ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
1.393 raeburn 1871: my @folders=split('&',$env{'form.folderpath'});
1.394 raeburn 1872: if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
1.459 raeburn 1873: my $suppanchor;
1874: if ($resurl =~ m{^/adm/wrapper/ext/}) {
1875: $suppanchor = $env{'form.anchor'};
1876: }
1.393 raeburn 1877: my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
1.468 raeburn 1878: my $link = '/adm/coursedocs?command=direct&forcesupplement=1&supppath='.
1879: "$esc_path&anchor=$suppanchor";
1880: if ($env{'request.use_absolute'} ne '') {
1881: $link = $env{'request.use_absolute'}.$link;
1882: }
1.393 raeburn 1883: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
1.468 raeburn 1884: "location.href='$link'",'Folder/Page Content');
1.393 raeburn 1885: }
1.390 raeburn 1886: }
1887: }
1888:
1889: # End checking for items for about me page for users in a course
1.393 raeburn 1890: if ($docscrumbs) {
1891: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1892: &advtools_crumbs(@inlineremote);
1893: return $editbutton;
1894: } elsif ($env{'request.registered'}) {
1.480 raeburn 1895: return $editbutton || $viewsrcbutton;
1.390 raeburn 1896: } else {
1897: if (ref($bread_crumbs) eq 'ARRAY') {
1898: if (@inlineremote > 0) {
1899: if (ref($advtools) eq 'ARRAY') {
1900: @{$advtools} = @inlineremote;
1901: }
1902: }
1903: return;
1904: } elsif (@inlineremote > 0) {
1905: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1906: &advtools_crumbs(@inlineremote);
1907: return &Apache::lonhtmlcommon::scripttag('', 'start')
1908: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
1909: . &Apache::lonhtmlcommon::scripttag('', 'end');
1910: }
1911: }
1912: }
1913:
1914: sub advtools_crumbs {
1915: my @funcs = @_;
1916: if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
1917: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1918: 'advtools', @funcs[61,64,65,66,67,74]);
1919: } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
1.515 raeburn 1920: if ($env{'request.state'} eq 'construct') {
1921: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.552 raeburn 1922: 'advtools', @funcs[61,73,74,71,72,77]);
1.515 raeburn 1923: } else {
1924: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.530 raeburn 1925: 'advtools', @funcs[61,71,72,73,74,75,92]);
1.515 raeburn 1926: }
1.393 raeburn 1927: } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
1928: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.407 raeburn 1929: 'advtools', $funcs[61]);
1.393 raeburn 1930: }
1.412 raeburn 1931: return;
1.258 raeburn 1932: }
1933:
1.2 www 1934: # ================================================================== Raw Config
1935:
1.3 www 1936: sub clear {
1937: my ($row,$col)=@_;
1.316 droeschl 1938: $inlineremote[10*$row+$col]='';
1.561 ! raeburn 1939: return '';
1.3 www 1940: }
1941:
1.40 www 1942: # ============================================ Switch a button or create a link
1.25 matthew 1943: # Switch acts on the javascript that is executed when a button is clicked.
1944: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1945:
1.2 www 1946: sub switch {
1.530 raeburn 1947: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak,$form)=@_;
1.2 www 1948: $act=~s/\$uname/$uname/g;
1949: $act=~s/\$udom/$udom/g;
1.88 www 1950: $desc=&mt($desc);
1.209 www 1951: my $idx=10*$row+$col;
1952: $category_members{$cat}.=':'.$idx;
1953:
1.320 droeschl 1954: # Inline Menu
1.317 droeschl 1955: if ($nobreak==2) { return ''; }
1.561 ! raeburn 1956: my ($text,$alttext);
! 1957: $text=&mt($top).' '.&mt($bot);
1.317 droeschl 1958: $text=~s/\s*\-\s*//gs;
1.561 ! raeburn 1959: if ($top) {
! 1960: $alttext = &mt("$top icon");
! 1961: } elsif ($bot) {
! 1962: $alttext = &mt("$bot icon");
! 1963: } elsif ($nobreak == 3) {
! 1964: $alttext = &mt('Go forward icon');
! 1965: } elsif ($nobreak) {
! 1966: $alttext = &mt('Go back icon');
! 1967: } else {
! 1968: $alttext = &mt('icon');
! 1969: }
1.105 www 1970:
1.317 droeschl 1971: my $pic=
1.561 ! raeburn 1972: '<img alt="'.$alttext.'" src="'.
1.225 albertel 1973: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1974: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 1975: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1976: # Main Menu
1.103 www 1977: if ($nobreak==3) {
1.209 www 1978: $inlineremote[$idx]="\n".
1.561 ! raeburn 1979: '<th class="LC_menubuttons_text" align="right">'.$text.
! 1980: '</th><td align="left">'.
1.103 www 1981: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1982: } elsif ($nobreak) {
1.209 www 1983: $inlineremote[$idx]="\n<tr>".
1.561 ! raeburn 1984: '<th align="left">'.
! 1985: '<a href="javascript:'.$act.';">'.$pic.'</a></th>
1.215 www 1986: <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 1987: } else {
1.209 www 1988: $inlineremote[$idx]="\n<tr>".
1.561 ! raeburn 1989: '<th align="left">'.
1.103 www 1990: '<a href="javascript:'.$act.';">'.$pic.
1.561 ! raeburn 1991: '</a></th><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1992: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1993: }
1.317 droeschl 1994: } else {
1.103 www 1995: # Inline Menu
1.378 raeburn 1996: my @tools = (93,91,81,82,83);
1997: unless ($env{'request.state'} eq 'construct') {
1998: push(@tools,63);
1999: }
1.492 raeburn 2000: if ((($env{'environment.icons'} eq 'iconsonly') ||
2001: ($env{'environment.icons'} eq '') && ($env{'request.lti.login'})) &&
1.378 raeburn 2002: (grep(/^$idx$/,@tools))) {
2003: $inlineremote[$idx] =
2004: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
2005: } else {
1.561 ! raeburn 2006: my $linktext = &mt($top);
1.378 raeburn 2007: $inlineremote[$idx] =
1.317 droeschl 2008: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.561 ! raeburn 2009: '<span class="LC_menubuttons_inline_text">'.$linktext.' </span></a>'.$form;
1.378 raeburn 2010: }
1.317 droeschl 2011: }
1.56 www 2012: return '';
1.2 www 2013: }
2014:
2015: sub secondlevel {
2016: my $output='';
2017: my
1.209 www 2018: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 2019: if ($prt eq 'any') {
1.209 www 2020: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2021: } elsif ($prt=~/^r(\w+)/) {
2022: if ($rol eq $1) {
1.209 www 2023: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2024: }
2025: }
2026: return $output;
2027: }
2028:
1.56 www 2029: sub inlinemenu {
1.210 albertel 2030: undef(@inlineremote);
2031: undef(%category_members);
1.275 www 2032: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 2033: &rawconfig(1);
1.561 ! raeburn 2034: my $output='<div class="LC_landmark" role="main">'."\n";
1.209 www 2035: for (my $col=1; $col<=2; $col++) {
1.561 ! raeburn 2036: $output .= '<div class="LC_mainmenu">'."\n";
1.209 www 2037: for (my $row=1; $row<=8; $row++) {
2038: foreach my $cat (keys(%category_members)) {
2039: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 2040: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 2041: $output.='<div class="LC_Box LC_400Box">';
1.561 ! raeburn 2042: $output.='<h2 class="LC_hcell LC_heading_2">'.&mt($category_names{$cat}).'</h2>';
1.247 harmsja 2043: $output.='<table>';
1.240 riegler 2044: my %active=();
2045: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
2046: if ($inlineremote[$menu_item]) {
2047: $active{$menu_item}=1;
2048: }
2049: }
2050: foreach my $item (sort(keys(%active))) {
2051: $output.=$inlineremote[$item];
2052: }
2053: $output.='</table>';
1.245 harmsja 2054: $output.='</div>';
1.240 riegler 2055: }
2056: }
1.561 ! raeburn 2057: $output.="</div>";
1.240 riegler 2058: }
1.561 ! raeburn 2059: $output .= '<div style="clear:both"></div></div>'."\n";
1.240 riegler 2060: return $output;
2061: }
2062:
1.2 www 2063: sub rawconfig {
1.274 www 2064: #
2065: # This evaluates mydesk.tab
2066: # Need to add more positions and more privileges to deal with all
2067: # menu items.
2068: #
1.34 www 2069: my $textualoverride=shift;
2070: my $output='';
1.316 droeschl 2071: return '' unless $textualoverride;
1.152 albertel 2072: my $uname=$env{'user.name'};
2073: my $udom=$env{'user.domain'};
2074: my $adv=$env{'user.adv'};
1.266 raeburn 2075: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 2076: my $author=$env{'user.author'};
1.5 www 2077: my $crs='';
1.295 raeburn 2078: my $crstype='';
1.152 albertel 2079: if ($env{'request.course.id'}) {
2080: $crs='/'.$env{'request.course.id'};
2081: if ($env{'request.course.sec'}) {
2082: $crs.='_'.$env{'request.course.sec'};
1.7 www 2083: }
1.8 www 2084: $crs=~s/\_/\//g;
1.295 raeburn 2085: $crstype = &Apache::loncommon::course_type();
1.5 www 2086: }
1.152 albertel 2087: my $pub=($env{'request.state'} eq 'published');
2088: my $con=($env{'request.state'} eq 'construct');
2089: my $rol=$env{'request.role'};
1.427 raeburn 2090: my $requested_domain;
2091: if ($rol) {
2092: $requested_domain = $env{'request.role.domain'};
2093: }
1.184 raeburn 2094: foreach my $line (@desklines) {
1.209 www 2095: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 2096: $prt=~s/\$uname/$uname/g;
2097: $prt=~s/\$udom/$udom/g;
1.295 raeburn 2098: if ($prt =~ /\$crs/) {
2099: next unless ($env{'request.course.id'});
2100: next if ($crstype eq 'Community');
2101: $prt=~s/\$crs/$crs/g;
2102: } elsif ($prt =~ /\$cmty/) {
2103: next unless ($env{'request.course.id'});
2104: next if ($crstype ne 'Community');
2105: $prt=~s/\$cmty/$crs/g;
2106: }
1.427 raeburn 2107: if ($prt =~ m/\$requested_domain/) {
2108: if ((!$requested_domain) && ($pro eq 'pbre') && ($env{'user.adv'})) {
2109: $prt=~s/\$requested_domain/$env{'user.domain'}/g;
2110: } else {
2111: $prt=~s/\$requested_domain/$requested_domain/g;
2112: }
2113: }
1.211 www 2114: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 2115: if ($pro eq 'clear') {
1.4 www 2116: $output.=&clear($row,$col);
1.3 www 2117: } elsif ($pro eq 'any') {
1.2 www 2118: $output.=&secondlevel(
1.209 www 2119: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2120: } elsif ($pro eq 'smp') {
2121: unless ($adv) {
2122: $output.=&secondlevel(
1.209 www 2123: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2124: }
2125: } elsif ($pro eq 'adv') {
2126: if ($adv) {
2127: $output.=&secondlevel(
1.209 www 2128: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2129: }
1.231 albertel 2130: } elsif ($pro eq 'shc') {
2131: if ($show_course) {
2132: $output.=&secondlevel(
2133: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
2134: }
2135: } elsif ($pro eq 'nsc') {
2136: if (!$show_course) {
2137: $output.=&secondlevel(
2138: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
2139: }
1.81 matthew 2140: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 2141: my $priv = $1;
2142: if ($priv =~ /^mdc(Course|Community)/) {
2143: if ($crstype eq $1) {
2144: $priv = 'mdc';
2145: } else {
2146: next;
2147: }
1.541 raeburn 2148: } elsif ($priv eq 'cca') {
2149: next if ($rol eq 'cm');
1.295 raeburn 2150: }
1.427 raeburn 2151: if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
2152: (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
2153: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 2154: }
1.295 raeburn 2155: } elsif ($pro eq 'course') {
2156: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 2157: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 2158: }
1.295 raeburn 2159: } elsif ($pro eq 'community') {
2160: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
2161: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
2162: }
1.124 matthew 2163: } elsif ($pro =~ /^courseenv_(.*)$/) {
2164: my $key = $1;
1.307 raeburn 2165: if ($crstype ne 'Community') {
2166: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
2167: if ($key eq 'canuse_pdfforms') {
2168: if ($env{'request.course.id'} && $coursepref eq '') {
2169: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
2170: $coursepref = $domdefs{'canuse_pdfforms'};
2171: }
2172: }
2173: if ($coursepref) {
2174: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
2175: }
1.295 raeburn 2176: }
2177: } elsif ($pro =~ /^communityenv_(.*)$/) {
2178: my $key = $1;
1.307 raeburn 2179: if ($crstype eq 'Community') {
2180: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
2181: if ($key eq 'canuse_pdfforms') {
2182: if ($env{'request.course.id'} && $coursepref eq '') {
2183: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
2184: $coursepref = $domdefs{'canuse_pdfforms'};
2185: }
2186: }
2187: if ($coursepref) {
2188: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
2189: }
1.124 matthew 2190: }
1.81 matthew 2191: } elsif ($pro =~ /^course_(.*)$/) {
2192: # Check for permissions inside of a course
1.295 raeburn 2193: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 2194: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
2195: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 2196: )) {
1.209 www 2197: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 2198: }
1.295 raeburn 2199: } elsif ($pro =~ /^community_(.*)$/) {
2200: # Check for permissions inside of a community
2201: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
2202: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
2203: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
2204: )) {
2205: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
2206: }
1.4 www 2207: } elsif ($pro eq 'author') {
2208: if ($author) {
1.152 albertel 2209: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 2210: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 2211: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 2212: # Check that we are on the correct machine
1.29 matthew 2213: my $cadom=$requested_domain;
1.152 albertel 2214: my $caname=$env{'user.name'};
1.234 raeburn 2215: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 2216: ($cadom,$caname)=
1.206 albertel 2217: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 2218: }
2219: $act =~ s/\$caname/$caname/g;
1.353 www 2220: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 2221: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 2222: my $allowed=0;
2223: my @ids=&Apache::lonnet::current_machine_ids();
2224: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2225: if ($allowed) {
1.209 www 2226: $output.=&switch($caname,$cadom,
2227: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 2228: }
1.6 www 2229: }
1.2 www 2230: }
1.541 raeburn 2231: } elsif ($pro eq 'coauthor') {
2232: if ($env{'request.role'}=~ m{^(ca|aa)\./($match_domain)/($match_username)$}) {
2233: my ($role,$audom,$auname) = ($1,$2,$3);
2234: if ((($prt eq 'raa') && ($role eq 'aa')) ||
2235: (($prt eq 'rca') && ($role eq 'ca') &&
2236: (!$env{"environment.internal.manager./$audom/$auname"}))) {
2237: $output.=&switch($auname,$audom,
2238: $row,$col,$img,$top,$bot,$act,$desc,$cat);
2239: }
2240: }
2241: } elsif ($pro eq 'coauthorenv_manager') {
2242: if ($env{'request.role'}=~ m{^ca\./($match_domain)/($match_username)$}) {
2243: my ($audom,$auname) = ($1,$2);
2244: if ($env{"environment.internal.manager./$audom/$auname"}) {
2245: $output.=&switch($auname,$audom,
2246: $row,$col,$img,$top,$bot,$act,$desc,$cat);
2247: }
2248: }
1.248 raeburn 2249: } elsif ($pro eq 'tools') {
2250: my @tools = ('aboutme','blog','portfolio');
2251: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 2252: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 2253: $env{'user.domain'},
2254: $prt,undef,'tools')) {
2255: $output.=&clear($row,$col);
2256: next;
2257: }
1.278 raeburn 2258: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
2259: if (($prt eq 'reqcrsnsc') && ($show_course)) {
2260: next;
2261: }
2262: if (($prt eq 'reqcrsshc') && (!$show_course)) {
2263: next;
2264: }
1.279 raeburn 2265: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 2266: if (!$showreqcrs) {
1.248 raeburn 2267: $output.=&clear($row,$col);
2268: next;
2269: }
2270: }
2271: $prt='any';
2272: $output.=&secondlevel(
2273: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 2274: }
1.13 harris41 2275: }
1.2 www 2276: return $output;
2277: }
2278:
1.279 raeburn 2279: sub check_for_rcrs {
2280: my $showreqcrs = 0;
1.443 raeburn 2281: my @reqtypes = ('official','unofficial','community','textbook','placement');
1.280 raeburn 2282: foreach my $type (@reqtypes) {
1.279 raeburn 2283: if (&Apache::lonnet::usertools_access($env{'user.name'},
2284: $env{'user.domain'},
2285: $type,undef,'requestcourses')) {
2286: $showreqcrs = 1;
2287: last;
2288: }
2289: }
1.280 raeburn 2290: if (!$showreqcrs) {
2291: foreach my $type (@reqtypes) {
2292: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1.522 raeburn 2293: my @domains = split(',',$env{'environment.reqcrsotherdom.'.$type});
2294: foreach my $entry (@domains) {
2295: my ($extdom,$extopt) = split(':',$entry);
2296: if (&Apache::lonnet::will_trust('reqcrs',$env{'user.domain'},$extdom)) {
2297: $showreqcrs = 1;
2298: last;
2299: }
2300: }
2301: if ($showreqcrs) {
2302: last;
2303: }
1.280 raeburn 2304: }
2305: }
2306: }
1.279 raeburn 2307: return $showreqcrs;
2308: }
2309:
1.306 raeburn 2310: sub dc_popup_js {
2311: my %lt = &Apache::lonlocal::texthash(
2312: more => '(More ...)',
2313: less => '(Less ...)',
2314: );
2315: return <<"END";
2316:
2317: function showCourseID() {
2318: document.getElementById('dccid').style.display='block';
2319: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 2320: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 2321: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 2322: return;
2323: }
2324:
2325: function hideCourseID() {
2326: document.getElementById('dccid').style.display='none';
1.369 raeburn 2327: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 2328: return;
2329: }
2330:
2331: END
2332:
2333: }
2334:
1.378 raeburn 2335: sub countdown_toggle_js {
2336: return <<"END";
2337:
2338: function toggleCountdown() {
2339: var countdownid = document.getElementById('duedatecountdown');
2340: var currstyle = countdownid.style.display;
2341: if (currstyle == 'inline') {
2342: countdownid.style.display = 'none';
2343: document.getElementById('ddcountcollapse').innerHTML='';
2344: document.getElementById('ddcountexpand').innerHTML='◄ ';
2345: } else {
2346: countdownid.style.display = 'inline';
2347: document.getElementById('ddcountcollapse').innerHTML='► ';
2348: document.getElementById('ddcountexpand').innerHTML='';
2349: }
2350: return;
2351: }
2352:
2353: END
2354: }
2355:
1.435 musolffc 2356: # This creates a "done button" for timed events. The confirmation box is a jQuery
1.440 raeburn 2357: # dialog widget. If the interval parameter requires a proctor key for the timed
2358: # event to be marked done, there will also be a textbox where that can be entered.
2359: # Clicking OK will set the value of LC_interval_done to 'true', and, if needed will
2360: # set the value of LC_interval_done_proctorpass to the text entered in that box,
2361: # and submit the corresponding form.
2362: #
2363: # The &zero_time() routine in lonhomework.pm is called when a page is rendered if
2364: # LC_interval_done is true.
2365: #
1.435 musolffc 2366: sub done_button_js {
1.448 raeburn 2367: my ($type,$width,$height,$proctor,$donebuttontext) = @_;
1.441 raeburn 2368: return unless (($type eq 'map') || ($type eq 'resource'));
1.435 musolffc 2369: my %lt = &Apache::lonlocal::texthash(
2370: title => 'WARNING!',
2371: preamble => 'You are trying to end this timed event early.',
2372: map => 'Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder.',
2373: resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).',
1.440 raeburn 2374: okdone => 'Click "OK" if you are completely finished.',
1.435 musolffc 2375: cancel => 'Click "Cancel" to continue working.',
1.440 raeburn 2376: proctor => 'Ask a proctor to enter the key, then click "OK" if you are completely finished.',
2377: ok => 'OK',
2378: exit => 'Cancel',
2379: key => 'Key:',
2380: nokey => 'A proctor key is required',
1.435 musolffc 2381: );
1.503 raeburn 2382: my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}));
1.441 raeburn 2383: my $navmap = Apache::lonnavmaps::navmap->new();
1.450 raeburn 2384: my ($missing,$tried) = (0,0);
1.441 raeburn 2385: if (ref($navmap)) {
2386: my @resources=();
2387: if ($type eq 'map') {
2388: my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});
1.500 raeburn 2389: if ($env{'request.symb'} =~ /\.page$/) {
2390: @resources=$navmap->retrieveResources($resurl,sub { $_[0]->is_problem() });
2391: } else {
2392: @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() });
2393: }
1.441 raeburn 2394: } else {
2395: my $res = $navmap->getBySymb($env{'request.symb'});
2396: if (ref($res)) {
2397: if ($res->is_problem()) {
2398: push(@resources,$res);
2399: }
2400: }
2401: }
2402: foreach my $res (@resources) {
1.450 raeburn 2403: if (ref($res->parts()) eq 'ARRAY') {
1.441 raeburn 2404: foreach my $part (@{$res->parts()}) {
2405: if (!$res->tries($part)) {
2406: $missing++;
2407: } else {
2408: $tried++;
2409: }
2410: }
2411: }
2412: }
2413: }
2414: if ($missing) {
2415: $lt{'miss'} .= '<p class="LC_error">';
2416: if ($type eq 'map') {
2417: $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,question part,question parts] in this folder.',$missing);
2418: } else {
2419: $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,part] in this question.',$missing);
2420: }
2421: if ($missing > 1) {
2422: $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit answers for them.').'</span>';
2423: } else {
2424: $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'</p>';
2425: }
2426: }
1.449 raeburn 2427: $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"');
1.441 raeburn 2428: if ($proctor) {
2429: if ($height !~ /^\d+$/) {
2430: $height = 400;
2431: if ($missing) {
2432: $height += 60;
1.440 raeburn 2433: }
1.441 raeburn 2434: }
2435: if ($width !~ /^\d+$/) {
2436: $width = 400;
2437: if ($missing) {
2438: $width += 60;
1.440 raeburn 2439: }
1.441 raeburn 2440: }
2441: return <<END;
1.440 raeburn 2442: <form method="post" name="LCdoneButton" action="">
2443: <input type="hidden" name="LC_interval_done" value="" />
2444: <input type="hidden" name="LC_interval_done_proctorpass" value="" />
1.503 raeburn 2445: <input type="hidden" name="symb" value="$shownsymb" />
1.448 raeburn 2446: <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
1.440 raeburn 2447: </form>
2448:
2449: <div id="LC_done-confirm" title="$lt{'title'}">
2450: <p>$lt{'preamble'} $lt{$type}</p>
1.441 raeburn 2451: $lt{'miss'}
1.440 raeburn 2452: <p>$lt{'proctor'}</p>
1.449 raeburn 2453: <form name="LCdoneButtonProctor" action="">
1.440 raeburn 2454: <label>$lt{'key'}<input type="password" name="LC_interval_done_proctorkey" value="" /></label>
2455: <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
2456: </form>
2457: <p>$lt{'cancel'}</p>
2458: </div>
2459:
2460: <script type="text/javascript">
2461: // <![CDATA[
2462: \$( "#LC_done-confirm" ).dialog({ autoOpen: false });
2463: \$( "#LC_done-confirm-opener" ).on("click", function() {
2464: \$( "#LC_done-confirm" ).dialog("open");
2465: \$( "#LC_done-confirm" ).dialog({
2466: height: $height,
2467: width: $width,
2468: modal: true,
2469: resizable: false,
2470: buttons: [
2471: {
2472: text: "$lt{'ok'}",
2473: click: function() {
2474: var proctorkey = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
2475: if ((proctorkey == '') || (proctorkey == null)) {
2476: alert("$lt{'nokey'}");
2477: } else {
2478: \$( '[name="LC_interval_done"]' )[0].value = 'true';
2479: \$( '[name="LC_interval_done_proctorpass"]' )[0].value = proctorkey;
2480: \$( '[name="LCdoneButton"]' )[0].submit();
2481: }
2482: },
2483: },
2484: {
2485: text: "$lt{'exit'}",
2486: click: function() {
2487: \$("#LC_done-confirm").dialog( "close" );
2488: }
2489: }
2490: ],
2491: close: function() {
2492: \$( '[name="LC_interval_done_proctorkey"]' )[0].value = '';
2493: }
2494: });
2495: \$( "#LC_done-confirm" ).find( "form" ).on( "submit", function( event ) {
2496: event.preventDefault();
2497: \$( '[name="LC_interval_done"]' )[0].value = 'true';
2498: \$( '[name="LC_interval_done_proctorpass"]' )[0].value = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
2499: \$( '[name="LCdoneButton"]' )[0].submit();
2500: });
2501: });
2502:
2503: // ]]>
2504: </script>
2505:
2506: END
1.441 raeburn 2507: } else {
2508: if ($height !~ /^\d+$/) {
2509: $height = 320;
2510: if ($missing) {
2511: $height += 60;
1.440 raeburn 2512: }
1.441 raeburn 2513: }
2514: if ($width !~ /^\d+$/) {
2515: $width = 320;
2516: if ($missing) {
2517: $width += 60;
1.440 raeburn 2518: }
1.441 raeburn 2519: }
2520: if ($missing) {
2521: $lt{'miss'} = '</p>'.$lt{'miss'}.'<p>';
2522: }
2523: return <<END;
1.435 musolffc 2524:
2525: <form method="post" name="LCdoneButton" action="">
2526: <input type="hidden" name="LC_interval_done" value="" />
1.503 raeburn 2527: <input type="hidden" name="symb" value="$shownsymb" />
1.449 raeburn 2528: <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
1.435 musolffc 2529: </form>
2530:
2531: <div id="LC_done-confirm" title="$lt{'title'}">
1.441 raeburn 2532: <p>$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}</p>
1.435 musolffc 2533: </div>
2534:
2535: <script type="text/javascript">
2536: // <![CDATA[
2537: \$( "#LC_done-confirm" ).dialog({ autoOpen: false });
2538: \$( "#LC_done-confirm-opener" ).click(function() {
2539: \$( "#LC_done-confirm" ).dialog( "open" );
2540: \$( "#LC_done-confirm" ).dialog({
2541: resizable: false,
2542: height: $height,
1.440 raeburn 2543: width: $width,
1.435 musolffc 2544: modal: true,
1.440 raeburn 2545: buttons: [
2546: {
2547: text: "$lt{'ok'}",
2548: click: function() {
2549: \$( this ).dialog( "close" );
2550: \$( '[name="LC_interval_done"]' )[0].value = 'true';
2551: \$( '[name="LCdoneButton"]' )[0].submit();
2552: },
2553: },
2554: {
2555: text: "$lt{'exit'}",
2556: click: function() {
2557: \$( this ).dialog( "close" );
2558: },
2559: },
2560: ],
2561: });
1.435 musolffc 2562: });
2563: // ]]>
2564: </script>
2565:
2566: END
2567: }
2568: }
2569:
1.530 raeburn 2570: sub view_as_js {
2571: my ($url,$symb) = @_;
2572: my %lt = &Apache::lonlocal::texthash(
2573: ente => 'Enter a username or a student/employee ID',
2574: info => 'Information you entered does not match a valid course user',
2575: );
2576: &js_escape(\%lt);
2577: return <<"END";
2578:
2579: function toggleViewAsUser(change) {
1.536 raeburn 2580: if (document.getElementById('LC_selectuser')) {
2581: var seluserid = document.getElementById('LC_selectuser');
2582: var currstyle = seluserid.style.display;
2583: if (change == 'off') {
2584: document.userview.elements['LC_viewas'].value = '';
2585: document.userview.elements['vuname'].value = '';
2586: document.userview.elements['vid'].value = '';
2587: document.userview.submit();
2588: return;
2589: }
2590: if ((document.getElementById('usexpand')) && (document.getElementById('uscollapse'))) {
2591: if (currstyle == 'inline') {
2592: seluserid.style.display = 'none';
1.561 ! raeburn 2593: document.getElementById('usexpand').style.display= 'inline';
! 2594: document.getElementById('uscollapse').style.display = 'none';
1.536 raeburn 2595: } else {
2596: seluserid.style.display = 'inline';
1.538 raeburn 2597: toggleIdentifier(document.userview);
1.561 ! raeburn 2598: document.getElementById('usexpand').style.display = 'none';
! 2599: document.getElementById('uscollapse').style.display = 'inline';
1.536 raeburn 2600: }
2601: }
1.530 raeburn 2602: }
2603: return;
2604: }
2605:
2606: function validCourseUser(form,change) {
2607: var possuname = form.elements['vuname'].value;
2608: var possuid = form.elements['vid'].value;
1.540 raeburn 2609: var domelem = form.elements['vudom'];
2610: var possudom = '';
2611: if ((domelem.tagName === 'INPUT') && ((domelem.type === 'text') || (domelem.type === 'hidden'))) {
2612: possudom = domelem.value;
2613: } else if (domelem.tagName === 'SELECT') {
2614: possudom = domelem.options[domelem.selectedIndex].value;
2615: }
1.530 raeburn 2616: if ((possuname == '') && (possuid == '')) {
2617: if (change == 'off') {
2618: form.elements['LC_viewas'].value = '';
2619: form.submit();
2620: } else {
2621: alert("$lt{'ente'}");
2622: }
2623: return;
2624: }
2625: var http = new XMLHttpRequest();
2626: var url = "/adm/courseuser";
2627: var params = "uname="+possuname+"&uid="+possuid+"&udom="+possudom;
2628: http.open("POST", url, true);
2629: http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
2630: http.onreadystatechange = function() {
2631: if (http.readyState == 4 && http.status == 200) {
2632: var data = JSON.parse(http.responseText);
2633: if (Array.isArray(data.match)) {
2634: var len = data.match.length;
2635: if (len == 2) {
2636: if (data.match[0] != '' && data.match[1] != '') {
2637: form.elements['LC_viewas'].value = data.match[0]+':'+data.match[1];
2638: form.submit();
2639: }
2640: } else {
2641: alert("$lt{'info'}");
2642: }
2643: }
2644: }
2645: return;
2646: }
2647: http.send(params);
2648: return false;
2649: }
2650:
1.538 raeburn 2651: function toggleIdentifier(form) {
2652: if ((document.getElementById('LC_vuname')) && (document.getElementById('LC_vid'))) {
1.561 ! raeburn 2653: var identifylabel = document.getElementById('LC_vuidentifier');
! 2654: var identifier;
! 2655: var userbyuname;
1.538 raeburn 2656: var radioelem = form.elements['vuidentifier'];
2657: if (radioelem.length > 0) {
2658: var i;
2659: for (i=0; i<radioelem.length; i++) {
2660: if (radioelem[i].checked == true) {
2661: if (radioelem[i].value == 'uname') {
1.561 ! raeburn 2662: userbyuname = 1;
1.538 raeburn 2663: document.getElementById('LC_vuname').type = 'text';
2664: document.getElementById('LC_vid').type = 'hidden';
2665: document.getElementById('LC_vid').value = '';
2666: } else {
1.561 ! raeburn 2667: userbyuname = 0;
1.538 raeburn 2668: document.getElementById('LC_vuname').type = 'hidden';
2669: document.getElementById('LC_vuname').value = '';
2670: document.getElementById('LC_vid').type = 'text';
2671: }
2672: break;
2673: }
2674: }
1.561 ! raeburn 2675: if (identifylabel) {
! 2676: if (userbyuname) {
! 2677: identifylabel.setAttribute("for","LC_vuname");
! 2678: } else {
! 2679: identifylabel.setAttribute("for","LC_vid");
! 2680: }
! 2681: }
1.538 raeburn 2682: }
2683: }
2684: return;
2685: }
2686:
1.530 raeburn 2687: END
2688: }
2689:
1.42 www 2690: sub utilityfunctions {
1.421 raeburn 2691: my ($httphost) = @_;
1.152 albertel 2692: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.494 raeburn 2693: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
2694: if ($currenturl =~ m{^/adm/wrapper/ext/}) {
2695: if ($env{'request.external.querystring'}) {
1.293 raeburn 2696: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1.494 raeburn 2697: }
1.495 raeburn 2698: my ($anchor) = ($env{'request.symb'} =~ /(\#[^\#]+)$/);
2699: if (($anchor) && ($currenturl !~ /\Q$anchor\E$/)) {
1.494 raeburn 2700: $currenturl .= $1;
2701: }
1.293 raeburn 2702: }
1.183 www 2703: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.175 albertel 2704:
1.306 raeburn 2705: my $dc_popup_cid;
2706: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
2707: $env{'course.'.$env{'request.course.id'}.
2708: '.domain'}.'/'})) {
2709: $dc_popup_cid = &dc_popup_js();
2710: }
2711:
1.175 albertel 2712: my $start_page_annotate =
2713: &Apache::loncommon::start_page('Annotator',undef,
2714: {'only_body' => 1,
2715: 'js_ready' => 1,
2716: 'bgcolor' => '#BBBBBB',
2717: 'add_entries' => {
2718: 'onload' => 'javascript:document.goannotate.submit();'}});
2719:
1.205 albertel 2720: my $end_page_annotate =
2721: &Apache::loncommon::end_page({'js_ready' => 1});
2722:
1.389 raeburn 2723: my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
1.336 raeburn 2724:
1.368 www 2725: my $esc_url=&escape($currenturl);
2726: my $esc_symb=&escape($currentsymb);
1.515 raeburn 2727: my $newname = &mt('New Name');
1.555 raeburn 2728: &js_escape(\$newname);
1.332 wenzelju 2729:
1.378 raeburn 2730: my $countdown = &countdown_toggle_js();
2731:
1.530 raeburn 2732: my $viewuser;
2733: if (($env{'request.course.id'}) &&
2734: ($env{'request.symb'} ne '') &&
2735: ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
2736: my $canview;
1.558 raeburn 2737: foreach my $priv ('mgr','vgr') {
1.530 raeburn 2738: $canview = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
2739: if (!$canview && $env{'request.course.sec'} ne '') {
2740: $canview =
2741: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
2742: }
2743: last if ($canview);
2744: }
2745: if ($canview) {
2746: $viewuser = &view_as_js($esc_url,$esc_symb);
2747: }
2748: }
2749:
1.516 raeburn 2750: my ($ltitarget,$deeplinktarget);
1.487 raeburn 2751: if ($env{'request.lti.login'}) {
2752: $ltitarget = $env{'request.lti.target'};
2753: }
1.516 raeburn 2754: if ($env{'request.deeplink.login'}) {
2755: $deeplinktarget = $env{'request.deeplink.target'};
2756: }
1.487 raeburn 2757:
1.493 raeburn 2758: my $annotateurl = '/adm/annotation';
2759: if ($httphost) {
2760: $annotateurl = '/adm/annotations';
2761: }
1.429 raeburn 2762: my $hostvar = '
2763: function setLCHost() {
2764: var lcHostname="";
2765: ';
2766: if ($httphost =~ m{^https?\://}) {
2767: $hostvar .= ' var lcServer="'.$httphost.'";'."\n".
2768: ' var hostReg = /^https?:\/\/([^\/]+)$/i;'."\n".
2769: ' var match = hostReg.exec(lcServer);'."\n".
2770: ' if (match.length) {'."\n".
2771: ' if (match[1] == location.hostname) {'."\n".
2772: ' lcHostname=lcServer;'."\n".
2773: ' }'."\n".
2774: ' }'."\n";
2775: }
2776:
2777: $hostvar .= ' return lcHostname;'."\n".
2778: '}'."\n";
2779:
1.42 www 2780: return (<<ENDUTILITY)
1.429 raeburn 2781: $hostvar
1.368 www 2782: var currentURL=unescape("$esc_url");
2783: var reloadURL=unescape("$esc_url");
2784: var currentSymb=unescape("$esc_symb");
1.42 www 2785:
1.306 raeburn 2786: $dc_popup_cid
1.114 albertel 2787:
1.389 raeburn 2788: $jumptores
1.336 raeburn 2789:
1.42 www 2790: function gopost(url,postdata) {
2791: if (url!='') {
1.429 raeburn 2792: var lcHostname = setLCHost();
2793: this.document.server.action=lcHostname+url;
1.42 www 2794: this.document.server.postdata.value=postdata;
2795: this.document.server.command.value='';
2796: this.document.server.url.value='';
2797: this.document.server.symb.value='';
2798: this.document.server.submit();
2799: }
2800: }
2801:
2802: function gocmd(url,cmd) {
2803: if (url!='') {
1.429 raeburn 2804: var lcHostname = setLCHost();
2805: this.document.server.action=lcHostname+url;
1.42 www 2806: this.document.server.postdata.value='';
2807: this.document.server.command.value=cmd;
2808: this.document.server.url.value=currentURL;
2809: this.document.server.symb.value=currentSymb;
2810: this.document.server.submit();
2811: }
1.57 www 2812: }
2813:
1.121 raeburn 2814: function gocstr(url,filename) {
2815: if (url == '/adm/cfile?action=delete') {
2816: this.document.cstrdelete.filename.value = filename
2817: this.document.cstrdelete.submit();
2818: return;
2819: }
1.515 raeburn 2820: if ((url == '/adm/cfile?action=copy') || (url == '/adm/cfile?action=rename')) {
2821: this.document.cstrcopy.filename.value = filename;
2822: var oldname = filename.substring(filename.lastIndexOf("/") + 1);
2823: var newname=prompt('$newname',oldname);
2824: if (newname == "" || !newname || newname == oldname) {
2825: return;
2826: }
2827: if (url == '/adm/cfile?action=rename') {
2828: this.document.cstrcopy.action.value = 'rename';
2829: } else {
2830: this.document.cstrcopy.action.value = 'copy';
2831: }
2832: this.document.cstrcopy.newfilename.value = newname;
2833: this.document.cstrcopy.submit();
2834: return;
2835: }
1.137 raeburn 2836: if (url == '/adm/printout') {
2837: this.document.cstrprint.postdata.value = filename
2838: this.document.cstrprint.curseed.value = 0;
2839: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 2840: if (this.document.lonhomework) {
2841: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
2842: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
2843: }
2844: if (this.document.lonhomework.problemtype) {
1.164 albertel 2845: if (this.document.lonhomework.problemtype.value) {
2846: this.document.cstrprint.problemtype.value =
2847: this.document.lonhomework.problemtype.value;
2848: } else if (this.document.lonhomework.problemtype.options) {
2849: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
2850: if (this.document.lonhomework.problemtype.options[i].selected) {
2851: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
2852: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
2853: }
2854: }
2855: }
2856: }
2857: }
2858: }
1.137 raeburn 2859: this.document.cstrprint.submit();
2860: return;
2861: }
1.548 raeburn 2862: if (url == '/adm/preferences?action=authorsettings') {
2863: document.location.href=url+'&returnurl='+filename;
2864: return;
2865: }
1.121 raeburn 2866: if (url !='') {
2867: this.document.constspace.filename.value = filename;
2868: this.document.constspace.action = url;
2869: this.document.constspace.submit();
2870: }
2871: }
2872:
1.131 raeburn 2873: function golist(url) {
2874: if (url!='' && url!= null) {
2875: currentURL = null;
2876: currentSymb= null;
1.429 raeburn 2877: var lcHostname = setLCHost();
1.487 raeburn 2878: var ltitarget = '$ltitarget';
1.517 raeburn 2879: var deeplinktarget = '$deeplinktarget';
2880: if ((ltitarget == 'iframe') || (deeplinktarget == '_self')) {
1.487 raeburn 2881: document.location.href=lcHostname+url;
2882: } else {
2883: top.location.href=lcHostname+url;
2884: }
1.131 raeburn 2885: }
2886: }
2887:
2888:
1.121 raeburn 2889:
1.496 raeburn 2890: function catalog_info(url,isMobile) {
1.428 raeburn 2891: if (isMobile == 1) {
1.496 raeburn 2892: openMyModal(url+'.meta?modal=1',500,400,'yes');
1.428 raeburn 2893: } else {
1.496 raeburn 2894: loncatinfo=window.open(url+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1.428 raeburn 2895: }
1.57 www 2896: }
2897:
2898: function chat_win() {
1.429 raeburn 2899: var lcHostname = setLCHost();
2900: lonchat=window.open(lcHostname+'/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 2901: }
1.169 raeburn 2902:
2903: function group_chat(group) {
1.429 raeburn 2904: var lcHostname = setLCHost();
2905: var url = lcHostname+'/adm/groupchat?group='+group;
1.169 raeburn 2906: var winName = 'LONchat_'+group;
2907: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
2908: }
1.175 albertel 2909:
2910: function annotate() {
2911: w_Annotator_flag=1;
2912: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
2913: annotator.document.write(
2914: '$start_page_annotate'
2915: +"<form name='goannotate' target='Annotator' method='post' "
1.493 raeburn 2916: +"action='$annotateurl'>"
1.217 albertel 2917: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 2918: +"<\\/form>"
1.205 albertel 2919: +'$end_page_annotate');
1.175 albertel 2920: annotator.document.close();
2921: }
2922:
1.370 raeburn 2923: function open_StoredLinks_Import(rat) {
1.335 wenzelju 2924: var newWin;
1.429 raeburn 2925: var lcHostname = setLCHost();
1.335 wenzelju 2926: if (rat) {
1.429 raeburn 2927: newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1.334 wenzelju 2928: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1.335 wenzelju 2929: }
2930: else {
1.429 raeburn 2931: newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import',
1.335 wenzelju 2932: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
2933: }
1.334 wenzelju 2934: newWin.focus();
2935: }
2936:
1.480 raeburn 2937: function open_source() {
1.496 raeburn 2938: sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+currentURL,'LONsource',
1.480 raeburn 2939: 'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes');
2940: }
2941:
1.491 raeburn 2942: function open_aboutLC() {
2943: var isMobile = "$env{'browser.mobile'}";
2944: var url = '/adm/about.html';
2945: if (isMobile == 1) {
2946: openMyModal(url,600,400,'yes');
2947: } else {
2948: window.open(url,"aboutLONCAPA","height=400,width=600,scrollbars=1,resizable=1,menubar=0,location=1");
2949: }
2950: return;
2951: }
2952:
2953:
1.372 raeburn 2954: (function (\$) {
2955: \$(document).ready(function () {
2956: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
2957: /*\@cc_on
2958: if (!window.XMLHttpRequest) {
2959: \$('.LC_hoverable').each(function () {
2960: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
2961: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
2962: });
2963: }
2964: \@*/
2965: });
2966: }(jQuery));
2967:
1.378 raeburn 2968: $countdown
2969:
1.530 raeburn 2970: $viewuser
2971:
1.42 www 2972: ENDUTILITY
2973: }
2974:
2975: sub serverform {
1.486 raeburn 2976: my $target;
2977: unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
2978: $target = ' target="_top"';
2979: }
1.516 raeburn 2980: if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) {
2981: $target = ' target="_self"';
2982: }
1.557 raeburn 2983: my $submit = &mt('Submit');
1.42 www 2984: return(<<ENDSERVERFORM);
1.557 raeburn 2985: <form name="server" action="/adm/logout" method="post"$target aria-hidden="true">
1.42 www 2986: <input type="hidden" name="postdata" value="none" />
2987: <input type="hidden" name="command" value="none" />
2988: <input type="hidden" name="url" value="none" />
2989: <input type="hidden" name="symb" value="none" />
1.557 raeburn 2990: <input type="submit" value="$submit" class="LC_visually_hidden" tabindex="-1" disabled="disabled" />
1.42 www 2991: </form>
2992: ENDSERVERFORM
2993: }
1.113 albertel 2994:
1.121 raeburn 2995: sub constspaceform {
1.518 raeburn 2996: my ($frameset) = @_;
1.487 raeburn 2997: my ($target,$printtarget);
1.518 raeburn 2998: if ($frameset) {
2999: $target = ' target="_parent"';
1.487 raeburn 3000: $printtarget = ' target="_parent"';
1.518 raeburn 3001: } else {
3002: unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
3003: (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
3004: $target = ' target="_top"';
1.521 raeburn 3005: $printtarget = ' target="_top"';
1.518 raeburn 3006: }
1.487 raeburn 3007: }
1.121 raeburn 3008: return(<<ENDCONSTSPACEFORM);
1.487 raeburn 3009: <form name="constspace" action="/adm/logout" method="post"$target>
1.121 raeburn 3010: <input type="hidden" name="filename" value="" />
3011: </form>
1.487 raeburn 3012: <form name="cstrdelete" action="/adm/cfile" method="post"$target>
1.121 raeburn 3013: <input type="hidden" name="action" value="delete" />
3014: <input type="hidden" name="filename" value="" />
3015: </form>
1.487 raeburn 3016: <form name="cstrprint" action="/adm/printout" method="post"$printtarget>
1.137 raeburn 3017: <input type="hidden" name="postdata" value="" />
3018: <input type="hidden" name="curseed" value="" />
3019: <input type="hidden" name="problemtype" value="" />
3020: </form>
1.515 raeburn 3021: <form name="cstrcopy" action="/adm/cfile" method="post"$target>
3022: <input type="hidden" name="action" value="copy" />
3023: <input type="hidden" name="filename" value="" />
3024: <input type="hidden" name="newfilename" value="" />
3025: </form>
1.137 raeburn 3026:
1.121 raeburn 3027: ENDCONSTSPACEFORM
3028: }
3029:
1.220 raeburn 3030: sub hidden_button_check {
1.317 droeschl 3031: if ( $env{'request.course.id'} eq ''
3032: || $env{'request.role.adv'} ) {
3033:
1.220 raeburn 3034: return;
3035: }
1.232 raeburn 3036: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
3037: return $buttonshide;
1.220 raeburn 3038: }
1.184 raeburn 3039:
1.235 raeburn 3040: sub roles_selector {
1.521 raeburn 3041: my ($cdom,$cnum,$httphost,$target,$menucoll,$menuref) = @_;
1.298 raeburn 3042: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 3043: my $now = time;
1.465 raeburn 3044: my (%courseroles,%seccount,%courseprivs,%roledesc);
1.235 raeburn 3045: my $is_cc;
1.507 raeburn 3046: my ($js,$form,$switcher,$has_opa_priv);
1.298 raeburn 3047: my $ccrole;
3048: if ($crstype eq 'Community') {
3049: $ccrole = 'co';
3050: } else {
3051: $ccrole = 'cc';
1.350 raeburn 3052: }
1.457 raeburn 3053: my ($privref,$gotsymb,$destsymb);
1.350 raeburn 3054: my $destinationurl = $ENV{'REQUEST_URI'};
1.468 raeburn 3055: if ($destinationurl =~ /(\?|\&)symb=/) {
1.386 raeburn 3056: $gotsymb = 1;
3057: } elsif ($destinationurl =~ m{^/enc/}) {
3058: my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
1.468 raeburn 3059: if ($plainurl =~ /(\?|\&)symb=/) {
1.386 raeburn 3060: $gotsymb = 1;
3061: }
3062: }
3063: unless ($gotsymb) {
3064: $destsymb = &Apache::lonnet::symbread();
3065: if ($destsymb ne '') {
3066: $destsymb = &Apache::lonenc::check_encrypt($destsymb);
3067: }
3068: }
1.350 raeburn 3069: my $reqprivs = &required_privs();
3070: if (ref($reqprivs) eq 'HASH') {
3071: my $destination = $destinationurl;
3072: $destination =~ s/(\?.*)$//;
3073: if (exists($reqprivs->{$destination})) {
1.457 raeburn 3074: if ($reqprivs->{$destination} =~ /,/) {
3075: @{$privref} = split(/,/,$reqprivs->{$destination});
3076: } else {
3077: $privref = [$reqprivs->{$destination}];
3078: }
1.350 raeburn 3079: }
3080: }
1.298 raeburn 3081: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
3082: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 3083: if ((($start) && ($start<0)) ||
3084: (($end) && ($end<$now)) ||
3085: (($start) && ($now<$start))) {
3086: $is_cc = 0;
3087: } else {
3088: $is_cc = 1;
3089: }
3090: }
3091: if ($is_cc) {
1.457 raeburn 3092: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs);
3093: } elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) {
1.465 raeburn 3094: &get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref);
1.235 raeburn 3095: } else {
1.262 raeburn 3096: my %gotnosection;
1.235 raeburn 3097: foreach my $item (keys(%env)) {
1.239 raeburn 3098: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 3099: my $role = $1;
3100: my $sec = $2;
3101: next if ($role eq 'gr');
3102: my ($start,$end) = split(/\./,$env{$item});
3103: next if (($start && $start > $now) || ($end && $end < $now));
3104: if ($sec eq '') {
1.239 raeburn 3105: if (!$gotnosection{$role}) {
3106: $seccount{$role} ++;
3107: $gotnosection{$role} = 1;
3108: }
1.235 raeburn 3109: }
1.457 raeburn 3110: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
1.350 raeburn 3111: my $cnumsec = $cnum;
3112: if ($sec ne '') {
3113: $cnumsec .= "/$sec";
3114: }
3115: $courseprivs{"$role./$cdom/$cnumsec./"} =
3116: $env{"user.priv.$role./$cdom/$cnumsec./"};
3117: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
3118: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
3119: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
3120: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
3121: }
1.235 raeburn 3122: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 3123: if ($sec ne '') {
1.264 raeburn 3124: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 3125: push(@{$courseroles{$role}},$sec);
3126: $seccount{$role} ++;
3127: }
3128: }
3129: } else {
3130: @{$courseroles{$role}} = ();
3131: if ($sec ne '') {
3132: $seccount{$role} ++;
1.235 raeburn 3133: push(@{$courseroles{$role}},$sec);
3134: }
3135: }
3136: }
3137: }
3138: }
1.298 raeburn 3139: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.402 raeburn 3140: my $numdiffsec;
3141: if (keys(%seccount) == 1) {
3142: foreach my $key (keys(%seccount)) {
3143: $numdiffsec = $seccount{$key};
3144: }
3145: }
3146: if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
1.521 raeburn 3147: my $targetattr;
3148: if ($target ne '') {
3149: $targetattr = ' target="'.$target.'"';
3150: }
1.401 raeburn 3151: my @submenu;
1.519 raeburn 3152: $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,
3153: \%roledesc,$privref,$menucoll,$menuref);
1.401 raeburn 3154: $form =
1.557 raeburn 3155: '<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles"'.$targetattr.' aria-hidden="true">'."\n".
1.401 raeburn 3156: ' <input type="hidden" name="destinationurl" value="'.
3157: &HTML::Entities::encode($destinationurl).'" />'."\n".
3158: ' <input type="hidden" name="gotorole" value="1" />'."\n".
3159: ' <input type="hidden" name="selectrole" value="" />'."\n".
1.402 raeburn 3160: ' <input type="hidden" name="switchrole" value="" />'."\n";
3161: if ($destsymb ne '') {
3162: $form .= ' <input type="hidden" name="destsymb" value="'.
3163: &HTML::Entities::encode($destsymb).'" />'."\n";
3164: }
1.557 raeburn 3165: $form .= '<input type="submit" value="'.&mt('Submit').'" class="LC_visually_hidden" tabindex="-1" disabled="disabled" />'."\n".
3166: '</form>'."\n";
1.235 raeburn 3167: foreach my $role (@roles_order) {
1.402 raeburn 3168: my $include;
1.235 raeburn 3169: if (defined($courseroles{$role})) {
1.402 raeburn 3170: if ($env{'request.role'} =~ m{^\Q$role\E}) {
3171: if ($seccount{$role} > 1) {
3172: $include = 1;
1.507 raeburn 3173: } else {
3174: if ($env{'user.priv.'.$env{'request.role'}."./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
3175: $has_opa_priv = 1;
3176: }
1.402 raeburn 3177: }
3178: } else {
3179: $include = 1;
3180: }
3181: }
3182: if ($include) {
1.507 raeburn 3183: if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
3184: $has_opa_priv = 1;
3185: }
1.401 raeburn 3186: push(@submenu,['javascript:adhocRole('."'$role'".')',
3187: &Apache::lonnet::plaintext($role,$crstype)]);
1.235 raeburn 3188: }
3189: }
3190: foreach my $role (sort(keys(%courseroles))) {
3191: if ($role =~ /^cr/) {
1.403 raeburn 3192: my $include;
3193: if ($env{'request.role'} =~ m{^\Q$role\E}) {
1.402 raeburn 3194: if ($seccount{$role} > 1) {
3195: $include = 1;
3196: }
1.403 raeburn 3197: } else {
3198: $include = 1;
3199: }
3200: if ($include) {
1.460 raeburn 3201: my $rolename;
3202: if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) {
1.465 raeburn 3203: $rolename = $roledesc{$role};
3204: if ($rolename eq '') {
3205: $rolename = &mt('Helpdesk [_1]',$1);
3206: }
1.460 raeburn 3207: } else {
3208: $rolename = &Apache::lonnet::plaintext($role);
3209: }
1.507 raeburn 3210: if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
3211: $has_opa_priv = 1;
3212: }
1.403 raeburn 3213: push(@submenu,['javascript:adhocRole('."'$role'".')',
1.460 raeburn 3214: $rolename]);
1.403 raeburn 3215: }
1.235 raeburn 3216: }
3217: }
1.401 raeburn 3218: if (@submenu > 0) {
1.521 raeburn 3219: $switcher = &create_submenu('#',$target,&mt('Switch role'),\@submenu);
1.386 raeburn 3220: }
1.235 raeburn 3221: }
1.507 raeburn 3222: return ($js,$form,$switcher,$has_opa_priv);
1.235 raeburn 3223: }
3224:
1.262 raeburn 3225: sub get_all_courseroles {
1.350 raeburn 3226: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 3227: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 3228: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 3229: return;
3230: }
3231: my ($result,$cached) =
3232: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
3233: if (defined($cached)) {
3234: if (ref($result) eq 'HASH') {
3235: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 3236: (ref($result->{'seccount'}) eq 'HASH') &&
3237: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 3238: %{$courseroles} = %{$result->{'roles'}};
3239: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 3240: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 3241: return;
3242: }
3243: }
3244: }
3245: my %gotnosection;
3246: my %adv_roles =
3247: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3248: foreach my $role (keys(%adv_roles)) {
3249: my ($urole,$usec) = split(/:/,$role);
3250: if (!$gotnosection{$urole}) {
3251: $seccount->{$urole} ++;
3252: $gotnosection{$urole} = 1;
3253: }
3254: if (ref($courseroles->{$urole}) eq 'ARRAY') {
3255: if ($usec ne '') {
3256: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
3257: push(@{$courseroles->{$urole}},$usec);
3258: $seccount->{$urole} ++;
3259: }
3260: }
3261: } else {
3262: @{$courseroles->{$urole}} = ();
3263: if ($usec ne '') {
3264: $seccount->{$urole} ++;
3265: push(@{$courseroles->{$urole}},$usec);
3266: }
3267: }
1.350 raeburn 3268: my $area = '/'.$cdom.'/'.$cnum;
3269: if ($usec ne '') {
3270: $area .= '/'.$usec;
3271: }
3272: if ($role =~ /^cr\//) {
3273: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
3274: } else {
3275: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
3276: }
1.262 raeburn 3277: }
3278: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
3279: @{$courseroles->{'st'}} = ();
1.350 raeburn 3280: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 3281: if (keys(%sections_count) > 0) {
3282: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 3283: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 3284: }
1.410 raeburn 3285: $seccount->{'st'} ++; # Increment for a section-less student role.
1.262 raeburn 3286: my $rolehash = {
3287: 'roles' => $courseroles,
3288: 'seccount' => $seccount,
1.350 raeburn 3289: 'privs' => $courseprivs,
1.262 raeburn 3290: };
3291: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
3292: return;
3293: }
3294:
1.457 raeburn 3295: sub get_customadhoc_roles {
1.465 raeburn 3296: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_;
1.457 raeburn 3297: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.465 raeburn 3298: (ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) {
1.457 raeburn 3299: return;
3300: }
1.466 raeburn 3301: my $is_helpdesk = 0;
3302: my $now = time;
3303: foreach my $role ('dh','da') {
3304: if ($env{"user.role.$role./$cdom/"}) {
3305: my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"});
3306: if (!($start && ($now<$start)) && !($end && ($now>$end))) {
3307: $is_helpdesk = 1;
3308: last;
3309: }
3310: }
3311: }
3312: if ($is_helpdesk) {
3313: my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
3314: my %available;
3315: if (ref($possroles) eq 'ARRAY') {
3316: map { $available{$_} = 1; } @{$possroles};
3317: }
3318: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
3319: if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
3320: if (keys(%{$domdefaults{'adhocroles'}})) {
3321: my $numsec = 1;
3322: my @sections;
3323: my ($allseclist,$cached) =
3324: &Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum);
3325: if (defined($cached)) {
3326: if ($allseclist ne '') {
3327: @sections = split(/,/,$allseclist);
1.465 raeburn 3328: $numsec += scalar(@sections);
1.457 raeburn 3329: }
1.466 raeburn 3330: } else {
3331: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
3332: @sections = sort(keys(%sections_count));
3333: $numsec += scalar(@sections);
3334: $allseclist = join(',',@sections);
3335: &Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
3336: }
3337: my (%adhoc,$gotprivs);
3338: my $prefix = "cr/$cdom/$cdom".'-domainconfig';
3339: foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
3340: next if (($role eq '') || ($role =~ /\W/));
3341: $seccount->{"$prefix/$role"} = $numsec;
3342: $roledesc->{"$prefix/$role"} = $description->{$role};
3343: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
3344: if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
3345: $courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
3346: $env{"user.priv.$prefix/$role./$cdom/$cnum./"};
3347: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} =
3348: $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"};
3349: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} =
3350: $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"};
3351: } else {
3352: unless ($gotprivs) {
3353: my ($adhocroles,$privscached) =
3354: &Apache::lonnet::is_cached_new('adhocroles',$cdom);
3355: if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) {
3356: %adhoc = %{$adhocroles};
3357: } else {
3358: my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
3359: my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_');
3360: foreach my $key (keys(%roledefs)) {
3361: (undef,my $rolename) = split(/_/,$key);
3362: if ($rolename ne '') {
3363: my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key});
3364: $coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv);
3365: $adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv));
1.457 raeburn 3366: }
3367: }
1.466 raeburn 3368: &Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc);
1.457 raeburn 3369: }
1.466 raeburn 3370: $gotprivs = 1;
1.457 raeburn 3371: }
1.466 raeburn 3372: ($courseprivs->{"$prefix/$role./$cdom/$cnum./"},
3373: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"},
3374: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) =
3375: split(/\_/,$adhoc{$role});
1.457 raeburn 3376: }
1.466 raeburn 3377: }
3378: if ($available{$role}) {
3379: $courseroles->{"$prefix/$role"} = \@sections;
1.457 raeburn 3380: }
3381: }
3382: }
3383: }
3384: }
3385: return;
3386: }
3387:
1.235 raeburn 3388: sub jump_to_role {
1.519 raeburn 3389: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref,
3390: $menucoll,$menuref) = @_;
1.239 raeburn 3391: my %lt = &Apache::lonlocal::texthash(
3392: this => 'This role has section(s) associated with it.',
3393: ente => 'Enter a specific section.',
3394: orlb => 'Enter a specific section, or leave blank for no section.',
3395: avai => 'Available sections are:',
3396: youe => 'You entered an invalid section choice:',
1.352 raeburn 3397: plst => 'Please try again.',
1.350 raeburn 3398: role => 'The role you selected is not permitted to view the current page.',
3399: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 3400: );
1.519 raeburn 3401: &js_escape(\%lt);
1.239 raeburn 3402: my $js;
3403: if (ref($courseroles) eq 'HASH') {
3404: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
3405: ' var numsec = new Array();'."\n".
3406: ' var rolesections = new Array();'."\n".
3407: ' var rolenames = new Array();'."\n".
3408: ' var roleseclist = new Array();'."\n";
3409: my @items = keys(%{$courseroles});
3410: for (my $i=0; $i<@items; $i++) {
3411: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
3412: my ($secs,$secstr);
3413: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
3414: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
3415: $secs = join('","',@sections);
3416: $secstr = join(', ',@sections);
3417: }
3418: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
3419: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
3420: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
3421: }
3422: }
1.350 raeburn 3423: my $checkroles = 0;
1.519 raeburn 3424: my $fallback = '/adm/menu';
3425: my $displaymsg = $lt{'swit'};
1.457 raeburn 3426: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) {
3427: my %disallowed;
1.350 raeburn 3428: foreach my $role (sort(keys(%{$courseprivs}))) {
3429: my $trole;
3430: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
3431: $trole = $1;
3432: }
3433: if (($trole ne '') && ($trole ne 'cm')) {
1.457 raeburn 3434: $disallowed{$trole} = 1;
3435: foreach my $priv (@{$privref}) {
3436: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
3437: delete($disallowed{$trole});
3438: last;
3439: }
1.350 raeburn 3440: }
3441: }
3442: }
1.457 raeburn 3443: if (keys(%disallowed) > 0) {
1.350 raeburn 3444: $checkroles = 1;
1.457 raeburn 3445: $js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n".
1.350 raeburn 3446: " var rolecheck = 1;\n";
1.519 raeburn 3447: if ($menucoll) {
3448: if (ref($menuref) eq 'HASH') {
3449: if ($menuref->{'main'} eq 'n') {
3450: $fallback = '/adm/navmaps';
3451: if (&Apache::loncommon::course_type() eq 'Community') {
3452: $displaymsg = &mt('Switch role, but display Community Contents page instead?');
3453: } else {
3454: $displaymsg = &mt('Switch role, but display Course Contents page instead?');
3455: }
3456: &js_escape(\$displaymsg);
3457: }
3458: }
3459: }
1.350 raeburn 3460: }
3461: }
1.519 raeburn 3462: &js_escape(\$fallback);
1.350 raeburn 3463: if (!$checkroles) {
3464: $js .= " var disallow = new Array();\n".
3465: " rolecheck = 0;\n";
3466: }
1.273 droeschl 3467: return <<"END";
1.235 raeburn 3468: <script type="text/javascript">
1.273 droeschl 3469: //<![CDATA[
1.401 raeburn 3470: function adhocRole(newrole) {
1.239 raeburn 3471: $js
1.235 raeburn 3472: if (newrole == '') {
1.350 raeburn 3473: return;
1.235 raeburn 3474: }
1.239 raeburn 3475: var fullrole = newrole+'./$cdom/$cnum';
3476: var selidx = '';
3477: for (var i=0; i<rolenames.length; i++) {
3478: if (rolenames[i] == newrole) {
3479: selidx = i;
3480: }
3481: }
1.350 raeburn 3482: if (rolecheck > 0) {
3483: for (var i=0; i<disallow.length; i++) {
3484: if (disallow[i] == newrole) {
1.519 raeburn 3485: if (confirm("$lt{'role'}\\n$displaymsg")) {
3486: document.rolechooser.destinationurl.value = '$fallback';
1.350 raeburn 3487: } else {
3488: return;
3489: }
3490: }
3491: }
3492: }
1.239 raeburn 3493: var secok = 1;
3494: var secchoice = '';
3495: if (selidx >= 0) {
3496: if (numsec[selidx] > 1) {
3497: secok = 0;
3498: var numrolesec = rolesections[selidx].length;
3499: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 3500: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 3501: if (secchoice == '') {
3502: if (msgidx > 0) {
3503: secok = 1;
3504: }
3505: } else {
3506: for (var j=0; j<rolesections[selidx].length; j++) {
3507: if (rolesections[selidx][j] == secchoice) {
3508: secok = 1;
3509: }
3510: }
3511: }
3512: } else {
3513: if (rolesections[selidx].length == 1) {
3514: secchoice = rolesections[selidx][0];
3515: }
3516: }
3517: }
3518: if (secok == 1) {
3519: if (secchoice != '') {
3520: fullrole += '/'+secchoice;
3521: }
3522: } else {
3523: if (secchoice != null) {
3524: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
3525: }
3526: return;
3527: }
3528: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 3529: return;
3530: }
3531: itemid = retrieveIndex('gotorole');
3532: if (itemid != -1) {
1.239 raeburn 3533: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 3534: }
1.401 raeburn 3535: document.rolechooser.switchrole.value = fullrole;
1.235 raeburn 3536: document.rolechooser.selectrole.value = '1';
3537: document.rolechooser.submit();
3538: return;
3539: }
3540:
3541: function retrieveIndex(item) {
3542: for (var i=0;i<document.rolechooser.elements.length;i++) {
3543: if (document.rolechooser.elements[i].name == item) {
3544: return i;
3545: }
3546: }
3547: return -1;
3548: }
1.273 droeschl 3549: // ]]>
1.235 raeburn 3550: </script>
3551: END
3552: }
3553:
1.350 raeburn 3554: sub required_privs {
3555: my $privs = {
1.457 raeburn 3556: '/adm/parmset' => 'opa,vpa',
3557: '/adm/courseprefs' => 'opa,vpa',
1.350 raeburn 3558: '/adm/whatsnew' => 'whn',
1.461 raeburn 3559: '/adm/populate' => 'cst,vpa,vcl',
1.350 raeburn 3560: '/adm/trackstudent' => 'vsa',
1.457 raeburn 3561: '/adm/statistics' => 'mgr,vgr',
3562: '/adm/setblock' => 'dcm,vcb',
1.367 raeburn 3563: '/adm/coursedocs' => 'mdc',
1.350 raeburn 3564: };
3565: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 3566: $privs->{'/adm/classcalc'} = 'vgr',
3567: $privs->{'/adm/assesscalc'} = 'vgr',
3568: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 3569: }
3570: return $privs;
3571: }
1.235 raeburn 3572:
1.378 raeburn 3573: sub countdown_timer {
3574: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
1.484 raeburn 3575: (($env{'request.filename'}=~/$LONCAPA::assess_re/) ||
3576: (($env{'request.symb'} =~ /ext\.tool$/) &&
3577: (&Apache::lonnet::EXT('resource.0.gradable',$env{'request.symb'}) =~ /^yes$/i)))) {
1.387 raeburn 3578: my ($type,$hastimeleft,$slothastime);
3579: my $now = time;
3580: if ($env{'request.filename'} =~ /\.task$/) {
3581: $type = 'Task';
1.485 raeburn 3582: } elsif ($env{'request.symb'} =~ /ext\.tool$/) {
3583: $type = 'tool';
1.387 raeburn 3584: } else {
3585: $type = 'problem';
3586: }
1.485 raeburn 3587: my ($status,$accessmsg,$slot_name,$slot);
3588: if ($type eq 'tool') {
3589: ($status,$accessmsg,$slot_name,$slot) =
3590: &Apache::lonhomework::check_slot_access('0',$type,$env{'request.symb'},['0']);
3591: } else {
3592: ($status,$accessmsg,$slot_name,$slot) =
3593: &Apache::lonhomework::check_slot_access('0',$type);
3594: }
1.387 raeburn 3595: if ($slot_name ne '') {
3596: if (ref($slot) eq 'HASH') {
3597: if (($slot->{'starttime'} < $now) &&
3598: ($slot->{'endtime'} > $now)) {
3599: $slothastime = 1;
3600: }
3601: }
3602: }
3603: if ($status ne 'CAN_ANSWER') {
3604: return;
3605: }
1.378 raeburn 3606: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.380 raeburn 3607: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.448 raeburn 3608: my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
1.381 raeburn 3609: if (@interval > 1) {
1.448 raeburn 3610: ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
3611: if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
3612: $usesdone = 'done';
3613: $donebuttontext = $1;
3614: (undef,$proctor,$secret) = split(/_/,$2);
3615: } elsif ($donesuffix =~ /^done(|_.+)$/) {
3616: $donebuttontext = &mt('Done');
3617: ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
3618: }
1.381 raeburn 3619: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
3620: if ($first_access > 0) {
1.437 raeburn 3621: if ($first_access+$timelimit > time) {
1.381 raeburn 3622: $hastimeleft = 1;
3623: }
3624: }
3625: }
1.380 raeburn 3626: if (($duedate && $duedate > time) ||
1.387 raeburn 3627: (!$duedate && $hastimeleft) ||
3628: ($slot_name ne '' && $slothastime)) {
1.435 musolffc 3629: my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton);
1.387 raeburn 3630: if ((@interval > 1 && $hastimeleft) ||
3631: ($type eq 'Task' && $slothastime)) {
1.378 raeburn 3632: $currdisp = 'inline';
3633: $collapse = '► ';
1.435 musolffc 3634: if ((@interval > 1) && ($hastimeleft)) {
1.437 raeburn 3635: if ($usesdone eq 'done') {
1.448 raeburn 3636: $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
1.437 raeburn 3637: }
1.435 musolffc 3638: }
1.378 raeburn 3639: } else {
3640: $currdisp = 'none';
3641: $expand = '◄ ';
3642: }
3643: unless ($env{'environment.icons'} eq 'iconsonly') {
1.379 raeburn 3644: $alttxt = &mt('Timer');
3645: $title = $alttxt.' ';
1.378 raeburn 3646: }
3647: my $desc = &mt('Countdown to due date/time');
1.435 musolffc 3648:
1.378 raeburn 3649: return <<END;
1.435 musolffc 3650: $donebutton
1.378 raeburn 3651: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
3652: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
3653: $collapse
1.379 raeburn 3654: </span></a>
1.557 raeburn 3655: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;" role="timer"></span>
1.378 raeburn 3656: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
3657: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.379 raeburn 3658: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1.378 raeburn 3659: END
3660: }
3661: }
3662: return;
3663: }
3664:
1.445 raeburn 3665: sub placement_progress {
3666: my ($totalpoints,$incomplete) = &Apache::lonplacementtest::check_completion(undef,undef,1);
3667: my $complete = 100 - $incomplete;
3668: return '<span class="LC_placement_prog">'.
3669: &mt('Test is [_1]% complete',$complete).'</span>';
3670: }
3671:
1.524 raeburn 3672: sub linkprot_exit {
1.525 raeburn 3673: if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) {
1.524 raeburn 3674: my ($deeplink_symb,$deeplink);
3675: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3676: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3677: if (($cnum ne '') && ($cdom ne '')) {
3678: $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom);
3679: if ($deeplink_symb) {
3680: if ($deeplink_symb =~ /\.(page|sequence)$/) {
3681: my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]);
3682: my $navmap = Apache::lonnavmaps::navmap->new();
3683: if (ref($navmap)) {
3684: $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
3685: }
3686: } else {
3687: $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb);
3688: }
3689: if ($deeplink ne '') {
3690: my ($state,$others,$listed,$scope,$protect,$display,$target,$exit) = split(/,/,$deeplink);
3691: my %lt = &Apache::lonlocal::texthash(
3692: title => 'Exit Tool',
3693: okdone => 'Click "OK" to exit embedded tool',
3694: cancel => 'Click "Cancel" to continue working.',
3695: ok => 'OK',
3696: exit => 'Cancel',
3697: );
3698: if ($exit) {
1.526 raeburn 3699: my ($show,$text) = split(/:/,$exit);
3700: unless ($show eq 'no') {
3701: my $height = 250;
3702: my $width = 300;
3703: my $exitbuttontext;
3704: if ($text eq '') {
3705: $exitbuttontext = &mt('Exit Tool');
3706: } else {
3707: $exitbuttontext = $text;
3708: }
3709: return <<END;
1.524 raeburn 3710: <form method="post" name="LCexitButton" action="/adm/linkexit">
3711: <input type="hidden" name="LC_deeplink_exit" value="" />
3712: <button id="LC_exit-confirm-opener" type="button">$exitbuttontext</button>
3713: </form>
3714:
3715: <div id="LC_exit-confirm" title="$lt{'title'}">
3716: <p>$lt{'okdone'} $lt{'cancel'}</p>
3717: </div>
3718:
3719: <script type="text/javascript">
3720: // <![CDATA[
3721: \$( "#LC_exit-confirm" ).dialog({ autoOpen: false });
3722: \$( "#LC_exit-confirm-opener" ).click(function() {
3723: \$( "#LC_exit-confirm" ).dialog( "open" );
3724: \$( "#LC_exit-confirm" ).dialog({
3725: resizable: false,
3726: height: $height,
3727: width: $width,
3728: modal: true,
3729: buttons: [
3730: {
3731: text: "$lt{'ok'}",
3732: click: function() {
3733: \$( this ).dialog( "close" );
3734: \$( '[name="LC_deeplink_exit"]' )[0].value = 'true';
3735: \$( '[name="LCexitButton"]' )[0].submit();
3736: },
3737: },
3738: {
3739: text: "$lt{'exit'}",
3740: click: function() {
3741: \$( this ).dialog( "close" );
3742: },
3743: },
3744: ],
3745: });
3746: });
3747: // ]]>
3748: </script>
3749:
3750: END
1.526 raeburn 3751: }
1.524 raeburn 3752: }
3753: }
3754: }
3755: }
3756: }
3757: return;
3758: }
3759:
1.2 www 3760: # ================================================================ Main Program
3761:
1.16 harris41 3762: BEGIN {
1.166 albertel 3763: if (! defined($readdesk)) {
1.283 droeschl 3764: {
3765: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
3766: if ( CORE::open( my $config,"<$tabfile") ) {
3767: while (my $configline=<$config>) {
3768: $configline=(split(/\#/,$configline))[0];
3769: $configline=~s/^\s+//;
3770: chomp($configline);
1.209 www 3771: if ($configline=~/^cat\:/) {
1.283 droeschl 3772: my @entries=split(/\:/,$configline);
3773: $category_positions{$entries[2]}=$entries[1];
3774: $category_names{$entries[2]}=$entries[3];
3775: } elsif ($configline=~/^prim\:/) {
1.507 raeburn 3776: my @entries = (split(/\:/, $configline))[1..7];
1.400 raeburn 3777: push(@primary_menu,\@entries);
1.371 raeburn 3778: } elsif ($configline=~/^primsub\:/) {
1.507 raeburn 3779: my ($parent,@entries) = (split(/\:/, $configline))[1..5];
1.400 raeburn 3780: push(@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 3781: } elsif ($configline=~/^scnd\:/) {
1.507 raeburn 3782: my @entries = (split(/\:/, $configline))[1..6];
1.401 raeburn 3783: push(@secondary_menu,\@entries);
1.482 raeburn 3784: } elsif ($configline=~/^scndsub\:/) {
3785: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
3786: push(@{$secondary_submenu{$parent}},\@entries);
1.283 droeschl 3787: } elsif ($configline) {
3788: push(@desklines,$configline);
3789: }
3790: }
3791: CORE::close($config);
3792: }
3793: }
3794: $readdesk='done';
1.2 www 3795: }
3796: }
1.30 www 3797:
1.1 www 3798: 1;
3799: __END__
3800:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>