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