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