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