1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.234 2008/02/03 05:07:58 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: 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'}=~/^(aa|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: } elsif ($env{'request.role'} =~ /^aa/) {
432: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
433: ($top,$bottom) = ('co con-','struct');
434: $action = "go('/priv/".$caname."');";
435: $desc = "Enter construction space as assistant co-author";
436: }
437: # Check that we are on the correct machine
438: my $home = &Apache::lonnet::homeserver($caname,$cadom);
439: my $allowed=0;
440: my @ids=&Apache::lonnet::current_machine_ids();
441: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
442: if (!$allowed) {
443: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
444: }
445: }
446: ##
447: ## Determine if user can edit url.
448: ##
449: my $cfile='';
450: my $cfuname='';
451: my $cfudom='';
452: if ($env{'request.filename'}) {
453: my $file=&Apache::lonnet::declutter($env{'request.filename'});
454: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
455: # Check that the user has permission to edit this resource
456: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
457: if (defined($cfudom)) {
458: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
459: my $allowed=0;
460: my @ids=&Apache::lonnet::current_machine_ids();
461: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
462: if ($allowed) {
463: $cfile=$file;
464: }
465: }
466: }
467: # Finally, turn the button on or off
468: if ($cfile && !$const_space) {
469: $editbutton=&switch
470: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
471: "go('".$cfile."');","Edit this resource");
472: } elsif ($editbutton eq '') {
473: $editbutton=&clear(6,1);
474: }
475: }
476: ###
477: ###
478: # Prepare the rest of the buttons
479: my $menuitems;
480: if ($const_space) {
481: my ($uname,$thisdisfn) =
482: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
483: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
484: if ($currdir =~ m-/$-) {
485: $is_const_dir = 1;
486: } else {
487: $currdir =~ s#[^/]+$##;
488: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
489: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
490: $menuitems=(<<ENDMENUITEMS);
491: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
492: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
493: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
494: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
495: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
496: ENDMENUITEMS
497: }
498: } elsif ( defined($env{'request.course.id'}) &&
499: $env{'request.symb'} ne '' ) {
500: $menuitems=(<<ENDMENUITEMS);
501: c&3&1
502: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
503: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
504: c&6&3
505: c&8&1
506: c&8&2
507: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
508: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
509: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
510: ENDMENUITEMS
511:
512: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
513: if (!$env{'request.enc'}) {
514: $menuitems.=(<<ENDREALRES);
515: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
516: ENDREALRES
517: }
518: $menuitems.=(<<ENDREALRES);
519: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
520: 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
521: ENDREALRES
522: }
523: }
524: if ($env{'request.uri'} =~ /^\/res/) {
525: $menuitems .= (<<ENDMENUITEMS);
526: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
527: ENDMENUITEMS
528: }
529: my $buttons='';
530: foreach (split(/\n/,$menuitems)) {
531: my ($command,@rest)=split(/\&/,$_);
532: my $idx=10*$rest[0]+$rest[1];
533: if (&hidden_button_check() eq 'yes') {
534: if ($idx == 21 ||$idx == 23) {
535: $buttons.=&switch('','',@rest);
536: } else {
537: $buttons.=&clear(@rest);
538: }
539: } else {
540: if ($command eq 's') {
541: $buttons.=&switch('','',@rest);
542: } else {
543: $buttons.=&clear(@rest);
544: }
545: }
546: }
547:
548: if ($textual) {
549: my $addremote=0;
550: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
551: my $inlinebuttons='';
552: if ($addremote) {
553: # Registered, textual output
554: if ($env{'browser.interface'} eq 'textual') {
555: $inlinebuttons=
556: join('',map { (defined($_)?$_:'') } @inlineremote);
557: } else {
558: if ($env{'environment.icons'} eq 'iconsonly') {
559: $inlinebuttons=(<<ENDARROWSINLINE);
560: <tr><td>
561: $inlineremote[21] $inlineremote[23]
562: ENDARROWSINLINE
563: if (&hidden_button_check() ne 'yes') {
564: $inlinebuttons .= (<<ENDINLINEICONS);
565: $inlineremote[61] $inlineremote[63]
566: $inlineremote[71] $inlineremote[72] $inlineremote[73]
567: $inlineremote[81] $inlineremote[82] $inlineremote[83]
568: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
569: ENDINLINEICONS
570: }
571: } else {
572: if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
573: $inlinebuttons=(<<ENDFIRSTLINE);
574: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
575: ENDFIRSTLINE
576: }
577: if (&hidden_button_check() ne 'yes') {
578: foreach my $row (6..9) {
579: if ($inlineremote[${row}.'1'] ne ''
580: || $inlineremote[$row.'2'] ne ''
581: || $inlineremote[$row.'3'] ne '') {
582: $inlinebuttons .= <<"ENDLINE";
583: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
584: ENDLINE
585: }
586: }
587: }
588: }
589: }
590: }
591: $result =(<<ENDREGTEXT);
592: <script type="text/javascript">
593: // BEGIN LON-CAPA Internal
594: </script>
595: $timesync
596: $tablestart
597: $inlinebuttons
598: $tableend
599: $newmail
600: <script type="text/javascript">
601: // END LON-CAPA Internal
602: </script>
603:
604: ENDREGTEXT
605: # Registered, graphical output
606: } else {
607: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
608: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
609: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
610: my $navstatus=&get_nav_status();
611: my $clearcstr;
612:
613: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
614: $result = (<<ENDREGTHIS);
615:
616: <script type="text/javascript">
617: // BEGIN LON-CAPA Internal
618: var swmenu=null;
619:
620: function LONCAPAreg() {
621: swmenu=$reopen;
622: swmenu.clearTimeout(swmenu.menucltim);
623: $timesync
624: $newmail
625: $buttons
626: swmenu.currentURL="$requri";
627: swmenu.reloadURL=swmenu.currentURL+window.location.search;
628: swmenu.currentSymb="$cursymb";
629: swmenu.reloadSymb="$cursymb";
630: swmenu.currentStale=0;
631: $navstatus
632: $hwkadd
633: $editbutton
634: }
635:
636: function LONCAPAstale() {
637: swmenu=$reopen
638: swmenu.currentStale=1;
639: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
640: swmenu.switchbutton
641: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
642: }
643: swmenu.clearbut(7,2);
644: swmenu.clearbut(7,3);
645: swmenu.menucltim=swmenu.setTimeout(
646: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
647: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
648: 2000);
649: }
650:
651: // END LON-CAPA Internal
652: </script>
653: ENDREGTHIS
654: }
655: # =============================================================================
656: } else {
657: # ========================================== This can or will not be registered
658: if ($textual) {
659: # Not registered, textual
660: $result= (<<ENDDONOTREGTEXT);
661: ENDDONOTREGTEXT
662: } else {
663: # Not registered, graphical
664: $result = (<<ENDDONOTREGTHIS);
665:
666: <script type="text/javascript">
667: // BEGIN LON-CAPA Internal
668: var swmenu=null;
669:
670: function LONCAPAreg() {
671: swmenu=$reopen
672: $timesync
673: swmenu.currentStale=1;
674: swmenu.clearbut(2,1);
675: swmenu.clearbut(2,3);
676: swmenu.clearbut(8,1);
677: swmenu.clearbut(8,2);
678: swmenu.clearbut(8,3);
679: if (swmenu.currentURL) {
680: swmenu.switchbutton
681: (3,1,'reload.gif','return','location','go(currentURL)');
682: } else {
683: swmenu.clearbut(3,1);
684: }
685: }
686:
687: function LONCAPAstale() {
688: }
689:
690: // END LON-CAPA Internal
691: </script>
692: ENDDONOTREGTHIS
693: }
694: # =============================================================================
695: }
696: return $result;
697: }
698:
699: sub loadevents() {
700: if ($env{'request.state'} eq 'construct' ||
701: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
702: return 'LONCAPAreg();';
703: }
704:
705: sub unloadevents() {
706: if ($env{'request.state'} eq 'construct' ||
707: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
708: return 'LONCAPAstale();';
709: }
710:
711: # ============================================================= Start up remote
712:
713: sub startupremote {
714: my ($lowerurl)=@_;
715: if (($env{'browser.interface'} eq 'textual') ||
716: ($env{'environment.remote'} eq 'off')) {
717: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
718: }
719: #
720: # The Remote actually gets launched!
721: #
722: my $configmenu=&rawconfig();
723: my $esclowerurl=&escape($lowerurl);
724: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
725: return(<<ENDREMOTESTARTUP);
726: <script type="text/javascript">
727: var timestart;
728: function wheelswitch() {
729: if (typeof(document.wheel) != 'undefined') {
730: if (typeof(document.wheel.spin) != 'undefined') {
731: var date=new Date();
732: var waited=Math.round(30-((date.getTime()-timestart)/1000));
733: document.wheel.spin.value=$message;
734: }
735: }
736: if (window.status=='|') {
737: window.status='/';
738: } else {
739: if (window.status=='/') {
740: window.status='-';
741: } else {
742: if (window.status=='-') {
743: window.status='\\\\';
744: } else {
745: if (window.status=='\\\\') { window.status='|'; }
746: }
747: }
748: }
749: }
750:
751: // ---------------------------------------------------------- The wait function
752: var canceltim;
753: function wait() {
754: if ((menuloaded==1) || (tim==1)) {
755: window.status='Done.';
756: if (tim==0) {
757: clearTimeout(canceltim);
758: $configmenu
759: window.location='$lowerurl';
760: } else {
761: window.location='/adm/remote?action=collapse&url=$esclowerurl';
762: }
763: } else {
764: wheelswitch();
765: setTimeout('wait();',200);
766: }
767: }
768:
769: function main() {
770: canceltim=setTimeout('tim=1;',30000);
771: window.status='-';
772: var date=new Date();
773: timestart=date.getTime();
774: wait();
775: }
776:
777: </script>
778: ENDREMOTESTARTUP
779: }
780:
781: sub setflags() {
782: return(<<ENDSETFLAGS);
783: <script type="text/javascript">
784: menuloaded=0;
785: tim=0;
786: </script>
787: ENDSETFLAGS
788: }
789:
790: sub maincall() {
791: if (($env{'browser.interface'} eq 'textual') ||
792: ($env{'environment.remote'} eq 'off')) { return ''; }
793: return(<<ENDMAINCALL);
794: <script type="text/javascript">
795: main();
796: </script>
797: ENDMAINCALL
798: }
799:
800: sub load_remote_msg {
801: my ($lowerurl)=@_;
802:
803: if (($env{'browser.interface'} eq 'textual') ||
804: ($env{'environment.remote'} eq 'off')) { return ''; }
805:
806: my $esclowerurl=&escape($lowerurl);
807: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
808: "/adm/remote?action=collapse&url=$esclowerurl");
809: return(<<ENDREMOTEFORM);
810: <p>
811: <form name="wheel">
812: <input name="spin" type="text" size="60" />
813: </form>
814: </p>
815: <p>$link</p>
816: ENDREMOTEFORM
817: }
818:
819: sub get_menu_name {
820: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
821: $hostid =~ s/\W//g;
822: return 'LCmenu'.$hostid;
823: }
824:
825: # ================================================================= Reopen menu
826:
827: sub reopenmenu {
828: if (($env{'browser.interface'} eq 'textual') ||
829: ($env{'environment.remote'} eq 'off')) { return ''; }
830: my $menuname = &get_menu_name();
831: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
832: return('window.open('.$nothing.',"'.$menuname.'","",false);');
833: }
834:
835: # =============================================================== Open the menu
836:
837: sub open {
838: my $returnval='';
839: if (($env{'browser.interface'} eq 'textual') ||
840: ($env{'environment.remote'} eq 'off')) {
841: return '<script type="text/javascript">self.name="loncapaclient";</script>';
842: }
843: my $menuname = &get_menu_name();
844:
845: # unless (shift eq 'unix') {
846: # resizing does not work on linux because of virtual desktop sizes
847: # $returnval.=(<<ENDRESIZE);
848: #if (window.screen) {
849: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
850: # self.moveTo(190,15);
851: #}
852: #ENDRESIZE
853: # }
854: $returnval.=(<<ENDOPEN);
855: window.status='Opening LON-CAPA Remote Control';
856: var menu=window.open("/res/adm/pages/menu.html","$menuname",
857: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
858: self.name='loncapaclient';
859: ENDOPEN
860: return '<script type="text/javascript">'.$returnval.'</script>';
861: }
862:
863:
864: # ================================================================== Raw Config
865:
866: sub clear {
867: my ($row,$col)=@_;
868: unless (($env{'browser.interface'} eq 'textual') ||
869: ($env{'environment.remote'} eq 'off')) {
870: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
871: } else {
872: $inlineremote[10*$row+$col]='';
873: return '';
874: }
875: }
876:
877: # ============================================ Switch a button or create a link
878: # Switch acts on the javascript that is executed when a button is clicked.
879: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
880:
881: sub switch {
882: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
883: $act=~s/\$uname/$uname/g;
884: $act=~s/\$udom/$udom/g;
885: $top=&mt($top);
886: $bot=&mt($bot);
887: $desc=&mt($desc);
888: $img=&mt($img);
889:
890: my $idx=10*$row+$col;
891: $category_members{$cat}.=':'.$idx;
892:
893: unless (($env{'browser.interface'} eq 'textual') ||
894: ($env{'environment.remote'} eq 'off')) {
895: # Remote
896: return "\n".
897: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
898: } elsif ($env{'browser.interface'} eq 'textual') {
899: # Accessibility
900: if ($nobreak==2) { return ''; }
901: my $text=$top.' '.$bot;
902: $text=~s/\s*\-\s*//gs;
903: if ($nobreak) {
904: $inlineremote[$idx]=
905: '<a href="javascript:'.$act.';">'.$text.'</a>';
906: } else {
907: $inlineremote[$idx]="\n<br />".
908: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
909: }
910: } else {
911: # Inline Remote
912: if ($env{'environment.icons'} ne 'classic') {
913: $img=~s/\.gif$/\.png/;
914: }
915: if ($nobreak==2) { return ''; }
916: my $text=$top.' '.$bot;
917: $text=~s/\s*\-\s*//gs;
918:
919: my $pic=
920: '<img alt="'.$text.'" src="'.
921: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
922: '" align="'.($nobreak==3?'right':'left').'" />';
923: if ($env{'browser.interface'} eq 'faketextual') {
924: # Accessibility
925: if ($nobreak==3) {
926: $inlineremote[$idx]="\n".
927: '<td class="LC_menubuttons_text" align="right">'.$text.
928: '</td><td class="LC_menubuttons_img" align="left">'.
929: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
930: } elsif ($nobreak) {
931: $inlineremote[$idx]="\n<tr>".
932: '<td class="LC_menubuttons_img" align="left">'.
933: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
934: <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>';
935: } else {
936: $inlineremote[$idx]="\n<tr>".
937: '<td class="LC_menubuttons_img" align="left">'.
938: '<a href="javascript:'.$act.';">'.$pic.
939: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
940: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
941: }
942: } else {
943: # Inline Menu
944: if ($env{'environment.icons'} eq 'iconsonly') {
945: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
946: } else {
947: $inlineremote[$idx]=
948: '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
949: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
950: }
951: }
952: }
953: return '';
954: }
955:
956: sub secondlevel {
957: my $output='';
958: my
959: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
960: if ($prt eq 'any') {
961: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
962: } elsif ($prt=~/^r(\w+)/) {
963: if ($rol eq $1) {
964: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
965: }
966: }
967: return $output;
968: }
969:
970: sub openmenu {
971: my $menuname = &get_menu_name();
972: if (($env{'browser.interface'} eq 'textual') ||
973: ($env{'environment.remote'} eq 'off')) { return ''; }
974: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
975: return "window.open(".$nothing.",'".$menuname."');";
976: }
977:
978: sub inlinemenu {
979: undef(@inlineremote);
980: undef(%category_members);
981: &rawconfig(1);
982: my $output='<table id="LC_mainmenu"><tr>';
983: for (my $col=1; $col<=2; $col++) {
984: $output.='<td class="LC_mainmenu_column">';
985: for (my $row=1; $row<=8; $row++) {
986: foreach my $cat (keys(%category_members)) {
987: if ($category_positions{$cat} ne "$col,$row") { next; }
988: $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
989: my %active=();
990: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
991: if ($inlineremote[$menu_item]) {
992: $active{$menu_item}=1;
993: }
994: }
995: foreach my $item (sort(keys(%active))) {
996: $output.=$inlineremote[$item];
997: }
998: $output.='</table>';
999: }
1000: }
1001: $output.="</td>";
1002: }
1003: $output.="</tr></table>";
1004: return $output;
1005: }
1006:
1007: sub rawconfig {
1008: my $textualoverride=shift;
1009: my $output='';
1010: unless (($env{'browser.interface'} eq 'textual') ||
1011: ($env{'environment.remote'} eq 'off')) {
1012: $output.=
1013: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1014: "\nwindow.status='Configuring Remote Control ';";
1015: } else {
1016: unless ($textualoverride) { return ''; }
1017: }
1018: my $uname=$env{'user.name'};
1019: my $udom=$env{'user.domain'};
1020: my $adv=$env{'user.adv'};
1021: my $show_course=&show_course();
1022: my $author=$env{'user.author'};
1023: my $crs='';
1024: if ($env{'request.course.id'}) {
1025: $crs='/'.$env{'request.course.id'};
1026: if ($env{'request.course.sec'}) {
1027: $crs.='_'.$env{'request.course.sec'};
1028: }
1029: $crs=~s/\_/\//g;
1030: }
1031: my $pub=($env{'request.state'} eq 'published');
1032: my $con=($env{'request.state'} eq 'construct');
1033: my $rol=$env{'request.role'};
1034: my $requested_domain = $env{'request.role.domain'};
1035: foreach my $line (@desklines) {
1036: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1037: $prt=~s/\$uname/$uname/g;
1038: $prt=~s/\$udom/$udom/g;
1039: $prt=~s/\$crs/$crs/g;
1040: $prt=~s/\$requested_domain/$requested_domain/g;
1041: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1042: my $type = &Apache::loncommon::course_type();
1043: if ($type eq 'Group') {
1044: $desc = &convert_menu_function($desc,$type);
1045: }
1046: if ($pro eq 'clear') {
1047: $output.=&clear($row,$col);
1048: } elsif ($pro eq 'any') {
1049: $output.=&secondlevel(
1050: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1051: } elsif ($pro eq 'smp') {
1052: unless ($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 'adv') {
1057: if ($adv) {
1058: $output.=&secondlevel(
1059: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1060: }
1061: } elsif ($pro eq 'shc') {
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 eq 'nsc') {
1067: if (!$show_course) {
1068: $output.=&secondlevel(
1069: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1070: }
1071: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1072: if (&Apache::lonnet::allowed($1,$prt)) {
1073: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1074: }
1075: } elsif ($pro eq 'course') {
1076: if ($env{'request.course.fn'}) {
1077: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1078: }
1079: } elsif ($pro =~ /^courseenv_(.*)$/) {
1080: my $key = $1;
1081: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1082: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1083: }
1084: } elsif ($pro =~ /^course_(.*)$/) {
1085: # Check for permissions inside of a course
1086: if (($env{'request.course.id'}) &&
1087: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1088: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1089: )) {
1090: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1091: }
1092: } elsif ($pro eq 'author') {
1093: if ($author) {
1094: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1095: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1096: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1097: # Check that we are on the correct machine
1098: my $cadom=$requested_domain;
1099: my $caname=$env{'user.name'};
1100: if (($prt eq 'rca') || ($prt eq 'raa')) {
1101: ($cadom,$caname)=
1102: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1103: }
1104: $act =~ s/\$caname/$caname/g;
1105: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1106: my $allowed=0;
1107: my @ids=&Apache::lonnet::current_machine_ids();
1108: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1109: if ($allowed) {
1110: $output.=&switch($caname,$cadom,
1111: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1112: }
1113: }
1114: }
1115: }
1116: }
1117: unless (($env{'browser.interface'} eq 'textual') ||
1118: ($env{'environment.remote'} eq 'off')) {
1119: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1120: if (&Apache::lonmsg::newmail()) {
1121: $output.='swmenu.setstatus("you have","messages");';
1122: }
1123: }
1124:
1125: return $output;
1126: }
1127:
1128: # ======================================================================= Close
1129:
1130: sub close {
1131: if (($env{'browser.interface'} eq 'textual') ||
1132: ($env{'environment.remote'} eq 'off')) { return ''; }
1133: my $menuname = &get_menu_name();
1134: return(<<ENDCLOSE);
1135: <script type="text/javascript">
1136: window.status='Accessing Remote Control';
1137: menu=window.open("/adm/rat/empty.html","$menuname",
1138: "height=350,width=150,scrollbars=no,menubar=no");
1139: window.status='Disabling Remote Control';
1140: menu.active=0;
1141: menu.autologout=0;
1142: window.status='Closing Remote Control';
1143: menu.close();
1144: window.status='Done.';
1145: </script>
1146: ENDCLOSE
1147: }
1148:
1149: # ====================================================================== Footer
1150:
1151: sub footer {
1152:
1153: }
1154:
1155: sub nav_control_js {
1156: my $nav=($env{'environment.remotenavmap'} eq 'on');
1157: return (<<NAVCONTROL);
1158: var w_loncapanav_flag="$nav";
1159:
1160:
1161: function gonav(url) {
1162: if (w_loncapanav_flag != 1) {
1163: gopost(url,'');
1164: } else {
1165: navwindow=window.open(url,
1166: "loncapanav","height=600,width=400,scrollbars=1");
1167: }
1168: }
1169: NAVCONTROL
1170: }
1171:
1172: sub utilityfunctions {
1173: my $caller = shift;
1174: unless (($env{'browser.interface'} eq 'textual') ||
1175: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1176: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1177: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1178:
1179: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1180: my $nav_control=&nav_control_js();
1181:
1182: my $start_page_annotate =
1183: &Apache::loncommon::start_page('Annotator',undef,
1184: {'only_body' => 1,
1185: 'js_ready' => 1,
1186: 'bgcolor' => '#BBBBBB',
1187: 'add_entries' => {
1188: 'onload' => 'javascript:document.goannotate.submit();'}});
1189:
1190: my $end_page_annotate =
1191: &Apache::loncommon::end_page({'js_ready' => 1});
1192:
1193: my $start_page_bookmark =
1194: &Apache::loncommon::start_page('Bookmarks',undef,
1195: {'only_body' => 1,
1196: 'js_ready' => 1,
1197: 'bgcolor' => '#BBBBBB',});
1198:
1199: my $end_page_bookmark =
1200: &Apache::loncommon::end_page({'js_ready' => 1});
1201:
1202: return (<<ENDUTILITY)
1203:
1204: var currentURL="$currenturl";
1205: var reloadURL="$currenturl";
1206: var currentSymb="$currentsymb";
1207:
1208: $nav_control
1209:
1210: function go(url) {
1211: if (url!='' && url!= null) {
1212: currentURL = null;
1213: currentSymb= null;
1214: window.location.href=url;
1215: }
1216: }
1217:
1218: function gopost(url,postdata) {
1219: if (url!='') {
1220: this.document.server.action=url;
1221: this.document.server.postdata.value=postdata;
1222: this.document.server.command.value='';
1223: this.document.server.url.value='';
1224: this.document.server.symb.value='';
1225: this.document.server.submit();
1226: }
1227: }
1228:
1229: function gocmd(url,cmd) {
1230: if (url!='') {
1231: this.document.server.action=url;
1232: this.document.server.postdata.value='';
1233: this.document.server.command.value=cmd;
1234: this.document.server.url.value=currentURL;
1235: this.document.server.symb.value=currentSymb;
1236: this.document.server.submit();
1237: }
1238: }
1239:
1240: function gocstr(url,filename) {
1241: if (url == '/adm/cfile?action=delete') {
1242: this.document.cstrdelete.filename.value = filename
1243: this.document.cstrdelete.submit();
1244: return;
1245: }
1246: if (url == '/adm/printout') {
1247: this.document.cstrprint.postdata.value = filename
1248: this.document.cstrprint.curseed.value = 0;
1249: this.document.cstrprint.problemtype.value = 0;
1250: if (this.document.lonhomework) {
1251: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1252: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1253: }
1254: if (this.document.lonhomework.problemtype) {
1255: if (this.document.lonhomework.problemtype.value) {
1256: this.document.cstrprint.problemtype.value =
1257: this.document.lonhomework.problemtype.value;
1258: } else if (this.document.lonhomework.problemtype.options) {
1259: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1260: if (this.document.lonhomework.problemtype.options[i].selected) {
1261: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1262: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1263: }
1264: }
1265: }
1266: }
1267: }
1268: }
1269: this.document.cstrprint.submit();
1270: return;
1271: }
1272: if (url !='') {
1273: this.document.constspace.filename.value = filename;
1274: this.document.constspace.action = url;
1275: this.document.constspace.submit();
1276: }
1277: }
1278:
1279: function golist(url) {
1280: if (url!='' && url!= null) {
1281: currentURL = null;
1282: currentSymb= null;
1283: top.location.href=url;
1284: }
1285: }
1286:
1287:
1288:
1289: function catalog_info() {
1290: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1291: }
1292:
1293: function chat_win() {
1294: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1295: }
1296:
1297: function group_chat(group) {
1298: var url = '/adm/groupchat?group='+group;
1299: var winName = 'LONchat_'+group;
1300: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1301: }
1302:
1303: function edit_bookmarks() {
1304: go('');
1305: w_BookmarkPal_flag=1;
1306: bookmarkpal=window.open("/adm/bookmarks",
1307: "BookmarkPal", "width=400,height=505,scrollbars=0");
1308: }
1309:
1310: function annotate() {
1311: w_Annotator_flag=1;
1312: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1313: annotator.document.write(
1314: '$start_page_annotate'
1315: +"<form name='goannotate' target='Annotator' method='post' "
1316: +"action='/adm/annotations'>"
1317: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1318: +"<\\/form>"
1319: +'$end_page_annotate');
1320: annotator.document.close();
1321: }
1322:
1323: function set_bookmark() {
1324: go('');
1325: clienttitle=document.title;
1326: clienthref=location.pathname;
1327: w_bmquery_flag=1;
1328: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1329: bmquery.document.write(
1330: '$start_page_bookmark'
1331: +"<center><form method='post'"
1332: +" name='newlink' action='/adm/bookmarks' target='bmquery' "
1333: +">\\n <table width=340 height=150 "
1334: +"bgcolor='ffffff' align=center><tr><td>Link Name:<br /><input "
1335: +"type='text' name='title' size=45 value='"+clienttitle+"' />"
1336: +"<br />Address:<br /><input type='text' name='address' size='45' "
1337: +"value='"+clienthref+"' /><br /><center><input type='submit' "
1338: +"value='Save' /> <input type='button' value='Close (no save)' "
1339: +"onclick='javascript:window.close();' /><\\/center><\\/td>"
1340: +"<\\/tr><\\/table><\\/form><\\/center>"
1341: +'$end_page_bookmark' );
1342: bmquery.document.close();
1343: }
1344:
1345: ENDUTILITY
1346: }
1347:
1348: sub serverform {
1349: return(<<ENDSERVERFORM);
1350: <form name="server" action="/adm/logout" method="post" target="_top">
1351: <input type="hidden" name="postdata" value="none" />
1352: <input type="hidden" name="command" value="none" />
1353: <input type="hidden" name="url" value="none" />
1354: <input type="hidden" name="symb" value="none" />
1355: </form>
1356: ENDSERVERFORM
1357: }
1358:
1359: sub constspaceform {
1360: return(<<ENDCONSTSPACEFORM);
1361: <form name="constspace" action="/adm/logout" method="post" target="_top">
1362: <input type="hidden" name="filename" value="" />
1363: </form>
1364: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1365: <input type="hidden" name="action" value="delete" />
1366: <input type="hidden" name="filename" value="" />
1367: </form>
1368: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1369: <input type="hidden" name="postdata" value="" />
1370: <input type="hidden" name="curseed" value="" />
1371: <input type="hidden" name="problemtype" value="" />
1372: </form>
1373:
1374: ENDCONSTSPACEFORM
1375: }
1376:
1377:
1378: sub get_nav_status {
1379: my $navstatus="swmenu.w_loncapanav_flag=";
1380: if ($env{'environment.remotenavmap'} eq 'on') {
1381: $navstatus.="1";
1382: } else {
1383: $navstatus.="-1";
1384: }
1385: return $navstatus;
1386: }
1387:
1388: #FIXME this needs to move into mydesktab and the other locations
1389: # the text is generated
1390: sub convert_menu_function {
1391: my ($rolename,$type) = @_;
1392: if ($type eq 'Group') {
1393: $rolename =~ s/student/member/g;
1394: $rolename =~ s/group/team/g;
1395: $rolename =~ s/course/group/g;
1396: $rolename =~ s/Course/Group/g;
1397: }
1398: return $rolename;
1399: }
1400:
1401: sub hidden_button_check {
1402: my $hidden;
1403: if ($env{'request.course.id'} eq '') {
1404: return;
1405: }
1406: if ($env{'request.role.adv'}) {
1407: return;
1408: }
1409: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
1410: return $buttonshide;
1411: }
1412:
1413: # ================================================================ Main Program
1414:
1415: BEGIN {
1416: if (! defined($readdesk)) {
1417: {
1418: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1419: if ( CORE::open( my $config,"<$tabfile") ) {
1420: while (my $configline=<$config>) {
1421: $configline=(split(/\#/,$configline))[0];
1422: $configline=~s/^\s+//;
1423: chomp($configline);
1424: if ($configline=~/^cat\:/) {
1425: my @entries=split(/\:/,$configline);
1426: $category_positions{$entries[2]}=$entries[1];
1427: $category_names{$entries[2]}=$entries[3];
1428: } elsif ($configline) {
1429: push(@desklines,$configline);
1430: }
1431: }
1432: CORE::close($config);
1433: }
1434: }
1435: $readdesk='done';
1436: }
1437: }
1438:
1439: 1;
1440: __END__
1441:
1442:
1443:
1444:
1445:
1446:
1447:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>