Annotation of loncom/interface/lonrequestcourse.pm, revision 1.30
1.1 raeburn 1: # The LearningOnline Network
2: # Request a course
3: #
1.30 ! raeburn 4: # $Id: lonrequestcourse.pm,v 1.29 2009/09/06 19:09:54 raeburn Exp $
1.1 raeburn 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: #
28: ###
29:
30: =head1 NAME
31:
32: Apache::lonrequestcourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows users to request creation of new courses.
37:
38: This is part of the LearningOnline Network with CAPA project
39: described at http://www.lon-capa.org.
40:
41: =head1 SUBROUTINES
42:
43: =over
44:
45: =item handler()
46:
1.27 raeburn 47: =item get_breadcrumbs()
48:
1.12 raeburn 49: =item header()
50:
51: =item form_elements()
52:
53: =item onload_action()
54:
55: =item check_can_request()
56:
57: =item course_types()
58:
59: =item print_main_menu()
60:
61: =item request_administration()
62:
1.27 raeburn 63: =item close_popup_form()
64:
65: =item get_instcode()
66:
1.12 raeburn 67: =item print_request_form()
68:
69: =item print_enrollment_menu()
70:
1.27 raeburn 71: =item show_invalid_crosslists()
72:
1.12 raeburn 73: =item inst_section_selector()
74:
75: =item date_setting_table()
76:
77: =item print_personnel_menu()
78:
79: =item print_request_status()
80:
81: =item print_request_logs()
82:
83: =item print_review()
84:
85: =item dates_from_form()
86:
87: =item courseinfo_form()
88:
89: =item clone_form()
90:
91: =item clone_text()
92:
93: =item coursecode_form()
94:
95: =item get_course_dom()
96:
97: =item display_navbuttons()
98:
99: =item print_request_outcome()
100:
101: =item get_processtype()
102:
103: =item check_autolimit()
104:
105: =item retrieve_settings()
106:
107: =item get_request_settings()
108:
1.27 raeburn 109: =item extract_instcode()
110:
111: =item generate_date_items()
112:
1.1 raeburn 113: =back
114:
115: =cut
116:
117: package Apache::lonrequestcourse;
118:
119: use strict;
120: use Apache::Constants qw(:common :http);
121: use Apache::lonnet;
122: use Apache::loncommon;
123: use Apache::lonlocal;
1.8 raeburn 124: use Apache::loncoursequeueadmin;
1.30 ! raeburn 125: use Apache::lonuserutils;
1.4 raeburn 126: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 127:
128: sub handler {
129: my ($r) = @_;
1.20 raeburn 130: &Apache::loncommon::content_type($r,'text/html');
131: $r->send_http_header;
1.1 raeburn 132: if ($r->header_only) {
133: return OK;
134: }
135:
1.27 raeburn 136: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
137: ['action','showdom','cnum','state']);
1.2 raeburn 138: &Apache::lonhtmlcommon::clear_breadcrumbs();
139: my $dom = &get_course_dom();
1.1 raeburn 140: my $action = $env{'form.action'};
141: my $state = $env{'form.state'};
1.27 raeburn 142: my (%states,%stored);
143: my ($jscript,$uname,$udom,$result,$warning);
144:
145: $states{'display'} = ['details'];
146: $states{'view'} = ['pick_request','details','cancel','removal'];
147: $states{'log'} = ['filter','display'];
148: $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
149:
150: if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
151: unless ($env{'form.state'} eq 'crstype') {
152: unshift(@{$states{'new'}},'codepick');
153: }
154: }
155:
156: foreach my $key (keys(%states)) {
157: if (ref($states{$key}) eq 'ARRAY') {
158: unshift (@{$states{$key}},'crstype');
159: }
160: }
161:
162: my @invalidcrosslist;
163: my %trail = (
164: crstype => 'Course Request Action',
165: codepick => 'Category',
166: courseinfo => 'Description',
167: enrollment => 'Access Dates',
168: personnel => 'Personnel',
169: review => 'Review',
170: process => 'Result',
171: pick_request => 'Display Summary',
172: details => 'Request Details',
173: cancel => 'Cancel Request',
174: removal => 'Outcome',
175: );
176:
177: if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
178: $trail{'enrollment'} = 'Enrollment';
179: }
180:
181: my ($page,$crumb,$newinstcode,$codechk,$checkedcode) =
182: &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
1.26 raeburn 183: if ($action eq 'display') {
184: if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
185: my $namespace = 'courserequestqueue';
186: if ($env{'form.cnum'} ne '') {
187: my $cnum = $env{'form.cnum'};
188: my $reqkey = $cnum.'_approval';
189: my $namespace = 'courserequestqueue';
190: my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
191: my %queued =
192: &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
193: if (ref($queued{$reqkey}) eq 'HASH') {
194: $uname = $queued{$reqkey}{'ownername'};
195: $udom = $queued{$reqkey}{'ownerdom'};
196: if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
197: $result = &retrieve_settings($dom,$cnum,$udom,$uname);
198: } else {
199: $warning = &mt('Invalid username or domain for course requestor');
200: }
201: } else {
202: $warning = &mt('No information was found for this course request.');
203: }
204: } else {
205: $warning = &mt('No course request ID provided.');
206: }
207: } else {
208: $warning = &mt('You do not have rights to view course request information.');
209: }
210: } elsif ((defined($state)) && (defined($action))) {
1.16 raeburn 211: if (($action eq 'view') && ($state eq 'details')) {
212: if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
213: my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'});
1.2 raeburn 214: }
1.27 raeburn 215: } elsif ($env{'form.crstype'} eq 'official') {
216: if (&Apache::lonnet::auto_run('',$dom)) {
217: if (($action eq 'new') && (($state eq 'enrollment') ||
218: ($state eq 'personnel'))) {
219: my $checkcrosslist = 0;
220: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
221: if ($env{'form.crosslist_'.$i}) {
222: $checkcrosslist ++;
223: }
224: }
225: if ($checkcrosslist) {
226: my %codechk;
227: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
228: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,
229: \%cat_titles,
230: \%cat_order,
231: \@code_order);
232: my $numtitles = scalar(@codetitles);
233: if ($numtitles) {
234: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
235: if ($env{'form.crosslist_'.$i}) {
236: my $codecheck;
237: my $crosslistcode = '';
238: foreach my $item (@code_order) {
239: $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
240: }
241: if ($crosslistcode ne '') {
242: $codechk{$i} =
243: &Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
244: }
245: unless ($codechk{$i} eq 'valid') {
246: $env{'form.crosslist_'.$i} = '';
247: push(@invalidcrosslist,$crosslistcode);
248: }
249: }
250: }
251: }
252: }
253: }
254: }
1.2 raeburn 255: }
1.16 raeburn 256: my %elements = &form_elements($dom);
1.2 raeburn 257: my $elementsref = {};
258: if (ref($elements{$action}) eq 'HASH') {
259: if (ref($elements{$action}{$state}) eq 'HASH') {
260: $elementsref = $elements{$action}{$state};
261: }
262: }
1.16 raeburn 263: if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
264: $env{'form.clonedom'} = $dom;
265: }
1.30 ! raeburn 266: if ($state eq 'crstype') {
! 267: $jscript = &mainmenu_javascript();
! 268: } else {
! 269: $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
! 270: }
1.2 raeburn 271: }
272:
273: if ($state eq 'personnel') {
274: $jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
275: }
276:
277: my $loaditems = &onload_action($action,$state);
278:
1.1 raeburn 279: my %can_request;
280: my $canreq = &check_can_request($dom,\%can_request);
281: if ($action eq 'new') {
282: if ($canreq) {
283: if ($state eq 'crstype') {
1.3 raeburn 284: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,
285: $crumb);
1.1 raeburn 286: } else {
1.27 raeburn 287: &request_administration($r,$action,$state,$page,\%states,$dom,
288: $jscript,$loaditems,$crumb,$newinstcode,
289: $codechk,$checkedcode,\@invalidcrosslist);
1.1 raeburn 290: }
291: } else {
1.3 raeburn 292: $r->print(&header('Course Requests').$crumb.
1.1 raeburn 293: '<div class="LC_warning">'.
294: &mt('You do not have privileges to request creation of courses.').
1.2 raeburn 295: '</div>'.&Apache::loncommon::end_page());
1.1 raeburn 296: }
297: } elsif ($action eq 'view') {
1.10 raeburn 298: if ($state eq 'crstype') {
1.30 ! raeburn 299: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb);
1.26 raeburn 300: } else {
301: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
302: $loaditems,$crumb);
303: }
304: } elsif ($action eq 'display') {
305: if ($warning ne '') {
306: my $args = { only_body => 1 };
307: $r->print(&header('Course Requests','','',$args).$crumb.
308: '<h3>'.&mt('Course Request Details').'</h3>'.
309: '<div class="LC_warning">'.$warning.'</div>'.
310: &close_popup_form());
1.11 raeburn 311: } else {
1.26 raeburn 312: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
1.27 raeburn 313: $loaditems,$crumb,'','','','',$uname,$udom);
1.10 raeburn 314: }
1.1 raeburn 315: } elsif ($action eq 'log') {
1.3 raeburn 316: &print_request_logs($jscript,$loaditems,$crumb);
1.1 raeburn 317: } else {
1.3 raeburn 318: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
1.1 raeburn 319: }
320: return OK;
321: }
322:
1.30 ! raeburn 323: sub mainmenu_javascript {
! 324: return <<"END";
! 325: function setType(courseForm) {
! 326: for (var i=0; i<courseForm.crstype.length; i++) {
! 327: if (courseForm.crstype.options[i].value == "$env{'form.crstype'}") {
! 328: courseForm.crstype.options[i].selected = true;
! 329: } else {
! 330: courseForm.crstype.options[i].selected = false;
! 331: }
! 332: }
! 333: }
! 334:
! 335: function setAction(courseForm) {
! 336: for (var i=0; i<courseForm.action.length; i++) {
! 337: if (courseForm.action.options[i].value == "$env{'form.action'}") {
! 338: courseForm.action.options[i].selected = true;
! 339: } else {
! 340: courseForm.action.options[i].selected = false;
! 341: }
! 342: }
! 343: }
! 344: END
! 345: }
! 346:
1.27 raeburn 347: sub get_breadcrumbs {
348: my ($dom,$action,$state,$states,$trail) = @_;
349: my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles);
350: my $page = 0;
351: if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {
352: if (defined($action)) {
353: my $done = 0;
354: my $i=0;
355: if (ref($states->{$action}) eq 'ARRAY') {
356: while ($i<@{$states->{$action}} && !$done) {
357: if ($states->{$action}[$i] eq $$state) {
358: $page = $i;
359: $done = 1;
360: }
361: $i++;
362: }
363: }
364: if ($env{'form.crstype'} eq 'official') {
365: if ($page > 1) {
366: if ($states->{$action}[$page-1] eq 'codepick') {
367: if ($env{'form.instcode'} eq '') {
368: ($newinstcode,$numtitles) = &get_instcode($dom);
369: if ($numtitles) {
370: if ($newinstcode eq '') {
371: $$state = 'codepick';
372: $page --;
373: } else {
374: $codechk =
375: &Apache::lonnet::auto_validate_instcode('',
376: $dom,$newinstcode);
377: if ($codechk ne 'valid') {
378: $$state = 'codepick';
379: $page --;
380: }
381: $checkedcode = 1;
382: }
383: }
384: }
385: }
386: }
387: }
388: for (my $i=0; $i<@{$states->{$action}}; $i++) {
389: if ($$state eq $states->{$action}[$i]) {
390: &Apache::lonhtmlcommon::add_breadcrumb(
391: {text=>"$trail->{$$state}"});
392: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
393: last;
394: } else {
395: if (($$state eq 'process') || ($$state eq 'removal')) {
396: &Apache::lonhtmlcommon::add_breadcrumb(
397: { href => '/adm/requestcourse',
398: text => "$trail->{$states->{$action}[$i]}",
399: }
400: );
401: } else {
402: &Apache::lonhtmlcommon::add_breadcrumb(
403: { href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')",
404: text => "$trail->{$states->{$action}[$i]}", }
405: );
406: }
407: }
408: }
409: } else {
410: &Apache::lonhtmlcommon::add_breadcrumb(
411: {text=>'Pick Action'});
412: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
413: }
414: } else {
415: &Apache::lonhtmlcommon::add_breadcrumb(
416: {text=>'Pick Action'});
417: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
418: }
419: return ($page,$crumb,$newinstcode,$codechk,$checkedcode);
420: }
421:
1.2 raeburn 422: sub header {
1.26 raeburn 423: my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_;
1.2 raeburn 424: if ($jscript) {
1.6 raeburn 425: $jscript = '<script type="text/javascript">'."\n".
426: '// <![CDATA['."\n".
427: $jscript."\n".'// ]]>'."\n".'</script>'."\n";
1.2 raeburn 428: }
429: if ($loaditems) {
1.26 raeburn 430: if (ref($args) eq 'HASH') {
431: my %loadhash = (
432: 'add_entries' => $loaditems,
433: );
434: my %arghash = (%loadhash,%{$args});
435: $args = \%arghash;
436: } else {
437: $args = {'add_entries' => $loaditems,};
438: }
1.3 raeburn 439: }
1.26 raeburn 440: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args);
1.2 raeburn 441: }
442:
443: sub form_elements {
444: my ($dom) = @_;
445: my %elements =
446: (
447: new => {
448: crstype => {
449: crstype => 'selectbox',
450: action => 'selectbox',
1.16 raeburn 451: origcnum => 'hidden',
1.2 raeburn 452: },
453: courseinfo => {
454: cdescr => 'text',
1.13 raeburn 455: clonecrs => 'text',
456: clonedom => 'selectbox',
1.2 raeburn 457: datemode => 'radio',
458: dateshift => 'text',
459: },
460: enrollment => {
1.13 raeburn 461: accessstart_month => 'selectbox',
462: accessstart_hour => 'selectbox',
463: accessend_month => 'selectbox',
464: accessend_hour => 'selectbox',
465: accessstart_day => 'text',
466: accessstart_year => 'text',
467: accessstart_minute => 'text',
468: accessstart_second => 'text',
469: accessend_day => 'text',
470: accessend_year => 'text',
471: accessend_minute => 'text',
472: accessend_second => 'text',
1.2 raeburn 473: no_end_date => 'checkbox',
474: },
475: personnel => {
476: addperson => 'checkbox',
477: },
1.13 raeburn 478: review => {
479: cnum => 'hidden',
480: },
1.2 raeburn 481: },
482: view => {
483: crstype => {
484: crstype => 'selectbox',
485: action => 'selectbox',
486: },
487: },
488: );
1.13 raeburn 489: my %servers = &Apache::lonnet::get_servers($dom,'library');
490: my $numlib = keys(%servers);
491: if ($numlib > 1) {
492: $elements{'new'}{'courseinfo'}{'chome'} = 'selectbox';
493: } else {
494: $elements{'new'}{'courseinfo'}{'chome'} = 'hidden';
495: }
1.2 raeburn 496: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
497: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
498: \%cat_order,\@code_order);
499: my $numtitles = scalar(@codetitles);
500: if ($numtitles) {
501: my %extras;
502: $lastitem = pop(@codetitles);
503: $extras{'instcode_'.$lastitem} = 'text';
504: foreach my $item (@codetitles) {
505: $extras{'instcode_'.$item} = 'selectbox';
506: }
507: $elements{'new'}{'codepick'} = \%extras;
508: }
509: if (&Apache::lonnet::auto_run('',$dom)) {
510: my %extras = (
511: sectotal => 'hidden',
1.13 raeburn 512: enrollstart_month => 'selectbox',
513: enrollstart_hour => 'selectbox',
514: enrollend_month => 'selectbox',
515: enrollend_hour => 'selectbox',
516: enrollstart_day => 'text',
517: enrollstart_year => 'text',
518: enrollstart_minute => 'text',
519: enrollstart_second => 'text',
520: enrollend_day => 'text',
521: enrollend_year => 'text',
522: enrollend_minute => 'text',
523: enrollend_second => 'text',
1.2 raeburn 524: addcrosslist => 'checkbox',
525: autoadds => 'radio',
526: autodrops => 'radio',
527: );
528: if ($env{'form.sectotal'} > 0) {
529: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
530: $extras{'sec_'.$i} = 'checkbox',
531: $extras{'secnum_'.$i} = 'text',
1.24 raeburn 532: $extras{'loncapasec_'.$i} = 'text',
1.2 raeburn 533: }
534: }
535: my $crosslisttotal = $env{'form.crosslisttotal'};
1.16 raeburn 536: if ($env{'form.addcrosslist'}) {
537: $crosslisttotal ++;
538: }
1.24 raeburn 539: if (!$crosslisttotal) {
1.2 raeburn 540: $crosslisttotal = 1;
541: }
1.27 raeburn 542:
1.24 raeburn 543: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
544: if ($numtitles) {
545: $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
546: }
547: if (@codetitles > 0) {
548: foreach my $item (@codetitles) {
549: $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
1.2 raeburn 550: }
551: }
1.24 raeburn 552: $extras{'crosslist_'.$i} = 'checkbox';
553: $extras{'crosslist_'.$i.'_instsec'} = 'text',
554: $extras{'crosslist_'.$i.'_lcsec'} = 'text',
1.2 raeburn 555: }
556: my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
557: %{$elements{'new'}{'enrollment'}} = %mergedhash;
558: }
559: my %people;
560: my $persontotal = $env{'form.persontotal'};
1.16 raeburn 561: if ($env{'form.addperson'}) {
562: $persontotal ++;
563: }
564: if ((!defined($persontotal)) || (!$persontotal)) {
1.2 raeburn 565: $persontotal = 1;
566: }
567: for (my $i=0; $i<$persontotal; $i++) {
1.13 raeburn 568: $people{'person_'.$i.'_uname'} = 'text',
569: $people{'person_'.$i.'_dom'} = 'selectbox',
570: $people{'person_'.$i.'_hidedom'} = 'hidden',
571: $people{'person_'.$i.'_firstname'} = 'text',
572: $people{'person_'.$i.'_lastname'} = 'text',
573: $people{'person_'.$i.'_emailaddr'} = 'text',
574: $people{'person_'.$i.'_role'} = 'selectbox',
575: $people{'person_'.$i.'_sec'} = 'selectbox',
576: $people{'person_'.$i.'_newsec'} = 'text',
1.2 raeburn 577: }
578: my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
579: %{$elements{'new'}{'personnel'}} = %personnelhash;
580: return %elements;
581: }
582:
583: sub onload_action {
584: my ($action,$state) = @_;
585: my %loaditems;
586: if (($action eq 'new') || ($action eq 'view')) {
1.30 ! raeburn 587: if ($state eq 'crstype') {
! 588: $loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
! 589: } else {
! 590: $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
! 591: }
1.2 raeburn 592: }
593: return \%loaditems;
594: }
595:
1.1 raeburn 596: sub check_can_request {
597: my ($dom,$can_request) = @_;
598: my $canreq = 0;
1.4 raeburn 599: my ($types,$typename) = &course_types();
1.19 raeburn 600: my @options = ('approval','validate','autolimit');
601: my $optregex = join('|',@options);
1.4 raeburn 602: if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
603: foreach my $type (@{$types}) {
1.1 raeburn 604: if (&Apache::lonnet::usertools_access($env{'user.name'},
605: $env{'user.domain'},
606: $type,undef,'requestcourses')) {
607: $canreq ++;
608: if ($dom eq $env{'user.domain'}) {
609: $can_request->{$type} = 1;
610: }
611: }
612: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
613: my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
614: if (@curr > 0) {
615: $canreq ++;
616: unless ($dom eq $env{'user.domain'}) {
1.19 raeburn 617: if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {
1.1 raeburn 618: $can_request->{$type} = 1;
619: }
620: }
621: }
622: }
623: }
624: }
625: return $canreq;
626: }
627:
1.4 raeburn 628: sub course_types {
629: my @types = ('official','unofficial','community');
630: my %typename = (
631: official => 'Official course',
632: unofficial => 'Unofficial course',
633: community => 'Community',
634: );
635: return (\@types,\%typename);
636: }
637:
638:
1.1 raeburn 639: sub print_main_menu {
1.3 raeburn 640: my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
1.4 raeburn 641: my ($types,$typename) = &course_types();
1.1 raeburn 642: my $onchange;
643: unless ($env{'form.interface'} eq 'textual') {
644: $onchange = 1;
645: }
646:
1.2 raeburn 647: my $nextstate_setter = "\n";
648: if (ref($states) eq 'HASH') {
649: foreach my $key (keys(%{$states})) {
650: if (ref($states->{$key}) eq 'ARRAY') {
651: $nextstate_setter .=
652: " if (actionchoice == '$key') {
653: nextstate = '".$states->{$key}[1]."';
654: }
655: ";
656: }
657: }
658: }
1.1 raeburn 659:
1.2 raeburn 660: my $js = <<"END";
1.1 raeburn 661:
1.2 raeburn 662: function nextPage(formname) {
1.27 raeburn 663: var crschoice = document.mainmenu_coursetype.crstype.value;
664: var actionchoice = document.mainmenu_action.action.value;
1.2 raeburn 665: if (check_can_request(crschoice,actionchoice) == true) {
666: if ((actionchoice == 'new') && (crschoice == 'official')) {
667: nextstate = 'codepick';
668: } else {
669: $nextstate_setter
1.27 raeburn 670: }
671: formname.crstype.value = crschoice;
672: formname.action.value = actionchoice;
1.1 raeburn 673: formname.state.value= nextstate;
674: formname.submit();
675: }
676: return;
677: }
678:
1.2 raeburn 679: function check_can_request(crschoice,actionchoice) {
1.1 raeburn 680: var official = '';
681: var unofficial = '';
682: var community = '';
683: END
684:
685: foreach my $item (keys(%{$can_request})) {
686: $js .= "
687: $item = 1;
688: ";
689: }
690: my %lt = &Apache::lonlocal::texthash(
691: official => 'You are not permitted to request creation of an official course in this domain.',
692: unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
693: community => 'You are not permitted to request creation of a community this domain.',
694: all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',
695: );
696: $js .= <<END;
697: if (crschoice == 'official') {
698: if (official != 1) {
699: alert("$lt{'official'}");
700: return false;
701: }
702: } else {
703: if (crschoice == 'unofficial') {
704: if (unofficial != 1) {
705: alert("$lt{'unofficial'}");
706: return false;
707: }
708: } else {
709: if (crschoice == 'community') {
710: if (community != 1) {
711: alert("$lt{'community'}");
712: return false;
713: }
714: } else {
715: if (actionchoice == 'new') {
716: alert("$lt{'all'}");
717: return false;
718: }
719: }
720: }
721: }
722: return true;
723: }
724:
725: END
726:
1.27 raeburn 727: $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.'<div>'.
728: &Apache::lonhtmlcommon::start_pick_box().
729: &Apache::lonhtmlcommon::row_title(&mt('Course Domain')).
1.1 raeburn 730: '<form name="domforcourse" method="post" action="/adm/requestcourse">'.
731: &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange));
732: if (!$onchange) {
733: $r->print(' <input type="submit" name="godom" value="'.
734: &mt('Change').'" />');
735: }
1.27 raeburn 736: $r->print('</form>'.&Apache::lonhtmlcommon::row_closure());
1.1 raeburn 737:
1.2 raeburn 738: my $formname = 'requestcrs';
1.1 raeburn 739: my $nexttext = &mt('Next');
1.27 raeburn 740: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Action')).'
741: <form name="mainmenu_action" method="post" action="">
1.1 raeburn 742: <select size="1" name="action" >
1.2 raeburn 743: <option value="new">'.&mt('New request').'</option>
1.1 raeburn 744: <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>
745: <option value="log">'.&mt('View request history').'</option>
1.27 raeburn 746: </select></form>'.
747: &Apache::lonhtmlcommon::row_closure(1).
748: &Apache::lonhtmlcommon::row_title(&mt('Course Type')).'
749: <form name="mainmenu_coursetype" method="post" action="">
1.1 raeburn 750: <select size="1" name="crstype">
1.4 raeburn 751: <option value="any">'.&mt('All types').'</option>');
752: if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
753: foreach my $type (@{$types}) {
754: my $selected = '';
755: if ($type eq 'official') {
756: $selected = ' selected="selected"';
757: }
758: $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}.
759: '</option>'."\n");
760: }
761: }
1.27 raeburn 762: $r->print('</select></form>'."\n".
763: &Apache::lonhtmlcommon::row_closure(1)."\n".
764: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n".
765: '<div><form name="'.$formname.'" method="post" action="">'."\n".
766: '<input type="hidden" name="state" value="crstype" />'."\n".
767: '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".
768: '<input type="hidden" name="crstype" value="" />'."\n".
769: '<input type="hidden" name="action" value="" />'."\n".
770: '<input type="button" name="next" value="'.$nexttext.
771: '" onclick="javascript:nextPage(document.'.$formname.')" />'."\n".
772: '</form></div>');
1.1 raeburn 773: $r->print(&Apache::loncommon::end_page());
774: return;
775: }
776:
777: sub request_administration {
1.27 raeburn 778: my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
779: $newinstcode,$codechk,$checkedcode,$invalidcrosslist,$uname,$udom) = @_;
1.2 raeburn 780: my $js;
1.16 raeburn 781: if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
1.2 raeburn 782: $js = <<END;
1.1 raeburn 783:
784: function nextPage(formname,nextstate) {
785: formname.state.value= nextstate;
786: formname.submit();
787: }
1.16 raeburn 788:
789: END
790: }
791: if (($action eq 'new') || ($action eq 'view')) {
792: $js .= <<END;
793:
1.1 raeburn 794: function backPage(formname,prevstate) {
795: formname.state.value = prevstate;
796: formname.submit();
797: }
798:
799: END
1.2 raeburn 800: }
801: if ($action eq 'new') {
802: my $jsextra;
1.1 raeburn 803: unless (($state eq 'review') || ($state eq 'process')) {
1.2 raeburn 804: $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
1.1 raeburn 805: }
1.3 raeburn 806: $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);
1.27 raeburn 807: &print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
808: $codechk,$checkedcode,$invalidcrosslist);
1.2 raeburn 809: } elsif ($action eq 'view') {
1.16 raeburn 810: my $jsextra;
811: my $formname = 'requestcrs';
812: my $prev = $states->{$action}[$page-1];
813: my $next = $states->{$action}[$page+1];
814: if ($state eq 'pick_request') {
815: $next = $states->{$action}[$page+1];
816: $jsextra = &viewrequest_javascript($formname,$next);
817: } elsif ($state eq 'details') {
818: $jsextra = &viewdetails_javascript($formname);
819:
820: } elsif ($state eq 'cancel') {
821: $jsextra = &viewcancel_javascript($formname);
822: }
823: $r->print(&header('Manage course requests',$js.$jscript.$jsextra,$loaditems).
824: $crumb);
825: my $form = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />';
1.11 raeburn 826: if ($state eq 'pick_request') {
1.16 raeburn 827: $r->print('<h3>'.&mt('Pending course requests').'</h3><div>'."\n".$form."\n".
1.30 ! raeburn 828: &print_request_status($dom).'</form></div>');
1.16 raeburn 829: } elsif ($state eq 'details') {
830: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
831: my $origcnum = $env{'form.cnum'};
832: if ($origcnum eq '') {
833: $origcnum = $env{'form.origcnum'};
834: }
835: if ($env{'form.crstype'} eq 'official') {
836: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
837: \%cat_order,\@code_order);
838: }
839: $r->print('<h3>'.&mt('Course Request Details').'</h3><div>'."\n".$form."\n".
1.26 raeburn 840: &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
1.16 raeburn 841: \@code_order)."\n".
842: '<input name="origcnum" value="'.$origcnum.'" type="hidden" />'."\n");
843: my @excluded = &get_excluded_elements($dom,$states,'new','review');
844: push(@excluded,'origcnum');
845: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
846: my $other = 'modify';
847: my %navtxt = &Apache::lonlocal::texthash (
848: prev => 'Back',
849: other => 'Modify Request',
850: next => 'Cancel Request',
851: );
852: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},
853: $state,$other,$navtxt{'other'});
854: $r->print('</form>');
855: } elsif ($state eq 'cancel') {
856: my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
857: $r->print('<h3>'.&mt('Cancel course request').'</h3><div>'."\n".$form."\n".
858: $output);
859: my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
860: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
861: my %navtxt = &Apache::lonlocal::texthash (
862: prev => 'Back',
863: next => 'Confirm Cancellation',
864: );
865: if ($result eq 'ok') {
866: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,
867: $navtxt{'next'},$state);
868: } else {
869: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},undef,'',$state);
870: }
871: $r->print('</form>');
872: } elsif ($state eq 'removal') {
873: my $cnum = $env{'form.origcnum'};
874: my $statuskey = 'status:'.$dom.':'.$cnum;
875: my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
876: $env{'user.domain'},$env{'user.name'});
877: my $currstatus = $userreqhash{$statuskey};
878: my ($result,$error);
879: if (($currstatus eq 'approval') || ($currstatus eq 'pending')) {
880: my %status = (
881: $statuskey => 'cancelled',
882: );
883: my $statusresult = &Apache::lonnet::put('courserequests',\%status);
884: if ($statusresult eq 'ok') {
885: my $delresult =
886: &Apache::lonnet::del_dom('courserequestqueue',
887: [$cnum.'_'.$currstatus],$dom);
888: if ($delresult eq 'ok') {
889: $result = 'ok';
890: } else {
891: $error = &mt('An error occurred when updating the pending requests queue: [_1]',$delresult);
892: }
893: } else {
894: $error = &mt("An error occurred when updating the status of this request in the requestor's records: [_1]",$statusresult);
895: }
896: } else {
897: $error = &mt('The current status of this request could not be verified as pending approval/institutional action.');
898: }
899: $r->print('<h3>'.&mt('Request Cancellation').'</h3><div>'."\n".$form."\n".
900: '<input type="hidden" name="state" value="'.$state.'" />'."\n".
901: '<input type="hidden" name="action" value="'.$action.'" />'."\n".
902: '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".
903: '<input type="hidden" name="orignum" value="'.$cnum.'" />'."\n");
904: if ($result eq 'ok') {
905: $r->print(&mt('Your course request has been cancelled.'));
906: } else {
907: $r->print('<div class="LC_error">'.
908: &mt('The request cancellation process was not complete.').
909: '<br />'.$error.'</div>');
910: }
911: $r->print('</form>');
1.11 raeburn 912: }
1.26 raeburn 913: } elsif ($action eq 'display') {
914: my $formname = 'requestcrs';
915: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
916: if ($env{'form.crstype'} eq 'official') {
917: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
918: \%cat_order,\@code_order);
919: }
920: $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
921: $crumb."\n".'<h3>'.&mt('Course Request Details').'</h3>'.
922: &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
923: \@code_order,$uname,$udom)."\n".'</div>'.
924: &close_popup_form());
1.1 raeburn 925: } elsif ($action eq 'log') {
1.11 raeburn 926: $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
1.1 raeburn 927: }
1.2 raeburn 928: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 929: return;
930: }
931:
1.26 raeburn 932: sub close_popup_form {
933: my $close= &mt('Close Window');
934: return << "END";
935: <p><form name="displayreq" action="" method="post">
936: <input type="button" name="closeme" value="$close" onclick="javascript:self.close();" />
937: </form></p>
938: END
939: }
940:
1.27 raeburn 941: sub get_instcode {
942: my ($dom) = @_;
943: my ($instcode,$numtitles);
944: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
945: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
946: \%cat_order,\@code_order);
947: $numtitles = scalar(@codetitles);
948: if (@code_order > 0) {
949: my $message;
950: foreach my $item (@code_order) {
951: $instcode .= $env{'form.instcode_'.$item};
952: }
953: }
954: return ($instcode,$numtitles);
955: }
956:
1.1 raeburn 957: sub print_request_form {
1.27 raeburn 958: my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
959: $invalidcrosslist) = @_;
1.1 raeburn 960: my $formname = 'requestcrs';
1.2 raeburn 961: my ($next,$prev,$message,$output,$codepicker,$crstype);
962: $prev = $states->{$action}[$page-1];
963: $next = $states->{$action}[$page+1];
1.4 raeburn 964: my %navtxt = &Apache::lonlocal::texthash (
1.10 raeburn 965: prev => 'Back',
1.4 raeburn 966: next => 'Next',
967: );
1.2 raeburn 968: $crstype = $env{'form.crstype'};
1.1 raeburn 969: $r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">');
1.30 ! raeburn 970: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk,
! 971: @disallowed);
1.1 raeburn 972: if ($crstype eq 'official') {
1.2 raeburn 973: if ($env{'form.instcode'} ne '') {
974: $instcode = $env{'form.instcode'};
1.27 raeburn 975: } elsif ($newinstcode ne '') {
976: $instcode = $newinstcode;
1.2 raeburn 977: }
1.27 raeburn 978: if ($checkedcode) {
979: if ($codechk eq 'valid') {
980: $message = '<div class="LC_info">'.
981: &mt('The chosen course category [_1] is valid.','<b>'.
982: $instcode.'</b>').
983: '<input type="hidden" name="instcode" value="'.
984: $instcode.'" /></div>';
1.2 raeburn 985: } else {
986: $message = '<div class="LC_warning">'.
1.27 raeburn 987: &mt('No course was found matching your choice of institutional course category.');
988: if ($codechk ne '') {
989: $message .= '<br />'.$codechk;
990: }
991: $message .= '</div>';
1.2 raeburn 992: $prev = 'crstype';
993: }
994: $r->print($message);
1.1 raeburn 995: }
1.2 raeburn 996: }
997: if ($prev eq 'crstype') {
1.4 raeburn 998: if ($crstype eq 'official') {
999: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1000: \%cat_order,\@code_order);
1001: }
1.2 raeburn 1002: if (@code_order > 0) {
1.1 raeburn 1003: $codepicker = &coursecode_form($dom,'instcode',\@codetitles,
1004: \%cat_titles,\%cat_order);
1.2 raeburn 1005: if ($codepicker) {
1006: $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
1007: &Apache::lonhtmlcommon::end_pick_box().'</div>');
1008: } else {
1.20 raeburn 1009: $next = $states->{$action}[$page+2];
1.15 raeburn 1010: $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
1.2 raeburn 1011: }
1012: } else {
1.20 raeburn 1013: if ($crstype eq 'official') {
1014: $next = $states->{$action}[$page+2];
1015: }
1.15 raeburn 1016: $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
1.1 raeburn 1017: }
1.2 raeburn 1018: } elsif ($prev eq 'codepick') {
1.27 raeburn 1019: if ($instcode eq '') {
1.20 raeburn 1020: $prev = $states->{$action}[$page-2];
1021: }
1.15 raeburn 1022: $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
1.2 raeburn 1023: } elsif ($state eq 'enrollment') {
1.4 raeburn 1024: if ($crstype eq 'official') {
1025: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1026: \%cat_order,\@code_order);
1027: }
1.2 raeburn 1028: $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
1.27 raeburn 1029: \%cat_titles,\%cat_order,\@code_order,
1030: $invalidcrosslist));
1.2 raeburn 1031: } elsif ($state eq 'personnel') {
1.27 raeburn 1032: $r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
1.4 raeburn 1033: } elsif ($state eq 'review') {
1.30 ! raeburn 1034: my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg);
! 1035: my $now = time;
! 1036: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
! 1037: my $personname = $env{'form.person_'.$i.'_uname'};
! 1038: my $persondom = $env{'form.person_'.$i.'_dom'};
! 1039: if (($personname =~ /^$match_username$/) &&
! 1040: ($persondom =~ /^$match_domain$/)) {
! 1041: if (&Apache::lonnet::domain($persondom)) {
! 1042: my $personhome =
! 1043: &Apache::lonnet::homeserver($personname,$persondom);
! 1044: if ($personhome eq 'no_host') {
! 1045: if ($persondom ne $dom) {
! 1046: my $skipuser = 1;
! 1047: if ($env{'user.role.dc./'.$persondom.'/'}) {
! 1048: my ($start,$end) = split('.',$env{'user.role.dc./'.$persondom.'/'});
! 1049: if (((!$start) || ($start < $now)) &&
! 1050: ((!$end) || ($end > $now))) {
! 1051: $skipuser = 0;
! 1052: }
! 1053: }
! 1054: if ($skipuser) {
! 1055: push(@disallowed,$i);
! 1056: $disallowmsg{$i} = &mt('[_1] was excluded because new users need be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>');
! 1057: next;
! 1058: }
! 1059: }
! 1060: if (&get_cancreate_status($persondom,$personname,$dom)) {
! 1061: my ($allowed,$msg) =
! 1062: &check_newuser_rules($persondom,$personname,
! 1063: \%alerts,\%rulematch,\%inst_results,
! 1064: \%curr_rules,\%got_rules);
! 1065: if ($allowed) {
! 1066: if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {
! 1067: if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {
! 1068: $env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};
! 1069: }
! 1070: if ($inst_results{$personname.':'.$persondom}{'firstname'} ne '') {
! 1071: $env{'form.person_'.$i.'_firstname'} = $inst_results{$personname.':'.$persondom}{'firstname'};
! 1072: }
! 1073: if ($inst_results{$personname.':'.$persondom}{'permanentemail'} ne '') {
! 1074: $env{'form.person_'.$i.'_emailaddr'} = $inst_results{$personname.':'.$persondom}{'permanentemail'};
! 1075: }
! 1076: }
! 1077: } else {
! 1078: push(@disallowed,$i);
! 1079: $disallowmsg{$i} = &mt('[_1] was excluded because the username violated format rules for the domain','<tt>'.$personname.':'.$persondom.'</tt>');
! 1080: }
! 1081: } else {
! 1082: push(@disallowed,$i);
! 1083: $disallowmsg{$i} = &mt('[_1] was excluded because you may not request new users in the domain','<tt>'.$personname.':'.$persondom.'</tt>');
! 1084: }
! 1085: } else {
! 1086: my %userenv =
! 1087: &Apache::lonnet::userenvironment($persondom,$personname,'lastname','firstname','permanentemail');
! 1088: if ($env{'form.person_'.$i.'_lastname'} eq '') {
! 1089: $env{'form.person_'.$i.'_lastname'} = $userenv{'lastname'};
! 1090: }
! 1091: if ($env{'form.person_'.$i.'_firstname'} eq '') {
! 1092: $env{'form.person_'.$i.'_firstname'} = $userenv{'firstname'};
! 1093: }
! 1094: if ($env{'form.person_'.$i.'_emailaddr'} eq '') {
! 1095: $env{'form.person_'.$i.'_emailaddr'} = $userenv{'permanentemail'};
! 1096: }
! 1097: }
! 1098: } elsif ($personname ne '') {
! 1099: push(@disallowed,$i);
! 1100: $disallowmsg{$i} = &mt('[_1] was excluded because the domain is invalid','<tt>'.$personname.':'.$persondom.'</tt>');
! 1101: }
! 1102: } elsif ($personname ne '') {
! 1103: push(@disallowed,$i);
! 1104: $disallowmsg{$i} = &mt('[_1] was excluded because the username or domain is invalid.','<tt>'.$personname.':'.$persondom.'</tt>');
! 1105: }
! 1106: }
1.16 raeburn 1107: my $cnum;
1108: if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {
1109: $cnum = $env{'form.origcnum'};
1110: } else {
1111: $cnum = &Apache::lonnet::generate_coursenum($dom);
1112: }
1.4 raeburn 1113: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1114: \%cat_order,\@code_order);
1.27 raeburn 1115: $r->print('<h3>'.&mt('Review course request details before submission').'</h3>'.
1.30 ! raeburn 1116: &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg).
1.16 raeburn 1117: '<input type="hidden" name="cnum" value="'.$cnum.'" />');
1.4 raeburn 1118: $navtxt{'next'} = &mt('Submit course request');
1.10 raeburn 1119: } elsif ($state eq 'process') {
1120: if ($crstype eq 'official') {
1121: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1122: \%cat_order,\@code_order);
1123: }
1.27 raeburn 1124: my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
1125: \@code_order);
1.13 raeburn 1126: $r->print($result);
1.27 raeburn 1127: if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
1128: $r->print('<p>');
1129: if ($storeresult eq 'ok') {
1130: $r->print('<a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'.
1131: &mt('Modify this request').'</a>'.(' 'x4));
1132: }
1133: $r->print('<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
1134: return;
1135: }
1.1 raeburn 1136: }
1.16 raeburn 1137: my @excluded = &get_excluded_elements($dom,$states,$action,$state);
1.24 raeburn 1138: if ($state eq 'personnel') {
1139: push(@excluded,'persontotal');
1140: }
1.30 ! raeburn 1141: if ($state eq 'review') {
! 1142: if (@disallowed > 0) {
! 1143: my @items = qw(uname dom lastname firstname emailaddr hidedom role newsec);
! 1144: my @currsecs = ¤t_lc_sections();
! 1145: if (@currsecs) {
! 1146: push(@items,'sec');
! 1147: }
! 1148: my $count = 0;
! 1149: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
! 1150: unless ($env{'form.person_'.$i.'_uname'} eq '') {
! 1151: if (grep(/^$i$/,@disallowed)) {
! 1152: foreach my $item (@items) {
! 1153: $env{'form.person_'.$i.'_'.$item} = '';
! 1154: }
! 1155: } else {
! 1156: foreach my $item (@items) {
! 1157: $env{'form.person_'.$count.'_'.$item} = $env{'form.person_'.$i.'_'.$item};
! 1158: }
! 1159: }
! 1160: }
! 1161: $count ++;
! 1162: }
! 1163: $env{'form.persontotal'} = $count;
! 1164:
! 1165: }
! 1166: }
1.27 raeburn 1167: if ($state eq 'enrollment') {
1168: push(@excluded,'crosslisttotal');
1169: }
1.16 raeburn 1170: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
1171: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);
1172: return;
1173: }
1174:
1.30 ! raeburn 1175: sub get_cancreate_status {
! 1176: my ($persondom,$personname,$dom) = @_;
! 1177: my ($rules,$ruleorder) =
! 1178: &Apache::lonnet::inst_userrules($persondom,'username');
! 1179: my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
! 1180: $rules);
! 1181: return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype);
! 1182: }
! 1183:
! 1184: sub check_newuser_rules {
! 1185: my ($persondom,$personname,$alerts,$rulematch,$inst_results,$curr_rules,
! 1186: $got_rules) = @_;
! 1187: my $allowed = 1;
! 1188: my $newuser = 1;
! 1189: my ($checkhash,$userchkmsg);
! 1190: my $checks = { 'username' => 1 };
! 1191: $checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
! 1192: &Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
! 1193: $inst_results,$curr_rules,$got_rules);
! 1194: if (ref($alerts->{'username'}) eq 'HASH') {
! 1195: if (ref($alerts->{'username'}{$persondom}) eq 'HASH') {
! 1196: my $domdesc =
! 1197: &Apache::lonnet::domain($persondom,'description');
! 1198: if ($alerts->{'username'}{$persondom}{$personname}) {
! 1199: if (ref($curr_rules->{$persondom}) eq 'HASH') {
! 1200: $userchkmsg =
! 1201: &Apache::loncommon::instrule_disallow_msg('username',
! 1202: $domdesc,1).
! 1203: &Apache::loncommon::user_rule_formats($persondom,
! 1204: $domdesc,$curr_rules->{$persondom}{'username'},
! 1205: 'username');
! 1206: }
! 1207: $allowed = 0;
! 1208: }
! 1209: }
! 1210: }
! 1211: return ($allowed,$userchkmsg);
! 1212: }
! 1213:
1.16 raeburn 1214: sub get_excluded_elements {
1215: my ($dom,$states,$action,$state) = @_;
1.2 raeburn 1216: my @excluded = ('counter');
1217: my %elements = &form_elements($dom);
1218: if (ref($states) eq 'HASH') {
1219: if (ref($states->{$action}) eq 'ARRAY') {
1220: my @items = @{$states->{$action}};
1221: my $numitems = scalar(@items);
1222: if ($numitems) {
1223: for (my $i=$numitems-1; $i>=0; $i--) {
1224: if (ref($elements{$action}) eq 'HASH') {
1225: if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
1.16 raeburn 1226: foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
1.2 raeburn 1227: push(@excluded,$key);
1228: }
1229: }
1230: }
1231: last if ($items[$i] eq $state);
1232: }
1233: }
1234: }
1235: }
1236: if (grep(/^instcode_/,@excluded)) {
1237: push(@excluded,'instcode');
1.1 raeburn 1238: }
1.16 raeburn 1239: return @excluded;
1.1 raeburn 1240: }
1241:
1.2 raeburn 1242: sub print_enrollment_menu {
1.27 raeburn 1243: my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
1244: $invalidcrosslist) =@_;
1245: my ($sections,$autoenroll,$access_dates,$output);
1.2 raeburn 1246: my $starttime = time;
1247: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1248:
1249: my %accesstitles = (
1250: 'start' => 'Default start access',
1.16 raeburn 1251: 'end' => 'Default end access',
1.2 raeburn 1252: );
1253: my %enrolltitles = (
1254: 'start' => 'Start auto-enrollment',
1255: 'end' => 'End auto-enrollment',
1256: );
1257: if ($env{'form.crstype'} eq 'official') {
1258: if (&Apache::lonnet::auto_run('',$dom)) {
1.27 raeburn 1259: $output = &show_invalid_crosslists($invalidcrosslist);
1260: my ($section_form,$crosslist_form);
1.2 raeburn 1261: $section_form = &inst_section_selector($dom,$instcode);
1.27 raeburn 1262: if ($section_form) {
1263: $sections = &Apache::lonhtmlcommon::row_headline().
1264: '<h3>'.&mt('Sections for auto-enrollment').'</h3>'.
1265: &Apache::lonhtmlcommon::row_closure(1).
1266: $section_form;
1267: }
1.2 raeburn 1268: my $crosslisttotal = $env{'form.crosslisttotal'};
1.24 raeburn 1269: if (!$crosslisttotal) {
1.2 raeburn 1270: $crosslisttotal = 1;
1271: }
1272: if ($env{'form.addcrosslist'}) {
1273: $crosslisttotal ++;
1274: }
1275: for (my $i=0; $i<$crosslisttotal; $i++) {
1276: $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
1277: $cat_titles,$cat_order,$i);
1278: }
1279: if ($crosslist_form) {
1280: $crosslist_form .=
1281: &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
1282: '<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'.
1283: '<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'.
1284: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
1.27 raeburn 1285: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
1286: $sections .= &Apache::lonhtmlcommon::row_headline.
1287: '<h3>'.&mt('Crosslisted courses for auto-enrollment').'</h3>'.
1288: &Apache::lonhtmlcommon::row_closure(1).
1289: $crosslist_form;
1.2 raeburn 1290: }
1.27 raeburn 1291: $autoenroll =
1.2 raeburn 1292: &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).
1293: '<span class="LC_nobreak"><label>'.
1294: '<input type="radio" name="autoadds" value="1">'.
1295: &mt('Yes').'</label>'.(' 'x3).'<label>'.
1296: '<input type="radio" name="autoadds" value="0" checked="checked">'.
1297: &mt('No').'</label></span>'.
1.27 raeburn 1298: &Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 1299: &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).
1300: '<span class="LC_nobreak"><label>'.
1301: '<input type="radio" name="autodrops" value="1">'.
1302: &mt('Yes').'</label>'.(' 'x3).'<label>'.
1303: '<input type="radio" name="autodrops" value="0" checked="checked">'.
1304: &mt('No').'</label></span>'.
1.27 raeburn 1305: &Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 1306: &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);
1307: }
1308: }
1.27 raeburn 1309: my $access_dates =
1.2 raeburn 1310: &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);
1.27 raeburn 1311: $output .= &Apache::lonhtmlcommon::start_pick_box();
1312: if ($sections) {
1313: $output .= $sections;
1314: }
1315: if ($autoenroll) {
1316: $output .= &Apache::lonhtmlcommon::row_headline('Auto-enroll').
1317: '<h3>'.&mt('Auto-enrollment settings').'</h3>'.
1318: &Apache::lonhtmlcommon::row_closure(1).
1319: $autoenroll;
1320: }
1321: if ($access_dates) {
1322: my $header = &mt('Access dates for students');
1323: if ($env{'form.crstype'} eq 'community') {
1324: $header = &mt('Access dates for community members');
1325: }
1326: $output .= &Apache::lonhtmlcommon::row_headline('Access').
1327: '<h3>'.$header.'</h3>'.
1328: &Apache::lonhtmlcommon::row_closure(1).
1329: $access_dates
1.2 raeburn 1330: }
1.27 raeburn 1331: return '<div>'.&Apache::lonhtmlcommon::start_pick_box().$output.
1332: &Apache::lonhtmlcommon::end_pick_box().'</div>';
1.2 raeburn 1333: }
1334:
1.27 raeburn 1335: sub show_invalid_crosslists {
1336: my ($invalidcrosslist) = @_;
1337: my $output;
1338: if (ref($invalidcrosslist) eq 'ARRAY') {
1339: if (@{$invalidcrosslist} > 0) {
1340: $output = '<div class="LC_warning">'.
1341: &mt('The following crosslisted courses were invalid:').'<ul>';
1342: foreach my $item (@{$invalidcrosslist}) {
1343: $output .= '<li>'.$item.'</li>';
1344: }
1345: $output .= '</ul></div><br />';
1346: }
1347: }
1348: return $output;
1349: }
1350:
1351:
1.1 raeburn 1352: sub inst_section_selector {
1.2 raeburn 1353: my ($dom,$instcode) = @_;
1354: my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
1355: my $sectotal = scalar(@sections);
1.1 raeburn 1356: my $output;
1.2 raeburn 1357: if ($sectotal) {
1.27 raeburn 1358: $output .= &Apache::lonhtmlcommon::row_title(&mt('Sections of [_1]',$instcode)).
1.2 raeburn 1359: &Apache::loncommon::start_data_table().
1360: &Apache::loncommon::start_data_table_row().
1361: '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
1.24 raeburn 1362: 'value="'.$sectotal.'" /></th>'.
1.2 raeburn 1363: '<th>'.&mt('Institutional Section').'</th>'.
1364: '<th>'.&mt('LON-CAPA section').'</th>'.
1365: &Apache::loncommon::end_data_table_row();
1366: for (my $i=0; $i<@sections; $i++) {
1.1 raeburn 1367: my $colflag = $i%2;
1.24 raeburn 1368: my $checked = ' checked="checked"';
1369: if ($env{'form.origcnum'}) {
1370: $checked='';
1371: }
1.1 raeburn 1372: $output .= &Apache::loncommon::start_data_table_row().
1.2 raeburn 1373: '<td><input type="checkbox" name="sec_'.$i.
1.24 raeburn 1374: '"'.$checked.' value="1" /></td>'.
1.2 raeburn 1375: '<td>'.$sections[$i].
1.1 raeburn 1376: '<input type="hidden" name="secnum_'.$i.'" value="'.
1.2 raeburn 1377: $sections[$i].'" /></td>'.
1.1 raeburn 1378: '<td><input type="text" size="10" name="loncapasec_'.$i.
1.2 raeburn 1379: '" value="'.$sections[$i].'" /></td>'.
1.1 raeburn 1380: &Apache::loncommon::end_data_table_row();
1381: }
1.2 raeburn 1382: $output .= &Apache::loncommon::end_data_table().
1383: &Apache::lonhtmlcommon::row_closure();
1.1 raeburn 1384: }
1385: return $output;
1386: }
1387:
1.2 raeburn 1388: sub date_setting_table {
1.14 raeburn 1389: my ($starttime,$endtime,$formname,$prefix,%datetitles) = @_;
1.2 raeburn 1390: my ($perpetual,$table);
1.14 raeburn 1391: my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
1.2 raeburn 1392: $starttime,'','','',1,'','','',1);
1.14 raeburn 1393: my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end',
1.2 raeburn 1394: $endtime,'','','',1,'','','',1);
1.27 raeburn 1395: my $closure = '';
1.14 raeburn 1396: if ($prefix eq 'access') {
1.2 raeburn 1397: $perpetual = ' <span class="LC_nobreak"><label>'.
1398: '<input type="checkbox" name="no_end_date" />'.
1399: &mt('No end date').'</label></span>';
1.27 raeburn 1400: $closure = '1';
1.2 raeburn 1401: }
1402: $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).
1403: $startform.
1.27 raeburn 1404: &Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 1405: &Apache::lonhtmlcommon::row_title($datetitles{'end'}).
1406: $endform.$perpetual.
1.27 raeburn 1407: &Apache::lonhtmlcommon::row_closure($closure);
1.2 raeburn 1408: return $table;
1409: }
1410:
1411: sub print_personnel_menu {
1.27 raeburn 1412: my ($dom,$formname,$crstype,$invalidcrosslist) = @_;
1413: my $output;
1414: if ($crstype eq 'official') {
1415: if (&Apache::lonnet::auto_run('',$dom)) {
1416: $output .= &show_invalid_crosslists($invalidcrosslist);
1417: }
1418: }
1419: $output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box();
1.2 raeburn 1420: my $persontotal = $env{'form.persontotal'};
1.16 raeburn 1421: if ((!defined($persontotal)) || (!$persontotal)) {
1.2 raeburn 1422: $persontotal = 1;
1423: }
1424: if ($env{'form.addperson'}) {
1425: $persontotal ++;
1426: }
1.13 raeburn 1427: my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');
1.2 raeburn 1428:
1429: my $roleoptions;
1430: my @roles = &Apache::lonuserutils::roles_by_context('course');
1.8 raeburn 1431: my $type = 'Course';
1432: if ($crstype eq 'community') {
1433: $type = 'Community';
1434: }
1.2 raeburn 1435: foreach my $role (@roles) {
1.28 raeburn 1436: my $plrole = &Apache::lonnet::plaintext($role,$type);
1.2 raeburn 1437: $roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n";
1438: }
1439: my %customroles=&Apache::lonuserutils::my_custom_roles();
1440: if (keys(%customroles) > 0) {
1441: foreach my $cust (sort(keys(%customroles))) {
1.28 raeburn 1442: my $custrole="cr/$env{'user.domain'}/$env{'user.name'}/$cust";
1.2 raeburn 1443: $roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n";
1444: }
1445: }
1446:
1.30 ! raeburn 1447: my @currsecs = ¤t_lc_sections();
1.2 raeburn 1448:
1449: my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
1450: if (@currsecs) {
1451: my $existsize = scalar(@currsecs);
1452: if ($existsize > 3) {
1453: $existsize = 3;
1454: }
1455: if ($existsize > 1) {
1456: $existmult = ' multiple="multiple" size="'.$existsize.'" ';
1457: }
1458: @currsecs = sort { $a <=> $b } (@currsecs);
1459: $existtitle = &mt('Official').': ';
1460: $existops = '<option value="">'.&mt('None').'</option>';
1461: foreach my $sec (@currsecs) {
1462: $existops .= '<option value="'.$sec.'">'.$sec.'</option>'."\n";
1463: }
1464: $seccolspan = ' colspan="2"';
1465: $newtitle = &mt('Other').': ';
1466: }
1467:
1.27 raeburn 1468: if ($persontotal) {
1469: $output .= &Apache::lonhtmlcommon::row_headline().
1470: '<h3>'.&mt('Requestor is automatically assigned Course Coordinator role.').' '.&mt('Include other personnel?').'</h3>';
1471: }
1.2 raeburn 1472: for (my $i=0; $i<$persontotal; $i++) {
1473: my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
1474: my $linkargstr = join("','",@linkargs);
1.29 raeburn 1475: my $uname_form = '<input type="text" name="person_'.$i.'_uname" value="" size="20" />';
1.2 raeburn 1476: my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
1.29 raeburn 1477: "'person_".$i."_hidedom','person_".$i."_uname'".');';
1.2 raeburn 1478: my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
1479: 1,$onchange).
1.29 raeburn 1480: '<input type="hidden" name="person_'.$i.'_hidedom" value="" />';
1.2 raeburn 1481: my %form_elems;
1482: foreach my $item (@items) {
1483: next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
1484: $form_elems{$item} = '<input type="text" name="person_'.$i.'_'.$item.'" '.
1485: 'value="" readonly="readonly" />';
1486: }
1487: my $roleselector = '<select name="person_'.$i.'_role">'."\n".
1488: $roleoptions.'</select>';
1489: my $sectionselector;
1490: if (@currsecs) {
1491: $sectionselector = $existtitle.'<select name="person_'.$i.'_sec"'.
1492: $existmult.'>'."\n".$existops.'</select>'.(' ' x3);
1493: }
1494: $sectionselector .= $newtitle.
1.14 raeburn 1495: '<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n";
1.29 raeburn 1496: my $usersrchlinktxt = &mt('Search for user');
1497: my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
1498: $usersrchlinktxt);
1499: my $userchklinktxt = &mt('Check username');
1500: my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
1501: $userchklinktxt,'checkusername');
1.2 raeburn 1502: $output .=
1.29 raeburn 1503: &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel')).
1504: '<table><tr><td align="center" valign="middle"><b>'.$usersrchlink.'</b></td>'."\n".
1505: '<td align="left" valign="top" colspan="2"><span class="LC_nobreak">'.
1506: &mt('Username').': '.$uname_form.' '.$userchklink.'</span><br />'."\n".
1507: '<span class="LC_nobreak">'.&mt('Domain').': '.$udom_form.'</span></td>'.
1508: '</tr>'."\n".'<tr>'.
1.13 raeburn 1509: '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n".
1510: '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n".
1511: '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n".
1.2 raeburn 1512: '<tr><td align="center" valign="top">'.&mt('Role').'<br />'.$roleselector.'</td>'."\n".
1513: '<td'.$seccolspan.' align="center" valign="top">'.&mt('Section(s)').'<br />'.$sectionselector.'</td>'."\n".
1514: '</tr></table>'.&Apache::lonhtmlcommon::row_closure();
1515: }
1516: $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
1517: '<input name="persontotal" type="hidden" value="'.$persontotal.'" />'.
1518: '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.
1519: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
1520: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
1521: &Apache::lonhtmlcommon::end_pick_box().'</div>';
1522: return $output;
1523: }
1524:
1.30 ! raeburn 1525: sub current_lc_sections {
! 1526: my @currsecs;
! 1527: if ($env{'form.sectotal'}) {
! 1528: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
! 1529: if (defined($env{'form.loncapasec_'.$i})) {
! 1530: my $lcsec = $env{'form.loncapasec_'.$i};
! 1531: unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
! 1532: push(@currsecs,$lcsec);
! 1533: }
! 1534: }
! 1535: }
! 1536: }
! 1537: return @currsecs;
! 1538: }
! 1539:
1.1 raeburn 1540: sub print_request_status {
1.11 raeburn 1541: my ($dom) = @_;
1.14 raeburn 1542: my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
1543: $env{'user.name'},'^status:'.$dom);
1544: my ($output,$formname,%queue_by_date,%typenames);
1545: if ($env{'form.crstype'} eq 'any') {
1546: %typenames = &Apache::lonlocal::texthash (
1547: official => 'Official course',
1548: unofficial => 'Unofficial course',
1549: community => 'Community',
1550: );
1551: }
1552: foreach my $key (keys(%statusinfo)) {
1553: if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {
1554: (undef,my($cdom,$cnum)) = split(':',$key);
1555: next if ($cdom ne $dom);
1556: my $requestkey = $cdom.'_'.$cnum;
1557: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
1558: my %history = &Apache::lonnet::restore($requestkey,'courserequests',
1559: $env{'user.domain'},$env{'user.name'});
1560: my $entry;
1561: my $timestamp = $history{'reqtime'};
1562: my $crstype = $history{'crstype'};
1563: my $disposition = $history{'disposition'};
1564: next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
1565: next unless (($env{'form.crstype'} eq 'any') ||
1566: ($env{'form.crstype'} eq $crstype));
1567: next unless (($disposition eq 'approval') ||
1568: ($disposition eq 'pending'));
1569: if (ref($history{'details'}) eq 'HASH') {
1570: $entry = $requestkey.':'.$crstype.':'.
1571: &escape($history{'details'}{'cdescr'});
1572: if ($crstype eq 'official') {
1573: $entry .= ':'.&escape($history{'details'}{'instcode'});
1574: }
1575: }
1576: if ($entry ne '') {
1577: if (exists($queue_by_date{$timestamp})) {
1578: if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {
1579: push(@{$queue_by_date{$timestamp}},$entry);
1580: }
1581: } else {
1582: @{$queue_by_date{$timestamp}} = ($entry);
1.10 raeburn 1583: }
1584: }
1585: }
1586: }
1587: }
1.11 raeburn 1588: $formname = 'requestcrs';
1.10 raeburn 1589: my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
1.16 raeburn 1590: $output = '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
1591:
1.10 raeburn 1592: '<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n".
1.16 raeburn 1593: '<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n".
1594: '<input type="hidden" name="showdom" value="" />'."\n".
1595: '<input type="hidden" name="cnum" value="" />'."\n";
1.10 raeburn 1596: if (@sortedtimes > 0) {
1597: $output .= &Apache::loncommon::start_data_table().
1598: &Apache::loncommon::start_data_table_header_row().
1599: '<th>'.&mt('Action').'</th>'.
1.14 raeburn 1600: '<th>'.&mt('Course Description').'</th>'.
1601: '<th>'.&mt('Domain').'</th>';
1602: if ($env{'form.crstype'} eq 'any') {
1.10 raeburn 1603: $output .= '<th>'.&mt('Type').'</th>';
1604: }
1.14 raeburn 1605: if (($env{'form.crstype'} eq 'any') || ($env{'form.crstype'} eq 'official')) {
1.10 raeburn 1606: $output .= '<th>'.&mt('Institutional Code').'</th>';
1607: }
1608: $output .= '<th>'.&mt('Date requested').'</th>'.
1609: &Apache::loncommon::end_data_table_header_row();
1610: my $count = 0;
1611: foreach my $item (@sortedtimes) {
1612: my $showtime = &Apache::lonlocal::locallocaltime($item);
1613: if (ref($queue_by_date{$item}) eq 'ARRAY') {
1614: foreach my $request (sort(@{$queue_by_date{$item}})) {
1615: my ($key,$type,$desc,$instcode) = split(':',$request);
1616: my ($cdom,$cnum) = split('_',$key);
1617: $output .= &Apache::loncommon::start_data_table_row().
1.16 raeburn 1618: '<td><input type="button" value="'.&mt('Select').'" onclick="javascript:chooseRequest('."'$cdom','$cnum'".')" /></td>'.
1.14 raeburn 1619: '<td>'.&unescape($desc).'</td>'.
1620: '<td>'.$cdom.'</td>';
1621: if ($env{'form.crstype'} eq 'any') {
1622: my $typename = $typenames{$type};
1623: if ($typename eq '') {
1624: $typename = &mt('Unknown type');
1625: }
1626: $output .= '<td>'.$typename.'</td>';
1.10 raeburn 1627: }
1.14 raeburn 1628: if (($env{'form.crstype'} eq 'any') ||
1.10 raeburn 1629: ($env{'form.crstype'} eq 'official')) {
1.14 raeburn 1630: my $showinstcode;
1631: if ($type eq 'official') {
1632: $showinstcode = &unescape($instcode);
1633: } else {
1634: $showinstcode = &mt('Not applicable');
1635: }
1636: $output .= '<td>'.$showinstcode.'</td>';
1.10 raeburn 1637: }
1638: $output .= '<td>'.$showtime.'</td>'.
1639: &Apache::loncommon::end_data_table_row();
1640: }
1641: }
1642: }
1643: $output .= &Apache::loncommon::end_data_table();
1644: } else {
1.11 raeburn 1645: $output .= '<div>'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>';
1.10 raeburn 1646: }
1647: $output .= '
1.30 ! raeburn 1648: <br /><input type="button" name="prev" value="'.&mt('Back').'" onclick="javascript:backPage(document.'.$formname.",'crstype'".')" />';
1.10 raeburn 1649: return $output;
1.1 raeburn 1650: }
1651:
1.16 raeburn 1652: sub print_cancel_request {
1653: my ($dom,$cnum) = @_;
1654: my $requestkey = $dom.'_'.$cnum;
1655: my ($result,$output);
1656: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
1657: my %history = &Apache::lonnet::restore($requestkey,'courserequests',
1658: $env{'user.domain'},$env{'user.name'});
1659: my $timestamp = $history{'reqtime'};
1660: my $crstype = $history{'crstype'};
1661: my $status = $history{'status'};
1662: if (($status eq 'cancelled') || ($status eq 'created')) {
1663: if ($status eq 'cancelled') {
1664: $output = &mt('This request has already been cancelled.');
1665: } elsif ($status eq 'created') {
1666: $output = &mt('This request has already been processed, and a course created.');
1667: }
1668: $output = &mt('No further action will be taken');
1669: } elsif (ref($history{'details'}) eq 'HASH') {
1670: my ($types,$typename) = &course_types();
1671: my $showtype = $crstype;
1672: if (defined($typename->{$crstype})) {
1673: $showtype = $typename->{$crstype};
1674: }
1675: $output = '<p>'.&Apache::loncommon::start_data_table().
1676: &Apache::loncommon::start_data_table_header_row().
1677: '<th>'.&mt('Description').'</th><th>'.&mt('Requested').'</th>'.
1678: '<th>'.&mt('Type').'</th>'.
1679: &Apache::loncommon::end_data_table_header_row().
1680: &Apache::loncommon::start_data_table_row().
1681: '<td>'.$history{details}{'cdescr'}.'</td><td>'.
1682: &Apache::lonlocal::locallocaltime($timestamp).'</td>'.
1683: '<td>'.$showtype.'</td>'.
1684: &Apache::loncommon::end_data_table_row().
1685: &Apache::loncommon::end_data_table().
1686: '<br /><div class="LC_warning">'.
1687: &mt('Cancelling the request will remove it from the queue of pending course requests').'</div>';
1688: $result = 'ok';
1689: } else {
1690: $output = '<div class="LC_error">'.&mt('No record exists for the course ID').'</div>';
1691: }
1692: } else {
1693: $output = '<div class="LC_error">'.&mt('Invalid course ID').'</div>';
1694: }
1695: return ($result,$output);
1696: }
1697:
1698: sub viewrequest_javascript {
1699: my ($formname,$next) = @_;
1700: return <<"ENDJS";
1701:
1702: function chooseRequest(cdom,cnum) {
1703: document.$formname.showdom.value = cdom;
1704: document.$formname.cnum.value = cnum;
1705: nextPage(document.$formname,'$next');
1706: }
1707:
1708: ENDJS
1709: }
1710:
1711: sub viewdetails_javascript {
1712: my ($formname) = @_;
1713: return << "ENDJS";
1714:
1715: function nextPage(formname,nextstate) {
1716: if (nextstate == "modify") {
1717: formname.state.value = "personnel";
1718: formname.action.value = "new";
1719: } else {
1720: formname.state.value = nextstate;
1721: }
1722: formname.submit();
1723: }
1724:
1725: function backPage(formname,prevstate) {
1726: formname.state.value = prevstate;
1727: formname.submit();
1728: }
1729:
1730: ENDJS
1731: }
1732:
1733: sub viewcancel_javascript {
1734: my $alert = &mt('Are you sure you want to cancel this request?\\n'.
1735: 'Your request will be removed.');
1736: return << "ENDJS";
1737: function nextPage(formname,nextstate) {
1738: if (confirm('$alert')) {
1739: formname.state.value = nextstate;
1740: formname.submit();
1741: }
1742: return;
1743: }
1744:
1745: ENDJS
1746: }
1747:
1.1 raeburn 1748: sub print_request_logs {
1.10 raeburn 1749: my ($jscript,$loaditems,$crumb) = @_;
1.1 raeburn 1750: return;
1751: }
1752:
1753: sub print_review {
1.30 ! raeburn 1754: my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
! 1755: $disallowed,$disallowmsg) = @_;
1.4 raeburn 1756: my ($types,$typename) = &course_types();
1757: my ($owner,$ownername,$owneremail);
1.26 raeburn 1758: if ($uname eq '' || $udom eq '') {
1759: $uname = $env{'user.name'};
1760: $udom = $env{'user.domain'};
1761: }
1762: $owner = $uname.':'.$udom;
1763: $ownername = &Apache::loncommon::plainname($uname,$udom,'first');
1764: my %emails = &Apache::loncommon::getemails($uname,$udom);
1.4 raeburn 1765: foreach my $email ('permanentemail','critnotification','notification') {
1766: $owneremail = $emails{$email};
1767: last if ($owneremail ne '');
1768: }
1769: my ($inst_headers,$inst_values,$crstypename,$enroll_headers,$enroll_values,
1770: $section_headers,$section_values,$personnel_headers,$personnel_values);
1771:
1772: $crstypename = $env{'form.crstype'};
1773: if (ref($typename) eq 'HASH') {
1774: unless ($typename->{$env{'form.crstype'}} eq '') {
1775: $crstypename = $typename->{$env{'form.crstype'}};
1776: }
1777: }
1.16 raeburn 1778: my $category = 'Course';
1779: if ($env{'form.crstype'} eq 'community') {
1780: $category = 'Community';
1781: }
1.4 raeburn 1782:
1783: $inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>';
1784: $inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>';
1785:
1.16 raeburn 1786: my $enrollrow_title = &mt('Default Access Dates').'<br />'.
1787: '('.&Apache::lonnet::plaintext('st',$category).')';
1.4 raeburn 1788: if ($env{'form.crstype'} eq 'official') {
1789: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
1790: foreach my $title (@{$codetitles}) {
1791: if ($env{'form.instcode_'.$title} ne '') {
1792: $inst_headers .= '<th>'.$title.'</th>';
1793: my $longitem = $env{'form.instcode_'.$title};
1794: if (ref($cat_titles->{$title}) eq 'HASH') {
1795: if ($cat_titles->{$title}{$env{'form.instcode_'.$title}} ne '') {
1796: $longitem = $cat_titles->{$title}{$env{'form.instcode_'.$title}};
1797: }
1798: }
1799: $inst_values .= '<td>'.$longitem.'</td>';
1800: }
1801: }
1802: }
1803: if (&Apache::lonnet::auto_run('',$dom)) {
1.16 raeburn 1804: $enrollrow_title = &mt('Enrollment');
1.4 raeburn 1805: $enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'.
1806: '<th>'.&mt('Automatic Drops').'</th>'.
1807: '<th>'.&mt('Enrollment Starts').'</th>'.
1808: '<th>'.&mt('Enrollment Ends').'</th>';
1809: $section_headers = '<th>'.&mt('Sections').'</th>'.
1810: '<th>'.&mt('Crosslistings').'</th>';
1811:
1.13 raeburn 1812: my ($enrollstart,$enrollend) = &dates_from_form('enrollstart','enrollend');
1.4 raeburn 1813: my @autoroster = (&mt('No'),&mt('Yes'));
1814: $enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'.
1815: '<td>'.$autoroster[$env{'form.autodrops'}].'</td>'.
1.13 raeburn 1816: '<td>'.&Apache::lonlocal::locallocaltime($enrollstart).'</td>'.
1817: '<td>'.&Apache::lonlocal::locallocaltime($enrollend).'</td>';
1.6 raeburn 1818: $section_values = '<td><table class="LC_innerpickbox"><tr><th>'.
1819: &mt('Institutional section').'</th>'.
1820: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 1821: my $secinfo;
1.4 raeburn 1822: if ($env{'form.sectotal'} > 0) {
1823: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
1824: if ($env{'form.sec_'.$i}) {
1.5 raeburn 1825: $secinfo .= '<tr><td>'.$env{'form.secnum_'.$i}.'</td><td>';
1.4 raeburn 1826: if ($env{'form.loncapasec_'.$i} ne '') {
1.5 raeburn 1827: $secinfo .= $env{'form.loncapasec_'.$i};
1828: } else {
1829: $secinfo .= &mt('None');
1.4 raeburn 1830: }
1.5 raeburn 1831: $secinfo .= '</td></tr>';
1.4 raeburn 1832: }
1833: }
1834: }
1.6 raeburn 1835: if ($secinfo eq '') {
1836: $secinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 1837: }
1.6 raeburn 1838: $section_values .= $secinfo.'</table></td><td>'.
1839: '<table class="LC_innerpickbox"><tr><th>'.
1840: &mt('Institutional course/section').'</th>'.
1841: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 1842: my $xlistinfo;
1.24 raeburn 1843: my $crosslisttotal = $env{'form.crosslisttotal'};
1844: if (!$crosslisttotal) {
1845: $crosslisttotal = 1;
1846: }
1847: for (my $i=0; $i<$crosslisttotal; $i++) {
1848: if ($env{'form.crosslist_'.$i}) {
1849: $xlistinfo .= '<tr><td>';
1850: if (ref($code_order) eq 'ARRAY') {
1851: if (@{$code_order} > 0) {
1852: foreach my $item (@{$code_order}) {
1853: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
1.4 raeburn 1854: }
1855: }
1856: }
1.24 raeburn 1857: $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
1858: if ($env{'form.crosslist_'.$i.'_lcsec'}) {
1859: $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
1860: } else {
1861: $xlistinfo .= &mt('None');
1862: }
1863: $xlistinfo .= '</td></tr>';
1.4 raeburn 1864: }
1865: }
1.6 raeburn 1866: if ($xlistinfo eq '') {
1867: $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 1868: }
1.24 raeburn 1869: $section_values .= $xlistinfo;
1.4 raeburn 1870: }
1.24 raeburn 1871: $section_values .= '</table></td>';
1.4 raeburn 1872: }
1873:
1874: my %ctxt = &clone_text();
1875: $inst_headers .= '<th>'.&mt('Clone From').'</th>';
1.13 raeburn 1876: if (($env{'form.clonecrs'} =~ /^$match_name$/) &&
1877: ($env{'form.clonedom'} =~ /^$match_domain$/)) {
1.15 raeburn 1878: my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
1879: $env{'user.domain'},$env{'form.clonecrs'}, $env{'form.clonedom'});
1880: if ($canclone) {
1881: my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
1882: $env{'form.clonecrs'},('description','internal.coursecode'));
1883: if (keys(%courseenv) > 0) {
1884: $inst_headers .= '<th>'.$ctxt{'dsh'}.'</th>';
1885: $inst_values .= '<td>'.$courseenv{'description'}.' ';
1886: my $cloneinst = $courseenv{'internal.coursecode'};
1887: if ($cloneinst ne '') {
1.18 raeburn 1888: $inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'};
1.15 raeburn 1889: } else {
1.18 raeburn 1890: $inst_values .= &mt('from').' '.$env{'form.clonedom'};
1.15 raeburn 1891: }
1892: $inst_values .= '</td><td>';
1893: if ($env{'form.datemode'} eq 'preserve') {
1.16 raeburn 1894: $inst_values .= $ctxt{'prd'};
1.15 raeburn 1895: } elsif ($env{'form.datemode'} eq 'shift') {
1896: $inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'});
1897: } else {
1898: $inst_values .= $ctxt{'ncd'};
1899: }
1900: $inst_values .= '</td>';
1901: } else {
1902: $inst_values .= '<td>'.&mt('Unknown').'</td>';
1903: }
1904: } else {
1905: $inst_values .= '<td>'.&mt('Not permitted'),'</td>';
1906: }
1.4 raeburn 1907: } else {
1908: $inst_values .= '<td>'.&mt('None').'</td>';
1909: }
1910: $enroll_headers .= '<th>'.&mt('Access Starts').'</th>'.
1911: '<th>'.&mt('Access Ends').'</th>';
1.13 raeburn 1912: my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
1913: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessstart).'</td>';
1914: if ($accessend == 0) {
1.4 raeburn 1915: $enroll_values .= '<td>'.&mt('No end date').'</td>';
1916: } else {
1.13 raeburn 1917: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessend).'</td>';
1.4 raeburn 1918: }
1919:
1920: my $container = 'Course';
1921: if ($env{'form.crstype'} eq 'community') {
1922: $container = 'Community';
1923: }
1924:
1925: $personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain').
1926: '</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections').
1927: '</th>';
1928: $personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'.
1929: '<td>'.&Apache::lonnet::plaintext('cc',$container).'</td>'.
1930: '<td>'.&mt('None').'</td></tr>';
1931: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
1932: if ($env{'form.person_'.$i.'_uname'} ne '') {
1.30 ! raeburn 1933: if (ref($disallowed) eq 'ARRAY') {
! 1934: next if (grep(/^$i$/,@{$disallowed}));
! 1935: }
1.14 raeburn 1936: my @allsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
1937: my $newsec = $env{'form.person_'.$i.'_newsec'};
1938: $newsec =~ s/^\s+//;
1939: $newsec =~s/\s+$//;
1940: my @newsecs = split(/[\s,;]+/,$newsec);
1941: foreach my $sec (@newsecs) {
1942: next if ($sec =~ /\W/);
1943: next if ($newsec eq 'none');
1944: if ($sec ne '') {
1945: unless (grep(/^\Q$sec\E$/,@allsecs)) {
1946: push(@allsecs,$sec);
1947: }
1948: }
1949: }
1.24 raeburn 1950: my $showsec;
1.14 raeburn 1951: if (@allsecs) {
1952: $showsec = join(', ',@allsecs);
1953: }
1.24 raeburn 1954: if ($showsec eq '') {
1955: $showsec = &mt('None');
1956: }
1957: if ($env{'form.person_'.$i.'_role'} eq 'cc') {
1958: $showsec = &mt('None');
1959: }
1.28 raeburn 1960: my $role = $env{'form.person_'.$i.'_role'};
1.4 raeburn 1961: $personnel_values .=
1.13 raeburn 1962: '<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '.
1963: $env{'form.person_'.$i.'_lastname'}.'</td>'.
1.4 raeburn 1964: '<td>'.$env{'form.person_'.$i.'_uname'}.':'.
1965: $env{'form.person_'.$i.'_dom'}.'</td>'.
1.28 raeburn 1966: '<td>'.&Apache::lonnet::plaintext($role,$container).'</td>'.
1.14 raeburn 1967: '<td>'.$showsec.'</td></tr>';
1.4 raeburn 1968: }
1969: }
1.30 ! raeburn 1970: my $output;
! 1971: if (ref($disallowed) eq 'ARRAY') {
! 1972: if (@{$disallowed} > 0) {
! 1973: if (ref($disallowmsg) eq 'HASH') {
! 1974: $output = '<p class="LC_warning">'.
! 1975: &mt('Not all requested personnel could be included.').'<ul>';
! 1976: foreach my $item (@{$disallowed}) {
! 1977: $output .= '<li>'.$disallowmsg->{$item}.'</li>';
! 1978: }
! 1979: $output .= '</ul></p>';
! 1980: }
! 1981: }
! 1982: }
! 1983: $output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box().
1.4 raeburn 1984: &Apache::lonhtmlcommon::row_title(&mt('Owner')).
1.6 raeburn 1985: '<table class="LC_innerpickbox"><tr>'.
1.4 raeburn 1986: '<th>'.&mt('Name').'</th>'.
1987: '<th>'.&mt('Username:Domain').'</th>'.
1988: '<th>'.&mt('E-mail address').'</th>'.
1989: '</tr><tr>'."\n".
1990: '<td>'.$ownername.'</td><td>'.$owner.'</td>'.
1991: '<td>'.$owneremail.'</td>'.
1992: '</tr></table>'."\n".
1993: &Apache::lonhtmlcommon::row_closure().
1.5 raeburn 1994: &Apache::lonhtmlcommon::row_title(&mt('Description')).
1.4 raeburn 1995: '<table class="LC_innerpickbox"><tr>'.$inst_headers.'</tr>'."\n".
1996: '<tr>'.$inst_values.'</tr></table>'."\n".
1997: &Apache::lonhtmlcommon::row_closure().
1.16 raeburn 1998: &Apache::lonhtmlcommon::row_title($enrollrow_title).
1.4 raeburn 1999: '<table class="LC_innerpickbox"><tr>'.$enroll_headers.'</tr>'."\n".
2000: '<tr>'.$enroll_values.'</tr></table>'."\n".
2001: &Apache::lonhtmlcommon::row_closure();
2002: if ($section_headers ne '') {
2003: $output .= &Apache::lonhtmlcommon::row_title(&mt('Sections')).
2004: '<table class="LC_innerpickbox"><tr>'.$section_headers.'</tr>'."\n".
2005: '<tr>'.$section_values.'</tr></table>'."\n".
2006: &Apache::lonhtmlcommon::row_closure();
2007: }
2008: $output .= &Apache::lonhtmlcommon::row_title(&mt('Personnel')).
2009: '<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n".
2010: $personnel_values.'</table>'."\n".
2011: &Apache::lonhtmlcommon::row_closure(1).
1.26 raeburn 2012: &Apache::lonhtmlcommon::end_pick_box().'</div>';
1.4 raeburn 2013: return $output;
2014: }
2015:
2016: sub dates_from_form {
2017: my ($startname,$endname) = @_;
2018: my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
2019: my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
1.13 raeburn 2020: if ($endname eq 'accessend') {
1.4 raeburn 2021: if (exists($env{'form.no_end_date'}) ) {
2022: $enddate = 0;
2023: }
2024: }
2025: return ($startdate,$enddate);
1.1 raeburn 2026: }
2027:
2028: sub courseinfo_form {
1.15 raeburn 2029: my ($dom,$formname,$crstype,$next) = @_;
2030: my $nodescr = &mt('You must provide a (brief) course description.');
2031: my $js_validate = <<"ENDJS";
2032: <script type="text/javascript">
2033: // <![CDATA['
2034:
2035: function validateForm() {
2036: if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) {
2037: alert('$nodescr');
2038: return;
2039: }
2040: nextPage(document.$formname,'$next');
2041: }
2042: // ]]
2043: </script>
2044:
2045: ENDJS
1.27 raeburn 2046: my $title = &mt('Brief Course Description');
2047: if ($crstype eq 'community') {
2048: $title = &mt('Brief Community Description');
2049: }
1.15 raeburn 2050: my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box().
1.27 raeburn 2051: &Apache::lonhtmlcommon::row_headline().
2052: '<h3>'.$title.'</h3>'.
2053: &Apache::lonhtmlcommon::row_closure(1).
2054: &Apache::lonhtmlcommon::row_title(&mt('Description')).
1.13 raeburn 2055: '<input type="text" size="40" name="cdescr" />';
2056: my ($home_server_pick,$numlib) =
2057: &Apache::loncommon::home_server_form_item($dom,'chome',
2058: 'default','hide');
2059: if ($numlib > 1) {
2060: $output .= &Apache::lonhtmlcommon::row_closure().
1.16 raeburn 2061: &Apache::lonhtmlcommon::row_title(&mt('Home Server for Course'));
1.13 raeburn 2062: }
2063: $output .= $home_server_pick.
1.27 raeburn 2064: &Apache::lonhtmlcommon::row_closure().
2065: &Apache::lonhtmlcommon::row_headline().
2066: '<h3>'.&mt('Clone content and settings from an existing course?').'</h3>'.
1.13 raeburn 2067: &Apache::lonhtmlcommon::row_closure(1).
1.27 raeburn 2068: &clone_form($dom,$formname,$crstype).
2069: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
1.1 raeburn 2070: return $output;
2071: }
2072:
2073: sub clone_form {
2074: my ($dom,$formname,$crstype) = @_;
2075: my $type = 'Course';
2076: if ($crstype eq 'community') {
2077: $type = 'Community';
2078: }
1.13 raeburn 2079: my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').
2080: &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type);
1.4 raeburn 2081: my %lt = &clone_text();
1.2 raeburn 2082: my $output .=
2083: &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
1.29 raeburn 2084: '<input type="text" size="25" name="clonecrs" value="" />'.
1.2 raeburn 2085: '</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'.
2086: &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'.
1.27 raeburn 2087: $cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 2088: &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.
2089: '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
2090: '</label><br /><label>'.
2091: '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
2092: '</label><br /><label>'.
2093: '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
2094: $lt{'shd'}.'</label>'.
2095: '<input type="text" size="5" name="dateshift" value="365" />'.
1.27 raeburn 2096: &Apache::lonhtmlcommon::row_closure(1);
1.1 raeburn 2097: return $output;
2098: }
2099:
1.16 raeburn 2100: sub clone_text {
1.4 raeburn 2101: return &Apache::lonlocal::texthash(
2102: 'cid' => 'Course ID',
2103: 'dmn' => 'Domain',
2104: 'dsh' => 'Date Shift',
2105: 'ncd' => 'Do not clone date parameters',
2106: 'prd' => 'Clone date parameters as-is',
2107: 'shd' => 'Shift date parameters by number of days',
2108: );
2109: }
2110:
1.1 raeburn 2111: sub coursecode_form {
1.2 raeburn 2112: my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;
1.1 raeburn 2113: my $output;
1.2 raeburn 2114: my %rowtitle = (
2115: instcode => 'Course Category',
2116: crosslist => 'Cross Listed Course',
2117: );
1.1 raeburn 2118: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&
2119: (ref($cat_order))) {
1.2 raeburn 2120: my ($sel,$instsec,$lcsec);
2121: $sel = $context;
2122: if ($context eq 'crosslist') {
2123: $sel .= '_'.$num;
2124: $instsec = &mt('Institutional section').'<br />'.
2125: '<input type="text" size="10" name="'.$sel.'_instsec" />';
2126: $lcsec = &mt('LON-CAPA section').'<br />'.
2127: '<input type="text" size="10" name="'.$sel.'_lcsec" />';
2128: }
1.1 raeburn 2129: if (@{$codetitles} > 0) {
2130: my $lastitem = pop(@{$codetitles});
1.2 raeburn 2131: my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />';
1.1 raeburn 2132: if (@{$codetitles} > 0) {
1.2 raeburn 2133: $output = &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
2134: '<table><tr>';
1.1 raeburn 2135: if ($context eq 'crosslist') {
1.2 raeburn 2136: $output .= '<td>'.&mt('Include?').'<br />'.
2137: '<input type="checkbox" name="'.$sel.'" value="1" /></td>';
1.1 raeburn 2138: }
2139: foreach my $title (@{$codetitles}) {
2140: if (ref($cat_order->{$title}) eq 'ARRAY') {
2141: if (@{$cat_order->{$title}} > 0) {
2142: $output .= '<td align="center">'.$title.'<br />'."\n".
2143: '<select name="'.$sel.'_'.$title.'">'."\n".
2144: ' <option value="" selected="selected">'.
2145: &mt('Select').'</option>'."\n";
2146: foreach my $item (@{$cat_order->{$title}}) {
2147: my $longitem = $item;
2148: if (ref($cat_titles->{$title}) eq 'HASH') {
2149: if ($cat_titles->{$title}{$item} ne '') {
2150: $longitem = $cat_titles->{$title}{$item};
2151: }
2152: }
2153: $output .= '<option value="'.$item.'">'.$longitem.
2154: '</option>'."\n";
2155: }
2156: }
2157: $output .= '</select></td>'."\n";
2158: }
2159: }
2160: if ($context eq 'crosslist') {
2161: $output .= '<td align="center">'.$lastitem.'<br />'."\n".
1.2 raeburn 2162: $lastinput.'</td><td align="center">'.$instsec.'</td>'.
2163: '<td align="center">'.$lcsec.'</td></tr></table>';
1.1 raeburn 2164: } else {
2165: $output .= '</tr></table>'.
2166: &Apache::lonhtmlcommon::row_closure().
2167: &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
2168: $lastinput;
2169: }
2170: } else {
2171: if ($context eq 'crosslist') {
2172: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
1.2 raeburn 2173: '<table><tr>'.
2174: '<td align="center">'.$lastitem.'<br />'.$lastinput.'</td>'.
2175: '<td align="center">'.$instsec.'</td><td>'.$lcsec.'</td>'.
2176: '</tr></table>';
1.1 raeburn 2177: } else {
2178: $output .= &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
2179: $lastinput;
2180: }
2181: }
1.2 raeburn 2182: $output .= &Apache::lonhtmlcommon::row_closure(1);
2183: push(@$codetitles,$lastitem);
2184: } elsif ($context eq 'crosslist') {
2185: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
2186: '<table><tr><td align="center">'.
2187: '<span class="LC_nobreak">'.&mt('Include?').
2188: '<input type="checkbox" name="'.$sel.'" value="1" /></span>'.
2189: '</td><td align="center">'.&mt('Institutional ID').'<br />'.
2190: '<input type="text" size="10" name="'.$sel.'_instsec" />'.
2191: '</td><td align="center">'.$lcsec.'</td></tr></table>'.
2192: &Apache::lonhtmlcommon::row_closure(1);
1.1 raeburn 2193: }
2194: }
2195: return $output;
2196: }
2197:
2198: sub get_course_dom {
2199: my $codedom = &Apache::lonnet::default_login_domain();
1.19 raeburn 2200: if ($env{'form.showdom'} ne '') {
2201: if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
2202: return $env{'form.showdom'};
2203: }
2204: }
1.1 raeburn 2205: if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
1.19 raeburn 2206: my ($types,$typename) = &course_types();
2207: if (ref($types) eq 'ARRAY') {
2208: foreach my $type (@{$types}) {
2209: if (&Apache::lonnet::usertools_access($env{'user.name'},
2210: $env{'user.domain'},$type,
2211: undef,'requestcourses')) {
2212: return $env{'user.domain'};
2213: }
2214: }
2215: my @possible_doms;
2216: foreach my $type (@{$types}) {
2217: my $dom_str = $env{'environment.reqcrsotherdom.'.$type};
2218: if ($dom_str ne '') {
2219: my @domains = split(',',$dom_str);
2220: foreach my $entry (@domains) {
2221: my ($extdom,$extopt) = split(':',$entry);
2222: if ($extdom eq $env{'request.role.domain'}) {
2223: return $extdom;
2224: }
2225: unless(grep(/^\Q$extdom\E$/,@possible_doms)) {
2226: push(@possible_doms,$extdom);
2227: }
2228: }
2229: }
2230: }
2231: if (@possible_doms) {
2232: @possible_doms = sort(@possible_doms);
2233: return $possible_doms[0];
2234: }
2235: }
1.1 raeburn 2236: $codedom = $env{'user.domain'};
2237: if ($env{'request.role.domain'} ne '') {
2238: $codedom = $env{'request.role.domain'};
2239: }
2240: }
2241: return $codedom;
2242: }
2243:
2244: sub display_navbuttons {
1.16 raeburn 2245: my ($r,$formname,$prev,$prevtext,$next,$nexttext,$state,$other,$othertext) = @_;
1.1 raeburn 2246: $r->print('<div class="LC_navbuttons">');
2247: if ($prev) {
1.16 raeburn 2248: $r->print('<input type="button" name="previous" value = "'.$prevtext.'" '.
2249: 'onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/>'.
2250: (' 'x3));
1.1 raeburn 2251: } elsif ($prevtext) {
1.16 raeburn 2252: $r->print('<input type="button" name="previous" value = "'.$prevtext.'" '.
2253: 'onclick="javascript:history.back()"/>'.(' 'x3));
2254: }
2255: if ($state eq 'details') {
2256: $r->print(' <input type="button" name="other" value="'.$othertext.'" '.
2257: 'onclick="javascript:nextPage(document.'.$formname.','."'".$other."'".
2258: ')" />');
1.1 raeburn 2259: }
1.15 raeburn 2260: if ($state eq 'courseinfo') {
1.16 raeburn 2261: $r->print('<input type="button" name="next" value="'.$nexttext.'" '.
2262: 'onclick="javascript:validateForm();" />');
1.15 raeburn 2263: } elsif ($next) {
1.1 raeburn 2264: $r->print('
1.16 raeburn 2265: <input type="button" name="next" value="'.$nexttext.'" '.
2266: 'onclick="javascript:nextPage(document.'.$formname.','."'".$next."'".')" />');
1.1 raeburn 2267: }
2268: $r->print('</div>');
2269: }
2270:
2271: sub print_request_outcome {
1.10 raeburn 2272: my ($dom,$codetitles,$code_order) = @_;
1.13 raeburn 2273: my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
1.10 raeburn 2274: %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
1.24 raeburn 2275: my $sectotal = $env{'form.sectotal'};
2276: my $crosslisttotal = 0;
1.10 raeburn 2277: $cnum = $env{'form.cnum'};
1.8 raeburn 2278: unless ($cnum =~ /^$match_courseid$/) {
2279: $output = &mt('Invalid LON-CAPA course number for the new course')."\n";
2280: return $output;
2281: }
1.11 raeburn 2282:
1.10 raeburn 2283: %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
1.9 raeburn 2284: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
2285: if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') {
2286: $req_notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
2287: }
2288: }
1.10 raeburn 2289: $now = time;
2290: $crstype = $env{'form.crstype'};
1.17 raeburn 2291: my @instsections;
1.8 raeburn 2292: if ($crstype eq 'official') {
2293: if (&Apache::lonnet::auto_run('',$dom)) {
1.13 raeburn 2294: ($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend');
1.8 raeburn 2295: }
1.10 raeburn 2296: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
2297: if ($env{'form.sec_'.$i}) {
2298: if ($env{'form.secnum_'.$i} ne '') {
1.17 raeburn 2299: my $sec = $env{'form.secnum_'.$i};
2300: $sections{$i}{'inst'} = $sec;
2301: if (($sec ne '') && (!grep(/^\Q$sec\E$/,@instsections))) {
2302: push(@instsections,$sec);
2303: }
1.13 raeburn 2304: $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
1.10 raeburn 2305: }
2306: }
2307: }
2308: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
2309: if ($env{'form.crosslist_'.$i}) {
2310: my $xlistinfo = '';
2311: if (ref($code_order) eq 'ARRAY') {
2312: if (@{$code_order} > 0) {
2313: foreach my $item (@{$code_order}) {
2314: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
2315: }
2316: }
2317: }
1.22 raeburn 2318: $crosslistings{$i}{'instcode'} = $xlistinfo;
1.24 raeburn 2319: if ($xlistinfo ne '') {
2320: $crosslisttotal ++;
2321: }
1.22 raeburn 2322: $crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'};
1.13 raeburn 2323: $crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};
1.10 raeburn 2324: }
2325: }
1.14 raeburn 2326: } else {
2327: $enrollstart = '';
2328: $enrollend = '';
1.10 raeburn 2329: }
2330: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
2331: my $uname = $env{'form.person_'.$i.'_uname'};
1.16 raeburn 2332: my $udom = $env{'form.person_'.$i.'_dom'};
1.10 raeburn 2333: if (($uname =~ /^$match_username$/) && ($udom =~ /^$match_domain$/)) {
2334: if (&Apache::lonnet::domain($udom) ne '') {
1.13 raeburn 2335: unless (ref($personnel{$uname.':'.$udom}) eq 'HASH') {
2336: $personnel{$uname.':'.$udom} = {
2337: firstname => $env{'form.person_'.$i.'_firstname'},
2338: lastname => $env{'form.person_'.$i.'_lastname'},
2339: emailaddr => $env{'form.person_'.$i.'_emailaddr'},
2340: };
2341: }
2342: my $role = $env{'form.person_'.$i.'_role'};
2343: unless ($role eq '') {
1.16 raeburn 2344: if (ref($personnel{$uname.':'.$udom}{'roles'}) eq 'ARRAY') {
1.13 raeburn 2345: my @curr_roles = @{$personnel{$uname.':'.$udom}{'roles'}};
2346: unless (grep(/^\Q$role\E$/,@curr_roles)) {
2347: push(@{$personnel{$uname.':'.$udom}{'roles'}},$role);
2348: }
2349: } else {
2350: @{$personnel{$uname.':'.$udom}{'roles'}} = ($role);
2351: }
2352: if ($role eq 'cc') {
2353: @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = ();
2354: } else {
1.14 raeburn 2355: my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
2356: my $newsec = $env{'form.person_'.$i.'_newsec'};
2357: $newsec =~ s/^\s+//;
2358: $newsec =~s/\s+$//;
2359: my @newsecs = split(/[\s,;]+/,$newsec);
2360: foreach my $sec (@newsecs) {
2361: next if ($sec =~ /\W/);
2362: next if ($newsec eq 'none');
2363: if ($sec ne '') {
2364: unless (grep(/^\Q$sec\E$/,@currsec)) {
2365: push(@currsec,$sec);
1.13 raeburn 2366: }
2367: }
2368: }
2369: @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = @currsec;
2370: }
2371: }
1.10 raeburn 2372: } else {
2373: push(@missingdom,$uname.':'.$udom);
2374: }
2375: } else {
2376: push(@baduname,$uname.':'.$udom);
2377: }
1.8 raeburn 2378: }
1.13 raeburn 2379: my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
1.14 raeburn 2380: my $autodrops = 0;
2381: if ($env{'form.autodrops'}) {
2382: $autodrops = $env{'form.autodrops'};
2383: }
2384: my $autoadds = 0;
2385: if ($env{'form.autoadds'}) {
2386: $autodrops = $env{'form.autoadds'};
2387: }
2388: if ($env{'form.autoadds'}) {
2389: $autodrops = $env{'form.autoadds'};
2390: }
2391: my $instcode = '';
2392: if (exists($env{'form.instcode'})) {
2393: $instcode = $env{'form.instcode'};
2394: }
1.15 raeburn 2395: my $clonecrs = '';
2396: my $clonedom = '';
2397: if (($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
2398: ($env{'form.clonedom'} =~ /^($match_domain)$/)) {
1.16 raeburn 2399: my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
2400: $env{'form.clonedom'});
1.15 raeburn 2401: if ($clonehome ne 'no_host') {
1.16 raeburn 2402: my $canclone =
2403: &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
2404: $env{'user.domain'},$env{'form.clonecrs'}, $env{'form.clonedom'});
1.15 raeburn 2405: if ($canclone) {
2406: $clonecrs = $env{'form.clonecrs'};
2407: $clonedom = $env{'form.clonedom'};
2408: }
2409: }
2410: }
1.8 raeburn 2411: my $details = {
1.10 raeburn 2412: owner => $env{'user.name'},
2413: domain => $env{'user.domain'},
2414: cdom => $dom,
1.11 raeburn 2415: cnum => $cnum,
1.13 raeburn 2416: coursehome => $env{'form.chome'},
2417: cdescr => $env{'form.cdescr'},
1.10 raeburn 2418: crstype => $env{'form.crstype'},
1.14 raeburn 2419: instcode => $instcode,
1.15 raeburn 2420: clonedom => $clonedom,
2421: clonecrs => $clonecrs,
1.10 raeburn 2422: datemode => $env{'form.datemode'},
1.14 raeburn 2423: dateshift => $env{'form.dateshift'},
2424: sectotal => $sectotal,
1.10 raeburn 2425: sections => \%sections,
1.14 raeburn 2426: crosslisttotal => $crosslisttotal,
1.13 raeburn 2427: crosslists => \%crosslistings,
1.14 raeburn 2428: autoadds => $autoadds,
2429: autodrops => $autodrops,
1.13 raeburn 2430: enrollstart => $enrollstart,
2431: enrollend => $enrollend,
2432: accessstart => $accessstart,
2433: accessend => $accessend,
1.10 raeburn 2434: personnel => \%personnel,
1.8 raeburn 2435: };
1.27 raeburn 2436: my (@inststatuses,$storeresult,$creationresult);
1.9 raeburn 2437: my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
1.8 raeburn 2438: if ($val eq '') {
2439: if ($crstype eq 'official') {
1.19 raeburn 2440: $output = &mt('You are not permitted to request creation of official courses.');
1.8 raeburn 2441: } elsif ($crstype eq 'unofficial') {
1.19 raeburn 2442: $output = &mt('You are not permitted to request creation of unofficial courses.');
1.8 raeburn 2443: } elsif ($crstype eq 'community') {
2444: $output = &mt('You are not permitted to request creation of communities');
2445: } else {
2446: $output = &mt('Unrecognized course type: [_1]',$crstype);
2447: }
1.27 raeburn 2448: $storeresult = 'notpermitted';
1.8 raeburn 2449: } else {
1.14 raeburn 2450: my ($disposition,$message,$reqstatus);
1.8 raeburn 2451: my %reqhash = (
1.14 raeburn 2452: reqtime => $now,
1.10 raeburn 2453: crstype => $crstype,
2454: details => $details,
1.8 raeburn 2455: );
2456: my $requestkey = $dom.'_'.$cnum;
1.17 raeburn 2457: my $validationerror;
1.10 raeburn 2458: if ($val eq 'autolimit=') {
2459: $disposition = 'process';
2460: } elsif ($val =~ /^autolimit=(\d+)$/) {
2461: my $limit = $1;
1.8 raeburn 2462: $disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
1.10 raeburn 2463: $dom,$crstype,$limit,\$message);
1.8 raeburn 2464: } elsif ($val eq 'validate') {
1.21 raeburn 2465: my ($inststatuslist,$validationchk,$validation);
1.17 raeburn 2466: if (@inststatuses > 0) {
2467: $inststatuslist = join(',',@inststatuses);
2468: }
2469: my $instseclist;
2470: if (@instsections > 0) {
2471: $instseclist = join(',',@instsections);
2472: }
1.21 raeburn 2473: $validationchk =
2474: &Apache::lonnet::auto_courserequest_validation($dom,
2475: $env{'user.name'}.':'.$env{'user.domain'},$crstype,
2476: $inststatuslist,$instcode,$instseclist);
2477: if ($validationchk =~ /:/) {
2478: ($validation,$message) = split(':',$validationchk);
2479: } else {
2480: $validation = $validationchk;
2481: }
2482: if ($validation =~ /^error(.*)$/) {
1.17 raeburn 2483: $disposition = 'approval';
2484: $validationerror = $1;
1.23 raeburn 2485: } else {
2486: $disposition = $validation;
1.17 raeburn 2487: }
1.8 raeburn 2488: } else {
2489: $disposition = 'approval';
2490: }
1.14 raeburn 2491: $reqhash{'disposition'} = $disposition;
2492: $reqstatus = $disposition;
1.16 raeburn 2493: my ($modified,$queued);
1.8 raeburn 2494: if ($disposition eq 'rejected') {
2495: $output = &mt('Your course request was rejected.');
2496: if ($message) {
2497: $output .= '<div class="LC_warning">'.$message.'</div>';
2498: }
1.27 raeburn 2499: $storeresult = 'rejected';
1.8 raeburn 2500: } elsif ($disposition eq 'process') {
1.14 raeburn 2501: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
2502: my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles);
2503: my @roles = &Apache::lonuserutils::roles_by_context('course');
1.8 raeburn 2504: my $type = 'Course';
2505: if ($crstype eq 'community') {
2506: $type = 'Community';
2507: }
2508: foreach my $role (@roles) {
2509: $longroles{$role}=&Apache::lonnet::plaintext($role,$type);
2510: }
1.14 raeburn 2511: my $result = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
2512: 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
2513: \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles);
2514: if ($result eq 'created') {
1.8 raeburn 2515: $disposition = 'created';
1.14 raeburn 2516: $reqstatus = 'created';
1.28 raeburn 2517: my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details,
2518: \%longroles);
2519: $output = '<p>'.&mt('Your course request has been processed and the course has been created.').
2520: '<br />'.$role_result.'</p>';
1.27 raeburn 2521: $creationresult = 'created';
1.8 raeburn 2522: } else {
1.14 raeburn 2523: $output = '<span class="LC_error">'.
2524: &mt('An error occurred when processing your course request.').
2525: '<br />'.
2526: &mt('You may want to review the request details and submit the request again.').
2527: '</span>';
1.27 raeburn 2528: $creationresult = 'error';
1.8 raeburn 2529: }
2530: } else {
2531: my $requestid = $cnum.'_'.$disposition;
2532: my $request = {
2533: $requestid => {
2534: timestamp => $now,
2535: crstype => $crstype,
2536: ownername => $env{'user.name'},
2537: ownerdom => $env{'user.domain'},
1.13 raeburn 2538: description => $env{'form.cdescr'},
1.8 raeburn 2539: },
2540: };
1.16 raeburn 2541: my $statuskey = 'status:'.$dom.':'.$cnum;
2542: my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
2543: $env{'user.domain'},$env{'user.name'});
1.17 raeburn 2544: if ($userreqhash{$statuskey} ne '') {
1.16 raeburn 2545: $modified = 1;
1.25 raeburn 2546: my $uname = &Apache::lonnet::get_domainconfiguser($dom);
2547: my %queuehash = &Apache::lonnet::get('courserequestqueue',
2548: [$cnum.'_approval',
2549: $cnum.'_pending'],$dom,$uname);
1.17 raeburn 2550: if (($queuehash{$cnum.'_approval'} ne '') ||
2551: ($queuehash{$cnum.'_pending'} ne '')) {
1.16 raeburn 2552: $queued = 1;
2553: }
2554: }
2555: unless ($queued) {
2556: my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,
2557: $dom);
2558: if ($putresult eq 'ok') {
2559: $output = &mt('Your course request has been recorded.').'<br />'.
2560: ¬ification_information($disposition,$req_notifylist,
2561: $cnum,$now);
1.8 raeburn 2562: } else {
1.16 raeburn 2563: $reqstatus = 'domainerror';
2564: $reqhash{'disposition'} = $disposition;
2565: my $warning = &mt('An error occurred saving your request in the pending requests queue.');
2566: $output = '<span class"LC_warning">'.$warning.'</span><br />';
1.8 raeburn 2567: }
2568: }
2569: }
1.27 raeburn 2570: my ($statusresult);
1.10 raeburn 2571: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
2572: $storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
2573: 'courserequests');
1.14 raeburn 2574: if ($storeresult eq 'ok') {
2575: my %status = (
2576: 'status:'.$dom.':'.$cnum => $reqstatus,
2577: );
1.27 raeburn 2578: $statusresult = &Apache::lonnet::put('courserequests',\%status);
1.14 raeburn 2579: }
1.10 raeburn 2580: } else {
2581: $storeresult = 'error: invalid requestkey format';
2582: }
1.8 raeburn 2583: if ($storeresult ne 'ok') {
1.13 raeburn 2584: $output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).'</span><br />';
2585: &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
1.14 raeburn 2586: } elsif ($statusresult ne 'ok') {
1.28 raeburn 2587: $output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).'</span><br />';
1.14 raeburn 2588: &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
1.8 raeburn 2589: }
1.16 raeburn 2590: if ($modified && $queued && $storeresult eq 'ok') {
2591: $output .= '<p>'.&mt('Your course request has been updated').'</p>'.
2592: ¬ification_information($disposition,$req_notifylist,$cnum,$now);
2593: }
1.17 raeburn 2594: if ($validationerror ne '') {
1.19 raeburn 2595: $output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>';
1.17 raeburn 2596: }
1.16 raeburn 2597: }
1.27 raeburn 2598: if ($creationresult ne '') {
2599: return ($creationresult,$output);
2600: } else {
2601: return ($storeresult,$output);
2602: }
1.16 raeburn 2603: }
2604:
1.28 raeburn 2605: sub update_requestors_roles {
2606: my ($dom,$cnum,$crstype,$details,$longroles) = @_;
2607: my $now = time;
2608: my ($active,$future,$numactive,$numfuture,$output);
2609: my $owner = $env{'user.name'}.':'.$env{'user.domain'};
2610: if (ref($details) eq 'HASH') {
2611: if (ref($details->{'personnel'}) eq 'HASH') {
2612: if (ref($details->{'personnel'}{$owner}) eq 'HASH') {
2613: my @roles;
2614: if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
2615: @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
2616: unless (grep(/^cc$/,@roles)) {
2617: push(@roles,'cc');
2618: }
2619: } else {
2620: @roles = ('cc');
2621: }
2622: foreach my $role (@roles) {
2623: my $start = $now;
2624: my $end = '0';
2625: if ($role eq 'st') {
2626: if ($details->{'accessstart'} ne '') {
2627: $start = $details->{'accessstart'};
2628: }
2629: if ($details->{'accessend'} ne '') {
2630: $end = $details->{'accessend'};
2631: }
2632: }
2633: my @usecs;
2634: if ($role ne 'cc') {
2635: if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
2636: @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
2637: }
2638: }
2639: if ($role eq 'st') {
2640: if (@usecs > 1) {
2641: my $firstsec = $usecs[0];
2642: @usecs = ($firstsec);
2643: }
2644: }
2645: if (@usecs == 0) {
2646: push(@usecs,'');
2647: }
2648: foreach my $usec (@usecs) {
2649: my (%userroles,%newrole,%newgroups,$spec,$area);
2650: my $area = '/'.$dom.'/'.$cnum;
2651: my $spec = $role.'.'.$area;
2652: if ($usec ne '') {
2653: $spec .= '/'.$usec;
2654: $area .= '/'.$usec;
2655: }
2656: if ($role =~ /^cr\//) {
2657: &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,
2658: $cnum,$spec,$area);
2659: } else {
2660: &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,
2661: $spec,$cnum,$area);
2662: }
2663: &Apache::lonnet::set_userprivs(\%userroles,\%newrole,
2664: \%newgroups);
2665: $userroles{'user.role.'.$spec} = $start.'.'.$end;
2666: &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
2667: if (($end == 0) || ($end > $now)) {
2668: my $showrole = $role;
2669: if ($role =~ /^cr\//) {
2670: $showrole = &Apache::lonnet::plaintext($role,$crstype);
2671: } elsif (ref($longroles) eq 'HASH') {
2672: if ($longroles->{$role} ne '') {
2673: $showrole = $longroles->{$role};
2674: }
2675: }
2676: if ($start <= $now) {
2677: $active .= '<li><a href="/adm/roles?selectrole=1&'. $spec.'=1">'.$showrole;
2678: if ($usec ne '') {
2679: $active .= ' - '.&mt('section:').' '.$usec;
2680: }
2681: $active .= '</a></li>';
2682: $numactive ++;
2683: } else {
2684: $future .= '<li>'.$showrole;
2685: if ($usec ne '') {
2686: $future .= ' - '.&mt('section:').' '.$usec;
2687: }
2688: $future .= '</li>';
2689: $numfuture ++;
2690: }
2691: }
2692: }
2693: }
2694: }
2695: }
2696: }
2697: if ($active) {
2698: if ($numactive == 1) {
2699: $output = &mt('Use the following link to enter the course:');
2700: } else {
2701: $output = &mt('Use the following links to your new roles to enter the course:');
2702: }
2703: $output .= ' <ul>'.$active.'</ul><br />';
2704: }
2705: if ($future) {
2706: $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'})).
2707: ' <ul>'.$future.'</ul>';
2708: }
2709: return $output;
2710: }
2711:
1.16 raeburn 2712: sub notification_information {
2713: my ($disposition,$req_notifylist,$cnum,$now) = @_;
2714: my %emails = &Apache::loncommon::getemails();
2715: my $address;
2716: if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
2717: $address = $emails{'permanentemail'};
2718: if ($address eq '') {
2719: $address = $emails{'notification'};
2720: }
2721: }
2722: my $output;
2723: if ($disposition eq 'approval') {
2724: $output .= &mt('A message will be sent to your LON-CAPA account when a domain coordinator takes action on your request.').'<br />'.
2725: &mt('To access your LON-CAPA message, go to the Main Menu and click on "Send and Receive Messages".').'<br />';
2726: if ($address ne '') {
2727: $output.= &mt('An e-mail will also be sent to: [_1] when this occurs.',$address).'<br />';
2728: }
2729: if ($req_notifylist) {
2730: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
2731: $env{'user.domain'});
2732: my $sender = $env{'user.name'}.':'.$env{'user.domain'};
2733: &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);
2734: }
1.17 raeburn 2735: } elsif ($disposition eq 'pending') {
1.16 raeburn 2736: $output .= '<div class="LC_info">'.
2737: &mt('Your request has been placed in a queue pending administrative action.').'<br />'.
2738: &mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'.
2739: &mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
2740: '</div>';
1.17 raeburn 2741: } else {
2742: $output .= '<div class="LC_warning">'.
2743: &mt('Your request status is: [_1].',$disposition).
2744: '</div>'
1.8 raeburn 2745: }
2746: return $output;
2747: }
2748:
2749: sub get_processtype {
1.9 raeburn 2750: my ($dom,$crstype,$inststatuses,$domconfig) = @_;
2751: return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
1.8 raeburn 2752: my (%userenv,%settings,$val);
1.19 raeburn 2753: my @options = ('autolimit','validate','approval');
1.8 raeburn 2754: if ($dom eq $env{'user.domain'}) {
2755: %userenv =
2756: &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
2757: 'requestcourses.'.$crstype,'inststatus');
2758: if ($userenv{'requestcourses.'.$crstype}) {
2759: $val = $userenv{'requestcourses.'.$crstype};
2760: @{$inststatuses} = ('_custom_');
2761: } else {
2762: my ($task,%alltasks);
1.9 raeburn 2763: if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
2764: %settings = %{$domconfig->{'requestcourses'}};
1.8 raeburn 2765: if (ref($settings{$crstype}) eq 'HASH') {
1.23 raeburn 2766: if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
1.8 raeburn 2767: $val = $settings{$crstype}{'_LC_adv'};
2768: @{$inststatuses} = ('_LC_adv_');
2769: } else {
2770: if ($userenv{'inststatus'} ne '') {
2771: @{$inststatuses} = split(',',$userenv{'inststatus'});
2772: } else {
1.13 raeburn 2773: @{$inststatuses} = ('default');
1.8 raeburn 2774: }
2775: foreach my $status (@{$inststatuses}) {
2776: if (exists($settings{$crstype}{$status})) {
2777: my $value = $settings{$crstype}{$status};
2778: next unless ($value);
2779: unless (exists($alltasks{$value})) {
2780: if (ref($alltasks{$value}) eq 'ARRAY') {
2781: unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
2782: push(@{$alltasks{$value}},$status);
2783: }
2784: } else {
2785: @{$alltasks{$value}} = ($status);
2786: }
2787: }
2788: }
2789: }
2790: my $maxlimit = 0;
1.13 raeburn 2791:
1.8 raeburn 2792: foreach my $key (sort(keys(%alltasks))) {
2793: if ($key =~ /^autolimit=(\d*)$/) {
2794: if ($1 eq '') {
2795: $val ='autolimit=';
2796: last;
2797: } elsif ($1 > $maxlimit) {
2798: $maxlimit = $1;
2799: }
2800: }
2801: }
2802: if ($maxlimit) {
2803: $val = 'autolimit='.$maxlimit;
2804: } else {
2805: foreach my $option (@options) {
2806: if ($alltasks{$option}) {
2807: $val = $option;
2808: last;
2809: }
2810: }
2811: }
2812: }
2813: }
2814: }
2815: }
2816: } else {
2817: %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},
2818: $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'});
1.19 raeburn 2819: if ($userenv{'reqcrsotherdom.'.$crstype}) {
2820: my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
2821: my $optregex = join('|',@options);
2822: foreach my $item (@doms) {
2823: my ($extdom,$extopt) = split(':',$item);
2824: if ($extdom eq $dom) {
2825: if ($extopt =~ /^($optregex)(=?\d*)$/) {
2826: $val = $1.$2;
2827: }
2828: last;
2829: }
1.8 raeburn 2830: }
2831: @{$inststatuses} = ('_external_');
2832: }
2833: }
2834: return $val;
2835: }
2836:
2837: sub check_autolimit {
1.10 raeburn 2838: my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
2839: my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
2840: 'userroles',['active','future'],['cc'],[$dom]);
2841: my ($types,$typename) = &course_types();
2842: my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);
2843: my %count;
2844: if (ref($types) eq 'ARRAY') {
2845: foreach my $type (@{$types}) {
2846: $count{$type} = 0;
2847: }
2848: }
2849: foreach my $key (keys(%requests)) {
2850: my ($cdom,$cnum) = split('_',$key);
2851: if (exists($crsroles{$cnum.':'.$cdom.':cc'})) {
2852: if (ref($requests{$key}) eq 'HASH') {
2853: my $type = $requests{$key}{'crstype'};
2854: if ($type =~ /^official|unofficial|community$/) {
2855: $count{$type} ++;
2856: }
2857: }
2858: }
2859: }
2860: if ($count{$crstype} < $limit) {
2861: return 'process';
2862: } else {
2863: if (ref($typename) eq 'HASH') {
2864: $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').'<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit);
2865: }
2866: return 'rejected';
2867: }
1.1 raeburn 2868: return;
2869: }
2870:
1.2 raeburn 2871: sub retrieve_settings {
1.26 raeburn 2872: my ($dom,$cnum,$udom,$uname) = @_;
2873: if ($udom eq '' || $uname eq '') {
2874: $udom = $env{'user.domain'};
2875: $uname = $env{'user.name'};
2876: }
2877: my ($result,%reqinfo) = &get_request_settings($dom,$cnum,$udom,$uname);
1.16 raeburn 2878: if ($result eq 'ok') {
1.26 raeburn 2879: if (($udom eq $reqinfo{'domain'}) && ($uname eq $reqinfo{'owner'})) {
1.16 raeburn 2880: $env{'form.chome'} = $reqinfo{'coursehome'};
2881: $env{'form.cdescr'} = $reqinfo{'cdescr'};
2882: $env{'form.crstype'} = $reqinfo{'crstype'};
2883: &generate_date_items($reqinfo{'accessstart'},'accessstart');
2884: &generate_date_items($reqinfo{'accessend'},'accessend');
2885: if ($reqinfo{'accessend'} == 0) {
2886: $env{'form.no_end_date'} = 1;
2887: }
2888: if (($reqinfo{'crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
2889: &generate_date_items($reqinfo{'enrollstart'},'enrollstart');
2890: &generate_date_items($reqinfo{'enrollend'},'enrollend');
2891: }
2892: $env{'form.clonecrs'} = $reqinfo{'clonecrs'};
2893: $env{'form.clonedom'} = $reqinfo{'clonedom'};
2894: $env{'form.datemode'} = $reqinfo{'datemode'};
2895: $env{'form.dateshift'} = $reqinfo{'dateshift'};
2896: if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {
2897: $env{'form.sectotal'} = $reqinfo{'sectotal'};
2898: $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
2899: $env{'form.autoadds'} = $reqinfo{'autoadds'};
2900: $env{'form.autdrops'} = $reqinfo{'autodrops'};
2901: $env{'form.instcode'} = $reqinfo{'instcode'};
1.24 raeburn 2902: my $crscode = {
2903: $cnum => $reqinfo{'instcode'},
2904: };
2905: &extract_instcode($dom,'instcode',$crscode,$cnum);
1.16 raeburn 2906: }
2907: my @currsec;
2908: if (ref($reqinfo{'sections'}) eq 'HASH') {
2909: foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {
2910: if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {
1.24 raeburn 2911: my $sec = $reqinfo{'sections'}{$i}{'inst'};
1.16 raeburn 2912: $env{'form.secnum_'.$i} = $sec;
1.24 raeburn 2913: $env{'form.sec_'.$i} = '1';
1.16 raeburn 2914: if (!grep(/^\Q$sec\E$/,@currsec)) {
2915: push(@currsec,$sec);
2916: }
2917: $env{'form.loncapasec_'.$i} = $reqinfo{'sections'}{$i}{'loncapa'};
2918: }
2919: }
2920: }
1.24 raeburn 2921: if (ref($reqinfo{'crosslists'}) eq 'HASH') {
2922: foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) {
2923: if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') {
2924: $env{'form.crosslist_'.$i} = '1';
2925: $env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'};
2926: $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'};
2927: if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') {
2928: my $key = $cnum.$i;
2929: my $crscode = {
2930: $key => $reqinfo{'crosslists'}{$i}{'instcode'},
2931: };
2932: &extract_instcode($dom,'crosslist',$crscode,$key,$i);
2933: }
1.16 raeburn 2934: }
2935: }
2936: }
2937: if (ref($reqinfo{'personnel'}) eq 'HASH') {
2938: my $i = 0;
2939: foreach my $user (sort(keys(%{$reqinfo{'personnel'}}))) {
2940: my ($uname,$udom) = split(':',$user);
2941: if (ref($reqinfo{'personnel'}{$user}) eq 'HASH') {
2942: if (ref($reqinfo{'personnel'}{$user}{'roles'}) eq 'ARRAY') {
2943: foreach my $role (sort(@{$reqinfo{'personnel'}{$user}{'roles'}})) {
2944: $env{'form.person_'.$i.'_role'} = $role;
2945: $env{'form.person_'.$i.'_firstname'} = $reqinfo{'personnel'}{$user}{'firstname'};
2946: $env{'form.person_'.$i.'_lastname'} = $reqinfo{'personnel'}{$user}{'lastname'}; ;
2947: $env{'form.person_'.$i.'_emailaddr'} = $reqinfo{'personnel'}{$user}{'emailaddr'};
2948: $env{'form.person_'.$i.'_uname'} = $uname;
2949: $env{'form.person_'.$i.'_dom'} = $udom;
2950: if (ref($reqinfo{'personnel'}{$user}{$role}) eq 'HASH') {
2951: if (ref($reqinfo{'personnel'}{$user}{$role}{'usec'}) eq 'ARRAY') {
2952: my @usecs = @{$reqinfo{'personnel'}{$user}{$role}{'usec'}};
2953: my @newsecs;
2954: if (@usecs > 0) {
2955: foreach my $sec (@usecs) {
2956: if (grep(/^\Q$sec\E/,@currsec)) {
2957: $env{'form.person_'.$i.'_sec'} = $sec;
2958: } else {
1.20 raeburn 2959: push(@newsecs,$sec);
1.16 raeburn 2960: }
2961: }
2962: }
2963: if (@newsecs > 0) {
2964: $env{'form.person_'.$i.'_newsec'} = join(',',@newsecs);
2965: }
2966: }
2967: }
2968: $i ++;
2969: }
2970: }
2971: }
2972: }
2973: $env{'form.persontotal'} = $i;
2974: }
2975: }
2976: }
2977: return $result;
2978: }
2979:
2980: sub get_request_settings {
1.26 raeburn 2981: my ($dom,$cnum,$udom,$uname) = @_;
1.16 raeburn 2982: my $requestkey = $dom.'_'.$cnum;
2983: my ($result,%reqinfo);
2984: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
1.26 raeburn 2985: my %history = &Apache::lonnet::restore($requestkey,'courserequests',$udom,$uname);
1.16 raeburn 2986: my $disposition = $history{'disposition'};
2987: if (($disposition eq 'approval') || ($disposition eq 'pending')) {
2988: if (ref($history{'details'}) eq 'HASH') {
2989: %reqinfo = %{$history{'details'}};
2990: $result = 'ok';
2991: } else {
2992: $result = 'nothash';
2993: }
2994: } else {
2995: $result = 'notqueued';
2996: }
2997: } else {
2998: $result = 'invalid';
2999: }
3000: return ($result,%reqinfo);
3001: }
1.2 raeburn 3002:
1.16 raeburn 3003: sub extract_instcode {
1.24 raeburn 3004: my ($cdom,$element,$crscode,$crskey,$counter) = @_;
1.16 raeburn 3005: my (%codes,@codetitles,%cat_titles,%cat_order);
1.24 raeburn 3006: if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes,
3007: \@codetitles,\%cat_titles,
3008: \%cat_order) eq 'ok') {
3009: if (ref($codes{$crskey}) eq 'HASH') {
1.16 raeburn 3010: if (@codetitles > 0) {
3011: my $sel = $element;
3012: if ($element eq 'crosslist') {
3013: $sel .= '_'.$counter;
3014: }
3015: foreach my $title (@codetitles) {
1.24 raeburn 3016: $env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title};
1.16 raeburn 3017: }
3018: }
3019: }
3020: }
3021: return;
1.2 raeburn 3022: }
3023:
1.16 raeburn 3024: sub generate_date_items {
3025: my ($currentval,$item) = @_;
3026: if ($currentval =~ /\d+/) {
3027: my ($tzname,$sec,$min,$hour,$mday,$month,$year) =
3028: &Apache::lonhtmlcommon::get_timedates($currentval);
3029: $env{'form.'.$item.'_day'} = $mday;
3030: $env{'form.'.$item.'_month'} = $month+1;
3031: $env{'form.'.$item.'_year'} = $year;
3032: }
3033: return;
1.2 raeburn 3034: }
3035:
1.1 raeburn 3036: 1;
3037:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>