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