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