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