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