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