Annotation of loncom/interface/lonmenu.pm, revision 1.411
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.411 ! raeburn 4: # $Id: lonmenu.pm,v 1.410 2013/03/19 23:28:57 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.371 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.371 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.371 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.375 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:
134: =item clear()
135:
136: =item switch()
137:
138: Switch a button or create a link
139: Switch acts on the javascript that is executed when a button is clicked.
140: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
141:
142: =item secondlevel()
143:
144: =item openmenu()
145:
146: =item inlinemenu()
147:
148: =item rawconfig()
149:
150: =item utilityfunctions()
151:
1.371 raeburn 152: Output from this routine is a number of javascript functions called by
153: items in the inline menu, and in some cases items in the Main Menu page.
154:
1.244 jms 155: =item serverform()
156:
157: =item constspaceform()
158:
159: =item get_nav_status()
160:
161: =item hidden_button_check()
162:
163: =item roles_selector()
164:
165: =item jump_to_role()
166:
167: =back
168:
169: =cut
170:
1.1 www 171: package Apache::lonmenu;
172:
173: use strict;
1.152 albertel 174: use Apache::lonnet;
1.47 matthew 175: use Apache::lonhtmlcommon();
1.115 albertel 176: use Apache::loncommon();
1.127 albertel 177: use Apache::lonenc();
1.88 www 178: use Apache::lonlocal;
1.361 raeburn 179: use Apache::lonmsg();
1.207 foxr 180: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 181: use HTML::Entities();
1.346 wenzelju 182: use Apache::lonwishlist();
1.88 www 183:
1.283 droeschl 184: use vars qw(@desklines %category_names %category_members %category_positions
1.371 raeburn 185: $readdesk @primary_menu %primary_submenu @secondary_menu);
1.88 www 186:
1.56 www 187: my @inlineremote;
1.38 www 188:
1.283 droeschl 189: sub prep_menuitem {
1.291 raeburn 190: my ($menuitem) = @_;
191: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 192: my $link;
193: if ($$menuitem[1]) { # graphical Link
194: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 195: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
196: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 197: } else { # textual Link
1.291 raeburn 198: $link = &mt($$menuitem[3]);
199: }
1.316 droeschl 200: return '<li><a'
201: # highlighting for new messages
202: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
1.325 droeschl 203: . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
1.283 droeschl 204: }
205:
206: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
207: # that contains following links:
1.371 raeburn 208: # About, Message, Personal, Roles, Help, Logout
1.283 droeschl 209: # @primary_menu is filled within the BEGIN block of this module with
210: # entries from mydesk.tab
211: sub primary_menu {
212: my $menu;
213: # each element of @primary contains following array:
214: # (link url, icon path, alt text, link text, condition)
1.319 raeburn 215: my $public;
216: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
217: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
218: $public = 1;
219: }
1.283 droeschl 220: foreach my $menuitem (@primary_menu) {
221: # evaluate conditions
1.296 droeschl 222: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 223: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 224: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 225: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 226: && !&Apache::lonmsg::mynewmail(); #
1.319 raeburn 227: next if $$menuitem[4] !~ /public/ ##we've a public user,
228: && $public; ##who should not see all
229: ##links
1.283 droeschl 230: next if $$menuitem[4] eq 'onlypublic'# hide links which are
1.319 raeburn 231: && !$public; # only visible to public
232: # users
1.283 droeschl 233: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 234: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 235: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 236: && !&Apache::loncommon::show_course(); ##
237:
1.371 raeburn 238: my $title = $menuitem->[3];
239: if (defined($primary_submenu{$title})) {
1.375 raeburn 240: my ($link,$target);
1.371 raeburn 241: if ($menuitem->[0] ne '') {
242: $link = $menuitem->[0];
243: $target = '_top';
244: } else {
245: $link = '#';
246: }
1.375 raeburn 247: my @primsub;
1.371 raeburn 248: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.375 raeburn 249: foreach my $item (@{$primary_submenu{$title}}) {
1.383 raeburn 250: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.375 raeburn 251: next if ((($item->[2] eq 'portfolio') ||
252: ($item->[2] eq 'blog')) &&
253: (!&Apache::lonnet::usertools_access('','',$item->[2],
254: undef,'tools')));
255: push(@primsub,$item);
256: }
257: if (@primsub > 0) {
258: $menu .= &create_submenu($link,$target,$title,\@primsub);
259: } elsif ($link) {
1.377 raeburn 260: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.371 raeburn 261: }
262: }
263: } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.340 raeburn 264: if ($public) {
265: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
266: my $defdom = &Apache::lonnet::default_login_domain();
267: my $to = &Apache::loncommon::build_recipient_list(undef,
268: 'helpdeskmail',
269: $defdom,$origmail);
270: if ($to ne '') {
271: $menu .= &prep_menuitem($menuitem);
272: }
273: } else {
274: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
275: }
1.283 droeschl 276: } else {
1.325 droeschl 277: $menu .= prep_menuitem($menuitem);
1.283 droeschl 278: }
1.291 raeburn 279: }
1.325 droeschl 280: $menu =~ s/\[domain\]/$env{'user.domain'}/g;
281: $menu =~ s/\[user\]/$env{'user.name'}/g;
1.283 droeschl 282:
1.291 raeburn 283: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 284: }
285:
1.329 droeschl 286: #returns hashref {user=>'',dom=>''} containing:
287: # own name, domain if user is au
288: # name, domain of parent author if user is ca or aa
289: #empty return if user is not an author or not on homeserver
290: #
291: #TODO this should probably be moved somewhere more central
292: #since it can be used by different parts of the system
293: sub getauthor{
294: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
295:
296: #co- or assistent author?
297: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
298: ? ($1, $2) #domain, username of the parent author
299: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
300:
301: # current server == home server?
302: my $home = &Apache::lonnet::homeserver($user,$dom);
303: foreach (&Apache::lonnet::current_machine_ids()){
304: return {user => $user, dom => $dom} if $_ eq $home;
305: }
306:
307: # if wrong server
308: return;
309: }
1.283 droeschl 310:
311: sub secondary_menu {
312: my $menu;
313:
1.286 raeburn 314: my $crstype = &Apache::loncommon::course_type();
1.327 droeschl 315: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
316: ? "/$env{'request.course.sec'}"
317: : '');
318: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
1.376 raeburn 319: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
1.327 droeschl 320: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
321: my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
322: my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
1.341 www 323: my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
1.343 www 324: my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
325: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
326: my $author = &getauthor();
1.327 droeschl 327:
1.404 raeburn 328: my ($canmodifycoauthor);
329: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
330: my $extent = "$env{'user.domain'}/$env{'user.name'}";
331: if ((&Apache::lonnet::allowed('cca',$extent)) ||
332: (&Apache::lonnet::allowed('caa',$extent))) {
333: $canmodifycoauthor = 1;
334: }
335: }
336:
1.286 raeburn 337: my %groups = &Apache::lonnet::get_active_groups(
338: $env{'user.domain'}, $env{'user.name'},
339: $env{'course.' . $env{'request.course.id'} . '.domain'},
340: $env{'course.' . $env{'request.course.id'} . '.num'});
1.327 droeschl 341:
1.401 raeburn 342: my ($roleswitcher_js,$roleswitcher_form);
343:
1.283 droeschl 344: foreach my $menuitem (@secondary_menu) {
345: # evaluate conditions
1.296 droeschl 346: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 347: next if $$menuitem[4] ne 'always'
1.404 raeburn 348: && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
1.283 droeschl 349: && !$env{'request.course.id'};
350: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 351: && !$canedit;
1.341 www 352: next if $$menuitem[4] eq 'nvgr'
353: && $canvgr;
354: next if $$menuitem[4] eq 'vgr'
355: && !$canvgr;
1.327 droeschl 356: next if $$menuitem[4] eq 'cst'
357: && !$canmodifyuser;
1.343 www 358: next if $$menuitem[4] eq 'ncst'
1.376 raeburn 359: && ($canmodifyuser || !$canviewroster);
1.343 www 360: next if $$menuitem[4] eq 'mgr'
361: && !$canmgr;
362: next if $$menuitem[4] eq 'nmgr'
363: && $canmgr;
1.327 droeschl 364: next if $$menuitem[4] eq 'whn'
365: && !$canviewwnew;
366: next if $$menuitem[4] eq 'opa'
367: && !$canmodpara;
1.283 droeschl 368: next if $$menuitem[4] =~ /showgroups$/
1.300 raeburn 369: && !$canviewgrps
1.286 raeburn 370: && !%groups;
1.329 droeschl 371: next if $$menuitem[4] eq 'author'
372: && !$author;
1.404 raeburn 373: next if $$menuitem[4] eq 'cca'
374: && !$canmodifycoauthor;
1.283 droeschl 375:
1.286 raeburn 376: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 377: # special treatment for role selector
1.401 raeburn 378: ($roleswitcher_js,$roleswitcher_form,my $switcher) =
379: &roles_selector(
1.283 droeschl 380: $env{'course.' . $env{'request.course.id'} . '.domain'},
1.401 raeburn 381: $env{'course.' . $env{'request.course.id'} . '.num'}
382: );
383: $menu .= $switcher;
1.296 droeschl 384: } else {
385: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 386: }
387: }
388: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 389: my $escurl = &escape( &Apache::lonenc::check_encrypt(
390: $env{'request.noversionuri'}));
1.283 droeschl 391:
1.291 raeburn 392: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
393: $env{'request.symb'}));
1.283 droeschl 394:
395: if ( $env{'request.state'} eq 'construct'
396: and ( $env{'request.noversionuri'} eq ''
397: || !defined($env{'request.noversionuri'})))
398: {
1.359 raeburn 399: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
400: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 401: $escurl = &escape($escurl);
1.283 droeschl 402: }
403: $menu =~ s/\[url\]/$escurl/g;
404: $menu =~ s/\[symb\]/$escsymb/g;
405: }
1.329 droeschl 406: $menu =~ s/\[uname\]/$$author{user}/g;
407: $menu =~ s/\[udom\]/$$author{dom}/g;
1.385 raeburn 408: if ($menu) {
409: $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
410: }
1.401 raeburn 411: if ($roleswitcher_form) {
412: $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
413: }
1.385 raeburn 414: return $menu;
1.283 droeschl 415: }
416:
1.375 raeburn 417: sub create_submenu {
418: my ($link,$target,$title,$submenu) = @_;
419: return unless (ref($submenu) eq 'ARRAY');
1.379 raeburn 420: my $disptarget;
421: if ($target ne '') {
422: $disptarget = ' target="'.$target.'"';
423: }
1.375 raeburn 424: my $menu = '<li class="LC_hoverable">'.
1.379 raeburn 425: '<a href="'.$link.'"'.$disptarget.'>'.
1.377 raeburn 426: '<span class="LC_nobreak">'.&mt($title).
1.375 raeburn 427: '<span class="LC_fontsize_small" style="font-weight:normal;">'.
428: ' ▼</span></span></a>'.
429: '<ul>';
430: my $count = 0;
431: my $numsub = scalar(@{$submenu});
432: foreach my $item (@{$submenu}) {
433: $count ++;
434: if (ref($item) eq 'ARRAY') {
435: my $borderbot;
436: if ($count == $numsub) {
437: $borderbot = 'border-bottom:1px solid black;';
438: }
439: $menu .= '<li style="margin:0;padding:0;'.
440: $borderbot.'"><a href="'.$item->[0].'">'.
1.377 raeburn 441: &mt($item->[1]).'</a></li>';
1.375 raeburn 442: }
443: }
444: $menu .= '</ul></li>';
445: return $menu;
446: }
447:
1.40 www 448: sub innerregister {
1.390 raeburn 449: my ($forcereg,$bread_crumbs,$group) = @_;
1.152 albertel 450: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 451: my $is_const_dir = 0;
1.120 raeburn 452:
1.175 albertel 453: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 454:
1.174 albertel 455: $env{'request.registered'} = 1;
1.40 www 456:
1.177 albertel 457: undef(@inlineremote);
1.56 www 458:
1.393 raeburn 459: my ($mapurl,$resurl);
1.390 raeburn 460:
1.393 raeburn 461: if ($env{'request.course.id'}) {
462: if ($env{'request.symb'}) {
463: ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
464: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
1.267 droeschl 465:
1.393 raeburn 466: my $maptitle = &Apache::lonnet::gettitle($mapurl);
467: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.318 droeschl 468:
469: #SD
470: #course_type only Course and Community?
471: #
1.393 raeburn 472: my @crumbs;
473: unless (($forcereg) &&
474: ($env{'request.noversionuri'} eq '/adm/navmaps') &&
475: ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
476: @crumbs = ({text => Apache::loncommon::course_type()
477: . ' Contents',
478: href => "Javascript:gopost('/adm/navmaps','')"});
479: }
480: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
481: push(@crumbs, {text => '...',
482: no_mt => 1});
483: }
484:
485: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
486: && $maptitle ne 'default.sequence'
487: && $maptitle ne $coursetitle);
1.268 droeschl 488:
1.393 raeburn 489: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
490: &Apache::lonhtmlcommon::clear_breadcrumbs();
491: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
492: } else {
493: $resurl = $env{'request.noversionuri'};
494: my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
495: my $crstype = &Apache::loncommon::course_type();
496: my $title = &mt('View Resource');
497: if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
498: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
1.392 raeburn 499: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.393 raeburn 500: if ($env{'form.title'}) {
501: $title = $env{'form.title'};
502: }
1.394 raeburn 503: my $trail;
1.393 raeburn 504: if ($env{'form.folderpath'}) {
1.399 raeburn 505: &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
1.394 raeburn 506: ($trail) =
1.393 raeburn 507: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
508: } else {
509: &Apache::lonhtmlcommon::add_breadcrumb(
1.392 raeburn 510: {text => "Supplemental $crstype Content",
511: href => "javascript:gopost('/adm/supplemental','')"});
1.393 raeburn 512: $title = &mt('View Resource');
1.394 raeburn 513: ($trail) =
514: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
1.392 raeburn 515: }
1.394 raeburn 516: return $trail;
1.392 raeburn 517: }
1.395 raeburn 518: unless ($env{'request.state'} eq 'construct') {
519: &Apache::lonhtmlcommon::clear_breadcrumbs();
520: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
521: }
1.392 raeburn 522: }
1.390 raeburn 523: } elsif (! $const_space){
1.328 droeschl 524: #a situation when we're looking at a resource outside of context of a
525: #course or construction space (e.g. with cumulative rights)
526: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.390 raeburn 527: unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
528: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
529: }
1.65 www 530: }
1.41 www 531: # =============================================================================
532: # ============================ This is for URLs that actually can be registered
1.316 droeschl 533: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
534: || $forcereg );
1.390 raeburn 535: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
536: $forceview,$editbutton);
1.391 raeburn 537: if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
538: ($env{'request.role'} !~/^(aa|ca|au)/)) {
1.390 raeburn 539: $editbutton = &prepare_functions($resurl,$forcereg,$group);
540: }
541: if ($editbutton eq '') {
1.399 raeburn 542: $editbutton = &clear(6,1);
1.390 raeburn 543: }
1.317 droeschl 544:
1.390 raeburn 545: #
546: # This applies in course context
547: #
548: if ($env{'request.course.id'}) {
549: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
550: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
551: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
552: my @privs;
553: if ($env{'request.symb'} ne '') {
554: if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
555: push(@privs,('mgr','vgr'));
556: }
557: push(@privs,'opa');
558: }
559: foreach my $priv (@privs) {
560: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
561: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
562: $perms{$priv} =
563: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
564: }
565: }
566: #
567: # Determine whether or not to show Grades and Submissions buttons
568: #
569: if ($env{'request.symb'} ne '' &&
570: $env{'request.filename'}=~/$LONCAPA::assess_re/) {
571: if ($perms{'mgr'}) {
572: &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
573: "gocmd('/adm/grades','gradingmenu')",
574: 'Content Grades');
575: } elsif ($perms{'vgr'}) {
576: &switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
577: "gocmd('/adm/grades','submission')",
578: 'Content Submissions');
579: }
580: }
581: if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
582: &switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
583: "gocmd('/adm/parmset','set')",
584: 'Content Settings');
1.107 albertel 585: }
1.393 raeburn 586: # End grades/submissions check
1.107 albertel 587:
1.274 www 588: #
1.393 raeburn 589: # This applies to items inside a folder/page modifiable in the course.
1.274 www 590: #
1.390 raeburn 591: if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
1.393 raeburn 592: my $text = 'Edit Folder';
1.395 raeburn 593: if (($mapurl =~ /\.page$/) ||
594: ($env{'request.symb'}=~
1.396 raeburn 595: m{uploaded/$cdom/$cnum/default_\d+\.page$})) {
1.393 raeburn 596: $text = 'Edit Page';
597: }
598: &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
1.390 raeburn 599: "gocmd('/adm/coursedocs','direct')",
600: 'Folder/Page Content');
1.258 raeburn 601: }
1.390 raeburn 602: # End modifiable folder/page container check
603: }
604: # End course context
605:
1.41 www 606: # Prepare the rest of the buttons
1.383 raeburn 607: my ($menuitems,$got_prt,$got_wishlist);
1.120 raeburn 608: if ($const_space) {
1.274 www 609: #
610: # We are in construction space
611: #
1.353 www 612:
1.355 raeburn 613: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 614: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 615: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.353 www 616: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 617: if ($currdir =~ m-/$-) {
618: $is_const_dir = 1;
619: } else {
1.267 droeschl 620: $currdir =~ s|[^/]+$||;
1.200 foxr 621: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 622: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 623: #
624: # Probably should be in mydesk.tab
625: #
1.131 raeburn 626: $menuitems=(<<ENDMENUITEMS);
1.344 www 627: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1.353 www 628: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
629: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
630: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
631: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 632: ENDMENUITEMS
1.131 raeburn 633: }
1.308 raeburn 634: if (ref($bread_crumbs) eq 'ARRAY') {
635: &Apache::lonhtmlcommon::clear_breadcrumbs();
636: foreach my $crumb (@{$bread_crumbs}){
637: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
638: }
639: }
1.203 foxr 640: } elsif ( defined($env{'request.course.id'}) &&
641: $env{'request.symb'} ne '' ) {
1.274 www 642: #
1.383 raeburn 643: # We are in a course and looking at a registered URL
1.274 www 644: # Should probably be in mydesk.tab
645: #
1.120 raeburn 646: $menuitems=(<<ENDMENUITEMS);
1.41 www 647: c&3&1
1.344 www 648: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
649: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
1.77 www 650: c&6&3
651: c&8&1
652: c&8&2
1.344 www 653: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 654: ENDMENUITEMS
1.383 raeburn 655: $got_prt = 1;
656: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
657: && (!$env{'request.enc'})) {
1.332 wenzelju 658: # wishlist is only available for users with access to resource-pool
659: # and links can only be set for resources within the resource-pool
660: $menuitems .= (<<ENDMENUITEMS);
1.370 raeburn 661: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
1.332 wenzelju 662: ENDMENUITEMS
1.383 raeburn 663: $got_wishlist = 1;
1.332 wenzelju 664: }
1.216 albertel 665:
1.243 tempelho 666: my $currentURL = &Apache::loncommon::get_symb();
667: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
668: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
669: $menuitems.="s&9&3&";
670: if(length($annotation) > 0){
1.317 droeschl 671: $menuitems.="anot2.png";
1.243 tempelho 672: }else{
1.317 droeschl 673: $menuitems.="anot.png";
1.243 tempelho 674: }
1.344 www 675: $menuitems.="&Notes&&annotate()&";
1.243 tempelho 676: $menuitems.="Make notes and annotations about this resource&&1\n";
677:
1.323 raeburn 678: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.382 raeburn 679: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
1.216 albertel 680: $menuitems.=(<<ENDREALRES);
1.344 www 681: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
1.216 albertel 682: ENDREALRES
683: }
1.382 raeburn 684: unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
685: $menuitems.=(<<ENDREALRES);
1.344 www 686: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.382 raeburn 687: ENDREALRES
688: }
689: $menuitems.=(<<ENDREALRES);
1.344 www 690: s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77 www 691: ENDREALRES
1.120 raeburn 692: }
693: }
1.203 foxr 694: if ($env{'request.uri'} =~ /^\/res/) {
1.383 raeburn 695: unless ($got_prt) {
696: $menuitems .= (<<ENDMENUITEMS);
1.344 www 697: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 698: ENDMENUITEMS
1.384 raeburn 699: $got_prt = 1;
1.383 raeburn 700: }
701: unless ($got_wishlist) {
702: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
703: # wishlist is only available for users with access to resource-pool
704: $menuitems .= (<<ENDMENUITEMS);
1.374 bisitz 705: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
1.332 wenzelju 706: ENDMENUITEMS
1.383 raeburn 707: $got_wishlist = 1;
708: }
709: }
710: }
1.41 www 711: my $buttons='';
712: foreach (split(/\n/,$menuitems)) {
713: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 714: my $idx=10*$rest[0]+$rest[1];
715: if (&hidden_button_check() eq 'yes') {
716: if ($idx == 21 ||$idx == 23) {
717: $buttons.=&switch('','',@rest);
718: } else {
719: $buttons.=&clear(@rest);
720: }
721: } else {
722: if ($command eq 's') {
723: $buttons.=&switch('','',@rest);
724: } else {
725: $buttons.=&clear(@rest);
726: }
1.41 www 727: }
728: }
1.148 albertel 729:
730: my $addremote=0;
1.267 droeschl 731: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.301 droeschl 732: if ($addremote) {
733:
1.342 www 734: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 735:
1.342 www 736: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.312 droeschl 737: 'navigation', @inlineremote[21,23]);
738:
1.378 raeburn 739: my $countdown = &countdown_timer();
740: if (&hidden_button_check() eq 'yes') {
741: if ($countdown) {
742: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
743: }
744: } else {
745: my @tools = @inlineremote[93,91,81,82,83];
746: if ($countdown) {
747: unshift(@tools,$countdown);
748: }
1.342 www 749: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.378 raeburn 750: 'tools',@tools);
1.313 droeschl 751:
752: #publish button in construction space
753: if ($env{'request.state'} eq 'construct'){
1.342 www 754: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 755: 'advtools', $inlineremote[63]);
1.342 www 756: } else {
757: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 758: 'tools', $inlineremote[63]);
1.313 droeschl 759: }
1.390 raeburn 760: &advtools_crumbs(@inlineremote);
1.301 droeschl 761: }
1.38 www 762: }
763:
1.342 www 764: return &Apache::lonhtmlcommon::scripttag('', 'start')
765: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
766: . &Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 767: }
768:
1.389 raeburn 769: sub get_editbutton {
1.390 raeburn 770: my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
1.398 raeburn 771: my $jscall;
772: if (($forceview) && ($env{'form.todocs'})) {
773: my ($folderpath,$command);
774: if ($env{'request.symb'}) {
775: $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
776: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
777: $folderpath = $env{'form.folderpath'};
778: $command = '&forcesupplement=1';
779: }
780: $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
781: $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
782: } else {
783: $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
1.393 raeburn 784: $forceedit,$forcereg,$env{'request.symb'},
785: &escape($env{'form.folderpath'}),
786: &escape($env{'form.title'}),$env{'form.idx'},
1.398 raeburn 787: &escape($env{'form.suppurl'},$env{'form.todocs'}));
788: }
1.389 raeburn 789: if ($jscall) {
1.390 raeburn 790: my $icon = 'pcstr.png';
791: my $label = 'Edit';
792: if ($forceview) {
793: $icon = 'tolastloc.png';
794: $label = 'Exit Editing';
795: }
796: &switch('','',6,1,$icon,$label,'resource[_2]',
797: $jscall,"Edit this resource");
798: return 1;
799: }
800: return;
801: }
802:
803: sub prepare_functions {
1.393 raeburn 804: my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
1.390 raeburn 805: unless ($env{'request.registered'}) {
806: undef(@inlineremote);
807: }
808: my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
809: $forceview);
810:
811: if ($env{'request.course.id'}) {
812: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
813: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
814: $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
815: }
816:
817: my $editbutton = '';
818: #
819: # Determine whether or not to display 'Edit' icon/button
820: #
821: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
822: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.391 raeburn 823: ($cfile,$home,$switchserver,$forceedit,$forceview) =
824: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
825: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
826: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
827: $editbutton = &get_editbutton($cfile,$home,$switchserver,
1.390 raeburn 828: $forceedit,$forceview,$forcereg);
829: }
1.391 raeburn 830: } elsif ((!$env{'request.course.id'}) &&
1.390 raeburn 831: ($env{'user.author'}) && ($env{'request.filename'}) &&
832: ($env{'request.role'} !~/^(aa|ca|au)/)) {
833: #
834: # Currently do not have the role of author or co-author.
835: # Do we have authoring privileges for the resource?
836: #
837: my $file=&Apache::lonnet::declutter($env{'request.filename'});
838: ($cfile,$home,$switchserver,$forceedit,$forceview) =
839: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
840: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
841: if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
842: $editbutton = &get_editbutton($cfile,$home,$switchserver,
843: $forceedit,$forceview,$forcereg);
844: }
845: } elsif ($env{'request.course.id'}) {
846: #
847: # This applies in course context
848: #
849: if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) {
1.411 ! raeburn 850: $cfile = $resurl;
! 851: $home = &Apache::lonnet::homeserver($cnum,$cdom);
! 852: if ($env{'form.forceedit'}) {
! 853: $forceview = 1;
1.390 raeburn 854: } else {
1.411 ! raeburn 855: $forceedit = 1;
1.390 raeburn 856: }
1.411 ! raeburn 857: $editbutton = &get_editbutton($cfile,$home,$switchserver,
! 858: $forceedit,$forceview,$forcereg);
1.393 raeburn 859: } elsif (($resurl eq '/adm/extresedit') &&
860: (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
861: ($cfile,$home,$switchserver,$forceedit,$forceview) =
862: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
863: $env{'form.symb'});
864: if ($cfile ne '') {
865: $editbutton = &get_editbutton($cfile,$home,$switchserver,
866: $forceedit,$forceview,$forcereg,
867: $env{'form.title'},$env{'form.suppurl'});
868: }
1.406 raeburn 869: } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
870: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
871: ($cfile,$home,$switchserver,$forceedit,$forceview) =
872: &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
873: $env{'form.symb'});
874: $editbutton = &get_editbutton($cfile,$home,$switchserver,
875: $forceedit,$forceview,$forcereg);
1.405 raeburn 876: } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
877: ($resurl ne '/cgi-bin/printout.pl')) {
1.390 raeburn 878: if ($env{'request.filename'}) {
879: my $file=&Apache::lonnet::declutter($env{'request.filename'});
880: ($cfile,$home,$switchserver,$forceedit,$forceview) =
881: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
882: &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
883: if ($cfile ne '') {
884: $editbutton = &get_editbutton($cfile,$home,$switchserver,
885: $forceedit,$forceview,$forcereg);
886: }
887: }
888: }
889: }
890: # End determination of 'Edit' icon/button display
891:
1.393 raeburn 892: if ($env{'request.course.id'}) {
1.390 raeburn 893: # This applies to about me page for users in a course
1.391 raeburn 894: if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
1.390 raeburn 895: my ($sdom,$sname) = ($1,$2);
896: unless (&Apache::lonnet::is_course($sdom,$sname)) {
897: &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
898: '',
899: "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
900: 'Send message to specific user');
901: }
1.391 raeburn 902: my $hideprivileged = 1;
903: if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
904: $hideprivileged)) {
1.390 raeburn 905: foreach my $priv ('vsa','vgr','srm') {
906: $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
907: if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
908: $perms{$priv} =
909: &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
910: }
911: }
912: if ($perms{'vsa'}) {
913: &switch('','',6,5,'trck-22x22.png','Activity',
914: '',
915: "go('/adm/trackstudent?selected_student=$sname:$sdom')",
916: 'View recent activity by this person');
917: }
918: if ($perms{'vgr'}) {
919: &switch('','',6,6,'rsrv-22x22.png','Reservations',
920: '',
921: "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
922: 'Slot reservation history');
923: }
924: if ($perms{'srm'}) {
925: &switch('','',6,7,'contact-new-22x22.png','Records',
926: '',
927: "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
928: 'Add records');
929: }
930: }
1.393 raeburn 931: }
932: if (($env{'form.folderpath'} =~ /^supplemental/) &&
933: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
934: (($resurl =~ m{^/adm/wrapper/ext/}) ||
935: ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
1.397 raeburn 936: ($resurl eq '/adm/supplemental') ||
937: ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
938: ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
1.393 raeburn 939: my @folders=split('&',$env{'form.folderpath'});
1.394 raeburn 940: if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
1.393 raeburn 941: my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
942: &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
943: "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
944: 'Folder/Page Content');
945: }
1.390 raeburn 946: }
947: }
948:
949: # End checking for items for about me page for users in a course
1.393 raeburn 950: if ($docscrumbs) {
951: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
952: &advtools_crumbs(@inlineremote);
953: return $editbutton;
954: } elsif ($env{'request.registered'}) {
1.390 raeburn 955: return $editbutton;
956: } else {
957: if (ref($bread_crumbs) eq 'ARRAY') {
958: if (@inlineremote > 0) {
959: if (ref($advtools) eq 'ARRAY') {
960: @{$advtools} = @inlineremote;
961: }
962: }
963: return;
964: } elsif (@inlineremote > 0) {
965: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
966: &advtools_crumbs(@inlineremote);
967: return &Apache::lonhtmlcommon::scripttag('', 'start')
968: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
969: . &Apache::lonhtmlcommon::scripttag('', 'end');
970: }
971: }
972: }
973:
974: sub advtools_crumbs {
975: my @funcs = @_;
976: if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
977: &Apache::lonhtmlcommon::add_breadcrumb_tool(
978: 'advtools', @funcs[61,64,65,66,67,74]);
979: } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
980: &Apache::lonhtmlcommon::add_breadcrumb_tool(
981: 'advtools', @funcs[61,71,72,73,74,92]);
1.393 raeburn 982: } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
983: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.407 raeburn 984: 'advtools', $funcs[61]);
1.393 raeburn 985: }
1.258 raeburn 986: }
987:
1.2 www 988: # ================================================================== Raw Config
989:
1.3 www 990: sub clear {
991: my ($row,$col)=@_;
1.316 droeschl 992: $inlineremote[10*$row+$col]='';
993: return '';
1.3 www 994: }
995:
1.40 www 996: # ============================================ Switch a button or create a link
1.25 matthew 997: # Switch acts on the javascript that is executed when a button is clicked.
998: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 999:
1.2 www 1000: sub switch {
1.209 www 1001: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1002: $act=~s/\$uname/$uname/g;
1003: $act=~s/\$udom/$udom/g;
1.88 www 1004: $top=&mt($top);
1005: $bot=&mt($bot);
1006: $desc=&mt($desc);
1.209 www 1007: my $idx=10*$row+$col;
1008: $category_members{$cat}.=':'.$idx;
1009:
1.320 droeschl 1010: # Inline Menu
1.317 droeschl 1011: if ($nobreak==2) { return ''; }
1012: my $text=$top.' '.$bot;
1013: $text=~s/\s*\-\s*//gs;
1.105 www 1014:
1.317 droeschl 1015: my $pic=
1.225 albertel 1016: '<img alt="'.$text.'" src="'.
1017: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1018: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 1019: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1020: # Main Menu
1.103 www 1021: if ($nobreak==3) {
1.209 www 1022: $inlineremote[$idx]="\n".
1.177 albertel 1023: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1024: '</td><td align="left">'.
1.103 www 1025: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1026: } elsif ($nobreak) {
1.209 www 1027: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1028: '<td align="left">'.
1.177 albertel 1029: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1030: <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 1031: } else {
1.209 www 1032: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1033: '<td align="left">'.
1.103 www 1034: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1035: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1036: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1037: }
1.317 droeschl 1038: } else {
1.103 www 1039: # Inline Menu
1.378 raeburn 1040: my @tools = (93,91,81,82,83);
1041: unless ($env{'request.state'} eq 'construct') {
1042: push(@tools,63);
1043: }
1044: if (($env{'environment.icons'} eq 'iconsonly') &&
1045: (grep(/^$idx$/,@tools))) {
1046: $inlineremote[$idx] =
1047: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
1048: } else {
1049: $inlineremote[$idx] =
1.317 droeschl 1050: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.344 www 1051: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1.378 raeburn 1052: }
1.317 droeschl 1053: }
1.56 www 1054: return '';
1.2 www 1055: }
1056:
1057: sub secondlevel {
1058: my $output='';
1059: my
1.209 www 1060: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1061: if ($prt eq 'any') {
1.209 www 1062: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1063: } elsif ($prt=~/^r(\w+)/) {
1064: if ($rol eq $1) {
1.209 www 1065: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1066: }
1067: }
1068: return $output;
1069: }
1070:
1.56 www 1071: sub inlinemenu {
1.210 albertel 1072: undef(@inlineremote);
1073: undef(%category_members);
1.275 www 1074: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1075: &rawconfig(1);
1.309 bisitz 1076: my $output='<table><tr>';
1.209 www 1077: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1078: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1079: for (my $row=1; $row<=8; $row++) {
1080: foreach my $cat (keys(%category_members)) {
1081: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1082: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1083: $output.='<div class="LC_Box LC_400Box">';
1084: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1085: $output.='<table>';
1.240 riegler 1086: my %active=();
1087: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1088: if ($inlineremote[$menu_item]) {
1089: $active{$menu_item}=1;
1090: }
1091: }
1092: foreach my $item (sort(keys(%active))) {
1093: $output.=$inlineremote[$item];
1094: }
1095: $output.='</table>';
1.245 harmsja 1096: $output.='</div>';
1.240 riegler 1097: }
1098: }
1099: $output.="</td>";
1100: }
1101: $output.="</tr></table>";
1102: return $output;
1103: }
1104:
1.2 www 1105: sub rawconfig {
1.274 www 1106: #
1107: # This evaluates mydesk.tab
1108: # Need to add more positions and more privileges to deal with all
1109: # menu items.
1110: #
1.34 www 1111: my $textualoverride=shift;
1112: my $output='';
1.316 droeschl 1113: return '' unless $textualoverride;
1.152 albertel 1114: my $uname=$env{'user.name'};
1115: my $udom=$env{'user.domain'};
1116: my $adv=$env{'user.adv'};
1.266 raeburn 1117: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1118: my $author=$env{'user.author'};
1.5 www 1119: my $crs='';
1.295 raeburn 1120: my $crstype='';
1.152 albertel 1121: if ($env{'request.course.id'}) {
1122: $crs='/'.$env{'request.course.id'};
1123: if ($env{'request.course.sec'}) {
1124: $crs.='_'.$env{'request.course.sec'};
1.7 www 1125: }
1.8 www 1126: $crs=~s/\_/\//g;
1.295 raeburn 1127: $crstype = &Apache::loncommon::course_type();
1.5 www 1128: }
1.152 albertel 1129: my $pub=($env{'request.state'} eq 'published');
1130: my $con=($env{'request.state'} eq 'construct');
1131: my $rol=$env{'request.role'};
1132: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1133: foreach my $line (@desklines) {
1.209 www 1134: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1135: $prt=~s/\$uname/$uname/g;
1136: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1137: if ($prt =~ /\$crs/) {
1138: next unless ($env{'request.course.id'});
1139: next if ($crstype eq 'Community');
1140: $prt=~s/\$crs/$crs/g;
1141: } elsif ($prt =~ /\$cmty/) {
1142: next unless ($env{'request.course.id'});
1143: next if ($crstype ne 'Community');
1144: $prt=~s/\$cmty/$crs/g;
1145: }
1.25 matthew 1146: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1147: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1148: if ($pro eq 'clear') {
1.4 www 1149: $output.=&clear($row,$col);
1.3 www 1150: } elsif ($pro eq 'any') {
1.2 www 1151: $output.=&secondlevel(
1.209 www 1152: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1153: } elsif ($pro eq 'smp') {
1154: unless ($adv) {
1155: $output.=&secondlevel(
1.209 www 1156: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1157: }
1158: } elsif ($pro eq 'adv') {
1159: if ($adv) {
1160: $output.=&secondlevel(
1.209 www 1161: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1162: }
1.231 albertel 1163: } elsif ($pro eq 'shc') {
1164: if ($show_course) {
1165: $output.=&secondlevel(
1166: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1167: }
1168: } elsif ($pro eq 'nsc') {
1169: if (!$show_course) {
1170: $output.=&secondlevel(
1171: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1172: }
1.81 matthew 1173: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1174: my $priv = $1;
1175: if ($priv =~ /^mdc(Course|Community)/) {
1176: if ($crstype eq $1) {
1177: $priv = 'mdc';
1178: } else {
1179: next;
1180: }
1181: }
1182: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1183: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1184: }
1.295 raeburn 1185: } elsif ($pro eq 'course') {
1186: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1187: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1188: }
1.295 raeburn 1189: } elsif ($pro eq 'community') {
1190: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1191: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1192: }
1.124 matthew 1193: } elsif ($pro =~ /^courseenv_(.*)$/) {
1194: my $key = $1;
1.307 raeburn 1195: if ($crstype ne 'Community') {
1196: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1197: if ($key eq 'canuse_pdfforms') {
1198: if ($env{'request.course.id'} && $coursepref eq '') {
1199: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1200: $coursepref = $domdefs{'canuse_pdfforms'};
1201: }
1202: }
1203: if ($coursepref) {
1204: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1205: }
1.295 raeburn 1206: }
1207: } elsif ($pro =~ /^communityenv_(.*)$/) {
1208: my $key = $1;
1.307 raeburn 1209: if ($crstype eq 'Community') {
1210: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1211: if ($key eq 'canuse_pdfforms') {
1212: if ($env{'request.course.id'} && $coursepref eq '') {
1213: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1214: $coursepref = $domdefs{'canuse_pdfforms'};
1215: }
1216: }
1217: if ($coursepref) {
1218: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1219: }
1.124 matthew 1220: }
1.81 matthew 1221: } elsif ($pro =~ /^course_(.*)$/) {
1222: # Check for permissions inside of a course
1.295 raeburn 1223: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1224: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1225: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1226: )) {
1.209 www 1227: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1228: }
1.295 raeburn 1229: } elsif ($pro =~ /^community_(.*)$/) {
1230: # Check for permissions inside of a community
1231: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1232: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1233: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1234: )) {
1235: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1236: }
1.4 www 1237: } elsif ($pro eq 'author') {
1238: if ($author) {
1.152 albertel 1239: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1240: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1241: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1242: # Check that we are on the correct machine
1.29 matthew 1243: my $cadom=$requested_domain;
1.152 albertel 1244: my $caname=$env{'user.name'};
1.234 raeburn 1245: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1246: ($cadom,$caname)=
1.206 albertel 1247: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1248: }
1249: $act =~ s/\$caname/$caname/g;
1.353 www 1250: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 1251: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1252: my $allowed=0;
1253: my @ids=&Apache::lonnet::current_machine_ids();
1254: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1255: if ($allowed) {
1.209 www 1256: $output.=&switch($caname,$cadom,
1257: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1258: }
1.6 www 1259: }
1.2 www 1260: }
1.248 raeburn 1261: } elsif ($pro eq 'tools') {
1262: my @tools = ('aboutme','blog','portfolio');
1263: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1264: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1265: $env{'user.domain'},
1266: $prt,undef,'tools')) {
1267: $output.=&clear($row,$col);
1268: next;
1269: }
1.278 raeburn 1270: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1271: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1272: next;
1273: }
1274: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1275: next;
1276: }
1.279 raeburn 1277: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1278: if (!$showreqcrs) {
1.248 raeburn 1279: $output.=&clear($row,$col);
1280: next;
1281: }
1282: }
1283: $prt='any';
1284: $output.=&secondlevel(
1285: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1286: }
1.13 harris41 1287: }
1.2 www 1288: return $output;
1289: }
1290:
1.279 raeburn 1291: sub check_for_rcrs {
1292: my $showreqcrs = 0;
1.280 raeburn 1293: my @reqtypes = ('official','unofficial','community');
1294: foreach my $type (@reqtypes) {
1.279 raeburn 1295: if (&Apache::lonnet::usertools_access($env{'user.name'},
1296: $env{'user.domain'},
1297: $type,undef,'requestcourses')) {
1298: $showreqcrs = 1;
1299: last;
1300: }
1301: }
1.280 raeburn 1302: if (!$showreqcrs) {
1303: foreach my $type (@reqtypes) {
1304: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1305: $showreqcrs = 1;
1306: last;
1307: }
1308: }
1309: }
1.279 raeburn 1310: return $showreqcrs;
1311: }
1312:
1.306 raeburn 1313: sub dc_popup_js {
1314: my %lt = &Apache::lonlocal::texthash(
1315: more => '(More ...)',
1316: less => '(Less ...)',
1317: );
1318: return <<"END";
1319:
1320: function showCourseID() {
1321: document.getElementById('dccid').style.display='block';
1322: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1323: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 1324: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 1325: return;
1326: }
1327:
1328: function hideCourseID() {
1329: document.getElementById('dccid').style.display='none';
1.369 raeburn 1330: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 1331: return;
1332: }
1333:
1334: END
1335:
1336: }
1337:
1.378 raeburn 1338: sub countdown_toggle_js {
1339: return <<"END";
1340:
1341: function toggleCountdown() {
1342: var countdownid = document.getElementById('duedatecountdown');
1343: var currstyle = countdownid.style.display;
1344: if (currstyle == 'inline') {
1345: countdownid.style.display = 'none';
1346: document.getElementById('ddcountcollapse').innerHTML='';
1347: document.getElementById('ddcountexpand').innerHTML='◄ ';
1348: } else {
1349: countdownid.style.display = 'inline';
1350: document.getElementById('ddcountcollapse').innerHTML='► ';
1351: document.getElementById('ddcountexpand').innerHTML='';
1352: }
1353: return;
1354: }
1355:
1356: END
1357: }
1358:
1.42 www 1359: sub utilityfunctions {
1.152 albertel 1360: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 droeschl 1361: if ($currenturl =~ m{^/adm/wrapper/ext/}
1362: && $env{'request.external.querystring'} ) {
1.293 raeburn 1363: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1364: }
1.183 www 1365: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1366:
1.152 albertel 1367: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.175 albertel 1368:
1.306 raeburn 1369: my $dc_popup_cid;
1370: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1371: $env{'course.'.$env{'request.course.id'}.
1372: '.domain'}.'/'})) {
1373: $dc_popup_cid = &dc_popup_js();
1374: }
1375:
1.175 albertel 1376: my $start_page_annotate =
1377: &Apache::loncommon::start_page('Annotator',undef,
1378: {'only_body' => 1,
1379: 'js_ready' => 1,
1380: 'bgcolor' => '#BBBBBB',
1381: 'add_entries' => {
1382: 'onload' => 'javascript:document.goannotate.submit();'}});
1383:
1.205 albertel 1384: my $end_page_annotate =
1385: &Apache::loncommon::end_page({'js_ready' => 1});
1386:
1.389 raeburn 1387: my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
1.336 raeburn 1388:
1.368 www 1389: my $esc_url=&escape($currenturl);
1390: my $esc_symb=&escape($currentsymb);
1.332 wenzelju 1391:
1.378 raeburn 1392: my $countdown = &countdown_toggle_js();
1393:
1.42 www 1394: return (<<ENDUTILITY)
1395:
1.368 www 1396: var currentURL=unescape("$esc_url");
1397: var reloadURL=unescape("$esc_url");
1398: var currentSymb=unescape("$esc_symb");
1.42 www 1399:
1.306 raeburn 1400: $dc_popup_cid
1.114 albertel 1401:
1.389 raeburn 1402: $jumptores
1.336 raeburn 1403:
1.42 www 1404: function gopost(url,postdata) {
1405: if (url!='') {
1406: this.document.server.action=url;
1407: this.document.server.postdata.value=postdata;
1408: this.document.server.command.value='';
1409: this.document.server.url.value='';
1410: this.document.server.symb.value='';
1411: this.document.server.submit();
1412: }
1413: }
1414:
1415: function gocmd(url,cmd) {
1416: if (url!='') {
1417: this.document.server.action=url;
1418: this.document.server.postdata.value='';
1419: this.document.server.command.value=cmd;
1420: this.document.server.url.value=currentURL;
1421: this.document.server.symb.value=currentSymb;
1422: this.document.server.submit();
1423: }
1.57 www 1424: }
1425:
1.121 raeburn 1426: function gocstr(url,filename) {
1427: if (url == '/adm/cfile?action=delete') {
1428: this.document.cstrdelete.filename.value = filename
1429: this.document.cstrdelete.submit();
1430: return;
1431: }
1.137 raeburn 1432: if (url == '/adm/printout') {
1433: this.document.cstrprint.postdata.value = filename
1434: this.document.cstrprint.curseed.value = 0;
1435: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1436: if (this.document.lonhomework) {
1437: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1438: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1439: }
1440: if (this.document.lonhomework.problemtype) {
1.164 albertel 1441: if (this.document.lonhomework.problemtype.value) {
1442: this.document.cstrprint.problemtype.value =
1443: this.document.lonhomework.problemtype.value;
1444: } else if (this.document.lonhomework.problemtype.options) {
1445: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1446: if (this.document.lonhomework.problemtype.options[i].selected) {
1447: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1448: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1449: }
1450: }
1451: }
1452: }
1453: }
1454: }
1.137 raeburn 1455: this.document.cstrprint.submit();
1456: return;
1457: }
1.121 raeburn 1458: if (url !='') {
1459: this.document.constspace.filename.value = filename;
1460: this.document.constspace.action = url;
1461: this.document.constspace.submit();
1462: }
1463: }
1464:
1.131 raeburn 1465: function golist(url) {
1466: if (url!='' && url!= null) {
1467: currentURL = null;
1468: currentSymb= null;
1469: top.location.href=url;
1470: }
1471: }
1472:
1473:
1.121 raeburn 1474:
1.57 www 1475: function catalog_info() {
1.365 www 1476: openMyModal(window.location.pathname+'.meta',500,400,'yes');
1.57 www 1477: }
1478:
1479: function chat_win() {
1.290 raeburn 1480: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1481: }
1.169 raeburn 1482:
1483: function group_chat(group) {
1484: var url = '/adm/groupchat?group='+group;
1485: var winName = 'LONchat_'+group;
1486: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1487: }
1.175 albertel 1488:
1489: function annotate() {
1490: w_Annotator_flag=1;
1491: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1492: annotator.document.write(
1493: '$start_page_annotate'
1494: +"<form name='goannotate' target='Annotator' method='post' "
1495: +"action='/adm/annotations'>"
1.217 albertel 1496: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1497: +"<\\/form>"
1.205 albertel 1498: +'$end_page_annotate');
1.175 albertel 1499: annotator.document.close();
1500: }
1501:
1.370 raeburn 1502: function open_StoredLinks_Import(rat) {
1.335 wenzelju 1503: var newWin;
1504: if (rat) {
1505: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1.334 wenzelju 1506: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1.335 wenzelju 1507: }
1508: else {
1509: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
1510: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1511: }
1.334 wenzelju 1512: newWin.focus();
1513: }
1514:
1.372 raeburn 1515: (function (\$) {
1516: \$(document).ready(function () {
1517: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
1518: /*\@cc_on
1519: if (!window.XMLHttpRequest) {
1520: \$('.LC_hoverable').each(function () {
1521: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
1522: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
1523: });
1524: }
1525: \@*/
1526: });
1527: }(jQuery));
1528:
1.378 raeburn 1529: $countdown
1530:
1.42 www 1531: ENDUTILITY
1532: }
1533:
1534: sub serverform {
1535: return(<<ENDSERVERFORM);
1.181 albertel 1536: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1537: <input type="hidden" name="postdata" value="none" />
1538: <input type="hidden" name="command" value="none" />
1539: <input type="hidden" name="url" value="none" />
1540: <input type="hidden" name="symb" value="none" />
1541: </form>
1542: ENDSERVERFORM
1543: }
1.113 albertel 1544:
1.121 raeburn 1545: sub constspaceform {
1546: return(<<ENDCONSTSPACEFORM);
1.181 albertel 1547: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 1548: <input type="hidden" name="filename" value="" />
1549: </form>
1.181 albertel 1550: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 1551: <input type="hidden" name="action" value="delete" />
1552: <input type="hidden" name="filename" value="" />
1553: </form>
1.181 albertel 1554: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 1555: <input type="hidden" name="postdata" value="" />
1556: <input type="hidden" name="curseed" value="" />
1557: <input type="hidden" name="problemtype" value="" />
1558: </form>
1559:
1.121 raeburn 1560: ENDCONSTSPACEFORM
1561: }
1562:
1.220 raeburn 1563: sub hidden_button_check {
1.317 droeschl 1564: if ( $env{'request.course.id'} eq ''
1565: || $env{'request.role.adv'} ) {
1566:
1.220 raeburn 1567: return;
1568: }
1.232 raeburn 1569: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1570: return $buttonshide;
1.220 raeburn 1571: }
1.184 raeburn 1572:
1.235 raeburn 1573: sub roles_selector {
1574: my ($cdom,$cnum) = @_;
1.298 raeburn 1575: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 1576: my $now = time;
1.350 raeburn 1577: my (%courseroles,%seccount,%courseprivs);
1.235 raeburn 1578: my $is_cc;
1.401 raeburn 1579: my ($js,$form,$switcher,$switchtext);
1.298 raeburn 1580: my $ccrole;
1581: if ($crstype eq 'Community') {
1582: $ccrole = 'co';
1583: } else {
1584: $ccrole = 'cc';
1.350 raeburn 1585: }
1.386 raeburn 1586: my ($priv,$gotsymb,$destsymb);
1.350 raeburn 1587: my $destinationurl = $ENV{'REQUEST_URI'};
1.386 raeburn 1588: if ($destinationurl =~ /\?symb=/) {
1589: $gotsymb = 1;
1590: } elsif ($destinationurl =~ m{^/enc/}) {
1591: my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
1592: if ($plainurl =~ /\?symb=/) {
1593: $gotsymb = 1;
1594: }
1595: }
1596: unless ($gotsymb) {
1597: $destsymb = &Apache::lonnet::symbread();
1598: if ($destsymb ne '') {
1599: $destsymb = &Apache::lonenc::check_encrypt($destsymb);
1600: }
1601: }
1.350 raeburn 1602: my $reqprivs = &required_privs();
1603: if (ref($reqprivs) eq 'HASH') {
1604: my $destination = $destinationurl;
1605: $destination =~ s/(\?.*)$//;
1606: if (exists($reqprivs->{$destination})) {
1607: $priv = $reqprivs->{$destination};
1608: }
1609: }
1.298 raeburn 1610: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1611: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 1612:
1613: if ((($start) && ($start<0)) ||
1614: (($end) && ($end<$now)) ||
1615: (($start) && ($now<$start))) {
1616: $is_cc = 0;
1617: } else {
1618: $is_cc = 1;
1619: }
1620: }
1621: if ($is_cc) {
1.350 raeburn 1622: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
1.235 raeburn 1623: } else {
1.262 raeburn 1624: my %gotnosection;
1.235 raeburn 1625: foreach my $item (keys(%env)) {
1.239 raeburn 1626: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 1627: my $role = $1;
1628: my $sec = $2;
1629: next if ($role eq 'gr');
1630: my ($start,$end) = split(/\./,$env{$item});
1631: next if (($start && $start > $now) || ($end && $end < $now));
1632: if ($sec eq '') {
1.239 raeburn 1633: if (!$gotnosection{$role}) {
1634: $seccount{$role} ++;
1635: $gotnosection{$role} = 1;
1636: }
1.235 raeburn 1637: }
1.350 raeburn 1638: if ($priv ne '') {
1639: my $cnumsec = $cnum;
1640: if ($sec ne '') {
1641: $cnumsec .= "/$sec";
1642: }
1643: $courseprivs{"$role./$cdom/$cnumsec./"} =
1644: $env{"user.priv.$role./$cdom/$cnumsec./"};
1645: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
1646: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
1647: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
1648: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
1649: }
1.235 raeburn 1650: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 1651: if ($sec ne '') {
1.264 raeburn 1652: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 1653: push(@{$courseroles{$role}},$sec);
1654: $seccount{$role} ++;
1655: }
1656: }
1657: } else {
1658: @{$courseroles{$role}} = ();
1659: if ($sec ne '') {
1660: $seccount{$role} ++;
1.235 raeburn 1661: push(@{$courseroles{$role}},$sec);
1662: }
1663: }
1664: }
1665: }
1666: }
1.409 raeburn 1667: $switchtext = &mt('Switch role');
1.298 raeburn 1668: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.402 raeburn 1669: my $numdiffsec;
1670: if (keys(%seccount) == 1) {
1671: foreach my $key (keys(%seccount)) {
1672: $numdiffsec = $seccount{$key};
1673: }
1674: }
1675: if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
1.401 raeburn 1676: my @submenu;
1677: $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
1678: $form =
1679: '<form name="rolechooser" method="post" action="/adm/roles">'."\n".
1680: ' <input type="hidden" name="destinationurl" value="'.
1681: &HTML::Entities::encode($destinationurl).'" />'."\n".
1682: ' <input type="hidden" name="gotorole" value="1" />'."\n".
1683: ' <input type="hidden" name="selectrole" value="" />'."\n".
1.402 raeburn 1684: ' <input type="hidden" name="switchrole" value="" />'."\n";
1685: if ($destsymb ne '') {
1686: $form .= ' <input type="hidden" name="destsymb" value="'.
1687: &HTML::Entities::encode($destsymb).'" />'."\n";
1688: }
1689: $form .= '</form>'."\n";
1.235 raeburn 1690: foreach my $role (@roles_order) {
1.402 raeburn 1691: my $include;
1.235 raeburn 1692: if (defined($courseroles{$role})) {
1.402 raeburn 1693: if ($env{'request.role'} =~ m{^\Q$role\E}) {
1694: if ($seccount{$role} > 1) {
1695: $include = 1;
1696: }
1697: } else {
1698: $include = 1;
1699: }
1700: }
1701: if ($include) {
1.401 raeburn 1702: push(@submenu,['javascript:adhocRole('."'$role'".')',
1703: &Apache::lonnet::plaintext($role,$crstype)]);
1.235 raeburn 1704: }
1705: }
1706: foreach my $role (sort(keys(%courseroles))) {
1707: if ($role =~ /^cr/) {
1.403 raeburn 1708: my $include;
1709: if ($env{'request.role'} =~ m{^\Q$role\E}) {
1.402 raeburn 1710: if ($seccount{$role} > 1) {
1711: $include = 1;
1712: }
1.403 raeburn 1713: } else {
1714: $include = 1;
1715: }
1716: if ($include) {
1717: push(@submenu,['javascript:adhocRole('."'$role'".')',
1718: &Apache::lonnet::plaintext($role)]);
1719: }
1.235 raeburn 1720: }
1721: }
1.401 raeburn 1722: if (@submenu > 0) {
1723: $switcher = &create_submenu('','',$switchtext,\@submenu);
1.386 raeburn 1724: }
1.235 raeburn 1725: }
1.401 raeburn 1726: return ($js,$form,$switcher);
1.235 raeburn 1727: }
1728:
1.262 raeburn 1729: sub get_all_courseroles {
1.350 raeburn 1730: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 1731: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 1732: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 1733: return;
1734: }
1735: my ($result,$cached) =
1736: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1737: if (defined($cached)) {
1738: if (ref($result) eq 'HASH') {
1739: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 1740: (ref($result->{'seccount'}) eq 'HASH') &&
1741: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 1742: %{$courseroles} = %{$result->{'roles'}};
1743: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 1744: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 1745: return;
1746: }
1747: }
1748: }
1749: my %gotnosection;
1750: my %adv_roles =
1751: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1752: foreach my $role (keys(%adv_roles)) {
1753: my ($urole,$usec) = split(/:/,$role);
1754: if (!$gotnosection{$urole}) {
1755: $seccount->{$urole} ++;
1756: $gotnosection{$urole} = 1;
1757: }
1758: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1759: if ($usec ne '') {
1760: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1761: push(@{$courseroles->{$urole}},$usec);
1762: $seccount->{$urole} ++;
1763: }
1764: }
1765: } else {
1766: @{$courseroles->{$urole}} = ();
1767: if ($usec ne '') {
1768: $seccount->{$urole} ++;
1769: push(@{$courseroles->{$urole}},$usec);
1770: }
1771: }
1.350 raeburn 1772: my $area = '/'.$cdom.'/'.$cnum;
1773: if ($usec ne '') {
1774: $area .= '/'.$usec;
1775: }
1776: if ($role =~ /^cr\//) {
1777: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
1778: } else {
1779: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
1780: }
1.262 raeburn 1781: }
1782: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1783: @{$courseroles->{'st'}} = ();
1.350 raeburn 1784: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 1785: if (keys(%sections_count) > 0) {
1786: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 1787: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 1788: }
1.410 raeburn 1789: $seccount->{'st'} ++; # Increment for a section-less student role.
1.262 raeburn 1790: my $rolehash = {
1791: 'roles' => $courseroles,
1792: 'seccount' => $seccount,
1.350 raeburn 1793: 'privs' => $courseprivs,
1.262 raeburn 1794: };
1795: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1796: return;
1797: }
1798:
1.235 raeburn 1799: sub jump_to_role {
1.350 raeburn 1800: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
1.239 raeburn 1801: my %lt = &Apache::lonlocal::texthash(
1802: this => 'This role has section(s) associated with it.',
1803: ente => 'Enter a specific section.',
1804: orlb => 'Enter a specific section, or leave blank for no section.',
1805: avai => 'Available sections are:',
1806: youe => 'You entered an invalid section choice:',
1.352 raeburn 1807: plst => 'Please try again.',
1.350 raeburn 1808: role => 'The role you selected is not permitted to view the current page.',
1809: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 1810: );
1811: my $js;
1812: if (ref($courseroles) eq 'HASH') {
1813: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1814: ' var numsec = new Array();'."\n".
1815: ' var rolesections = new Array();'."\n".
1816: ' var rolenames = new Array();'."\n".
1817: ' var roleseclist = new Array();'."\n";
1818: my @items = keys(%{$courseroles});
1819: for (my $i=0; $i<@items; $i++) {
1820: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1821: my ($secs,$secstr);
1822: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1823: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1824: $secs = join('","',@sections);
1825: $secstr = join(', ',@sections);
1826: }
1827: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1828: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1829: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1830: }
1831: }
1.350 raeburn 1832: my $checkroles = 0;
1833: if ($priv && ref($courseprivs) eq 'HASH') {
1834: my (%disallowed,%allowed,@disallow);
1835: foreach my $role (sort(keys(%{$courseprivs}))) {
1836: my $trole;
1837: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
1838: $trole = $1;
1839: }
1840: if (($trole ne '') && ($trole ne 'cm')) {
1841: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
1842: $allowed{$trole} = 1;
1843: } else {
1844: $disallowed{$trole} = 1;
1845: }
1846: }
1847: }
1848: foreach my $trole (keys(%disallowed)) {
1849: unless ($allowed{$trole}) {
1850: push(@disallow,$trole);
1851: }
1852: }
1853: if (@disallow > 0) {
1854: $checkroles = 1;
1855: $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
1856: " var rolecheck = 1;\n";
1857: }
1858: }
1859: if (!$checkroles) {
1860: $js .= " var disallow = new Array();\n".
1861: " rolecheck = 0;\n";
1862: }
1.273 droeschl 1863: return <<"END";
1.235 raeburn 1864: <script type="text/javascript">
1.273 droeschl 1865: //<![CDATA[
1.401 raeburn 1866: function adhocRole(newrole) {
1.239 raeburn 1867: $js
1.235 raeburn 1868: if (newrole == '') {
1.350 raeburn 1869: return;
1.235 raeburn 1870: }
1.239 raeburn 1871: var fullrole = newrole+'./$cdom/$cnum';
1872: var selidx = '';
1873: for (var i=0; i<rolenames.length; i++) {
1874: if (rolenames[i] == newrole) {
1875: selidx = i;
1876: }
1877: }
1.350 raeburn 1878: if (rolecheck > 0) {
1879: for (var i=0; i<disallow.length; i++) {
1880: if (disallow[i] == newrole) {
1881: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
1882: document.rolechooser.destinationurl.value = '/adm/menu';
1883: } else {
1884: return;
1885: }
1886: }
1887: }
1888: }
1.239 raeburn 1889: var secok = 1;
1890: var secchoice = '';
1891: if (selidx >= 0) {
1892: if (numsec[selidx] > 1) {
1893: secok = 0;
1894: var numrolesec = rolesections[selidx].length;
1895: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 1896: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 1897: if (secchoice == '') {
1898: if (msgidx > 0) {
1899: secok = 1;
1900: }
1901: } else {
1902: for (var j=0; j<rolesections[selidx].length; j++) {
1903: if (rolesections[selidx][j] == secchoice) {
1904: secok = 1;
1905: }
1906: }
1907: }
1908: } else {
1909: if (rolesections[selidx].length == 1) {
1910: secchoice = rolesections[selidx][0];
1911: }
1912: }
1913: }
1914: if (secok == 1) {
1915: if (secchoice != '') {
1916: fullrole += '/'+secchoice;
1917: }
1918: } else {
1919: if (secchoice != null) {
1920: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1921: }
1922: return;
1923: }
1924: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 1925: return;
1926: }
1927: itemid = retrieveIndex('gotorole');
1928: if (itemid != -1) {
1.239 raeburn 1929: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 1930: }
1.401 raeburn 1931: document.rolechooser.switchrole.value = fullrole;
1.235 raeburn 1932: document.rolechooser.selectrole.value = '1';
1933: document.rolechooser.submit();
1934: return;
1935: }
1936:
1937: function retrieveIndex(item) {
1938: for (var i=0;i<document.rolechooser.elements.length;i++) {
1939: if (document.rolechooser.elements[i].name == item) {
1940: return i;
1941: }
1942: }
1943: return -1;
1944: }
1.273 droeschl 1945: // ]]>
1.235 raeburn 1946: </script>
1947: END
1948: }
1949:
1.350 raeburn 1950: sub required_privs {
1951: my $privs = {
1952: '/adm/parmset' => 'opa',
1953: '/adm/courseprefs' => 'opa',
1954: '/adm/whatsnew' => 'whn',
1955: '/adm/populate' => 'cst',
1956: '/adm/trackstudent' => 'vsa',
1957: '/adm/statistics' => 'vgr',
1.366 raeburn 1958: '/adm/setblock' => 'dcm',
1.367 raeburn 1959: '/adm/coursedocs' => 'mdc',
1.350 raeburn 1960: };
1961: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 1962: $privs->{'/adm/classcalc'} = 'vgr',
1963: $privs->{'/adm/assesscalc'} = 'vgr',
1964: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 1965: }
1966: return $privs;
1967: }
1.235 raeburn 1968:
1.378 raeburn 1969: sub countdown_timer {
1970: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
1.387 raeburn 1971: ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
1972: my ($type,$hastimeleft,$slothastime);
1973: my $now = time;
1974: if ($env{'request.filename'} =~ /\.task$/) {
1975: $type = 'Task';
1976: } else {
1977: $type = 'problem';
1978: }
1979: my ($status,$accessmsg,$slot_name,$slot) =
1980: &Apache::lonhomework::check_slot_access('0',$type);
1981: if ($slot_name ne '') {
1982: if (ref($slot) eq 'HASH') {
1983: if (($slot->{'starttime'} < $now) &&
1984: ($slot->{'endtime'} > $now)) {
1985: $slothastime = 1;
1986: }
1987: }
1988: }
1989: if ($status ne 'CAN_ANSWER') {
1990: return;
1991: }
1.378 raeburn 1992: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.380 raeburn 1993: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.381 raeburn 1994: if (@interval > 1) {
1995: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
1996: if ($first_access > 0) {
1997: if ($first_access+$interval[0] > time) {
1998: $hastimeleft = 1;
1999: }
2000: }
2001: }
1.380 raeburn 2002: if (($duedate && $duedate > time) ||
1.387 raeburn 2003: (!$duedate && $hastimeleft) ||
2004: ($slot_name ne '' && $slothastime)) {
1.379 raeburn 2005: my ($collapse,$expand,$alttxt,$title,$currdisp);
1.387 raeburn 2006: if ((@interval > 1 && $hastimeleft) ||
2007: ($type eq 'Task' && $slothastime)) {
1.378 raeburn 2008: $currdisp = 'inline';
2009: $collapse = '► ';
2010: } else {
2011: $currdisp = 'none';
2012: $expand = '◄ ';
2013: }
2014: unless ($env{'environment.icons'} eq 'iconsonly') {
1.379 raeburn 2015: $alttxt = &mt('Timer');
2016: $title = $alttxt.' ';
1.378 raeburn 2017: }
2018: my $desc = &mt('Countdown to due date/time');
2019: return <<END;
2020:
2021: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2022: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
2023: $collapse
1.379 raeburn 2024: </span></a>
1.378 raeburn 2025: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
2026: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2027: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.379 raeburn 2028: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1.378 raeburn 2029: END
2030: }
2031: }
2032: return;
2033: }
2034:
1.2 www 2035: # ================================================================ Main Program
2036:
1.16 harris41 2037: BEGIN {
1.166 albertel 2038: if (! defined($readdesk)) {
1.283 droeschl 2039: {
2040: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2041: if ( CORE::open( my $config,"<$tabfile") ) {
2042: while (my $configline=<$config>) {
2043: $configline=(split(/\#/,$configline))[0];
2044: $configline=~s/^\s+//;
2045: chomp($configline);
1.209 www 2046: if ($configline=~/^cat\:/) {
1.283 droeschl 2047: my @entries=split(/\:/,$configline);
2048: $category_positions{$entries[2]}=$entries[1];
2049: $category_names{$entries[2]}=$entries[3];
2050: } elsif ($configline=~/^prim\:/) {
2051: my @entries = (split(/\:/, $configline))[1..5];
1.400 raeburn 2052: push(@primary_menu,\@entries);
1.371 raeburn 2053: } elsif ($configline=~/^primsub\:/) {
2054: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
1.400 raeburn 2055: push(@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 2056: } elsif ($configline=~/^scnd\:/) {
2057: my @entries = (split(/\:/, $configline))[1..5];
1.401 raeburn 2058: push(@secondary_menu,\@entries);
1.283 droeschl 2059: } elsif ($configline) {
2060: push(@desklines,$configline);
2061: }
2062: }
2063: CORE::close($config);
2064: }
2065: }
2066: $readdesk='done';
1.2 www 2067: }
2068: }
1.30 www 2069:
1.1 www 2070: 1;
2071: __END__
2072:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>