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