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