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