Annotation of loncom/interface/lonmenu.pm, revision 1.369.2.16
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.369.2.16! raeburn 4: # $Id: lonmenu.pm,v 1.369.2.15 2012/08/01 20:36:05 raeburn Exp $
1.11 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 www 28: #
29:
1.244 jms 30: =head1 NAME
31:
32: Apache::lonmenu
33:
34: =head1 SYNOPSIS
35:
1.369.2.3 raeburn 36: Loads contents of /home/httpd/lonTabs/mydesk.tab,
37: used to generate inline menu, and Main Menu page.
1.244 jms 38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.314 droeschl 42: =head1 GLOBAL VARIABLES
43:
44: =over
45:
46: =item @desklines
47:
48: Each element of this array contains a line of mydesk.tab that doesn't start with
49: cat, prim or scnd.
50: It gets filled in the BEGIN block of this module.
51:
52: =item %category_names
53:
54: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
55: start with cat, the values are strings representing titles.
56: It gets filled in the BEGIN block of this module.
57:
58: =item %category_members
59:
60: TODO
61:
62: =item %category_positions
63:
64: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
65: start with cat, its values are position vectors (column, row).
66: It gets filled in the BEGIN block of this module.
67:
68: =item $readdesk
69:
70: Indicates that mydesk.tab has been read.
71: It is set to 'done' in the BEGIN block of this module.
72:
73: =item @primary_menu
74:
75: The elements of this array reference arrays that are made up of the components
1.369.2.3 raeburn 76: of those lines of mydesk.tab that start with prim:.
1.314 droeschl 77: It is used by primary_menu() to generate the corresponding menu.
78: It gets filled in the BEGIN block of this module.
79:
1.369.2.3 raeburn 80: =item %primary_sub_menu
81:
82: The keys of this hash reference are the names of items in the primary_menu array
83: which have sub-menus. For each key, the corresponding value is a reference to
84: an array containing components extracted from lines in mydesk.tab which begin
85: with primsub:.
86: This hash, which is used by primary_menu to generate sub-menus, is populated in
87: the BEGIN block.
88:
1.314 droeschl 89: =item @secondary_menu
90:
91: The elements of this array reference arrays that are made up of the components
92: of those lines of mydesk.tab that start with scnd.
93: It is used by secondary_menu() to generate the corresponding menu.
94: It gets filled in the BEGIN block of this module.
95:
96: =back
97:
1.244 jms 98: =head1 SUBROUTINES
99:
100: =over
101:
1.314 droeschl 102: =item prep_menuitems(\@menuitem)
103:
104: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
105: secondary_menu().
106:
107: =item primary_menu()
108:
109: This routine evaluates @primary_menu and returns XHTML for the menu
110: that contains following links: About, Message, Roles, Help, Logout
111: @primary_menu is filled within the BEGIN block of this module with
112: entries from mydesk.tab
113:
114: =item secondary_menu()
115:
116: Same as primary_menu() but operates on @secondary_menu.
117:
1.369.2.6 raeburn 118: =item create_submenu()
119:
120: Creates XHTML for unordered list of sub-menu items which belong to a
121: particular top-level menu item. Uses hover pseudo class in css to display
122: dropdown list when mouse hovers over top-level item. Support for IE6
123: (no hover psuedo class) via LC_hoverable class for <li> tag for top-
124: level item, which employs jQuery to handle behavior on mouseover.
125:
126: Inputs: 4 - (a) link and (b) target for anchor href in top level item,
127: (c) title for text wrapped by anchor tag in top level item.
128: (d) reference to array of arrays of sub-menu items.
129:
1.244 jms 130: =item innerregister()
131:
1.320 droeschl 132: This gets called in order to register a URL in the body of the document
1.244 jms 133:
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.369.2.6 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.369.2.8 raeburn 182: use Apache::lonwishlist();
1.88 www 183:
1.283 droeschl 184: use vars qw(@desklines %category_names %category_members %category_positions
1.369.2.5 raeburn 185: $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
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.369.2.3 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.369.2.3 raeburn 238: my $title = $menuitem->[3];
239: if (defined($primary_submenu{$title})) {
1.369.2.6 raeburn 240: my ($link,$target);
1.369.2.3 raeburn 241: if ($menuitem->[0] ne '') {
242: $link = $menuitem->[0];
243: $target = '_top';
244: } else {
245: $link = '#';
246: }
1.369.2.6 raeburn 247: my @primsub;
1.369.2.3 raeburn 248: if (ref($primary_submenu{$title}) eq 'ARRAY') {
1.369.2.6 raeburn 249: foreach my $item (@{$primary_submenu{$title}}) {
1.369.2.16! raeburn 250: next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
1.369.2.6 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.369.2.7 raeburn 261: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.369.2.3 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.369.2.5 raeburn 320: my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
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);
1.369.2.5 raeburn 326: my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
1.343 www 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.369.2.5 raeburn 342: next if $$menuitem[4] eq 'mdcCourse'
343: && ($crstype eq 'Community');
344: next if $$menuitem[4] eq 'mdcCommunity'
345: && ($crstype eq 'Course');
1.341 www 346: next if $$menuitem[4] eq 'nvgr'
347: && $canvgr;
348: next if $$menuitem[4] eq 'vgr'
349: && !$canvgr;
1.327 droeschl 350: next if $$menuitem[4] eq 'cst'
351: && !$canmodifyuser;
1.343 www 352: next if $$menuitem[4] eq 'ncst'
1.369.2.5 raeburn 353: && ($canmodifyuser || !$canviewroster);
1.343 www 354: next if $$menuitem[4] eq 'mgr'
355: && !$canmgr;
356: next if $$menuitem[4] eq 'nmgr'
357: && $canmgr;
1.327 droeschl 358: next if $$menuitem[4] eq 'whn'
359: && !$canviewwnew;
360: next if $$menuitem[4] eq 'opa'
361: && !$canmodpara;
1.369.2.5 raeburn 362: next if $$menuitem[4] eq 'nvcg'
363: && ($canviewgrps || !%groups);
1.329 droeschl 364: next if $$menuitem[4] eq 'author'
365: && !$author;
1.283 droeschl 366:
1.369.2.5 raeburn 367: my $title = $menuitem->[3];
368: if (defined($secondary_submenu{$title})) {
1.369.2.6 raeburn 369: my ($link,$target);
1.369.2.5 raeburn 370: if ($menuitem->[0] ne '') {
371: $link = $menuitem->[0];
372: $target = '_top';
373: } else {
374: $link = '#';
375: }
376: my @scndsub;
377: if (ref($secondary_submenu{$title}) eq 'ARRAY') {
378: foreach my $item (@{$secondary_submenu{$title}}) {
379: if (ref($item) eq 'ARRAY') {
380: next if ($item->[2] eq 'vgr' && !$canvgr);
381: next if ($item->[2] eq 'opa' && !$canmodpara);
382: next if ($item->[2] eq 'cst' && !$canmodifyuser);
383: next if ($item->[2] eq 'mgr' && !$canmgr);
384: next if ($item->[2] eq 'vcg' && !$canviewgrps);
385: push(@scndsub,$item);
386: }
387: }
1.369.2.6 raeburn 388: if (@scndsub > 0) {
389: $menu .= &create_submenu($link,$target,$title,\@scndsub);
390: } elsif ($link) {
1.369.2.7 raeburn 391: $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
1.369.2.5 raeburn 392: }
393: }
394: } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 395: # special treatment for role selector
1.298 raeburn 396: my $roles_selector = &roles_selector(
1.283 droeschl 397: $env{'course.' . $env{'request.course.id'} . '.domain'},
398: $env{'course.' . $env{'request.course.id'} . '.num'} );
399:
1.369.2.5 raeburn 400: $menu .= $roles_selector ? "<li style=\"padding: 0 0.8em;\">$roles_selector</li>"
1.283 droeschl 401: : '';
1.296 droeschl 402: } else {
403: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 404: }
405: }
406: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 407: my $escurl = &escape( &Apache::lonenc::check_encrypt(
408: $env{'request.noversionuri'}));
1.283 droeschl 409:
1.291 raeburn 410: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
411: $env{'request.symb'}));
1.283 droeschl 412:
413: if ( $env{'request.state'} eq 'construct'
414: and ( $env{'request.noversionuri'} eq ''
415: || !defined($env{'request.noversionuri'})))
416: {
1.359 raeburn 417: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
418: ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
1.291 raeburn 419: $escurl = &escape($escurl);
1.283 droeschl 420: }
421: $menu =~ s/\[url\]/$escurl/g;
422: $menu =~ s/\[symb\]/$escsymb/g;
423: }
1.329 droeschl 424: $menu =~ s/\[uname\]/$$author{user}/g;
425: $menu =~ s/\[udom\]/$$author{dom}/g;
1.283 droeschl 426:
1.285 wenzelju 427: return "<ul id=\"LC_secondary_menu\">$menu</ul>";
1.283 droeschl 428: }
429:
1.369.2.6 raeburn 430: sub create_submenu {
431: my ($link,$target,$title,$submenu) = @_;
432: return unless (ref($submenu) eq 'ARRAY');
1.369.2.11 raeburn 433: my $disptarget;
434: if ($target ne '') {
435: $disptarget = ' target="'.$target.'"';
436: }
1.369.2.6 raeburn 437: my $menu = '<li class="LC_hoverable">'.
1.369.2.11 raeburn 438: '<a href="'.$link.'"'.$disptarget.'>'.
1.369.2.7 raeburn 439: '<span class="LC_nobreak">'.&mt($title).
1.369.2.6 raeburn 440: '<span class="LC_fontsize_small" style="font-weight:normal;">'.
441: ' ▼</span></span></a>'.
442: '<ul>';
443: my $count = 0;
444: my $numsub = scalar(@{$submenu});
445: foreach my $item (@{$submenu}) {
446: $count ++;
447: if (ref($item) eq 'ARRAY') {
448: my $borderbot;
449: if ($count == $numsub) {
450: $borderbot = 'border-bottom:1px solid black;';
451: }
452: $menu .= '<li style="margin:0;padding:0;'.
453: $borderbot.'"><a href="'.$item->[0].'">'.
1.369.2.7 raeburn 454: &mt($item->[1]).'</a></li>';
1.369.2.6 raeburn 455: }
456: }
457: $menu .= '</ul></li>';
458: return $menu;
459: }
460:
1.40 www 461: sub innerregister {
1.321 droeschl 462: my ($forcereg,$bread_crumbs) = @_;
1.152 albertel 463: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 464: my $is_const_dir = 0;
1.120 raeburn 465:
1.175 albertel 466: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 467:
1.174 albertel 468: $env{'request.registered'} = 1;
1.40 www 469:
1.177 albertel 470: undef(@inlineremote);
1.56 www 471:
1.348 raeburn 472: my $resurl;
1.316 droeschl 473: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
1.267 droeschl 474:
1.348 raeburn 475: (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
1.267 droeschl 476: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
477:
478: my $maptitle = &Apache::lonnet::gettitle($mapurl);
479: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.318 droeschl 480:
481: #SD
482: #course_type only Course and Community?
483: #
1.324 raeburn 484: my @crumbs;
485: unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
486: && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
487: @crumbs = ({text => Apache::loncommon::course_type()
1.318 droeschl 488: . ' Contents',
1.324 raeburn 489: href => "Javascript:gopost('/adm/navmaps','')"});
490: }
1.289 raeburn 491: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
492: push(@crumbs, {text => '...',
493: no_mt => 1});
494: }
1.268 droeschl 495:
496: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
497: && $maptitle ne 'default.sequence'
498: && $maptitle ne $coursetitle);
499:
500: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
501:
1.291 raeburn 502: &Apache::lonhtmlcommon::clear_breadcrumbs();
503: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.328 droeschl 504: }elsif (! $const_space){
505: #a situation when we're looking at a resource outside of context of a
506: #course or construction space (e.g. with cumulative rights)
507: &Apache::lonhtmlcommon::clear_breadcrumbs();
508: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
1.65 www 509: }
1.41 www 510: # =============================================================================
511: # ============================ This is for URLs that actually can be registered
1.316 droeschl 512: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
513: || $forcereg );
1.317 droeschl 514:
1.40 www 515: # -- This applies to homework problems for users with grading privileges
1.152 albertel 516: my $crs='/'.$env{'request.course.id'};
517: if ($env{'request.course.sec'}) {
518: $crs.='_'.$env{'request.course.sec'};
1.107 albertel 519: }
520: $crs=~s/\_/\//g;
521:
1.38 www 522: my $hwkadd='';
1.152 albertel 523: if ($env{'request.symb'} ne '' &&
1.360 www 524: $env{'request.filename'}=~/$LONCAPA::assess_re/) {
1.79 www 525: if (&Apache::lonnet::allowed('mgr',$crs)) {
1.344 www 526: $hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
1.40 www 527: "gocmd('/adm/grades','gradingmenu')",
1.344 www 528: 'Content Grades');
1.154 www 529: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
1.344 www 530: $hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
1.154 www 531: "gocmd('/adm/grades','submission')",
1.344 www 532: 'Content Submissions');
1.38 www 533: }
1.107 albertel 534: }
1.152 albertel 535: if ($env{'request.symb'} ne '' &&
1.145 albertel 536: &Apache::lonnet::allowed('opa',$crs)) {
1.344 www 537: $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
1.107 albertel 538: "gocmd('/adm/parmset','set')",
1.344 www 539: 'Content Settings');
1.38 www 540: }
1.363 www 541: if ($env{'request.symb'}=~/^uploaded/ &&
1.362 www 542: &Apache::lonnet::allowed('mdc',$crs)) {
543: $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]',
544: "gocmd('/adm/coursedocs','direct')",
545: 'Folder/Page Content');
546: }
1.40 www 547: # -- End Homework
1.38 www 548: ###
549: ### Determine whether or not to display the 'cstr' button for this
550: ### resource
551: ###
552: my $editbutton = '';
1.258 raeburn 553: my $noeditbutton = 1;
554: my ($cnum,$cdom);
555: if ($env{'request.course.id'}) {
556: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
557: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
558: }
1.152 albertel 559: if ($env{'user.author'}) {
1.234 raeburn 560: if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.274 www 561: #
562: # We have the role of an author
563: #
1.38 www 564: # Set defaults for authors
565: my ($top,$bottom) = ('con-','struct');
1.353 www 566: my $action = "go('/priv/".$env{'user.domain'}.'/'.$env{'user.name'}."');";
1.152 albertel 567: my $cadom = $env{'request.role.domain'};
568: my $caname = $env{'user.name'};
1.236 bisitz 569: my $desc = "Enter my construction space";
1.38 www 570: # Set defaults for co-authors
1.152 albertel 571: if ($env{'request.role'} =~ /^ca/) {
1.206 albertel 572: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38 www 573: ($top,$bottom) = ('co con-','struct');
1.353 www 574: $action = "go('/priv/".$cadom.'/'.$caname."');";
1.38 www 575: $desc = "Enter construction space as co-author";
1.234 raeburn 576: } elsif ($env{'request.role'} =~ /^aa/) {
577: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
578: ($top,$bottom) = ('co con-','struct');
1.353 www 579: $action = "go('/priv/".$cadom.'/'.$caname."');";
1.234 raeburn 580: $desc = "Enter construction space as assistant co-author";
1.38 www 581: }
582: # Check that we are on the correct machine
583: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 584: my $allowed=0;
585: my @ids=&Apache::lonnet::current_machine_ids();
586: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
587: if (!$allowed) {
588: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258 raeburn 589: $noeditbutton = 0;
1.38 www 590: }
591: }
1.274 www 592: #
593: # We are an author for some stuff, but currently do not have the role of author.
594: # Figure out if we have authoring privileges for the resource we are looking at.
595: # This should maybe become a privilege check in lonnet
596: #
1.38 www 597: ##
598: ## Determine if user can edit url.
599: ##
600: my $cfile='';
601: my $cfuname='';
602: my $cfudom='';
1.258 raeburn 603: my $uploaded;
1.330 raeburn 604: my $switchserver='';
605: my $home;
1.152 albertel 606: if ($env{'request.filename'}) {
607: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258 raeburn 608: if (defined($cnum) && defined($cdom)) {
609: $uploaded = &is_course_upload($file,$cnum,$cdom);
610: }
611: if (!$uploaded) {
1.357 raeburn 612:
613: $file=~s{^(priv/$match_domain/$match_username)}{/$1};
1.358 raeburn 614: $file=~s{^($match_domain/$match_username)}{/priv/$1};
1.356 raeburn 615:
1.258 raeburn 616: # Check that the user has permission to edit this resource
1.356 raeburn 617: my $setpriv = 1;
618: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$setpriv);
1.258 raeburn 619: if (defined($cfudom)) {
1.330 raeburn 620: $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
1.258 raeburn 621: my $allowed=0;
622: my @ids=&Apache::lonnet::current_machine_ids();
623: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
624: if ($allowed) {
625: $cfile=$file;
1.330 raeburn 626: } else {
627: $switchserver=$file;
1.258 raeburn 628: }
1.38 www 629: }
630: }
1.258 raeburn 631: }
1.38 www 632: # Finally, turn the button on or off
1.330 raeburn 633: if (($cfile || $switchserver) && !$const_space) {
1.302 raeburn 634: my $nocrsedit;
635: # Suppress display where CC has switched to student role.
636: if ($env{'request.course.id'}) {
637: unless(&Apache::lonnet::allowed('mdc',
638: $env{'request.course.id'})) {
639: $nocrsedit = 1;
640: }
641: }
642: if ($nocrsedit) {
643: $editbutton=&clear(6,1);
644: } else {
1.336 raeburn 645: my $bot = "go('$cfile')";
1.330 raeburn 646: if ($switchserver) {
647: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
1.336 raeburn 648: $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
649: &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='.
650: &HTML::Entities::encode($env{'request.symb'},'"<>&');
651: $bot = "need_switchserver('$cfile');";
1.330 raeburn 652: }
653: }
1.302 raeburn 654: $editbutton=&switch
1.345 www 655: ('','',6,1,'pcstr.png','Edit','resource[_2]',
1.336 raeburn 656: $bot,"Edit this resource");
1.302 raeburn 657: $noeditbutton = 0;
658: }
1.38 www 659: } elsif ($editbutton eq '') {
1.191 www 660: $editbutton=&clear(6,1);
1.38 www 661: }
662: }
1.258 raeburn 663: if (($noeditbutton) && ($env{'request.filename'})) {
664: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
665: my $file=&Apache::lonnet::declutter($env{'request.filename'});
666: if (defined($cnum) && defined($cdom)) {
667: if (&is_course_upload($file,$cnum,$cdom)) {
668: my $cfile = &edit_course_upload($file,$cnum,$cdom);
669: if ($cfile) {
670: $editbutton=&switch
1.345 www 671: ('','',6,1,'pcstr.png','Edit',
1.258 raeburn 672: 'resource[_2]',"go('".$cfile."');",
673: 'Edit this resource');
674: }
675: }
676: }
677: }
678: }
1.348 raeburn 679: if ($env{'request.course.id'}) {
680: if ($resurl eq "public/$cdom/$cnum/syllabus") {
681: if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
682: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
683: $editbutton=&switch('','',6,1,'pcstr.png','Edit',
684: 'resource[_2]',
685: "go('/adm/courseprefs?phase=display&actions=courseinfo')",
686: 'Edit this resource');
687: }
688: }
689: }
690: }
1.38 www 691: ###
692: ###
1.41 www 693: # Prepare the rest of the buttons
1.369.2.16! raeburn 694: my ($menuitems,$got_prt,$got_wishlist);
1.120 raeburn 695: if ($const_space) {
1.274 www 696: #
697: # We are in construction space
698: #
1.353 www 699:
1.355 raeburn 700: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
1.353 www 701: my ($udom,$uname,$thisdisfn) =
1.355 raeburn 702: ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
1.353 www 703: my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
1.131 raeburn 704: if ($currdir =~ m-/$-) {
705: $is_const_dir = 1;
706: } else {
1.267 droeschl 707: $currdir =~ s|[^/]+$||;
1.200 foxr 708: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 709: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 710: #
711: # Probably should be in mydesk.tab
712: #
1.131 raeburn 713: $menuitems=(<<ENDMENUITEMS);
1.344 www 714: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
1.353 www 715: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
716: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
717: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
718: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 719: ENDMENUITEMS
1.131 raeburn 720: }
1.308 raeburn 721: if (ref($bread_crumbs) eq 'ARRAY') {
722: &Apache::lonhtmlcommon::clear_breadcrumbs();
723: foreach my $crumb (@{$bread_crumbs}){
724: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
725: }
726: }
1.203 foxr 727: } elsif ( defined($env{'request.course.id'}) &&
728: $env{'request.symb'} ne '' ) {
1.274 www 729: #
1.369.2.16! raeburn 730: # We are in a course and looking at a registered URL
1.274 www 731: # Should probably be in mydesk.tab
732: #
1.120 raeburn 733: $menuitems=(<<ENDMENUITEMS);
1.41 www 734: c&3&1
1.344 www 735: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
736: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
1.77 www 737: c&6&3
738: c&8&1
739: c&8&2
1.344 www 740: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.41 www 741: ENDMENUITEMS
1.369.2.16! raeburn 742: $got_prt = 1;
! 743: if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
! 744: && (!$env{'request.enc'})) {
1.369.2.8 raeburn 745: # wishlist is only available for users with access to resource-pool
746: # and links can only be set for resources within the resource-pool
747: $menuitems .= (<<ENDMENUITEMS);
748: 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
749: ENDMENUITEMS
1.369.2.16! raeburn 750: $got_wishlist = 1;
1.369.2.8 raeburn 751: }
1.216 albertel 752:
1.243 tempelho 753: my $currentURL = &Apache::loncommon::get_symb();
754: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
755: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
756: $menuitems.="s&9&3&";
757: if(length($annotation) > 0){
1.317 droeschl 758: $menuitems.="anot2.png";
1.243 tempelho 759: }else{
1.317 droeschl 760: $menuitems.="anot.png";
1.243 tempelho 761: }
1.344 www 762: $menuitems.="&Notes&&annotate()&";
1.243 tempelho 763: $menuitems.="Make notes and annotations about this resource&&1\n";
764:
1.323 raeburn 765: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.369.2.15 raeburn 766: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
1.216 albertel 767: $menuitems.=(<<ENDREALRES);
1.344 www 768: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
1.216 albertel 769: ENDREALRES
770: }
1.369.2.14 raeburn 771: unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
772: $menuitems.=(<<ENDREALRES);
1.344 www 773: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
1.369.2.14 raeburn 774: ENDREALRES
775: }
776: $menuitems.=(<<ENDREALRES);
1.344 www 777: 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 778: ENDREALRES
1.120 raeburn 779: }
780: }
1.203 foxr 781: if ($env{'request.uri'} =~ /^\/res/) {
1.369.2.16! raeburn 782: unless ($got_prt) {
! 783: $menuitems .= (<<ENDMENUITEMS);
1.344 www 784: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.203 foxr 785: ENDMENUITEMS
1.369.2.16! raeburn 786: $got_prt = 1;
! 787: }
! 788: unless ($got_wishlist) {
! 789: if (($env{'user.adv'}) && (!$env{'request.enc'})) {
! 790: # wishlist is only available for users with access to resource-pool
! 791: $menuitems .= (<<ENDMENUITEMS);
1.369.2.8 raeburn 792: 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
793: ENDMENUITEMS
1.369.2.16! raeburn 794: $got_wishlist = 1;
! 795: }
1.369.2.8 raeburn 796: }
1.203 foxr 797: }
1.41 www 798: my $buttons='';
799: foreach (split(/\n/,$menuitems)) {
800: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 801: my $idx=10*$rest[0]+$rest[1];
802: if (&hidden_button_check() eq 'yes') {
803: if ($idx == 21 ||$idx == 23) {
804: $buttons.=&switch('','',@rest);
805: } else {
806: $buttons.=&clear(@rest);
807: }
808: } else {
809: if ($command eq 's') {
810: $buttons.=&switch('','',@rest);
811: } else {
812: $buttons.=&clear(@rest);
813: }
1.41 www 814: }
815: }
1.148 albertel 816:
817: my $addremote=0;
1.267 droeschl 818: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.301 droeschl 819: if ($addremote) {
820:
1.342 www 821: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 822:
1.342 www 823: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.312 droeschl 824: 'navigation', @inlineremote[21,23]);
825:
1.369.2.10 raeburn 826: my $countdown = &countdown_timer();
827: if (&hidden_button_check() eq 'yes') {
828: if ($countdown) {
829: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
830: }
831: } else {
832: my @tools = @inlineremote[93,91,81,82,83];
833: if ($countdown) {
834: unshift(@tools,$countdown);
835: }
1.342 www 836: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.369.2.10 raeburn 837: 'tools',@tools);
1.313 droeschl 838:
839: #publish button in construction space
840: if ($env{'request.state'} eq 'construct'){
1.342 www 841: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 842: 'advtools', $inlineremote[63]);
1.342 www 843: } else {
844: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.349 raeburn 845: 'tools', $inlineremote[63]);
1.313 droeschl 846: }
847:
1.322 raeburn 848: unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
1.342 www 849: &Apache::lonhtmlcommon::add_breadcrumb_tool(
1.362 www 850: 'advtools', @inlineremote[61,71,72,73,74,92]);
1.322 raeburn 851: }
1.301 droeschl 852: }
1.38 www 853: }
854:
1.342 www 855: return &Apache::lonhtmlcommon::scripttag('', 'start')
856: . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
857: . &Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 858: }
859:
1.258 raeburn 860: sub is_course_upload {
861: my ($file,$cnum,$cdom) = @_;
862: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
863: $uploadpath =~ s{^\/}{};
864: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
865: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
866: return 1;
867: }
868: return;
869: }
870:
871: sub edit_course_upload {
872: my ($file,$cnum,$cdom) = @_;
873: my $cfile;
874: if ($file =~/\.(htm|html|css|js|txt)$/) {
875: my $ext = $1;
876: my $url = &Apache::lonnet::hreflocation('',$file);
877: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
878: my @ids=&Apache::lonnet::current_machine_ids();
879: my $dest;
880: if ($home && grep(/^\Q$home\E$/,@ids)) {
881: $dest = $url.'?forceedit=1';
882: } else {
883: unless (&Apache::lonnet::get_locks()) {
884: $dest = '/adm/switchserver?otherserver='.
885: $home.'&role='.$env{'request.role'}.
886: '&url='.$url.'&forceedit=1';
887: }
888: }
889: if ($dest) {
890: $cfile = &HTML::Entities::encode($dest,'"<>&');
891: }
892: }
893: return $cfile;
894: }
895:
1.369.2.1 raeburn 896: sub startupremote {
897: my ($lowerurl)=@_;
898: if ($env{'environment.remote'} eq 'off') {
899: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
900: }
901: #
902: # The Remote actually gets launched!
903: #
904: my $configmenu=&rawconfig();
905: my $esclowerurl=&escape($lowerurl);
906: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
907: return(<<ENDREMOTESTARTUP);
908: <script type="text/javascript">
909: // <![CDATA[
910: var timestart;
911: function wheelswitch() {
912: if (typeof(document.wheel) != 'undefined') {
913: if (typeof(document.wheel.spin) != 'undefined') {
914: var date=new Date();
915: var waited=Math.round(30-((date.getTime()-timestart)/1000));
916: document.wheel.spin.value=$message;
917: }
918: }
919: if (window.status=='|') {
920: window.status='/';
921: } else {
922: if (window.status=='/') {
923: window.status='-';
924: } else {
925: if (window.status=='-') {
926: window.status='\\\\';
927: } else {
928: if (window.status=='\\\\') { window.status='|'; }
929: }
930: }
931: }
932: }
933:
934: // ---------------------------------------------------------- The wait function
935: var canceltim;
936: function wait() {
937: if ((menuloaded==1) || (tim==1)) {
938: window.status='Done.';
939: if (tim==0) {
940: clearTimeout(canceltim);
941: $configmenu
942: window.location='$lowerurl';
943: } else {
944: window.location='/adm/remote?action=collapse&url=$esclowerurl';
945: }
946: } else {
947: wheelswitch();
948: setTimeout('wait();',200);
949: }
950: }
951:
952: function main() {
953: canceltim=setTimeout('tim=1;',30000);
954: window.status='-';
955: var date=new Date();
956: timestart=date.getTime();
957: wait();
958: }
959:
960: // ]]>
961: </script>
962: ENDREMOTESTARTUP
963: }
964:
965: sub setflags() {
966: return(<<ENDSETFLAGS);
967: <script type="text/javascript">
968: // <![CDATA[
969: menuloaded=0;
970: tim=0;
971: // ]]>
972: </script>
973: ENDSETFLAGS
974: }
975:
976: sub maincall() {
977: if ($env{'environment.remote'} eq 'off') { return ''; }
978: return(<<ENDMAINCALL);
979: <script type="text/javascript">
980: // <![CDATA[
981: main();
982: // ]]>
983: </script>
984: ENDMAINCALL
985: }
986:
987: sub load_remote_msg {
988: my ($lowerurl)=@_;
989:
990: if ($env{'environment.remote'} eq 'off') { return ''; }
991:
992: my $esclowerurl=&escape($lowerurl);
993: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
994: ,'<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">'
995: ,'</a>');
996: return(<<ENDREMOTEFORM);
997: <p>
998: <form name="wheel">
999: <input name="spin" type="text" size="60" />
1000: </form>
1001: </p>
1002: <p>$link</p>
1003: ENDREMOTEFORM
1004: }
1005:
1006: sub get_menu_name {
1007: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
1008: $hostid =~ s/\W//g;
1009: return 'LCmenu'.$hostid;
1010: }
1011:
1012:
1013: sub reopenmenu {
1014: if ($env{'environment.remote'} eq 'off') { return ''; }
1015: my $menuname = &get_menu_name();
1016: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1017: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1018: }
1019:
1020:
1021: sub open {
1022: my $returnval='';
1023: if ($env{'environment.remote'} eq 'off') {
1024: return
1025: '<script type="text/javascript">'."\n"
1026: .'// <![CDATA['."\n"
1027: .'self.name="loncapaclient";'."\n"
1028: .'// ]]>'."\n"
1029: .'</script>';
1030: }
1031: my $menuname = &get_menu_name();
1032:
1033: # unless (shift eq 'unix') {
1034: # resizing does not work on linux because of virtual desktop sizes
1035: # $returnval.=(<<ENDRESIZE);
1036: #if (window.screen) {
1037: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1038: # self.moveTo(190,15);
1039: #}
1040: #ENDRESIZE
1041: # }
1042: $returnval=(<<ENDOPEN);
1043: // <![CDATA[
1044: window.status='Opening LON-CAPA Remote Control';
1045: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
1046: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1047: self.name='loncapaclient';
1048: // ]]>
1049: ENDOPEN
1050: return '<script type="text/javascript">'.$returnval.'</script>';
1051: }
1052:
1053:
1.2 www 1054: # ================================================================== Raw Config
1055:
1.3 www 1056: sub clear {
1057: my ($row,$col)=@_;
1.316 droeschl 1058: $inlineremote[10*$row+$col]='';
1059: return '';
1.3 www 1060: }
1061:
1.40 www 1062: # ============================================ Switch a button or create a link
1.25 matthew 1063: # Switch acts on the javascript that is executed when a button is clicked.
1064: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1065:
1.2 www 1066: sub switch {
1.209 www 1067: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1068: $act=~s/\$uname/$uname/g;
1069: $act=~s/\$udom/$udom/g;
1.88 www 1070: $top=&mt($top);
1071: $bot=&mt($bot);
1072: $desc=&mt($desc);
1.209 www 1073: my $idx=10*$row+$col;
1074: $category_members{$cat}.=':'.$idx;
1075:
1.320 droeschl 1076: # Inline Menu
1.317 droeschl 1077: if ($nobreak==2) { return ''; }
1078: my $text=$top.' '.$bot;
1079: $text=~s/\s*\-\s*//gs;
1.105 www 1080:
1.317 droeschl 1081: my $pic=
1.225 albertel 1082: '<img alt="'.$text.'" src="'.
1083: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1084: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.317 droeschl 1085: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1086: # Main Menu
1.103 www 1087: if ($nobreak==3) {
1.209 www 1088: $inlineremote[$idx]="\n".
1.177 albertel 1089: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1090: '</td><td align="left">'.
1.103 www 1091: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1092: } elsif ($nobreak) {
1.209 www 1093: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1094: '<td align="left">'.
1.177 albertel 1095: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1096: <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 1097: } else {
1.209 www 1098: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1099: '<td align="left">'.
1.103 www 1100: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1101: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1102: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1103: }
1.317 droeschl 1104: } else {
1.103 www 1105: # Inline Menu
1.369.2.10 raeburn 1106: my @tools = (93,91,81,82,83);
1107: unless ($env{'request.state'} eq 'construct') {
1108: push(@tools,63);
1109: }
1110: if (($env{'environment.icons'} eq 'iconsonly') &&
1111: (grep(/^$idx$/,@tools))) {
1112: $inlineremote[$idx] =
1113: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
1114: } else {
1115: $inlineremote[$idx] =
1.317 droeschl 1116: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.344 www 1117: '<span class="LC_menubuttons_inline_text">'.$top.' </span></a>';
1.369.2.10 raeburn 1118: }
1.317 droeschl 1119: }
1.56 www 1120: return '';
1.2 www 1121: }
1122:
1123: sub secondlevel {
1124: my $output='';
1125: my
1.209 www 1126: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1127: if ($prt eq 'any') {
1.209 www 1128: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1129: } elsif ($prt=~/^r(\w+)/) {
1130: if ($rol eq $1) {
1.209 www 1131: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1132: }
1133: }
1134: return $output;
1135: }
1136:
1.56 www 1137: sub inlinemenu {
1.210 albertel 1138: undef(@inlineremote);
1139: undef(%category_members);
1.275 www 1140: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1141: &rawconfig(1);
1.309 bisitz 1142: my $output='<table><tr>';
1.209 www 1143: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1144: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1145: for (my $row=1; $row<=8; $row++) {
1146: foreach my $cat (keys(%category_members)) {
1147: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1148: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1149: $output.='<div class="LC_Box LC_400Box">';
1150: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1151: $output.='<table>';
1.240 riegler 1152: my %active=();
1153: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1154: if ($inlineremote[$menu_item]) {
1155: $active{$menu_item}=1;
1156: }
1157: }
1158: foreach my $item (sort(keys(%active))) {
1159: $output.=$inlineremote[$item];
1160: }
1161: $output.='</table>';
1.245 harmsja 1162: $output.='</div>';
1.240 riegler 1163: }
1164: }
1165: $output.="</td>";
1166: }
1167: $output.="</tr></table>";
1168: return $output;
1169: }
1170:
1.2 www 1171: sub rawconfig {
1.274 www 1172: #
1173: # This evaluates mydesk.tab
1174: # Need to add more positions and more privileges to deal with all
1175: # menu items.
1176: #
1.34 www 1177: my $textualoverride=shift;
1178: my $output='';
1.316 droeschl 1179: return '' unless $textualoverride;
1.152 albertel 1180: my $uname=$env{'user.name'};
1181: my $udom=$env{'user.domain'};
1182: my $adv=$env{'user.adv'};
1.266 raeburn 1183: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1184: my $author=$env{'user.author'};
1.5 www 1185: my $crs='';
1.295 raeburn 1186: my $crstype='';
1.152 albertel 1187: if ($env{'request.course.id'}) {
1188: $crs='/'.$env{'request.course.id'};
1189: if ($env{'request.course.sec'}) {
1190: $crs.='_'.$env{'request.course.sec'};
1.7 www 1191: }
1.8 www 1192: $crs=~s/\_/\//g;
1.295 raeburn 1193: $crstype = &Apache::loncommon::course_type();
1.5 www 1194: }
1.152 albertel 1195: my $pub=($env{'request.state'} eq 'published');
1196: my $con=($env{'request.state'} eq 'construct');
1197: my $rol=$env{'request.role'};
1198: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1199: foreach my $line (@desklines) {
1.209 www 1200: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1201: $prt=~s/\$uname/$uname/g;
1202: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1203: if ($prt =~ /\$crs/) {
1204: next unless ($env{'request.course.id'});
1205: next if ($crstype eq 'Community');
1206: $prt=~s/\$crs/$crs/g;
1207: } elsif ($prt =~ /\$cmty/) {
1208: next unless ($env{'request.course.id'});
1209: next if ($crstype ne 'Community');
1210: $prt=~s/\$cmty/$crs/g;
1211: }
1.25 matthew 1212: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1213: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1214: if ($pro eq 'clear') {
1.4 www 1215: $output.=&clear($row,$col);
1.3 www 1216: } elsif ($pro eq 'any') {
1.2 www 1217: $output.=&secondlevel(
1.209 www 1218: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1219: } elsif ($pro eq 'smp') {
1220: unless ($adv) {
1221: $output.=&secondlevel(
1.209 www 1222: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1223: }
1224: } elsif ($pro eq 'adv') {
1225: if ($adv) {
1226: $output.=&secondlevel(
1.209 www 1227: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1228: }
1.231 albertel 1229: } elsif ($pro eq 'shc') {
1230: if ($show_course) {
1231: $output.=&secondlevel(
1232: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1233: }
1234: } elsif ($pro eq 'nsc') {
1235: if (!$show_course) {
1236: $output.=&secondlevel(
1237: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1238: }
1.81 matthew 1239: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1240: my $priv = $1;
1241: if ($priv =~ /^mdc(Course|Community)/) {
1242: if ($crstype eq $1) {
1243: $priv = 'mdc';
1244: } else {
1245: next;
1246: }
1247: }
1248: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1249: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1250: }
1.295 raeburn 1251: } elsif ($pro eq 'course') {
1252: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1253: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1254: }
1.295 raeburn 1255: } elsif ($pro eq 'community') {
1256: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1257: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1258: }
1.124 matthew 1259: } elsif ($pro =~ /^courseenv_(.*)$/) {
1260: my $key = $1;
1.307 raeburn 1261: if ($crstype ne 'Community') {
1262: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1263: if ($key eq 'canuse_pdfforms') {
1264: if ($env{'request.course.id'} && $coursepref eq '') {
1265: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1266: $coursepref = $domdefs{'canuse_pdfforms'};
1267: }
1268: }
1269: if ($coursepref) {
1270: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1271: }
1.295 raeburn 1272: }
1273: } elsif ($pro =~ /^communityenv_(.*)$/) {
1274: my $key = $1;
1.307 raeburn 1275: if ($crstype eq 'Community') {
1276: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1277: if ($key eq 'canuse_pdfforms') {
1278: if ($env{'request.course.id'} && $coursepref eq '') {
1279: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1280: $coursepref = $domdefs{'canuse_pdfforms'};
1281: }
1282: }
1283: if ($coursepref) {
1284: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1285: }
1.124 matthew 1286: }
1.81 matthew 1287: } elsif ($pro =~ /^course_(.*)$/) {
1288: # Check for permissions inside of a course
1.295 raeburn 1289: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1290: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1291: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1292: )) {
1.209 www 1293: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1294: }
1.295 raeburn 1295: } elsif ($pro =~ /^community_(.*)$/) {
1296: # Check for permissions inside of a community
1297: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1298: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1299: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1300: )) {
1301: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1302: }
1.4 www 1303: } elsif ($pro eq 'author') {
1304: if ($author) {
1.152 albertel 1305: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1306: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1307: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1308: # Check that we are on the correct machine
1.29 matthew 1309: my $cadom=$requested_domain;
1.152 albertel 1310: my $caname=$env{'user.name'};
1.234 raeburn 1311: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1312: ($cadom,$caname)=
1.206 albertel 1313: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1314: }
1315: $act =~ s/\$caname/$caname/g;
1.353 www 1316: $act =~ s/\$cadom/$cadom/g;
1.19 matthew 1317: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1318: my $allowed=0;
1319: my @ids=&Apache::lonnet::current_machine_ids();
1320: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1321: if ($allowed) {
1.209 www 1322: $output.=&switch($caname,$cadom,
1323: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1324: }
1.6 www 1325: }
1.2 www 1326: }
1.248 raeburn 1327: } elsif ($pro eq 'tools') {
1328: my @tools = ('aboutme','blog','portfolio');
1329: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1330: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1331: $env{'user.domain'},
1332: $prt,undef,'tools')) {
1333: $output.=&clear($row,$col);
1334: next;
1335: }
1.278 raeburn 1336: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1337: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1338: next;
1339: }
1340: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1341: next;
1342: }
1.279 raeburn 1343: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1344: if (!$showreqcrs) {
1.248 raeburn 1345: $output.=&clear($row,$col);
1346: next;
1347: }
1348: }
1349: $prt='any';
1350: $output.=&secondlevel(
1351: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1352: }
1.13 harris41 1353: }
1.2 www 1354: return $output;
1355: }
1356:
1.279 raeburn 1357: sub check_for_rcrs {
1358: my $showreqcrs = 0;
1.280 raeburn 1359: my @reqtypes = ('official','unofficial','community');
1360: foreach my $type (@reqtypes) {
1.279 raeburn 1361: if (&Apache::lonnet::usertools_access($env{'user.name'},
1362: $env{'user.domain'},
1363: $type,undef,'requestcourses')) {
1364: $showreqcrs = 1;
1365: last;
1366: }
1367: }
1.280 raeburn 1368: if (!$showreqcrs) {
1369: foreach my $type (@reqtypes) {
1370: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1371: $showreqcrs = 1;
1372: last;
1373: }
1374: }
1375: }
1.279 raeburn 1376: return $showreqcrs;
1377: }
1378:
1.369.2.1 raeburn 1379: # ======================================================================= Close
1380:
1381: sub close {
1382: if ($env{'environment.remote'} eq 'off') { return ''; }
1383: my $menuname = &get_menu_name();
1384: return(<<ENDCLOSE);
1385: <script type="text/javascript">
1386: // <![CDATA[
1387: window.status='Accessing Remote Control';
1388: menu=window.open("/adm/rat/empty.html","$menuname",
1389: "height=350,width=150,scrollbars=no,menubar=no");
1390: window.status='Disabling Remote Control';
1391: menu.active=0;
1392: menu.autologout=0;
1393: window.status='Closing Remote Control';
1394: menu.close();
1395: window.status='Done.';
1396: // ]]>
1397: </script>
1398: ENDCLOSE
1399: }
1400:
1.306 raeburn 1401: sub dc_popup_js {
1402: my %lt = &Apache::lonlocal::texthash(
1403: more => '(More ...)',
1404: less => '(Less ...)',
1405: );
1406: return <<"END";
1407:
1408: function showCourseID() {
1409: document.getElementById('dccid').style.display='block';
1410: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1411: document.getElementById('dccid').style.textFace='normal';
1.369 raeburn 1412: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
1.306 raeburn 1413: return;
1414: }
1415:
1416: function hideCourseID() {
1417: document.getElementById('dccid').style.display='none';
1.369 raeburn 1418: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
1.306 raeburn 1419: return;
1420: }
1421:
1422: END
1423:
1424: }
1425:
1.369.2.10 raeburn 1426: sub countdown_toggle_js {
1427: return <<"END";
1428:
1429: function toggleCountdown() {
1430: var countdownid = document.getElementById('duedatecountdown');
1431: var currstyle = countdownid.style.display;
1432: if (currstyle == 'inline') {
1433: countdownid.style.display = 'none';
1434: document.getElementById('ddcountcollapse').innerHTML='';
1435: document.getElementById('ddcountexpand').innerHTML='◄ ';
1436: } else {
1437: countdownid.style.display = 'inline';
1438: document.getElementById('ddcountcollapse').innerHTML='► ';
1439: document.getElementById('ddcountexpand').innerHTML='';
1440: }
1441: return;
1442: }
1443:
1444: END
1445: }
1446:
1.42 www 1447: sub utilityfunctions {
1.152 albertel 1448: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 droeschl 1449: if ($currenturl =~ m{^/adm/wrapper/ext/}
1450: && $env{'request.external.querystring'} ) {
1.293 raeburn 1451: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1452: }
1.183 www 1453: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1454:
1.152 albertel 1455: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.175 albertel 1456:
1.306 raeburn 1457: my $dc_popup_cid;
1458: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1459: $env{'course.'.$env{'request.course.id'}.
1460: '.domain'}.'/'})) {
1461: $dc_popup_cid = &dc_popup_js();
1462: }
1463:
1.175 albertel 1464: my $start_page_annotate =
1465: &Apache::loncommon::start_page('Annotator',undef,
1466: {'only_body' => 1,
1467: 'js_ready' => 1,
1468: 'bgcolor' => '#BBBBBB',
1469: 'add_entries' => {
1470: 'onload' => 'javascript:document.goannotate.submit();'}});
1471:
1.205 albertel 1472: my $end_page_annotate =
1473: &Apache::loncommon::end_page({'js_ready' => 1});
1474:
1.336 raeburn 1475: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
1476: &mt('Switch server?');
1477:
1.368 www 1478: my $esc_url=&escape($currenturl);
1479: my $esc_symb=&escape($currentsymb);
1.332 wenzelju 1480:
1.369.2.10 raeburn 1481: my $countdown = &countdown_toggle_js();
1482:
1.42 www 1483: return (<<ENDUTILITY)
1484:
1.368 www 1485: var currentURL=unescape("$esc_url");
1486: var reloadURL=unescape("$esc_url");
1487: var currentSymb=unescape("$esc_symb");
1.42 www 1488:
1.306 raeburn 1489: $dc_popup_cid
1.114 albertel 1490:
1.42 www 1491: function go(url) {
1492: if (url!='' && url!= null) {
1493: currentURL = null;
1494: currentSymb= null;
1495: window.location.href=url;
1496: }
1497: }
1498:
1.336 raeburn 1499: function need_switchserver(url) {
1500: if (url!='' && url!= null) {
1501: if (confirm("$confirm_switch")) {
1502: go(url);
1503: }
1504: }
1505: return;
1506: }
1507:
1.42 www 1508: function gopost(url,postdata) {
1509: if (url!='') {
1510: this.document.server.action=url;
1511: this.document.server.postdata.value=postdata;
1512: this.document.server.command.value='';
1513: this.document.server.url.value='';
1514: this.document.server.symb.value='';
1515: this.document.server.submit();
1516: }
1517: }
1518:
1519: function gocmd(url,cmd) {
1520: if (url!='') {
1521: this.document.server.action=url;
1522: this.document.server.postdata.value='';
1523: this.document.server.command.value=cmd;
1524: this.document.server.url.value=currentURL;
1525: this.document.server.symb.value=currentSymb;
1526: this.document.server.submit();
1527: }
1.57 www 1528: }
1529:
1.121 raeburn 1530: function gocstr(url,filename) {
1531: if (url == '/adm/cfile?action=delete') {
1532: this.document.cstrdelete.filename.value = filename
1533: this.document.cstrdelete.submit();
1534: return;
1535: }
1.137 raeburn 1536: if (url == '/adm/printout') {
1537: this.document.cstrprint.postdata.value = filename
1538: this.document.cstrprint.curseed.value = 0;
1539: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1540: if (this.document.lonhomework) {
1541: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1542: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1543: }
1544: if (this.document.lonhomework.problemtype) {
1.164 albertel 1545: if (this.document.lonhomework.problemtype.value) {
1546: this.document.cstrprint.problemtype.value =
1547: this.document.lonhomework.problemtype.value;
1548: } else if (this.document.lonhomework.problemtype.options) {
1549: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1550: if (this.document.lonhomework.problemtype.options[i].selected) {
1551: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1552: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1553: }
1554: }
1555: }
1556: }
1557: }
1558: }
1.137 raeburn 1559: this.document.cstrprint.submit();
1560: return;
1561: }
1.121 raeburn 1562: if (url !='') {
1563: this.document.constspace.filename.value = filename;
1564: this.document.constspace.action = url;
1565: this.document.constspace.submit();
1566: }
1567: }
1568:
1.131 raeburn 1569: function golist(url) {
1570: if (url!='' && url!= null) {
1571: currentURL = null;
1572: currentSymb= null;
1573: top.location.href=url;
1574: }
1575: }
1576:
1577:
1.121 raeburn 1578:
1.57 www 1579: function catalog_info() {
1.365 www 1580: openMyModal(window.location.pathname+'.meta',500,400,'yes');
1.57 www 1581: }
1582:
1583: function chat_win() {
1.290 raeburn 1584: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1585: }
1.169 raeburn 1586:
1587: function group_chat(group) {
1588: var url = '/adm/groupchat?group='+group;
1589: var winName = 'LONchat_'+group;
1590: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1591: }
1.175 albertel 1592:
1593: function annotate() {
1594: w_Annotator_flag=1;
1595: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1596: annotator.document.write(
1597: '$start_page_annotate'
1598: +"<form name='goannotate' target='Annotator' method='post' "
1599: +"action='/adm/annotations'>"
1.217 albertel 1600: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1601: +"<\\/form>"
1.205 albertel 1602: +'$end_page_annotate');
1.175 albertel 1603: annotator.document.close();
1604: }
1605:
1.369.2.8 raeburn 1606: function open_StoredLinks_Import(rat) {
1607: var newWin;
1608: if (rat) {
1609: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
1610: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1611: }
1612: else {
1613: newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
1614: 'wishlistImport','scrollbars=1,resizable=1,menubar=0');
1615: }
1616: newWin.focus();
1617: }
1618:
1.369.2.4 raeburn 1619: (function (\$) {
1620: \$(document).ready(function () {
1621: \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
1622: /*\@cc_on
1623: if (!window.XMLHttpRequest) {
1624: \$('.LC_hoverable').each(function () {
1625: this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
1626: this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
1627: });
1628: }
1629: \@*/
1630: });
1631: }(jQuery));
1632:
1.369.2.10 raeburn 1633: $countdown
1634:
1.42 www 1635: ENDUTILITY
1636: }
1637:
1638: sub serverform {
1639: return(<<ENDSERVERFORM);
1.181 albertel 1640: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1641: <input type="hidden" name="postdata" value="none" />
1642: <input type="hidden" name="command" value="none" />
1643: <input type="hidden" name="url" value="none" />
1644: <input type="hidden" name="symb" value="none" />
1645: </form>
1646: ENDSERVERFORM
1647: }
1.113 albertel 1648:
1.121 raeburn 1649: sub constspaceform {
1650: return(<<ENDCONSTSPACEFORM);
1.181 albertel 1651: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 1652: <input type="hidden" name="filename" value="" />
1653: </form>
1.181 albertel 1654: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 1655: <input type="hidden" name="action" value="delete" />
1656: <input type="hidden" name="filename" value="" />
1657: </form>
1.181 albertel 1658: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 1659: <input type="hidden" name="postdata" value="" />
1660: <input type="hidden" name="curseed" value="" />
1661: <input type="hidden" name="problemtype" value="" />
1662: </form>
1663:
1.121 raeburn 1664: ENDCONSTSPACEFORM
1665: }
1666:
1.220 raeburn 1667: sub hidden_button_check {
1.317 droeschl 1668: if ( $env{'request.course.id'} eq ''
1669: || $env{'request.role.adv'} ) {
1670:
1.220 raeburn 1671: return;
1672: }
1.232 raeburn 1673: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1674: return $buttonshide;
1.220 raeburn 1675: }
1.184 raeburn 1676:
1.235 raeburn 1677: sub roles_selector {
1678: my ($cdom,$cnum) = @_;
1.298 raeburn 1679: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 1680: my $now = time;
1.350 raeburn 1681: my (%courseroles,%seccount,%courseprivs);
1.235 raeburn 1682: my $is_cc;
1683: my $role_selector;
1.298 raeburn 1684: my $ccrole;
1685: if ($crstype eq 'Community') {
1686: $ccrole = 'co';
1687: } else {
1688: $ccrole = 'cc';
1.350 raeburn 1689: }
1690: my $priv;
1691: my $destinationurl = $ENV{'REQUEST_URI'};
1692: my $reqprivs = &required_privs();
1693: if (ref($reqprivs) eq 'HASH') {
1694: my $destination = $destinationurl;
1695: $destination =~ s/(\?.*)$//;
1696: if (exists($reqprivs->{$destination})) {
1697: $priv = $reqprivs->{$destination};
1698: }
1699: }
1.298 raeburn 1700: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1701: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 1702:
1703: if ((($start) && ($start<0)) ||
1704: (($end) && ($end<$now)) ||
1705: (($start) && ($now<$start))) {
1706: $is_cc = 0;
1707: } else {
1708: $is_cc = 1;
1709: }
1710: }
1711: if ($is_cc) {
1.350 raeburn 1712: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
1.235 raeburn 1713: } else {
1.262 raeburn 1714: my %gotnosection;
1.235 raeburn 1715: foreach my $item (keys(%env)) {
1.239 raeburn 1716: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 1717: my $role = $1;
1718: my $sec = $2;
1719: next if ($role eq 'gr');
1720: my ($start,$end) = split(/\./,$env{$item});
1721: next if (($start && $start > $now) || ($end && $end < $now));
1722: if ($sec eq '') {
1.239 raeburn 1723: if (!$gotnosection{$role}) {
1724: $seccount{$role} ++;
1725: $gotnosection{$role} = 1;
1726: }
1.235 raeburn 1727: }
1.350 raeburn 1728: if ($priv ne '') {
1729: my $cnumsec = $cnum;
1730: if ($sec ne '') {
1731: $cnumsec .= "/$sec";
1732: }
1733: $courseprivs{"$role./$cdom/$cnumsec./"} =
1734: $env{"user.priv.$role./$cdom/$cnumsec./"};
1735: $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
1736: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
1737: $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
1738: $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
1739: }
1.235 raeburn 1740: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 1741: if ($sec ne '') {
1.264 raeburn 1742: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 1743: push(@{$courseroles{$role}},$sec);
1744: $seccount{$role} ++;
1745: }
1746: }
1747: } else {
1748: @{$courseroles{$role}} = ();
1749: if ($sec ne '') {
1750: $seccount{$role} ++;
1.235 raeburn 1751: push(@{$courseroles{$role}},$sec);
1752: }
1753: }
1754: }
1755: }
1756: }
1.286 raeburn 1757: my $switchtext;
1758: if ($crstype eq 'Community') {
1759: $switchtext = &mt('Switch community role to...')
1760: } else {
1761: $switchtext = &mt('Switch course role to...')
1762: }
1.298 raeburn 1763: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235 raeburn 1764: if (keys(%courseroles) > 1) {
1.350 raeburn 1765: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
1.235 raeburn 1766: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1767: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286 raeburn 1768: $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235 raeburn 1769: foreach my $role (@roles_order) {
1770: if (defined($courseroles{$role})) {
1.298 raeburn 1771: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1.235 raeburn 1772: }
1773: }
1774: foreach my $role (sort(keys(%courseroles))) {
1775: if ($role =~ /^cr/) {
1776: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1777: }
1778: }
1779: $role_selector .= '</select>'."\n".
1780: '<input type="hidden" name="destinationurl" value="'.
1.350 raeburn 1781: &HTML::Entities::encode($destinationurl).'" />'."\n".
1.235 raeburn 1782: '<input type="hidden" name="gotorole" value="1" />'."\n".
1783: '<input type="hidden" name="selectrole" value="" />'."\n".
1784: '<input type="hidden" name="switch" value="1" />'."\n".
1785: '</form>';
1786: }
1787: return $role_selector;
1788: }
1789:
1.262 raeburn 1790: sub get_all_courseroles {
1.350 raeburn 1791: my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
1.351 raeburn 1792: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
1.350 raeburn 1793: (ref($courseprivs) eq 'HASH')) {
1.262 raeburn 1794: return;
1795: }
1796: my ($result,$cached) =
1797: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1798: if (defined($cached)) {
1799: if (ref($result) eq 'HASH') {
1800: if ((ref($result->{'roles'}) eq 'HASH') &&
1.350 raeburn 1801: (ref($result->{'seccount'}) eq 'HASH') &&
1802: (ref($result->{'privs'}) eq 'HASH')) {
1.262 raeburn 1803: %{$courseroles} = %{$result->{'roles'}};
1804: %{$seccount} = %{$result->{'seccount'}};
1.350 raeburn 1805: %{$courseprivs} = %{$result->{'privs'}};
1.262 raeburn 1806: return;
1807: }
1808: }
1809: }
1810: my %gotnosection;
1811: my %adv_roles =
1812: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1813: foreach my $role (keys(%adv_roles)) {
1814: my ($urole,$usec) = split(/:/,$role);
1815: if (!$gotnosection{$urole}) {
1816: $seccount->{$urole} ++;
1817: $gotnosection{$urole} = 1;
1818: }
1819: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1820: if ($usec ne '') {
1821: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1822: push(@{$courseroles->{$urole}},$usec);
1823: $seccount->{$urole} ++;
1824: }
1825: }
1826: } else {
1827: @{$courseroles->{$urole}} = ();
1828: if ($usec ne '') {
1829: $seccount->{$urole} ++;
1830: push(@{$courseroles->{$urole}},$usec);
1831: }
1832: }
1.350 raeburn 1833: my $area = '/'.$cdom.'/'.$cnum;
1834: if ($usec ne '') {
1835: $area .= '/'.$usec;
1836: }
1837: if ($role =~ /^cr\//) {
1838: &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
1839: } else {
1840: &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
1841: }
1.262 raeburn 1842: }
1843: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1844: @{$courseroles->{'st'}} = ();
1.350 raeburn 1845: &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
1.262 raeburn 1846: if (keys(%sections_count) > 0) {
1847: push(@{$courseroles->{'st'}},keys(%sections_count));
1.350 raeburn 1848: $seccount->{'st'} = scalar(keys(%sections_count));
1.262 raeburn 1849: }
1850: my $rolehash = {
1851: 'roles' => $courseroles,
1852: 'seccount' => $seccount,
1.350 raeburn 1853: 'privs' => $courseprivs,
1.262 raeburn 1854: };
1855: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1856: return;
1857: }
1858:
1.235 raeburn 1859: sub jump_to_role {
1.350 raeburn 1860: my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
1.239 raeburn 1861: my %lt = &Apache::lonlocal::texthash(
1862: this => 'This role has section(s) associated with it.',
1863: ente => 'Enter a specific section.',
1864: orlb => 'Enter a specific section, or leave blank for no section.',
1865: avai => 'Available sections are:',
1866: youe => 'You entered an invalid section choice:',
1.352 raeburn 1867: plst => 'Please try again.',
1.350 raeburn 1868: role => 'The role you selected is not permitted to view the current page.',
1869: swit => 'Switch role, but display Main Menu page instead?',
1.239 raeburn 1870: );
1871: my $js;
1872: if (ref($courseroles) eq 'HASH') {
1873: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1874: ' var numsec = new Array();'."\n".
1875: ' var rolesections = new Array();'."\n".
1876: ' var rolenames = new Array();'."\n".
1877: ' var roleseclist = new Array();'."\n";
1878: my @items = keys(%{$courseroles});
1879: for (my $i=0; $i<@items; $i++) {
1880: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1881: my ($secs,$secstr);
1882: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1883: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1884: $secs = join('","',@sections);
1885: $secstr = join(', ',@sections);
1886: }
1887: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1888: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1889: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1890: }
1891: }
1.350 raeburn 1892: my $checkroles = 0;
1893: if ($priv && ref($courseprivs) eq 'HASH') {
1894: my (%disallowed,%allowed,@disallow);
1895: foreach my $role (sort(keys(%{$courseprivs}))) {
1896: my $trole;
1897: if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
1898: $trole = $1;
1899: }
1900: if (($trole ne '') && ($trole ne 'cm')) {
1901: if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
1902: $allowed{$trole} = 1;
1903: } else {
1904: $disallowed{$trole} = 1;
1905: }
1906: }
1907: }
1908: foreach my $trole (keys(%disallowed)) {
1909: unless ($allowed{$trole}) {
1910: push(@disallow,$trole);
1911: }
1912: }
1913: if (@disallow > 0) {
1914: $checkroles = 1;
1915: $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
1916: " var rolecheck = 1;\n";
1917: }
1918: }
1919: if (!$checkroles) {
1920: $js .= " var disallow = new Array();\n".
1921: " rolecheck = 0;\n";
1922: }
1.273 droeschl 1923: return <<"END";
1.235 raeburn 1924: <script type="text/javascript">
1.273 droeschl 1925: //<![CDATA[
1.235 raeburn 1926: function adhocRole(roleitem) {
1.239 raeburn 1927: $js
1.235 raeburn 1928: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1929: if (newrole == '') {
1.350 raeburn 1930: return;
1.235 raeburn 1931: }
1.239 raeburn 1932: var fullrole = newrole+'./$cdom/$cnum';
1933: var selidx = '';
1934: for (var i=0; i<rolenames.length; i++) {
1935: if (rolenames[i] == newrole) {
1936: selidx = i;
1937: }
1938: }
1.350 raeburn 1939: if (rolecheck > 0) {
1940: for (var i=0; i<disallow.length; i++) {
1941: if (disallow[i] == newrole) {
1942: if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
1943: document.rolechooser.destinationurl.value = '/adm/menu';
1944: } else {
1945: document.rolechooser.elements[roleitem].selectedIndex = 0;
1946: return;
1947: }
1948: }
1949: }
1950: }
1.239 raeburn 1951: var secok = 1;
1952: var secchoice = '';
1953: if (selidx >= 0) {
1954: if (numsec[selidx] > 1) {
1955: secok = 0;
1956: var numrolesec = rolesections[selidx].length;
1957: var msgidx = numsec[selidx] - numrolesec;
1.339 raeburn 1958: secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1.239 raeburn 1959: if (secchoice == '') {
1960: if (msgidx > 0) {
1961: secok = 1;
1962: }
1963: } else {
1964: for (var j=0; j<rolesections[selidx].length; j++) {
1965: if (rolesections[selidx][j] == secchoice) {
1966: secok = 1;
1967: }
1968: }
1969: }
1970: } else {
1971: if (rolesections[selidx].length == 1) {
1972: secchoice = rolesections[selidx][0];
1973: }
1974: }
1975: }
1976: if (secok == 1) {
1977: if (secchoice != '') {
1978: fullrole += '/'+secchoice;
1979: }
1980: } else {
1981: document.rolechooser.elements[roleitem].selectedIndex = 0;
1982: if (secchoice != null) {
1983: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1984: }
1985: return;
1986: }
1987: if (fullrole == "$env{'request.role'}") {
1.350 raeburn 1988: document.rolechooser.elements[roleitem].selectedIndex = 0;
1.235 raeburn 1989: return;
1990: }
1991: itemid = retrieveIndex('gotorole');
1992: if (itemid != -1) {
1.239 raeburn 1993: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 1994: }
1.239 raeburn 1995: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235 raeburn 1996: document.rolechooser.selectrole.value = '1';
1997: document.rolechooser.submit();
1998: return;
1999: }
2000:
2001: function retrieveIndex(item) {
2002: for (var i=0;i<document.rolechooser.elements.length;i++) {
2003: if (document.rolechooser.elements[i].name == item) {
2004: return i;
2005: }
2006: }
2007: return -1;
2008: }
1.273 droeschl 2009: // ]]>
1.235 raeburn 2010: </script>
2011: END
2012: }
2013:
1.350 raeburn 2014: sub required_privs {
2015: my $privs = {
2016: '/adm/parmset' => 'opa',
2017: '/adm/courseprefs' => 'opa',
2018: '/adm/whatsnew' => 'whn',
2019: '/adm/populate' => 'cst',
2020: '/adm/trackstudent' => 'vsa',
2021: '/adm/statistics' => 'vgr',
1.366 raeburn 2022: '/adm/setblock' => 'dcm',
1.367 raeburn 2023: '/adm/coursedocs' => 'mdc',
1.350 raeburn 2024: };
2025: unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
1.364 raeburn 2026: $privs->{'/adm/classcalc'} = 'vgr',
2027: $privs->{'/adm/assesscalc'} = 'vgr',
2028: $privs->{'/adm/studentcalc'} = 'vgr';
1.350 raeburn 2029: }
2030: return $privs;
2031: }
1.235 raeburn 2032:
1.369.2.10 raeburn 2033: sub countdown_timer {
2034: if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
2035: ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
2036: ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
2037: my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
1.369.2.12 raeburn 2038: my @interval=&Apache::lonnet::EXT("resource.0.interval");
1.369.2.13 raeburn 2039: my $hastimeleft;
2040: if (@interval > 1) {
2041: my $first_access=&Apache::lonnet::get_first_access($interval[1]);
2042: if ($first_access > 0) {
2043: if ($first_access+$interval[0] > time) {
2044: $hastimeleft = 1;
2045: }
2046: }
2047: }
1.369.2.12 raeburn 2048: if (($duedate && $duedate > time) ||
1.369.2.13 raeburn 2049: (!$duedate && $hastimeleft)) {
1.369.2.11 raeburn 2050: my ($collapse,$expand,$alttxt,$title,$currdisp);
1.369.2.13 raeburn 2051: if (@interval > 1 && $hastimeleft) {
1.369.2.10 raeburn 2052: $currdisp = 'inline';
2053: $collapse = '► ';
2054: } else {
2055: $currdisp = 'none';
2056: $expand = '◄ ';
2057: }
2058: unless ($env{'environment.icons'} eq 'iconsonly') {
1.369.2.11 raeburn 2059: $alttxt = &mt('Timer');
2060: $title = $alttxt.' ';
1.369.2.10 raeburn 2061: }
2062: my $desc = &mt('Countdown to due date/time');
2063: return <<END;
2064:
2065: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2066: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
2067: $collapse
1.369.2.11 raeburn 2068: </span></a>
1.369.2.10 raeburn 2069: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
2070: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
2071: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1.369.2.11 raeburn 2072: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1.369.2.10 raeburn 2073: END
2074: }
2075: }
2076: return;
2077: }
2078:
1.2 www 2079: # ================================================================ Main Program
2080:
1.16 harris41 2081: BEGIN {
1.166 albertel 2082: if (! defined($readdesk)) {
1.283 droeschl 2083: {
2084: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2085: if ( CORE::open( my $config,"<$tabfile") ) {
2086: while (my $configline=<$config>) {
2087: $configline=(split(/\#/,$configline))[0];
2088: $configline=~s/^\s+//;
2089: chomp($configline);
1.209 www 2090: if ($configline=~/^cat\:/) {
1.283 droeschl 2091: my @entries=split(/\:/,$configline);
2092: $category_positions{$entries[2]}=$entries[1];
2093: $category_names{$entries[2]}=$entries[3];
2094: } elsif ($configline=~/^prim\:/) {
2095: my @entries = (split(/\:/, $configline))[1..5];
2096: push @primary_menu, \@entries;
1.369.2.3 raeburn 2097: } elsif ($configline=~/^primsub\:/) {
2098: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
2099: push (@{$primary_submenu{$parent}},\@entries);
1.283 droeschl 2100: } elsif ($configline=~/^scnd\:/) {
2101: my @entries = (split(/\:/, $configline))[1..5];
2102: push @secondary_menu, \@entries;
1.369.2.5 raeburn 2103: } elsif ($configline=~/^scndsub\:/) {
2104: my ($parent,@entries) = (split(/\:/, $configline))[1..4];
2105: push (@{$secondary_submenu{$parent}},\@entries);
1.283 droeschl 2106: } elsif ($configline) {
2107: push(@desklines,$configline);
2108: }
2109: }
2110: CORE::close($config);
2111: }
2112: }
2113: $readdesk='done';
1.2 www 2114: }
2115: }
1.30 www 2116:
1.1 www 2117: 1;
2118: __END__
2119:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>