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