1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.266 2009/05/18 16:29:55 raeburn Exp $
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: #
28: #
29: # There are two parameters controlling the action of this module:
30: #
31: # browser.interface - if this is 'textual', it overrides the second parameter
32: # and goes to screen reader PDA mode
33: #
34: # environment.remote - if this is 'on', the routines controll the remote
35: # control, otherwise they render the main window controls; ignored it
36: # browser.interface is 'textual'
37: #
38:
39: =head1 NAME
40:
41: Apache::lonmenu
42:
43: =head1 SYNOPSIS
44:
45: Coordinates the response to clicking an image.
46:
47: This is part of the LearningOnline Network with CAPA project
48: described at http://www.lon-capa.org.
49:
50: =head1 SUBROUTINES
51:
52: =over
53:
54: Little texts
55:
56: =item initlittle()
57:
58: =item menubuttons()
59:
60: This gets called at the top of the body section
61:
62: =item show_return_link()
63:
64: =item registerurl()
65:
66: This gets called in the header section
67:
68: =item innerregister()
69:
70: This gets called in order to register a URL, both with the Remote
71: and in the body of the document
72:
73: =item loadevents()
74:
75: =item unloadevents()
76:
77: =item startupremote()
78:
79: =item setflags()
80:
81: =item maincall()
82:
83: =item load_remote_msg()
84:
85: =item get_menu_name()
86:
87: =item reopenmenu()
88:
89: =item open()
90:
91: Open the menu
92:
93: =item clear()
94:
95: =item switch()
96:
97: Switch a button or create a link
98: Switch acts on the javascript that is executed when a button is clicked.
99: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
100:
101: =item secondlevel()
102:
103: =item openmenu()
104:
105: =item inlinemenu()
106:
107: =item rawconfig()
108:
109: =item close()
110:
111: =item footer()
112:
113: =item utilityfunctions()
114:
115: =item serverform()
116:
117: =item constspaceform()
118:
119: =item get_nav_status()
120:
121: =item convert_menu_function()
122:
123: FIXME this needs to move into mydesktab and the other locations
124: the text is generated
125:
126: =item hidden_button_check()
127:
128: =item roles_selector()
129:
130: =item jump_to_role()
131:
132: =back
133:
134: =cut
135:
136: package Apache::lonmenu;
137:
138: use strict;
139: use Apache::lonnet;
140: use Apache::lonhtmlcommon();
141: use Apache::loncommon();
142: use Apache::lonenc();
143: use Apache::lonlocal;
144: use LONCAPA qw(:DEFAULT :match);
145:
146: use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
147:
148:
149: my @inlineremote;
150:
151: sub initlittle {
152: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
153: 'nav' => 'Navigate Contents',
154: 'main' => 'Main Menu',
155: 'roles' => (&Apache::loncommon::show_course()?
156: 'Courses':'Roles'),
157: 'other' => 'Other Roles',
158: 'docs' => 'Edit Course',
159: 'exit' => 'Logout',
160: 'login' => 'Log In',
161: 'launch' => 'Launch Remote Control',
162: 'groups' => 'Groups',
163: 'gdoc' => 'Group Documents',
164: );
165: }
166:
167: sub menubuttons {
168: my $forcereg=shift;
169: my $registration=shift;
170: my $titletable=shift;
171: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
172: ['inhibitmenu']);
173: if (($env{'form.inhibitmenu'} eq 'yes') ||
174: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
175:
176: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
177:
178: my %lt=&initlittle();
179: my $navmaps='';
180: my $reloadlink='';
181: my $docs='';
182: my $groups='';
183: my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
184: my $role_selector;
185: my $showgroups=0;
186: my ($cnum,$cdom);
187: my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
188: my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
189:
190: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
191: $logo = '<a href="/adm/about.html"><img src="'.
192: $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
193:
194: if ($env{'request.state'} eq 'construct') {
195: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
196: my $returnurl = $env{'request.filename'};
197: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
198: $escurl = &escape($returnurl);
199: }
200: }
201: if ($env{'request.course.id'}) {
202: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
203: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
204: my %coursegroups;
205: my $viewgrps_permission =
206: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
207: if (!$viewgrps_permission) {
208: %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
209: }
210: if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
211: $showgroups = 1;
212: }
213: $role_selector = &roles_selector($cdom,$cnum);
214: if ($role_selector) {
215: $roles = '<span class="LC_nobreak">'.$role_selector.' <a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>';
216: }
217: }
218:
219: if ($env{'browser.interface'} eq 'textual') {
220: # Textual display only
221: if ($env{'request.course.id'}) {
222: $navmaps=(<<ENDNAV);
223: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
224: ENDNAV
225: if (&show_return_link()) {
226: my $escreload=&escape('return:');
227: $reloadlink=(<<ENDRELOAD);
228: <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
229: ENDRELOAD
230: }
231: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
232: $docs=(<<ENDDOCS);
233: <a href="/adm/coursedocs" target="_top">$lt{'docs'}</a>
234: ENDDOCS
235: }
236: if ($showgroups) {
237: $groups =(<<ENDGROUPS);
238: <a href="/adm/coursegroups" target="_top">$lt{'groups'}</a>
239: ENDGROUPS
240: }
241: }
242: my $form=&serverform();
243: my $utility=&utilityfunctions();
244: my $output=(<<ENDMAINMENU);
245: <script type="text/javascript">
246: // BEGIN LON-CAPA Internal
247: $utility
248: </script>
249: <div id="LC_top_nav">
250: <a href="/adm/menu" target="_top">$lt{'main'}</a>
251: $reloadlink $navmaps $docs $groups $roles
252: <a href="/adm/logout" target="_top">$lt{'exit'}</a>
253: </div>
254: <br />
255: <script type="text/javascript">
256: // END LON-CAPA Internal
257: </script>
258: $form
259: ENDMAINMENU
260: if ($registration) { $output.=&innerregister($forcereg); }
261: return $output."<hr />";
262: } elsif ($env{'environment.remote'} eq 'off') {
263: # Remote Control is switched off
264: # figure out colors
265: my %lt=&initlittle();
266:
267: my $domain=&Apache::loncommon::determinedomain();
268: my $function =&Apache::loncommon::get_users_function();
269: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
270: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
271: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
272: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
273: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
274: return (<<ENDINLINEMENU);
275: <table id="LC_top_nav">
276: <tr>
277: <td>$logo</td>
278: <td></td>
279: <td class="LC_top_nav_login">
280: <a href="/adm/roles" target="_top">$lt{'login'}</a>
281: </td>
282: </tr>
283: </table>
284: ENDINLINEMENU
285: }
286: $roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
287: # Do we have a NAV link?
288: if ($env{'request.course.id'}) {
289: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
290: $escsymb;
291: if ($env{'environment.remotenavmap'} eq 'on') {
292: $link="javascript:gonav('".$link."')";
293: }
294: $navmaps=(<<ENDNAV);
295: <li><a href="$link" target="_top">$lt{'nav'}</a></li>
296: ENDNAV
297: my $is_group = (&Apache::loncommon::course_type() eq 'Group');
298: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
299: my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
300: $docs=(<<ENDDOCS);
301: <li><a href="/adm/coursedocs" target="_top">$text</a></li>
302: ENDDOCS
303: }
304: if ($showgroups) {
305: $groups =(<<ENDGROUPS);
306: <li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li>
307: ENDGROUPS
308: }
309: if (&show_return_link()) {
310: my $escreload=&escape('return:');
311: $reloadlink=(<<ENDRELOAD);
312: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
313: ENDRELOAD
314: }
315: if ($role_selector) {
316: #$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
317: $role_selector = '<li>'.$role_selector.'</li>';
318: }
319: }
320: if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
321: my $escreload=&escape('return:');
322: $reloadlink=(<<ENDCRELOAD);
323: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
324: ENDCRELOAD
325: }
326: my $reg='';
327: if ($registration) {
328: $reg=&innerregister($forcereg,$titletable);
329: }
330: my $form=&serverform();
331: my $utility=&utilityfunctions();
332:
333: my $messagelink = "";
334: if(&Apache::lonmsg::mynewmail()){
335: $messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message(new)</a>'
336: }else{
337: $messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message</a>'
338: }
339: my $helplink=&Apache::loncommon::top_nav_help('Help');
340: return (<<ENDINLINEMENU);
341: <script type="text/javascript">
342: // BEGIN LON-CAPA Internal
343: // <![CDATA[
344: $utility
345: // ]]>
346: </script>
347: <ol class="LC_smallMenu LC_right">
348: <li>$logo</li>
349: <li>$messagelink</li>
350: <li>$roles</li>
351: <li>$helplink</li>
352: <li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li>
353: </ol>
354: <ul id="LC_TabMainMenuContent">
355: <li><a href="/adm/menu" target="_top">$lt{'main'}</a></li>
356: $reloadlink
357: $navmaps
358: $docs
359: $groups
360: $role_selector
361: </ul>
362: $form
363: <script type="text/javascript">
364: // END LON-CAPA Internal
365: </script>
366: $reg
367: ENDINLINEMENU
368: } else {
369: return '';
370: }
371: }
372:
373: sub show_return_link {
374: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
375: $env{'request.symb'} eq '')
376: ||
377: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
378: ||
379: (($env{'request.noversionuri'}=~/^\/adm\//) &&
380: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
381: ($env{'request.noversionuri'}!~
382: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
383: ));
384: }
385:
386:
387: sub registerurl {
388: my ($forcereg) = @_;
389: my $result = '';
390: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
391: my $force_title='';
392: if ($env{'request.state'} eq 'construct') {
393: $force_title=&Apache::lonxml::display_title();
394: }
395: if (($env{'browser.interface'} eq 'textual') ||
396: ($env{'environment.remote'} eq 'off') ||
397: ((($env{'request.publicaccess'}) ||
398: (!&Apache::lonnet::is_on_map(
399: &unescape($env{'request.noversionuri'})))) &&
400: (!$forcereg))) {
401: return $result.
402: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
403: }
404: # Graphical display after login only
405: if ($env{'request.registered'} && !$forcereg) { return ''; }
406: $result.=&innerregister($forcereg);
407: return $result.$force_title;
408: }
409:
410: sub innerregister {
411: my ($forcereg, $titletable) = @_;
412: my $result = '';
413: my ($uname,$thisdisfn);
414: my $const_space = ($env{'request.state'} eq 'construct');
415: my $is_const_dir = 0;
416:
417: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
418:
419: $env{'request.registered'} = 1;
420:
421: my $textinter=($env{'browser.interface'} eq 'textual');
422: my $noremote=($env{'environment.remote'} eq 'off');
423:
424: my $textual=($textinter || $noremote);
425:
426: undef(@inlineremote);
427:
428: my $reopen=&Apache::lonmenu::reopenmenu();
429:
430: my $newmail='';
431: if ($noremote) {
432: $newmail='<table id="LC_nav_location"><tr>';
433: }
434: if (&Apache::lonmsg::newmail()) {
435: if ($textual) {
436: $newmail.= '<td class="LC_new_mail">
437: <a href="/adm/communicate" target="_top">'.
438: &mt('You have new messages').'</a></td>';
439: } else {
440: $newmail= 'swmenu.setstatus("you have","messages");';
441: }
442: }
443: if (($textual)
444: && ($env{'request.symb'})
445: && ($env{'request.course.id'})) {
446: $newmail.= '<td class="LC_current_location">';
447: my ($mapurl,$rid,$resurl)=
448: &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
449: my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
450: $newmail.=$coursetitle;
451: my $maptitle=&Apache::lonnet::gettitle($mapurl);
452: my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
453: if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
454: $newmail.=', '.$maptitle;
455: }
456: if ($restitle) {
457: $newmail.=': '.$restitle;
458: }
459: $newmail.=' </td>';
460: }
461: if ($env{'request.state'} eq 'construct') {
462: $newmail = $titletable;
463: } else {
464: if ($noremote) {
465: $newmail.='</tr></table>';
466: }
467: }
468: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
469: my $tablestart=($noremote?'<table id="LC_menubuttons">':'').
470: ($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
471: my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':'');
472: # =============================================================================
473: # ============================ This is for URLs that actually can be registered
474: if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
475: # -- This applies to homework problems for users with grading privileges
476: my $crs='/'.$env{'request.course.id'};
477: if ($env{'request.course.sec'}) {
478: $crs.='_'.$env{'request.course.sec'};
479: }
480: $crs=~s/\_/\//g;
481:
482: my $hwkadd='';
483: if ($env{'request.symb'} ne '' &&
484: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
485: if (&Apache::lonnet::allowed('mgr',$crs)) {
486: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
487: "gocmd('/adm/grades','gradingmenu')",
488: 'Modify user grades for this assessment resource');
489: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
490: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
491: "gocmd('/adm/grades','submission')",
492: 'View user submissions for this assessment resource');
493: }
494: }
495: if ($env{'request.symb'} ne '' &&
496: &Apache::lonnet::allowed('opa',$crs)) {
497: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
498: "gocmd('/adm/parmset','set')",
499: 'Modify parameter settings for this resource');
500: }
501: # -- End Homework
502: ###
503: ### Determine whether or not to display the 'cstr' button for this
504: ### resource
505: ###
506: my $editbutton = '';
507: my $noeditbutton = 1;
508: my ($cnum,$cdom);
509: if ($env{'request.course.id'}) {
510: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
511: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
512: }
513: if ($env{'user.author'}) {
514: if ($env{'request.role'}=~/^(aa|ca|au)/) {
515: # Set defaults for authors
516: my ($top,$bottom) = ('con-','struct');
517: my $action = "go('/priv/".$env{'user.name'}."');";
518: my $cadom = $env{'request.role.domain'};
519: my $caname = $env{'user.name'};
520: my $desc = "Enter my construction space";
521: # Set defaults for co-authors
522: if ($env{'request.role'} =~ /^ca/) {
523: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
524: ($top,$bottom) = ('co con-','struct');
525: $action = "go('/priv/".$caname."');";
526: $desc = "Enter construction space as co-author";
527: } elsif ($env{'request.role'} =~ /^aa/) {
528: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
529: ($top,$bottom) = ('co con-','struct');
530: $action = "go('/priv/".$caname."');";
531: $desc = "Enter construction space as assistant co-author";
532: }
533: # Check that we are on the correct machine
534: my $home = &Apache::lonnet::homeserver($caname,$cadom);
535: my $allowed=0;
536: my @ids=&Apache::lonnet::current_machine_ids();
537: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
538: if (!$allowed) {
539: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
540: $noeditbutton = 0;
541: }
542: }
543: ##
544: ## Determine if user can edit url.
545: ##
546: my $cfile='';
547: my $cfuname='';
548: my $cfudom='';
549: my $uploaded;
550: if ($env{'request.filename'}) {
551: my $file=&Apache::lonnet::declutter($env{'request.filename'});
552: if (defined($cnum) && defined($cdom)) {
553: $uploaded = &is_course_upload($file,$cnum,$cdom);
554: }
555: if (!$uploaded) {
556: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
557: # Check that the user has permission to edit this resource
558: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
559: if (defined($cfudom)) {
560: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
561: my $allowed=0;
562: my @ids=&Apache::lonnet::current_machine_ids();
563: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
564: if ($allowed) {
565: $cfile=$file;
566: }
567: }
568: }
569: }
570: # Finally, turn the button on or off
571: if ($cfile && !$const_space) {
572: $editbutton=&switch
573: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
574: "go('".$cfile."');","Edit this resource");
575: $noeditbutton = 0;
576: } elsif ($editbutton eq '') {
577: $editbutton=&clear(6,1);
578: }
579: }
580: if (($noeditbutton) && ($env{'request.filename'})) {
581: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
582: my $file=&Apache::lonnet::declutter($env{'request.filename'});
583: if (defined($cnum) && defined($cdom)) {
584: if (&is_course_upload($file,$cnum,$cdom)) {
585: my $cfile = &edit_course_upload($file,$cnum,$cdom);
586: if ($cfile) {
587: $editbutton=&switch
588: ('','',6,1,'pcstr.gif','edit[_1]',
589: 'resource[_2]',"go('".$cfile."');",
590: 'Edit this resource');
591: }
592: }
593: }
594: }
595: }
596: ###
597: ###
598: # Prepare the rest of the buttons
599: my $menuitems;
600: if ($const_space) {
601: my ($uname,$thisdisfn) =
602: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
603: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
604: if ($currdir =~ m-/$-) {
605: $is_const_dir = 1;
606: } else {
607: $currdir =~ s#[^/]+$##;
608: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
609: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
610: $menuitems=(<<ENDMENUITEMS);
611: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
612: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
613: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
614: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
615: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
616: ENDMENUITEMS
617: }
618: } elsif ( defined($env{'request.course.id'}) &&
619: $env{'request.symb'} ne '' ) {
620: $menuitems=(<<ENDMENUITEMS);
621: c&3&1
622: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
623: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
624: c&6&3
625: c&8&1
626: c&8&2
627: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
628: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
629: ENDMENUITEMS
630:
631: my $currentURL = &Apache::loncommon::get_symb();
632: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
633: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
634: $menuitems.="s&9&3&";
635: if(length($annotation) > 0){
636: $menuitems.="anot2.gif";
637: }else{
638: $menuitems.="anot.gif";
639: }
640: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
641: $menuitems.="Make notes and annotations about this resource&&1\n";
642:
643: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
644: if (!$env{'request.enc'}) {
645: $menuitems.=(<<ENDREALRES);
646: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
647: ENDREALRES
648: }
649: $menuitems.=(<<ENDREALRES);
650: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
651: 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
652: ENDREALRES
653: }
654: }
655: if ($env{'request.uri'} =~ /^\/res/) {
656: $menuitems .= (<<ENDMENUITEMS);
657: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
658: ENDMENUITEMS
659: }
660: my $buttons='';
661: foreach (split(/\n/,$menuitems)) {
662: my ($command,@rest)=split(/\&/,$_);
663: my $idx=10*$rest[0]+$rest[1];
664: if (&hidden_button_check() eq 'yes') {
665: if ($idx == 21 ||$idx == 23) {
666: $buttons.=&switch('','',@rest);
667: } else {
668: $buttons.=&clear(@rest);
669: }
670: } else {
671: if ($command eq 's') {
672: $buttons.=&switch('','',@rest);
673: } else {
674: $buttons.=&clear(@rest);
675: }
676: }
677: }
678:
679: if ($textual) {
680: my $addremote=0;
681: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
682: my $inlinebuttons='';
683: if ($addremote) {
684: # Registered, textual output
685: if ($env{'browser.interface'} eq 'textual') {
686: $inlinebuttons=
687: join('',map { (defined($_)?$_:'') } @inlineremote);
688: } else {
689: if ($env{'environment.icons'} eq 'iconsonly') {
690: $inlinebuttons=(<<ENDARROWSINLINE);
691: <tr><td>
692: $inlineremote[21] $inlineremote[23]
693: ENDARROWSINLINE
694: if (&hidden_button_check() ne 'yes') {
695: $inlinebuttons .= (<<ENDINLINEICONS);
696: $inlineremote[61] $inlineremote[63]
697: $inlineremote[71] $inlineremote[72] $inlineremote[73]
698: $inlineremote[81] $inlineremote[82] $inlineremote[83]
699: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
700: ENDINLINEICONS
701: }
702: } else {
703: if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
704: $inlinebuttons=(<<ENDFIRSTLINE);
705: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
706: ENDFIRSTLINE
707: }
708: if (&hidden_button_check() ne 'yes') {
709: foreach my $row (6..9) {
710: if ($inlineremote[${row}.'1'] ne ''
711: || $inlineremote[$row.'2'] ne ''
712: || $inlineremote[$row.'3'] ne '') {
713: $inlinebuttons .= <<"ENDLINE";
714: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
715: ENDLINE
716: }
717: }
718: }
719: }
720: }
721: }
722: $result =(<<ENDREGTEXT);
723: <script type="text/javascript">
724: // BEGIN LON-CAPA Internal
725: </script>
726: $timesync
727: $tablestart
728: $inlinebuttons
729: $tableend
730: $newmail
731: <script type="text/javascript">
732: // END LON-CAPA Internal
733: </script>
734:
735: ENDREGTEXT
736: # Registered, graphical output
737: } else {
738: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
739: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
740: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
741: my $navstatus=&get_nav_status();
742: my $clearcstr;
743:
744: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
745: $result = (<<ENDREGTHIS);
746:
747: <script type="text/javascript">
748: // BEGIN LON-CAPA Internal
749: var swmenu=null;
750:
751: function LONCAPAreg() {
752: swmenu=$reopen;
753: swmenu.clearTimeout(swmenu.menucltim);
754: $timesync
755: $newmail
756: $buttons
757: swmenu.currentURL="$requri";
758: swmenu.reloadURL=swmenu.currentURL+window.location.search;
759: swmenu.currentSymb="$cursymb";
760: swmenu.reloadSymb="$cursymb";
761: swmenu.currentStale=0;
762: $navstatus
763: $hwkadd
764: $editbutton
765: }
766:
767: function LONCAPAstale() {
768: swmenu=$reopen
769: swmenu.currentStale=1;
770: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
771: swmenu.switchbutton
772: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
773: }
774: swmenu.clearbut(7,2);
775: swmenu.clearbut(7,3);
776: swmenu.menucltim=swmenu.setTimeout(
777: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
778: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
779: 2000);
780: }
781:
782: // END LON-CAPA Internal
783: </script>
784: ENDREGTHIS
785: }
786: # =============================================================================
787: } else {
788: # ========================================== This can or will not be registered
789: if ($textual) {
790: # Not registered, textual
791: $result= (<<ENDDONOTREGTEXT);
792: ENDDONOTREGTEXT
793: } else {
794: # Not registered, graphical
795: $result = (<<ENDDONOTREGTHIS);
796:
797: <script type="text/javascript">
798: // BEGIN LON-CAPA Internal
799: var swmenu=null;
800:
801: function LONCAPAreg() {
802: swmenu=$reopen
803: $timesync
804: swmenu.currentStale=1;
805: swmenu.clearbut(2,1);
806: swmenu.clearbut(2,3);
807: swmenu.clearbut(8,1);
808: swmenu.clearbut(8,2);
809: swmenu.clearbut(8,3);
810: if (swmenu.currentURL) {
811: swmenu.switchbutton
812: (3,1,'reload.gif','return','location','go(currentURL)');
813: } else {
814: swmenu.clearbut(3,1);
815: }
816: }
817:
818: function LONCAPAstale() {
819: }
820:
821: // END LON-CAPA Internal
822: </script>
823: ENDDONOTREGTHIS
824: }
825: # =============================================================================
826: }
827: return $result;
828: }
829:
830: sub is_course_upload {
831: my ($file,$cnum,$cdom) = @_;
832: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
833: $uploadpath =~ s{^\/}{};
834: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
835: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
836: return 1;
837: }
838: return;
839: }
840:
841: sub edit_course_upload {
842: my ($file,$cnum,$cdom) = @_;
843: my $cfile;
844: if ($file =~/\.(htm|html|css|js|txt)$/) {
845: my $ext = $1;
846: my $url = &Apache::lonnet::hreflocation('',$file);
847: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
848: my @ids=&Apache::lonnet::current_machine_ids();
849: my $dest;
850: if ($home && grep(/^\Q$home\E$/,@ids)) {
851: $dest = $url.'?forceedit=1';
852: } else {
853: unless (&Apache::lonnet::get_locks()) {
854: $dest = '/adm/switchserver?otherserver='.
855: $home.'&role='.$env{'request.role'}.
856: '&url='.$url.'&forceedit=1';
857: }
858: }
859: if ($dest) {
860: $cfile = &HTML::Entities::encode($dest,'"<>&');
861: }
862: }
863: return $cfile;
864: }
865:
866: sub loadevents() {
867: if ($env{'request.state'} eq 'construct' ||
868: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
869: return 'LONCAPAreg();';
870: }
871:
872: sub unloadevents() {
873: if ($env{'request.state'} eq 'construct' ||
874: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
875: return 'LONCAPAstale();';
876: }
877:
878:
879: sub startupremote {
880: my ($lowerurl)=@_;
881: if (($env{'browser.interface'} eq 'textual') ||
882: ($env{'environment.remote'} eq 'off')) {
883: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
884: }
885: #
886: # The Remote actually gets launched!
887: #
888: my $configmenu=&rawconfig();
889: my $esclowerurl=&escape($lowerurl);
890: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
891: return(<<ENDREMOTESTARTUP);
892: <script type="text/javascript">
893: var timestart;
894: function wheelswitch() {
895: if (typeof(document.wheel) != 'undefined') {
896: if (typeof(document.wheel.spin) != 'undefined') {
897: var date=new Date();
898: var waited=Math.round(30-((date.getTime()-timestart)/1000));
899: document.wheel.spin.value=$message;
900: }
901: }
902: if (window.status=='|') {
903: window.status='/';
904: } else {
905: if (window.status=='/') {
906: window.status='-';
907: } else {
908: if (window.status=='-') {
909: window.status='\\\\';
910: } else {
911: if (window.status=='\\\\') { window.status='|'; }
912: }
913: }
914: }
915: }
916:
917: // ---------------------------------------------------------- The wait function
918: var canceltim;
919: function wait() {
920: if ((menuloaded==1) || (tim==1)) {
921: window.status='Done.';
922: if (tim==0) {
923: clearTimeout(canceltim);
924: $configmenu
925: window.location='$lowerurl';
926: } else {
927: window.location='/adm/remote?action=collapse&url=$esclowerurl';
928: }
929: } else {
930: wheelswitch();
931: setTimeout('wait();',200);
932: }
933: }
934:
935: function main() {
936: canceltim=setTimeout('tim=1;',30000);
937: window.status='-';
938: var date=new Date();
939: timestart=date.getTime();
940: wait();
941: }
942:
943: </script>
944: ENDREMOTESTARTUP
945: }
946:
947: sub setflags() {
948: return(<<ENDSETFLAGS);
949: <script type="text/javascript">
950: menuloaded=0;
951: tim=0;
952: </script>
953: ENDSETFLAGS
954: }
955:
956: sub maincall() {
957: if (($env{'browser.interface'} eq 'textual') ||
958: ($env{'environment.remote'} eq 'off')) { return ''; }
959: return(<<ENDMAINCALL);
960: <script type="text/javascript">
961: main();
962: </script>
963: ENDMAINCALL
964: }
965:
966: sub load_remote_msg {
967: my ($lowerurl)=@_;
968:
969: if (($env{'browser.interface'} eq 'textual') ||
970: ($env{'environment.remote'} eq 'off')) { return ''; }
971:
972: my $esclowerurl=&escape($lowerurl);
973: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
974: ,'<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">'
975: ,'</a>');
976: return(<<ENDREMOTEFORM);
977: <p>
978: <form name="wheel">
979: <input name="spin" type="text" size="60" />
980: </form>
981: </p>
982: <p>$link</p>
983: ENDREMOTEFORM
984: }
985:
986: sub get_menu_name {
987: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
988: $hostid =~ s/\W//g;
989: return 'LCmenu'.$hostid;
990: }
991:
992:
993: sub reopenmenu {
994: if (($env{'browser.interface'} eq 'textual') ||
995: ($env{'environment.remote'} eq 'off')) { return ''; }
996: my $menuname = &get_menu_name();
997: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
998: return('window.open('.$nothing.',"'.$menuname.'","",false);');
999: }
1000:
1001:
1002: sub open {
1003: my $returnval='';
1004: if (($env{'browser.interface'} eq 'textual') ||
1005: ($env{'environment.remote'} eq 'off')) {
1006: return '<script type="text/javascript">self.name="loncapaclient";</script>';
1007: }
1008: my $menuname = &get_menu_name();
1009:
1010: # unless (shift eq 'unix') {
1011: # resizing does not work on linux because of virtual desktop sizes
1012: # $returnval.=(<<ENDRESIZE);
1013: #if (window.screen) {
1014: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1015: # self.moveTo(190,15);
1016: #}
1017: #ENDRESIZE
1018: # }
1019: $returnval.=(<<ENDOPEN);
1020: window.status='Opening LON-CAPA Remote Control';
1021: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1022: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1023: self.name='loncapaclient';
1024: ENDOPEN
1025: return '<script type="text/javascript">'.$returnval.'</script>';
1026: }
1027:
1028:
1029: # ================================================================== Raw Config
1030:
1031: sub clear {
1032: my ($row,$col)=@_;
1033: unless (($env{'browser.interface'} eq 'textual') ||
1034: ($env{'environment.remote'} eq 'off')) {
1035: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1036: } else {
1037: $inlineremote[10*$row+$col]='';
1038: return '';
1039: }
1040: }
1041:
1042: # ============================================ Switch a button or create a link
1043: # Switch acts on the javascript that is executed when a button is clicked.
1044: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1045:
1046: sub switch {
1047: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1048: $act=~s/\$uname/$uname/g;
1049: $act=~s/\$udom/$udom/g;
1050: $top=&mt($top);
1051: $bot=&mt($bot);
1052: $desc=&mt($desc);
1053: if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
1054: $img=&mt($img);
1055: }
1056: my $idx=10*$row+$col;
1057: $category_members{$cat}.=':'.$idx;
1058:
1059: unless (($env{'browser.interface'} eq 'textual') ||
1060: ($env{'environment.remote'} eq 'off')) {
1061: # Remote
1062: return "\n".
1063: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1064: } elsif ($env{'browser.interface'} eq 'textual') {
1065: # Accessibility
1066: if ($nobreak==2) { return ''; }
1067: my $text=$top.' '.$bot;
1068: $text=~s/\s*\-\s*//gs;
1069: if ($nobreak) {
1070: $inlineremote[$idx]=
1071: '<a href="javascript:'.$act.';">'.$text.'</a>';
1072: } else {
1073: $inlineremote[$idx]="\n<br />".
1074: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
1075: }
1076: } else {
1077: # Inline Remote
1078: if ($env{'environment.icons'} ne 'classic') {
1079: $img=~s/\.gif$/\.png/;
1080: }
1081: if ($nobreak==2) { return ''; }
1082: my $text=$top.' '.$bot;
1083: $text=~s/\s*\-\s*//gs;
1084:
1085: my $pic=
1086: '<img alt="'.$text.'" src="'.
1087: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1088: '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
1089: if ($env{'browser.interface'} eq 'faketextual') {
1090: # Accessibility
1091: if ($nobreak==3) {
1092: $inlineremote[$idx]="\n".
1093: '<td class="LC_menubuttons_text" align="right">'.$text.
1094: '</td><td align="left">'.
1095: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1096: } elsif ($nobreak) {
1097: $inlineremote[$idx]="\n<tr>".
1098: '<td align="left">'.
1099: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1100: <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>';
1101: } else {
1102: $inlineremote[$idx]="\n<tr>".
1103: '<td align="left">'.
1104: '<a href="javascript:'.$act.';">'.$pic.
1105: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1106: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1107: }
1108: } else {
1109: # Inline Menu
1110: if ($env{'environment.icons'} eq 'iconsonly') {
1111: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
1112: } else {
1113: $inlineremote[$idx]=
1114: '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1115: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1116: }
1117: }
1118: }
1119: return '';
1120: }
1121:
1122: sub secondlevel {
1123: my $output='';
1124: my
1125: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1126: if ($prt eq 'any') {
1127: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1128: } elsif ($prt=~/^r(\w+)/) {
1129: if ($rol eq $1) {
1130: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1131: }
1132: }
1133: return $output;
1134: }
1135:
1136: sub openmenu {
1137: my $menuname = &get_menu_name();
1138: if (($env{'browser.interface'} eq 'textual') ||
1139: ($env{'environment.remote'} eq 'off')) { return ''; }
1140: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1141: return "window.open(".$nothing.",'".$menuname."');";
1142: }
1143:
1144: sub inlinemenu {
1145: undef(@inlineremote);
1146: undef(%category_members);
1147: &rawconfig(1);
1148: my $output='<table id="LC_mainmenu"><tr>';
1149: for (my $col=1; $col<=2; $col++) {
1150: $output.='<td class="LC_mainmenu_col_fieldset">';
1151: for (my $row=1; $row<=8; $row++) {
1152: foreach my $cat (keys(%category_members)) {
1153: if ($category_positions{$cat} ne "$col,$row") { next; }
1154: #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1155: $output.='<div class="LC_ContentBoxSpecial">';
1156: $output.='<h4 class="LC_hcell">'.&mt($category_names{$cat}).'</h4>';
1157: $output.='<table>';
1158: my %active=();
1159: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1160: if ($inlineremote[$menu_item]) {
1161: $active{$menu_item}=1;
1162: }
1163: }
1164: foreach my $item (sort(keys(%active))) {
1165: $output.=$inlineremote[$item];
1166: }
1167: $output.='</table>';
1168: $output.='</div>';
1169: }
1170: }
1171: $output.="</td>";
1172: }
1173: $output.="</tr></table>";
1174: return $output;
1175: }
1176:
1177: sub rawconfig {
1178: my $textualoverride=shift;
1179: my $output='';
1180: unless (($env{'browser.interface'} eq 'textual') ||
1181: ($env{'environment.remote'} eq 'off')) {
1182: $output.=
1183: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1184: "\nwindow.status='Configuring Remote Control ';";
1185: } else {
1186: unless ($textualoverride) { return ''; }
1187: }
1188: my $uname=$env{'user.name'};
1189: my $udom=$env{'user.domain'};
1190: my $adv=$env{'user.adv'};
1191: my $show_course=&Apache::loncommon::show_course();
1192: my $author=$env{'user.author'};
1193: my $crs='';
1194: if ($env{'request.course.id'}) {
1195: $crs='/'.$env{'request.course.id'};
1196: if ($env{'request.course.sec'}) {
1197: $crs.='_'.$env{'request.course.sec'};
1198: }
1199: $crs=~s/\_/\//g;
1200: }
1201: my $pub=($env{'request.state'} eq 'published');
1202: my $con=($env{'request.state'} eq 'construct');
1203: my $rol=$env{'request.role'};
1204: my $requested_domain = $env{'request.role.domain'};
1205: foreach my $line (@desklines) {
1206: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1207: $prt=~s/\$uname/$uname/g;
1208: $prt=~s/\$udom/$udom/g;
1209: $prt=~s/\$crs/$crs/g;
1210: $prt=~s/\$requested_domain/$requested_domain/g;
1211: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1212: my $type = &Apache::loncommon::course_type();
1213: if ($type eq 'Group') {
1214: $desc = &convert_menu_function($desc,$type);
1215: }
1216: if ($pro eq 'clear') {
1217: $output.=&clear($row,$col);
1218: } elsif ($pro eq 'any') {
1219: $output.=&secondlevel(
1220: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1221: } elsif ($pro eq 'smp') {
1222: unless ($adv) {
1223: $output.=&secondlevel(
1224: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1225: }
1226: } elsif ($pro eq 'adv') {
1227: if ($adv) {
1228: $output.=&secondlevel(
1229: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1230: }
1231: } elsif ($pro eq 'shc') {
1232: if ($show_course) {
1233: $output.=&secondlevel(
1234: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1235: }
1236: } elsif ($pro eq 'nsc') {
1237: if (!$show_course) {
1238: $output.=&secondlevel(
1239: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1240: }
1241: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1242: if (&Apache::lonnet::allowed($1,$prt)) {
1243: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1244: }
1245: } elsif ($pro eq 'course') {
1246: if ($env{'request.course.fn'}) {
1247: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1248: }
1249: } elsif ($pro =~ /^courseenv_(.*)$/) {
1250: my $key = $1;
1251: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1252: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1253: }
1254: } elsif ($pro =~ /^course_(.*)$/) {
1255: # Check for permissions inside of a course
1256: if (($env{'request.course.id'}) &&
1257: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1258: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1259: )) {
1260: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1261: }
1262: } elsif ($pro eq 'author') {
1263: if ($author) {
1264: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1265: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1266: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1267: # Check that we are on the correct machine
1268: my $cadom=$requested_domain;
1269: my $caname=$env{'user.name'};
1270: if (($prt eq 'rca') || ($prt eq 'raa')) {
1271: ($cadom,$caname)=
1272: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1273: }
1274: $act =~ s/\$caname/$caname/g;
1275: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1276: my $allowed=0;
1277: my @ids=&Apache::lonnet::current_machine_ids();
1278: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1279: if ($allowed) {
1280: $output.=&switch($caname,$cadom,
1281: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1282: }
1283: }
1284: }
1285: } elsif ($pro eq 'tools') {
1286: my @tools = ('aboutme','blog','portfolio');
1287: if (grep(/^\Q$prt\E$/,@tools)) {
1288: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1289: $env{'user.domain'},
1290: $prt,undef,'tools')) {
1291: $output.=&clear($row,$col);
1292: next;
1293: }
1294: } elsif ($prt eq 'reqcrs') {
1295: my $showreqcrs = 0;
1296: foreach my $type ('official','unofficial') {
1297: if (&Apache::lonnet::usertools_access($env{'user.name'},
1298: $env{'user.domain'},
1299: $type,undef,'requestcourses')) {
1300: $showreqcrs = 1;
1301: last;
1302: }
1303: }
1304: if (!$showreqcrs) {
1305: $output.=&clear($row,$col);
1306: next;
1307: }
1308: }
1309: $prt='any';
1310: $output.=&secondlevel(
1311: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1312: }
1313: }
1314: unless (($env{'browser.interface'} eq 'textual') ||
1315: ($env{'environment.remote'} eq 'off')) {
1316: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1317: if (&Apache::lonmsg::newmail()) {
1318: $output.='swmenu.setstatus("you have","messages");';
1319: }
1320: }
1321:
1322: return $output;
1323: }
1324:
1325: # ======================================================================= Close
1326:
1327: sub close {
1328: if (($env{'browser.interface'} eq 'textual') ||
1329: ($env{'environment.remote'} eq 'off')) { return ''; }
1330: my $menuname = &get_menu_name();
1331: return(<<ENDCLOSE);
1332: <script type="text/javascript">
1333: window.status='Accessing Remote Control';
1334: menu=window.open("/adm/rat/empty.html","$menuname",
1335: "height=350,width=150,scrollbars=no,menubar=no");
1336: window.status='Disabling Remote Control';
1337: menu.active=0;
1338: menu.autologout=0;
1339: window.status='Closing Remote Control';
1340: menu.close();
1341: window.status='Done.';
1342: </script>
1343: ENDCLOSE
1344: }
1345:
1346: # ====================================================================== Footer
1347:
1348: sub footer {
1349:
1350: }
1351:
1352: sub nav_control_js {
1353: my $nav=($env{'environment.remotenavmap'} eq 'on');
1354: return (<<NAVCONTROL);
1355: var w_loncapanav_flag="$nav";
1356:
1357:
1358: function gonav(url) {
1359: if (w_loncapanav_flag != 1) {
1360: gopost(url,'');
1361: } else {
1362: navwindow=window.open(url,
1363: "loncapanav","height=600,width=400,scrollbars=1");
1364: }
1365: }
1366: NAVCONTROL
1367: }
1368:
1369: sub utilityfunctions {
1370: my $caller = shift;
1371: unless (($env{'browser.interface'} eq 'textual') ||
1372: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1373: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1374: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1375:
1376: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1377: my $nav_control=&nav_control_js();
1378:
1379: my $start_page_annotate =
1380: &Apache::loncommon::start_page('Annotator',undef,
1381: {'only_body' => 1,
1382: 'js_ready' => 1,
1383: 'bgcolor' => '#BBBBBB',
1384: 'add_entries' => {
1385: 'onload' => 'javascript:document.goannotate.submit();'}});
1386:
1387: my $end_page_annotate =
1388: &Apache::loncommon::end_page({'js_ready' => 1});
1389:
1390: my $start_page_bookmark =
1391: &Apache::loncommon::start_page('Bookmarks',undef,
1392: {'only_body' => 1,
1393: 'js_ready' => 1,
1394: 'bgcolor' => '#BBBBBB',});
1395:
1396: my $end_page_bookmark =
1397: &Apache::loncommon::end_page({'js_ready' => 1});
1398:
1399: return (<<ENDUTILITY)
1400:
1401: var currentURL="$currenturl";
1402: var reloadURL="$currenturl";
1403: var currentSymb="$currentsymb";
1404:
1405: $nav_control
1406:
1407: function go(url) {
1408: if (url!='' && url!= null) {
1409: currentURL = null;
1410: currentSymb= null;
1411: window.location.href=url;
1412: }
1413: }
1414:
1415: function gopost(url,postdata) {
1416: if (url!='') {
1417: this.document.server.action=url;
1418: this.document.server.postdata.value=postdata;
1419: this.document.server.command.value='';
1420: this.document.server.url.value='';
1421: this.document.server.symb.value='';
1422: this.document.server.submit();
1423: }
1424: }
1425:
1426: function gocmd(url,cmd) {
1427: if (url!='') {
1428: this.document.server.action=url;
1429: this.document.server.postdata.value='';
1430: this.document.server.command.value=cmd;
1431: this.document.server.url.value=currentURL;
1432: this.document.server.symb.value=currentSymb;
1433: this.document.server.submit();
1434: }
1435: }
1436:
1437: function gocstr(url,filename) {
1438: if (url == '/adm/cfile?action=delete') {
1439: this.document.cstrdelete.filename.value = filename
1440: this.document.cstrdelete.submit();
1441: return;
1442: }
1443: if (url == '/adm/printout') {
1444: this.document.cstrprint.postdata.value = filename
1445: this.document.cstrprint.curseed.value = 0;
1446: this.document.cstrprint.problemtype.value = 0;
1447: if (this.document.lonhomework) {
1448: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1449: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1450: }
1451: if (this.document.lonhomework.problemtype) {
1452: if (this.document.lonhomework.problemtype.value) {
1453: this.document.cstrprint.problemtype.value =
1454: this.document.lonhomework.problemtype.value;
1455: } else if (this.document.lonhomework.problemtype.options) {
1456: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1457: if (this.document.lonhomework.problemtype.options[i].selected) {
1458: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1459: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1460: }
1461: }
1462: }
1463: }
1464: }
1465: }
1466: this.document.cstrprint.submit();
1467: return;
1468: }
1469: if (url !='') {
1470: this.document.constspace.filename.value = filename;
1471: this.document.constspace.action = url;
1472: this.document.constspace.submit();
1473: }
1474: }
1475:
1476: function golist(url) {
1477: if (url!='' && url!= null) {
1478: currentURL = null;
1479: currentSymb= null;
1480: top.location.href=url;
1481: }
1482: }
1483:
1484:
1485:
1486: function catalog_info() {
1487: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1488: }
1489:
1490: function chat_win() {
1491: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1492: }
1493:
1494: function group_chat(group) {
1495: var url = '/adm/groupchat?group='+group;
1496: var winName = 'LONchat_'+group;
1497: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1498: }
1499:
1500: function edit_bookmarks() {
1501: go('');
1502: w_BookmarkPal_flag=1;
1503: bookmarkpal=window.open("/adm/bookmarks",
1504: "BookmarkPal", "width=400,height=505,scrollbars=0");
1505: }
1506:
1507: function annotate() {
1508: w_Annotator_flag=1;
1509: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1510: annotator.document.write(
1511: '$start_page_annotate'
1512: +"<form name='goannotate' target='Annotator' method='post' "
1513: +"action='/adm/annotations'>"
1514: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1515: +"<\\/form>"
1516: +'$end_page_annotate');
1517: annotator.document.close();
1518: }
1519:
1520: function set_bookmark() {
1521: go('');
1522: clienttitle=document.title;
1523: clienthref=location.pathname;
1524: w_bmquery_flag=1;
1525: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1526: bmquery.document.write(
1527: '$start_page_bookmark'
1528: +'<center><form method="post"'
1529: +' name="newlink" action="/adm/bookmarks" target="bmquery" '
1530: +'> <table width="340" height="150" '
1531: +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
1532: +'type="text" name="title" size="45" value="'+clienttitle+'" />'
1533: +'<br />Address:<br /><input type="text" name="address" size="45" '
1534: +'value="'+clienthref+'" /><br /><center><input type="submit" '
1535: +'value="Save" /> <input type="button" value="Close" '
1536: +'onclick="javascript:window.close();" /></center></td>'
1537: +'</tr></table></form></center>'
1538: +'$end_page_bookmark' );
1539: bmquery.document.close();
1540: }
1541:
1542: ENDUTILITY
1543: }
1544:
1545: sub serverform {
1546: return(<<ENDSERVERFORM);
1547: <form name="server" action="/adm/logout" method="post" target="_top">
1548: <input type="hidden" name="postdata" value="none" />
1549: <input type="hidden" name="command" value="none" />
1550: <input type="hidden" name="url" value="none" />
1551: <input type="hidden" name="symb" value="none" />
1552: </form>
1553: ENDSERVERFORM
1554: }
1555:
1556: sub constspaceform {
1557: return(<<ENDCONSTSPACEFORM);
1558: <form name="constspace" action="/adm/logout" method="post" target="_top">
1559: <input type="hidden" name="filename" value="" />
1560: </form>
1561: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1562: <input type="hidden" name="action" value="delete" />
1563: <input type="hidden" name="filename" value="" />
1564: </form>
1565: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1566: <input type="hidden" name="postdata" value="" />
1567: <input type="hidden" name="curseed" value="" />
1568: <input type="hidden" name="problemtype" value="" />
1569: </form>
1570:
1571: ENDCONSTSPACEFORM
1572: }
1573:
1574:
1575: sub get_nav_status {
1576: my $navstatus="swmenu.w_loncapanav_flag=";
1577: if ($env{'environment.remotenavmap'} eq 'on') {
1578: $navstatus.="1";
1579: } else {
1580: $navstatus.="-1";
1581: }
1582: return $navstatus;
1583: }
1584:
1585: #FIXME this needs to move into mydesktab and the other locations
1586: # the text is generated
1587: sub convert_menu_function {
1588: my ($rolename,$type) = @_;
1589: if ($type eq 'Group') {
1590: $rolename =~ s/student/member/g;
1591: $rolename =~ s/group/team/g;
1592: $rolename =~ s/course/group/g;
1593: $rolename =~ s/Course/Group/g;
1594: }
1595: return $rolename;
1596: }
1597:
1598: sub hidden_button_check {
1599: my $hidden;
1600: if ($env{'request.course.id'} eq '') {
1601: return;
1602: }
1603: if ($env{'request.role.adv'}) {
1604: return;
1605: }
1606: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1607: return $buttonshide;
1608: }
1609:
1610: sub roles_selector {
1611: my ($cdom,$cnum) = @_;
1612: my $now = time;
1613: my (%courseroles,%seccount);
1614: my $is_cc;
1615: my $role_selector;
1616: if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
1617: my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum});
1618:
1619: if ((($start) && ($start<0)) ||
1620: (($end) && ($end<$now)) ||
1621: (($start) && ($now<$start))) {
1622: $is_cc = 0;
1623: } else {
1624: $is_cc = 1;
1625: }
1626: }
1627: if ($is_cc) {
1628: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1629: } else {
1630: my %gotnosection;
1631: foreach my $item (keys(%env)) {
1632: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1633: my $role = $1;
1634: my $sec = $2;
1635: next if ($role eq 'gr');
1636: my ($start,$end) = split(/\./,$env{$item});
1637: next if (($start && $start > $now) || ($end && $end < $now));
1638: if ($sec eq '') {
1639: if (!$gotnosection{$role}) {
1640: $seccount{$role} ++;
1641: $gotnosection{$role} = 1;
1642: }
1643: }
1644: if (ref($courseroles{$role}) eq 'ARRAY') {
1645: if ($sec ne '') {
1646: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1647: push(@{$courseroles{$role}},$sec);
1648: $seccount{$role} ++;
1649: }
1650: }
1651: } else {
1652: @{$courseroles{$role}} = ();
1653: if ($sec ne '') {
1654: $seccount{$role} ++;
1655: push(@{$courseroles{$role}},$sec);
1656: }
1657: }
1658: }
1659: }
1660: }
1661: my @roles_order = ('cc','in','ta','ep','ad','st');
1662: if (keys(%courseroles) > 1) {
1663: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1664: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
1665: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1666: $role_selector .= '<option value="">'.&mt('Switch course role to...').'</option>';
1667: foreach my $role (@roles_order) {
1668: if (defined($courseroles{$role})) {
1669: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1670: }
1671: }
1672: foreach my $role (sort(keys(%courseroles))) {
1673: if ($role =~ /^cr/) {
1674: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
1675: }
1676: }
1677: $role_selector .= '</select>'."\n".
1678: '<input type="hidden" name="destinationurl" value="'.
1679: $ENV{'REQUEST_URI'}.'" />'."\n".
1680: '<input type="hidden" name="gotorole" value="1" />'."\n".
1681: '<input type="hidden" name="selectrole" value="" />'."\n".
1682: '<input type="hidden" name="switch" value="1" />'."\n".
1683: '</form>';
1684: }
1685: return $role_selector;
1686: }
1687:
1688: sub get_all_courseroles {
1689: my ($cdom,$cnum,$courseroles,$seccount) = @_;
1690: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
1691: return;
1692: }
1693: my ($result,$cached) =
1694: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
1695: if (defined($cached)) {
1696: if (ref($result) eq 'HASH') {
1697: if ((ref($result->{'roles'}) eq 'HASH') &&
1698: (ref($result->{'seccount'}) eq 'HASH')) {
1699: %{$courseroles} = %{$result->{'roles'}};
1700: %{$seccount} = %{$result->{'seccount'}};
1701: return;
1702: }
1703: }
1704: }
1705: my %gotnosection;
1706: my %adv_roles =
1707: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1708: foreach my $role (keys(%adv_roles)) {
1709: my ($urole,$usec) = split(/:/,$role);
1710: if (!$gotnosection{$urole}) {
1711: $seccount->{$urole} ++;
1712: $gotnosection{$urole} = 1;
1713: }
1714: if (ref($courseroles->{$urole}) eq 'ARRAY') {
1715: if ($usec ne '') {
1716: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
1717: push(@{$courseroles->{$urole}},$usec);
1718: $seccount->{$urole} ++;
1719: }
1720: }
1721: } else {
1722: @{$courseroles->{$urole}} = ();
1723: if ($usec ne '') {
1724: $seccount->{$urole} ++;
1725: push(@{$courseroles->{$urole}},$usec);
1726: }
1727: }
1728: }
1729: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
1730: @{$courseroles->{'st'}} = ();
1731: if (keys(%sections_count) > 0) {
1732: push(@{$courseroles->{'st'}},keys(%sections_count));
1733: $seccount->{'st'} = scalar(keys(%sections_count));
1734: }
1735: my $rolehash = {
1736: 'roles' => $courseroles,
1737: 'seccount' => $seccount,
1738: };
1739: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
1740: return;
1741: }
1742:
1743: sub jump_to_role {
1744: my ($cdom,$cnum,$seccount,$courseroles) = @_;
1745: my %lt = &Apache::lonlocal::texthash(
1746: this => 'This role has section(s) associated with it.',
1747: ente => 'Enter a specific section.',
1748: orlb => 'Enter a specific section, or leave blank for no section.',
1749: avai => 'Available sections are:',
1750: youe => 'You entered an invalid section choice:',
1751: plst => 'Please try again',
1752: );
1753: my $js;
1754: if (ref($courseroles) eq 'HASH') {
1755: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
1756: ' var numsec = new Array();'."\n".
1757: ' var rolesections = new Array();'."\n".
1758: ' var rolenames = new Array();'."\n".
1759: ' var roleseclist = new Array();'."\n";
1760: my @items = keys(%{$courseroles});
1761: for (my $i=0; $i<@items; $i++) {
1762: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
1763: my ($secs,$secstr);
1764: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
1765: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
1766: $secs = join('","',@sections);
1767: $secstr = join(', ',@sections);
1768: }
1769: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
1770: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
1771: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
1772: }
1773: }
1774: my $output = <<"END";
1775: <script type="text/javascript">
1776: function adhocRole(roleitem) {
1777: $js
1778: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
1779: if (newrole == '') {
1780: return;
1781: }
1782: var fullrole = newrole+'./$cdom/$cnum';
1783: var selidx = '';
1784: for (var i=0; i<rolenames.length; i++) {
1785: if (rolenames[i] == newrole) {
1786: selidx = i;
1787: }
1788: }
1789: var secok = 1;
1790: var secchoice = '';
1791: if (selidx >= 0) {
1792: if (numsec[selidx] > 1) {
1793: secok = 0;
1794: var numrolesec = rolesections[selidx].length;
1795: var msgidx = numsec[selidx] - numrolesec;
1796: secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
1797: if (secchoice == '') {
1798: if (msgidx > 0) {
1799: secok = 1;
1800: }
1801: } else {
1802: for (var j=0; j<rolesections[selidx].length; j++) {
1803: if (rolesections[selidx][j] == secchoice) {
1804: secok = 1;
1805: }
1806: }
1807: }
1808: } else {
1809: if (rolesections[selidx].length == 1) {
1810: secchoice = rolesections[selidx][0];
1811: }
1812: }
1813: }
1814: if (secok == 1) {
1815: if (secchoice != '') {
1816: fullrole += '/'+secchoice;
1817: }
1818: } else {
1819: document.rolechooser.elements[roleitem].selectedIndex = 0;
1820: if (secchoice != null) {
1821: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
1822: }
1823: return;
1824: }
1825: if (fullrole == "$env{'request.role'}") {
1826: return;
1827: }
1828: itemid = retrieveIndex('gotorole');
1829: if (itemid != -1) {
1830: document.rolechooser.elements[itemid].name = fullrole;
1831: }
1832: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1833: document.rolechooser.selectrole.value = '1';
1834: document.rolechooser.submit();
1835: return;
1836: }
1837:
1838: function retrieveIndex(item) {
1839: for (var i=0;i<document.rolechooser.elements.length;i++) {
1840: if (document.rolechooser.elements[i].name == item) {
1841: return i;
1842: }
1843: }
1844: return -1;
1845: }
1846:
1847:
1848: </script>
1849: END
1850: return $output;
1851: }
1852:
1853:
1854: # ================================================================ Main Program
1855:
1856: BEGIN {
1857: if (! defined($readdesk)) {
1858: {
1859: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1860: if ( CORE::open( my $config,"<$tabfile") ) {
1861: while (my $configline=<$config>) {
1862: $configline=(split(/\#/,$configline))[0];
1863: $configline=~s/^\s+//;
1864: chomp($configline);
1865: if ($configline=~/^cat\:/) {
1866: my @entries=split(/\:/,$configline);
1867: $category_positions{$entries[2]}=$entries[1];
1868: $category_names{$entries[2]}=$entries[3];
1869: } elsif ($configline) {
1870: push(@desklines,$configline);
1871: }
1872: }
1873: CORE::close($config);
1874: }
1875: }
1876: $readdesk='done';
1877: }
1878: }
1879:
1880: 1;
1881: __END__
1882:
1883:
1884:
1885:
1886:
1887:
1888:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>