1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.233 2008/01/15 16:53:27 www 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: package Apache::lonmenu;
40:
41: use strict;
42: use Apache::lonnet;
43: use Apache::lonhtmlcommon();
44: use Apache::loncommon();
45: use Apache::lonenc();
46: use Apache::lonlocal;
47: use LONCAPA qw(:DEFAULT :match);
48:
49: use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
50:
51:
52: my @inlineremote;
53:
54:
55:
56: # ================================================================ Little texts
57: sub show_course {
58: my $course = !$env{'user.adv'};
59: if (!$env{'user.adv'}) {
60: foreach my $env (keys(%env)) {
61: next if ($env !~ m/^user\.priv\./);
62: if ($env !~ m/^user\.priv\.(?:st|cm)/) {
63: $course = 0;
64: last;
65: }
66: }
67: }
68: return $course;
69: }
70:
71: sub initlittle {
72: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
73: 'nav' => 'Navigate Contents',
74: 'main' => 'Main Menu',
75: 'roles' => (&show_course()?
76: 'Courses':'Roles'),
77: 'docs' => 'Edit Course',
78: 'exit' => 'Exit',
79: 'login' => 'Log In',
80: 'launch' => 'Launch Remote Control',
81: 'groups' => 'Groups',
82: 'gdoc' => 'Group Documents',
83: );
84: }
85:
86: # ============================= This gets called at the top of the body section
87:
88: sub menubuttons {
89: my $forcereg=shift;
90: my $registration=shift;
91: my $titletable=shift;
92: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
93: ['inhibitmenu']);
94: if (($env{'form.inhibitmenu'} eq 'yes') ||
95: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
96:
97: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
98:
99: my %lt=&initlittle();
100: my $navmaps='';
101: my $reloadlink='';
102: my $docs='';
103: my $groups='';
104: my $showgroups=0;
105: my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
106: my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
107:
108: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
109: $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.
110: $logo.'" alt="LON-CAPA Logo" /></a></td>';
111:
112: if ($env{'request.state'} eq 'construct') {
113: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
114: my $returnurl = $env{'request.filename'};
115: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
116: $escurl = &escape($returnurl);
117: }
118: }
119: if ($env{'request.course.id'}) {
120: my %coursegroups;
121: my $viewgrps_permission =
122: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
123: if (!$viewgrps_permission) {
124: %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
125: }
126: if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
127: $showgroups = 1;
128: }
129: }
130:
131: if ($env{'browser.interface'} eq 'textual') {
132: # Textual display only
133: if ($env{'request.course.id'}) {
134: $navmaps=(<<ENDNAV);
135: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
136: ENDNAV
137: if (&show_return_link()) {
138: my $escreload=&escape('return:');
139: $reloadlink=(<<ENDRELOAD);
140: <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
141: ENDRELOAD
142: }
143: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
144: $docs=(<<ENDDOCS);
145: <a href="/adm/coursedocs" target="_top">$lt{'docs'}</a>
146: ENDDOCS
147: }
148: if ($showgroups) {
149: $groups =(<<ENDGROUPS);
150: <a href="/adm/coursegroups" target="_top">$lt{'groups'}</a>
151: ENDGROUPS
152: }
153: }
154: my $form=&serverform();
155: my $utility=&utilityfunctions();
156: my $output=(<<ENDMAINMENU);
157: <script type="text/javascript">
158: // BEGIN LON-CAPA Internal
159: $utility
160: </script>
161: <div id="LC_top_nav">
162: <a href="/adm/menu" target="_top">$lt{'main'}</a>
163: $reloadlink $navmaps $docs $groups
164: <a href="/adm/roles" target="_top">$lt{'roles'}</a>
165: <a href="/adm/logout" target="_top">$lt{'exit'}</a>
166: </div>
167: <br />
168: <script type="text/javascript">
169: // END LON-CAPA Internal
170: </script>
171: $form
172: ENDMAINMENU
173: if ($registration) { $output.=&innerregister($forcereg); }
174: return $output."<hr />";
175: } elsif ($env{'environment.remote'} eq 'off') {
176: # Remote Control is switched off
177: # figure out colors
178: my %lt=&initlittle();
179:
180: my $domain=&Apache::loncommon::determinedomain();
181: my $function =&Apache::loncommon::get_users_function();
182: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
183: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
184: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
185: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
186: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
187: return (<<ENDINLINEMENU);
188: <table id="LC_top_nav">
189: <tr>
190: $logo
191: <td></td>
192: <td class="LC_top_nav_login">
193: <a href="/adm/roles" target="_top">$lt{'login'}</a>
194: </td>
195: </tr>
196: </table>
197: </font>
198: ENDINLINEMENU
199: }
200: # Do we have a NAV link?
201: if ($env{'request.course.id'}) {
202: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
203: $escsymb;
204: if ($env{'environment.remotenavmap'} eq 'on') {
205: $link="javascript:gonav('".$link."')";
206: }
207: $navmaps=(<<ENDNAV);
208: <td><a href="$link" target="_top">$lt{'nav'}</a></td>
209: ENDNAV
210: my $is_group = (&Apache::loncommon::course_type() eq 'Group');
211: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
212: my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
213: $docs=(<<ENDDOCS);
214: <td><a href="/adm/coursedocs" target="_top">$text</a></td>
215: ENDDOCS
216: }
217: if ($showgroups) {
218: $groups =(<<ENDGROUPS);
219: <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>
220: ENDGROUPS
221: }
222: if (&show_return_link()) {
223: my $escreload=&escape('return:');
224: $reloadlink=(<<ENDRELOAD);
225: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
226: ENDRELOAD
227: }
228: }
229: if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
230: my $escreload=&escape('return:');
231: $reloadlink=(<<ENDCRELOAD);
232: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
233: ENDCRELOAD
234: }
235: my $reg='';
236: if ($registration) {
237: $reg=&innerregister($forcereg,$titletable);
238: }
239: my $form=&serverform();
240: my $utility=&utilityfunctions();
241: my $remote;
242: if ($env{'user.adv'}) {
243: $remote = '<td><a href="/adm/remote?action=launch&url='.$escurl.'" target="_top">'.$lt{'launch'}.'</a></td>'
244: }
245:
246: my $helplink=&Apache::loncommon::top_nav_help('Help');
247: return (<<ENDINLINEMENU);
248: <script type="text/javascript">
249: // BEGIN LON-CAPA Internal
250: // <![CDATA[
251: $utility
252: // ]]>
253: </script>
254: <table id="LC_top_nav">
255: <tr>
256: $logo
257: <td><a href="/adm/menu" target="_top">$lt{'main'}</a></td>
258: $reloadlink
259: $navmaps
260: $docs
261: $groups
262: $remote
263: <td><a href="/adm/roles" target="_top">$lt{'roles'}</a></td>
264: <td class="LC_top_nav_help">$helplink</td>
265: <td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
266: </tr>
267: </table>
268: $form
269: <script type="text/javascript">
270: // END LON-CAPA Internal
271: </script>
272: $reg
273: ENDINLINEMENU
274: } else {
275: return '';
276: }
277: }
278:
279: sub show_return_link {
280: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
281: $env{'request.symb'} eq '')
282: ||
283: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
284: ||
285: (($env{'request.noversionuri'}=~/^\/adm\//) &&
286: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
287: ($env{'request.noversionuri'}!~
288: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
289: ));
290: }
291:
292: # ====================================== This gets called in the header section
293:
294: sub registerurl {
295: my ($forcereg) = @_;
296: my $result = '';
297: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
298: my $force_title='';
299: if ($env{'request.state'} eq 'construct') {
300: $force_title=&Apache::lonxml::display_title();
301: }
302: if (($env{'browser.interface'} eq 'textual') ||
303: ($env{'environment.remote'} eq 'off') ||
304: ((($env{'request.publicaccess'}) ||
305: (!&Apache::lonnet::is_on_map(
306: &unescape($env{'request.noversionuri'})))) &&
307: (!$forcereg))) {
308: return $result.
309: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
310: }
311: # Graphical display after login only
312: if ($env{'request.registered'} && !$forcereg) { return ''; }
313: $result.=&innerregister($forcereg);
314: return $result.$force_title;
315: }
316:
317: # =========== This gets called in order to register a URL, both with the Remote
318: # =========== and in the body of the document
319:
320: sub innerregister {
321: my ($forcereg, $titletable) = @_;
322: my $result = '';
323: my ($uname,$thisdisfn);
324: my $const_space = ($env{'request.state'} eq 'construct');
325: my $is_const_dir = 0;
326:
327: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
328:
329: $env{'request.registered'} = 1;
330:
331: my $textinter=($env{'browser.interface'} eq 'textual');
332: my $noremote=($env{'environment.remote'} eq 'off');
333:
334: my $textual=($textinter || $noremote);
335:
336: undef(@inlineremote);
337:
338: my $reopen=&Apache::lonmenu::reopenmenu();
339:
340: my $newmail='';
341: if ($noremote) {
342: $newmail='<table id="LC_nav_location"><tr>';
343: }
344: if (&Apache::lonmsg::newmail()) {
345: if ($textual) {
346: $newmail.= '<td class="LC_new_mail">
347: <a href="/adm/communicate" target="_top">'.
348: &mt('You have new messages').'</a></td>';
349: } else {
350: $newmail= 'swmenu.setstatus("you have","messages");';
351: }
352: }
353: if (($textual)
354: && ($env{'request.symb'})
355: && ($env{'request.course.id'})) {
356: $newmail.= '<td class="LC_current_location">';
357: my ($mapurl,$rid,$resurl)=
358: &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
359: my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
360: $newmail.=$coursetitle;
361: my $maptitle=&Apache::lonnet::gettitle($mapurl);
362: my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
363: if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
364: $newmail.=', '.$maptitle;
365: }
366: if ($restitle) {
367: $newmail.=': '.$restitle;
368: }
369: $newmail.=' </td>';
370: }
371: if ($env{'request.state'} eq 'construct') {
372: $newmail = $titletable;
373: } else {
374: if ($noremote) {
375: $newmail.='</tr></table>';
376: }
377: }
378: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
379: my $tablestart=($noremote?'<table id="LC_menubuttons">':'').
380: ($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
381: my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':'');
382: # =============================================================================
383: # ============================ This is for URLs that actually can be registered
384: if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
385: # -- This applies to homework problems for users with grading privileges
386: my $crs='/'.$env{'request.course.id'};
387: if ($env{'request.course.sec'}) {
388: $crs.='_'.$env{'request.course.sec'};
389: }
390: $crs=~s/\_/\//g;
391:
392: my $hwkadd='';
393: if ($env{'request.symb'} ne '' &&
394: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
395: if (&Apache::lonnet::allowed('mgr',$crs)) {
396: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
397: "gocmd('/adm/grades','gradingmenu')",
398: 'Modify user grades for this assessment resource');
399: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
400: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
401: "gocmd('/adm/grades','submission')",
402: 'View user submissions for this assessment resource');
403: }
404: }
405: if ($env{'request.symb'} ne '' &&
406: &Apache::lonnet::allowed('opa',$crs)) {
407: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
408: "gocmd('/adm/parmset','set')",
409: 'Modify parameter settings for this resource');
410: }
411: # -- End Homework
412: ###
413: ### Determine whether or not to display the 'cstr' button for this
414: ### resource
415: ###
416: my $editbutton = '';
417: if ($env{'user.author'}) {
418: if ($env{'request.role'}=~/^(ca|au)/) {
419: # Set defaults for authors
420: my ($top,$bottom) = ('con-','struct');
421: my $action = "go('/priv/".$env{'user.name'}."');";
422: my $cadom = $env{'request.role.domain'};
423: my $caname = $env{'user.name'};
424: my $desc = "Enter my resource construction space";
425: # Set defaults for co-authors
426: if ($env{'request.role'} =~ /^ca/) {
427: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
428: ($top,$bottom) = ('co con-','struct');
429: $action = "go('/priv/".$caname."');";
430: $desc = "Enter construction space as co-author";
431: }
432: # Check that we are on the correct machine
433: my $home = &Apache::lonnet::homeserver($caname,$cadom);
434: my $allowed=0;
435: my @ids=&Apache::lonnet::current_machine_ids();
436: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
437: if (!$allowed) {
438: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
439: }
440: }
441: ##
442: ## Determine if user can edit url.
443: ##
444: my $cfile='';
445: my $cfuname='';
446: my $cfudom='';
447: if ($env{'request.filename'}) {
448: my $file=&Apache::lonnet::declutter($env{'request.filename'});
449: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
450: # Check that the user has permission to edit this resource
451: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
452: if (defined($cfudom)) {
453: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
454: my $allowed=0;
455: my @ids=&Apache::lonnet::current_machine_ids();
456: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
457: if ($allowed) {
458: $cfile=$file;
459: }
460: }
461: }
462: # Finally, turn the button on or off
463: if ($cfile && !$const_space) {
464: $editbutton=&switch
465: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
466: "go('".$cfile."');","Edit this resource");
467: } elsif ($editbutton eq '') {
468: $editbutton=&clear(6,1);
469: }
470: }
471: ###
472: ###
473: # Prepare the rest of the buttons
474: my $menuitems;
475: if ($const_space) {
476: my ($uname,$thisdisfn) =
477: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
478: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
479: if ($currdir =~ m-/$-) {
480: $is_const_dir = 1;
481: } else {
482: $currdir =~ s#[^/]+$##;
483: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
484: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
485: $menuitems=(<<ENDMENUITEMS);
486: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
487: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
488: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
489: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
490: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
491: ENDMENUITEMS
492: }
493: } elsif ( defined($env{'request.course.id'}) &&
494: $env{'request.symb'} ne '' ) {
495: $menuitems=(<<ENDMENUITEMS);
496: c&3&1
497: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
498: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
499: c&6&3
500: c&8&1
501: c&8&2
502: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
503: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
504: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
505: ENDMENUITEMS
506:
507: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
508: if (!$env{'request.enc'}) {
509: $menuitems.=(<<ENDREALRES);
510: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
511: ENDREALRES
512: }
513: $menuitems.=(<<ENDREALRES);
514: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
515: 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
516: ENDREALRES
517: }
518: }
519: if ($env{'request.uri'} =~ /^\/res/) {
520: $menuitems .= (<<ENDMENUITEMS);
521: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
522: ENDMENUITEMS
523: }
524: my $buttons='';
525: foreach (split(/\n/,$menuitems)) {
526: my ($command,@rest)=split(/\&/,$_);
527: my $idx=10*$rest[0]+$rest[1];
528: if (&hidden_button_check() eq 'yes') {
529: if ($idx == 21 ||$idx == 23) {
530: $buttons.=&switch('','',@rest);
531: } else {
532: $buttons.=&clear(@rest);
533: }
534: } else {
535: if ($command eq 's') {
536: $buttons.=&switch('','',@rest);
537: } else {
538: $buttons.=&clear(@rest);
539: }
540: }
541: }
542:
543: if ($textual) {
544: my $addremote=0;
545: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
546: my $inlinebuttons='';
547: if ($addremote) {
548: # Registered, textual output
549: if ($env{'browser.interface'} eq 'textual') {
550: $inlinebuttons=
551: join('',map { (defined($_)?$_:'') } @inlineremote);
552: } else {
553: if ($env{'environment.icons'} eq 'iconsonly') {
554: $inlinebuttons=(<<ENDARROWSINLINE);
555: <tr><td>
556: $inlineremote[21] $inlineremote[23]
557: ENDARROWSINLINE
558: if (&hidden_button_check() ne 'yes') {
559: $inlinebuttons .= (<<ENDINLINEICONS);
560: $inlineremote[61] $inlineremote[63]
561: $inlineremote[71] $inlineremote[72] $inlineremote[73]
562: $inlineremote[81] $inlineremote[82] $inlineremote[83]
563: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
564: ENDINLINEICONS
565: }
566: } else {
567: if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
568: $inlinebuttons=(<<ENDFIRSTLINE);
569: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
570: ENDFIRSTLINE
571: }
572: if (&hidden_button_check() ne 'yes') {
573: foreach my $row (6..9) {
574: if ($inlineremote[${row}.'1'] ne ''
575: || $inlineremote[$row.'2'] ne ''
576: || $inlineremote[$row.'3'] ne '') {
577: $inlinebuttons .= <<"ENDLINE";
578: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
579: ENDLINE
580: }
581: }
582: }
583: }
584: }
585: }
586: $result =(<<ENDREGTEXT);
587: <script type="text/javascript">
588: // BEGIN LON-CAPA Internal
589: </script>
590: $timesync
591: $tablestart
592: $inlinebuttons
593: $tableend
594: $newmail
595: <script type="text/javascript">
596: // END LON-CAPA Internal
597: </script>
598:
599: ENDREGTEXT
600: # Registered, graphical output
601: } else {
602: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
603: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
604: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
605: my $navstatus=&get_nav_status();
606: my $clearcstr;
607:
608: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
609: $result = (<<ENDREGTHIS);
610:
611: <script type="text/javascript">
612: // BEGIN LON-CAPA Internal
613: var swmenu=null;
614:
615: function LONCAPAreg() {
616: swmenu=$reopen;
617: swmenu.clearTimeout(swmenu.menucltim);
618: $timesync
619: $newmail
620: $buttons
621: swmenu.currentURL="$requri";
622: swmenu.reloadURL=swmenu.currentURL+window.location.search;
623: swmenu.currentSymb="$cursymb";
624: swmenu.reloadSymb="$cursymb";
625: swmenu.currentStale=0;
626: $navstatus
627: $hwkadd
628: $editbutton
629: }
630:
631: function LONCAPAstale() {
632: swmenu=$reopen
633: swmenu.currentStale=1;
634: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
635: swmenu.switchbutton
636: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
637: }
638: swmenu.clearbut(7,2);
639: swmenu.clearbut(7,3);
640: swmenu.menucltim=swmenu.setTimeout(
641: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
642: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
643: 2000);
644: }
645:
646: // END LON-CAPA Internal
647: </script>
648: ENDREGTHIS
649: }
650: # =============================================================================
651: } else {
652: # ========================================== This can or will not be registered
653: if ($textual) {
654: # Not registered, textual
655: $result= (<<ENDDONOTREGTEXT);
656: ENDDONOTREGTEXT
657: } else {
658: # Not registered, graphical
659: $result = (<<ENDDONOTREGTHIS);
660:
661: <script type="text/javascript">
662: // BEGIN LON-CAPA Internal
663: var swmenu=null;
664:
665: function LONCAPAreg() {
666: swmenu=$reopen
667: $timesync
668: swmenu.currentStale=1;
669: swmenu.clearbut(2,1);
670: swmenu.clearbut(2,3);
671: swmenu.clearbut(8,1);
672: swmenu.clearbut(8,2);
673: swmenu.clearbut(8,3);
674: if (swmenu.currentURL) {
675: swmenu.switchbutton
676: (3,1,'reload.gif','return','location','go(currentURL)');
677: } else {
678: swmenu.clearbut(3,1);
679: }
680: }
681:
682: function LONCAPAstale() {
683: }
684:
685: // END LON-CAPA Internal
686: </script>
687: ENDDONOTREGTHIS
688: }
689: # =============================================================================
690: }
691: return $result;
692: }
693:
694: sub loadevents() {
695: if ($env{'request.state'} eq 'construct' ||
696: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
697: return 'LONCAPAreg();';
698: }
699:
700: sub unloadevents() {
701: if ($env{'request.state'} eq 'construct' ||
702: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
703: return 'LONCAPAstale();';
704: }
705:
706: # ============================================================= Start up remote
707:
708: sub startupremote {
709: my ($lowerurl)=@_;
710: if (($env{'browser.interface'} eq 'textual') ||
711: ($env{'environment.remote'} eq 'off')) {
712: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
713: }
714: #
715: # The Remote actually gets launched!
716: #
717: my $configmenu=&rawconfig();
718: my $esclowerurl=&escape($lowerurl);
719: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
720: return(<<ENDREMOTESTARTUP);
721: <script type="text/javascript">
722: var timestart;
723: function wheelswitch() {
724: if (typeof(document.wheel) != 'undefined') {
725: if (typeof(document.wheel.spin) != 'undefined') {
726: var date=new Date();
727: var waited=Math.round(30-((date.getTime()-timestart)/1000));
728: document.wheel.spin.value=$message;
729: }
730: }
731: if (window.status=='|') {
732: window.status='/';
733: } else {
734: if (window.status=='/') {
735: window.status='-';
736: } else {
737: if (window.status=='-') {
738: window.status='\\\\';
739: } else {
740: if (window.status=='\\\\') { window.status='|'; }
741: }
742: }
743: }
744: }
745:
746: // ---------------------------------------------------------- The wait function
747: var canceltim;
748: function wait() {
749: if ((menuloaded==1) || (tim==1)) {
750: window.status='Done.';
751: if (tim==0) {
752: clearTimeout(canceltim);
753: $configmenu
754: window.location='$lowerurl';
755: } else {
756: window.location='/adm/remote?action=collapse&url=$esclowerurl';
757: }
758: } else {
759: wheelswitch();
760: setTimeout('wait();',200);
761: }
762: }
763:
764: function main() {
765: canceltim=setTimeout('tim=1;',30000);
766: window.status='-';
767: var date=new Date();
768: timestart=date.getTime();
769: wait();
770: }
771:
772: </script>
773: ENDREMOTESTARTUP
774: }
775:
776: sub setflags() {
777: return(<<ENDSETFLAGS);
778: <script type="text/javascript">
779: menuloaded=0;
780: tim=0;
781: </script>
782: ENDSETFLAGS
783: }
784:
785: sub maincall() {
786: if (($env{'browser.interface'} eq 'textual') ||
787: ($env{'environment.remote'} eq 'off')) { return ''; }
788: return(<<ENDMAINCALL);
789: <script type="text/javascript">
790: main();
791: </script>
792: ENDMAINCALL
793: }
794:
795: sub load_remote_msg {
796: my ($lowerurl)=@_;
797:
798: if (($env{'browser.interface'} eq 'textual') ||
799: ($env{'environment.remote'} eq 'off')) { return ''; }
800:
801: my $esclowerurl=&escape($lowerurl);
802: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
803: "/adm/remote?action=collapse&url=$esclowerurl");
804: return(<<ENDREMOTEFORM);
805: <p>
806: <form name="wheel">
807: <input name="spin" type="text" size="60" />
808: </form>
809: </p>
810: <p>$link</p>
811: ENDREMOTEFORM
812: }
813:
814: sub get_menu_name {
815: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
816: $hostid =~ s/\W//g;
817: return 'LCmenu'.$hostid;
818: }
819:
820: # ================================================================= Reopen menu
821:
822: sub reopenmenu {
823: if (($env{'browser.interface'} eq 'textual') ||
824: ($env{'environment.remote'} eq 'off')) { return ''; }
825: my $menuname = &get_menu_name();
826: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
827: return('window.open('.$nothing.',"'.$menuname.'","",false);');
828: }
829:
830: # =============================================================== Open the menu
831:
832: sub open {
833: my $returnval='';
834: if (($env{'browser.interface'} eq 'textual') ||
835: ($env{'environment.remote'} eq 'off')) {
836: return '<script type="text/javascript">self.name="loncapaclient";</script>';
837: }
838: my $menuname = &get_menu_name();
839:
840: # unless (shift eq 'unix') {
841: # resizing does not work on linux because of virtual desktop sizes
842: # $returnval.=(<<ENDRESIZE);
843: #if (window.screen) {
844: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
845: # self.moveTo(190,15);
846: #}
847: #ENDRESIZE
848: # }
849: $returnval.=(<<ENDOPEN);
850: window.status='Opening LON-CAPA Remote Control';
851: var menu=window.open("/res/adm/pages/menu.html","$menuname",
852: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
853: self.name='loncapaclient';
854: ENDOPEN
855: return '<script type="text/javascript">'.$returnval.'</script>';
856: }
857:
858:
859: # ================================================================== Raw Config
860:
861: sub clear {
862: my ($row,$col)=@_;
863: unless (($env{'browser.interface'} eq 'textual') ||
864: ($env{'environment.remote'} eq 'off')) {
865: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
866: } else {
867: $inlineremote[10*$row+$col]='';
868: return '';
869: }
870: }
871:
872: # ============================================ Switch a button or create a link
873: # Switch acts on the javascript that is executed when a button is clicked.
874: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
875:
876: sub switch {
877: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
878: $act=~s/\$uname/$uname/g;
879: $act=~s/\$udom/$udom/g;
880: $top=&mt($top);
881: $bot=&mt($bot);
882: $desc=&mt($desc);
883: $img=&mt($img);
884:
885: my $idx=10*$row+$col;
886: $category_members{$cat}.=':'.$idx;
887:
888: unless (($env{'browser.interface'} eq 'textual') ||
889: ($env{'environment.remote'} eq 'off')) {
890: # Remote
891: return "\n".
892: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
893: } elsif ($env{'browser.interface'} eq 'textual') {
894: # Accessibility
895: if ($nobreak==2) { return ''; }
896: my $text=$top.' '.$bot;
897: $text=~s/\s*\-\s*//gs;
898: if ($nobreak) {
899: $inlineremote[$idx]=
900: '<a href="javascript:'.$act.';">'.$text.'</a>';
901: } else {
902: $inlineremote[$idx]="\n<br />".
903: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
904: }
905: } else {
906: # Inline Remote
907: if ($env{'environment.icons'} ne 'classic') {
908: $img=~s/\.gif$/\.png/;
909: }
910: if ($nobreak==2) { return ''; }
911: my $text=$top.' '.$bot;
912: $text=~s/\s*\-\s*//gs;
913:
914: my $pic=
915: '<img alt="'.$text.'" src="'.
916: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
917: '" align="'.($nobreak==3?'right':'left').'" />';
918: if ($env{'browser.interface'} eq 'faketextual') {
919: # Accessibility
920: if ($nobreak==3) {
921: $inlineremote[$idx]="\n".
922: '<td class="LC_menubuttons_text" align="right">'.$text.
923: '</td><td class="LC_menubuttons_img" align="left">'.
924: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
925: } elsif ($nobreak) {
926: $inlineremote[$idx]="\n<tr>".
927: '<td class="LC_menubuttons_img" align="left">'.
928: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
929: <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>';
930: } else {
931: $inlineremote[$idx]="\n<tr>".
932: '<td class="LC_menubuttons_img" align="left">'.
933: '<a href="javascript:'.$act.';">'.$pic.
934: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
935: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
936: }
937: } else {
938: # Inline Menu
939: if ($env{'environment.icons'} eq 'iconsonly') {
940: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
941: } else {
942: $inlineremote[$idx]=
943: '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
944: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
945: }
946: }
947: }
948: return '';
949: }
950:
951: sub secondlevel {
952: my $output='';
953: my
954: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
955: if ($prt eq 'any') {
956: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
957: } elsif ($prt=~/^r(\w+)/) {
958: if ($rol eq $1) {
959: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
960: }
961: }
962: return $output;
963: }
964:
965: sub openmenu {
966: my $menuname = &get_menu_name();
967: if (($env{'browser.interface'} eq 'textual') ||
968: ($env{'environment.remote'} eq 'off')) { return ''; }
969: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
970: return "window.open(".$nothing.",'".$menuname."');";
971: }
972:
973: sub inlinemenu {
974: undef(@inlineremote);
975: undef(%category_members);
976: &rawconfig(1);
977: my $output='<table id="LC_mainmenu"><tr>';
978: for (my $col=1; $col<=2; $col++) {
979: $output.='<td class="LC_mainmenu_column">';
980: for (my $row=1; $row<=8; $row++) {
981: foreach my $cat (keys(%category_members)) {
982: if ($category_positions{$cat} ne "$col,$row") { next; }
983: $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
984: my %active=();
985: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
986: if ($inlineremote[$menu_item]) {
987: $active{$menu_item}=1;
988: }
989: }
990: foreach my $item (sort(keys(%active))) {
991: $output.=$inlineremote[$item];
992: }
993: $output.='</table>';
994: }
995: }
996: $output.="</td>";
997: }
998: $output.="</tr></table>";
999: return $output;
1000: }
1001:
1002: sub rawconfig {
1003: my $textualoverride=shift;
1004: my $output='';
1005: unless (($env{'browser.interface'} eq 'textual') ||
1006: ($env{'environment.remote'} eq 'off')) {
1007: $output.=
1008: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1009: "\nwindow.status='Configuring Remote Control ';";
1010: } else {
1011: unless ($textualoverride) { return ''; }
1012: }
1013: my $uname=$env{'user.name'};
1014: my $udom=$env{'user.domain'};
1015: my $adv=$env{'user.adv'};
1016: my $show_course=&show_course();
1017: my $author=$env{'user.author'};
1018: my $crs='';
1019: if ($env{'request.course.id'}) {
1020: $crs='/'.$env{'request.course.id'};
1021: if ($env{'request.course.sec'}) {
1022: $crs.='_'.$env{'request.course.sec'};
1023: }
1024: $crs=~s/\_/\//g;
1025: }
1026: my $pub=($env{'request.state'} eq 'published');
1027: my $con=($env{'request.state'} eq 'construct');
1028: my $rol=$env{'request.role'};
1029: my $requested_domain = $env{'request.role.domain'};
1030: foreach my $line (@desklines) {
1031: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1032: $prt=~s/\$uname/$uname/g;
1033: $prt=~s/\$udom/$udom/g;
1034: $prt=~s/\$crs/$crs/g;
1035: $prt=~s/\$requested_domain/$requested_domain/g;
1036: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1037: my $type = &Apache::loncommon::course_type();
1038: if ($type eq 'Group') {
1039: $desc = &convert_menu_function($desc,$type);
1040: }
1041: if ($pro eq 'clear') {
1042: $output.=&clear($row,$col);
1043: } elsif ($pro eq 'any') {
1044: $output.=&secondlevel(
1045: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1046: } elsif ($pro eq 'smp') {
1047: unless ($adv) {
1048: $output.=&secondlevel(
1049: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1050: }
1051: } elsif ($pro eq 'adv') {
1052: if ($adv) {
1053: $output.=&secondlevel(
1054: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1055: }
1056: } elsif ($pro eq 'shc') {
1057: if ($show_course) {
1058: $output.=&secondlevel(
1059: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1060: }
1061: } elsif ($pro eq 'nsc') {
1062: if (!$show_course) {
1063: $output.=&secondlevel(
1064: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1065: }
1066: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1067: if (&Apache::lonnet::allowed($1,$prt)) {
1068: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1069: }
1070: } elsif ($pro eq 'course') {
1071: if ($env{'request.course.fn'}) {
1072: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1073: }
1074: } elsif ($pro =~ /^courseenv_(.*)$/) {
1075: my $key = $1;
1076: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1077: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1078: }
1079: } elsif ($pro =~ /^course_(.*)$/) {
1080: # Check for permissions inside of a course
1081: if (($env{'request.course.id'}) &&
1082: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1083: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1084: )) {
1085: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1086: }
1087: } elsif ($pro eq 'author') {
1088: if ($author) {
1089: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1090: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1091: # Check that we are on the correct machine
1092: my $cadom=$requested_domain;
1093: my $caname=$env{'user.name'};
1094: if ($prt eq 'rca') {
1095: ($cadom,$caname)=
1096: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1097: }
1098: $act =~ s/\$caname/$caname/g;
1099: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1100: my $allowed=0;
1101: my @ids=&Apache::lonnet::current_machine_ids();
1102: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1103: if ($allowed) {
1104: $output.=&switch($caname,$cadom,
1105: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1106: }
1107: }
1108: }
1109: }
1110: }
1111: unless (($env{'browser.interface'} eq 'textual') ||
1112: ($env{'environment.remote'} eq 'off')) {
1113: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1114: if (&Apache::lonmsg::newmail()) {
1115: $output.='swmenu.setstatus("you have","messages");';
1116: }
1117: }
1118:
1119: return $output;
1120: }
1121:
1122: # ======================================================================= Close
1123:
1124: sub close {
1125: if (($env{'browser.interface'} eq 'textual') ||
1126: ($env{'environment.remote'} eq 'off')) { return ''; }
1127: my $menuname = &get_menu_name();
1128: return(<<ENDCLOSE);
1129: <script type="text/javascript">
1130: window.status='Accessing Remote Control';
1131: menu=window.open("/adm/rat/empty.html","$menuname",
1132: "height=350,width=150,scrollbars=no,menubar=no");
1133: window.status='Disabling Remote Control';
1134: menu.active=0;
1135: menu.autologout=0;
1136: window.status='Closing Remote Control';
1137: menu.close();
1138: window.status='Done.';
1139: </script>
1140: ENDCLOSE
1141: }
1142:
1143: # ====================================================================== Footer
1144:
1145: sub footer {
1146:
1147: }
1148:
1149: sub nav_control_js {
1150: my $nav=($env{'environment.remotenavmap'} eq 'on');
1151: return (<<NAVCONTROL);
1152: var w_loncapanav_flag="$nav";
1153:
1154:
1155: function gonav(url) {
1156: if (w_loncapanav_flag != 1) {
1157: gopost(url,'');
1158: } else {
1159: navwindow=window.open(url,
1160: "loncapanav","height=600,width=400,scrollbars=1");
1161: }
1162: }
1163: NAVCONTROL
1164: }
1165:
1166: sub utilityfunctions {
1167: my $caller = shift;
1168: unless (($env{'browser.interface'} eq 'textual') ||
1169: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1170: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1171: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1172:
1173: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1174: my $nav_control=&nav_control_js();
1175:
1176: my $start_page_annotate =
1177: &Apache::loncommon::start_page('Annotator',undef,
1178: {'only_body' => 1,
1179: 'js_ready' => 1,
1180: 'bgcolor' => '#BBBBBB',
1181: 'add_entries' => {
1182: 'onload' => 'javascript:document.goannotate.submit();'}});
1183:
1184: my $end_page_annotate =
1185: &Apache::loncommon::end_page({'js_ready' => 1});
1186:
1187: my $start_page_bookmark =
1188: &Apache::loncommon::start_page('Bookmarks',undef,
1189: {'only_body' => 1,
1190: 'js_ready' => 1,
1191: 'bgcolor' => '#BBBBBB',});
1192:
1193: my $end_page_bookmark =
1194: &Apache::loncommon::end_page({'js_ready' => 1});
1195:
1196: return (<<ENDUTILITY)
1197:
1198: var currentURL="$currenturl";
1199: var reloadURL="$currenturl";
1200: var currentSymb="$currentsymb";
1201:
1202: $nav_control
1203:
1204: function go(url) {
1205: if (url!='' && url!= null) {
1206: currentURL = null;
1207: currentSymb= null;
1208: window.location.href=url;
1209: }
1210: }
1211:
1212: function gopost(url,postdata) {
1213: if (url!='') {
1214: this.document.server.action=url;
1215: this.document.server.postdata.value=postdata;
1216: this.document.server.command.value='';
1217: this.document.server.url.value='';
1218: this.document.server.symb.value='';
1219: this.document.server.submit();
1220: }
1221: }
1222:
1223: function gocmd(url,cmd) {
1224: if (url!='') {
1225: this.document.server.action=url;
1226: this.document.server.postdata.value='';
1227: this.document.server.command.value=cmd;
1228: this.document.server.url.value=currentURL;
1229: this.document.server.symb.value=currentSymb;
1230: this.document.server.submit();
1231: }
1232: }
1233:
1234: function gocstr(url,filename) {
1235: if (url == '/adm/cfile?action=delete') {
1236: this.document.cstrdelete.filename.value = filename
1237: this.document.cstrdelete.submit();
1238: return;
1239: }
1240: if (url == '/adm/printout') {
1241: this.document.cstrprint.postdata.value = filename
1242: this.document.cstrprint.curseed.value = 0;
1243: this.document.cstrprint.problemtype.value = 0;
1244: if (this.document.lonhomework) {
1245: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1246: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1247: }
1248: if (this.document.lonhomework.problemtype) {
1249: if (this.document.lonhomework.problemtype.value) {
1250: this.document.cstrprint.problemtype.value =
1251: this.document.lonhomework.problemtype.value;
1252: } else if (this.document.lonhomework.problemtype.options) {
1253: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1254: if (this.document.lonhomework.problemtype.options[i].selected) {
1255: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1256: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1257: }
1258: }
1259: }
1260: }
1261: }
1262: }
1263: this.document.cstrprint.submit();
1264: return;
1265: }
1266: if (url !='') {
1267: this.document.constspace.filename.value = filename;
1268: this.document.constspace.action = url;
1269: this.document.constspace.submit();
1270: }
1271: }
1272:
1273: function golist(url) {
1274: if (url!='' && url!= null) {
1275: currentURL = null;
1276: currentSymb= null;
1277: top.location.href=url;
1278: }
1279: }
1280:
1281:
1282:
1283: function catalog_info() {
1284: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1285: }
1286:
1287: function chat_win() {
1288: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1289: }
1290:
1291: function group_chat(group) {
1292: var url = '/adm/groupchat?group='+group;
1293: var winName = 'LONchat_'+group;
1294: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1295: }
1296:
1297: function edit_bookmarks() {
1298: go('');
1299: w_BookmarkPal_flag=1;
1300: bookmarkpal=window.open("/adm/bookmarks",
1301: "BookmarkPal", "width=400,height=505,scrollbars=0");
1302: }
1303:
1304: function annotate() {
1305: w_Annotator_flag=1;
1306: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1307: annotator.document.write(
1308: '$start_page_annotate'
1309: +"<form name='goannotate' target='Annotator' method='post' "
1310: +"action='/adm/annotations'>"
1311: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1312: +"<\\/form>"
1313: +'$end_page_annotate');
1314: annotator.document.close();
1315: }
1316:
1317: function set_bookmark() {
1318: go('');
1319: clienttitle=document.title;
1320: clienthref=location.pathname;
1321: w_bmquery_flag=1;
1322: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1323: bmquery.document.write(
1324: '$start_page_bookmark'
1325: +"<center><form method='post'"
1326: +" name='newlink' action='/adm/bookmarks' target='bmquery' "
1327: +">\\n <table width=340 height=150 "
1328: +"bgcolor='ffffff' align=center><tr><td>Link Name:<br /><input "
1329: +"type='text' name='title' size=45 value='"+clienttitle+"' />"
1330: +"<br />Address:<br /><input type='text' name='address' size='45' "
1331: +"value='"+clienthref+"' /><br /><center><input type='submit' "
1332: +"value='Save' /> <input type='button' value='Close (no save)' "
1333: +"onclick='javascript:window.close();' /><\\/center><\\/td>"
1334: +"<\\/tr><\\/table><\\/form><\\/center>"
1335: +'$end_page_bookmark' );
1336: bmquery.document.close();
1337: }
1338:
1339: ENDUTILITY
1340: }
1341:
1342: sub serverform {
1343: return(<<ENDSERVERFORM);
1344: <form name="server" action="/adm/logout" method="post" target="_top">
1345: <input type="hidden" name="postdata" value="none" />
1346: <input type="hidden" name="command" value="none" />
1347: <input type="hidden" name="url" value="none" />
1348: <input type="hidden" name="symb" value="none" />
1349: </form>
1350: ENDSERVERFORM
1351: }
1352:
1353: sub constspaceform {
1354: return(<<ENDCONSTSPACEFORM);
1355: <form name="constspace" action="/adm/logout" method="post" target="_top">
1356: <input type="hidden" name="filename" value="" />
1357: </form>
1358: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1359: <input type="hidden" name="action" value="delete" />
1360: <input type="hidden" name="filename" value="" />
1361: </form>
1362: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1363: <input type="hidden" name="postdata" value="" />
1364: <input type="hidden" name="curseed" value="" />
1365: <input type="hidden" name="problemtype" value="" />
1366: </form>
1367:
1368: ENDCONSTSPACEFORM
1369: }
1370:
1371:
1372: sub get_nav_status {
1373: my $navstatus="swmenu.w_loncapanav_flag=";
1374: if ($env{'environment.remotenavmap'} eq 'on') {
1375: $navstatus.="1";
1376: } else {
1377: $navstatus.="-1";
1378: }
1379: return $navstatus;
1380: }
1381:
1382: #FIXME this needs to move into mydesktab and the other locations
1383: # the text is generated
1384: sub convert_menu_function {
1385: my ($rolename,$type) = @_;
1386: if ($type eq 'Group') {
1387: $rolename =~ s/student/member/g;
1388: $rolename =~ s/group/team/g;
1389: $rolename =~ s/course/group/g;
1390: $rolename =~ s/Course/Group/g;
1391: }
1392: return $rolename;
1393: }
1394:
1395: sub hidden_button_check {
1396: my $hidden;
1397: if ($env{'request.course.id'} eq '') {
1398: return;
1399: }
1400: if ($env{'request.role.adv'}) {
1401: return;
1402: }
1403: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1404: return $buttonshide;
1405: }
1406:
1407: # ================================================================ Main Program
1408:
1409: BEGIN {
1410: if (! defined($readdesk)) {
1411: {
1412: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1413: if ( CORE::open( my $config,"<$tabfile") ) {
1414: while (my $configline=<$config>) {
1415: $configline=(split(/\#/,$configline))[0];
1416: $configline=~s/^\s+//;
1417: chomp($configline);
1418: if ($configline=~/^cat\:/) {
1419: my @entries=split(/\:/,$configline);
1420: $category_positions{$entries[2]}=$entries[1];
1421: $category_names{$entries[2]}=$entries[3];
1422: } elsif ($configline) {
1423: push(@desklines,$configline);
1424: }
1425: }
1426: CORE::close($config);
1427: }
1428: }
1429: $readdesk='done';
1430: }
1431: }
1432:
1433: 1;
1434: __END__
1435:
1436:
1437:
1438:
1439:
1440:
1441:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>