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