Annotation of loncom/interface/lonmenu.pm, revision 1.315.2.3
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.315.2.3! raeburn 4: # $Id: lonmenu.pm,v 1.315.2.2 2010/08/14 21:38:08 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: #
1.269 droeschl 29: # There is one parameter controlling the action of this module:
1.48 www 30: #
31: # environment.remote - if this is 'on', the routines controll the remote
1.269 droeschl 32: # control, otherwise they render the main window controls;
1.1 www 33:
1.244 jms 34: =head1 NAME
35:
36: Apache::lonmenu
37:
38: =head1 SYNOPSIS
39:
40: Coordinates the response to clicking an image.
41:
42: This is part of the LearningOnline Network with CAPA project
43: described at http://www.lon-capa.org.
44:
1.314 droeschl 45: =head1 GLOBAL VARIABLES
46:
47: =over
48:
49: =item @desklines
50:
51: Each element of this array contains a line of mydesk.tab that doesn't start with
52: cat, prim or scnd.
53: It gets filled in the BEGIN block of this module.
54:
55: =item %category_names
56:
57: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
58: start with cat, the values are strings representing titles.
59: It gets filled in the BEGIN block of this module.
60:
61: =item %category_members
62:
63: TODO
64:
65: =item %category_positions
66:
67: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
68: start with cat, its values are position vectors (column, row).
69: It gets filled in the BEGIN block of this module.
70:
71: =item $readdesk
72:
73: Indicates that mydesk.tab has been read.
74: It is set to 'done' in the BEGIN block of this module.
75:
76: =item @primary_menu
77:
78: The elements of this array reference arrays that are made up of the components
79: of those lines of mydesk.tab that start with prim.
80: It is used by primary_menu() to generate the corresponding menu.
81: It gets filled in the BEGIN block of this module.
82:
83: =item @secondary_menu
84:
85: The elements of this array reference arrays that are made up of the components
86: of those lines of mydesk.tab that start with scnd.
87: It is used by secondary_menu() to generate the corresponding menu.
88: It gets filled in the BEGIN block of this module.
89:
90: =back
91:
1.244 jms 92: =head1 SUBROUTINES
93:
94: =over
95:
1.314 droeschl 96: =item prep_menuitems(\@menuitem)
97:
98: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
99: secondary_menu().
100:
101: =item primary_menu()
102:
103: This routine evaluates @primary_menu and returns XHTML for the menu
104: that contains following links: About, Message, Roles, Help, Logout
105: @primary_menu is filled within the BEGIN block of this module with
106: entries from mydesk.tab
107:
108: =item secondary_menu()
109:
110: Same as primary_menu() but operates on @secondary_menu.
111:
1.244 jms 112: =item show_return_link()
113:
114: =item registerurl()
115:
116: This gets called in the header section
117:
118: =item innerregister()
119:
120: This gets called in order to register a URL, both with the Remote
121: and in the body of the document
122:
123: =item loadevents()
124:
125: =item unloadevents()
126:
127: =item startupremote()
128:
129: =item setflags()
130:
131: =item maincall()
132:
133: =item load_remote_msg()
134:
135: =item get_menu_name()
136:
137: =item reopenmenu()
138:
139: =item open()
140:
141: Open the menu
142:
143: =item clear()
144:
145: =item switch()
146:
147: Switch a button or create a link
148: Switch acts on the javascript that is executed when a button is clicked.
149: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
150:
151: =item secondlevel()
152:
153: =item openmenu()
154:
155: =item inlinemenu()
156:
157: =item rawconfig()
158:
159: =item close()
160:
161: =item footer()
162:
163: =item utilityfunctions()
164:
165: =item serverform()
166:
167: =item constspaceform()
168:
169: =item get_nav_status()
170:
171: =item hidden_button_check()
172:
173: =item roles_selector()
174:
175: =item jump_to_role()
176:
177: =back
178:
179: =cut
180:
1.1 www 181: package Apache::lonmenu;
182:
183: use strict;
1.152 albertel 184: use Apache::lonnet;
1.47 matthew 185: use Apache::lonhtmlcommon();
1.115 albertel 186: use Apache::loncommon();
1.127 albertel 187: use Apache::lonenc();
1.88 www 188: use Apache::lonlocal;
1.207 foxr 189: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 190: use HTML::Entities();
1.88 www 191:
1.283 droeschl 192: use vars qw(@desklines %category_names %category_members %category_positions
193: $readdesk @primary_menu @secondary_menu);
1.88 www 194:
1.56 www 195: my @inlineremote;
1.38 www 196:
1.283 droeschl 197: sub prep_menuitem {
1.291 raeburn 198: my ($menuitem) = @_;
199: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 200: my $link;
201: if ($$menuitem[1]) { # graphical Link
202: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 203: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
204: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 205: } else { # textual Link
1.291 raeburn 206: $link = &mt($$menuitem[3]);
207: }
1.310 wenzelju 208: if($$menuitem[4] eq 'newmsg'){ #special style for New Messages
209: return '<li><a href="'.$$menuitem[0].'"><span class="LC_new_message">'.$link.'</span></a></li>';
210: }
1.299 raeburn 211: return '<li><a href="'.$$menuitem[0].'">'.$link.'</a></li>';
1.283 droeschl 212: }
213:
214: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
215: # that contains following links:
216: # About, Message, Roles, Help, Logout
217: # @primary_menu is filled within the BEGIN block of this module with
218: # entries from mydesk.tab
219: sub primary_menu {
220: my $menu;
221: # each element of @primary contains following array:
222: # (link url, icon path, alt text, link text, condition)
1.315.2.1 raeburn 223: my $public;
224: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
225: || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
226: $public = 1;
227: }
1.283 droeschl 228: foreach my $menuitem (@primary_menu) {
229: # evaluate conditions
1.296 droeschl 230: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 231: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 232: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 233: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 234: && !&Apache::lonmsg::mynewmail(); #
1.315.2.1 raeburn 235: next if $$menuitem[4] !~ /public/ ##we've a public user,
236: && $public; ##who should not see all
237: ##links
238: next if $$menuitem[4] eq 'onlypublic'# hide links which are
239: && !$public; # only visible to public
240: # users
1.283 droeschl 241: next if $$menuitem[4] eq 'roles' ##show links depending on
1.315.2.1 raeburn 242: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 243: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 244: && !&Apache::loncommon::show_course(); ##
1.315.2.1 raeburn 245:
246:
1.283 droeschl 247: if ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.291 raeburn 248: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.283 droeschl 249: } else {
1.296 droeschl 250: my @items = @{$menuitem};
251: $items[0] = 'javascript:'.$menuitem->[0].';';
252: $menu .= &prep_menuitem(\@items);
1.283 droeschl 253: }
1.291 raeburn 254: }
1.283 droeschl 255:
1.291 raeburn 256: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 257: }
258:
1.315.2.2 raeburn 259: #returns hashref {user=>'',dom=>''} containing:
260: # own name, domain if user is au
261: # name, domain of parent author if user is ca or aa
262: #empty return if user is not an author or not on homeserver
263: #
264: #TODO this should probably be moved somewhere more central
265: #since it can be used by different parts of the system
266: sub getauthor{
267: return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
268:
269: #co- or assistent author?
270: my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
271: ? ($1, $2) #domain, username of the parent author
272: : @env{ ('request.role.domain', 'user.name') }; #own domain, username
273:
274: # current server == home server?
275: my $home = &Apache::lonnet::homeserver($user,$dom);
276: foreach (&Apache::lonnet::current_machine_ids()){
277: return {user => $user, dom => $dom} if $_ eq $home;
278: }
279:
280: # if wrong server
281: return;
282: }
283:
1.283 droeschl 284:
285: sub secondary_menu {
286: my $menu;
287:
1.286 raeburn 288: my $crstype = &Apache::loncommon::course_type();
1.315.2.2 raeburn 289: my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'}
290: ? "/$env{'request.course.sec'}"
291: : '');
292: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
293: my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
294: my $author = getauthor();
295:
1.286 raeburn 296: my $showlink = &show_return_link();
297: my %groups = &Apache::lonnet::get_active_groups(
298: $env{'user.domain'}, $env{'user.name'},
299: $env{'course.' . $env{'request.course.id'} . '.domain'},
300: $env{'course.' . $env{'request.course.id'} . '.num'});
1.283 droeschl 301: foreach my $menuitem (@secondary_menu) {
302: # evaluate conditions
1.296 droeschl 303: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 304: next if $$menuitem[4] ne 'always'
1.315.2.2 raeburn 305: && $$menuitem[4] ne 'author'
1.283 droeschl 306: && !$env{'request.course.id'};
307: next if $$menuitem[4] eq 'showreturn'
1.286 raeburn 308: && !$showlink
1.283 droeschl 309: && !($env{'request.state'} eq 'construct');
310: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 311: && !$canedit;
312: next if $$menuitem[4] eq 'mdcCourse'
313: && $crstype eq 'Community';
314: next if $$menuitem[4] eq 'mdcCommunity'
315: && $crstype ne 'Community';
316: next if $$menuitem[4] =~ /^remotenav/
1.283 droeschl 317: && $env{'environment.remotenavmap'} ne 'on';
1.286 raeburn 318: next if $$menuitem[4] =~ /noremotenav/
1.283 droeschl 319: && $env{'environment.remotenavmap'} eq 'on';
1.295 raeburn 320: next if $$menuitem[4] =~ /^(no|)remotenav$/
321: && $crstype eq 'Community';
322: next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/
323: && $crstype ne 'Community';
1.283 droeschl 324: next if $$menuitem[4] =~ /showgroups$/
1.300 raeburn 325: && !$canviewgrps
1.286 raeburn 326: && !%groups;
1.315.2.2 raeburn 327: next if $$menuitem[4] eq 'author'
328: && !$author;
1.283 droeschl 329:
1.286 raeburn 330: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 331: # special treatment for role selector
1.298 raeburn 332: my $roles_selector = &roles_selector(
1.283 droeschl 333: $env{'course.' . $env{'request.course.id'} . '.domain'},
334: $env{'course.' . $env{'request.course.id'} . '.num'} );
335:
336: $menu .= $roles_selector ? "<li>$roles_selector</li>"
337: : '';
1.296 droeschl 338: } elsif ($env{'environment.remotenavmap'} eq 'on') {
339: # open link using javascript when remote navmap is activated
340: my @items = @{$menuitem};
341: if ($menuitem->[4] eq 'remotenav') {
342: $items[0] = "javascript:gonav('$menuitem->[0]');";
1.291 raeburn 343: } else {
1.296 droeschl 344: $items[0] = "javascript:go('$menuitem->[0]');";
1.291 raeburn 345: }
1.296 droeschl 346: $menu .= &prep_menuitem(\@items);
347: } else {
348: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 349: }
350: }
351: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 352: my $escurl = &escape( &Apache::lonenc::check_encrypt(
353: $env{'request.noversionuri'}));
1.283 droeschl 354:
1.291 raeburn 355: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
356: $env{'request.symb'}));
1.283 droeschl 357:
358: if ( $env{'request.state'} eq 'construct'
359: and ( $env{'request.noversionuri'} eq ''
360: || !defined($env{'request.noversionuri'})))
361: {
362: ($escurl = $env{'request.filename'}) =~
363: s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
364:
1.291 raeburn 365: $escurl = &escape($escurl);
1.283 droeschl 366: }
367: $menu =~ s/\[url\]/$escurl/g;
368: $menu =~ s/\[symb\]/$escsymb/g;
369: }
1.315.2.2 raeburn 370: $menu =~ s/\[uname\]/$$author{user}/g;
371: $menu =~ s/\[udom\]/$$author{dom}/g;
1.283 droeschl 372:
1.285 wenzelju 373: return "<ul id=\"LC_secondary_menu\">$menu</ul>";
1.283 droeschl 374: }
375:
1.228 albertel 376: sub show_return_link {
1.315.2.1 raeburn 377: if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)})
378: || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) {
379:
380: return if ($env{'form.register'});
381: }
1.228 albertel 382: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
383: $env{'request.symb'} eq '')
384: ||
385: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
386: ||
387: (($env{'request.noversionuri'}=~/^\/adm\//) &&
388: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
389: ($env{'request.noversionuri'}!~
1.315.2.1 raeburn 390: m[^/adm/.*/(smppg|bulletinboard)($|\?)])
1.228 albertel 391: ));
392: }
393:
1.38 www 394:
395: sub registerurl {
1.173 albertel 396: my ($forcereg) = @_;
1.38 www 397: my $result = '';
1.175 albertel 398: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.66 albertel 399: my $force_title='';
1.152 albertel 400: if ($env{'request.state'} eq 'construct') {
1.66 albertel 401: $force_title=&Apache::lonxml::display_title();
402: }
1.269 droeschl 403: if (($env{'environment.remote'} eq 'off') ||
1.152 albertel 404: ((($env{'request.publicaccess'}) ||
1.83 www 405: (!&Apache::lonnet::is_on_map(
1.183 www 406: &unescape($env{'request.noversionuri'})))) &&
1.38 www 407: (!$forcereg))) {
1.277 bisitz 408: return
409: $result
410: .'<script type="text/javascript">'."\n"
411: .'// <![CDATA['."\n"
412: .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
413: .'// ]]>'."\n"
414: .'</script>'
415: .$force_title;
1.38 www 416: }
1.41 www 417: # Graphical display after login only
1.174 albertel 418: if ($env{'request.registered'} && !$forcereg) { return ''; }
1.173 albertel 419: $result.=&innerregister($forcereg);
1.66 albertel 420: return $result.$force_title;
1.40 www 421: }
422:
423: sub innerregister {
1.308 raeburn 424: my ($forcereg,$titletable,$bread_crumbs) = @_;
1.40 www 425: my $result = '';
1.120 raeburn 426: my ($uname,$thisdisfn);
1.152 albertel 427: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 428: my $is_const_dir = 0;
1.120 raeburn 429:
1.175 albertel 430: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 431:
1.174 albertel 432: $env{'request.registered'} = 1;
1.40 www 433:
1.267 droeschl 434: my $noremote = ($env{'environment.remote'} eq 'off');
1.49 www 435:
1.177 albertel 436: undef(@inlineremote);
1.56 www 437:
1.38 www 438: my $reopen=&Apache::lonmenu::reopenmenu();
1.40 www 439:
1.38 www 440: my $newmail='';
1.267 droeschl 441:
442: if (&Apache::lonmsg::newmail() && !$noremote) {
443: # We have new mail and remote is up
444: $newmail= 'swmenu.setstatus("you have","messages");';
1.233 www 445: }
1.276 droeschl 446:
1.288 raeburn 447: my ($breadcrumb,$separator);
1.267 droeschl 448: if ($noremote
1.177 albertel 449: && ($env{'request.symb'})
450: && ($env{'request.course.id'})) {
1.267 droeschl 451:
452: my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
453: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
454:
455: my $maptitle = &Apache::lonnet::gettitle($mapurl);
456: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.299 raeburn 457: my $contentstext;
458: if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') {
459: $contentstext = &mt('Community Contents');
460: } else {
461: $contentstext = &mt('Course Contents');
462: }
1.315.2.1 raeburn 463: my @crumbs;
464: unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
465: && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
466: @crumbs = ({text => $contentstext,
467: href => "Javascript:gopost('/adm/navmaps','')"});
468: }
1.289 raeburn 469: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
470: push(@crumbs, {text => '...',
471: no_mt => 1});
472: }
1.268 droeschl 473:
474: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
475: && $maptitle ne 'default.sequence'
476: && $maptitle ne $coursetitle);
477:
478: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
479:
1.291 raeburn 480: &Apache::lonhtmlcommon::clear_breadcrumbs();
481: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.315.2.2 raeburn 482:
1.301 droeschl 483: #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.288 raeburn 484: unless (($env{'request.state'} eq 'edit') || ($newmail) ||
485: ($env{'request.state'} eq 'construct') ||
486: ($env{'form.register'})) {
487: $separator = &Apache::loncommon::head_subbox();
488: }
1.267 droeschl 489: #
1.315.2.2 raeburn 490: } elsif (!$const_space){
491: #a situation when we're looking at a resource outside of context of a
492: #course or construction space (e.g. with cumulative rights)
493: &Apache::lonhtmlcommon::clear_breadcrumbs();
494: &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
1.65 www 495: }
1.152 albertel 496: if ($env{'request.state'} eq 'construct') {
1.131 raeburn 497: $newmail = $titletable;
1.267 droeschl 498: }
499: my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
500: my $tablestart = ( $noremote ? '<table id="LC_menubuttons">' : '');
501: my $tableend = ( $noremote ? '</table>' : '');
1.41 www 502: # =============================================================================
503: # ============================ This is for URLs that actually can be registered
1.296 droeschl 504: if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) {
1.40 www 505: # -- This applies to homework problems for users with grading privileges
1.152 albertel 506: my $crs='/'.$env{'request.course.id'};
507: if ($env{'request.course.sec'}) {
508: $crs.='_'.$env{'request.course.sec'};
1.107 albertel 509: }
510: $crs=~s/\_/\//g;
511:
1.38 www 512: my $hwkadd='';
1.152 albertel 513: if ($env{'request.symb'} ne '' &&
1.161 albertel 514: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
1.79 www 515: if (&Apache::lonnet::allowed('mgr',$crs)) {
1.259 bisitz 516: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
1.40 www 517: "gocmd('/adm/grades','gradingmenu')",
518: 'Modify user grades for this assessment resource');
1.154 www 519: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
520: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
521: "gocmd('/adm/grades','submission')",
522: 'View user submissions for this assessment resource');
1.38 www 523: }
1.107 albertel 524: }
1.152 albertel 525: if ($env{'request.symb'} ne '' &&
1.145 albertel 526: &Apache::lonnet::allowed('opa',$crs)) {
1.107 albertel 527: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
528: "gocmd('/adm/parmset','set')",
1.196 www 529: 'Modify parameter settings for this resource');
1.38 www 530: }
1.40 www 531: # -- End Homework
1.38 www 532: ###
533: ### Determine whether or not to display the 'cstr' button for this
534: ### resource
535: ###
536: my $editbutton = '';
1.258 raeburn 537: my $noeditbutton = 1;
538: my ($cnum,$cdom);
539: if ($env{'request.course.id'}) {
540: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
541: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
542: }
1.152 albertel 543: if ($env{'user.author'}) {
1.234 raeburn 544: if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.274 www 545: #
546: # We have the role of an author
547: #
1.38 www 548: # Set defaults for authors
549: my ($top,$bottom) = ('con-','struct');
1.152 albertel 550: my $action = "go('/priv/".$env{'user.name'}."');";
551: my $cadom = $env{'request.role.domain'};
552: my $caname = $env{'user.name'};
1.236 bisitz 553: my $desc = "Enter my construction space";
1.38 www 554: # Set defaults for co-authors
1.152 albertel 555: if ($env{'request.role'} =~ /^ca/) {
1.206 albertel 556: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38 www 557: ($top,$bottom) = ('co con-','struct');
558: $action = "go('/priv/".$caname."');";
559: $desc = "Enter construction space as co-author";
1.234 raeburn 560: } elsif ($env{'request.role'} =~ /^aa/) {
561: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
562: ($top,$bottom) = ('co con-','struct');
563: $action = "go('/priv/".$caname."');";
564: $desc = "Enter construction space as assistant co-author";
1.38 www 565: }
566: # Check that we are on the correct machine
567: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 568: my $allowed=0;
569: my @ids=&Apache::lonnet::current_machine_ids();
570: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
571: if (!$allowed) {
572: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258 raeburn 573: $noeditbutton = 0;
1.38 www 574: }
575: }
1.274 www 576: #
577: # We are an author for some stuff, but currently do not have the role of author.
578: # Figure out if we have authoring privileges for the resource we are looking at.
579: # This should maybe become a privilege check in lonnet
580: #
1.38 www 581: ##
582: ## Determine if user can edit url.
583: ##
584: my $cfile='';
585: my $cfuname='';
586: my $cfudom='';
1.258 raeburn 587: my $uploaded;
1.315.2.2 raeburn 588: my $switchserver='';
589: my $home;
1.152 albertel 590: if ($env{'request.filename'}) {
591: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258 raeburn 592: if (defined($cnum) && defined($cdom)) {
593: $uploaded = &is_course_upload($file,$cnum,$cdom);
594: }
595: if (!$uploaded) {
596: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
597: # Check that the user has permission to edit this resource
598: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
599: if (defined($cfudom)) {
1.315.2.2 raeburn 600: $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
1.258 raeburn 601: my $allowed=0;
602: my @ids=&Apache::lonnet::current_machine_ids();
603: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
604: if ($allowed) {
605: $cfile=$file;
1.315.2.2 raeburn 606: } else {
607: $switchserver=$file;
1.258 raeburn 608: }
1.38 www 609: }
610: }
1.258 raeburn 611: }
1.38 www 612: # Finally, turn the button on or off
1.315.2.2 raeburn 613: if (($cfile || $switchserver) && !$const_space) {
1.302 raeburn 614: my $nocrsedit;
615: # Suppress display where CC has switched to student role.
616: if ($env{'request.course.id'}) {
617: unless(&Apache::lonnet::allowed('mdc',
618: $env{'request.course.id'})) {
619: $nocrsedit = 1;
620: }
621: }
622: if ($nocrsedit) {
623: $editbutton=&clear(6,1);
624: } else {
1.315.2.3! raeburn 625: my $bot = "go('$cfile')";
1.315.2.2 raeburn 626: if ($switchserver) {
627: if ( $env{'request.symb'} && $env{'request.course.id'} ) {
628: my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
1.315.2.3! raeburn 629: $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
! 630: &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='.
! 631: &HTML::Entities::encode($env{'request.symb'},'"<>&');
! 632: $bot = "need_switchserver('$cfile');";
1.315.2.2 raeburn 633: }
634: }
1.302 raeburn 635: $editbutton=&switch
636: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
1.315.2.3! raeburn 637: $bot,"Edit this resource");
1.302 raeburn 638: $noeditbutton = 0;
639: }
1.38 www 640: } elsif ($editbutton eq '') {
1.191 www 641: $editbutton=&clear(6,1);
1.38 www 642: }
643: }
1.258 raeburn 644: if (($noeditbutton) && ($env{'request.filename'})) {
645: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
646: my $file=&Apache::lonnet::declutter($env{'request.filename'});
647: if (defined($cnum) && defined($cdom)) {
648: if (&is_course_upload($file,$cnum,$cdom)) {
649: my $cfile = &edit_course_upload($file,$cnum,$cdom);
650: if ($cfile) {
651: $editbutton=&switch
652: ('','',6,1,'pcstr.gif','edit[_1]',
653: 'resource[_2]',"go('".$cfile."');",
654: 'Edit this resource');
655: }
656: }
657: }
658: }
659: }
1.38 www 660: ###
661: ###
1.41 www 662: # Prepare the rest of the buttons
1.120 raeburn 663: my $menuitems;
664: if ($const_space) {
1.274 www 665: #
666: # We are in construction space
667: #
1.128 albertel 668: my ($uname,$thisdisfn) =
1.152 albertel 669: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121 raeburn 670: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131 raeburn 671: if ($currdir =~ m-/$-) {
672: $is_const_dir = 1;
673: } else {
1.267 droeschl 674: $currdir =~ s|[^/]+$||;
1.200 foxr 675: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 676: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 677: #
678: # Probably should be in mydesk.tab
679: #
1.131 raeburn 680: $menuitems=(<<ENDMENUITEMS);
1.208 albertel 681: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
1.200 foxr 682: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
1.259 bisitz 683: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
1.200 foxr 684: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
685: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 686: ENDMENUITEMS
1.131 raeburn 687: }
1.308 raeburn 688: if ($noremote) {
689: if (ref($bread_crumbs) eq 'ARRAY') {
690: &Apache::lonhtmlcommon::clear_breadcrumbs();
691: foreach my $crumb (@{$bread_crumbs}){
692: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
693: }
694: }
695: }
1.203 foxr 696: } elsif ( defined($env{'request.course.id'}) &&
697: $env{'request.symb'} ne '' ) {
1.274 www 698: #
699: # We are in a course and looking at a registred URL
700: # Should probably be in mydesk.tab
701: #
1.120 raeburn 702: $menuitems=(<<ENDMENUITEMS);
1.41 www 703: c&3&1
1.209 www 704: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
705: 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 706: c&6&3
707: c&8&1
708: c&8&2
1.106 www 709: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.209 www 710: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
1.41 www 711: ENDMENUITEMS
1.216 albertel 712:
1.243 tempelho 713: my $currentURL = &Apache::loncommon::get_symb();
714: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
715: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
716: $menuitems.="s&9&3&";
717: if(length($annotation) > 0){
718: $menuitems.="anot2.gif";
719: }else{
720: $menuitems.="anot.gif";
721: }
722: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
723: $menuitems.="Make notes and annotations about this resource&&1\n";
724:
1.279 raeburn 725: unless ($noremote) {
726: my $showreqcrs = &check_for_rcrs();
727: if ($showreqcrs) {
728: $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]".
729: "&go('/adm/requestcourse')&Course requests\n";
730: }
731: }
1.315.2.1 raeburn 732: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
1.294 raeburn 733: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
1.216 albertel 734: $menuitems.=(<<ENDREALRES);
1.259 bisitz 735: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
1.216 albertel 736: ENDREALRES
737: }
1.120 raeburn 738: $menuitems.=(<<ENDREALRES);
1.106 www 739: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
740: 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 741: ENDREALRES
1.120 raeburn 742: }
743: }
1.203 foxr 744: if ($env{'request.uri'} =~ /^\/res/) {
745: $menuitems .= (<<ENDMENUITEMS);
746: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
747: ENDMENUITEMS
748: }
1.41 www 749: my $buttons='';
750: foreach (split(/\n/,$menuitems)) {
751: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 752: my $idx=10*$rest[0]+$rest[1];
753: if (&hidden_button_check() eq 'yes') {
754: if ($idx == 21 ||$idx == 23) {
755: $buttons.=&switch('','',@rest);
756: } else {
757: $buttons.=&clear(@rest);
758: }
759: } else {
760: if ($command eq 's') {
761: $buttons.=&switch('','',@rest);
762: } else {
763: $buttons.=&clear(@rest);
764: }
1.41 www 765: }
766: }
1.148 albertel 767:
1.267 droeschl 768: if ($noremote) {
1.148 albertel 769: my $addremote=0;
1.267 droeschl 770: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.148 albertel 771: my $inlinebuttons='';
1.301 droeschl 772: if ($addremote) {
773:
1.304 droeschl 774: Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 775:
1.312 droeschl 776: Apache::lonhtmlcommon::add_breadcrumb_tool(
777: 'navigation', @inlineremote[21,23]);
778:
779: if(hidden_button_check() ne 'yes') {
780: Apache::lonhtmlcommon::add_breadcrumb_tool(
1.313 droeschl 781: 'tools', @inlineremote[93,91,81,82,83]);
782:
783: #publish button in construction space
784: if ($env{'request.state'} eq 'construct'){
785: Apache::lonhtmlcommon::add_breadcrumb_tool(
786: 'advtools', @inlineremote[63]);
787: }else{
788: Apache::lonhtmlcommon::add_breadcrumb_tool(
789: 'tools', @inlineremote[63]);
790: }
1.312 droeschl 791:
1.315.2.1 raeburn 792: unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
793: Apache::lonhtmlcommon::add_breadcrumb_tool(
794: 'advtools', @inlineremote[61,71,72,73,92]);
795: }
1.301 droeschl 796: }
797:
798: # # Registered, textual output
799: # if ( $env{'environment.icons'} eq 'iconsonly' ) {
800: # $inlinebuttons = (<<ENDARROWSINLINE);
801: #<tr><td>
802: #$inlineremote[21] $inlineremote[23]
803: #ENDARROWSINLINE
804: # if ( &hidden_button_check() ne 'yes' ) {
805: # $inlinebuttons .= (<<ENDINLINEICONS);
806: #$inlineremote[61] $inlineremote[63]
807: #$inlineremote[71] $inlineremote[72] $inlineremote[73]
808: #$inlineremote[81] $inlineremote[82] $inlineremote[83]
809: #$inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
810: #ENDINLINEICONS
811: # }
812: # } else { # not iconsonly
813: # if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) {
814: # $inlinebuttons = (<<ENDFIRSTLINE);
815: #<tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
816: #ENDFIRSTLINE
817: # }
818: # if ( &hidden_button_check() ne 'yes' ) {
819: # foreach my $row ( 6 .. 9 ) {
820: # if ( $inlineremote[ ${row} . '1' ] ne ''
821: # || $inlineremote[ $row . '2' ] ne ''
822: # || $inlineremote[ $row . '3' ] ne '' )
823: # {
824: # $inlinebuttons .= <<"ENDLINE";
825: #<tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
826: #ENDLINE
827: # }
828: # }
829: # }
830: # }
831: }
832: $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.41 www 833: $result =(<<ENDREGTEXT);
1.129 albertel 834: <script type="text/javascript">
1.42 www 835: // BEGIN LON-CAPA Internal
836: </script>
1.41 www 837: $timesync
1.267 droeschl 838: $breadcrumb
1.305 bisitz 839: <!-- $tablestart -->
840: <!-- $inlinebuttons -->
841: <!-- $tableend -->
1.224 albertel 842: $newmail
1.305 bisitz 843: <!-- $separator -->
1.129 albertel 844: <script type="text/javascript">
1.64 www 845: // END LON-CAPA Internal
1.42 www 846: </script>
847:
1.41 www 848: ENDREGTEXT
849: # Registered, graphical output
850: } else {
1.152 albertel 851: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.183 www 852: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
1.152 albertel 853: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.113 albertel 854: my $navstatus=&get_nav_status();
1.140 albertel 855: my $clearcstr;
1.148 albertel 856:
1.152 albertel 857: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
1.41 www 858: $result = (<<ENDREGTHIS);
1.38 www 859:
1.129 albertel 860: <script type="text/javascript">
1.277 bisitz 861: // <![CDATA[
1.150 albertel 862: // BEGIN LON-CAPA Internal
1.42 www 863: var swmenu=null;
1.38 www 864:
865: function LONCAPAreg() {
866: swmenu=$reopen;
867: swmenu.clearTimeout(swmenu.menucltim);
868: $timesync
869: $newmail
1.41 www 870: $buttons
1.84 www 871: swmenu.currentURL="$requri";
1.85 www 872: swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125 albertel 873: swmenu.currentSymb="$cursymb";
874: swmenu.reloadSymb="$cursymb";
1.38 www 875: swmenu.currentStale=0;
1.113 albertel 876: $navstatus
1.38 www 877: $hwkadd
878: $editbutton
879: }
880:
881: function LONCAPAstale() {
882: swmenu=$reopen
883: swmenu.currentStale=1;
884: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
885: swmenu.switchbutton
886: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
887: }
888: swmenu.clearbut(7,2);
889: swmenu.clearbut(7,3);
890: swmenu.menucltim=swmenu.setTimeout(
891: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.140 albertel 892: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
1.38 www 893: 2000);
894: }
895:
1.150 albertel 896: // END LON-CAPA Internal
1.277 bisitz 897: // ]]>
1.38 www 898: </script>
899: ENDREGTHIS
1.41 www 900: }
901: # =============================================================================
1.38 www 902: } else {
1.41 www 903: # ========================================== This can or will not be registered
1.267 droeschl 904: if ($noremote) {
1.269 droeschl 905: # Not registered
1.267 droeschl 906: $result= (<<ENDDONOTREGTEXT);
1.41 www 907: ENDDONOTREGTEXT
908: } else {
909: # Not registered, graphical
910: $result = (<<ENDDONOTREGTHIS);
1.38 www 911:
1.129 albertel 912: <script type="text/javascript">
1.277 bisitz 913: // <![CDATA[
1.38 www 914: // BEGIN LON-CAPA Internal
1.42 www 915: var swmenu=null;
1.38 www 916:
917: function LONCAPAreg() {
918: swmenu=$reopen
919: $timesync
920: swmenu.currentStale=1;
921: swmenu.clearbut(2,1);
922: swmenu.clearbut(2,3);
923: swmenu.clearbut(8,1);
924: swmenu.clearbut(8,2);
925: swmenu.clearbut(8,3);
926: if (swmenu.currentURL) {
927: swmenu.switchbutton
928: (3,1,'reload.gif','return','location','go(currentURL)');
929: } else {
930: swmenu.clearbut(3,1);
931: }
932: }
933:
934: function LONCAPAstale() {
935: }
936:
937: // END LON-CAPA Internal
1.277 bisitz 938: // ]]>
1.38 www 939: </script>
940: ENDDONOTREGTHIS
1.41 www 941: }
942: # =============================================================================
1.38 www 943: }
944: return $result;
945: }
946:
1.258 raeburn 947: sub is_course_upload {
948: my ($file,$cnum,$cdom) = @_;
949: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
950: $uploadpath =~ s{^\/}{};
951: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
952: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
953: return 1;
954: }
955: return;
956: }
957:
958: sub edit_course_upload {
959: my ($file,$cnum,$cdom) = @_;
960: my $cfile;
961: if ($file =~/\.(htm|html|css|js|txt)$/) {
962: my $ext = $1;
963: my $url = &Apache::lonnet::hreflocation('',$file);
964: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
965: my @ids=&Apache::lonnet::current_machine_ids();
966: my $dest;
967: if ($home && grep(/^\Q$home\E$/,@ids)) {
968: $dest = $url.'?forceedit=1';
969: } else {
970: unless (&Apache::lonnet::get_locks()) {
971: $dest = '/adm/switchserver?otherserver='.
972: $home.'&role='.$env{'request.role'}.
973: '&url='.$url.'&forceedit=1';
974: }
975: }
976: if ($dest) {
977: $cfile = &HTML::Entities::encode($dest,'"<>&');
978: }
979: }
980: return $cfile;
981: }
982:
1.38 www 983: sub loadevents() {
1.152 albertel 984: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 985: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 986: return 'LONCAPAreg();';
987: }
988:
989: sub unloadevents() {
1.152 albertel 990: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 991: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 992: return 'LONCAPAstale();';
993: }
1.30 www 994:
1.32 www 995:
996: sub startupremote {
997: my ($lowerurl)=@_;
1.269 droeschl 998: if ($env{'environment.remote'} eq 'off') {
1.34 www 999: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
1000: }
1.49 www 1001: #
1002: # The Remote actually gets launched!
1003: #
1.32 www 1004: my $configmenu=&rawconfig();
1.183 www 1005: my $esclowerurl=&escape($lowerurl);
1.119 www 1006: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32 www 1007: return(<<ENDREMOTESTARTUP);
1.129 albertel 1008: <script type="text/javascript">
1.277 bisitz 1009: // <![CDATA[
1.118 albertel 1010: var timestart;
1.35 www 1011: function wheelswitch() {
1.118 albertel 1012: if (typeof(document.wheel) != 'undefined') {
1013: if (typeof(document.wheel.spin) != 'undefined') {
1014: var date=new Date();
1015: var waited=Math.round(30-((date.getTime()-timestart)/1000));
1016: document.wheel.spin.value=$message;
1017: }
1018: }
1.35 www 1019: if (window.status=='|') {
1020: window.status='/';
1021: } else {
1022: if (window.status=='/') {
1023: window.status='-';
1024: } else {
1025: if (window.status=='-') {
1026: window.status='\\\\';
1027: } else {
1028: if (window.status=='\\\\') { window.status='|'; }
1029: }
1030: }
1031: }
1032: }
1033:
1.32 www 1034: // ---------------------------------------------------------- The wait function
1035: var canceltim;
1036: function wait() {
1037: if ((menuloaded==1) || (tim==1)) {
1.35 www 1038: window.status='Done.';
1.32 www 1039: if (tim==0) {
1040: clearTimeout(canceltim);
1041: $configmenu
1042: window.location='$lowerurl';
1043: } else {
1.52 www 1044: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32 www 1045: }
1046: } else {
1.35 www 1047: wheelswitch();
1048: setTimeout('wait();',200);
1.32 www 1049: }
1050: }
1051:
1052: function main() {
1.52 www 1053: canceltim=setTimeout('tim=1;',30000);
1.35 www 1054: window.status='-';
1.118 albertel 1055: var date=new Date();
1056: timestart=date.getTime();
1.32 www 1057: wait();
1058: }
1059:
1.277 bisitz 1060: // ]]>
1.32 www 1061: </script>
1062: ENDREMOTESTARTUP
1063: }
1064:
1065: sub setflags() {
1066: return(<<ENDSETFLAGS);
1.129 albertel 1067: <script type="text/javascript">
1.277 bisitz 1068: // <![CDATA[
1.32 www 1069: menuloaded=0;
1070: tim=0;
1.277 bisitz 1071: // ]]>
1.32 www 1072: </script>
1073: ENDSETFLAGS
1074: }
1075:
1076: sub maincall() {
1.269 droeschl 1077: if ($env{'environment.remote'} eq 'off') { return ''; }
1.32 www 1078: return(<<ENDMAINCALL);
1.129 albertel 1079: <script type="text/javascript">
1.277 bisitz 1080: // <![CDATA[
1.32 www 1081: main();
1.277 bisitz 1082: // ]]>
1.32 www 1083: </script>
1084: ENDMAINCALL
1085: }
1.118 albertel 1086:
1087: sub load_remote_msg {
1088: my ($lowerurl)=@_;
1089:
1.269 droeschl 1090: if ($env{'environment.remote'} eq 'off') { return ''; }
1.118 albertel 1091:
1.183 www 1092: my $esclowerurl=&escape($lowerurl);
1.261 bisitz 1093: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
1094: ,'<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">'
1095: ,'</a>');
1.118 albertel 1096: return(<<ENDREMOTEFORM);
1097: <p>
1098: <form name="wheel">
1.119 www 1099: <input name="spin" type="text" size="60" />
1.118 albertel 1100: </form>
1101: </p>
1102: <p>$link</p>
1103: ENDREMOTEFORM
1104: }
1.230 albertel 1105:
1106: sub get_menu_name {
1107: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
1108: $hostid =~ s/\W//g;
1109: return 'LCmenu'.$hostid;
1110: }
1111:
1.30 www 1112:
1113: sub reopenmenu {
1.269 droeschl 1114: if ($env{'environment.remote'} eq 'off') { return ''; }
1.230 albertel 1115: my $menuname = &get_menu_name();
1.47 matthew 1116: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1117: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30 www 1118: }
1119:
1.1 www 1120:
1121: sub open {
1.22 www 1122: my $returnval='';
1.269 droeschl 1123: if ($env{'environment.remote'} eq 'off') {
1.277 bisitz 1124: return
1125: '<script type="text/javascript">'."\n"
1126: .'// <![CDATA['."\n"
1127: .'self.name="loncapaclient";'."\n"
1128: .'// ]]>'."\n"
1129: .'</script>';
1.111 albertel 1130: }
1.230 albertel 1131: my $menuname = &get_menu_name();
1.222 albertel 1132:
1133: # unless (shift eq 'unix') {
1.22 www 1134: # resizing does not work on linux because of virtual desktop sizes
1.222 albertel 1135: # $returnval.=(<<ENDRESIZE);
1136: #if (window.screen) {
1137: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1138: # self.moveTo(190,15);
1139: #}
1140: #ENDRESIZE
1141: # }
1.277 bisitz 1142: $returnval=(<<ENDOPEN);
1143: // <![CDATA[
1.35 www 1144: window.status='Opening LON-CAPA Remote Control';
1.272 droeschl 1145: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
1.191 www 1146: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71 www 1147: self.name='loncapaclient';
1.277 bisitz 1148: // ]]>
1.1 www 1149: ENDOPEN
1.129 albertel 1150: return '<script type="text/javascript">'.$returnval.'</script>';
1.1 www 1151: }
1152:
1.2 www 1153:
1154: # ================================================================== Raw Config
1155:
1.3 www 1156: sub clear {
1157: my ($row,$col)=@_;
1.269 droeschl 1158: unless ($env{'environment.remote'} eq 'off') {
1.275 www 1159: if (($row<1) || ($row>13)) { return ''; }
1.35 www 1160: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56 www 1161: } else {
1162: $inlineremote[10*$row+$col]='';
1163: return '';
1164: }
1.3 www 1165: }
1166:
1.40 www 1167: # ============================================ Switch a button or create a link
1.25 matthew 1168: # Switch acts on the javascript that is executed when a button is clicked.
1169: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1170:
1.2 www 1171: sub switch {
1.209 www 1172: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1173: $act=~s/\$uname/$uname/g;
1174: $act=~s/\$udom/$udom/g;
1.88 www 1175: $top=&mt($top);
1176: $bot=&mt($bot);
1177: $desc=&mt($desc);
1.238 www 1178: if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
1179: $img=&mt($img);
1180: }
1.209 www 1181: my $idx=10*$row+$col;
1182: $category_members{$cat}.=':'.$idx;
1183:
1.269 droeschl 1184: unless ($env{'environment.remote'} eq 'off') {
1.275 www 1185: if (($row<1) || ($row>13)) { return ''; }
1.50 www 1186: # Remote
1.34 www 1187: return "\n".
1.35 www 1188: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.34 www 1189: } else {
1.50 www 1190: # Inline Remote
1.213 www 1191: if ($env{'environment.icons'} ne 'classic') {
1192: $img=~s/\.gif$/\.png/;
1193: }
1.41 www 1194: if ($nobreak==2) { return ''; }
1.34 www 1195: my $text=$top.' '.$bot;
1.78 www 1196: $text=~s/\s*\-\s*//gs;
1.105 www 1197:
1.99 www 1198: my $pic=
1.225 albertel 1199: '<img alt="'.$text.'" src="'.
1200: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1201: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.177 albertel 1202: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1203: # Main Menu
1.103 www 1204: if ($nobreak==3) {
1.209 www 1205: $inlineremote[$idx]="\n".
1.177 albertel 1206: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1207: '</td><td align="left">'.
1.103 www 1208: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1209: } elsif ($nobreak) {
1.209 www 1210: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1211: '<td align="left">'.
1.177 albertel 1212: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1213: <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 1214: } else {
1.209 www 1215: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1216: '<td align="left">'.
1.103 www 1217: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1218: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1219: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1220: }
1.94 www 1221: } else {
1.103 www 1222: # Inline Menu
1.218 www 1223: if ($env{'environment.icons'} eq 'iconsonly') {
1224: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
1225: } else {
1226: $inlineremote[$idx]=
1.301 droeschl 1227: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.215 www 1228: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1.218 www 1229: }
1.94 www 1230: }
1.34 www 1231: }
1.56 www 1232: return '';
1.2 www 1233: }
1234:
1235: sub secondlevel {
1236: my $output='';
1237: my
1.209 www 1238: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1239: if ($prt eq 'any') {
1.209 www 1240: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1241: } elsif ($prt=~/^r(\w+)/) {
1242: if ($rol eq $1) {
1.209 www 1243: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1244: }
1245: }
1246: return $output;
1247: }
1248:
1.18 www 1249: sub openmenu {
1.230 albertel 1250: my $menuname = &get_menu_name();
1.269 droeschl 1251: if ($env{'environment.remote'} eq 'off') { return ''; }
1.47 matthew 1252: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1253: return "window.open(".$nothing.",'".$menuname."');";
1.18 www 1254: }
1255:
1.56 www 1256: sub inlinemenu {
1.210 albertel 1257: undef(@inlineremote);
1258: undef(%category_members);
1.275 www 1259: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
1.56 www 1260: &rawconfig(1);
1.309 bisitz 1261: my $output='<table><tr>';
1.209 www 1262: for (my $col=1; $col<=2; $col++) {
1.241 riegler 1263: $output.='<td class="LC_mainmenu_col_fieldset">';
1.209 www 1264: for (my $row=1; $row<=8; $row++) {
1265: foreach my $cat (keys(%category_members)) {
1266: if ($category_positions{$cat} ne "$col,$row") { next; }
1.247 harmsja 1267: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.309 bisitz 1268: $output.='<div class="LC_Box LC_400Box">';
1269: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1.247 harmsja 1270: $output.='<table>';
1.240 riegler 1271: my %active=();
1272: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1273: if ($inlineremote[$menu_item]) {
1274: $active{$menu_item}=1;
1275: }
1276: }
1277: foreach my $item (sort(keys(%active))) {
1278: $output.=$inlineremote[$item];
1279: }
1280: $output.='</table>';
1.245 harmsja 1281: $output.='</div>';
1.240 riegler 1282: }
1283: }
1284: $output.="</td>";
1285: }
1286: $output.="</tr></table>";
1287: return $output;
1288: }
1289:
1.2 www 1290: sub rawconfig {
1.274 www 1291: #
1292: # This evaluates mydesk.tab
1293: # Need to add more positions and more privileges to deal with all
1294: # menu items.
1295: #
1.34 www 1296: my $textualoverride=shift;
1297: my $output='';
1.269 droeschl 1298: unless ($env{'environment.remote'} eq 'off') {
1.35 www 1299: $output.=
1300: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1301: "\nwindow.status='Configuring Remote Control ';";
1.34 www 1302: } else {
1303: unless ($textualoverride) { return ''; }
1304: }
1.152 albertel 1305: my $uname=$env{'user.name'};
1306: my $udom=$env{'user.domain'};
1307: my $adv=$env{'user.adv'};
1.266 raeburn 1308: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1309: my $author=$env{'user.author'};
1.5 www 1310: my $crs='';
1.295 raeburn 1311: my $crstype='';
1.152 albertel 1312: if ($env{'request.course.id'}) {
1313: $crs='/'.$env{'request.course.id'};
1314: if ($env{'request.course.sec'}) {
1315: $crs.='_'.$env{'request.course.sec'};
1.7 www 1316: }
1.8 www 1317: $crs=~s/\_/\//g;
1.295 raeburn 1318: $crstype = &Apache::loncommon::course_type();
1.5 www 1319: }
1.152 albertel 1320: my $pub=($env{'request.state'} eq 'published');
1321: my $con=($env{'request.state'} eq 'construct');
1322: my $rol=$env{'request.role'};
1323: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1324: foreach my $line (@desklines) {
1.209 www 1325: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1326: $prt=~s/\$uname/$uname/g;
1327: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1328: if ($prt =~ /\$crs/) {
1329: next unless ($env{'request.course.id'});
1330: next if ($crstype eq 'Community');
1331: $prt=~s/\$crs/$crs/g;
1332: } elsif ($prt =~ /\$cmty/) {
1333: next unless ($env{'request.course.id'});
1334: next if ($crstype ne 'Community');
1335: $prt=~s/\$cmty/$crs/g;
1336: }
1.25 matthew 1337: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1338: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1339: if ($pro eq 'clear') {
1.4 www 1340: $output.=&clear($row,$col);
1.3 www 1341: } elsif ($pro eq 'any') {
1.2 www 1342: $output.=&secondlevel(
1.209 www 1343: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1344: } elsif ($pro eq 'smp') {
1345: unless ($adv) {
1346: $output.=&secondlevel(
1.209 www 1347: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1348: }
1349: } elsif ($pro eq 'adv') {
1350: if ($adv) {
1351: $output.=&secondlevel(
1.209 www 1352: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1353: }
1.231 albertel 1354: } elsif ($pro eq 'shc') {
1355: if ($show_course) {
1356: $output.=&secondlevel(
1357: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1358: }
1359: } elsif ($pro eq 'nsc') {
1360: if (!$show_course) {
1361: $output.=&secondlevel(
1362: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1363: }
1.81 matthew 1364: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1365: my $priv = $1;
1366: if ($priv =~ /^mdc(Course|Community)/) {
1367: if ($crstype eq $1) {
1368: $priv = 'mdc';
1369: } else {
1370: next;
1371: }
1372: }
1373: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1374: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1375: }
1.295 raeburn 1376: } elsif ($pro eq 'course') {
1377: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1378: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1379: }
1.295 raeburn 1380: } elsif ($pro eq 'community') {
1381: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1382: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1383: }
1.124 matthew 1384: } elsif ($pro =~ /^courseenv_(.*)$/) {
1385: my $key = $1;
1.307 raeburn 1386: if ($crstype ne 'Community') {
1387: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1388: if ($key eq 'canuse_pdfforms') {
1389: if ($env{'request.course.id'} && $coursepref eq '') {
1390: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1391: $coursepref = $domdefs{'canuse_pdfforms'};
1392: }
1393: }
1394: if ($coursepref) {
1395: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1396: }
1.295 raeburn 1397: }
1398: } elsif ($pro =~ /^communityenv_(.*)$/) {
1399: my $key = $1;
1.307 raeburn 1400: if ($crstype eq 'Community') {
1401: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1402: if ($key eq 'canuse_pdfforms') {
1403: if ($env{'request.course.id'} && $coursepref eq '') {
1404: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1405: $coursepref = $domdefs{'canuse_pdfforms'};
1406: }
1407: }
1408: if ($coursepref) {
1409: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1410: }
1.124 matthew 1411: }
1.81 matthew 1412: } elsif ($pro =~ /^course_(.*)$/) {
1413: # Check for permissions inside of a course
1.295 raeburn 1414: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1415: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1416: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1417: )) {
1.209 www 1418: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1419: }
1.295 raeburn 1420: } elsif ($pro =~ /^community_(.*)$/) {
1421: # Check for permissions inside of a community
1422: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1423: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1424: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1425: )) {
1426: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1427: }
1.4 www 1428: } elsif ($pro eq 'author') {
1429: if ($author) {
1.152 albertel 1430: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1431: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1432: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1433: # Check that we are on the correct machine
1.29 matthew 1434: my $cadom=$requested_domain;
1.152 albertel 1435: my $caname=$env{'user.name'};
1.234 raeburn 1436: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1437: ($cadom,$caname)=
1.206 albertel 1438: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1439: }
1440: $act =~ s/\$caname/$caname/g;
1.19 matthew 1441: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1442: my $allowed=0;
1443: my @ids=&Apache::lonnet::current_machine_ids();
1444: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1445: if ($allowed) {
1.209 www 1446: $output.=&switch($caname,$cadom,
1447: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1448: }
1.6 www 1449: }
1.2 www 1450: }
1.248 raeburn 1451: } elsif ($pro eq 'tools') {
1452: my @tools = ('aboutme','blog','portfolio');
1453: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1454: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1455: $env{'user.domain'},
1456: $prt,undef,'tools')) {
1457: $output.=&clear($row,$col);
1458: next;
1459: }
1.278 raeburn 1460: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1461: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1462: next;
1463: }
1464: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1465: next;
1466: }
1.279 raeburn 1467: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1468: if (!$showreqcrs) {
1.248 raeburn 1469: $output.=&clear($row,$col);
1470: next;
1471: }
1472: }
1473: $prt='any';
1474: $output.=&secondlevel(
1475: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1476: }
1.13 harris41 1477: }
1.269 droeschl 1478: unless ($env{'environment.remote'} eq 'off') {
1.35 www 1479: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123 www 1480: if (&Apache::lonmsg::newmail()) {
1481: $output.='swmenu.setstatus("you have","messages");';
1482: }
1.34 www 1483: }
1.123 www 1484:
1.2 www 1485: return $output;
1486: }
1487:
1.279 raeburn 1488: sub check_for_rcrs {
1489: my $showreqcrs = 0;
1.280 raeburn 1490: my @reqtypes = ('official','unofficial','community');
1491: foreach my $type (@reqtypes) {
1.279 raeburn 1492: if (&Apache::lonnet::usertools_access($env{'user.name'},
1493: $env{'user.domain'},
1494: $type,undef,'requestcourses')) {
1495: $showreqcrs = 1;
1496: last;
1497: }
1498: }
1.280 raeburn 1499: if (!$showreqcrs) {
1500: foreach my $type (@reqtypes) {
1501: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1502: $showreqcrs = 1;
1503: last;
1504: }
1505: }
1506: }
1.279 raeburn 1507: return $showreqcrs;
1508: }
1509:
1.2 www 1510: # ======================================================================= Close
1.1 www 1511:
1512: sub close {
1.269 droeschl 1513: if ($env{'environment.remote'} eq 'off') { return ''; }
1.230 albertel 1514: my $menuname = &get_menu_name();
1.1 www 1515: return(<<ENDCLOSE);
1.129 albertel 1516: <script type="text/javascript">
1.277 bisitz 1517: // <![CDATA[
1.35 www 1518: window.status='Accessing Remote Control';
1.30 www 1519: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 1520: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 1521: window.status='Disabling Remote Control';
1522: menu.active=0;
1.31 www 1523: menu.autologout=0;
1.35 www 1524: window.status='Closing Remote Control';
1.1 www 1525: menu.close();
1.35 www 1526: window.status='Done.';
1.277 bisitz 1527: // ]]>
1.1 www 1528: </script>
1529: ENDCLOSE
1530: }
1531:
1532: # ====================================================================== Footer
1533:
1534: sub footer {
1535:
1.33 www 1536: }
1537:
1.122 albertel 1538: sub nav_control_js {
1.152 albertel 1539: my $nav=($env{'environment.remotenavmap'} eq 'on');
1.122 albertel 1540: return (<<NAVCONTROL);
1541: var w_loncapanav_flag="$nav";
1542:
1543:
1544: function gonav(url) {
1545: if (w_loncapanav_flag != 1) {
1546: gopost(url,'');
1547: } else {
1548: navwindow=window.open(url,
1549: "loncapanav","height=600,width=400,scrollbars=1");
1550: }
1551: }
1552: NAVCONTROL
1553: }
1554:
1.306 raeburn 1555: sub dc_popup_js {
1556: my %lt = &Apache::lonlocal::texthash(
1557: more => '(More ...)',
1558: less => '(Less ...)',
1559: );
1560: return <<"END";
1561:
1562: function showCourseID() {
1563: document.getElementById('dccid').style.display='block';
1564: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1565: document.getElementById('dccid').style.textFace='normal';
1.306 raeburn 1566: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
1567: return;
1568: }
1569:
1570: function hideCourseID() {
1571: document.getElementById('dccid').style.display='none';
1572: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
1573: return;
1574: }
1575:
1576: END
1577:
1578: }
1579:
1.42 www 1580: sub utilityfunctions {
1.132 raeburn 1581: my $caller = shift;
1.269 droeschl 1582: unless ($env{'environment.remote'} eq 'off' ||
1583: $caller eq '/adm/menu') {
1584: return ''; }
1585:
1.152 albertel 1586: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.293 raeburn 1587: if ($currenturl =~ m{^/adm/wrapper/ext/}) {
1588: if ($env{'request.external.querystring'}) {
1589: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1590: }
1591: }
1.183 www 1592: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1593:
1.152 albertel 1594: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.122 albertel 1595: my $nav_control=&nav_control_js();
1.175 albertel 1596:
1.306 raeburn 1597: my $dc_popup_cid;
1598: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1599: $env{'course.'.$env{'request.course.id'}.
1600: '.domain'}.'/'})) {
1601: $dc_popup_cid = &dc_popup_js();
1602: }
1603:
1.175 albertel 1604: my $start_page_annotate =
1605: &Apache::loncommon::start_page('Annotator',undef,
1606: {'only_body' => 1,
1607: 'js_ready' => 1,
1608: 'bgcolor' => '#BBBBBB',
1609: 'add_entries' => {
1610: 'onload' => 'javascript:document.goannotate.submit();'}});
1611:
1.205 albertel 1612: my $end_page_annotate =
1613: &Apache::loncommon::end_page({'js_ready' => 1});
1614:
1.175 albertel 1615: my $start_page_bookmark =
1616: &Apache::loncommon::start_page('Bookmarks',undef,
1617: {'only_body' => 1,
1618: 'js_ready' => 1,
1619: 'bgcolor' => '#BBBBBB',});
1620:
1.205 albertel 1621: my $end_page_bookmark =
1.175 albertel 1622: &Apache::loncommon::end_page({'js_ready' => 1});
1623:
1.315.2.3! raeburn 1624: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
! 1625: &mt('Switch server?');
! 1626:
1.42 www 1627: return (<<ENDUTILITY)
1628:
1629: var currentURL="$currenturl";
1630: var reloadURL="$currenturl";
1631: var currentSymb="$currentsymb";
1632:
1.114 albertel 1633: $nav_control
1.306 raeburn 1634: $dc_popup_cid
1.114 albertel 1635:
1.42 www 1636: function go(url) {
1637: if (url!='' && url!= null) {
1638: currentURL = null;
1639: currentSymb= null;
1640: window.location.href=url;
1641: }
1642: }
1643:
1.297 raeburn 1644: function gotop(url) {
1645: if (url!='' && url!= null) {
1646: top.location.href = url;
1647: }
1648: }
1649:
1.315.2.3! raeburn 1650: function need_switchserver(url) {
! 1651: if (url!='' && url!= null) {
! 1652: if (confirm("$confirm_switch")) {
! 1653: go(url);
! 1654: }
! 1655: }
! 1656: return;
! 1657: }
! 1658:
1.42 www 1659: function gopost(url,postdata) {
1660: if (url!='') {
1661: this.document.server.action=url;
1662: this.document.server.postdata.value=postdata;
1663: this.document.server.command.value='';
1664: this.document.server.url.value='';
1665: this.document.server.symb.value='';
1666: this.document.server.submit();
1667: }
1668: }
1669:
1670: function gocmd(url,cmd) {
1671: if (url!='') {
1672: this.document.server.action=url;
1673: this.document.server.postdata.value='';
1674: this.document.server.command.value=cmd;
1675: this.document.server.url.value=currentURL;
1676: this.document.server.symb.value=currentSymb;
1677: this.document.server.submit();
1678: }
1.57 www 1679: }
1680:
1.121 raeburn 1681: function gocstr(url,filename) {
1682: if (url == '/adm/cfile?action=delete') {
1683: this.document.cstrdelete.filename.value = filename
1684: this.document.cstrdelete.submit();
1685: return;
1686: }
1.137 raeburn 1687: if (url == '/adm/printout') {
1688: this.document.cstrprint.postdata.value = filename
1689: this.document.cstrprint.curseed.value = 0;
1690: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1691: if (this.document.lonhomework) {
1692: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1693: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1694: }
1695: if (this.document.lonhomework.problemtype) {
1.164 albertel 1696: if (this.document.lonhomework.problemtype.value) {
1697: this.document.cstrprint.problemtype.value =
1698: this.document.lonhomework.problemtype.value;
1699: } else if (this.document.lonhomework.problemtype.options) {
1700: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1701: if (this.document.lonhomework.problemtype.options[i].selected) {
1702: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1703: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1704: }
1705: }
1706: }
1707: }
1708: }
1709: }
1.137 raeburn 1710: this.document.cstrprint.submit();
1711: return;
1712: }
1.121 raeburn 1713: if (url !='') {
1714: this.document.constspace.filename.value = filename;
1715: this.document.constspace.action = url;
1716: this.document.constspace.submit();
1717: }
1718: }
1719:
1.131 raeburn 1720: function golist(url) {
1721: if (url!='' && url!= null) {
1722: currentURL = null;
1723: currentSymb= null;
1724: top.location.href=url;
1725: }
1726: }
1727:
1728:
1.121 raeburn 1729:
1.57 www 1730: function catalog_info() {
1.102 albertel 1731: 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 1732: }
1733:
1734: function chat_win() {
1.290 raeburn 1735: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1736: }
1.169 raeburn 1737:
1738: function group_chat(group) {
1739: var url = '/adm/groupchat?group='+group;
1740: var winName = 'LONchat_'+group;
1741: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1742: }
1.175 albertel 1743:
1744: function edit_bookmarks() {
1745: go('');
1746: w_BookmarkPal_flag=1;
1747: bookmarkpal=window.open("/adm/bookmarks",
1.315.2.1 raeburn 1748: "BookmarkPal", "width=500,height=505,scrollbars=0");
1.175 albertel 1749: }
1750:
1751: function annotate() {
1752: w_Annotator_flag=1;
1753: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1754: annotator.document.write(
1755: '$start_page_annotate'
1756: +"<form name='goannotate' target='Annotator' method='post' "
1757: +"action='/adm/annotations'>"
1.217 albertel 1758: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1759: +"<\\/form>"
1.205 albertel 1760: +'$end_page_annotate');
1.175 albertel 1761: annotator.document.close();
1762: }
1763:
1764: function set_bookmark() {
1765: go('');
1766: clienttitle=document.title;
1767: clienthref=location.pathname;
1768: w_bmquery_flag=1;
1769: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1770: bmquery.document.write(
1771: '$start_page_bookmark'
1.260 bisitz 1772: +'<center><form method="post"'
1773: +' name="newlink" action="/adm/bookmarks" target="bmquery" '
1774: +'> <table width="340" height="150" '
1775: +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
1776: +'type="text" name="title" size="45" value="'+clienttitle+'" />'
1777: +'<br />Address:<br /><input type="text" name="address" size="45" '
1778: +'value="'+clienthref+'" /><br /><center><input type="submit" '
1779: +'value="Save" /> <input type="button" value="Close" '
1780: +'onclick="javascript:window.close();" /></center></td>'
1781: +'</tr></table></form></center>'
1.205 albertel 1782: +'$end_page_bookmark' );
1.175 albertel 1783: bmquery.document.close();
1784: }
1785:
1.42 www 1786: ENDUTILITY
1787: }
1788:
1789: sub serverform {
1790: return(<<ENDSERVERFORM);
1.181 albertel 1791: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1792: <input type="hidden" name="postdata" value="none" />
1793: <input type="hidden" name="command" value="none" />
1794: <input type="hidden" name="url" value="none" />
1795: <input type="hidden" name="symb" value="none" />
1796: </form>
1797: ENDSERVERFORM
1798: }
1.113 albertel 1799:
1.121 raeburn 1800: sub constspaceform {
1801: return(<<ENDCONSTSPACEFORM);
1.181 albertel 1802: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 1803: <input type="hidden" name="filename" value="" />
1804: </form>
1.181 albertel 1805: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 1806: <input type="hidden" name="action" value="delete" />
1807: <input type="hidden" name="filename" value="" />
1808: </form>
1.181 albertel 1809: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 1810: <input type="hidden" name="postdata" value="" />
1811: <input type="hidden" name="curseed" value="" />
1812: <input type="hidden" name="problemtype" value="" />
1813: </form>
1814:
1.121 raeburn 1815: ENDCONSTSPACEFORM
1816: }
1817:
1818:
1.113 albertel 1819: sub get_nav_status {
1820: my $navstatus="swmenu.w_loncapanav_flag=";
1.152 albertel 1821: if ($env{'environment.remotenavmap'} eq 'on') {
1.113 albertel 1822: $navstatus.="1";
1823: } else {
1824: $navstatus.="-1";
1825: }
1826: return $navstatus;
1827: }
1828:
1.220 raeburn 1829: sub hidden_button_check {
1830: my $hidden;
1831: if ($env{'request.course.id'} eq '') {
1832: return;
1833: }
1834: if ($env{'request.role.adv'}) {
1835: return;
1836: }
1.232 raeburn 1837: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1838: return $buttonshide;
1.220 raeburn 1839: }
1.184 raeburn 1840:
1.235 raeburn 1841: sub roles_selector {
1842: my ($cdom,$cnum) = @_;
1.298 raeburn 1843: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 1844: my $now = time;
1.262 raeburn 1845: my (%courseroles,%seccount);
1.235 raeburn 1846: my $is_cc;
1847: my $role_selector;
1.298 raeburn 1848: my $ccrole;
1849: if ($crstype eq 'Community') {
1850: $ccrole = 'co';
1851: } else {
1852: $ccrole = 'cc';
1853: }
1854: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
1855: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 1856:
1857: if ((($start) && ($start<0)) ||
1858: (($end) && ($end<$now)) ||
1859: (($start) && ($now<$start))) {
1860: $is_cc = 0;
1861: } else {
1862: $is_cc = 1;
1863: }
1864: }
1865: if ($is_cc) {
1.264 raeburn 1866: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1.235 raeburn 1867: } else {
1.262 raeburn 1868: my %gotnosection;
1.235 raeburn 1869: foreach my $item (keys(%env)) {
1.239 raeburn 1870: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 1871: my $role = $1;
1872: my $sec = $2;
1873: next if ($role eq 'gr');
1874: my ($start,$end) = split(/\./,$env{$item});
1875: next if (($start && $start > $now) || ($end && $end < $now));
1876: if ($sec eq '') {
1.239 raeburn 1877: if (!$gotnosection{$role}) {
1878: $seccount{$role} ++;
1879: $gotnosection{$role} = 1;
1880: }
1.235 raeburn 1881: }
1882: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 1883: if ($sec ne '') {
1.264 raeburn 1884: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 1885: push(@{$courseroles{$role}},$sec);
1886: $seccount{$role} ++;
1887: }
1888: }
1889: } else {
1890: @{$courseroles{$role}} = ();
1891: if ($sec ne '') {
1892: $seccount{$role} ++;
1.235 raeburn 1893: push(@{$courseroles{$role}},$sec);
1894: }
1895: }
1896: }
1897: }
1898: }
1.286 raeburn 1899: my $switchtext;
1900: if ($crstype eq 'Community') {
1901: $switchtext = &mt('Switch community role to...')
1902: } else {
1903: $switchtext = &mt('Switch course role to...')
1904: }
1.298 raeburn 1905: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235 raeburn 1906: if (keys(%courseroles) > 1) {
1.239 raeburn 1907: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1.235 raeburn 1908: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1909: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286 raeburn 1910: $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235 raeburn 1911: foreach my $role (@roles_order) {
1912: if (defined($courseroles{$role})) {
1.298 raeburn 1913: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1.235 raeburn 1914: }
1915: }
1916: foreach my $role (sort(keys(%courseroles))) {
1917: if ($role =~ /^cr/) {
1918: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1919: }
1920: }
1921: $role_selector .= '</select>'."\n".
1922: '<input type="hidden" name="destinationurl" value="'.
1.282 amueller 1923: &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n".
1.235 raeburn 1924: '<input type="hidden" name="gotorole" value="1" />'."\n".
1925: '<input type="hidden" name="selectrole" value="" />'."\n".
1926: '<input type="hidden" name="switch" value="1" />'."\n".
1927: '</form>';
1928: }
1929: return $role_selector;
1930: }
1931:
1.262 raeburn 1932: sub get_all_courseroles {
1933: my ($cdom,$cnum,$courseroles,$seccount) = @_;
1934: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
1935: return;
1936: }
1937: my ($result,$cached) =
1938: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1939: if (defined($cached)) {
1940: if (ref($result) eq 'HASH') {
1941: if ((ref($result->{'roles'}) eq 'HASH') &&
1942: (ref($result->{'seccount'}) eq 'HASH')) {
1943: %{$courseroles} = %{$result->{'roles'}};
1944: %{$seccount} = %{$result->{'seccount'}};
1945: return;
1946: }
1947: }
1948: }
1949: my %gotnosection;
1950: my %adv_roles =
1951: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1952: foreach my $role (keys(%adv_roles)) {
1953: my ($urole,$usec) = split(/:/,$role);
1954: if (!$gotnosection{$urole}) {
1955: $seccount->{$urole} ++;
1956: $gotnosection{$urole} = 1;
1957: }
1958: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1959: if ($usec ne '') {
1960: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1961: push(@{$courseroles->{$urole}},$usec);
1962: $seccount->{$urole} ++;
1963: }
1964: }
1965: } else {
1966: @{$courseroles->{$urole}} = ();
1967: if ($usec ne '') {
1968: $seccount->{$urole} ++;
1969: push(@{$courseroles->{$urole}},$usec);
1970: }
1971: }
1972: }
1973: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1974: @{$courseroles->{'st'}} = ();
1975: if (keys(%sections_count) > 0) {
1976: push(@{$courseroles->{'st'}},keys(%sections_count));
1977: $seccount->{'st'} = scalar(keys(%sections_count));
1978: }
1979: my $rolehash = {
1980: 'roles' => $courseroles,
1981: 'seccount' => $seccount,
1982: };
1983: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1984: return;
1985: }
1986:
1.235 raeburn 1987: sub jump_to_role {
1.239 raeburn 1988: my ($cdom,$cnum,$seccount,$courseroles) = @_;
1989: my %lt = &Apache::lonlocal::texthash(
1990: this => 'This role has section(s) associated with it.',
1991: ente => 'Enter a specific section.',
1992: orlb => 'Enter a specific section, or leave blank for no section.',
1993: avai => 'Available sections are:',
1994: youe => 'You entered an invalid section choice:',
1995: plst => 'Please try again',
1996: );
1997: my $js;
1998: if (ref($courseroles) eq 'HASH') {
1999: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
2000: ' var numsec = new Array();'."\n".
2001: ' var rolesections = new Array();'."\n".
2002: ' var rolenames = new Array();'."\n".
2003: ' var roleseclist = new Array();'."\n";
2004: my @items = keys(%{$courseroles});
2005: for (my $i=0; $i<@items; $i++) {
2006: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
2007: my ($secs,$secstr);
2008: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
2009: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
2010: $secs = join('","',@sections);
2011: $secstr = join(', ',@sections);
2012: }
2013: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
2014: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
2015: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
2016: }
2017: }
1.273 droeschl 2018: return <<"END";
1.235 raeburn 2019: <script type="text/javascript">
1.273 droeschl 2020: //<![CDATA[
1.235 raeburn 2021: function adhocRole(roleitem) {
1.239 raeburn 2022: $js
1.235 raeburn 2023: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
2024: if (newrole == '') {
2025: return;
2026: }
1.239 raeburn 2027: var fullrole = newrole+'./$cdom/$cnum';
2028: var selidx = '';
2029: for (var i=0; i<rolenames.length; i++) {
2030: if (rolenames[i] == newrole) {
2031: selidx = i;
2032: }
2033: }
2034: var secok = 1;
2035: var secchoice = '';
2036: if (selidx >= 0) {
2037: if (numsec[selidx] > 1) {
2038: secok = 0;
2039: var numrolesec = rolesections[selidx].length;
2040: var msgidx = numsec[selidx] - numrolesec;
2041: secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
2042: if (secchoice == '') {
2043: if (msgidx > 0) {
2044: secok = 1;
2045: }
2046: } else {
2047: for (var j=0; j<rolesections[selidx].length; j++) {
2048: if (rolesections[selidx][j] == secchoice) {
2049: secok = 1;
2050: }
2051: }
2052: }
2053: } else {
2054: if (rolesections[selidx].length == 1) {
2055: secchoice = rolesections[selidx][0];
2056: }
2057: }
2058: }
2059: if (secok == 1) {
2060: if (secchoice != '') {
2061: fullrole += '/'+secchoice;
2062: }
2063: } else {
2064: document.rolechooser.elements[roleitem].selectedIndex = 0;
2065: if (secchoice != null) {
2066: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
2067: }
2068: return;
2069: }
2070: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 2071: return;
2072: }
2073: itemid = retrieveIndex('gotorole');
2074: if (itemid != -1) {
1.239 raeburn 2075: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 2076: }
1.239 raeburn 2077: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235 raeburn 2078: document.rolechooser.selectrole.value = '1';
2079: document.rolechooser.submit();
2080: return;
2081: }
2082:
2083: function retrieveIndex(item) {
2084: for (var i=0;i<document.rolechooser.elements.length;i++) {
2085: if (document.rolechooser.elements[i].name == item) {
2086: return i;
2087: }
2088: }
2089: return -1;
2090: }
1.273 droeschl 2091: // ]]>
1.235 raeburn 2092: </script>
2093: END
2094: }
2095:
2096:
1.2 www 2097: # ================================================================ Main Program
2098:
1.16 harris41 2099: BEGIN {
1.166 albertel 2100: if (! defined($readdesk)) {
1.283 droeschl 2101: {
2102: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2103: if ( CORE::open( my $config,"<$tabfile") ) {
2104: while (my $configline=<$config>) {
2105: $configline=(split(/\#/,$configline))[0];
2106: $configline=~s/^\s+//;
2107: chomp($configline);
1.209 www 2108: if ($configline=~/^cat\:/) {
1.283 droeschl 2109: my @entries=split(/\:/,$configline);
2110: $category_positions{$entries[2]}=$entries[1];
2111: $category_names{$entries[2]}=$entries[3];
2112: } elsif ($configline=~/^prim\:/) {
2113: my @entries = (split(/\:/, $configline))[1..5];
2114: push @primary_menu, \@entries;
2115: } elsif ($configline=~/^scnd\:/) {
2116: my @entries = (split(/\:/, $configline))[1..5];
2117: push @secondary_menu, \@entries;
2118: } elsif ($configline) {
2119: push(@desklines,$configline);
2120: }
2121: }
2122: CORE::close($config);
2123: }
2124: }
2125: $readdesk='done';
1.2 www 2126: }
2127: }
1.30 www 2128:
1.1 www 2129: 1;
2130: __END__
2131:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>