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