Annotation of loncom/interface/lonmenu.pm, revision 1.316
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.316 ! droeschl 4: # $Id: lonmenu.pm,v 1.315 2010/03/03 21:33:15 droeschl 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: #
1.269 droeschl 29: # There is one parameter controlling the action of this module:
1.48 www 30: #
1.1 www 31:
1.244 jms 32: =head1 NAME
33:
34: Apache::lonmenu
35:
36: =head1 SYNOPSIS
37:
38: Coordinates the response to clicking an image.
39:
40: This is part of the LearningOnline Network with CAPA project
41: described at http://www.lon-capa.org.
42:
1.314 droeschl 43: =head1 GLOBAL VARIABLES
44:
45: =over
46:
47: =item @desklines
48:
49: Each element of this array contains a line of mydesk.tab that doesn't start with
50: cat, prim or scnd.
51: It gets filled in the BEGIN block of this module.
52:
53: =item %category_names
54:
55: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
56: start with cat, the values are strings representing titles.
57: It gets filled in the BEGIN block of this module.
58:
59: =item %category_members
60:
61: TODO
62:
63: =item %category_positions
64:
65: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
66: start with cat, its values are position vectors (column, row).
67: It gets filled in the BEGIN block of this module.
68:
69: =item $readdesk
70:
71: Indicates that mydesk.tab has been read.
72: It is set to 'done' in the BEGIN block of this module.
73:
74: =item @primary_menu
75:
76: The elements of this array reference arrays that are made up of the components
77: of those lines of mydesk.tab that start with prim.
78: It is used by primary_menu() to generate the corresponding menu.
79: It gets filled in the BEGIN block of this module.
80:
81: =item @secondary_menu
82:
83: The elements of this array reference arrays that are made up of the components
84: of those lines of mydesk.tab that start with scnd.
85: It is used by secondary_menu() to generate the corresponding menu.
86: It gets filled in the BEGIN block of this module.
87:
88: =back
89:
1.244 jms 90: =head1 SUBROUTINES
91:
92: =over
93:
1.314 droeschl 94: =item prep_menuitems(\@menuitem)
95:
96: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
97: secondary_menu().
98:
99: =item primary_menu()
100:
101: This routine evaluates @primary_menu and returns XHTML for the menu
102: that contains following links: About, Message, Roles, Help, Logout
103: @primary_menu is filled within the BEGIN block of this module with
104: entries from mydesk.tab
105:
106: =item secondary_menu()
107:
108: Same as primary_menu() but operates on @secondary_menu.
109:
1.244 jms 110: =item show_return_link()
111:
112: =item registerurl()
113:
114: This gets called in the header section
115:
116: =item innerregister()
117:
118: This gets called in order to register a URL, both with the Remote
119: and in the body of the document
120:
121: =item loadevents()
122:
123: =item unloadevents()
124:
125: =item get_menu_name()
126:
127: =item clear()
128:
129: =item switch()
130:
131: Switch a button or create a link
132: Switch acts on the javascript that is executed when a button is clicked.
133: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
134:
135: =item secondlevel()
136:
137: =item openmenu()
138:
139: =item inlinemenu()
140:
141: =item rawconfig()
142:
143: =item utilityfunctions()
144:
145: =item serverform()
146:
147: =item constspaceform()
148:
149: =item get_nav_status()
150:
151: =item hidden_button_check()
152:
153: =item roles_selector()
154:
155: =item jump_to_role()
156:
157: =back
158:
159: =cut
160:
1.1 www 161: package Apache::lonmenu;
162:
163: use strict;
1.152 albertel 164: use Apache::lonnet;
1.47 matthew 165: use Apache::lonhtmlcommon();
1.115 albertel 166: use Apache::loncommon();
1.127 albertel 167: use Apache::lonenc();
1.88 www 168: use Apache::lonlocal;
1.207 foxr 169: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 170: use HTML::Entities();
1.88 www 171:
1.283 droeschl 172: use vars qw(@desklines %category_names %category_members %category_positions
173: $readdesk @primary_menu @secondary_menu);
1.88 www 174:
1.56 www 175: my @inlineremote;
1.38 www 176:
1.283 droeschl 177: sub prep_menuitem {
1.291 raeburn 178: my ($menuitem) = @_;
179: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 180: my $link;
181: if ($$menuitem[1]) { # graphical Link
182: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 183: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
184: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 185: } else { # textual Link
1.291 raeburn 186: $link = &mt($$menuitem[3]);
187: }
1.316 ! droeschl 188: return '<li><a'
! 189: # highlighting for new messages
! 190: . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
! 191: . qq| href="$$menuitem[0]">$link</a></li>|;
1.283 droeschl 192: }
193:
194: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
195: # that contains following links:
196: # About, Message, Roles, Help, Logout
197: # @primary_menu is filled within the BEGIN block of this module with
198: # entries from mydesk.tab
199: sub primary_menu {
200: my $menu;
201: # each element of @primary contains following array:
202: # (link url, icon path, alt text, link text, condition)
203: foreach my $menuitem (@primary_menu) {
204: # evaluate conditions
1.296 droeschl 205: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 206: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 207: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 208: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 209: && !&Apache::lonmsg::mynewmail(); #
1.283 droeschl 210: next if $$menuitem[4] !~ /public/ ##we've a public user,
211: && $env{'user.name'} eq 'public' ##who should not see all
212: && $env{'user.domain'} eq 'public'; ##links
213: next if $$menuitem[4] eq 'onlypublic'# hide links which are
214: && $env{'user.name'} ne 'public' # only visible to public
215: && $env{'user.domain'} ne 'public'; # users
216: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 217: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 218: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 219: && !&Apache::loncommon::show_course(); ##
220:
221:
1.283 droeschl 222: if ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.291 raeburn 223: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.283 droeschl 224: } else {
1.296 droeschl 225: my @items = @{$menuitem};
226: $items[0] = 'javascript:'.$menuitem->[0].';';
227: $menu .= &prep_menuitem(\@items);
1.283 droeschl 228: }
1.291 raeburn 229: }
1.283 droeschl 230:
1.291 raeburn 231: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 232: }
233:
234:
235: sub secondary_menu {
236: my $menu;
237:
1.286 raeburn 238: my $crstype = &Apache::loncommon::course_type();
239: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
240: my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'}
241: . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
242: : ''));
243: my $showlink = &show_return_link();
244: my %groups = &Apache::lonnet::get_active_groups(
245: $env{'user.domain'}, $env{'user.name'},
246: $env{'course.' . $env{'request.course.id'} . '.domain'},
247: $env{'course.' . $env{'request.course.id'} . '.num'});
1.283 droeschl 248: foreach my $menuitem (@secondary_menu) {
249: # evaluate conditions
1.296 droeschl 250: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 251: next if $$menuitem[4] ne 'always'
252: && !$env{'request.course.id'};
253: next if $$menuitem[4] eq 'showreturn'
1.286 raeburn 254: && !$showlink
1.283 droeschl 255: && !($env{'request.state'} eq 'construct');
256: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 257: && !$canedit;
258: next if $$menuitem[4] eq 'mdcCourse'
259: && $crstype eq 'Community';
260: next if $$menuitem[4] eq 'mdcCommunity'
261: && $crstype ne 'Community';
262: next if $$menuitem[4] =~ /^remotenav/
1.283 droeschl 263: && $env{'environment.remotenavmap'} ne 'on';
1.286 raeburn 264: next if $$menuitem[4] =~ /noremotenav/
1.283 droeschl 265: && $env{'environment.remotenavmap'} eq 'on';
1.295 raeburn 266: next if $$menuitem[4] =~ /^(no|)remotenav$/
267: && $crstype eq 'Community';
268: next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/
269: && $crstype ne 'Community';
1.283 droeschl 270: next if $$menuitem[4] =~ /showgroups$/
1.300 raeburn 271: && !$canviewgrps
1.286 raeburn 272: && !%groups;
1.283 droeschl 273:
1.286 raeburn 274: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 275: # special treatment for role selector
1.298 raeburn 276: my $roles_selector = &roles_selector(
1.283 droeschl 277: $env{'course.' . $env{'request.course.id'} . '.domain'},
278: $env{'course.' . $env{'request.course.id'} . '.num'} );
279:
280: $menu .= $roles_selector ? "<li>$roles_selector</li>"
281: : '';
1.296 droeschl 282: } elsif ($env{'environment.remotenavmap'} eq 'on') {
283: # open link using javascript when remote navmap is activated
284: my @items = @{$menuitem};
285: if ($menuitem->[4] eq 'remotenav') {
286: $items[0] = "javascript:gonav('$menuitem->[0]');";
1.291 raeburn 287: } else {
1.296 droeschl 288: $items[0] = "javascript:go('$menuitem->[0]');";
1.291 raeburn 289: }
1.296 droeschl 290: $menu .= &prep_menuitem(\@items);
291: } else {
292: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 293: }
294: }
295: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 296: my $escurl = &escape( &Apache::lonenc::check_encrypt(
297: $env{'request.noversionuri'}));
1.283 droeschl 298:
1.291 raeburn 299: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
300: $env{'request.symb'}));
1.283 droeschl 301:
302: if ( $env{'request.state'} eq 'construct'
303: and ( $env{'request.noversionuri'} eq ''
304: || !defined($env{'request.noversionuri'})))
305: {
306: ($escurl = $env{'request.filename'}) =~
307: s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
308:
1.291 raeburn 309: $escurl = &escape($escurl);
1.283 droeschl 310: }
311: $menu =~ s/\[url\]/$escurl/g;
312: $menu =~ s/\[symb\]/$escsymb/g;
313: }
314:
1.285 wenzelju 315: return "<ul id=\"LC_secondary_menu\">$menu</ul>";
1.283 droeschl 316: }
317:
1.228 albertel 318: sub show_return_link {
319: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
320: $env{'request.symb'} eq '')
321: ||
322: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
323: ||
324: (($env{'request.noversionuri'}=~/^\/adm\//) &&
325: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
326: ($env{'request.noversionuri'}!~
327: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
328: ));
329: }
330:
1.38 www 331:
332: sub registerurl {
1.173 albertel 333: my ($forcereg) = @_;
1.38 www 334: my $result = '';
1.175 albertel 335: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.66 albertel 336: my $force_title='';
1.152 albertel 337: if ($env{'request.state'} eq 'construct') {
1.66 albertel 338: $force_title=&Apache::lonxml::display_title();
339: }
1.277 bisitz 340: return
341: $result
342: .'<script type="text/javascript">'."\n"
343: .'// <![CDATA['."\n"
344: .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
345: .'// ]]>'."\n"
346: .'</script>'
347: .$force_title;
1.40 www 348: }
349:
350: sub innerregister {
1.308 raeburn 351: my ($forcereg,$titletable,$bread_crumbs) = @_;
1.120 raeburn 352: my ($uname,$thisdisfn);
1.152 albertel 353: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 354: my $is_const_dir = 0;
1.120 raeburn 355:
1.175 albertel 356: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 357:
1.174 albertel 358: $env{'request.registered'} = 1;
1.40 www 359:
1.177 albertel 360: undef(@inlineremote);
1.56 www 361:
1.316 ! droeschl 362: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
1.267 droeschl 363:
364: my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
365: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
366:
367: my $maptitle = &Apache::lonnet::gettitle($mapurl);
368: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.299 raeburn 369: my $contentstext;
370: if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') {
371: $contentstext = &mt('Community Contents');
372: } else {
373: $contentstext = &mt('Course Contents');
374: }
375: my @crumbs = ({text => $contentstext,
1.289 raeburn 376: href => "Javascript:gonav('/adm/navmaps')"});
377:
378: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
379: push(@crumbs, {text => '...',
380: no_mt => 1});
381: }
1.268 droeschl 382:
383: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
384: && $maptitle ne 'default.sequence'
385: && $maptitle ne $coursetitle);
386:
387: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
388:
1.291 raeburn 389: &Apache::lonhtmlcommon::clear_breadcrumbs();
390: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.301 droeschl 391: #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.65 www 392: }
1.41 www 393: # =============================================================================
394: # ============================ This is for URLs that actually can be registered
1.316 ! droeschl 395: return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
! 396: || $forcereg );
1.40 www 397: # -- This applies to homework problems for users with grading privileges
1.152 albertel 398: my $crs='/'.$env{'request.course.id'};
399: if ($env{'request.course.sec'}) {
400: $crs.='_'.$env{'request.course.sec'};
1.107 albertel 401: }
402: $crs=~s/\_/\//g;
403:
1.38 www 404: my $hwkadd='';
1.152 albertel 405: if ($env{'request.symb'} ne '' &&
1.161 albertel 406: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
1.79 www 407: if (&Apache::lonnet::allowed('mgr',$crs)) {
1.259 bisitz 408: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
1.40 www 409: "gocmd('/adm/grades','gradingmenu')",
410: 'Modify user grades for this assessment resource');
1.154 www 411: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
412: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
413: "gocmd('/adm/grades','submission')",
414: 'View user submissions for this assessment resource');
1.38 www 415: }
1.107 albertel 416: }
1.152 albertel 417: if ($env{'request.symb'} ne '' &&
1.145 albertel 418: &Apache::lonnet::allowed('opa',$crs)) {
1.107 albertel 419: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
420: "gocmd('/adm/parmset','set')",
1.196 www 421: 'Modify parameter settings for this resource');
1.38 www 422: }
1.40 www 423: # -- End Homework
1.38 www 424: ###
425: ### Determine whether or not to display the 'cstr' button for this
426: ### resource
427: ###
428: my $editbutton = '';
1.258 raeburn 429: my $noeditbutton = 1;
430: my ($cnum,$cdom);
431: if ($env{'request.course.id'}) {
432: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
433: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
434: }
1.152 albertel 435: if ($env{'user.author'}) {
1.234 raeburn 436: if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.274 www 437: #
438: # We have the role of an author
439: #
1.38 www 440: # Set defaults for authors
441: my ($top,$bottom) = ('con-','struct');
1.152 albertel 442: my $action = "go('/priv/".$env{'user.name'}."');";
443: my $cadom = $env{'request.role.domain'};
444: my $caname = $env{'user.name'};
1.236 bisitz 445: my $desc = "Enter my construction space";
1.38 www 446: # Set defaults for co-authors
1.152 albertel 447: if ($env{'request.role'} =~ /^ca/) {
1.206 albertel 448: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38 www 449: ($top,$bottom) = ('co con-','struct');
450: $action = "go('/priv/".$caname."');";
451: $desc = "Enter construction space as co-author";
1.234 raeburn 452: } elsif ($env{'request.role'} =~ /^aa/) {
453: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
454: ($top,$bottom) = ('co con-','struct');
455: $action = "go('/priv/".$caname."');";
456: $desc = "Enter construction space as assistant co-author";
1.38 www 457: }
458: # Check that we are on the correct machine
459: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 460: my $allowed=0;
461: my @ids=&Apache::lonnet::current_machine_ids();
462: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
463: if (!$allowed) {
464: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258 raeburn 465: $noeditbutton = 0;
1.38 www 466: }
467: }
1.274 www 468: #
469: # We are an author for some stuff, but currently do not have the role of author.
470: # Figure out if we have authoring privileges for the resource we are looking at.
471: # This should maybe become a privilege check in lonnet
472: #
1.38 www 473: ##
474: ## Determine if user can edit url.
475: ##
476: my $cfile='';
477: my $cfuname='';
478: my $cfudom='';
1.258 raeburn 479: my $uploaded;
1.152 albertel 480: if ($env{'request.filename'}) {
481: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258 raeburn 482: if (defined($cnum) && defined($cdom)) {
483: $uploaded = &is_course_upload($file,$cnum,$cdom);
484: }
485: if (!$uploaded) {
486: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
487: # Check that the user has permission to edit this resource
488: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
489: if (defined($cfudom)) {
490: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
491: my $allowed=0;
492: my @ids=&Apache::lonnet::current_machine_ids();
493: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
494: if ($allowed) {
495: $cfile=$file;
496: }
1.38 www 497: }
498: }
1.258 raeburn 499: }
1.38 www 500: # Finally, turn the button on or off
1.120 raeburn 501: if ($cfile && !$const_space) {
1.302 raeburn 502: my $nocrsedit;
503: # Suppress display where CC has switched to student role.
504: if ($env{'request.course.id'}) {
505: unless(&Apache::lonnet::allowed('mdc',
506: $env{'request.course.id'})) {
507: $nocrsedit = 1;
508: }
509: }
510: if ($nocrsedit) {
511: $editbutton=&clear(6,1);
512: } else {
513: $editbutton=&switch
514: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
1.38 www 515: "go('".$cfile."');","Edit this resource");
1.302 raeburn 516: $noeditbutton = 0;
517: }
1.38 www 518: } elsif ($editbutton eq '') {
1.191 www 519: $editbutton=&clear(6,1);
1.38 www 520: }
521: }
1.258 raeburn 522: if (($noeditbutton) && ($env{'request.filename'})) {
523: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
524: my $file=&Apache::lonnet::declutter($env{'request.filename'});
525: if (defined($cnum) && defined($cdom)) {
526: if (&is_course_upload($file,$cnum,$cdom)) {
527: my $cfile = &edit_course_upload($file,$cnum,$cdom);
528: if ($cfile) {
529: $editbutton=&switch
530: ('','',6,1,'pcstr.gif','edit[_1]',
531: 'resource[_2]',"go('".$cfile."');",
532: 'Edit this resource');
533: }
534: }
535: }
536: }
537: }
1.38 www 538: ###
539: ###
1.41 www 540: # Prepare the rest of the buttons
1.120 raeburn 541: my $menuitems;
542: if ($const_space) {
1.274 www 543: #
544: # We are in construction space
545: #
1.128 albertel 546: my ($uname,$thisdisfn) =
1.152 albertel 547: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121 raeburn 548: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131 raeburn 549: if ($currdir =~ m-/$-) {
550: $is_const_dir = 1;
551: } else {
1.267 droeschl 552: $currdir =~ s|[^/]+$||;
1.200 foxr 553: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 554: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 555: #
556: # Probably should be in mydesk.tab
557: #
1.131 raeburn 558: $menuitems=(<<ENDMENUITEMS);
1.208 albertel 559: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
1.200 foxr 560: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
1.259 bisitz 561: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
1.200 foxr 562: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
563: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 564: ENDMENUITEMS
1.131 raeburn 565: }
1.308 raeburn 566: if (ref($bread_crumbs) eq 'ARRAY') {
567: &Apache::lonhtmlcommon::clear_breadcrumbs();
568: foreach my $crumb (@{$bread_crumbs}){
569: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
570: }
571: }
1.203 foxr 572: } elsif ( defined($env{'request.course.id'}) &&
573: $env{'request.symb'} ne '' ) {
1.274 www 574: #
575: # We are in a course and looking at a registred URL
576: # Should probably be in mydesk.tab
577: #
1.120 raeburn 578: $menuitems=(<<ENDMENUITEMS);
1.41 www 579: c&3&1
1.209 www 580: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
581: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
1.77 www 582: c&6&3
583: c&8&1
584: c&8&2
1.106 www 585: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.209 www 586: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
1.41 www 587: ENDMENUITEMS
1.216 albertel 588:
1.243 tempelho 589: my $currentURL = &Apache::loncommon::get_symb();
590: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
591: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
592: $menuitems.="s&9&3&";
593: if(length($annotation) > 0){
594: $menuitems.="anot2.gif";
595: }else{
596: $menuitems.="anot.gif";
597: }
598: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
599: $menuitems.="Make notes and annotations about this resource&&1\n";
600:
1.193 raeburn 601: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
1.294 raeburn 602: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
1.216 albertel 603: $menuitems.=(<<ENDREALRES);
1.259 bisitz 604: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
1.216 albertel 605: ENDREALRES
606: }
1.120 raeburn 607: $menuitems.=(<<ENDREALRES);
1.106 www 608: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
609: s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77 www 610: ENDREALRES
1.120 raeburn 611: }
612: }
1.203 foxr 613: if ($env{'request.uri'} =~ /^\/res/) {
614: $menuitems .= (<<ENDMENUITEMS);
615: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
616: ENDMENUITEMS
617: }
1.41 www 618: my $buttons='';
619: foreach (split(/\n/,$menuitems)) {
620: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 621: my $idx=10*$rest[0]+$rest[1];
622: if (&hidden_button_check() eq 'yes') {
623: if ($idx == 21 ||$idx == 23) {
624: $buttons.=&switch('','',@rest);
625: } else {
626: $buttons.=&clear(@rest);
627: }
628: } else {
629: if ($command eq 's') {
630: $buttons.=&switch('','',@rest);
631: } else {
632: $buttons.=&clear(@rest);
633: }
1.41 www 634: }
635: }
1.148 albertel 636:
637: my $addremote=0;
1.267 droeschl 638: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.301 droeschl 639: if ($addremote) {
640:
1.304 droeschl 641: Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 642:
1.312 droeschl 643: Apache::lonhtmlcommon::add_breadcrumb_tool(
644: 'navigation', @inlineremote[21,23]);
645:
646: if(hidden_button_check() ne 'yes') {
647: Apache::lonhtmlcommon::add_breadcrumb_tool(
1.313 droeschl 648: 'tools', @inlineremote[93,91,81,82,83]);
649:
650: #publish button in construction space
651: if ($env{'request.state'} eq 'construct'){
652: Apache::lonhtmlcommon::add_breadcrumb_tool(
653: 'advtools', @inlineremote[63]);
654: }else{
655: Apache::lonhtmlcommon::add_breadcrumb_tool(
656: 'tools', @inlineremote[63]);
657: }
658:
1.312 droeschl 659:
660: Apache::lonhtmlcommon::add_breadcrumb_tool(
661: 'advtools', @inlineremote[61,71,72,73,92]);
1.301 droeschl 662: }
1.38 www 663: }
664:
1.316 ! droeschl 665: return Apache::lonhtmlcommon::scripttag('', 'start')
! 666: . Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
! 667: . Apache::lonhtmlcommon::scripttag('', 'end');
1.38 www 668: }
669:
1.258 raeburn 670: sub is_course_upload {
671: my ($file,$cnum,$cdom) = @_;
672: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
673: $uploadpath =~ s{^\/}{};
674: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
675: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
676: return 1;
677: }
678: return;
679: }
680:
681: sub edit_course_upload {
682: my ($file,$cnum,$cdom) = @_;
683: my $cfile;
684: if ($file =~/\.(htm|html|css|js|txt)$/) {
685: my $ext = $1;
686: my $url = &Apache::lonnet::hreflocation('',$file);
687: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
688: my @ids=&Apache::lonnet::current_machine_ids();
689: my $dest;
690: if ($home && grep(/^\Q$home\E$/,@ids)) {
691: $dest = $url.'?forceedit=1';
692: } else {
693: unless (&Apache::lonnet::get_locks()) {
694: $dest = '/adm/switchserver?otherserver='.
695: $home.'&role='.$env{'request.role'}.
696: '&url='.$url.'&forceedit=1';
697: }
698: }
699: if ($dest) {
700: $cfile = &HTML::Entities::encode($dest,'"<>&');
701: }
702: }
703: return $cfile;
704: }
705:
1.38 www 706: sub loadevents() {
1.152 albertel 707: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 708: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 709: return 'LONCAPAreg();';
710: }
711:
712: sub unloadevents() {
1.152 albertel 713: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 714: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 715: return 'LONCAPAstale();';
716: }
1.30 www 717:
1.230 albertel 718: sub get_menu_name {
719: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
720: $hostid =~ s/\W//g;
721: return 'LCmenu'.$hostid;
722: }
723:
1.2 www 724: # ================================================================== Raw Config
725:
1.316 ! droeschl 726: #SD
! 727: #this is called by
! 728: #lonmenu
! 729: #
1.3 www 730: sub clear {
731: my ($row,$col)=@_;
1.316 ! droeschl 732: $inlineremote[10*$row+$col]='';
! 733: return '';
1.3 www 734: }
735:
1.40 www 736: # ============================================ Switch a button or create a link
1.25 matthew 737: # Switch acts on the javascript that is executed when a button is clicked.
738: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 739:
1.2 www 740: sub switch {
1.209 www 741: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 742: $act=~s/\$uname/$uname/g;
743: $act=~s/\$udom/$udom/g;
1.88 www 744: $top=&mt($top);
745: $bot=&mt($bot);
746: $desc=&mt($desc);
1.209 www 747: my $idx=10*$row+$col;
748: $category_members{$cat}.=':'.$idx;
749:
1.50 www 750: # Inline Remote
1.316 ! droeschl 751: $img=~s/\.gif$/\.png/;
1.41 www 752: if ($nobreak==2) { return ''; }
1.34 www 753: my $text=$top.' '.$bot;
1.78 www 754: $text=~s/\s*\-\s*//gs;
1.105 www 755:
1.99 www 756: my $pic=
1.225 albertel 757: '<img alt="'.$text.'" src="'.
758: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 759: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.177 albertel 760: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 761: # Main Menu
1.103 www 762: if ($nobreak==3) {
1.209 www 763: $inlineremote[$idx]="\n".
1.177 albertel 764: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 765: '</td><td align="left">'.
1.103 www 766: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
767: } elsif ($nobreak) {
1.209 www 768: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 769: '<td align="left">'.
1.177 albertel 770: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 771: <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 772: } else {
1.209 www 773: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 774: '<td align="left">'.
1.103 www 775: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 776: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 777: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 778: }
1.94 www 779: } else {
1.103 www 780: # Inline Menu
1.316 ! droeschl 781: #SD look here
1.218 www 782: if ($env{'environment.icons'} eq 'iconsonly') {
783: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
784: } else {
785: $inlineremote[$idx]=
1.301 droeschl 786: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.215 www 787: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1.218 www 788: }
1.94 www 789: }
1.56 www 790: return '';
1.2 www 791: }
792:
793: sub secondlevel {
794: my $output='';
795: my
1.209 www 796: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 797: if ($prt eq 'any') {
1.209 www 798: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 799: } elsif ($prt=~/^r(\w+)/) {
800: if ($rol eq $1) {
1.209 www 801: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 802: }
803: }
804: return $output;
805: }
806:
1.56 www 807: sub inlinemenu {
1.210 albertel 808: undef(@inlineremote);
809: undef(%category_members);
1.275 www 810: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 811: &rawconfig(1);
1.309 bisitz 812: my $output='<table><tr>';
1.209 www 813: for (my $col=1; $col<=2; $col++) {
1.241 riegler 814: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 815: for (my $row=1; $row<=8; $row++) {
816: foreach my $cat (keys(%category_members)) {
817: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 818: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 819: $output.='<div class="LC_Box LC_400Box">';
820: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 821: $output.='<table>';
1.240 riegler 822: my %active=();
823: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
824: if ($inlineremote[$menu_item]) {
825: $active{$menu_item}=1;
826: }
827: }
828: foreach my $item (sort(keys(%active))) {
829: $output.=$inlineremote[$item];
830: }
831: $output.='</table>';
1.245 harmsja 832: $output.='</div>';
1.240 riegler 833: }
834: }
835: $output.="</td>";
836: }
837: $output.="</tr></table>";
838: return $output;
839: }
840:
1.2 www 841: sub rawconfig {
1.274 www 842: #
843: # This evaluates mydesk.tab
844: # Need to add more positions and more privileges to deal with all
845: # menu items.
846: #
1.34 www 847: my $textualoverride=shift;
848: my $output='';
1.316 ! droeschl 849: return '' unless $textualoverride;
1.152 albertel 850: my $uname=$env{'user.name'};
851: my $udom=$env{'user.domain'};
852: my $adv=$env{'user.adv'};
1.266 raeburn 853: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 854: my $author=$env{'user.author'};
1.5 www 855: my $crs='';
1.295 raeburn 856: my $crstype='';
1.152 albertel 857: if ($env{'request.course.id'}) {
858: $crs='/'.$env{'request.course.id'};
859: if ($env{'request.course.sec'}) {
860: $crs.='_'.$env{'request.course.sec'};
1.7 www 861: }
1.8 www 862: $crs=~s/\_/\//g;
1.295 raeburn 863: $crstype = &Apache::loncommon::course_type();
1.5 www 864: }
1.152 albertel 865: my $pub=($env{'request.state'} eq 'published');
866: my $con=($env{'request.state'} eq 'construct');
867: my $rol=$env{'request.role'};
868: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 869: foreach my $line (@desklines) {
1.209 www 870: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 871: $prt=~s/\$uname/$uname/g;
872: $prt=~s/\$udom/$udom/g;
1.295 raeburn 873: if ($prt =~ /\$crs/) {
874: next unless ($env{'request.course.id'});
875: next if ($crstype eq 'Community');
876: $prt=~s/\$crs/$crs/g;
877: } elsif ($prt =~ /\$cmty/) {
878: next unless ($env{'request.course.id'});
879: next if ($crstype ne 'Community');
880: $prt=~s/\$cmty/$crs/g;
881: }
1.25 matthew 882: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 883: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 884: if ($pro eq 'clear') {
1.4 www 885: $output.=&clear($row,$col);
1.3 www 886: } elsif ($pro eq 'any') {
1.2 www 887: $output.=&secondlevel(
1.209 www 888: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 889: } elsif ($pro eq 'smp') {
890: unless ($adv) {
891: $output.=&secondlevel(
1.209 www 892: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 893: }
894: } elsif ($pro eq 'adv') {
895: if ($adv) {
896: $output.=&secondlevel(
1.209 www 897: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 898: }
1.231 albertel 899: } elsif ($pro eq 'shc') {
900: if ($show_course) {
901: $output.=&secondlevel(
902: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
903: }
904: } elsif ($pro eq 'nsc') {
905: if (!$show_course) {
906: $output.=&secondlevel(
907: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
908: }
1.81 matthew 909: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 910: my $priv = $1;
911: if ($priv =~ /^mdc(Course|Community)/) {
912: if ($crstype eq $1) {
913: $priv = 'mdc';
914: } else {
915: next;
916: }
917: }
918: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 919: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 920: }
1.295 raeburn 921: } elsif ($pro eq 'course') {
922: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 923: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 924: }
1.295 raeburn 925: } elsif ($pro eq 'community') {
926: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
927: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
928: }
1.124 matthew 929: } elsif ($pro =~ /^courseenv_(.*)$/) {
930: my $key = $1;
1.307 raeburn 931: if ($crstype ne 'Community') {
932: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
933: if ($key eq 'canuse_pdfforms') {
934: if ($env{'request.course.id'} && $coursepref eq '') {
935: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
936: $coursepref = $domdefs{'canuse_pdfforms'};
937: }
938: }
939: if ($coursepref) {
940: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
941: }
1.295 raeburn 942: }
943: } elsif ($pro =~ /^communityenv_(.*)$/) {
944: my $key = $1;
1.307 raeburn 945: if ($crstype eq 'Community') {
946: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
947: if ($key eq 'canuse_pdfforms') {
948: if ($env{'request.course.id'} && $coursepref eq '') {
949: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
950: $coursepref = $domdefs{'canuse_pdfforms'};
951: }
952: }
953: if ($coursepref) {
954: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
955: }
1.124 matthew 956: }
1.81 matthew 957: } elsif ($pro =~ /^course_(.*)$/) {
958: # Check for permissions inside of a course
1.295 raeburn 959: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 960: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
961: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 962: )) {
1.209 www 963: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 964: }
1.295 raeburn 965: } elsif ($pro =~ /^community_(.*)$/) {
966: # Check for permissions inside of a community
967: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
968: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
969: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
970: )) {
971: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
972: }
1.4 www 973: } elsif ($pro eq 'author') {
974: if ($author) {
1.152 albertel 975: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 976: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 977: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 978: # Check that we are on the correct machine
1.29 matthew 979: my $cadom=$requested_domain;
1.152 albertel 980: my $caname=$env{'user.name'};
1.234 raeburn 981: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 982: ($cadom,$caname)=
1.206 albertel 983: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 984: }
985: $act =~ s/\$caname/$caname/g;
1.19 matthew 986: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 987: my $allowed=0;
988: my @ids=&Apache::lonnet::current_machine_ids();
989: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
990: if ($allowed) {
1.209 www 991: $output.=&switch($caname,$cadom,
992: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 993: }
1.6 www 994: }
1.2 www 995: }
1.248 raeburn 996: } elsif ($pro eq 'tools') {
997: my @tools = ('aboutme','blog','portfolio');
998: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 999: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1000: $env{'user.domain'},
1001: $prt,undef,'tools')) {
1002: $output.=&clear($row,$col);
1003: next;
1004: }
1.278 raeburn 1005: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1006: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1007: next;
1008: }
1009: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1010: next;
1011: }
1.279 raeburn 1012: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1013: if (!$showreqcrs) {
1.248 raeburn 1014: $output.=&clear($row,$col);
1015: next;
1016: }
1017: }
1018: $prt='any';
1019: $output.=&secondlevel(
1020: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1021: }
1.13 harris41 1022: }
1.2 www 1023: return $output;
1024: }
1025:
1.279 raeburn 1026: sub check_for_rcrs {
1027: my $showreqcrs = 0;
1.280 raeburn 1028: my @reqtypes = ('official','unofficial','community');
1029: foreach my $type (@reqtypes) {
1.279 raeburn 1030: if (&Apache::lonnet::usertools_access($env{'user.name'},
1031: $env{'user.domain'},
1032: $type,undef,'requestcourses')) {
1033: $showreqcrs = 1;
1034: last;
1035: }
1036: }
1.280 raeburn 1037: if (!$showreqcrs) {
1038: foreach my $type (@reqtypes) {
1039: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1040: $showreqcrs = 1;
1041: last;
1042: }
1043: }
1044: }
1.279 raeburn 1045: return $showreqcrs;
1046: }
1047:
1.1 www 1048: # ====================================================================== Footer
1049:
1.122 albertel 1050: sub nav_control_js {
1.152 albertel 1051: my $nav=($env{'environment.remotenavmap'} eq 'on');
1.122 albertel 1052: return (<<NAVCONTROL);
1053: var w_loncapanav_flag="$nav";
1054:
1055:
1056: function gonav(url) {
1057: if (w_loncapanav_flag != 1) {
1058: gopost(url,'');
1059: } else {
1060: navwindow=window.open(url,
1061: "loncapanav","height=600,width=400,scrollbars=1");
1062: }
1063: }
1064: NAVCONTROL
1065: }
1066:
1.306 raeburn 1067: sub dc_popup_js {
1068: my %lt = &Apache::lonlocal::texthash(
1069: more => '(More ...)',
1070: less => '(Less ...)',
1071: );
1072: return <<"END";
1073:
1074: function showCourseID() {
1075: document.getElementById('dccid').style.display='block';
1076: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1077: document.getElementById('dccid').style.textFace='normal';
1.306 raeburn 1078: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
1079: return;
1080: }
1081:
1082: function hideCourseID() {
1083: document.getElementById('dccid').style.display='none';
1084: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
1085: return;
1086: }
1087:
1088: END
1089:
1090: }
1091:
1.42 www 1092: sub utilityfunctions {
1.152 albertel 1093: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.316 ! droeschl 1094: if ($currenturl =~ m{^/adm/wrapper/ext/}
! 1095: && $env{'request.external.querystring'} ) {
1.293 raeburn 1096: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1097: }
1.183 www 1098: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1099:
1.152 albertel 1100: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.122 albertel 1101: my $nav_control=&nav_control_js();
1.175 albertel 1102:
1.306 raeburn 1103: my $dc_popup_cid;
1104: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1105: $env{'course.'.$env{'request.course.id'}.
1106: '.domain'}.'/'})) {
1107: $dc_popup_cid = &dc_popup_js();
1108: }
1109:
1.175 albertel 1110: my $start_page_annotate =
1111: &Apache::loncommon::start_page('Annotator',undef,
1112: {'only_body' => 1,
1113: 'js_ready' => 1,
1114: 'bgcolor' => '#BBBBBB',
1115: 'add_entries' => {
1116: 'onload' => 'javascript:document.goannotate.submit();'}});
1117:
1.205 albertel 1118: my $end_page_annotate =
1119: &Apache::loncommon::end_page({'js_ready' => 1});
1120:
1.175 albertel 1121: my $start_page_bookmark =
1122: &Apache::loncommon::start_page('Bookmarks',undef,
1123: {'only_body' => 1,
1124: 'js_ready' => 1,
1125: 'bgcolor' => '#BBBBBB',});
1126:
1.205 albertel 1127: my $end_page_bookmark =
1.175 albertel 1128: &Apache::loncommon::end_page({'js_ready' => 1});
1129:
1.42 www 1130: return (<<ENDUTILITY)
1131:
1132: var currentURL="$currenturl";
1133: var reloadURL="$currenturl";
1134: var currentSymb="$currentsymb";
1135:
1.114 albertel 1136: $nav_control
1.306 raeburn 1137: $dc_popup_cid
1.114 albertel 1138:
1.42 www 1139: function go(url) {
1140: if (url!='' && url!= null) {
1141: currentURL = null;
1142: currentSymb= null;
1143: window.location.href=url;
1144: }
1145: }
1146:
1.297 raeburn 1147: function gotop(url) {
1148: if (url!='' && url!= null) {
1149: top.location.href = url;
1150: }
1151: }
1152:
1.42 www 1153: function gopost(url,postdata) {
1154: if (url!='') {
1155: this.document.server.action=url;
1156: this.document.server.postdata.value=postdata;
1157: this.document.server.command.value='';
1158: this.document.server.url.value='';
1159: this.document.server.symb.value='';
1160: this.document.server.submit();
1161: }
1162: }
1163:
1164: function gocmd(url,cmd) {
1165: if (url!='') {
1166: this.document.server.action=url;
1167: this.document.server.postdata.value='';
1168: this.document.server.command.value=cmd;
1169: this.document.server.url.value=currentURL;
1170: this.document.server.symb.value=currentSymb;
1171: this.document.server.submit();
1172: }
1.57 www 1173: }
1174:
1.121 raeburn 1175: function gocstr(url,filename) {
1176: if (url == '/adm/cfile?action=delete') {
1177: this.document.cstrdelete.filename.value = filename
1178: this.document.cstrdelete.submit();
1179: return;
1180: }
1.137 raeburn 1181: if (url == '/adm/printout') {
1182: this.document.cstrprint.postdata.value = filename
1183: this.document.cstrprint.curseed.value = 0;
1184: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1185: if (this.document.lonhomework) {
1186: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1187: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1188: }
1189: if (this.document.lonhomework.problemtype) {
1.164 albertel 1190: if (this.document.lonhomework.problemtype.value) {
1191: this.document.cstrprint.problemtype.value =
1192: this.document.lonhomework.problemtype.value;
1193: } else if (this.document.lonhomework.problemtype.options) {
1194: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1195: if (this.document.lonhomework.problemtype.options[i].selected) {
1196: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1197: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1198: }
1199: }
1200: }
1201: }
1202: }
1203: }
1.137 raeburn 1204: this.document.cstrprint.submit();
1205: return;
1206: }
1.121 raeburn 1207: if (url !='') {
1208: this.document.constspace.filename.value = filename;
1209: this.document.constspace.action = url;
1210: this.document.constspace.submit();
1211: }
1212: }
1213:
1.131 raeburn 1214: function golist(url) {
1215: if (url!='' && url!= null) {
1216: currentURL = null;
1217: currentSymb= null;
1218: top.location.href=url;
1219: }
1220: }
1221:
1222:
1.121 raeburn 1223:
1.57 www 1224: function catalog_info() {
1.102 albertel 1225: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1.57 www 1226: }
1227:
1228: function chat_win() {
1.290 raeburn 1229: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1230: }
1.169 raeburn 1231:
1232: function group_chat(group) {
1233: var url = '/adm/groupchat?group='+group;
1234: var winName = 'LONchat_'+group;
1235: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1236: }
1.175 albertel 1237:
1238: function edit_bookmarks() {
1239: go('');
1240: w_BookmarkPal_flag=1;
1241: bookmarkpal=window.open("/adm/bookmarks",
1242: "BookmarkPal", "width=400,height=505,scrollbars=0");
1243: }
1244:
1245: function annotate() {
1246: w_Annotator_flag=1;
1247: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1248: annotator.document.write(
1249: '$start_page_annotate'
1250: +"<form name='goannotate' target='Annotator' method='post' "
1251: +"action='/adm/annotations'>"
1.217 albertel 1252: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1253: +"<\\/form>"
1.205 albertel 1254: +'$end_page_annotate');
1.175 albertel 1255: annotator.document.close();
1256: }
1257:
1258: function set_bookmark() {
1259: go('');
1260: clienttitle=document.title;
1261: clienthref=location.pathname;
1262: w_bmquery_flag=1;
1263: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1264: bmquery.document.write(
1265: '$start_page_bookmark'
1.260 bisitz 1266: +'<center><form method="post"'
1267: +' name="newlink" action="/adm/bookmarks" target="bmquery" '
1268: +'> <table width="340" height="150" '
1269: +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
1270: +'type="text" name="title" size="45" value="'+clienttitle+'" />'
1271: +'<br />Address:<br /><input type="text" name="address" size="45" '
1272: +'value="'+clienthref+'" /><br /><center><input type="submit" '
1273: +'value="Save" /> <input type="button" value="Close" '
1274: +'onclick="javascript:window.close();" /></center></td>'
1275: +'</tr></table></form></center>'
1.205 albertel 1276: +'$end_page_bookmark' );
1.175 albertel 1277: bmquery.document.close();
1278: }
1279:
1.42 www 1280: ENDUTILITY
1281: }
1282:
1283: sub serverform {
1284: return(<<ENDSERVERFORM);
1.181 albertel 1285: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1286: <input type="hidden" name="postdata" value="none" />
1287: <input type="hidden" name="command" value="none" />
1288: <input type="hidden" name="url" value="none" />
1289: <input type="hidden" name="symb" value="none" />
1290: </form>
1291: ENDSERVERFORM
1292: }
1.113 albertel 1293:
1.121 raeburn 1294: sub constspaceform {
1295: return(<<ENDCONSTSPACEFORM);
1.181 albertel 1296: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 1297: <input type="hidden" name="filename" value="" />
1298: </form>
1.181 albertel 1299: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 1300: <input type="hidden" name="action" value="delete" />
1301: <input type="hidden" name="filename" value="" />
1302: </form>
1.181 albertel 1303: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 1304: <input type="hidden" name="postdata" value="" />
1305: <input type="hidden" name="curseed" value="" />
1306: <input type="hidden" name="problemtype" value="" />
1307: </form>
1308:
1.121 raeburn 1309: ENDCONSTSPACEFORM
1310: }
1311:
1312:
1.113 albertel 1313: sub get_nav_status {
1314: my $navstatus="swmenu.w_loncapanav_flag=";
1.152 albertel 1315: if ($env{'environment.remotenavmap'} eq 'on') {
1.113 albertel 1316: $navstatus.="1";
1317: } else {
1318: $navstatus.="-1";
1319: }
1320: return $navstatus;
1321: }
1322:
1.220 raeburn 1323: sub hidden_button_check {
1324: my $hidden;
1325: if ($env{'request.course.id'} eq '') {
1326: return;
1327: }
1328: if ($env{'request.role.adv'}) {
1329: return;
1330: }
1.232 raeburn 1331: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1332: return $buttonshide;
1.220 raeburn 1333: }
1.184 raeburn 1334:
1.235 raeburn 1335: sub roles_selector {
1336: my ($cdom,$cnum) = @_;
1.298 raeburn 1337: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 1338: my $now = time;
1.262 raeburn 1339: my (%courseroles,%seccount);
1.235 raeburn 1340: my $is_cc;
1341: my $role_selector;
1.298 raeburn 1342: my $ccrole;
1343: if ($crstype eq 'Community') {
1344: $ccrole = 'co';
1345: } else {
1346: $ccrole = 'cc';
1347: }
1348: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1349: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 1350:
1351: if ((($start) && ($start<0)) ||
1352: (($end) && ($end<$now)) ||
1353: (($start) && ($now<$start))) {
1354: $is_cc = 0;
1355: } else {
1356: $is_cc = 1;
1357: }
1358: }
1359: if ($is_cc) {
1.264 raeburn 1360: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1.235 raeburn 1361: } else {
1.262 raeburn 1362: my %gotnosection;
1.235 raeburn 1363: foreach my $item (keys(%env)) {
1.239 raeburn 1364: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 1365: my $role = $1;
1366: my $sec = $2;
1367: next if ($role eq 'gr');
1368: my ($start,$end) = split(/\./,$env{$item});
1369: next if (($start && $start > $now) || ($end && $end < $now));
1370: if ($sec eq '') {
1.239 raeburn 1371: if (!$gotnosection{$role}) {
1372: $seccount{$role} ++;
1373: $gotnosection{$role} = 1;
1374: }
1.235 raeburn 1375: }
1376: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 1377: if ($sec ne '') {
1.264 raeburn 1378: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 1379: push(@{$courseroles{$role}},$sec);
1380: $seccount{$role} ++;
1381: }
1382: }
1383: } else {
1384: @{$courseroles{$role}} = ();
1385: if ($sec ne '') {
1386: $seccount{$role} ++;
1.235 raeburn 1387: push(@{$courseroles{$role}},$sec);
1388: }
1389: }
1390: }
1391: }
1392: }
1.286 raeburn 1393: my $switchtext;
1394: if ($crstype eq 'Community') {
1395: $switchtext = &mt('Switch community role to...')
1396: } else {
1397: $switchtext = &mt('Switch course role to...')
1398: }
1.298 raeburn 1399: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235 raeburn 1400: if (keys(%courseroles) > 1) {
1.239 raeburn 1401: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1.235 raeburn 1402: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1403: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286 raeburn 1404: $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235 raeburn 1405: foreach my $role (@roles_order) {
1406: if (defined($courseroles{$role})) {
1.298 raeburn 1407: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1.235 raeburn 1408: }
1409: }
1410: foreach my $role (sort(keys(%courseroles))) {
1411: if ($role =~ /^cr/) {
1412: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1413: }
1414: }
1415: $role_selector .= '</select>'."\n".
1416: '<input type="hidden" name="destinationurl" value="'.
1.282 amueller 1417: &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n".
1.235 raeburn 1418: '<input type="hidden" name="gotorole" value="1" />'."\n".
1419: '<input type="hidden" name="selectrole" value="" />'."\n".
1420: '<input type="hidden" name="switch" value="1" />'."\n".
1421: '</form>';
1422: }
1423: return $role_selector;
1424: }
1425:
1.262 raeburn 1426: sub get_all_courseroles {
1427: my ($cdom,$cnum,$courseroles,$seccount) = @_;
1428: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
1429: return;
1430: }
1431: my ($result,$cached) =
1432: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1433: if (defined($cached)) {
1434: if (ref($result) eq 'HASH') {
1435: if ((ref($result->{'roles'}) eq 'HASH') &&
1436: (ref($result->{'seccount'}) eq 'HASH')) {
1437: %{$courseroles} = %{$result->{'roles'}};
1438: %{$seccount} = %{$result->{'seccount'}};
1439: return;
1440: }
1441: }
1442: }
1443: my %gotnosection;
1444: my %adv_roles =
1445: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1446: foreach my $role (keys(%adv_roles)) {
1447: my ($urole,$usec) = split(/:/,$role);
1448: if (!$gotnosection{$urole}) {
1449: $seccount->{$urole} ++;
1450: $gotnosection{$urole} = 1;
1451: }
1452: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1453: if ($usec ne '') {
1454: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1455: push(@{$courseroles->{$urole}},$usec);
1456: $seccount->{$urole} ++;
1457: }
1458: }
1459: } else {
1460: @{$courseroles->{$urole}} = ();
1461: if ($usec ne '') {
1462: $seccount->{$urole} ++;
1463: push(@{$courseroles->{$urole}},$usec);
1464: }
1465: }
1466: }
1467: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1468: @{$courseroles->{'st'}} = ();
1469: if (keys(%sections_count) > 0) {
1470: push(@{$courseroles->{'st'}},keys(%sections_count));
1471: $seccount->{'st'} = scalar(keys(%sections_count));
1472: }
1473: my $rolehash = {
1474: 'roles' => $courseroles,
1475: 'seccount' => $seccount,
1476: };
1477: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1478: return;
1479: }
1480:
1.235 raeburn 1481: sub jump_to_role {
1.239 raeburn 1482: my ($cdom,$cnum,$seccount,$courseroles) = @_;
1483: my %lt = &Apache::lonlocal::texthash(
1484: this => 'This role has section(s) associated with it.',
1485: ente => 'Enter a specific section.',
1486: orlb => 'Enter a specific section, or leave blank for no section.',
1487: avai => 'Available sections are:',
1488: youe => 'You entered an invalid section choice:',
1489: plst => 'Please try again',
1490: );
1491: my $js;
1492: if (ref($courseroles) eq 'HASH') {
1493: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1494: ' var numsec = new Array();'."\n".
1495: ' var rolesections = new Array();'."\n".
1496: ' var rolenames = new Array();'."\n".
1497: ' var roleseclist = new Array();'."\n";
1498: my @items = keys(%{$courseroles});
1499: for (my $i=0; $i<@items; $i++) {
1500: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1501: my ($secs,$secstr);
1502: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1503: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1504: $secs = join('","',@sections);
1505: $secstr = join(', ',@sections);
1506: }
1507: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1508: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1509: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1510: }
1511: }
1.273 droeschl 1512: return <<"END";
1.235 raeburn 1513: <script type="text/javascript">
1.273 droeschl 1514: //<![CDATA[
1.235 raeburn 1515: function adhocRole(roleitem) {
1.239 raeburn 1516: $js
1.235 raeburn 1517: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1518: if (newrole == '') {
1519: return;
1520: }
1.239 raeburn 1521: var fullrole = newrole+'./$cdom/$cnum';
1522: var selidx = '';
1523: for (var i=0; i<rolenames.length; i++) {
1524: if (rolenames[i] == newrole) {
1525: selidx = i;
1526: }
1527: }
1528: var secok = 1;
1529: var secchoice = '';
1530: if (selidx >= 0) {
1531: if (numsec[selidx] > 1) {
1532: secok = 0;
1533: var numrolesec = rolesections[selidx].length;
1534: var msgidx = numsec[selidx] - numrolesec;
1535: secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1536: if (secchoice == '') {
1537: if (msgidx > 0) {
1538: secok = 1;
1539: }
1540: } else {
1541: for (var j=0; j<rolesections[selidx].length; j++) {
1542: if (rolesections[selidx][j] == secchoice) {
1543: secok = 1;
1544: }
1545: }
1546: }
1547: } else {
1548: if (rolesections[selidx].length == 1) {
1549: secchoice = rolesections[selidx][0];
1550: }
1551: }
1552: }
1553: if (secok == 1) {
1554: if (secchoice != '') {
1555: fullrole += '/'+secchoice;
1556: }
1557: } else {
1558: document.rolechooser.elements[roleitem].selectedIndex = 0;
1559: if (secchoice != null) {
1560: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1561: }
1562: return;
1563: }
1564: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 1565: return;
1566: }
1567: itemid = retrieveIndex('gotorole');
1568: if (itemid != -1) {
1.239 raeburn 1569: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 1570: }
1.239 raeburn 1571: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235 raeburn 1572: document.rolechooser.selectrole.value = '1';
1573: document.rolechooser.submit();
1574: return;
1575: }
1576:
1577: function retrieveIndex(item) {
1578: for (var i=0;i<document.rolechooser.elements.length;i++) {
1579: if (document.rolechooser.elements[i].name == item) {
1580: return i;
1581: }
1582: }
1583: return -1;
1584: }
1.273 droeschl 1585: // ]]>
1.235 raeburn 1586: </script>
1587: END
1588: }
1589:
1590:
1.2 www 1591: # ================================================================ Main Program
1592:
1.16 harris41 1593: BEGIN {
1.166 albertel 1594: if (! defined($readdesk)) {
1.283 droeschl 1595: {
1596: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1597: if ( CORE::open( my $config,"<$tabfile") ) {
1598: while (my $configline=<$config>) {
1599: $configline=(split(/\#/,$configline))[0];
1600: $configline=~s/^\s+//;
1601: chomp($configline);
1.209 www 1602: if ($configline=~/^cat\:/) {
1.283 droeschl 1603: my @entries=split(/\:/,$configline);
1604: $category_positions{$entries[2]}=$entries[1];
1605: $category_names{$entries[2]}=$entries[3];
1606: } elsif ($configline=~/^prim\:/) {
1607: my @entries = (split(/\:/, $configline))[1..5];
1608: push @primary_menu, \@entries;
1609: } elsif ($configline=~/^scnd\:/) {
1610: my @entries = (split(/\:/, $configline))[1..5];
1611: push @secondary_menu, \@entries;
1612: } elsif ($configline) {
1613: push(@desklines,$configline);
1614: }
1615: }
1616: CORE::close($config);
1617: }
1618: }
1619: $readdesk='done';
1.2 www 1620: }
1621: }
1.30 www 1622:
1.1 www 1623: 1;
1624: __END__
1625:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>