Annotation of loncom/interface/lonmenu.pm, revision 1.309.2.13
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.309.2.13! raeburn 4: # $Id: lonmenu.pm,v 1.309.2.12 2010/01/15 04:12:54 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.269 droeschl 29: # There is one parameter controlling the action of this module:
1.48 www 30: #
31: # environment.remote - if this is 'on', the routines controll the remote
1.269 droeschl 32: # control, otherwise they render the main window controls;
1.1 www 33:
1.244 jms 34: =head1 NAME
35:
36: Apache::lonmenu
37:
38: =head1 SYNOPSIS
39:
40: Coordinates the response to clicking an image.
41:
42: This is part of the LearningOnline Network with CAPA project
43: described at http://www.lon-capa.org.
44:
45: =head1 SUBROUTINES
46:
47: =over
48:
49: Little texts
50:
51: =item initlittle()
52:
53: =item menubuttons()
54:
55: This gets called at the top of the body section
56:
57: =item show_return_link()
58:
59: =item registerurl()
60:
61: This gets called in the header section
62:
63: =item innerregister()
64:
65: This gets called in order to register a URL, both with the Remote
66: and in the body of the document
67:
68: =item loadevents()
69:
70: =item unloadevents()
71:
72: =item startupremote()
73:
74: =item setflags()
75:
76: =item maincall()
77:
78: =item load_remote_msg()
79:
80: =item get_menu_name()
81:
82: =item reopenmenu()
83:
84: =item open()
85:
86: Open the menu
87:
88: =item clear()
89:
90: =item switch()
91:
92: Switch a button or create a link
93: Switch acts on the javascript that is executed when a button is clicked.
94: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
95:
96: =item secondlevel()
97:
98: =item openmenu()
99:
100: =item inlinemenu()
101:
102: =item rawconfig()
103:
104: =item close()
105:
106: =item footer()
107:
108: =item utilityfunctions()
109:
110: =item serverform()
111:
112: =item constspaceform()
113:
114: =item get_nav_status()
115:
116: =item hidden_button_check()
117:
118: =item roles_selector()
119:
120: =item jump_to_role()
121:
122: =back
123:
124: =cut
125:
1.1 www 126: package Apache::lonmenu;
127:
128: use strict;
1.152 albertel 129: use Apache::lonnet;
1.47 matthew 130: use Apache::lonhtmlcommon();
1.115 albertel 131: use Apache::loncommon();
1.127 albertel 132: use Apache::lonenc();
1.88 www 133: use Apache::lonlocal;
1.309.2.12 raeburn 134: use Apache::loncoursequeueadmin;
1.207 foxr 135: use LONCAPA qw(:DEFAULT :match);
1.282 amueller 136: use HTML::Entities();
1.88 www 137:
1.283 droeschl 138: use vars qw(@desklines %category_names %category_members %category_positions
139: $readdesk @primary_menu @secondary_menu);
1.88 www 140:
1.56 www 141: my @inlineremote;
1.38 www 142:
1.283 droeschl 143: sub prep_menuitem {
1.291 raeburn 144: my ($menuitem) = @_;
145: return '' unless(ref($menuitem) eq 'ARRAY');
1.283 droeschl 146: my $link;
147: if ($$menuitem[1]) { # graphical Link
148: $link = "<img class=\"LC_noBorder\""
1.291 raeburn 149: . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
150: . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283 droeschl 151: } else { # textual Link
1.291 raeburn 152: $link = &mt($$menuitem[3]);
153: }
1.299 raeburn 154: return '<li><a href="'.$$menuitem[0].'">'.$link.'</a></li>';
1.283 droeschl 155: }
156:
157: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
158: # that contains following links:
159: # About, Message, Roles, Help, Logout
160: # @primary_menu is filled within the BEGIN block of this module with
161: # entries from mydesk.tab
162: sub primary_menu {
163: my $menu;
1.309.2.1 raeburn 164: my $custommenu = &Apache::loncommon::needs_gci_custom();
1.283 droeschl 165: # each element of @primary contains following array:
166: # (link url, icon path, alt text, link text, condition)
167: foreach my $menuitem (@primary_menu) {
168: # evaluate conditions
1.296 droeschl 169: next if ref($menuitem) ne 'ARRAY'; #
1.283 droeschl 170: next if $$menuitem[4] eq 'nonewmsg' # show links depending on
1.291 raeburn 171: && &Apache::lonmsg::mynewmail(); # whether a new msg
1.283 droeschl 172: next if $$menuitem[4] eq 'newmsg' # arrived or not
1.291 raeburn 173: && !&Apache::lonmsg::mynewmail(); #
1.283 droeschl 174: next if $$menuitem[4] !~ /public/ ##we've a public user,
175: && $env{'user.name'} eq 'public' ##who should not see all
176: && $env{'user.domain'} eq 'public'; ##links
177: next if $$menuitem[4] eq 'onlypublic'# hide links which are
178: && $env{'user.name'} ne 'public' # only visible to public
179: && $env{'user.domain'} ne 'public'; # users
1.309.2.1 raeburn 180: next if $$menuitem[4] eq 'roles' # hide links which are
181: && $custommenu; # not visible when GCI
182: next if $$menuitem[4] eq 'courses' # tabbed interface in use
183: && $custommenu; #
1.283 droeschl 184: next if $$menuitem[4] eq 'roles' ##show links depending on
1.291 raeburn 185: && &Apache::loncommon::show_course(); ##term 'Courses' or
1.283 droeschl 186: next if $$menuitem[4] eq 'courses' ##'Roles' wanted
1.291 raeburn 187: && !&Apache::loncommon::show_course(); ##
188:
189:
1.283 droeschl 190: if ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.291 raeburn 191: $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.283 droeschl 192: } else {
1.296 droeschl 193: my @items = @{$menuitem};
194: $items[0] = 'javascript:'.$menuitem->[0].';';
195: $menu .= &prep_menuitem(\@items);
1.283 droeschl 196: }
1.291 raeburn 197: }
1.283 droeschl 198:
1.291 raeburn 199: return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283 droeschl 200: }
201:
202:
203: sub secondary_menu {
204: my $menu;
205:
1.286 raeburn 206: my $crstype = &Apache::loncommon::course_type();
207: my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
208: my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'}
209: . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
210: : ''));
211: my $showlink = &show_return_link();
212: my %groups = &Apache::lonnet::get_active_groups(
213: $env{'user.domain'}, $env{'user.name'},
214: $env{'course.' . $env{'request.course.id'} . '.domain'},
215: $env{'course.' . $env{'request.course.id'} . '.num'});
1.283 droeschl 216: foreach my $menuitem (@secondary_menu) {
217: # evaluate conditions
1.296 droeschl 218: next if ref($menuitem) ne 'ARRAY';
1.283 droeschl 219: next if $$menuitem[4] ne 'always'
220: && !$env{'request.course.id'};
221: next if $$menuitem[4] eq 'showreturn'
1.286 raeburn 222: && !$showlink
1.283 droeschl 223: && !($env{'request.state'} eq 'construct');
224: next if $$menuitem[4] =~ /^mdc/
1.286 raeburn 225: && !$canedit;
226: next if $$menuitem[4] eq 'mdcCourse'
227: && $crstype eq 'Community';
228: next if $$menuitem[4] eq 'mdcCommunity'
229: && $crstype ne 'Community';
230: next if $$menuitem[4] =~ /^remotenav/
1.283 droeschl 231: && $env{'environment.remotenavmap'} ne 'on';
1.286 raeburn 232: next if $$menuitem[4] =~ /noremotenav/
1.283 droeschl 233: && $env{'environment.remotenavmap'} eq 'on';
1.295 raeburn 234: next if $$menuitem[4] =~ /^(no|)remotenav$/
235: && $crstype eq 'Community';
236: next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/
237: && $crstype ne 'Community';
1.283 droeschl 238: next if $$menuitem[4] =~ /showgroups$/
1.300 raeburn 239: && !$canviewgrps
1.286 raeburn 240: && !%groups;
1.283 droeschl 241:
1.286 raeburn 242: if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283 droeschl 243: # special treatment for role selector
1.298 raeburn 244: my $roles_selector = &roles_selector(
1.283 droeschl 245: $env{'course.' . $env{'request.course.id'} . '.domain'},
246: $env{'course.' . $env{'request.course.id'} . '.num'} );
247:
248: $menu .= $roles_selector ? "<li>$roles_selector</li>"
249: : '';
1.296 droeschl 250: } elsif ($env{'environment.remotenavmap'} eq 'on') {
251: # open link using javascript when remote navmap is activated
252: my @items = @{$menuitem};
253: if ($menuitem->[4] eq 'remotenav') {
254: $items[0] = "javascript:gonav('$menuitem->[0]');";
1.291 raeburn 255: } else {
1.296 droeschl 256: $items[0] = "javascript:go('$menuitem->[0]');";
1.291 raeburn 257: }
1.296 droeschl 258: $menu .= &prep_menuitem(\@items);
259: } else {
260: $menu .= &prep_menuitem(\@$menuitem);
1.283 droeschl 261: }
262: }
263: if ($menu =~ /\[url\].*\[symb\]/) {
1.291 raeburn 264: my $escurl = &escape( &Apache::lonenc::check_encrypt(
265: $env{'request.noversionuri'}));
1.283 droeschl 266:
1.291 raeburn 267: my $escsymb = &escape( &Apache::lonenc::check_encrypt(
268: $env{'request.symb'}));
1.283 droeschl 269:
270: if ( $env{'request.state'} eq 'construct'
271: and ( $env{'request.noversionuri'} eq ''
272: || !defined($env{'request.noversionuri'})))
273: {
274: ($escurl = $env{'request.filename'}) =~
275: s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
276:
1.291 raeburn 277: $escurl = &escape($escurl);
1.283 droeschl 278: }
279: $menu =~ s/\[url\]/$escurl/g;
280: $menu =~ s/\[symb\]/$escsymb/g;
281: }
282:
1.285 wenzelju 283: return "<ul id=\"LC_secondary_menu\">$menu</ul>";
1.283 droeschl 284: }
285:
1.309.2.1 raeburn 286: sub gci_secondary_menu {
287: my %courses = (
288: 'review' => 'gci_9615072b469884921gcil1',
289: 'submit' => 'gci_1H96711d710194bfegcil1',
290: );
291: my %linktext = (
292: 'review' => 'Review Questions',
293: 'submit' => 'Submit Questions',
1.309.2.3 raeburn 294: 'managetest' => 'Manage Tests',
1.309.2.1 raeburn 295: );
1.309.2.3 raeburn 296: my %links = (
297: 'managetest' => '/adm/menu',
298: );
299: my $current = 'managetest';
1.309.2.5 raeburn 300: if ($env{'form.destinationurl'} eq '/adm/gci_info') {
301: undef($current);
302: }
1.309.2.1 raeburn 303: foreach my $key (keys(%courses)) {
304: $links{$key} = "javascript:switchpage('$key');";
305: if ($env{'request.course.id'} eq $courses{$key}) {
306: $links{$key} = '/adm/navmaps';
307: $current = $key;
1.309.2.3 raeburn 308: $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
1.309.2.1 raeburn 309: }
310: }
1.309.2.3 raeburn 311: my @menutabs = ('review','submit','managetest');
1.309.2.1 raeburn 312: my $tabs;
313: foreach my $item (@menutabs) {
314: if ($item eq $current) {
315: $tabs .= ' <li id="current"><a href="'.$links{$item}.'">'.
316: $linktext{$item}.'</a></li>';
317: } else {
318: $tabs .= ' <li><a href="'.$links{$item}.'">'.
319: $linktext{$item}.'</a></li>';
320: }
321: }
322: return '<div id="gciheader">'.
323: '<ul>'.$tabs.'</ul></div><br />';
324: }
1.283 droeschl 325:
1.274 www 326: #
327: # This routine returns a translated hash for the menu items in the top inline menu row
328: # Probably should be in mydesk.tab
329:
1.283 droeschl 330: #SD this sub is deprecated - don't use it
1.88 www 331: sub initlittle {
332: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
1.281 raeburn 333: 'nav' => 'Course Contents',
1.88 www 334: 'main' => 'Main Menu',
1.266 raeburn 335: 'roles' => (&Apache::loncommon::show_course()?
1.231 albertel 336: 'Courses':'Roles'),
1.235 raeburn 337: 'other' => 'Other Roles',
1.219 albertel 338: 'docs' => 'Edit Course',
1.257 hauer 339: 'exit' => 'Logout',
1.202 albertel 340: 'login' => 'Log In',
1.165 raeburn 341: 'launch' => 'Launch Remote Control',
1.188 albertel 342: 'groups' => 'Groups',
1.286 raeburn 343: 'gdoc' => 'Community Documents',
1.184 raeburn 344: );
1.88 www 345: }
346:
1.283 droeschl 347: #SD this sub is deprecated - don't use it
348: #SD functionality is covered by new loncommon::bodytag and primary_menu(), secondary_menu()
1.38 www 349: sub menubuttons {
350: my $forcereg=shift;
1.131 raeburn 351: my $titletable=shift;
1.274 www 352: #
353: # Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes"
354: #
1.112 albertel 355: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
356: ['inhibitmenu']);
1.152 albertel 357: if (($env{'form.inhibitmenu'} eq 'yes') ||
1.149 www 358: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
1.175 albertel 359:
360: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
361:
1.163 www 362: my %lt=&initlittle();
1.55 www 363: my $navmaps='';
1.59 www 364: my $reloadlink='';
1.151 www 365: my $docs='';
1.165 raeburn 366: my $groups='';
1.235 raeburn 367: my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
368: my $role_selector;
1.165 raeburn 369: my $showgroups=0;
1.235 raeburn 370: my ($cnum,$cdom);
1.274 www 371: #
372: # if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted
373: #
1.183 www 374: my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
375: my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
1.176 albertel 376:
1.199 albertel 377: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
1.253 kaisler 378: $logo = '<a href="/adm/about.html"><img src="'.
379: $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
1.199 albertel 380:
1.152 albertel 381: if ($env{'request.state'} eq 'construct') {
1.274 www 382: #
383: # We are in construction space
384: #
1.152 albertel 385: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
386: my $returnurl = $env{'request.filename'};
1.134 raeburn 387: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
1.183 www 388: $escurl = &escape($returnurl);
1.134 raeburn 389: }
390: }
1.165 raeburn 391: if ($env{'request.course.id'}) {
1.274 www 392: #
393: # We are in a course
394: #
1.235 raeburn 395: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
396: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.165 raeburn 397: my %coursegroups;
1.188 albertel 398: my $viewgrps_permission =
1.197 raeburn 399: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.165 raeburn 400: if (!$viewgrps_permission) {
1.235 raeburn 401: %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
1.188 albertel 402: }
1.165 raeburn 403: if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
404: $showgroups = 1;
405: }
1.235 raeburn 406: $role_selector = &roles_selector($cdom,$cnum);
407: if ($role_selector) {
408: $roles = '<span class="LC_nobreak">'.$role_selector.' <a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>';
409: }
1.165 raeburn 410: }
411:
1.267 droeschl 412: if ($env{'environment.remote'} eq 'off') {
1.48 www 413: # Remote Control is switched off
1.58 www 414: # figure out colors
1.267 droeschl 415: my %lt=&initlittle();
1.172 albertel 416:
1.58 www 417: my $domain=&Apache::loncommon::determinedomain();
1.291 raeburn 418: my $function=&Apache::loncommon::get_users_function();
1.58 www 419: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
420: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
421: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
422: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
1.267 droeschl 423:
424: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
425: return (<<ENDINLINEMENU);
1.285 wenzelju 426: <ol class="LC_primary_menu LC_right">
1.271 droeschl 427: <li>$logo</li>
428: <li><a href="/adm/roles" target="_top">$lt{'login'}</a></li>
429: </ol>
430: <hr />
1.156 albertel 431: ENDINLINEMENU
432: }
1.253 kaisler 433: $roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
1.58 www 434: # Do we have a NAV link?
1.152 albertel 435: if ($env{'request.course.id'}) {
1.141 albertel 436: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
437: $escsymb;
1.152 albertel 438: if ($env{'environment.remotenavmap'} eq 'on') {
1.141 albertel 439: $link="javascript:gonav('".$link."')";
440: }
441: $navmaps=(<<ENDNAV);
1.253 kaisler 442: <li><a href="$link" target="_top">$lt{'nav'}</a></li>
1.114 albertel 443: ENDNAV
1.286 raeburn 444: my $is_community =
445: (&Apache::loncommon::course_type() eq 'Community');
1.152 albertel 446: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.286 raeburn 447: my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'};
1.151 www 448: $docs=(<<ENDDOCS);
1.253 kaisler 449: <li><a href="/adm/coursedocs" target="_top">$text</a></li>
1.151 www 450: ENDDOCS
451: }
1.197 raeburn 452: if ($showgroups) {
453: $groups =(<<ENDGROUPS);
1.253 kaisler 454: <li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li>
1.197 raeburn 455: ENDGROUPS
456: }
1.228 albertel 457: if (&show_return_link()) {
1.183 www 458: my $escreload=&escape('return:');
1.59 www 459: $reloadlink=(<<ENDRELOAD);
1.253 kaisler 460: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.59 www 461: ENDRELOAD
462: }
1.235 raeburn 463: if ($role_selector) {
1.253 kaisler 464: #$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
465: $role_selector = '<li>'.$role_selector.'</li>';
1.235 raeburn 466: }
1.55 www 467: }
1.163 www 468: if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
1.183 www 469: my $escreload=&escape('return:');
1.163 www 470: $reloadlink=(<<ENDCRELOAD);
1.253 kaisler 471: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.163 www 472: ENDCRELOAD
473: }
1.276 droeschl 474: my $reg = $forcereg ? &innerregister($forcereg,$titletable) : '';
475: my $form = &serverform();
476: my $utility = &utilityfunctions();
477:
478: #Prepare the message link that indicates the arrival of new mail
1.291 raeburn 479: my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
1.276 droeschl 480: $messagelink = '<a href="javascript:go(\'/adm/communicate\');">'
481: . mt($messagelink) .'</a>';
482:
483: my $helplink = &Apache::loncommon::top_nav_help('Help');
1.58 www 484: return (<<ENDINLINEMENU);
1.129 albertel 485: <script type="text/javascript">
1.277 bisitz 486: // <![CDATA[
1.150 albertel 487: // BEGIN LON-CAPA Internal
1.116 albertel 488: $utility
1.150 albertel 489: // ]]>
1.48 www 490: </script>
1.285 wenzelju 491: <ol class="LC_primary_menu LC_right">
1.253 kaisler 492: <li>$logo</li>
1.256 kaisler 493: <li>$messagelink</li>
1.253 kaisler 494: <li>$roles</li>
495: <li>$helplink</li>
496: <li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li>
497: </ol>
1.285 wenzelju 498: <ul id="LC_secondary_menu">
1.253 kaisler 499: <li><a href="/adm/menu" target="_top">$lt{'main'}</a></li>
1.59 www 500: $reloadlink
1.55 www 501: $navmaps
1.151 www 502: $docs
1.165 raeburn 503: $groups
1.253 kaisler 504: $role_selector
1.263 droeschl 505: </ul>
1.168 albertel 506: $form
1.129 albertel 507: <script type="text/javascript">
1.48 www 508: // END LON-CAPA Internal
509: </script>
1.58 www 510: $reg
1.48 www 511: ENDINLINEMENU
512: } else {
513: return '';
514: }
1.72 www 515: }
516:
1.228 albertel 517: sub show_return_link {
518: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
519: $env{'request.symb'} eq '')
520: ||
521: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
522: ||
523: (($env{'request.noversionuri'}=~/^\/adm\//) &&
524: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
525: ($env{'request.noversionuri'}!~
526: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
527: ));
528: }
529:
1.38 www 530:
531: sub registerurl {
1.173 albertel 532: my ($forcereg) = @_;
1.38 www 533: my $result = '';
1.175 albertel 534: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.66 albertel 535: my $force_title='';
1.152 albertel 536: if ($env{'request.state'} eq 'construct') {
1.66 albertel 537: $force_title=&Apache::lonxml::display_title();
538: }
1.269 droeschl 539: if (($env{'environment.remote'} eq 'off') ||
1.152 albertel 540: ((($env{'request.publicaccess'}) ||
1.83 www 541: (!&Apache::lonnet::is_on_map(
1.183 www 542: &unescape($env{'request.noversionuri'})))) &&
1.38 www 543: (!$forcereg))) {
1.277 bisitz 544: return
545: $result
546: .'<script type="text/javascript">'."\n"
547: .'// <![CDATA['."\n"
548: .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
549: .'// ]]>'."\n"
550: .'</script>'
551: .$force_title;
1.38 www 552: }
1.41 www 553: # Graphical display after login only
1.174 albertel 554: if ($env{'request.registered'} && !$forcereg) { return ''; }
1.173 albertel 555: $result.=&innerregister($forcereg);
1.66 albertel 556: return $result.$force_title;
1.40 www 557: }
558:
559: sub innerregister {
1.308 raeburn 560: my ($forcereg,$titletable,$bread_crumbs) = @_;
1.40 www 561: my $result = '';
1.120 raeburn 562: my ($uname,$thisdisfn);
1.152 albertel 563: my $const_space = ($env{'request.state'} eq 'construct');
1.131 raeburn 564: my $is_const_dir = 0;
1.120 raeburn 565:
1.175 albertel 566: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40 www 567:
1.174 albertel 568: $env{'request.registered'} = 1;
1.40 www 569:
1.267 droeschl 570: my $noremote = ($env{'environment.remote'} eq 'off');
1.49 www 571:
1.177 albertel 572: undef(@inlineremote);
1.56 www 573:
1.38 www 574: my $reopen=&Apache::lonmenu::reopenmenu();
1.40 www 575:
1.38 www 576: my $newmail='';
1.267 droeschl 577:
578: if (&Apache::lonmsg::newmail() && !$noremote) {
579: # We have new mail and remote is up
580: $newmail= 'swmenu.setstatus("you have","messages");';
1.233 www 581: }
1.276 droeschl 582:
1.288 raeburn 583: my ($breadcrumb,$separator);
1.267 droeschl 584: if ($noremote
1.177 albertel 585: && ($env{'request.symb'})
586: && ($env{'request.course.id'})) {
1.267 droeschl 587:
588: my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
589: my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
590:
591: my $maptitle = &Apache::lonnet::gettitle($mapurl);
592: my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.299 raeburn 593: my $contentstext;
594: if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') {
595: $contentstext = &mt('Community Contents');
596: } else {
597: $contentstext = &mt('Course Contents');
598: }
599: my @crumbs = ({text => $contentstext,
1.289 raeburn 600: href => "Javascript:gonav('/adm/navmaps')"});
601:
602: if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
603: push(@crumbs, {text => '...',
604: no_mt => 1});
605: }
1.268 droeschl 606:
607: push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
608: && $maptitle ne 'default.sequence'
609: && $maptitle ne $coursetitle);
610:
611: push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
612:
1.291 raeburn 613: &Apache::lonhtmlcommon::clear_breadcrumbs();
614: &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.301 droeschl 615: #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.288 raeburn 616: unless (($env{'request.state'} eq 'edit') || ($newmail) ||
617: ($env{'request.state'} eq 'construct') ||
618: ($env{'form.register'})) {
619: $separator = &Apache::loncommon::head_subbox();
620: }
1.267 droeschl 621: #
1.65 www 622: }
1.152 albertel 623: if ($env{'request.state'} eq 'construct') {
1.131 raeburn 624: $newmail = $titletable;
1.267 droeschl 625: }
626: my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
627: my $tablestart = ( $noremote ? '<table id="LC_menubuttons">' : '');
628: my $tableend = ( $noremote ? '</table>' : '');
1.41 www 629: # =============================================================================
630: # ============================ This is for URLs that actually can be registered
1.296 droeschl 631: if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) {
1.40 www 632: # -- This applies to homework problems for users with grading privileges
1.152 albertel 633: my $crs='/'.$env{'request.course.id'};
634: if ($env{'request.course.sec'}) {
635: $crs.='_'.$env{'request.course.sec'};
1.107 albertel 636: }
637: $crs=~s/\_/\//g;
638:
1.38 www 639: my $hwkadd='';
1.152 albertel 640: if ($env{'request.symb'} ne '' &&
1.161 albertel 641: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
1.79 www 642: if (&Apache::lonnet::allowed('mgr',$crs)) {
1.259 bisitz 643: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
1.40 www 644: "gocmd('/adm/grades','gradingmenu')",
645: 'Modify user grades for this assessment resource');
1.154 www 646: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
647: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
648: "gocmd('/adm/grades','submission')",
649: 'View user submissions for this assessment resource');
1.38 www 650: }
1.107 albertel 651: }
1.152 albertel 652: if ($env{'request.symb'} ne '' &&
1.145 albertel 653: &Apache::lonnet::allowed('opa',$crs)) {
1.107 albertel 654: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
655: "gocmd('/adm/parmset','set')",
1.196 www 656: 'Modify parameter settings for this resource');
1.38 www 657: }
1.40 www 658: # -- End Homework
1.38 www 659: ###
660: ### Determine whether or not to display the 'cstr' button for this
661: ### resource
662: ###
663: my $editbutton = '';
1.258 raeburn 664: my $noeditbutton = 1;
665: my ($cnum,$cdom);
666: if ($env{'request.course.id'}) {
667: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
668: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
669: }
1.152 albertel 670: if ($env{'user.author'}) {
1.234 raeburn 671: if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.274 www 672: #
673: # We have the role of an author
674: #
1.38 www 675: # Set defaults for authors
676: my ($top,$bottom) = ('con-','struct');
1.152 albertel 677: my $action = "go('/priv/".$env{'user.name'}."');";
678: my $cadom = $env{'request.role.domain'};
679: my $caname = $env{'user.name'};
1.236 bisitz 680: my $desc = "Enter my construction space";
1.38 www 681: # Set defaults for co-authors
1.152 albertel 682: if ($env{'request.role'} =~ /^ca/) {
1.206 albertel 683: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38 www 684: ($top,$bottom) = ('co con-','struct');
685: $action = "go('/priv/".$caname."');";
686: $desc = "Enter construction space as co-author";
1.234 raeburn 687: } elsif ($env{'request.role'} =~ /^aa/) {
688: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
689: ($top,$bottom) = ('co con-','struct');
690: $action = "go('/priv/".$caname."');";
691: $desc = "Enter construction space as assistant co-author";
1.38 www 692: }
693: # Check that we are on the correct machine
694: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 695: my $allowed=0;
696: my @ids=&Apache::lonnet::current_machine_ids();
697: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
698: if (!$allowed) {
699: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258 raeburn 700: $noeditbutton = 0;
1.38 www 701: }
702: }
1.274 www 703: #
704: # We are an author for some stuff, but currently do not have the role of author.
705: # Figure out if we have authoring privileges for the resource we are looking at.
706: # This should maybe become a privilege check in lonnet
707: #
1.38 www 708: ##
709: ## Determine if user can edit url.
710: ##
711: my $cfile='';
712: my $cfuname='';
713: my $cfudom='';
1.258 raeburn 714: my $uploaded;
1.152 albertel 715: if ($env{'request.filename'}) {
716: my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258 raeburn 717: if (defined($cnum) && defined($cdom)) {
718: $uploaded = &is_course_upload($file,$cnum,$cdom);
719: }
720: if (!$uploaded) {
721: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
722: # Check that the user has permission to edit this resource
723: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
724: if (defined($cfudom)) {
725: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
726: my $allowed=0;
727: my @ids=&Apache::lonnet::current_machine_ids();
728: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
729: if ($allowed) {
730: $cfile=$file;
731: }
1.38 www 732: }
733: }
1.258 raeburn 734: }
1.38 www 735: # Finally, turn the button on or off
1.120 raeburn 736: if ($cfile && !$const_space) {
1.302 raeburn 737: my $nocrsedit;
738: # Suppress display where CC has switched to student role.
739: if ($env{'request.course.id'}) {
740: unless(&Apache::lonnet::allowed('mdc',
741: $env{'request.course.id'})) {
742: $nocrsedit = 1;
743: }
744: }
745: if ($nocrsedit) {
746: $editbutton=&clear(6,1);
747: } else {
748: $editbutton=&switch
749: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
1.38 www 750: "go('".$cfile."');","Edit this resource");
1.302 raeburn 751: $noeditbutton = 0;
752: }
1.38 www 753: } elsif ($editbutton eq '') {
1.191 www 754: $editbutton=&clear(6,1);
1.38 www 755: }
756: }
1.258 raeburn 757: if (($noeditbutton) && ($env{'request.filename'})) {
758: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
759: my $file=&Apache::lonnet::declutter($env{'request.filename'});
760: if (defined($cnum) && defined($cdom)) {
761: if (&is_course_upload($file,$cnum,$cdom)) {
762: my $cfile = &edit_course_upload($file,$cnum,$cdom);
763: if ($cfile) {
764: $editbutton=&switch
765: ('','',6,1,'pcstr.gif','edit[_1]',
766: 'resource[_2]',"go('".$cfile."');",
767: 'Edit this resource');
768: }
769: }
770: }
771: }
772: }
1.38 www 773: ###
774: ###
1.41 www 775: # Prepare the rest of the buttons
1.120 raeburn 776: my $menuitems;
777: if ($const_space) {
1.274 www 778: #
779: # We are in construction space
780: #
1.128 albertel 781: my ($uname,$thisdisfn) =
1.152 albertel 782: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121 raeburn 783: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131 raeburn 784: if ($currdir =~ m-/$-) {
785: $is_const_dir = 1;
786: } else {
1.267 droeschl 787: $currdir =~ s|[^/]+$||;
1.200 foxr 788: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208 albertel 789: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274 www 790: #
791: # Probably should be in mydesk.tab
792: #
1.131 raeburn 793: $menuitems=(<<ENDMENUITEMS);
1.208 albertel 794: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
1.200 foxr 795: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
1.259 bisitz 796: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
1.200 foxr 797: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
798: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
1.120 raeburn 799: ENDMENUITEMS
1.131 raeburn 800: }
1.308 raeburn 801: if ($noremote) {
802: if (ref($bread_crumbs) eq 'ARRAY') {
803: &Apache::lonhtmlcommon::clear_breadcrumbs();
804: foreach my $crumb (@{$bread_crumbs}){
805: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
806: }
807: }
808: }
1.203 foxr 809: } elsif ( defined($env{'request.course.id'}) &&
810: $env{'request.symb'} ne '' ) {
1.274 www 811: #
812: # We are in a course and looking at a registred URL
813: # Should probably be in mydesk.tab
814: #
1.120 raeburn 815: $menuitems=(<<ENDMENUITEMS);
1.41 www 816: c&3&1
1.209 www 817: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
818: 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 819: c&6&3
820: c&8&1
821: c&8&2
1.106 www 822: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.209 www 823: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
1.41 www 824: ENDMENUITEMS
1.216 albertel 825:
1.243 tempelho 826: my $currentURL = &Apache::loncommon::get_symb();
827: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
828: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
829: $menuitems.="s&9&3&";
830: if(length($annotation) > 0){
831: $menuitems.="anot2.gif";
832: }else{
833: $menuitems.="anot.gif";
834: }
835: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
836: $menuitems.="Make notes and annotations about this resource&&1\n";
837:
1.279 raeburn 838: unless ($noremote) {
839: my $showreqcrs = &check_for_rcrs();
840: if ($showreqcrs) {
841: $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]".
842: "&go('/adm/requestcourse')&Course requests\n";
843: }
844: }
1.193 raeburn 845: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
1.294 raeburn 846: if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
1.216 albertel 847: $menuitems.=(<<ENDREALRES);
1.259 bisitz 848: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
1.216 albertel 849: ENDREALRES
850: }
1.120 raeburn 851: $menuitems.=(<<ENDREALRES);
1.106 www 852: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
853: 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 854: ENDREALRES
1.120 raeburn 855: }
856: }
1.203 foxr 857: if ($env{'request.uri'} =~ /^\/res/) {
858: $menuitems .= (<<ENDMENUITEMS);
859: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
860: ENDMENUITEMS
861: }
1.41 www 862: my $buttons='';
863: foreach (split(/\n/,$menuitems)) {
864: my ($command,@rest)=split(/\&/,$_);
1.220 raeburn 865: my $idx=10*$rest[0]+$rest[1];
866: if (&hidden_button_check() eq 'yes') {
867: if ($idx == 21 ||$idx == 23) {
868: $buttons.=&switch('','',@rest);
869: } else {
870: $buttons.=&clear(@rest);
871: }
872: } else {
873: if ($command eq 's') {
874: $buttons.=&switch('','',@rest);
875: } else {
876: $buttons.=&clear(@rest);
877: }
1.41 www 878: }
879: }
1.148 albertel 880:
1.267 droeschl 881: if ($noremote) {
1.148 albertel 882: my $addremote=0;
1.267 droeschl 883: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.148 albertel 884: my $inlinebuttons='';
1.301 droeschl 885: if ($addremote) {
886:
887: #SD START (work in progress!)
1.304 droeschl 888: Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301 droeschl 889: # Arrows for navigation
890: Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] );
891: Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] );
892: if(hidden_button_check() ne 'yes'){
893: # notes
894: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]);
895: # bookmark
896: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]);
897: # evaluate
898: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]);
899: # feedback
900: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]);
901: # print
902: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]);
903: # metadata
904: Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]);
905:
906: # ?
907: Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]);
908: # ?
909: Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]);
910: # ?
911: Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]);
912: # ?
913: Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]);
914: # ?
915: Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]);
916:
917: }
918:
919: #SD END
920: # # Registered, textual output
921: # if ( $env{'environment.icons'} eq 'iconsonly' ) {
922: # $inlinebuttons = (<<ENDARROWSINLINE);
923: #<tr><td>
924: #$inlineremote[21] $inlineremote[23]
925: #ENDARROWSINLINE
926: # if ( &hidden_button_check() ne 'yes' ) {
927: # $inlinebuttons .= (<<ENDINLINEICONS);
928: #$inlineremote[61] $inlineremote[63]
929: #$inlineremote[71] $inlineremote[72] $inlineremote[73]
930: #$inlineremote[81] $inlineremote[82] $inlineremote[83]
931: #$inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
932: #ENDINLINEICONS
933: # }
934: # } else { # not iconsonly
935: # if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) {
936: # $inlinebuttons = (<<ENDFIRSTLINE);
937: #<tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
938: #ENDFIRSTLINE
939: # }
940: # if ( &hidden_button_check() ne 'yes' ) {
941: # foreach my $row ( 6 .. 9 ) {
942: # if ( $inlineremote[ ${row} . '1' ] ne ''
943: # || $inlineremote[ $row . '2' ] ne ''
944: # || $inlineremote[ $row . '3' ] ne '' )
945: # {
946: # $inlinebuttons .= <<"ENDLINE";
947: #<tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
948: #ENDLINE
949: # }
950: # }
951: # }
952: # }
953: }
954: #SD see below
955: $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.41 www 956: $result =(<<ENDREGTEXT);
1.129 albertel 957: <script type="text/javascript">
1.42 www 958: // BEGIN LON-CAPA Internal
959: </script>
1.41 www 960: $timesync
1.267 droeschl 961: $breadcrumb
1.305 bisitz 962: <!-- $tablestart -->
963: <!-- $inlinebuttons -->
964: <!-- $tableend -->
1.224 albertel 965: $newmail
1.305 bisitz 966: <!-- $separator -->
1.129 albertel 967: <script type="text/javascript">
1.64 www 968: // END LON-CAPA Internal
1.42 www 969: </script>
970:
1.41 www 971: ENDREGTEXT
972: # Registered, graphical output
973: } else {
1.152 albertel 974: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.183 www 975: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
1.152 albertel 976: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.113 albertel 977: my $navstatus=&get_nav_status();
1.140 albertel 978: my $clearcstr;
1.148 albertel 979:
1.152 albertel 980: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
1.41 www 981: $result = (<<ENDREGTHIS);
1.38 www 982:
1.129 albertel 983: <script type="text/javascript">
1.277 bisitz 984: // <![CDATA[
1.150 albertel 985: // BEGIN LON-CAPA Internal
1.42 www 986: var swmenu=null;
1.38 www 987:
988: function LONCAPAreg() {
989: swmenu=$reopen;
990: swmenu.clearTimeout(swmenu.menucltim);
991: $timesync
992: $newmail
1.41 www 993: $buttons
1.84 www 994: swmenu.currentURL="$requri";
1.85 www 995: swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125 albertel 996: swmenu.currentSymb="$cursymb";
997: swmenu.reloadSymb="$cursymb";
1.38 www 998: swmenu.currentStale=0;
1.113 albertel 999: $navstatus
1.38 www 1000: $hwkadd
1001: $editbutton
1002: }
1003:
1004: function LONCAPAstale() {
1005: swmenu=$reopen
1006: swmenu.currentStale=1;
1007: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
1008: swmenu.switchbutton
1009: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
1010: }
1011: swmenu.clearbut(7,2);
1012: swmenu.clearbut(7,3);
1013: swmenu.menucltim=swmenu.setTimeout(
1014: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.140 albertel 1015: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
1.38 www 1016: 2000);
1017: }
1018:
1.150 albertel 1019: // END LON-CAPA Internal
1.277 bisitz 1020: // ]]>
1.38 www 1021: </script>
1022: ENDREGTHIS
1.41 www 1023: }
1024: # =============================================================================
1.38 www 1025: } else {
1.41 www 1026: # ========================================== This can or will not be registered
1.267 droeschl 1027: if ($noremote) {
1.269 droeschl 1028: # Not registered
1.267 droeschl 1029: $result= (<<ENDDONOTREGTEXT);
1.41 www 1030: ENDDONOTREGTEXT
1031: } else {
1032: # Not registered, graphical
1033: $result = (<<ENDDONOTREGTHIS);
1.38 www 1034:
1.129 albertel 1035: <script type="text/javascript">
1.277 bisitz 1036: // <![CDATA[
1.38 www 1037: // BEGIN LON-CAPA Internal
1.42 www 1038: var swmenu=null;
1.38 www 1039:
1040: function LONCAPAreg() {
1041: swmenu=$reopen
1042: $timesync
1043: swmenu.currentStale=1;
1044: swmenu.clearbut(2,1);
1045: swmenu.clearbut(2,3);
1046: swmenu.clearbut(8,1);
1047: swmenu.clearbut(8,2);
1048: swmenu.clearbut(8,3);
1049: if (swmenu.currentURL) {
1050: swmenu.switchbutton
1051: (3,1,'reload.gif','return','location','go(currentURL)');
1052: } else {
1053: swmenu.clearbut(3,1);
1054: }
1055: }
1056:
1057: function LONCAPAstale() {
1058: }
1059:
1060: // END LON-CAPA Internal
1.277 bisitz 1061: // ]]>
1.38 www 1062: </script>
1063: ENDDONOTREGTHIS
1.41 www 1064: }
1065: # =============================================================================
1.38 www 1066: }
1067: return $result;
1068: }
1069:
1.258 raeburn 1070: sub is_course_upload {
1071: my ($file,$cnum,$cdom) = @_;
1072: my $uploadpath = &LONCAPA::propath($cdom,$cnum);
1073: $uploadpath =~ s{^\/}{};
1074: if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
1075: ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
1076: return 1;
1077: }
1078: return;
1079: }
1080:
1081: sub edit_course_upload {
1082: my ($file,$cnum,$cdom) = @_;
1083: my $cfile;
1084: if ($file =~/\.(htm|html|css|js|txt)$/) {
1085: my $ext = $1;
1086: my $url = &Apache::lonnet::hreflocation('',$file);
1087: my $home = &Apache::lonnet::homeserver($cnum,$cdom);
1088: my @ids=&Apache::lonnet::current_machine_ids();
1089: my $dest;
1090: if ($home && grep(/^\Q$home\E$/,@ids)) {
1091: $dest = $url.'?forceedit=1';
1092: } else {
1093: unless (&Apache::lonnet::get_locks()) {
1094: $dest = '/adm/switchserver?otherserver='.
1095: $home.'&role='.$env{'request.role'}.
1096: '&url='.$url.'&forceedit=1';
1097: }
1098: }
1099: if ($dest) {
1100: $cfile = &HTML::Entities::encode($dest,'"<>&');
1101: }
1102: }
1103: return $cfile;
1104: }
1105:
1.38 www 1106: sub loadevents() {
1.152 albertel 1107: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 1108: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 1109: return 'LONCAPAreg();';
1110: }
1111:
1112: sub unloadevents() {
1.152 albertel 1113: if ($env{'request.state'} eq 'construct' ||
1.175 albertel 1114: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38 www 1115: return 'LONCAPAstale();';
1116: }
1.30 www 1117:
1.32 www 1118:
1119: sub startupremote {
1120: my ($lowerurl)=@_;
1.269 droeschl 1121: if ($env{'environment.remote'} eq 'off') {
1.34 www 1122: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
1123: }
1.49 www 1124: #
1125: # The Remote actually gets launched!
1126: #
1.32 www 1127: my $configmenu=&rawconfig();
1.183 www 1128: my $esclowerurl=&escape($lowerurl);
1.119 www 1129: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32 www 1130: return(<<ENDREMOTESTARTUP);
1.129 albertel 1131: <script type="text/javascript">
1.277 bisitz 1132: // <![CDATA[
1.118 albertel 1133: var timestart;
1.35 www 1134: function wheelswitch() {
1.118 albertel 1135: if (typeof(document.wheel) != 'undefined') {
1136: if (typeof(document.wheel.spin) != 'undefined') {
1137: var date=new Date();
1138: var waited=Math.round(30-((date.getTime()-timestart)/1000));
1139: document.wheel.spin.value=$message;
1140: }
1141: }
1.35 www 1142: if (window.status=='|') {
1143: window.status='/';
1144: } else {
1145: if (window.status=='/') {
1146: window.status='-';
1147: } else {
1148: if (window.status=='-') {
1149: window.status='\\\\';
1150: } else {
1151: if (window.status=='\\\\') { window.status='|'; }
1152: }
1153: }
1154: }
1155: }
1156:
1.32 www 1157: // ---------------------------------------------------------- The wait function
1158: var canceltim;
1159: function wait() {
1160: if ((menuloaded==1) || (tim==1)) {
1.35 www 1161: window.status='Done.';
1.32 www 1162: if (tim==0) {
1163: clearTimeout(canceltim);
1164: $configmenu
1165: window.location='$lowerurl';
1166: } else {
1.52 www 1167: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32 www 1168: }
1169: } else {
1.35 www 1170: wheelswitch();
1171: setTimeout('wait();',200);
1.32 www 1172: }
1173: }
1174:
1175: function main() {
1.52 www 1176: canceltim=setTimeout('tim=1;',30000);
1.35 www 1177: window.status='-';
1.118 albertel 1178: var date=new Date();
1179: timestart=date.getTime();
1.32 www 1180: wait();
1181: }
1182:
1.277 bisitz 1183: // ]]>
1.32 www 1184: </script>
1185: ENDREMOTESTARTUP
1186: }
1187:
1188: sub setflags() {
1189: return(<<ENDSETFLAGS);
1.129 albertel 1190: <script type="text/javascript">
1.277 bisitz 1191: // <![CDATA[
1.32 www 1192: menuloaded=0;
1193: tim=0;
1.277 bisitz 1194: // ]]>
1.32 www 1195: </script>
1196: ENDSETFLAGS
1197: }
1198:
1199: sub maincall() {
1.269 droeschl 1200: if ($env{'environment.remote'} eq 'off') { return ''; }
1.32 www 1201: return(<<ENDMAINCALL);
1.129 albertel 1202: <script type="text/javascript">
1.277 bisitz 1203: // <![CDATA[
1.32 www 1204: main();
1.277 bisitz 1205: // ]]>
1.32 www 1206: </script>
1207: ENDMAINCALL
1208: }
1.118 albertel 1209:
1210: sub load_remote_msg {
1211: my ($lowerurl)=@_;
1212:
1.269 droeschl 1213: if ($env{'environment.remote'} eq 'off') { return ''; }
1.118 albertel 1214:
1.183 www 1215: my $esclowerurl=&escape($lowerurl);
1.261 bisitz 1216: my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
1217: ,'<a href="/adm/remote?action=collapse&url='.$esclowerurl.'">'
1218: ,'</a>');
1.118 albertel 1219: return(<<ENDREMOTEFORM);
1220: <p>
1221: <form name="wheel">
1.119 www 1222: <input name="spin" type="text" size="60" />
1.118 albertel 1223: </form>
1224: </p>
1225: <p>$link</p>
1226: ENDREMOTEFORM
1227: }
1.230 albertel 1228:
1229: sub get_menu_name {
1230: my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
1231: $hostid =~ s/\W//g;
1232: return 'LCmenu'.$hostid;
1233: }
1234:
1.30 www 1235:
1236: sub reopenmenu {
1.269 droeschl 1237: if ($env{'environment.remote'} eq 'off') { return ''; }
1.230 albertel 1238: my $menuname = &get_menu_name();
1.47 matthew 1239: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1240: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30 www 1241: }
1242:
1.1 www 1243:
1244: sub open {
1.22 www 1245: my $returnval='';
1.269 droeschl 1246: if ($env{'environment.remote'} eq 'off') {
1.277 bisitz 1247: return
1248: '<script type="text/javascript">'."\n"
1249: .'// <![CDATA['."\n"
1250: .'self.name="loncapaclient";'."\n"
1251: .'// ]]>'."\n"
1252: .'</script>';
1.111 albertel 1253: }
1.230 albertel 1254: my $menuname = &get_menu_name();
1.222 albertel 1255:
1256: # unless (shift eq 'unix') {
1.22 www 1257: # resizing does not work on linux because of virtual desktop sizes
1.222 albertel 1258: # $returnval.=(<<ENDRESIZE);
1259: #if (window.screen) {
1260: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1261: # self.moveTo(190,15);
1262: #}
1263: #ENDRESIZE
1264: # }
1.277 bisitz 1265: $returnval=(<<ENDOPEN);
1266: // <![CDATA[
1.35 www 1267: window.status='Opening LON-CAPA Remote Control';
1.272 droeschl 1268: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
1.191 www 1269: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71 www 1270: self.name='loncapaclient';
1.277 bisitz 1271: // ]]>
1.1 www 1272: ENDOPEN
1.129 albertel 1273: return '<script type="text/javascript">'.$returnval.'</script>';
1.1 www 1274: }
1275:
1.2 www 1276:
1277: # ================================================================== Raw Config
1278:
1.3 www 1279: sub clear {
1280: my ($row,$col)=@_;
1.269 droeschl 1281: unless ($env{'environment.remote'} eq 'off') {
1.275 www 1282: if (($row<1) || ($row>13)) { return ''; }
1.35 www 1283: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56 www 1284: } else {
1285: $inlineremote[10*$row+$col]='';
1286: return '';
1287: }
1.3 www 1288: }
1289:
1.40 www 1290: # ============================================ Switch a button or create a link
1.25 matthew 1291: # Switch acts on the javascript that is executed when a button is clicked.
1292: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 1293:
1.2 www 1294: sub switch {
1.209 www 1295: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2 www 1296: $act=~s/\$uname/$uname/g;
1297: $act=~s/\$udom/$udom/g;
1.88 www 1298: $top=&mt($top);
1299: $bot=&mt($bot);
1300: $desc=&mt($desc);
1.238 www 1301: if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
1302: $img=&mt($img);
1303: }
1.209 www 1304: my $idx=10*$row+$col;
1305: $category_members{$cat}.=':'.$idx;
1306:
1.269 droeschl 1307: unless ($env{'environment.remote'} eq 'off') {
1.275 www 1308: if (($row<1) || ($row>13)) { return ''; }
1.50 www 1309: # Remote
1.34 www 1310: return "\n".
1.35 www 1311: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.34 www 1312: } else {
1.50 www 1313: # Inline Remote
1.213 www 1314: if ($env{'environment.icons'} ne 'classic') {
1315: $img=~s/\.gif$/\.png/;
1316: }
1.41 www 1317: if ($nobreak==2) { return ''; }
1.34 www 1318: my $text=$top.' '.$bot;
1.78 www 1319: $text=~s/\s*\-\s*//gs;
1.105 www 1320:
1.99 www 1321: my $pic=
1.225 albertel 1322: '<img alt="'.$text.'" src="'.
1323: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303 droeschl 1324: '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.177 albertel 1325: if ($env{'browser.interface'} eq 'faketextual') {
1.274 www 1326: # Main Menu
1.103 www 1327: if ($nobreak==3) {
1.209 www 1328: $inlineremote[$idx]="\n".
1.177 albertel 1329: '<td class="LC_menubuttons_text" align="right">'.$text.
1.247 harmsja 1330: '</td><td align="left">'.
1.103 www 1331: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
1332: } elsif ($nobreak) {
1.209 www 1333: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1334: '<td align="left">'.
1.177 albertel 1335: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215 www 1336: <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 1337: } else {
1.209 www 1338: $inlineremote[$idx]="\n<tr>".
1.247 harmsja 1339: '<td align="left">'.
1.103 www 1340: '<a href="javascript:'.$act.';">'.$pic.
1.177 albertel 1341: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215 www 1342: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103 www 1343: }
1.94 www 1344: } else {
1.103 www 1345: # Inline Menu
1.218 www 1346: if ($env{'environment.icons'} eq 'iconsonly') {
1347: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
1348: } else {
1349: $inlineremote[$idx]=
1.301 droeschl 1350: '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.215 www 1351: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1.218 www 1352: }
1.94 www 1353: }
1.34 www 1354: }
1.56 www 1355: return '';
1.2 www 1356: }
1357:
1358: sub secondlevel {
1359: my $output='';
1360: my
1.209 www 1361: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2 www 1362: if ($prt eq 'any') {
1.209 www 1363: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1364: } elsif ($prt=~/^r(\w+)/) {
1365: if ($rol eq $1) {
1.209 www 1366: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1367: }
1368: }
1369: return $output;
1370: }
1371:
1.18 www 1372: sub openmenu {
1.230 albertel 1373: my $menuname = &get_menu_name();
1.269 droeschl 1374: if ($env{'environment.remote'} eq 'off') { return ''; }
1.47 matthew 1375: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
1376: return "window.open(".$nothing.",'".$menuname."');";
1.18 www 1377: }
1378:
1.56 www 1379: sub inlinemenu {
1.309.2.1 raeburn 1380: my ($context,$switcher) = @_;
1.210 albertel 1381: undef(@inlineremote);
1382: undef(%category_members);
1.309.2.1 raeburn 1383: my $output;
1.309.2.12 raeburn 1384: if (($context eq 'gcicustom') || ($context eq 'gcistudent') ||
1385: ($context eq 'gcinorole')) {
1.309.2.3 raeburn 1386: $output='<table><tr>'.
1387: '<td class="LC_mainmenu_col_fieldset">'.
1388: '<div class="LC_Box LC_400Box">'.
1389: '<h3 class="LC_hcell">'.&mt('Utilities').'</h3>'.
1.309.2.7 raeburn 1390: '<table>';
1391: if ($context eq 'gcicustom') {
1392: my $createtext = &mt('Create Concept Test');
1393: if ($switcher) {
1394: $createtext = &mt('Create New Test');
1395: }
1396: $output .= '<tr><td align="left"><a href="javascript:switchpage('."'createtest'".');"><img alt="choose role" src="/res/adm/pages/rcrs.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:switchpage('."'createtest'".');"><span class="LC_menubuttons_inline_text">'.$createtext.'</span></a></td></tr>';
1397: }
1.309.2.1 raeburn 1398: if ($switcher) {
1.309.2.4 raeburn 1399: $output .= '<tr><td align="left"><a href="javascript:courseswitcher('."'icon'".');"><img alt="choose role" src="/res/adm/pages/roles.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="2">'.$switcher.'</td></tr>';
1.309.2.1 raeburn 1400: }
1.309.2.8 raeburn 1401: $output .= '<tr><td align="left"><a href="javascript:go('."'/adm/communicate'".');"><img alt="communication" src="/res/adm/pages/com.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/communicate'".');"><span class="LC_menubuttons_inline_text">'.&mt('Send/Display Messages').'</span></a></td></tr>'.
1402: '<tr><td align="left"><a href="javascript:go('."'/adm/preferences'".');"><img alt="user preferences" src="/res/adm/pages/pref.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/preferences'".');"><span class="LC_menubuttons_inline_text">'.&mt('Set my user preferences').'</span></a></td></tr>';
1403: if ($env{'request.course.id'}) {
1.309.2.7 raeburn 1404: if (($context eq 'gcicustom') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
1405: $output.= '</td></tr></table></div></td>'.
1406: '<td class="LC_mainmenu_col_fieldset">'.
1407: '<div class="LC_Box LC_400Box">'.
1408: '<h3 class="LC_hcell">'.&mt('Test Management').'</h3>'.
1409: '<table><tr><td align="left"><a href="javascript:gonav('."'/adm/navmaps'".');"><img alt="course contents" src="/res/adm/pages/nav.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:gonav('."'/adm/navmaps'".');"><span class="LC_menubuttons_inline_text">Concept Test Contents</span></a></td></tr>'."\n".
1410: '<tr><td align="left"><a href="javascript:go('."'/adm/coursedocs'".');"><img alt="assemble test" src="/res/adm/pages/docs.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/coursedocs'".');"><span class="LC_menubuttons_inline_text">Assemble Concept Test</span></a></td></tr>'."\n".
1411: '<tr><td align="left"><a href="javascript:go('."'/adm/createuser'".');"><img alt="user privs" src="/res/adm/pages/cprv.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/createuser'".');"><span class="LC_menubuttons_inline_text">'.&mt('Manage Enrollment').'</span></a></td></tr>'."\n".
1.309.2.9 raeburn 1412: '<tr><td align="left"><a href="javascript:go('."'/adm/whatsnew'".');"><img alt="what is new" src="/res/adm/pages/new.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/whatsnew'".');"><span class="LC_menubuttons_inline_text">'.&mt("What's New?").'</span></a></td></tr>'.
1.309.2.13! raeburn 1413: '<tr><td align="left"><a href="javascript:go('."'/adm/printout'".');"><img alt="print concept test" src="/res/adm/pages/prnt.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/printout'".');"><span class="LC_menubuttons_inline_text">'.&mt("Prepare Printable Concept Test").'</span></a></td></tr>'.
1.309.2.9 raeburn 1414: '<tr><td align="left"><a href="javascript:go('."'/adm/statistics'".');"><img alt="Test Statistics" src="/res/adm/pages/chrt.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/statistics'".');"><span class="LC_menubuttons_inline_text">'.&mt("Concept Test Statistics").'</span></a></td></tr></table></div></td>';
1.309.2.7 raeburn 1415: } else {
1416: my $navtext = &mt('Table of Contents');
1417: if ($env{'request.role.domain'} eq 'gcitest') {
1418: $navtext = &mt('Display Test Contents');
1419: }
1420: $output .= '<tr><td align="left"><a href="javascript:gonav('."'/adm/navmaps'".');"><img alt="course contents" src="/res/adm/pages/nav.png" align="left" class="LC_icon" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:gonav('."'/adm/navmaps'".');"><span class="LC_menubuttons_inline_text">'.$navtext.'</span></a></td></tr></table></div></td>';
1421: }
1.309.2.11 raeburn 1422: } else {
1423: $output.='</td></tr></table></div></td>';
1.309.2.1 raeburn 1424: }
1.309.2.12 raeburn 1425: if ($context eq 'gcinorole') {
1426: my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle');
1427: if ($queued) {
1428: $output .= '<td class="LC_mainmenu_col_fieldset">'.
1429: '<div class="LC_Box LC_400Box">'.
1430: '<h3 class="LC_hcell">'.&mt('Pending Enrollment Requests').'</h3>'.
1431: $queued.
1432: '</td></tr></table></div></td>';
1433: }
1434: }
1.309.2.3 raeburn 1435: $output.='</tr></table>';
1.309.2.2 raeburn 1436: } else {
1.309.2.1 raeburn 1437: # calling rawconfig with "1" will evaluate mydesk.tab,
1438: # even if there is no active remote control
1439: &rawconfig(1);
1.309.2.2 raeburn 1440: $output='<table><tr>';
1.309.2.1 raeburn 1441: for (my $col=1; $col<=2; $col++) {
1442: $output.='<td class="LC_mainmenu_col_fieldset">';
1443: for (my $row=1; $row<=8; $row++) {
1444: foreach my $cat (keys(%category_members)) {
1445: if ($category_positions{$cat} ne "$col,$row") { next; }
1446: $output.='<div class="LC_Box LC_400Box">';
1447: $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
1448: $output.='<table>';
1449: my %active=();
1450: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
1451: if ($inlineremote[$menu_item]) {
1452: $active{$menu_item}=1;
1453: }
1454: }
1455: foreach my $item (sort(keys(%active))) {
1456: $output.=$inlineremote[$item];
1457: }
1458: $output.='</table>';
1459: $output.='</div>';
1.309.2.2 raeburn 1460: }
1.240 riegler 1461: }
1.309.2.1 raeburn 1462: $output.="</td>";
1463: }
1464: $output.="</tr></table>";
1.240 riegler 1465: }
1466: return $output;
1467: }
1468:
1.2 www 1469: sub rawconfig {
1.274 www 1470: #
1471: # This evaluates mydesk.tab
1472: # Need to add more positions and more privileges to deal with all
1473: # menu items.
1474: #
1.34 www 1475: my $textualoverride=shift;
1476: my $output='';
1.269 droeschl 1477: unless ($env{'environment.remote'} eq 'off') {
1.35 www 1478: $output.=
1479: "window.status='Opening Remote Control';var swmenu=".&openmenu().
1480: "\nwindow.status='Configuring Remote Control ';";
1.34 www 1481: } else {
1482: unless ($textualoverride) { return ''; }
1483: }
1.152 albertel 1484: my $uname=$env{'user.name'};
1485: my $udom=$env{'user.domain'};
1486: my $adv=$env{'user.adv'};
1.266 raeburn 1487: my $show_course=&Apache::loncommon::show_course();
1.152 albertel 1488: my $author=$env{'user.author'};
1.5 www 1489: my $crs='';
1.295 raeburn 1490: my $crstype='';
1.152 albertel 1491: if ($env{'request.course.id'}) {
1492: $crs='/'.$env{'request.course.id'};
1493: if ($env{'request.course.sec'}) {
1494: $crs.='_'.$env{'request.course.sec'};
1.7 www 1495: }
1.8 www 1496: $crs=~s/\_/\//g;
1.295 raeburn 1497: $crstype = &Apache::loncommon::course_type();
1.5 www 1498: }
1.152 albertel 1499: my $pub=($env{'request.state'} eq 'published');
1500: my $con=($env{'request.state'} eq 'construct');
1501: my $rol=$env{'request.role'};
1502: my $requested_domain = $env{'request.role.domain'};
1.184 raeburn 1503: foreach my $line (@desklines) {
1.209 www 1504: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3 www 1505: $prt=~s/\$uname/$uname/g;
1506: $prt=~s/\$udom/$udom/g;
1.295 raeburn 1507: if ($prt =~ /\$crs/) {
1508: next unless ($env{'request.course.id'});
1509: next if ($crstype eq 'Community');
1510: $prt=~s/\$crs/$crs/g;
1511: } elsif ($prt =~ /\$cmty/) {
1512: next unless ($env{'request.course.id'});
1513: next if ($crstype ne 'Community');
1514: $prt=~s/\$cmty/$crs/g;
1515: }
1.25 matthew 1516: $prt=~s/\$requested_domain/$requested_domain/g;
1.211 www 1517: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3 www 1518: if ($pro eq 'clear') {
1.4 www 1519: $output.=&clear($row,$col);
1.3 www 1520: } elsif ($pro eq 'any') {
1.2 www 1521: $output.=&secondlevel(
1.209 www 1522: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1523: } elsif ($pro eq 'smp') {
1524: unless ($adv) {
1525: $output.=&secondlevel(
1.209 www 1526: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1527: }
1528: } elsif ($pro eq 'adv') {
1529: if ($adv) {
1530: $output.=&secondlevel(
1.209 www 1531: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1532: }
1.231 albertel 1533: } elsif ($pro eq 'shc') {
1534: if ($show_course) {
1535: $output.=&secondlevel(
1536: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1537: }
1538: } elsif ($pro eq 'nsc') {
1539: if (!$show_course) {
1540: $output.=&secondlevel(
1541: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1542: }
1.81 matthew 1543: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295 raeburn 1544: my $priv = $1;
1545: if ($priv =~ /^mdc(Course|Community)/) {
1546: if ($crstype eq $1) {
1547: $priv = 'mdc';
1548: } else {
1549: next;
1550: }
1551: }
1552: if (&Apache::lonnet::allowed($priv,$prt)) {
1.209 www 1553: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4 www 1554: }
1.295 raeburn 1555: } elsif ($pro eq 'course') {
1556: if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209 www 1557: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81 matthew 1558: }
1.295 raeburn 1559: } elsif ($pro eq 'community') {
1560: if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
1561: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1562: }
1.124 matthew 1563: } elsif ($pro =~ /^courseenv_(.*)$/) {
1564: my $key = $1;
1.307 raeburn 1565: if ($crstype ne 'Community') {
1566: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1567: if ($key eq 'canuse_pdfforms') {
1568: if ($env{'request.course.id'} && $coursepref eq '') {
1569: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1570: $coursepref = $domdefs{'canuse_pdfforms'};
1571: }
1572: }
1573: if ($coursepref) {
1574: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1575: }
1.295 raeburn 1576: }
1577: } elsif ($pro =~ /^communityenv_(.*)$/) {
1578: my $key = $1;
1.307 raeburn 1579: if ($crstype eq 'Community') {
1580: my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
1581: if ($key eq 'canuse_pdfforms') {
1582: if ($env{'request.course.id'} && $coursepref eq '') {
1583: my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
1584: $coursepref = $domdefs{'canuse_pdfforms'};
1585: }
1586: }
1587: if ($coursepref) {
1588: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1589: }
1.124 matthew 1590: }
1.81 matthew 1591: } elsif ($pro =~ /^course_(.*)$/) {
1592: # Check for permissions inside of a course
1.295 raeburn 1593: if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
1.152 albertel 1594: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1595: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81 matthew 1596: )) {
1.209 www 1597: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26 www 1598: }
1.295 raeburn 1599: } elsif ($pro =~ /^community_(.*)$/) {
1600: # Check for permissions inside of a community
1601: if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
1602: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1603: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1604: )) {
1605: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1606: }
1.4 www 1607: } elsif ($pro eq 'author') {
1608: if ($author) {
1.152 albertel 1609: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234 raeburn 1610: (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
1.152 albertel 1611: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19 matthew 1612: # Check that we are on the correct machine
1.29 matthew 1613: my $cadom=$requested_domain;
1.152 albertel 1614: my $caname=$env{'user.name'};
1.234 raeburn 1615: if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29 matthew 1616: ($cadom,$caname)=
1.206 albertel 1617: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29 matthew 1618: }
1619: $act =~ s/\$caname/$caname/g;
1.19 matthew 1620: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 1621: my $allowed=0;
1622: my @ids=&Apache::lonnet::current_machine_ids();
1623: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1624: if ($allowed) {
1.209 www 1625: $output.=&switch($caname,$cadom,
1626: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19 matthew 1627: }
1.6 www 1628: }
1.2 www 1629: }
1.248 raeburn 1630: } elsif ($pro eq 'tools') {
1631: my @tools = ('aboutme','blog','portfolio');
1632: if (grep(/^\Q$prt\E$/,@tools)) {
1.249 raeburn 1633: if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251 raeburn 1634: $env{'user.domain'},
1635: $prt,undef,'tools')) {
1636: $output.=&clear($row,$col);
1637: next;
1638: }
1.278 raeburn 1639: } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
1640: if (($prt eq 'reqcrsnsc') && ($show_course)) {
1641: next;
1642: }
1643: if (($prt eq 'reqcrsshc') && (!$show_course)) {
1644: next;
1645: }
1.279 raeburn 1646: my $showreqcrs = &check_for_rcrs();
1.251 raeburn 1647: if (!$showreqcrs) {
1.248 raeburn 1648: $output.=&clear($row,$col);
1649: next;
1650: }
1651: }
1652: $prt='any';
1653: $output.=&secondlevel(
1654: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2 www 1655: }
1.13 harris41 1656: }
1.269 droeschl 1657: unless ($env{'environment.remote'} eq 'off') {
1.35 www 1658: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123 www 1659: if (&Apache::lonmsg::newmail()) {
1660: $output.='swmenu.setstatus("you have","messages");';
1661: }
1.34 www 1662: }
1.123 www 1663:
1.2 www 1664: return $output;
1665: }
1666:
1.279 raeburn 1667: sub check_for_rcrs {
1668: my $showreqcrs = 0;
1.280 raeburn 1669: my @reqtypes = ('official','unofficial','community');
1670: foreach my $type (@reqtypes) {
1.279 raeburn 1671: if (&Apache::lonnet::usertools_access($env{'user.name'},
1672: $env{'user.domain'},
1673: $type,undef,'requestcourses')) {
1674: $showreqcrs = 1;
1675: last;
1676: }
1677: }
1.280 raeburn 1678: if (!$showreqcrs) {
1679: foreach my $type (@reqtypes) {
1680: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
1681: $showreqcrs = 1;
1682: last;
1683: }
1684: }
1685: }
1.279 raeburn 1686: return $showreqcrs;
1687: }
1688:
1.2 www 1689: # ======================================================================= Close
1.1 www 1690:
1691: sub close {
1.269 droeschl 1692: if ($env{'environment.remote'} eq 'off') { return ''; }
1.230 albertel 1693: my $menuname = &get_menu_name();
1.1 www 1694: return(<<ENDCLOSE);
1.129 albertel 1695: <script type="text/javascript">
1.277 bisitz 1696: // <![CDATA[
1.35 www 1697: window.status='Accessing Remote Control';
1.30 www 1698: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 1699: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 1700: window.status='Disabling Remote Control';
1701: menu.active=0;
1.31 www 1702: menu.autologout=0;
1.35 www 1703: window.status='Closing Remote Control';
1.1 www 1704: menu.close();
1.35 www 1705: window.status='Done.';
1.277 bisitz 1706: // ]]>
1.1 www 1707: </script>
1708: ENDCLOSE
1709: }
1710:
1711: # ====================================================================== Footer
1712:
1713: sub footer {
1714:
1.33 www 1715: }
1716:
1.122 albertel 1717: sub nav_control_js {
1.152 albertel 1718: my $nav=($env{'environment.remotenavmap'} eq 'on');
1.122 albertel 1719: return (<<NAVCONTROL);
1720: var w_loncapanav_flag="$nav";
1721:
1722:
1723: function gonav(url) {
1724: if (w_loncapanav_flag != 1) {
1725: gopost(url,'');
1726: } else {
1727: navwindow=window.open(url,
1728: "loncapanav","height=600,width=400,scrollbars=1");
1729: }
1730: }
1731: NAVCONTROL
1732: }
1733:
1.306 raeburn 1734: sub dc_popup_js {
1735: my %lt = &Apache::lonlocal::texthash(
1736: more => '(More ...)',
1737: less => '(Less ...)',
1738: );
1739: return <<"END";
1740:
1741: function showCourseID() {
1742: document.getElementById('dccid').style.display='block';
1743: document.getElementById('dccid').style.textAlign='left';
1.307 raeburn 1744: document.getElementById('dccid').style.textFace='normal';
1.306 raeburn 1745: document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
1746: return;
1747: }
1748:
1749: function hideCourseID() {
1750: document.getElementById('dccid').style.display='none';
1751: document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
1752: return;
1753: }
1754:
1755: END
1756:
1757: }
1758:
1.42 www 1759: sub utilityfunctions {
1.309.2.1 raeburn 1760: my ($caller,$custommenu) = @_;
1.269 droeschl 1761: unless ($env{'environment.remote'} eq 'off' ||
1762: $caller eq '/adm/menu') {
1763: return ''; }
1.309.2.1 raeburn 1764:
1765: my $gcimenujs;
1766: if ($custommenu) {
1.309.2.10 raeburn 1767: my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc');
1.309.2.1 raeburn 1768: my $managetesturl = '/adm/menu';
1769: my $createtesturl = '/adm/requestcourse';
1770: if (($env{'request.course.id'}) &&
1771: ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) {
1772: my @items = keys(%concepttests);
1773: if (@items== 1) {
1774: my $newrole = $items[0];
1775: $newrole =~ s{_}{/};
1776: $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
1777: } else {
1778: $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
1779: }
1780: }
1781: if ($env{'request.course.id'}) {
1782: $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
1783: }
1784: $gcimenujs = <<"ENDCUSTOM";
1785:
1786: function switchpage(caller) {
1787: if (caller == 'review') {
1788: document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1';
1789: }
1790: if (caller == 'submit') {
1791: document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1';
1792: }
1793: if (caller == 'createtest') {
1794: document.location.href = '$createtesturl';
1795: }
1796: if (caller == 'managetest') {
1797: document.location.href = '$managetesturl';
1798: }
1799: return;
1800: }
1801:
1802: ENDCUSTOM
1803: }
1804:
1.152 albertel 1805: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.293 raeburn 1806: if ($currenturl =~ m{^/adm/wrapper/ext/}) {
1807: if ($env{'request.external.querystring'}) {
1808: $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
1809: }
1810: }
1.183 www 1811: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125 albertel 1812:
1.152 albertel 1813: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.122 albertel 1814: my $nav_control=&nav_control_js();
1.175 albertel 1815:
1.306 raeburn 1816: my $dc_popup_cid;
1817: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
1818: $env{'course.'.$env{'request.course.id'}.
1819: '.domain'}.'/'})) {
1820: $dc_popup_cid = &dc_popup_js();
1821: }
1822:
1.175 albertel 1823: my $start_page_annotate =
1824: &Apache::loncommon::start_page('Annotator',undef,
1825: {'only_body' => 1,
1826: 'js_ready' => 1,
1827: 'bgcolor' => '#BBBBBB',
1828: 'add_entries' => {
1829: 'onload' => 'javascript:document.goannotate.submit();'}});
1830:
1.205 albertel 1831: my $end_page_annotate =
1832: &Apache::loncommon::end_page({'js_ready' => 1});
1833:
1.175 albertel 1834: my $start_page_bookmark =
1835: &Apache::loncommon::start_page('Bookmarks',undef,
1836: {'only_body' => 1,
1837: 'js_ready' => 1,
1838: 'bgcolor' => '#BBBBBB',});
1839:
1.205 albertel 1840: my $end_page_bookmark =
1.175 albertel 1841: &Apache::loncommon::end_page({'js_ready' => 1});
1842:
1.42 www 1843: return (<<ENDUTILITY)
1844:
1845: var currentURL="$currenturl";
1846: var reloadURL="$currenturl";
1847: var currentSymb="$currentsymb";
1848:
1.114 albertel 1849: $nav_control
1.306 raeburn 1850: $dc_popup_cid
1.114 albertel 1851:
1.309.2.1 raeburn 1852: $gcimenujs
1853:
1.42 www 1854: function go(url) {
1855: if (url!='' && url!= null) {
1856: currentURL = null;
1857: currentSymb= null;
1858: window.location.href=url;
1859: }
1860: }
1861:
1.297 raeburn 1862: function gotop(url) {
1863: if (url!='' && url!= null) {
1864: top.location.href = url;
1865: }
1866: }
1867:
1.42 www 1868: function gopost(url,postdata) {
1869: if (url!='') {
1870: this.document.server.action=url;
1871: this.document.server.postdata.value=postdata;
1872: this.document.server.command.value='';
1873: this.document.server.url.value='';
1874: this.document.server.symb.value='';
1875: this.document.server.submit();
1876: }
1877: }
1878:
1879: function gocmd(url,cmd) {
1880: if (url!='') {
1881: this.document.server.action=url;
1882: this.document.server.postdata.value='';
1883: this.document.server.command.value=cmd;
1884: this.document.server.url.value=currentURL;
1885: this.document.server.symb.value=currentSymb;
1886: this.document.server.submit();
1887: }
1.57 www 1888: }
1889:
1.121 raeburn 1890: function gocstr(url,filename) {
1891: if (url == '/adm/cfile?action=delete') {
1892: this.document.cstrdelete.filename.value = filename
1893: this.document.cstrdelete.submit();
1894: return;
1895: }
1.137 raeburn 1896: if (url == '/adm/printout') {
1897: this.document.cstrprint.postdata.value = filename
1898: this.document.cstrprint.curseed.value = 0;
1899: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1900: if (this.document.lonhomework) {
1901: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1902: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1903: }
1904: if (this.document.lonhomework.problemtype) {
1.164 albertel 1905: if (this.document.lonhomework.problemtype.value) {
1906: this.document.cstrprint.problemtype.value =
1907: this.document.lonhomework.problemtype.value;
1908: } else if (this.document.lonhomework.problemtype.options) {
1909: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1910: if (this.document.lonhomework.problemtype.options[i].selected) {
1911: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1912: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1913: }
1914: }
1915: }
1916: }
1917: }
1918: }
1.137 raeburn 1919: this.document.cstrprint.submit();
1920: return;
1921: }
1.121 raeburn 1922: if (url !='') {
1923: this.document.constspace.filename.value = filename;
1924: this.document.constspace.action = url;
1925: this.document.constspace.submit();
1926: }
1927: }
1928:
1.131 raeburn 1929: function golist(url) {
1930: if (url!='' && url!= null) {
1931: currentURL = null;
1932: currentSymb= null;
1933: top.location.href=url;
1934: }
1935: }
1936:
1937:
1.121 raeburn 1938:
1.57 www 1939: function catalog_info() {
1.102 albertel 1940: 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 1941: }
1942:
1943: function chat_win() {
1.290 raeburn 1944: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1945: }
1.169 raeburn 1946:
1947: function group_chat(group) {
1948: var url = '/adm/groupchat?group='+group;
1949: var winName = 'LONchat_'+group;
1950: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1951: }
1.175 albertel 1952:
1953: function edit_bookmarks() {
1954: go('');
1955: w_BookmarkPal_flag=1;
1956: bookmarkpal=window.open("/adm/bookmarks",
1957: "BookmarkPal", "width=400,height=505,scrollbars=0");
1958: }
1959:
1960: function annotate() {
1961: w_Annotator_flag=1;
1962: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1963: annotator.document.write(
1964: '$start_page_annotate'
1965: +"<form name='goannotate' target='Annotator' method='post' "
1966: +"action='/adm/annotations'>"
1.217 albertel 1967: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181 albertel 1968: +"<\\/form>"
1.205 albertel 1969: +'$end_page_annotate');
1.175 albertel 1970: annotator.document.close();
1971: }
1972:
1973: function set_bookmark() {
1974: go('');
1975: clienttitle=document.title;
1976: clienthref=location.pathname;
1977: w_bmquery_flag=1;
1978: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1979: bmquery.document.write(
1980: '$start_page_bookmark'
1.260 bisitz 1981: +'<center><form method="post"'
1982: +' name="newlink" action="/adm/bookmarks" target="bmquery" '
1983: +'> <table width="340" height="150" '
1984: +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
1985: +'type="text" name="title" size="45" value="'+clienttitle+'" />'
1986: +'<br />Address:<br /><input type="text" name="address" size="45" '
1987: +'value="'+clienthref+'" /><br /><center><input type="submit" '
1988: +'value="Save" /> <input type="button" value="Close" '
1989: +'onclick="javascript:window.close();" /></center></td>'
1990: +'</tr></table></form></center>'
1.205 albertel 1991: +'$end_page_bookmark' );
1.175 albertel 1992: bmquery.document.close();
1993: }
1994:
1.42 www 1995: ENDUTILITY
1996: }
1997:
1998: sub serverform {
1999: return(<<ENDSERVERFORM);
1.181 albertel 2000: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 2001: <input type="hidden" name="postdata" value="none" />
2002: <input type="hidden" name="command" value="none" />
2003: <input type="hidden" name="url" value="none" />
2004: <input type="hidden" name="symb" value="none" />
2005: </form>
2006: ENDSERVERFORM
2007: }
1.113 albertel 2008:
1.121 raeburn 2009: sub constspaceform {
2010: return(<<ENDCONSTSPACEFORM);
1.181 albertel 2011: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121 raeburn 2012: <input type="hidden" name="filename" value="" />
2013: </form>
1.181 albertel 2014: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121 raeburn 2015: <input type="hidden" name="action" value="delete" />
2016: <input type="hidden" name="filename" value="" />
2017: </form>
1.181 albertel 2018: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137 raeburn 2019: <input type="hidden" name="postdata" value="" />
2020: <input type="hidden" name="curseed" value="" />
2021: <input type="hidden" name="problemtype" value="" />
2022: </form>
2023:
1.121 raeburn 2024: ENDCONSTSPACEFORM
2025: }
2026:
2027:
1.113 albertel 2028: sub get_nav_status {
2029: my $navstatus="swmenu.w_loncapanav_flag=";
1.152 albertel 2030: if ($env{'environment.remotenavmap'} eq 'on') {
1.113 albertel 2031: $navstatus.="1";
2032: } else {
2033: $navstatus.="-1";
2034: }
2035: return $navstatus;
2036: }
2037:
1.220 raeburn 2038: sub hidden_button_check {
2039: my $hidden;
2040: if ($env{'request.course.id'} eq '') {
2041: return;
2042: }
2043: if ($env{'request.role.adv'}) {
1.309.2.6 raeburn 2044: unless (&Apache::loncommon::needs_gci_custom()) {
2045: return;
2046: }
1.220 raeburn 2047: }
1.232 raeburn 2048: my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
2049: return $buttonshide;
1.220 raeburn 2050: }
1.184 raeburn 2051:
1.235 raeburn 2052: sub roles_selector {
2053: my ($cdom,$cnum) = @_;
1.298 raeburn 2054: my $crstype = &Apache::loncommon::course_type();
1.235 raeburn 2055: my $now = time;
1.262 raeburn 2056: my (%courseroles,%seccount);
1.235 raeburn 2057: my $is_cc;
2058: my $role_selector;
1.298 raeburn 2059: my $ccrole;
2060: if ($crstype eq 'Community') {
2061: $ccrole = 'co';
2062: } else {
2063: $ccrole = 'cc';
2064: }
2065: if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
2066: my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235 raeburn 2067:
2068: if ((($start) && ($start<0)) ||
2069: (($end) && ($end<$now)) ||
2070: (($start) && ($now<$start))) {
2071: $is_cc = 0;
2072: } else {
2073: $is_cc = 1;
2074: }
2075: }
2076: if ($is_cc) {
1.264 raeburn 2077: &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1.235 raeburn 2078: } else {
1.262 raeburn 2079: my %gotnosection;
1.235 raeburn 2080: foreach my $item (keys(%env)) {
1.239 raeburn 2081: if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235 raeburn 2082: my $role = $1;
2083: my $sec = $2;
2084: next if ($role eq 'gr');
2085: my ($start,$end) = split(/\./,$env{$item});
2086: next if (($start && $start > $now) || ($end && $end < $now));
2087: if ($sec eq '') {
1.239 raeburn 2088: if (!$gotnosection{$role}) {
2089: $seccount{$role} ++;
2090: $gotnosection{$role} = 1;
2091: }
1.235 raeburn 2092: }
2093: if (ref($courseroles{$role}) eq 'ARRAY') {
1.239 raeburn 2094: if ($sec ne '') {
1.264 raeburn 2095: if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239 raeburn 2096: push(@{$courseroles{$role}},$sec);
2097: $seccount{$role} ++;
2098: }
2099: }
2100: } else {
2101: @{$courseroles{$role}} = ();
2102: if ($sec ne '') {
2103: $seccount{$role} ++;
1.235 raeburn 2104: push(@{$courseroles{$role}},$sec);
2105: }
2106: }
2107: }
2108: }
2109: }
1.286 raeburn 2110: my $switchtext;
2111: if ($crstype eq 'Community') {
2112: $switchtext = &mt('Switch community role to...')
2113: } else {
2114: $switchtext = &mt('Switch course role to...')
2115: }
1.298 raeburn 2116: my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235 raeburn 2117: if (keys(%courseroles) > 1) {
1.239 raeburn 2118: $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1.235 raeburn 2119: $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
2120: <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286 raeburn 2121: $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235 raeburn 2122: foreach my $role (@roles_order) {
2123: if (defined($courseroles{$role})) {
1.298 raeburn 2124: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>';
1.235 raeburn 2125: }
2126: }
2127: foreach my $role (sort(keys(%courseroles))) {
2128: if ($role =~ /^cr/) {
2129: $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>';
2130: }
2131: }
2132: $role_selector .= '</select>'."\n".
2133: '<input type="hidden" name="destinationurl" value="'.
1.282 amueller 2134: &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n".
1.235 raeburn 2135: '<input type="hidden" name="gotorole" value="1" />'."\n".
2136: '<input type="hidden" name="selectrole" value="" />'."\n".
2137: '<input type="hidden" name="switch" value="1" />'."\n".
2138: '</form>';
2139: }
2140: return $role_selector;
2141: }
2142:
1.262 raeburn 2143: sub get_all_courseroles {
2144: my ($cdom,$cnum,$courseroles,$seccount) = @_;
2145: unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
2146: return;
2147: }
2148: my ($result,$cached) =
2149: &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
2150: if (defined($cached)) {
2151: if (ref($result) eq 'HASH') {
2152: if ((ref($result->{'roles'}) eq 'HASH') &&
2153: (ref($result->{'seccount'}) eq 'HASH')) {
2154: %{$courseroles} = %{$result->{'roles'}};
2155: %{$seccount} = %{$result->{'seccount'}};
2156: return;
2157: }
2158: }
2159: }
2160: my %gotnosection;
2161: my %adv_roles =
2162: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
2163: foreach my $role (keys(%adv_roles)) {
2164: my ($urole,$usec) = split(/:/,$role);
2165: if (!$gotnosection{$urole}) {
2166: $seccount->{$urole} ++;
2167: $gotnosection{$urole} = 1;
2168: }
2169: if (ref($courseroles->{$urole}) eq 'ARRAY') {
2170: if ($usec ne '') {
2171: if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
2172: push(@{$courseroles->{$urole}},$usec);
2173: $seccount->{$urole} ++;
2174: }
2175: }
2176: } else {
2177: @{$courseroles->{$urole}} = ();
2178: if ($usec ne '') {
2179: $seccount->{$urole} ++;
2180: push(@{$courseroles->{$urole}},$usec);
2181: }
2182: }
2183: }
2184: my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
2185: @{$courseroles->{'st'}} = ();
2186: if (keys(%sections_count) > 0) {
2187: push(@{$courseroles->{'st'}},keys(%sections_count));
2188: $seccount->{'st'} = scalar(keys(%sections_count));
2189: }
2190: my $rolehash = {
2191: 'roles' => $courseroles,
2192: 'seccount' => $seccount,
2193: };
2194: &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
2195: return;
2196: }
2197:
1.235 raeburn 2198: sub jump_to_role {
1.239 raeburn 2199: my ($cdom,$cnum,$seccount,$courseroles) = @_;
2200: my %lt = &Apache::lonlocal::texthash(
2201: this => 'This role has section(s) associated with it.',
2202: ente => 'Enter a specific section.',
2203: orlb => 'Enter a specific section, or leave blank for no section.',
2204: avai => 'Available sections are:',
2205: youe => 'You entered an invalid section choice:',
2206: plst => 'Please try again',
2207: );
2208: my $js;
2209: if (ref($courseroles) eq 'HASH') {
2210: $js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
2211: ' var numsec = new Array();'."\n".
2212: ' var rolesections = new Array();'."\n".
2213: ' var rolenames = new Array();'."\n".
2214: ' var roleseclist = new Array();'."\n";
2215: my @items = keys(%{$courseroles});
2216: for (my $i=0; $i<@items; $i++) {
2217: $js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n";
2218: my ($secs,$secstr);
2219: if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
2220: my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
2221: $secs = join('","',@sections);
2222: $secstr = join(', ',@sections);
2223: }
2224: $js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
2225: ' roleseclist['.$i.'] = "'.$secstr.'";'."\n".
2226: ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
2227: }
2228: }
1.273 droeschl 2229: return <<"END";
1.235 raeburn 2230: <script type="text/javascript">
1.273 droeschl 2231: //<![CDATA[
1.235 raeburn 2232: function adhocRole(roleitem) {
1.239 raeburn 2233: $js
1.235 raeburn 2234: var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
2235: if (newrole == '') {
2236: return;
2237: }
1.239 raeburn 2238: var fullrole = newrole+'./$cdom/$cnum';
2239: var selidx = '';
2240: for (var i=0; i<rolenames.length; i++) {
2241: if (rolenames[i] == newrole) {
2242: selidx = i;
2243: }
2244: }
2245: var secok = 1;
2246: var secchoice = '';
2247: if (selidx >= 0) {
2248: if (numsec[selidx] > 1) {
2249: secok = 0;
2250: var numrolesec = rolesections[selidx].length;
2251: var msgidx = numsec[selidx] - numrolesec;
2252: secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
2253: if (secchoice == '') {
2254: if (msgidx > 0) {
2255: secok = 1;
2256: }
2257: } else {
2258: for (var j=0; j<rolesections[selidx].length; j++) {
2259: if (rolesections[selidx][j] == secchoice) {
2260: secok = 1;
2261: }
2262: }
2263: }
2264: } else {
2265: if (rolesections[selidx].length == 1) {
2266: secchoice = rolesections[selidx][0];
2267: }
2268: }
2269: }
2270: if (secok == 1) {
2271: if (secchoice != '') {
2272: fullrole += '/'+secchoice;
2273: }
2274: } else {
2275: document.rolechooser.elements[roleitem].selectedIndex = 0;
2276: if (secchoice != null) {
2277: alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
2278: }
2279: return;
2280: }
2281: if (fullrole == "$env{'request.role'}") {
1.235 raeburn 2282: return;
2283: }
2284: itemid = retrieveIndex('gotorole');
2285: if (itemid != -1) {
1.239 raeburn 2286: document.rolechooser.elements[itemid].name = fullrole;
1.235 raeburn 2287: }
1.239 raeburn 2288: document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235 raeburn 2289: document.rolechooser.selectrole.value = '1';
2290: document.rolechooser.submit();
2291: return;
2292: }
2293:
2294: function retrieveIndex(item) {
2295: for (var i=0;i<document.rolechooser.elements.length;i++) {
2296: if (document.rolechooser.elements[i].name == item) {
2297: return i;
2298: }
2299: }
2300: return -1;
2301: }
1.273 droeschl 2302: // ]]>
1.235 raeburn 2303: </script>
2304: END
2305: }
2306:
2307:
1.2 www 2308: # ================================================================ Main Program
2309:
1.16 harris41 2310: BEGIN {
1.166 albertel 2311: if (! defined($readdesk)) {
1.283 droeschl 2312: {
2313: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
2314: if ( CORE::open( my $config,"<$tabfile") ) {
2315: while (my $configline=<$config>) {
2316: $configline=(split(/\#/,$configline))[0];
2317: $configline=~s/^\s+//;
2318: chomp($configline);
1.209 www 2319: if ($configline=~/^cat\:/) {
1.283 droeschl 2320: my @entries=split(/\:/,$configline);
2321: $category_positions{$entries[2]}=$entries[1];
2322: $category_names{$entries[2]}=$entries[3];
2323: } elsif ($configline=~/^prim\:/) {
2324: my @entries = (split(/\:/, $configline))[1..5];
2325: push @primary_menu, \@entries;
2326: } elsif ($configline=~/^scnd\:/) {
2327: my @entries = (split(/\:/, $configline))[1..5];
2328: push @secondary_menu, \@entries;
2329: } elsif ($configline) {
2330: push(@desklines,$configline);
2331: }
2332: }
2333: CORE::close($config);
2334: }
2335: }
2336: $readdesk='done';
1.2 www 2337: }
2338: }
1.30 www 2339:
1.1 www 2340: 1;
2341: __END__
2342:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>