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