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