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