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