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