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