Annotation of loncom/interface/lonmenu.pm, revision 1.488
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.488 ! raeburn 4: # $Id: lonmenu.pm,v 1.487 2018/04/15 00:28:07 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.486 raeburn 102: =item prep_menuitems(\@menuitem,$ltitarget)
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.486 raeburn 213: use LONCAPA::ltiutils;
1.282 amueller 214: use HTML::Entities();
1.346 wenzelju 215: use Apache::lonwishlist();
1.88 www 216:
1.283 droeschl 217: use vars qw(@desklines %category_names %category_members %category_positions
1.482 raeburn 218: $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
1.88 www 219:
1.56 www 220: my @inlineremote;
1.38 www 221:
1.283 droeschl 222: sub prep_menuitem {
1.486 raeburn 223: my ($menuitem,$ltitarget) = @_;
1.291 raeburn 224: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 225: my $link;
226: if ($$menuitem[1]) { # graphical Link
227: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 228: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
229: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 230: } else { # textual Link
1.291 raeburn 231: $link = &mt($$menuitem[3]);
232: }
1.486 raeburn 233: my $target = ' target="_top"';
234: if ($ltitarget eq 'iframe') {
235: $target ='';
236: }
1.316 droeschl 237: return '<li><a'
238: # highlighting for new messages
239: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
1.486 raeburn 240: . qq| href="$$menuitem[0]"$target>$link</a></li>|;
1.283 droeschl 241: }
242:
1.415 raeburn 243: # primary_menu() evaluates @primary_menu and returns a two item array,
244: # with the array elements containing XHTML for the left and right sides of
245: # the menu that contains the following links:
246: # Personal, About, Message, Roles, Help, Logout
1.283 droeschl 247: # @primary_menu is filled within the BEGIN block of this module with
248: # entries from mydesk.tab
249: sub primary_menu {
1.443 raeburn 250: my ($crstype) = @_;
1.415 raeburn 251: my (%menu);
1.283 droeschl 252: # each element of @primary contains following array:
1.415 raeburn 253: # (link url, icon path, alt text, link text, condition, position)
1.319 raeburn 254: my $public;
255: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
256: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
257: $public = 1;
258: }
1.443 raeburn 259: my $rolecount;
260: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
261: my $update=$env{'user.update.time'};
262: if (!$update) {
263: $update = $env{'user.login.time'};
264: }
265: my %roles_in_env;
266: $rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
267: }
1.486 raeburn 268: my $ltitarget;
269: if ($env{'request.lti.login'}) {
270: $ltitarget = $env{'request.lti.target'};
271: }
1.283 droeschl 272: foreach my $menuitem (@primary_menu) {
273: # evaluate conditions
1.296 droeschl 274: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 275: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 276: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 277: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 278: && !&Apache::lonmsg::mynewmail(); #
1.319 raeburn 279: next if $$menuitem[4] !~ /public/ ##we've a public user,
280: && $public; ##who should not see all
281: ##links
1.283 droeschl 282: next if $$menuitem[4] eq 'onlypublic'# hide links which are
1.319 raeburn 283: && !$public; # only visible to public
284: # users
1.283 droeschl 285: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 286: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 287: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 288: && !&Apache::loncommon::show_course(); ##
1.371 raeburn 289: my $title = $menuitem->[3];
1.443 raeburn 290: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
291: if ($menuitem->[4] eq 'courses') {
292: next unless ($rolecount>1);
293: } else {
294: next unless (($title eq 'Personal') || ($title eq 'Logout'));
295: }
296: }
1.415 raeburn 297: my $position = $menuitem->[5];
298: if ($position eq '') {
299: $position = 'right';
300: }
1.371 raeburn 301: if (defined($primary_submenu{$title})) {
1.375 raeburn 302: my ($link,$target);
1.371 raeburn 303: if ($menuitem->[0] ne '') {
304: $link = $menuitem->[0];
1.486 raeburn 305: unless ($ltitarget eq 'iframe') {
306: $target = '_top';
307: }
1.371 raeburn 308: } else {
309: $link = '#';
310: }
1.375 raeburn 311: my @primsub;
1.371 raeburn 312: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.375 raeburn 313: foreach my $item (@{$primary_submenu{$title}}) {
1.443 raeburn 314: next if (($crstype eq 'Placement') && (!$env{'request.role.adv'}));
1.383 raeburn 315: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.375 raeburn 316: next if ((($item->[2] eq 'portfolio') ||
317: ($item->[2] eq 'blog')) &&
318: (!&Apache::lonnet::usertools_access('','',$item->[2],
319: undef,'tools')));
320: push(@primsub,$item);
321: }
1.443 raeburn 322: if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
323: $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
324: } else {
325: $title = &mt($title);
326: }
1.375 raeburn 327: if (@primsub > 0) {
1.419 bisitz 328: $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1);
1.375 raeburn 329: } elsif ($link) {
1.443 raeburn 330: $menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.$title.'</a></li>';
1.371 raeburn 331: }
332: }
333: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.443 raeburn 334: next if ($crstype eq 'Placement');
1.340 raeburn 335: if ($public) {
336: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
337: my $defdom = &Apache::lonnet::default_login_domain();
338: my $to = &Apache::loncommon::build_recipient_list(undef,
339: 'helpdeskmail',
340: $defdom,$origmail);
341: if ($to ne '') {
1.486 raeburn 342: $menu{$position} .= &prep_menuitem($menuitem,$ltitarget);
1.340 raeburn 343: }
344: } else {
1.415 raeburn 345: $menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.340 raeburn 346: }
1.283 droeschl 347: } else {
1.486 raeburn 348: $menu{$position} .= prep_menuitem($menuitem,$ltitarget);
1.283 droeschl 349: }
1.291 raeburn 350: }
1.423 raeburn 351: my @output = ('','');
352: if ($menu{'left'} ne '') {
353: $output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>";
354: }
355: if ($menu{'right'} ne '') {
356: $output[1] = "<ol class=\"LC_primary_menu LC_floatright LC_right\">$menu{'right'}</ol>";
357: }
358: return @output;
1.283 droeschl 359: }
360:
1.329 droeschl 361: #returns hashref {user=>'',dom=>''} containing:
362: # own name, domain if user is au
363: # name, domain of parent author if user is ca or aa
364: #empty return if user is not an author or not on homeserver
365: #
366: #TODO this should probably be moved somewhere more central
367: #since it can be used by different parts of the system
368: sub getauthor{
369: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
370:
371: #co- or assistent author?
372: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
373: ? ($1, $2) #domain, username of the parent author
374: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
375:
376: # current server == home server?
377: my $home = &Apache::lonnet::homeserver($user,$dom);
378: foreach (&Apache::lonnet::current_machine_ids()){
379: return {user => $user, dom => $dom} if $_ eq $home;
380: }
381:
382: # if wrong server
383: return;
384: }
1.283 droeschl 385:
386: sub secondary_menu {
1.421 raeburn 387: my ($httphost) = @_;
1.283 droeschl 388: my $menu;
389:
1.286 raeburn 390: my $crstype = &Apache::loncommon::course_type();
1.327 droeschl 391: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
392: ? "/$env{'request.course.sec'}"
393: : '');
394: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
1.464 raeburn 395: my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'});
1.376 raeburn 396: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
1.418 raeburn 397: if ($canviewroster eq 'disabled') {
398: undef($canviewroster);
399: }
1.327 droeschl 400: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
1.453 raeburn 401: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
402: my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec);
1.327 droeschl 403: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
1.454 raeburn 404: my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec);
1.341 www 405: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
1.343 www 406: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
407: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
408: my $author = &getauthor();
1.327 droeschl 409:
1.439 raeburn 410: my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools);
411: $grouptools = 0;
1.413 raeburn 412: if ($env{'request.course.id'}) {
413: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
414: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.482 raeburn 415: unless ($canedit || $canvieweditor) {
1.414 raeburn 416: unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) {
417: if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) ||
418: ($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) ||
419: ($env{'course.'.$env{'request.course.id'}.'.updatedsyllabus'}) ||
420: ($env{'request.course.syllabustime'})) {
421: $showsyllabus = 1;
422: }
423: }
424: if ($env{'request.course.feeds'}) {
425: $showfeeds = 1;
1.413 raeburn 426: }
427: }
1.464 raeburn 428: unless ($canmgr || $canvgr) {
1.417 raeburn 429: my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
430: if (keys(%slots) > 0) {
431: $showresv = 1;
432: }
433: }
1.439 raeburn 434: my %groups = &Apache::lonnet::get_active_groups(
435: $env{'user.domain'}, $env{'user.name'},$cdom,$cnum);
436: if (%groups) {
437: foreach my $group (keys(%groups)) {
438: my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"});
439: shift(@privs);
440: if (@privs) {
441: $grouptools ++;
442: }
443: }
444: }
1.413 raeburn 445: }
446:
1.404 raeburn 447: my ($canmodifycoauthor);
448: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
449: my $extent = "$env{'user.domain'}/$env{'user.name'}";
450: if ((&Apache::lonnet::allowed('cca',$extent)) ||
451: (&Apache::lonnet::allowed('caa',$extent))) {
452: $canmodifycoauthor = 1;
453: }
454: }
1.486 raeburn 455: my ($roleswitcher_js,$roleswitcher_form,$ltitarget);
456: if ($env{'request.lti.login'}) {
457: $ltitarget = $env{'request.lti.target'};
458: }
1.401 raeburn 459:
1.283 droeschl 460: foreach my $menuitem (@secondary_menu) {
461: # evaluate conditions
1.296 droeschl 462: next if ref($menuitem) ne 'ARRAY';
1.443 raeburn 463: next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));
1.283 droeschl 464: next if $$menuitem[4] ne 'always'
1.404 raeburn 465: && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
1.283 droeschl 466: && !$env{'request.course.id'};
1.464 raeburn 467: next if $$menuitem[4] =~ /^crsedit/
468: && (!$canedit && !$canvieweditor);
1.341 www 469: next if $$menuitem[4] eq 'nvgr'
470: && $canvgr;
471: next if $$menuitem[4] eq 'vgr'
472: && !$canvgr;
1.456 raeburn 473: next if $$menuitem[4] eq 'viewusers'
1.453 raeburn 474: && !$canmodifyuser && !$canviewusers;
1.456 raeburn 475: next if $$menuitem[4] eq 'noviewusers'
1.453 raeburn 476: && ($canmodifyuser || $canviewusers || !$canviewroster);
1.343 www 477: next if $$menuitem[4] eq 'mgr'
478: && !$canmgr;
1.417 raeburn 479: next if $$menuitem[4] eq 'showresv'
480: && !$showresv;
1.327 droeschl 481: next if $$menuitem[4] eq 'whn'
482: && !$canviewwnew;
1.454 raeburn 483: next if $$menuitem[4] eq 'params'
484: && (!$canmodpara && !$canviewpara);
1.482 raeburn 485: next if $$menuitem[4] eq 'showgroups'
486: && ($canviewgrps || !$grouptools);
1.413 raeburn 487: next if $$menuitem[4] eq 'showsyllabus'
488: && !$showsyllabus;
489: next if $$menuitem[4] eq 'showfeeds'
490: && !$showfeeds;
1.329 droeschl 491: next if $$menuitem[4] eq 'author'
492: && !$author;
1.404 raeburn 493: next if $$menuitem[4] eq 'cca'
494: && !$canmodifycoauthor;
1.283 droeschl 495:
1.482 raeburn 496: my $title = $menuitem->[3];
497: if (defined($secondary_submenu{$title})) {
498: my ($link,$target);
499: if ($menuitem->[0] ne '') {
500: $link = $menuitem->[0];
1.486 raeburn 501: unless ($ltitarget eq 'iframe') {
502: $target = '_top';
503: }
1.482 raeburn 504: } else {
505: $link = '#';
506: }
507: my @scndsub;
508: if (ref($secondary_submenu{$title}) eq 'ARRAY') {
509: foreach my $item (@{$secondary_submenu{$title}}) {
510: if (ref($item) eq 'ARRAY') {
511: next if ($item->[2] eq 'vgr' && !$canvgr);
512: next if ($item->[2] eq 'opa' && !$canmodpara);
513: next if ($item->[2] eq 'vpa' && !$canviewpara);
514: next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers));
515: next if ($item->[2] eq 'mgr' && !$canmgr);
516: next if ($item->[2] eq 'vcg' && !$canviewgrps);
517: next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);
518: next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
1.483 raeburn 519: next if ($item->[2] eq 'author' && !$author);
520: next if ($item->[2] eq 'cca' && !$canmodifycoauthor);
1.482 raeburn 521: push(@scndsub,$item);
522: }
523: }
524: if (@scndsub > 0) {
525: $menu .= &create_submenu($link,$target,$title,\@scndsub,1);
526: } elsif ($link ne '#') {
527: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
528: }
529: }
530: } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 531: # special treatment for role selector
1.401 raeburn 532: ($roleswitcher_js,$roleswitcher_form,my $switcher) =
533: &roles_selector(
1.283 droeschl 534: $env{'course.' . $env{'request.course.id'} . '.domain'},
1.421 raeburn 535: $env{'course.' . $env{'request.course.id'} . '.num'},
1.486 raeburn 536: $httphost,$ltitarget
1.401 raeburn 537: );
538: $menu .= $switcher;
1.296 droeschl 539: } else {
1.414 raeburn 540: if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
541: my $url = $$menuitem[0];
542: $url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum};
543: if (&Apache::lonnet::is_on_map($url)) {
1.468 raeburn 544: unless ($$menuitem[0] =~ /(\?|\&)register=1/) {
545: $$menuitem[0] .= (($$menuitem[0]=~/\?/)? '&' : '?').'register=1';
1.414 raeburn 546: }
547: } else {
1.468 raeburn 548: $$menuitem[0] =~ s{\&?register=1}{};
1.414 raeburn 549: }
1.468 raeburn 550: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
551: if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) {
552: unless ($$menuitem[0] =~ m{^https?://}) {
553: $$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
554: }
555: unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) {
556: $$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1';
557: }
558: }
1.467 raeburn 559: }
1.473 raeburn 560: $$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
1.414 raeburn 561: }
1.486 raeburn 562: $menu .= &prep_menuitem(\@$menuitem,$ltitarget);
1.283 droeschl 563: }
564: }
565: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 566: my $escurl = &escape( &Apache::lonenc::check_encrypt(
567: $env{'request.noversionuri'}));
1.283 droeschl 568:
1.291 raeburn 569: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
570: $env{'request.symb'}));
1.283 droeschl 571:
572: if ( $env{'request.state'} eq 'construct'
573: and ( $env{'request.noversionuri'} eq ''
574: || !defined($env{'request.noversionuri'})))
575: {
1.359 raeburn 576: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
577: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 578: $escurl = &escape($escurl);
1.473 raeburn 579: }
1.283 droeschl 580: $menu =~ s/\[url\]/$escurl/g;
581: $menu =~ s/\[symb\]/$escsymb/g;
582: }
1.329 droeschl 583: $menu =~ s/\[uname\]/$$author{user}/g;
584: $menu =~ s/\[udom\]/$$author{dom}/g;
1.482 raeburn 585: if ($env{'request.course.id'}) {
1.413 raeburn 586: $menu =~ s/\[cnum\]/$cnum/g;
587: $menu =~ s/\[cdom\]/$cdom/g;
588: }
1.385 raeburn 589: if ($menu) {
590: $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
591: }
1.401 raeburn 592: if ($roleswitcher_form) {
593: $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
594: }
1.385 raeburn 595: return $menu;
1.283 droeschl 596: }
597:
1.375 raeburn 598: sub create_submenu {
1.447 raeburn 599: my ($link,$target,$title,$submenu,$translate,$addclass) = @_;
1.375 raeburn 600: return unless (ref($submenu) eq 'ARRAY');
1.379 raeburn 601: my $disptarget;
602: if ($target ne '') {
603: $disptarget = ' target="'.$target.'"';
604: }
1.447 raeburn 605: my $menu = '<li class="LC_hoverable '.$addclass.'">'.
1.379 raeburn 606: '<a href="'.$link.'"'.$disptarget.'>'.
1.432 droeschl 607: '<span class="LC_nobreak">'.$title.
1.375 raeburn 608: '<span class="LC_fontsize_small" style="font-weight:normal;">'.
609: ' ▼</span></span></a>'.
610: '<ul>';
1.431 golterma 611:
612: # $link and $title are only used in the initial string written in $menu
613: # as seen above, not needed for nested submenus
614: $menu .= &build_submenu($target, $submenu, $translate, '1');
615: $menu .= '</ul></li>';
616:
617: return $menu;
618: }
619:
620: # helper routine for create_submenu
621: # build the dropdown (and nested submenus) recursively
622: # see perldoc create_submenu documentation for further information
623: sub build_submenu {
624: my ($target, $submenu, $translate, $first_level) = @_;
1.446 raeburn 625: unless (@{$submenu}) {
1.431 golterma 626: return '';
627: }
628:
629: my $menu = '';
1.375 raeburn 630: my $count = 0;
631: my $numsub = scalar(@{$submenu});
632: foreach my $item (@{$submenu}) {
633: $count ++;
634: if (ref($item) eq 'ARRAY') {
1.416 raeburn 635: my $href = $item->[0];
1.431 golterma 636: my $bordertop;
637: my $borderbot;
638: my $title;
639:
640: if ($translate) {
641: $title = &mt($item->[1]);
642: } else {
643: $title = $item->[1];
644: }
645:
646: if ($count == 1 && !$first_level) {
647: $bordertop = 'border-top: 1px solid black;';
1.416 raeburn 648: }
1.375 raeburn 649: if ($count == $numsub) {
1.431 golterma 650: $borderbot = 'border-bottom: 1px solid black;';
1.375 raeburn 651: }
1.431 golterma 652:
653: # href is a reference to another submenu
654: if (ref($href) eq 'ARRAY') {
655: $menu .= '<li style="margin:0;padding:0;'.$bordertop . $borderbot . '">';
656: $menu .= '<p><span class="LC_primary_menu_innertitle">'
657: . $title . '</span><span class="LC_primary_menu_innerarrow">▶</span></p>';
658: $menu .= '<ul>';
659: $menu .= &build_submenu($target, $href, $translate);
660: $menu .= '</ul>';
661: $menu .= '</li>';
662: } else { # href is the actual hyperlink and does not represent another submenu
663: # for the current menu title
664: if ($href =~ /(aboutme|rss\.html)$/) {
665: next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne ''));
666: $href =~ s/\[domain\]/$env{'user.domain'}/g;
667: $href =~ s/\[user\]/$env{'user.name'}/g;
1.488 ! raeburn 668: } elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) {
! 669: my $returnurl = $ENV{'REQUEST_URI'};
! 670: if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) {
! 671: $returnurl = $1;
! 672: }
! 673: if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
! 674: ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
! 675: ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
! 676: $returnurl =~ s{\?.*$}{};
! 677: $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
! 678: } else {
! 679: undef($returnurl);
! 680: }
! 681: $href =~ s/\[returnurl\]/$returnurl/;
1.431 golterma 682: }
683: unless (($href eq '') || ($href =~ /^\#/)) {
1.486 raeburn 684: if ($target eq '_top') {
685: $target = ' target="_top"';
686: }
1.431 golterma 687: }
688:
689: $menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">';
690: $menu .= '<a href="'.$href.'"'.$target.'>' . $title . '</a>';
691: $menu .= '</li>';
1.425 raeburn 692: }
1.375 raeburn 693: }
694: }
695: return $menu;
696: }
697:
1.40 www 698: sub innerregister {
1.468 raeburn 699: my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_;
1.152 albertel 700: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 701: my $is_const_dir = 0;
1.120 raeburn 702:
1.175 albertel 703: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 704:
1.174 albertel 705: $env{'request.registered'} = 1;
1.40 www 706:
1.177 albertel 707: undef(@inlineremote);
1.56 www 708:
1.486 raeburn 709: my ($mapurl,$resurl,$crstype,$navmap,$ltiscope,$ltiuri);
1.390 raeburn 710:
1.393 raeburn 711: if ($env{'request.course.id'}) {
1.443 raeburn 712: #
713: #course_type: Course, Community, or Placement
714: #
715: $crstype = &Apache::loncommon::course_type();
1.486 raeburn 716: if (($env{'request.lti.login'}) && ($env{'request.lti.uri'})) {
717: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
718: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
719: ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
720: }
1.393 raeburn 721: if ($env{'request.symb'}) {
1.476 raeburn 722: my $ignorenull;
723: unless ($env{'request.noversionuri'} eq '/adm/navmaps') {
724: $ignorenull = 1;
725: }
726: my $symb = &Apache::lonnet::symbread('','',$ignorenull);
727: ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb);
1.393 raeburn 728: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
1.267 droeschl 729:
1.393 raeburn 730: my $maptitle = &Apache::lonnet::gettitle($mapurl);
1.476 raeburn 731: my $restitle = &Apache::lonnet::gettitle($symb);
1.475 raeburn 732: my (@crumbs,@mapcrumbs);
1.478 raeburn 733: if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') &&
734: (!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) {
1.486 raeburn 735: unless ($ltiscope eq 'resource') {
736: if (($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) &&
737: !(($ltiscope eq 'map') && (&Apache::lonnet::clutter($resurl) eq $ltiuri))) {
738: $navmap = Apache::lonnavmaps::navmap->new();
739: if (ref($navmap)) {
740: @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
741: }
742: }
1.475 raeburn 743: }
744: }
1.393 raeburn 745: unless (($forcereg) &&
746: ($env{'request.noversionuri'} eq '/adm/navmaps') &&
1.443 raeburn 747: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
1.486 raeburn 748: (($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
749: ($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
1.443 raeburn 750: @crumbs = ({text => $crstype.' Contents',
1.393 raeburn 751: href => "Javascript:gopost('/adm/navmaps','')"});
752: }
753: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
1.475 raeburn 754: if (@mapcrumbs) {
755: push(@crumbs,@mapcrumbs);
1.486 raeburn 756: } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'})) &&
757: ($ltiscope ne 'map') && ($ltiscope ne 'resource')) {
1.475 raeburn 758: push(@crumbs, {text => '...',
759: no_mt => 1});
760: }
1.393 raeburn 761: }
762:
1.475 raeburn 763: unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) ||
764: (!$maptitle) || ($maptitle eq 'default.sequence') ||
1.486 raeburn 765: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
766: ($ltiscope eq 'resource')) {
767: push @crumbs, {text => $maptitle, no_mt => 1,
768: href => &Apache::lonnet::clutter($mapurl).'?navmap=1'};
1.443 raeburn 769: }
1.479 raeburn 770: if ($restitle && !@mapcrumbs) {
771: push(@crumbs,{text => $restitle, no_mt => 1});
772: }
1.436 raeburn 773: my @tools;
774: if ($env{'request.filename'} =~ /\.page$/) {
775: my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
776: if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
777: @tools = @{$breadcrumb_tools{'tools'}};
778: }
779: }
1.393 raeburn 780: &Apache::lonhtmlcommon::clear_breadcrumbs();
781: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.436 raeburn 782: if (@tools) {
783: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',@tools);
784: }
1.393 raeburn 785: } else {
786: $resurl = $env{'request.noversionuri'};
787: my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
788: my $title = &mt('View Resource');
789: if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
790: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
1.392 raeburn 791: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.393 raeburn 792: if ($env{'form.title'}) {
793: $title = $env{'form.title'};
794: }
1.394 raeburn 795: my $trail;
1.393 raeburn 796: if ($env{'form.folderpath'}) {
1.468 raeburn 797: &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
1.394 raeburn 798: ($trail) =
1.393 raeburn 799: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
800: } else {
801: &Apache::lonhtmlcommon::add_breadcrumb(
1.392 raeburn 802: {text => "Supplemental $crstype Content",
803: href => "javascript:gopost('/adm/supplemental','')"});
1.393 raeburn 804: $title = &mt('View Resource');
1.394 raeburn 805: ($trail) =
806: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
1.392 raeburn 807: }
1.394 raeburn 808: return $trail;
1.412 raeburn 809: } elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
810: &Apache::lonhtmlcommon::clear_breadcrumbs();
811: &prepare_functions('/public'.$courseurl."/syllabus",
1.468 raeburn 812: $forcereg,$group,undef,undef,1,$hostname);
1.412 raeburn 813: $title = &mt('Syllabus File');
814: my ($trail) =
1.468 raeburn 815: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname);
1.412 raeburn 816: return $trail;
1.392 raeburn 817: }
1.395 raeburn 818: unless ($env{'request.state'} eq 'construct') {
819: &Apache::lonhtmlcommon::clear_breadcrumbs();
820: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
821: }
1.392 raeburn 822: }
1.390 raeburn 823: } elsif (! $const_space){
1.328 droeschl 824: #a situation when we're looking at a resource outside of context of a
825: #course or construction space (e.g. with cumulative rights)
826: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.390 raeburn 827: unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
828: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
829: }
1.65 www 830: }
1.41 www 831: # =============================================================================
832: # ============================ This is for URLs that actually can be registered
1.316 droeschl 833: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
834: || $forcereg );
1.390 raeburn 835: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
836: $forceview,$editbutton);
1.391 raeburn 837: if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
838: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1.468 raeburn 839: $editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname);
1.390 raeburn 840: }
841: if ($editbutton eq '') {
1.399 raeburn 842: $editbutton = &clear(6,1);
1.390 raeburn 843: }
1.317 droeschl 844:
1.390 raeburn 845: #
846: # This applies in course context
847: #
848: if ($env{'request.course.id'}) {
849: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
850: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
851: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1.462 raeburn 852: $perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'});
1.390 raeburn 853: my @privs;
1.484 raeburn 854: my $gradable_exttool;
1.390 raeburn 855: if ($env{'request.symb'} ne '') {
1.484 raeburn 856: if ($env{'request.noversionuri'} =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
857: if (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i) {
858: $gradable_exttool = 1;
859: push(@privs,('mgr','vgr'));
860: }
861: } elsif ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
1.390 raeburn 862: push(@privs,('mgr','vgr'));
863: }
1.455 raeburn 864: push(@privs,('opa','vpa'));
1.390 raeburn 865: }
866: foreach my $priv (@privs) {
867: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
868: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
869: $perms{$priv} =
870: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
871: }
872: }
873: #
874: # Determine whether or not to show Grades and Submissions buttons
875: #
1.484 raeburn 876: if (($env{'request.symb'} ne '') &&
877: (($env{'request.filename'}=~/$LONCAPA::assess_re/) || ($gradable_exttool))) {
1.390 raeburn 878: if ($perms{'mgr'}) {
879: &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
880: "gocmd('/adm/grades','gradingmenu')",
881: 'Content Grades');
882: } elsif ($perms{'vgr'}) {
883: &switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
884: "gocmd('/adm/grades','submission')",
885: 'Content Submissions');
886: }
887: }
1.455 raeburn 888: if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) {
1.390 raeburn 889: &switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
890: "gocmd('/adm/parmset','set')",
891: 'Content Settings');
1.107 albertel 892: }
1.393 raeburn 893: # End grades/submissions check
1.107 albertel 894:
1.274 www 895: #
1.393 raeburn 896: # This applies to items inside a folder/page modifiable in the course.
1.274 www 897: #
1.462 raeburn 898: if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) {
1.393 raeburn 899: my $text = 'Edit Folder';
1.395 raeburn 900: if (($mapurl =~ /\.page$/) ||
901: ($env{'request.symb'}=~
1.396 raeburn 902: m{uploaded/$cdom/$cnum/default_\d+\.page$})) {
1.393 raeburn 903: $text = 'Edit Page';
904: }
905: &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
1.390 raeburn 906: "gocmd('/adm/coursedocs','direct')",
907: 'Folder/Page Content');
1.258 raeburn 908: }
1.390 raeburn 909: # End modifiable folder/page container check
910: }
911: # End course context
912:
1.41 www 913: # Prepare the rest of the buttons
1.383 raeburn 914: my ($menuitems,$got_prt,$got_wishlist);
1.120 raeburn 915: if ($const_space) {
1.274 www 916: #
917: # We are in construction space
918: #
1.353 www 919:
1.355 raeburn 920: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 921: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 922: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.353 www 923: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 924: if ($currdir =~ m-/$-) {
925: $is_const_dir = 1;
1.433 raeburn 926: if ($thisdisfn eq '') {
1.451 raeburn 927: unless (($env{'request.course.id'}) &&
928: ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
929: ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
930: $is_const_dir = 2;
931: }
1.433 raeburn 932: }
1.131 raeburn 933: } else {
1.267 droeschl 934: $currdir =~ s|[^/]+$||;
1.200 foxr 935: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 936: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 937: #
938: # Probably should be in mydesk.tab
939: #
1.131 raeburn 940: $menuitems=(<<ENDMENUITEMS);
1.344 www 941: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1.353 www 942: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
943: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
944: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
945: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 946: ENDMENUITEMS
1.131 raeburn 947: }
1.308 raeburn 948: if (ref($bread_crumbs) eq 'ARRAY') {
949: &Apache::lonhtmlcommon::clear_breadcrumbs();
950: foreach my $crumb (@{$bread_crumbs}){
951: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
952: }
953: }
1.203 foxr 954: } elsif ( defined($env{'request.course.id'}) &&
955: $env{'request.symb'} ne '' ) {
1.274 www 956: #
1.383 raeburn 957: # We are in a course and looking at a registered URL
1.274 www 958: # Should probably be in mydesk.tab
959: #
1.443 raeburn 960: $menuitems = "c&3&1";
1.486 raeburn 961: if ($ltiscope eq 'resource') {
962: # Suppress display of backward arrow for LTI Provider if scope is resource.
963: # Suppress display of forward arrow for LTI Provider if scope is resource.
964: } elsif ($ltiscope eq 'map') {
965: # Suppress display of backward arrow for LTI Provider if scope is map and this is first resource.
966: # Suppress display of forward arrow for LTI Provider if scope is map and this is the last resource.
967: my $showforw = 1;
968: my $showback = 1;
969: my $navmap = Apache::lonnavmaps::navmap->new();
970: if (ref($navmap)) {
971: my $mapres = $navmap->getResourceByUrl($ltiuri);
972: if (ref($mapres)) {
973: if ($navmap->isLastResource($mapres,$env{'request.symb'})) {
974: $showforw = 0;
975: }
976: if ($navmap->isFirstResource($mapres,$env{'request.symb'})) {
977: $showback = 0;
978: }
979: }
980: }
981: if ($showback) {
982: $menuitems.="
983: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1";
984: }
985: if ($showforw) {
986: $menuitems.="
987: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
988: }
989: } elsif (($crstype ne 'Placement') || ($env{'request.role.adv'})) {
1.443 raeburn 990: $menuitems.="
1.444 raeburn 991: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
992: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
993: } else {
994: # Suppress display of backward arrow for Placement Tests
995: # Suppress display of forward arrow for Placement Tests if this is the last resource.
996: my $showforw = 1;
997: if ($env{'request.symb'}) {
998: my $navmap = Apache::lonnavmaps::navmap->new();
999: if (ref($navmap)) {
1000: if (&Apache::lonplacementtest::is_lastres($env{'request.symb'},$navmap)) {
1001: $showforw = 0;
1002: }
1003: }
1004: }
1005: if ($showforw) {
1006: $menuitems.="
1007: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
1008: }
1.443 raeburn 1009: }
1010: $menuitems .= (<<ENDMENUITEMS);
1011:
1.77 www 1012: c&6&3
1013: c&8&1
1014: c&8&2
1.344 www 1015: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 1016: ENDMENUITEMS
1.383 raeburn 1017: $got_prt = 1;
1018: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
1019: && (!$env{'request.enc'})) {
1.452 raeburn 1020: my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($env{'request.uri'});
1021: unless ($cnum) {
1022: # wishlist is only available for users with access to resource-pool
1023: # and links can only be set for resources within the resource-pool
1024: $menuitems .= (<<ENDMENUITEMS);
1.431 golterma 1025: 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 1026: ENDMENUITEMS
1.452 raeburn 1027: $got_wishlist = 1;
1028: }
1.332 wenzelju 1029: }
1.216 albertel 1030:
1.243 tempelho 1031: my $currentURL = &Apache::loncommon::get_symb();
1032: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
1033: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
1034: $menuitems.="s&9&3&";
1035: if(length($annotation) > 0){
1.317 droeschl 1036: $menuitems.="anot2.png";
1.243 tempelho 1037: }else{
1.317 droeschl 1038: $menuitems.="anot.png";
1.243 tempelho 1039: }
1.344 www 1040: $menuitems.="&Notes&&annotate()&";
1.243 tempelho 1041: $menuitems.="Make notes and annotations about this resource&&1\n";
1.428 raeburn 1042: my $is_mobile;
1043: if ($env{'browser.mobile'}) {
1044: $is_mobile = 1;
1045: }
1.243 tempelho 1046:
1.484 raeburn 1047: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1048: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/}) && ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) {
1.216 albertel 1049: $menuitems.=(<<ENDREALRES);
1.428 raeburn 1050: s&6&3&catalog.png&Info&info[_1]&catalog_info('$is_mobile')&Show Metadata
1.216 albertel 1051: ENDREALRES
1052: }
1.422 raeburn 1053: unless (($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) ||
1.484 raeburn 1054: ($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/}) ||
1055: ($env{'request.noversionuri'} =~ m{^/adm/.+/ext\.tool$})) {
1.382 raeburn 1056: $menuitems.=(<<ENDREALRES);
1.344 www 1057: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.382 raeburn 1058: ENDREALRES
1059: }
1.422 raeburn 1060: unless ($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/}) {
1061: $menuitems.=(<<ENDREALRES);
1.344 www 1062: 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 1063: ENDREALRES
1.422 raeburn 1064: }
1.120 raeburn 1065: }
1066: }
1.203 foxr 1067: if ($env{'request.uri'} =~ /^\/res/) {
1.383 raeburn 1068: unless ($got_prt) {
1069: $menuitems .= (<<ENDMENUITEMS);
1.344 www 1070: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 1071: ENDMENUITEMS
1.384 raeburn 1072: $got_prt = 1;
1.383 raeburn 1073: }
1074: unless ($got_wishlist) {
1075: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
1076: # wishlist is only available for users with access to resource-pool
1077: $menuitems .= (<<ENDMENUITEMS);
1.431 golterma 1078: 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 1079: ENDMENUITEMS
1.383 raeburn 1080: $got_wishlist = 1;
1081: }
1082: }
1083: }
1.41 www 1084: my $buttons='';
1085: foreach (split(/\n/,$menuitems)) {
1086: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 1087: my $idx=10*$rest[0]+$rest[1];
1088: if (&hidden_button_check() eq 'yes') {
1089: if ($idx == 21 ||$idx == 23) {
1090: $buttons.=&switch('','',@rest);
1091: } else {
1092: $buttons.=&clear(@rest);
1093: }
1094: } else {
1095: if ($command eq 's') {
1096: $buttons.=&switch('','',@rest);
1097: } else {
1098: $buttons.=&clear(@rest);
1099: }
1.41 www 1100: }
1101: }
1.445 raeburn 1102: my $showprogress;
1103: if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
1104: $showprogress = &placement_progress();
1105: }
1106:
1107: my $addremote=0;
1108: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.148 albertel 1109:
1.301 droeschl 1110: if ($addremote) {
1.458 raeburn 1111: my ($countdown,$buttonshide);
1.436 raeburn 1112: if ($env{'request.filename'} =~ /\.page$/) {
1113: my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
1114: if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
1.458 raeburn 1115: $countdown = $breadcrumb_tools{'tools'}->[0];
1.436 raeburn 1116: }
1.458 raeburn 1117: $buttonshide = $pagebuttonshide;
1.436 raeburn 1118: } else {
1119: $countdown = &countdown_timer();
1.458 raeburn 1120: $buttonshide = &hidden_button_check();
1.436 raeburn 1121: }
1.342 www 1122: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 1123:
1.342 www 1124: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.312 droeschl 1125: 'navigation', @inlineremote[21,23]);
1126:
1.458 raeburn 1127: if ($buttonshide eq 'yes') {
1.378 raeburn 1128: if ($countdown) {
1129: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
1130: }
1.445 raeburn 1131: if ($showprogress) {
1132: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
1133: }
1.378 raeburn 1134: } else {
1135: my @tools = @inlineremote[93,91,81,82,83];
1136: if ($countdown) {
1137: unshift(@tools,$countdown);
1138: }
1.342 www 1139: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.378 raeburn 1140: 'tools',@tools);
1.313 droeschl 1141:
1142: #publish button in construction space
1143: if ($env{'request.state'} eq 'construct'){
1.342 www 1144: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 1145: 'advtools', $inlineremote[63]);
1.342 www 1146: } else {
1147: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 1148: 'tools', $inlineremote[63]);
1.313 droeschl 1149: }
1.390 raeburn 1150: &advtools_crumbs(@inlineremote);
1.301 droeschl 1151: }
1.445 raeburn 1152: } else {
1153: if ($showprogress) {
1154: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
1155: }
1.38 www 1156: }
1.433 raeburn 1157: my ($topic_help,$topic_help_text);
1158: if ($is_const_dir == 2) {
1.434 raeburn 1159: if ((($ENV{'SERVER_PORT'} == 443) ||
1160: ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) &&
1161: (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {
1.433 raeburn 1162: $topic_help = 'Authoring_WebDAV,Authoring_WebDAV_Mac_10v6,Authoring_WebDAV_Mac_10v10,'.
1163: 'Authoring_WebDAV_Windows_v7,Authoring_WebDAV_Linux_Centos';
1164: $topic_help_text = 'About WebDAV access';
1165: }
1166: }
1.342 www 1167: return &Apache::lonhtmlcommon::scripttag('', 'start')
1.433 raeburn 1168: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text)
1.342 www 1169: . &Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 1170: }
1171:
1.389 raeburn 1172: sub get_editbutton {
1.468 raeburn 1173: my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg,$hostname) = @_;
1.398 raeburn 1174: my $jscall;
1175: if (($forceview) && ($env{'form.todocs'})) {
1.463 raeburn 1176: my ($folderpath,$command,$navmap);
1.398 raeburn 1177: if ($env{'request.symb'}) {
1.463 raeburn 1178: $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap);
1.398 raeburn 1179: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
1180: $folderpath = $env{'form.folderpath'};
1181: $command = '&forcesupplement=1';
1182: }
1183: $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
1184: $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
1185: } else {
1.459 raeburn 1186: my $suppanchor;
1187: if ($env{'form.folderpath'}) {
1188: $suppanchor = $env{'form.anchor'};
1189: }
1.398 raeburn 1190: $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
1.393 raeburn 1191: $forceedit,$forcereg,$env{'request.symb'},
1192: &escape($env{'form.folderpath'}),
1.468 raeburn 1193: &escape($env{'form.title'}),$hostname,
1194: $env{'form.idx'},&escape($env{'form.suppurl'}),
1195: $env{'form.todocs'},$suppanchor);
1.398 raeburn 1196: }
1.389 raeburn 1197: if ($jscall) {
1.390 raeburn 1198: my $icon = 'pcstr.png';
1199: my $label = 'Edit';
1200: if ($forceview) {
1201: $icon = 'tolastloc.png';
1202: $label = 'Exit Editing';
1203: }
1204: &switch('','',6,1,$icon,$label,'resource[_2]',
1205: $jscall,"Edit this resource");
1206: return 1;
1207: }
1208: return;
1209: }
1210:
1211: sub prepare_functions {
1.468 raeburn 1212: my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$hostname) = @_;
1.390 raeburn 1213: unless ($env{'request.registered'}) {
1214: undef(@inlineremote);
1215: }
1216: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
1217: $forceview);
1218:
1219: if ($env{'request.course.id'}) {
1220: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1221: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1222: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1223: }
1224:
1225: my $editbutton = '';
1.480 raeburn 1226: my $viewsrcbutton = '';
1.390 raeburn 1227: #
1.480 raeburn 1228: # Determine whether or not to display 'Edit' or 'View Source' icon/button
1.390 raeburn 1229: #
1230: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1231: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.391 raeburn 1232: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1233: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1234: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1235: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
1236: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.390 raeburn 1237: $forceedit,$forceview,$forcereg);
1238: }
1.391 raeburn 1239: } elsif ((!$env{'request.course.id'}) &&
1.390 raeburn 1240: ($env{'user.author'}) && ($env{'request.filename'}) &&
1241: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1242: #
1243: # Currently do not have the role of author or co-author.
1244: # Do we have authoring privileges for the resource?
1245: #
1246: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1247: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1248: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1249: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1250: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
1251: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1252: $forceedit,$forceview,$forcereg);
1253: }
1254: } elsif ($env{'request.course.id'}) {
1255: #
1256: # This applies in course context
1257: #
1.412 raeburn 1258: if (($perms{'mdc'}) &&
1.469 raeburn 1259: (($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) ||
1.477 raeburn 1260: ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) ||
1261: (($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) {
1.470 raeburn 1262: if ($resurl =~ m{^/}) {
1263: $cfile = $resurl;
1264: } else {
1265: $cfile = "/$resurl";
1266: }
1.411 raeburn 1267: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1268: if ($env{'form.forceedit'}) {
1269: $forceview = 1;
1.390 raeburn 1270: } else {
1.411 raeburn 1271: $forceedit = 1;
1.390 raeburn 1272: }
1.477 raeburn 1273: if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) {
1274: my $text = 'Edit Folder';
1275: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
1276: "gocmd('/adm/coursedocs','direct')",
1277: 'Folder/Page Content');
1278: $editbutton = 1;
1279: } else {
1280: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1281: $forceedit,$forceview,$forcereg,
1282: $hostname);
1283: }
1.393 raeburn 1284: } elsif (($resurl eq '/adm/extresedit') &&
1285: (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
1286: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1287: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
1288: $env{'form.symb'});
1289: if ($cfile ne '') {
1290: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.468 raeburn 1291: $forceedit,$forceview,$forcereg);
1.393 raeburn 1292: }
1.406 raeburn 1293: } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
1294: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
1295: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1296: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
1297: $env{'form.symb'});
1298: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1299: $forceedit,$forceview,$forcereg);
1.405 raeburn 1300: } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
1301: ($resurl ne '/cgi-bin/printout.pl')) {
1.390 raeburn 1302: if ($env{'request.filename'}) {
1303: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1304: ($cfile,$home,$switchserver,$forceedit,$forceview) =
1305: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
1306: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
1307: if ($cfile ne '') {
1308: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.468 raeburn 1309: $forceedit,$forceview,$forcereg,
1310: $hostname);
1.390 raeburn 1311: }
1.480 raeburn 1312: if ((($cfile eq '') || (!$editbutton)) &&
1313: ($resurl =~ /$LONCAPA::assess_re/)) {
1314: my $showurl = &Apache::lonnet::clutter($resurl);
1315: if ((&Apache::lonnet::allowed('cre','/')) &&
1316: (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) {
1317: $viewsrcbutton = 1;
1318: } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
1319: if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) {
1320: my $auname = $1;
1321: if (($env{'request.course.adhocsrcaccess'} ne '') &&
1322: (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
1323: $viewsrcbutton = 1;
1.481 raeburn 1324: } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') &&
1325: (&Apache::lonnet::allowed('bre','/'))) {
1326: $viewsrcbutton = 1;
1.480 raeburn 1327: }
1328: }
1329: }
1330: if ($viewsrcbutton) {
1331: &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()',
1332: 'View source code');
1333: }
1334: }
1.390 raeburn 1335: }
1336: }
1337: }
1338: # End determination of 'Edit' icon/button display
1339:
1.393 raeburn 1340: if ($env{'request.course.id'}) {
1.390 raeburn 1341: # This applies to about me page for users in a course
1.391 raeburn 1342: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.390 raeburn 1343: my ($sdom,$sname) = ($1,$2);
1344: unless (&Apache::lonnet::is_course($sdom,$sname)) {
1345: &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
1346: '',
1.415 raeburn 1347: "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
1.390 raeburn 1348: 'Send message to specific user');
1349: }
1.391 raeburn 1350: my $hideprivileged = 1;
1351: if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
1352: $hideprivileged)) {
1.390 raeburn 1353: foreach my $priv ('vsa','vgr','srm') {
1354: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
1355: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
1356: $perms{$priv} =
1357: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
1358: }
1359: }
1360: if ($perms{'vsa'}) {
1361: &switch('','',6,5,'trck-22x22.png','Activity',
1362: '',
1363: "go('/adm/trackstudent?selected_student=$sname:$sdom')",
1364: 'View recent activity by this person');
1365: }
1366: if ($perms{'vgr'}) {
1367: &switch('','',6,6,'rsrv-22x22.png','Reservations',
1368: '',
1.415 raeburn 1369: "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
1.390 raeburn 1370: 'Slot reservation history');
1371: }
1372: if ($perms{'srm'}) {
1373: &switch('','',6,7,'contact-new-22x22.png','Records',
1374: '',
1.415 raeburn 1375: "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
1.390 raeburn 1376: 'Add records');
1377: }
1378: }
1.393 raeburn 1379: }
1380: if (($env{'form.folderpath'} =~ /^supplemental/) &&
1381: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
1382: (($resurl =~ m{^/adm/wrapper/ext/}) ||
1.472 raeburn 1383: ($resurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) ||
1.393 raeburn 1384: ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
1.397 raeburn 1385: ($resurl eq '/adm/supplemental') ||
1386: ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
1387: ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
1.393 raeburn 1388: my @folders=split('&',$env{'form.folderpath'});
1.394 raeburn 1389: if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
1.459 raeburn 1390: my $suppanchor;
1391: if ($resurl =~ m{^/adm/wrapper/ext/}) {
1392: $suppanchor = $env{'form.anchor'};
1393: }
1.393 raeburn 1394: my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
1.468 raeburn 1395: my $link = '/adm/coursedocs?command=direct&forcesupplement=1&supppath='.
1396: "$esc_path&anchor=$suppanchor";
1397: if ($env{'request.use_absolute'} ne '') {
1398: $link = $env{'request.use_absolute'}.$link;
1399: }
1.393 raeburn 1400: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
1.468 raeburn 1401: "location.href='$link'",'Folder/Page Content');
1.393 raeburn 1402: }
1.390 raeburn 1403: }
1404: }
1405:
1406: # End checking for items for about me page for users in a course
1.393 raeburn 1407: if ($docscrumbs) {
1408: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1409: &advtools_crumbs(@inlineremote);
1410: return $editbutton;
1411: } elsif ($env{'request.registered'}) {
1.480 raeburn 1412: return $editbutton || $viewsrcbutton;
1.390 raeburn 1413: } else {
1414: if (ref($bread_crumbs) eq 'ARRAY') {
1415: if (@inlineremote > 0) {
1416: if (ref($advtools) eq 'ARRAY') {
1417: @{$advtools} = @inlineremote;
1418: }
1419: }
1420: return;
1421: } elsif (@inlineremote > 0) {
1422: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1423: &advtools_crumbs(@inlineremote);
1424: return &Apache::lonhtmlcommon::scripttag('', 'start')
1425: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
1426: . &Apache::lonhtmlcommon::scripttag('', 'end');
1427: }
1428: }
1429: }
1430:
1431: sub advtools_crumbs {
1432: my @funcs = @_;
1433: if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
1434: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1435: 'advtools', @funcs[61,64,65,66,67,74]);
1436: } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
1437: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1438: 'advtools', @funcs[61,71,72,73,74,92]);
1.393 raeburn 1439: } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
1440: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.407 raeburn 1441: 'advtools', $funcs[61]);
1.393 raeburn 1442: }
1.412 raeburn 1443: return;
1.258 raeburn 1444: }
1445:
1.2 www 1446: # ================================================================== Raw Config
1447:
1.3 www 1448: sub clear {
1449: my ($row,$col)=@_;
1.316 droeschl 1450: $inlineremote[10*$row+$col]='';
1451: return '';
1.3 www 1452: }
1453:
1.40 www 1454: # ============================================ Switch a button or create a link
1.25 matthew 1455: # Switch acts on the javascript that is executed when a button is clicked.
1456: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1457:
1.2 www 1458: sub switch {
1.209 www 1459: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1460: $act=~s/\$uname/$uname/g;
1461: $act=~s/\$udom/$udom/g;
1.88 www 1462: $top=&mt($top);
1463: $bot=&mt($bot);
1464: $desc=&mt($desc);
1.209 www 1465: my $idx=10*$row+$col;
1466: $category_members{$cat}.=':'.$idx;
1467:
1.320 droeschl 1468: # Inline Menu
1.317 droeschl 1469: if ($nobreak==2) { return ''; }
1470: my $text=$top.' '.$bot;
1471: $text=~s/\s*\-\s*//gs;
1.105 www 1472:
1.317 droeschl 1473: my $pic=
1.225 albertel 1474: '<img alt="'.$text.'" src="'.
1475: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1476: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 1477: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1478: # Main Menu
1.103 www 1479: if ($nobreak==3) {
1.209 www 1480: $inlineremote[$idx]="\n".
1.177 albertel 1481: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1482: '</td><td align="left">'.
1.103 www 1483: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1484: } elsif ($nobreak) {
1.209 www 1485: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1486: '<td align="left">'.
1.177 albertel 1487: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1488: <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 1489: } else {
1.209 www 1490: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1491: '<td align="left">'.
1.103 www 1492: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1493: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1494: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1495: }
1.317 droeschl 1496: } else {
1.103 www 1497: # Inline Menu
1.378 raeburn 1498: my @tools = (93,91,81,82,83);
1499: unless ($env{'request.state'} eq 'construct') {
1500: push(@tools,63);
1501: }
1502: if (($env{'environment.icons'} eq 'iconsonly') &&
1503: (grep(/^$idx$/,@tools))) {
1504: $inlineremote[$idx] =
1505: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
1506: } else {
1507: $inlineremote[$idx] =
1.317 droeschl 1508: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.344 www 1509: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1.378 raeburn 1510: }
1.317 droeschl 1511: }
1.56 www 1512: return '';
1.2 www 1513: }
1514:
1515: sub secondlevel {
1516: my $output='';
1517: my
1.209 www 1518: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1519: if ($prt eq 'any') {
1.209 www 1520: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1521: } elsif ($prt=~/^r(\w+)/) {
1522: if ($rol eq $1) {
1.209 www 1523: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1524: }
1525: }
1526: return $output;
1527: }
1528:
1.56 www 1529: sub inlinemenu {
1.210 albertel 1530: undef(@inlineremote);
1531: undef(%category_members);
1.275 www 1532: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1533: &rawconfig(1);
1.309 bisitz 1534: my $output='<table><tr>';
1.209 www 1535: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1536: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1537: for (my $row=1; $row<=8; $row++) {
1538: foreach my $cat (keys(%category_members)) {
1539: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1540: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1541: $output.='<div class="LC_Box LC_400Box">';
1542: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1543: $output.='<table>';
1.240 riegler 1544: my %active=();
1545: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1546: if ($inlineremote[$menu_item]) {
1547: $active{$menu_item}=1;
1548: }
1549: }
1550: foreach my $item (sort(keys(%active))) {
1551: $output.=$inlineremote[$item];
1552: }
1553: $output.='</table>';
1.245 harmsja 1554: $output.='</div>';
1.240 riegler 1555: }
1556: }
1557: $output.="</td>";
1558: }
1559: $output.="</tr></table>";
1560: return $output;
1561: }
1562:
1.2 www 1563: sub rawconfig {
1.274 www 1564: #
1565: # This evaluates mydesk.tab
1566: # Need to add more positions and more privileges to deal with all
1567: # menu items.
1568: #
1.34 www 1569: my $textualoverride=shift;
1570: my $output='';
1.316 droeschl 1571: return '' unless $textualoverride;
1.152 albertel 1572: my $uname=$env{'user.name'};
1573: my $udom=$env{'user.domain'};
1574: my $adv=$env{'user.adv'};
1.266 raeburn 1575: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1576: my $author=$env{'user.author'};
1.5 www 1577: my $crs='';
1.295 raeburn 1578: my $crstype='';
1.152 albertel 1579: if ($env{'request.course.id'}) {
1580: $crs='/'.$env{'request.course.id'};
1581: if ($env{'request.course.sec'}) {
1582: $crs.='_'.$env{'request.course.sec'};
1.7 www 1583: }
1.8 www 1584: $crs=~s/\_/\//g;
1.295 raeburn 1585: $crstype = &Apache::loncommon::course_type();
1.5 www 1586: }
1.152 albertel 1587: my $pub=($env{'request.state'} eq 'published');
1588: my $con=($env{'request.state'} eq 'construct');
1589: my $rol=$env{'request.role'};
1.427 raeburn 1590: my $requested_domain;
1591: if ($rol) {
1592: $requested_domain = $env{'request.role.domain'};
1593: }
1.184 raeburn 1594: foreach my $line (@desklines) {
1.209 www 1595: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1596: $prt=~s/\$uname/$uname/g;
1597: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1598: if ($prt =~ /\$crs/) {
1599: next unless ($env{'request.course.id'});
1600: next if ($crstype eq 'Community');
1601: $prt=~s/\$crs/$crs/g;
1602: } elsif ($prt =~ /\$cmty/) {
1603: next unless ($env{'request.course.id'});
1604: next if ($crstype ne 'Community');
1605: $prt=~s/\$cmty/$crs/g;
1606: }
1.427 raeburn 1607: if ($prt =~ m/\$requested_domain/) {
1608: if ((!$requested_domain) && ($pro eq 'pbre') && ($env{'user.adv'})) {
1609: $prt=~s/\$requested_domain/$env{'user.domain'}/g;
1610: } else {
1611: $prt=~s/\$requested_domain/$requested_domain/g;
1612: }
1613: }
1.211 www 1614: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1615: if ($pro eq 'clear') {
1.4 www 1616: $output.=&clear($row,$col);
1.3 www 1617: } elsif ($pro eq 'any') {
1.2 www 1618: $output.=&secondlevel(
1.209 www 1619: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1620: } elsif ($pro eq 'smp') {
1621: unless ($adv) {
1622: $output.=&secondlevel(
1.209 www 1623: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1624: }
1625: } elsif ($pro eq 'adv') {
1626: if ($adv) {
1627: $output.=&secondlevel(
1.209 www 1628: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1629: }
1.231 albertel 1630: } elsif ($pro eq 'shc') {
1631: if ($show_course) {
1632: $output.=&secondlevel(
1633: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1634: }
1635: } elsif ($pro eq 'nsc') {
1636: if (!$show_course) {
1637: $output.=&secondlevel(
1638: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1639: }
1.81 matthew 1640: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1641: my $priv = $1;
1642: if ($priv =~ /^mdc(Course|Community)/) {
1643: if ($crstype eq $1) {
1644: $priv = 'mdc';
1645: } else {
1646: next;
1647: }
1648: }
1.427 raeburn 1649: if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
1650: (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
1651: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1652: }
1.295 raeburn 1653: } elsif ($pro eq 'course') {
1654: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1655: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1656: }
1.295 raeburn 1657: } elsif ($pro eq 'community') {
1658: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1659: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1660: }
1.124 matthew 1661: } elsif ($pro =~ /^courseenv_(.*)$/) {
1662: my $key = $1;
1.307 raeburn 1663: if ($crstype ne 'Community') {
1664: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1665: if ($key eq 'canuse_pdfforms') {
1666: if ($env{'request.course.id'} && $coursepref eq '') {
1667: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1668: $coursepref = $domdefs{'canuse_pdfforms'};
1669: }
1670: }
1671: if ($coursepref) {
1672: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1673: }
1.295 raeburn 1674: }
1675: } elsif ($pro =~ /^communityenv_(.*)$/) {
1676: my $key = $1;
1.307 raeburn 1677: if ($crstype eq 'Community') {
1678: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1679: if ($key eq 'canuse_pdfforms') {
1680: if ($env{'request.course.id'} && $coursepref eq '') {
1681: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1682: $coursepref = $domdefs{'canuse_pdfforms'};
1683: }
1684: }
1685: if ($coursepref) {
1686: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1687: }
1.124 matthew 1688: }
1.81 matthew 1689: } elsif ($pro =~ /^course_(.*)$/) {
1690: # Check for permissions inside of a course
1.295 raeburn 1691: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1692: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1693: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1694: )) {
1.209 www 1695: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1696: }
1.295 raeburn 1697: } elsif ($pro =~ /^community_(.*)$/) {
1698: # Check for permissions inside of a community
1699: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1700: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1701: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1702: )) {
1703: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1704: }
1.4 www 1705: } elsif ($pro eq 'author') {
1706: if ($author) {
1.152 albertel 1707: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1708: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1709: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1710: # Check that we are on the correct machine
1.29 matthew 1711: my $cadom=$requested_domain;
1.152 albertel 1712: my $caname=$env{'user.name'};
1.234 raeburn 1713: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1714: ($cadom,$caname)=
1.206 albertel 1715: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1716: }
1717: $act =~ s/\$caname/$caname/g;
1.353 www 1718: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 1719: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1720: my $allowed=0;
1721: my @ids=&Apache::lonnet::current_machine_ids();
1722: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1723: if ($allowed) {
1.209 www 1724: $output.=&switch($caname,$cadom,
1725: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1726: }
1.6 www 1727: }
1.2 www 1728: }
1.248 raeburn 1729: } elsif ($pro eq 'tools') {
1730: my @tools = ('aboutme','blog','portfolio');
1731: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1732: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1733: $env{'user.domain'},
1734: $prt,undef,'tools')) {
1735: $output.=&clear($row,$col);
1736: next;
1737: }
1.278 raeburn 1738: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1739: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1740: next;
1741: }
1742: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1743: next;
1744: }
1.279 raeburn 1745: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1746: if (!$showreqcrs) {
1.248 raeburn 1747: $output.=&clear($row,$col);
1748: next;
1749: }
1750: }
1751: $prt='any';
1752: $output.=&secondlevel(
1753: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1754: }
1.13 harris41 1755: }
1.2 www 1756: return $output;
1757: }
1758:
1.279 raeburn 1759: sub check_for_rcrs {
1760: my $showreqcrs = 0;
1.443 raeburn 1761: my @reqtypes = ('official','unofficial','community','textbook','placement');
1.280 raeburn 1762: foreach my $type (@reqtypes) {
1.279 raeburn 1763: if (&Apache::lonnet::usertools_access($env{'user.name'},
1764: $env{'user.domain'},
1765: $type,undef,'requestcourses')) {
1766: $showreqcrs = 1;
1767: last;
1768: }
1769: }
1.280 raeburn 1770: if (!$showreqcrs) {
1771: foreach my $type (@reqtypes) {
1772: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1773: $showreqcrs = 1;
1774: last;
1775: }
1776: }
1777: }
1.279 raeburn 1778: return $showreqcrs;
1779: }
1780:
1.306 raeburn 1781: sub dc_popup_js {
1782: my %lt = &Apache::lonlocal::texthash(
1783: more => '(More ...)',
1784: less => '(Less ...)',
1785: );
1786: return <<"END";
1787:
1788: function showCourseID() {
1789: document.getElementById('dccid').style.display='block';
1790: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1791: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 1792: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 1793: return;
1794: }
1795:
1796: function hideCourseID() {
1797: document.getElementById('dccid').style.display='none';
1.369 raeburn 1798: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 1799: return;
1800: }
1801:
1802: END
1803:
1804: }
1805:
1.378 raeburn 1806: sub countdown_toggle_js {
1807: return <<"END";
1808:
1809: function toggleCountdown() {
1810: var countdownid = document.getElementById('duedatecountdown');
1811: var currstyle = countdownid.style.display;
1812: if (currstyle == 'inline') {
1813: countdownid.style.display = 'none';
1814: document.getElementById('ddcountcollapse').innerHTML='';
1815: document.getElementById('ddcountexpand').innerHTML='◄ ';
1816: } else {
1817: countdownid.style.display = 'inline';
1818: document.getElementById('ddcountcollapse').innerHTML='► ';
1819: document.getElementById('ddcountexpand').innerHTML='';
1820: }
1821: return;
1822: }
1823:
1824: END
1825: }
1826:
1.435 musolffc 1827: # This creates a "done button" for timed events. The confirmation box is a jQuery
1.440 raeburn 1828: # dialog widget. If the interval parameter requires a proctor key for the timed
1829: # event to be marked done, there will also be a textbox where that can be entered.
1830: # Clicking OK will set the value of LC_interval_done to 'true', and, if needed will
1831: # set the value of LC_interval_done_proctorpass to the text entered in that box,
1832: # and submit the corresponding form.
1833: #
1834: # The &zero_time() routine in lonhomework.pm is called when a page is rendered if
1835: # LC_interval_done is true.
1836: #
1.435 musolffc 1837: sub done_button_js {
1.448 raeburn 1838: my ($type,$width,$height,$proctor,$donebuttontext) = @_;
1.441 raeburn 1839: return unless (($type eq 'map') || ($type eq 'resource'));
1.435 musolffc 1840: my %lt = &Apache::lonlocal::texthash(
1841: title => 'WARNING!',
1842: preamble => 'You are trying to end this timed event early.',
1843: map => 'Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder.',
1844: 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 1845: okdone => 'Click "OK" if you are completely finished.',
1.435 musolffc 1846: cancel => 'Click "Cancel" to continue working.',
1.440 raeburn 1847: proctor => 'Ask a proctor to enter the key, then click "OK" if you are completely finished.',
1848: ok => 'OK',
1849: exit => 'Cancel',
1850: key => 'Key:',
1851: nokey => 'A proctor key is required',
1.435 musolffc 1852: );
1.441 raeburn 1853: my $navmap = Apache::lonnavmaps::navmap->new();
1.450 raeburn 1854: my ($missing,$tried) = (0,0);
1.441 raeburn 1855: if (ref($navmap)) {
1856: my @resources=();
1857: if ($type eq 'map') {
1858: my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});
1.442 raeburn 1859: @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() });
1.441 raeburn 1860: } else {
1861: my $res = $navmap->getBySymb($env{'request.symb'});
1862: if (ref($res)) {
1863: if ($res->is_problem()) {
1864: push(@resources,$res);
1865: }
1866: }
1867: }
1868: foreach my $res (@resources) {
1.450 raeburn 1869: if (ref($res->parts()) eq 'ARRAY') {
1.441 raeburn 1870: foreach my $part (@{$res->parts()}) {
1871: if (!$res->tries($part)) {
1872: $missing++;
1873: } else {
1874: $tried++;
1875: }
1876: }
1877: }
1878: }
1879: }
1880: if ($missing) {
1881: $lt{'miss'} .= '<p class="LC_error">';
1882: if ($type eq 'map') {
1883: $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,question part,question parts] in this folder.',$missing);
1884: } else {
1885: $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,part] in this question.',$missing);
1886: }
1887: if ($missing > 1) {
1888: $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit answers for them.').'</span>';
1889: } else {
1890: $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'</p>';
1891: }
1892: }
1.449 raeburn 1893: $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"');
1.441 raeburn 1894: if ($proctor) {
1895: if ($height !~ /^\d+$/) {
1896: $height = 400;
1897: if ($missing) {
1898: $height += 60;
1.440 raeburn 1899: }
1.441 raeburn 1900: }
1901: if ($width !~ /^\d+$/) {
1902: $width = 400;
1903: if ($missing) {
1904: $width += 60;
1.440 raeburn 1905: }
1.441 raeburn 1906: }
1907: return <<END;
1.440 raeburn 1908: <form method="post" name="LCdoneButton" action="">
1909: <input type="hidden" name="LC_interval_done" value="" />
1910: <input type="hidden" name="LC_interval_done_proctorpass" value="" />
1.448 raeburn 1911: <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
1.440 raeburn 1912: </form>
1913:
1914: <div id="LC_done-confirm" title="$lt{'title'}">
1915: <p>$lt{'preamble'} $lt{$type}</p>
1.441 raeburn 1916: $lt{'miss'}
1.440 raeburn 1917: <p>$lt{'proctor'}</p>
1.449 raeburn 1918: <form name="LCdoneButtonProctor" action="">
1.440 raeburn 1919: <label>$lt{'key'}<input type="password" name="LC_interval_done_proctorkey" value="" /></label>
1920: <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
1921: </form>
1922: <p>$lt{'cancel'}</p>
1923: </div>
1924:
1925: <script type="text/javascript">
1926: // <![CDATA[
1927: \$( "#LC_done-confirm" ).dialog({ autoOpen: false });
1928: \$( "#LC_done-confirm-opener" ).on("click", function() {
1929: \$( "#LC_done-confirm" ).dialog("open");
1930: \$( "#LC_done-confirm" ).dialog({
1931: height: $height,
1932: width: $width,
1933: modal: true,
1934: resizable: false,
1935: buttons: [
1936: {
1937: text: "$lt{'ok'}",
1938: click: function() {
1939: var proctorkey = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
1940: if ((proctorkey == '') || (proctorkey == null)) {
1941: alert("$lt{'nokey'}");
1942: } else {
1943: \$( '[name="LC_interval_done"]' )[0].value = 'true';
1944: \$( '[name="LC_interval_done_proctorpass"]' )[0].value = proctorkey;
1945: \$( '[name="LCdoneButton"]' )[0].submit();
1946: }
1947: },
1948: },
1949: {
1950: text: "$lt{'exit'}",
1951: click: function() {
1952: \$("#LC_done-confirm").dialog( "close" );
1953: }
1954: }
1955: ],
1956: close: function() {
1957: \$( '[name="LC_interval_done_proctorkey"]' )[0].value = '';
1958: }
1959: });
1960: \$( "#LC_done-confirm" ).find( "form" ).on( "submit", function( event ) {
1961: event.preventDefault();
1962: \$( '[name="LC_interval_done"]' )[0].value = 'true';
1963: \$( '[name="LC_interval_done_proctorpass"]' )[0].value = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
1964: \$( '[name="LCdoneButton"]' )[0].submit();
1965: });
1966: });
1967:
1968: // ]]>
1969: </script>
1970:
1971: END
1.441 raeburn 1972: } else {
1973: if ($height !~ /^\d+$/) {
1974: $height = 320;
1975: if ($missing) {
1976: $height += 60;
1.440 raeburn 1977: }
1.441 raeburn 1978: }
1979: if ($width !~ /^\d+$/) {
1980: $width = 320;
1981: if ($missing) {
1982: $width += 60;
1.440 raeburn 1983: }
1.441 raeburn 1984: }
1985: if ($missing) {
1986: $lt{'miss'} = '</p>'.$lt{'miss'}.'<p>';
1987: }
1988: return <<END;
1.435 musolffc 1989:
1990: <form method="post" name="LCdoneButton" action="">
1991: <input type="hidden" name="LC_interval_done" value="" />
1.449 raeburn 1992: <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
1.435 musolffc 1993: </form>
1994:
1995: <div id="LC_done-confirm" title="$lt{'title'}">
1.441 raeburn 1996: <p>$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}</p>
1.435 musolffc 1997: </div>
1998:
1999: <script type="text/javascript">
2000: // <![CDATA[
2001: \$( "#LC_done-confirm" ).dialog({ autoOpen: false });
2002: \$( "#LC_done-confirm-opener" ).click(function() {
2003: \$( "#LC_done-confirm" ).dialog( "open" );
2004: \$( "#LC_done-confirm" ).dialog({
2005: resizable: false,
2006: height: $height,
1.440 raeburn 2007: width: $width,
1.435 musolffc 2008: modal: true,
1.440 raeburn 2009: buttons: [
2010: {
2011: text: "$lt{'ok'}",
2012: click: function() {
2013: \$( this ).dialog( "close" );
2014: \$( '[name="LC_interval_done"]' )[0].value = 'true';
2015: \$( '[name="LCdoneButton"]' )[0].submit();
2016: },
2017: },
2018: {
2019: text: "$lt{'exit'}",
2020: click: function() {
2021: \$( this ).dialog( "close" );
2022: },
2023: },
2024: ],
2025: });
1.435 musolffc 2026: });
2027: // ]]>
2028: </script>
2029:
2030: END
2031: }
2032: }
2033:
1.42 www 2034: sub utilityfunctions {
1.421 raeburn 2035: my ($httphost) = @_;
1.152 albertel 2036: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 droeschl 2037: if ($currenturl =~ m{^/adm/wrapper/ext/}
2038: && $env{'request.external.querystring'} ) {
1.293 raeburn 2039: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
2040: }
1.183 www 2041: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 2042:
1.152 albertel 2043: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.175 albertel 2044:
1.306 raeburn 2045: my $dc_popup_cid;
2046: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
2047: $env{'course.'.$env{'request.course.id'}.
2048: '.domain'}.'/'})) {
2049: $dc_popup_cid = &dc_popup_js();
2050: }
2051:
1.175 albertel 2052: my $start_page_annotate =
2053: &Apache::loncommon::start_page('Annotator',undef,
2054: {'only_body' => 1,
2055: 'js_ready' => 1,
2056: 'bgcolor' => '#BBBBBB',
2057: 'add_entries' => {
2058: 'onload' => 'javascript:document.goannotate.submit();'}});
2059:
1.205 albertel 2060: my $end_page_annotate =
2061: &Apache::loncommon::end_page({'js_ready' => 1});
2062:
1.389 raeburn 2063: my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
1.336 raeburn 2064:
1.368 www 2065: my $esc_url=&escape($currenturl);
2066: my $esc_symb=&escape($currentsymb);
1.332 wenzelju 2067:
1.378 raeburn 2068: my $countdown = &countdown_toggle_js();
2069:
1.487 raeburn 2070: my $ltitarget;
2071: if ($env{'request.lti.login'}) {
2072: $ltitarget = $env{'request.lti.target'};
2073: }
2074:
1.429 raeburn 2075: my $hostvar = '
2076: function setLCHost() {
2077: var lcHostname="";
2078: ';
2079: if ($httphost =~ m{^https?\://}) {
2080: $hostvar .= ' var lcServer="'.$httphost.'";'."\n".
2081: ' var hostReg = /^https?:\/\/([^\/]+)$/i;'."\n".
2082: ' var match = hostReg.exec(lcServer);'."\n".
2083: ' if (match.length) {'."\n".
2084: ' if (match[1] == location.hostname) {'."\n".
2085: ' lcHostname=lcServer;'."\n".
2086: ' }'."\n".
2087: ' }'."\n";
2088: }
2089:
2090: $hostvar .= ' return lcHostname;'."\n".
2091: '}'."\n";
2092:
1.42 www 2093: return (<<ENDUTILITY)
1.429 raeburn 2094: $hostvar
1.368 www 2095: var currentURL=unescape("$esc_url");
2096: var reloadURL=unescape("$esc_url");
2097: var currentSymb=unescape("$esc_symb");
1.42 www 2098:
1.306 raeburn 2099: $dc_popup_cid
1.114 albertel 2100:
1.389 raeburn 2101: $jumptores
1.336 raeburn 2102:
1.42 www 2103: function gopost(url,postdata) {
2104: if (url!='') {
1.429 raeburn 2105: var lcHostname = setLCHost();
2106: this.document.server.action=lcHostname+url;
1.42 www 2107: this.document.server.postdata.value=postdata;
2108: this.document.server.command.value='';
2109: this.document.server.url.value='';
2110: this.document.server.symb.value='';
2111: this.document.server.submit();
2112: }
2113: }
2114:
2115: function gocmd(url,cmd) {
2116: if (url!='') {
1.429 raeburn 2117: var lcHostname = setLCHost();
2118: this.document.server.action=lcHostname+url;
1.42 www 2119: this.document.server.postdata.value='';
2120: this.document.server.command.value=cmd;
2121: this.document.server.url.value=currentURL;
2122: this.document.server.symb.value=currentSymb;
2123: this.document.server.submit();
2124: }
1.57 www 2125: }
2126:
1.121 raeburn 2127: function gocstr(url,filename) {
2128: if (url == '/adm/cfile?action=delete') {
2129: this.document.cstrdelete.filename.value = filename
2130: this.document.cstrdelete.submit();
2131: return;
2132: }
1.137 raeburn 2133: if (url == '/adm/printout') {
2134: this.document.cstrprint.postdata.value = filename
2135: this.document.cstrprint.curseed.value = 0;
2136: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 2137: if (this.document.lonhomework) {
2138: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
2139: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
2140: }
2141: if (this.document.lonhomework.problemtype) {
1.164 albertel 2142: if (this.document.lonhomework.problemtype.value) {
2143: this.document.cstrprint.problemtype.value =
2144: this.document.lonhomework.problemtype.value;
2145: } else if (this.document.lonhomework.problemtype.options) {
2146: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
2147: if (this.document.lonhomework.problemtype.options[i].selected) {
2148: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
2149: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
2150: }
2151: }
2152: }
2153: }
2154: }
2155: }
1.137 raeburn 2156: this.document.cstrprint.submit();
2157: return;
2158: }
1.121 raeburn 2159: if (url !='') {
2160: this.document.constspace.filename.value = filename;
2161: this.document.constspace.action = url;
2162: this.document.constspace.submit();
2163: }
2164: }
2165:
1.131 raeburn 2166: function golist(url) {
2167: if (url!='' && url!= null) {
2168: currentURL = null;
2169: currentSymb= null;
1.429 raeburn 2170: var lcHostname = setLCHost();
1.487 raeburn 2171: var ltitarget = '$ltitarget';
2172: if (ltitarget == 'iframe') {
2173: document.location.href=lcHostname+url;
2174: } else {
2175: top.location.href=lcHostname+url;
2176: }
1.131 raeburn 2177: }
2178: }
2179:
2180:
1.121 raeburn 2181:
1.428 raeburn 2182: function catalog_info(isMobile) {
2183: if (isMobile == 1) {
2184: openMyModal(window.location.pathname+'.meta?modal=1',500,400,'yes');
2185: } else {
2186: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2187: }
1.57 www 2188: }
2189:
2190: function chat_win() {
1.429 raeburn 2191: var lcHostname = setLCHost();
2192: 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 2193: }
1.169 raeburn 2194:
2195: function group_chat(group) {
1.429 raeburn 2196: var lcHostname = setLCHost();
2197: var url = lcHostname+'/adm/groupchat?group='+group;
1.169 raeburn 2198: var winName = 'LONchat_'+group;
2199: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
2200: }
1.175 albertel 2201:
2202: function annotate() {
2203: w_Annotator_flag=1;
2204: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
2205: annotator.document.write(
2206: '$start_page_annotate'
2207: +"<form name='goannotate' target='Annotator' method='post' "
2208: +"action='/adm/annotations'>"
1.217 albertel 2209: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 2210: +"<\\/form>"
1.205 albertel 2211: +'$end_page_annotate');
1.175 albertel 2212: annotator.document.close();
2213: }
2214:
1.370 raeburn 2215: function open_StoredLinks_Import(rat) {
1.335 wenzelju 2216: var newWin;
1.429 raeburn 2217: var lcHostname = setLCHost();
1.335 wenzelju 2218: if (rat) {
1.429 raeburn 2219: newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1.334 wenzelju 2220: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1.335 wenzelju 2221: }
2222: else {
1.429 raeburn 2223: newWin = window.open(lcHostname+'/adm/wishlist?inhibitmenu=yes&mode=import',
1.335 wenzelju 2224: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
2225: }
1.334 wenzelju 2226: newWin.focus();
2227: }
2228:
1.480 raeburn 2229: function open_source() {
2230: var url = escape(window.location.pathname);
2231: sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+url,'LONsource',
2232: 'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes');
2233: }
2234:
1.372 raeburn 2235: (function (\$) {
2236: \$(document).ready(function () {
2237: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
2238: /*\@cc_on
2239: if (!window.XMLHttpRequest) {
2240: \$('.LC_hoverable').each(function () {
2241: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
2242: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
2243: });
2244: }
2245: \@*/
2246: });
2247: }(jQuery));
2248:
1.378 raeburn 2249: $countdown
2250:
1.42 www 2251: ENDUTILITY
2252: }
2253:
2254: sub serverform {
1.486 raeburn 2255: my $target;
2256: unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
2257: $target = ' target="_top"';
2258: }
1.42 www 2259: return(<<ENDSERVERFORM);
1.486 raeburn 2260: <form name="server" action="/adm/logout" method="post"$target>
1.42 www 2261: <input type="hidden" name="postdata" value="none" />
2262: <input type="hidden" name="command" value="none" />
2263: <input type="hidden" name="url" value="none" />
2264: <input type="hidden" name="symb" value="none" />
2265: </form>
2266: ENDSERVERFORM
2267: }
1.113 albertel 2268:
1.121 raeburn 2269: sub constspaceform {
1.487 raeburn 2270: my ($target,$printtarget);
2271: unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
2272: $target = ' target="_top"';
2273: $printtarget = ' target="_parent"';
2274: }
1.121 raeburn 2275: return(<<ENDCONSTSPACEFORM);
1.487 raeburn 2276: <form name="constspace" action="/adm/logout" method="post"$target>
1.121 raeburn 2277: <input type="hidden" name="filename" value="" />
2278: </form>
1.487 raeburn 2279: <form name="cstrdelete" action="/adm/cfile" method="post"$target>
1.121 raeburn 2280: <input type="hidden" name="action" value="delete" />
2281: <input type="hidden" name="filename" value="" />
2282: </form>
1.487 raeburn 2283: <form name="cstrprint" action="/adm/printout" method="post"$printtarget>
1.137 raeburn 2284: <input type="hidden" name="postdata" value="" />
2285: <input type="hidden" name="curseed" value="" />
2286: <input type="hidden" name="problemtype" value="" />
2287: </form>
2288:
1.121 raeburn 2289: ENDCONSTSPACEFORM
2290: }
2291:
1.220 raeburn 2292: sub hidden_button_check {
1.317 droeschl 2293: if ( $env{'request.course.id'} eq ''
2294: || $env{'request.role.adv'} ) {
2295:
1.220 raeburn 2296: return;
2297: }
1.232 raeburn 2298: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
2299: return $buttonshide;
1.220 raeburn 2300: }
1.184 raeburn 2301:
1.235 raeburn 2302: sub roles_selector {
1.486 raeburn 2303: my ($cdom,$cnum,$httphost,$ltitarget) = @_;
1.298 raeburn 2304: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 2305: my $now = time;
1.465 raeburn 2306: my (%courseroles,%seccount,%courseprivs,%roledesc);
1.235 raeburn 2307: my $is_cc;
1.432 droeschl 2308: my ($js,$form,$switcher);
1.298 raeburn 2309: my $ccrole;
2310: if ($crstype eq 'Community') {
2311: $ccrole = 'co';
2312: } else {
2313: $ccrole = 'cc';
1.350 raeburn 2314: }
1.457 raeburn 2315: my ($privref,$gotsymb,$destsymb);
1.350 raeburn 2316: my $destinationurl = $ENV{'REQUEST_URI'};
1.468 raeburn 2317: if ($destinationurl =~ /(\?|\&)symb=/) {
1.386 raeburn 2318: $gotsymb = 1;
2319: } elsif ($destinationurl =~ m{^/enc/}) {
2320: my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
1.468 raeburn 2321: if ($plainurl =~ /(\?|\&)symb=/) {
1.386 raeburn 2322: $gotsymb = 1;
2323: }
2324: }
2325: unless ($gotsymb) {
2326: $destsymb = &Apache::lonnet::symbread();
2327: if ($destsymb ne '') {
2328: $destsymb = &Apache::lonenc::check_encrypt($destsymb);
2329: }
2330: }
1.350 raeburn 2331: my $reqprivs = &required_privs();
2332: if (ref($reqprivs) eq 'HASH') {
2333: my $destination = $destinationurl;
2334: $destination =~ s/(\?.*)$//;
2335: if (exists($reqprivs->{$destination})) {
1.457 raeburn 2336: if ($reqprivs->{$destination} =~ /,/) {
2337: @{$privref} = split(/,/,$reqprivs->{$destination});
2338: } else {
2339: $privref = [$reqprivs->{$destination}];
2340: }
1.350 raeburn 2341: }
2342: }
1.298 raeburn 2343: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
2344: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 2345: if ((($start) && ($start<0)) ||
2346: (($end) && ($end<$now)) ||
2347: (($start) && ($now<$start))) {
2348: $is_cc = 0;
2349: } else {
2350: $is_cc = 1;
2351: }
2352: }
2353: if ($is_cc) {
1.457 raeburn 2354: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs);
2355: } elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) {
1.465 raeburn 2356: &get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref);
1.235 raeburn 2357: } else {
1.262 raeburn 2358: my %gotnosection;
1.235 raeburn 2359: foreach my $item (keys(%env)) {
1.239 raeburn 2360: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 2361: my $role = $1;
2362: my $sec = $2;
2363: next if ($role eq 'gr');
2364: my ($start,$end) = split(/\./,$env{$item});
2365: next if (($start && $start > $now) || ($end && $end < $now));
2366: if ($sec eq '') {
1.239 raeburn 2367: if (!$gotnosection{$role}) {
2368: $seccount{$role} ++;
2369: $gotnosection{$role} = 1;
2370: }
1.235 raeburn 2371: }
1.457 raeburn 2372: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
1.350 raeburn 2373: my $cnumsec = $cnum;
2374: if ($sec ne '') {
2375: $cnumsec .= "/$sec";
2376: }
2377: $courseprivs{"$role./$cdom/$cnumsec./"} =
2378: $env{"user.priv.$role./$cdom/$cnumsec./"};
2379: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
2380: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
2381: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
2382: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
2383: }
1.235 raeburn 2384: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 2385: if ($sec ne '') {
1.264 raeburn 2386: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 2387: push(@{$courseroles{$role}},$sec);
2388: $seccount{$role} ++;
2389: }
2390: }
2391: } else {
2392: @{$courseroles{$role}} = ();
2393: if ($sec ne '') {
2394: $seccount{$role} ++;
1.235 raeburn 2395: push(@{$courseroles{$role}},$sec);
2396: }
2397: }
2398: }
2399: }
2400: }
1.298 raeburn 2401: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.402 raeburn 2402: my $numdiffsec;
2403: if (keys(%seccount) == 1) {
2404: foreach my $key (keys(%seccount)) {
2405: $numdiffsec = $seccount{$key};
2406: }
2407: }
2408: if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
1.401 raeburn 2409: my @submenu;
1.465 raeburn 2410: $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref);
1.401 raeburn 2411: $form =
1.421 raeburn 2412: '<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n".
1.401 raeburn 2413: ' <input type="hidden" name="destinationurl" value="'.
2414: &HTML::Entities::encode($destinationurl).'" />'."\n".
2415: ' <input type="hidden" name="gotorole" value="1" />'."\n".
2416: ' <input type="hidden" name="selectrole" value="" />'."\n".
1.402 raeburn 2417: ' <input type="hidden" name="switchrole" value="" />'."\n";
2418: if ($destsymb ne '') {
2419: $form .= ' <input type="hidden" name="destsymb" value="'.
2420: &HTML::Entities::encode($destsymb).'" />'."\n";
2421: }
2422: $form .= '</form>'."\n";
1.235 raeburn 2423: foreach my $role (@roles_order) {
1.402 raeburn 2424: my $include;
1.235 raeburn 2425: if (defined($courseroles{$role})) {
1.402 raeburn 2426: if ($env{'request.role'} =~ m{^\Q$role\E}) {
2427: if ($seccount{$role} > 1) {
2428: $include = 1;
2429: }
2430: } else {
2431: $include = 1;
2432: }
2433: }
2434: if ($include) {
1.401 raeburn 2435: push(@submenu,['javascript:adhocRole('."'$role'".')',
2436: &Apache::lonnet::plaintext($role,$crstype)]);
1.235 raeburn 2437: }
2438: }
2439: foreach my $role (sort(keys(%courseroles))) {
2440: if ($role =~ /^cr/) {
1.403 raeburn 2441: my $include;
2442: if ($env{'request.role'} =~ m{^\Q$role\E}) {
1.402 raeburn 2443: if ($seccount{$role} > 1) {
2444: $include = 1;
2445: }
1.403 raeburn 2446: } else {
2447: $include = 1;
2448: }
2449: if ($include) {
1.460 raeburn 2450: my $rolename;
2451: if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) {
1.465 raeburn 2452: $rolename = $roledesc{$role};
2453: if ($rolename eq '') {
2454: $rolename = &mt('Helpdesk [_1]',$1);
2455: }
1.460 raeburn 2456: } else {
2457: $rolename = &Apache::lonnet::plaintext($role);
2458: }
1.403 raeburn 2459: push(@submenu,['javascript:adhocRole('."'$role'".')',
1.460 raeburn 2460: $rolename]);
1.403 raeburn 2461: }
1.235 raeburn 2462: }
2463: }
1.401 raeburn 2464: if (@submenu > 0) {
1.486 raeburn 2465: $switcher = &create_submenu('','',&mt('Switch role'),\@submenu,'','',$ltitarget);
1.386 raeburn 2466: }
1.235 raeburn 2467: }
1.401 raeburn 2468: return ($js,$form,$switcher);
1.235 raeburn 2469: }
2470:
1.262 raeburn 2471: sub get_all_courseroles {
1.350 raeburn 2472: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 2473: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 2474: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 2475: return;
2476: }
2477: my ($result,$cached) =
2478: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
2479: if (defined($cached)) {
2480: if (ref($result) eq 'HASH') {
2481: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 2482: (ref($result->{'seccount'}) eq 'HASH') &&
2483: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 2484: %{$courseroles} = %{$result->{'roles'}};
2485: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 2486: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 2487: return;
2488: }
2489: }
2490: }
2491: my %gotnosection;
2492: my %adv_roles =
2493: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2494: foreach my $role (keys(%adv_roles)) {
2495: my ($urole,$usec) = split(/:/,$role);
2496: if (!$gotnosection{$urole}) {
2497: $seccount->{$urole} ++;
2498: $gotnosection{$urole} = 1;
2499: }
2500: if (ref($courseroles->{$urole}) eq 'ARRAY') {
2501: if ($usec ne '') {
2502: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
2503: push(@{$courseroles->{$urole}},$usec);
2504: $seccount->{$urole} ++;
2505: }
2506: }
2507: } else {
2508: @{$courseroles->{$urole}} = ();
2509: if ($usec ne '') {
2510: $seccount->{$urole} ++;
2511: push(@{$courseroles->{$urole}},$usec);
2512: }
2513: }
1.350 raeburn 2514: my $area = '/'.$cdom.'/'.$cnum;
2515: if ($usec ne '') {
2516: $area .= '/'.$usec;
2517: }
2518: if ($role =~ /^cr\//) {
2519: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
2520: } else {
2521: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
2522: }
1.262 raeburn 2523: }
2524: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
2525: @{$courseroles->{'st'}} = ();
1.350 raeburn 2526: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 2527: if (keys(%sections_count) > 0) {
2528: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 2529: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 2530: }
1.410 raeburn 2531: $seccount->{'st'} ++; # Increment for a section-less student role.
1.262 raeburn 2532: my $rolehash = {
2533: 'roles' => $courseroles,
2534: 'seccount' => $seccount,
1.350 raeburn 2535: 'privs' => $courseprivs,
1.262 raeburn 2536: };
2537: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
2538: return;
2539: }
2540:
1.457 raeburn 2541: sub get_customadhoc_roles {
1.465 raeburn 2542: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_;
1.457 raeburn 2543: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.465 raeburn 2544: (ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) {
1.457 raeburn 2545: return;
2546: }
1.466 raeburn 2547: my $is_helpdesk = 0;
2548: my $now = time;
2549: foreach my $role ('dh','da') {
2550: if ($env{"user.role.$role./$cdom/"}) {
2551: my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"});
2552: if (!($start && ($now<$start)) && !($end && ($now>$end))) {
2553: $is_helpdesk = 1;
2554: last;
2555: }
2556: }
2557: }
2558: if ($is_helpdesk) {
2559: my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
2560: my %available;
2561: if (ref($possroles) eq 'ARRAY') {
2562: map { $available{$_} = 1; } @{$possroles};
2563: }
2564: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
2565: if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
2566: if (keys(%{$domdefaults{'adhocroles'}})) {
2567: my $numsec = 1;
2568: my @sections;
2569: my ($allseclist,$cached) =
2570: &Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum);
2571: if (defined($cached)) {
2572: if ($allseclist ne '') {
2573: @sections = split(/,/,$allseclist);
1.465 raeburn 2574: $numsec += scalar(@sections);
1.457 raeburn 2575: }
1.466 raeburn 2576: } else {
2577: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
2578: @sections = sort(keys(%sections_count));
2579: $numsec += scalar(@sections);
2580: $allseclist = join(',',@sections);
2581: &Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
2582: }
2583: my (%adhoc,$gotprivs);
2584: my $prefix = "cr/$cdom/$cdom".'-domainconfig';
2585: foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
2586: next if (($role eq '') || ($role =~ /\W/));
2587: $seccount->{"$prefix/$role"} = $numsec;
2588: $roledesc->{"$prefix/$role"} = $description->{$role};
2589: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
2590: if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
2591: $courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
2592: $env{"user.priv.$prefix/$role./$cdom/$cnum./"};
2593: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} =
2594: $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"};
2595: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} =
2596: $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"};
2597: } else {
2598: unless ($gotprivs) {
2599: my ($adhocroles,$privscached) =
2600: &Apache::lonnet::is_cached_new('adhocroles',$cdom);
2601: if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) {
2602: %adhoc = %{$adhocroles};
2603: } else {
2604: my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
2605: my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_');
2606: foreach my $key (keys(%roledefs)) {
2607: (undef,my $rolename) = split(/_/,$key);
2608: if ($rolename ne '') {
2609: my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key});
2610: $coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv);
2611: $adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv));
1.457 raeburn 2612: }
2613: }
1.466 raeburn 2614: &Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc);
1.457 raeburn 2615: }
1.466 raeburn 2616: $gotprivs = 1;
1.457 raeburn 2617: }
1.466 raeburn 2618: ($courseprivs->{"$prefix/$role./$cdom/$cnum./"},
2619: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"},
2620: $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) =
2621: split(/\_/,$adhoc{$role});
1.457 raeburn 2622: }
1.466 raeburn 2623: }
2624: if ($available{$role}) {
2625: $courseroles->{"$prefix/$role"} = \@sections;
1.457 raeburn 2626: }
2627: }
2628: }
2629: }
2630: }
2631: return;
2632: }
2633:
1.235 raeburn 2634: sub jump_to_role {
1.465 raeburn 2635: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_;
1.239 raeburn 2636: my %lt = &Apache::lonlocal::texthash(
2637: this => 'This role has section(s) associated with it.',
2638: ente => 'Enter a specific section.',
2639: orlb => 'Enter a specific section, or leave blank for no section.',
2640: avai => 'Available sections are:',
2641: youe => 'You entered an invalid section choice:',
1.352 raeburn 2642: plst => 'Please try again.',
1.350 raeburn 2643: role => 'The role you selected is not permitted to view the current page.',
2644: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 2645: );
2646: my $js;
2647: if (ref($courseroles) eq 'HASH') {
2648: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
2649: ' var numsec = new Array();'."\n".
2650: ' var rolesections = new Array();'."\n".
2651: ' var rolenames = new Array();'."\n".
2652: ' var roleseclist = new Array();'."\n";
2653: my @items = keys(%{$courseroles});
2654: for (my $i=0; $i<@items; $i++) {
2655: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
2656: my ($secs,$secstr);
2657: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
2658: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
2659: $secs = join('","',@sections);
2660: $secstr = join(', ',@sections);
2661: }
2662: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
2663: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
2664: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
2665: }
2666: }
1.350 raeburn 2667: my $checkroles = 0;
1.457 raeburn 2668: if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) {
2669: my %disallowed;
1.350 raeburn 2670: foreach my $role (sort(keys(%{$courseprivs}))) {
2671: my $trole;
2672: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
2673: $trole = $1;
2674: }
2675: if (($trole ne '') && ($trole ne 'cm')) {
1.457 raeburn 2676: $disallowed{$trole} = 1;
2677: foreach my $priv (@{$privref}) {
2678: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
2679: delete($disallowed{$trole});
2680: last;
2681: }
1.350 raeburn 2682: }
2683: }
2684: }
1.457 raeburn 2685: if (keys(%disallowed) > 0) {
1.350 raeburn 2686: $checkroles = 1;
1.457 raeburn 2687: $js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n".
1.350 raeburn 2688: " var rolecheck = 1;\n";
2689: }
2690: }
2691: if (!$checkroles) {
2692: $js .= " var disallow = new Array();\n".
2693: " rolecheck = 0;\n";
2694: }
1.273 droeschl 2695: return <<"END";
1.235 raeburn 2696: <script type="text/javascript">
1.273 droeschl 2697: //<![CDATA[
1.401 raeburn 2698: function adhocRole(newrole) {
1.239 raeburn 2699: $js
1.235 raeburn 2700: if (newrole == '') {
1.350 raeburn 2701: return;
1.235 raeburn 2702: }
1.239 raeburn 2703: var fullrole = newrole+'./$cdom/$cnum';
2704: var selidx = '';
2705: for (var i=0; i<rolenames.length; i++) {
2706: if (rolenames[i] == newrole) {
2707: selidx = i;
2708: }
2709: }
1.350 raeburn 2710: if (rolecheck > 0) {
2711: for (var i=0; i<disallow.length; i++) {
2712: if (disallow[i] == newrole) {
2713: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
2714: document.rolechooser.destinationurl.value = '/adm/menu';
2715: } else {
2716: return;
2717: }
2718: }
2719: }
2720: }
1.239 raeburn 2721: var secok = 1;
2722: var secchoice = '';
2723: if (selidx >= 0) {
2724: if (numsec[selidx] > 1) {
2725: secok = 0;
2726: var numrolesec = rolesections[selidx].length;
2727: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 2728: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 2729: if (secchoice == '') {
2730: if (msgidx > 0) {
2731: secok = 1;
2732: }
2733: } else {
2734: for (var j=0; j<rolesections[selidx].length; j++) {
2735: if (rolesections[selidx][j] == secchoice) {
2736: secok = 1;
2737: }
2738: }
2739: }
2740: } else {
2741: if (rolesections[selidx].length == 1) {
2742: secchoice = rolesections[selidx][0];
2743: }
2744: }
2745: }
2746: if (secok == 1) {
2747: if (secchoice != '') {
2748: fullrole += '/'+secchoice;
2749: }
2750: } else {
2751: if (secchoice != null) {
2752: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
2753: }
2754: return;
2755: }
2756: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 2757: return;
2758: }
2759: itemid = retrieveIndex('gotorole');
2760: if (itemid != -1) {
1.239 raeburn 2761: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 2762: }
1.401 raeburn 2763: document.rolechooser.switchrole.value = fullrole;
1.235 raeburn 2764: document.rolechooser.selectrole.value = '1';
2765: document.rolechooser.submit();
2766: return;
2767: }
2768:
2769: function retrieveIndex(item) {
2770: for (var i=0;i<document.rolechooser.elements.length;i++) {
2771: if (document.rolechooser.elements[i].name == item) {
2772: return i;
2773: }
2774: }
2775: return -1;
2776: }
1.273 droeschl 2777: // ]]>
1.235 raeburn 2778: </script>
2779: END
2780: }
2781:
1.350 raeburn 2782: sub required_privs {
2783: my $privs = {
1.457 raeburn 2784: '/adm/parmset' => 'opa,vpa',
2785: '/adm/courseprefs' => 'opa,vpa',
1.350 raeburn 2786: '/adm/whatsnew' => 'whn',
1.461 raeburn 2787: '/adm/populate' => 'cst,vpa,vcl',
1.350 raeburn 2788: '/adm/trackstudent' => 'vsa',
1.457 raeburn 2789: '/adm/statistics' => 'mgr,vgr',
2790: '/adm/setblock' => 'dcm,vcb',
1.367 raeburn 2791: '/adm/coursedocs' => 'mdc',
1.350 raeburn 2792: };
2793: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 2794: $privs->{'/adm/classcalc'} = 'vgr',
2795: $privs->{'/adm/assesscalc'} = 'vgr',
2796: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 2797: }
2798: return $privs;
2799: }
1.235 raeburn 2800:
1.378 raeburn 2801: sub countdown_timer {
2802: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
1.484 raeburn 2803: (($env{'request.filename'}=~/$LONCAPA::assess_re/) ||
2804: (($env{'request.symb'} =~ /ext\.tool$/) &&
2805: (&Apache::lonnet::EXT('resource.0.gradable',$env{'request.symb'}) =~ /^yes$/i)))) {
1.387 raeburn 2806: my ($type,$hastimeleft,$slothastime);
2807: my $now = time;
2808: if ($env{'request.filename'} =~ /\.task$/) {
2809: $type = 'Task';
1.485 raeburn 2810: } elsif ($env{'request.symb'} =~ /ext\.tool$/) {
2811: $type = 'tool';
1.387 raeburn 2812: } else {
2813: $type = 'problem';
2814: }
1.485 raeburn 2815: my ($status,$accessmsg,$slot_name,$slot);
2816: if ($type eq 'tool') {
2817: ($status,$accessmsg,$slot_name,$slot) =
2818: &Apache::lonhomework::check_slot_access('0',$type,$env{'request.symb'},['0']);
2819: } else {
2820: ($status,$accessmsg,$slot_name,$slot) =
2821: &Apache::lonhomework::check_slot_access('0',$type);
2822: }
1.387 raeburn 2823: if ($slot_name ne '') {
2824: if (ref($slot) eq 'HASH') {
2825: if (($slot->{'starttime'} < $now) &&
2826: ($slot->{'endtime'} > $now)) {
2827: $slothastime = 1;
2828: }
2829: }
2830: }
2831: if ($status ne 'CAN_ANSWER') {
2832: return;
2833: }
1.378 raeburn 2834: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.380 raeburn 2835: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.448 raeburn 2836: my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
1.381 raeburn 2837: if (@interval > 1) {
1.448 raeburn 2838: ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
2839: if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
2840: $usesdone = 'done';
2841: $donebuttontext = $1;
2842: (undef,$proctor,$secret) = split(/_/,$2);
2843: } elsif ($donesuffix =~ /^done(|_.+)$/) {
2844: $donebuttontext = &mt('Done');
2845: ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
2846: }
1.381 raeburn 2847: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
2848: if ($first_access > 0) {
1.437 raeburn 2849: if ($first_access+$timelimit > time) {
1.381 raeburn 2850: $hastimeleft = 1;
2851: }
2852: }
2853: }
1.380 raeburn 2854: if (($duedate && $duedate > time) ||
1.387 raeburn 2855: (!$duedate && $hastimeleft) ||
2856: ($slot_name ne '' && $slothastime)) {
1.435 musolffc 2857: my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton);
1.387 raeburn 2858: if ((@interval > 1 && $hastimeleft) ||
2859: ($type eq 'Task' && $slothastime)) {
1.378 raeburn 2860: $currdisp = 'inline';
2861: $collapse = '► ';
1.435 musolffc 2862: if ((@interval > 1) && ($hastimeleft)) {
1.437 raeburn 2863: if ($usesdone eq 'done') {
1.448 raeburn 2864: $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
1.437 raeburn 2865: }
1.435 musolffc 2866: }
1.378 raeburn 2867: } else {
2868: $currdisp = 'none';
2869: $expand = '◄ ';
2870: }
2871: unless ($env{'environment.icons'} eq 'iconsonly') {
1.379 raeburn 2872: $alttxt = &mt('Timer');
2873: $title = $alttxt.' ';
1.378 raeburn 2874: }
2875: my $desc = &mt('Countdown to due date/time');
1.435 musolffc 2876:
1.378 raeburn 2877: return <<END;
1.435 musolffc 2878: $donebutton
1.378 raeburn 2879: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2880: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
2881: $collapse
1.379 raeburn 2882: </span></a>
1.378 raeburn 2883: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
2884: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2885: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.379 raeburn 2886: <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 2887: END
2888: }
2889: }
2890: return;
2891: }
2892:
1.445 raeburn 2893: sub placement_progress {
2894: my ($totalpoints,$incomplete) = &Apache::lonplacementtest::check_completion(undef,undef,1);
2895: my $complete = 100 - $incomplete;
2896: return '<span class="LC_placement_prog">'.
2897: &mt('Test is [_1]% complete',$complete).'</span>';
2898: }
2899:
1.2 www 2900: # ================================================================ Main Program
2901:
1.16 harris41 2902: BEGIN {
1.166 albertel 2903: if (! defined($readdesk)) {
1.283 droeschl 2904: {
2905: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2906: if ( CORE::open( my $config,"<$tabfile") ) {
2907: while (my $configline=<$config>) {
2908: $configline=(split(/\#/,$configline))[0];
2909: $configline=~s/^\s+//;
2910: chomp($configline);
1.209 www 2911: if ($configline=~/^cat\:/) {
1.283 droeschl 2912: my @entries=split(/\:/,$configline);
2913: $category_positions{$entries[2]}=$entries[1];
2914: $category_names{$entries[2]}=$entries[3];
2915: } elsif ($configline=~/^prim\:/) {
1.415 raeburn 2916: my @entries = (split(/\:/, $configline))[1..6];
1.400 raeburn 2917: push(@primary_menu,\@entries);
1.371 raeburn 2918: } elsif ($configline=~/^primsub\:/) {
2919: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
1.400 raeburn 2920: push(@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 2921: } elsif ($configline=~/^scnd\:/) {
2922: my @entries = (split(/\:/, $configline))[1..5];
1.401 raeburn 2923: push(@secondary_menu,\@entries);
1.482 raeburn 2924: } elsif ($configline=~/^scndsub\:/) {
2925: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
2926: push(@{$secondary_submenu{$parent}},\@entries);
1.283 droeschl 2927: } elsif ($configline) {
2928: push(@desklines,$configline);
2929: }
2930: }
2931: CORE::close($config);
2932: }
2933: }
2934: $readdesk='done';
1.2 www 2935: }
2936: }
1.30 www 2937:
1.1 www 2938: 1;
2939: __END__
2940:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>