Annotation of loncom/interface/loncoursequeueadmin.pm, revision 1.59
1.1 raeburn 1: # The LearningOnline Network
1.19 raeburn 2: # Utilities to administer domain course requests and course self-enroll requests
1.1 raeburn 3: #
1.59 ! raeburn 4: # $Id: loncoursequeueadmin.pm,v 1.58 2017/08/03 16:28:39 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:
1.23 raeburn 30: =pod
31:
1.1 raeburn 32: =head1 NAME
33:
34: Apache::loncoursequeueadmin.pm
35:
36: =head1 SYNOPSIS
37:
1.14 raeburn 38: Utilities used by domain coordinators to administer queued course creation requests,
39: and by course coordinators for queued self-enrollment requests, and by general
40: users to display their queued self-enrollment requests.
1.1 raeburn 41:
42: This is part of the LearningOnline Network with CAPA project
43: described at http://www.lon-capa.org.
44:
45: =head1 SUBROUTINES
46:
47: =over
48:
49: =item send_selfserve_notification()
50:
51: =item display_queued_requests()
52:
1.23 raeburn 53: =item build_queue_display()
54:
1.1 raeburn 55: =item update_request_queue()
56:
57: =item get_student_counts()
58:
1.13 raeburn 59: =item course_creation()
60:
61: =item build_batchcreatehash()
62:
63: =item can_clone_course()
64:
65: =item get_processtype()
66:
1.14 raeburn 67: =item queued_selfenrollment()
68:
1.23 raeburn 69: =item update_coursereq_status()
70:
71: =item process_official_reqs()
72:
1.31 raeburn 73: =item is_active_author()
74:
75: =item author_prompt()
76:
77: =item reqauthor_check()
78:
79: =item process_reqauthor()
80:
1.1 raeburn 81: =back
82:
83: =cut
84:
85: package Apache::loncoursequeueadmin;
86:
87: use strict;
88: use Apache::lonnet;
89: use Apache::loncommon;
90: use Apache::lonmsg;
91: use Apache::lonlocal;
1.2 raeburn 92: use Apache::lonuserutils;
1.45 raeburn 93: use LONCAPA::batchcreatecourse;
1.19 raeburn 94: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 95:
96: sub send_selfserve_notification {
1.2 raeburn 97: my ($notifylist,$textstr,$cid,$contextdesc,$timestamp,$context,$sender,
1.12 raeburn 98: $approvedlist,$rejectedlist,$crstype) = @_;
1.1 raeburn 99: # FIXME locallocaltime needs to be able to take $sender_lh as an argument
100: # so this can be localized to the recipients date display format/time zone
101: $timestamp =&Apache::lonlocal::locallocaltime($timestamp);
1.26 raeburn 102: my ($msgcc,$rawsubj,@rawmsg,$subject,$message,$reviewer,$msgtxt);
103: my ($senderuname,$senderudom) = split(':',$sender);
1.1 raeburn 104: if ($context eq 'coursemanagers') {
105: $rawsubj = 'Self-enrollment requests processed';
106: push(@rawmsg,{
1.10 raeburn 107: mt => 'Enrollment requests in the following course: [_1] have been processed.',
1.57 raeburn 108: args => ["\n$contextdesc\n"],
1.1 raeburn 109: });
110: } elsif ($context eq 'domainmanagers') {
1.12 raeburn 111: $rawsubj = 'Course/Community requests reviewed';
1.1 raeburn 112: push(@rawmsg,{
1.57 raeburn 113: mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.',
114: args => ["\n$contextdesc\n"],
1.30 raeburn 115: });
116: if (ref($textstr) eq 'ARRAY') {
117: push(@rawmsg,@{$textstr});
118: }
119: } elsif ($context eq 'authormanagers') {
1.42 bisitz 120: $rawsubj = 'Authoring Space requests reviewed';
1.30 raeburn 121: push(@rawmsg,{
1.57 raeburn 122: mt => 'Authoring requests in the following domain: [_1] have been reviewed.',
123: args => ["\n$contextdesc\n"],
1.1 raeburn 124: });
125: if (ref($textstr) eq 'ARRAY') {
126: push(@rawmsg,@{$textstr});
127: }
1.43 raeburn 128: } elsif ($context eq 'usernamemanagers') {
129: $rawsubj = 'LON-CAPA account requests reviewed';
130: push(@rawmsg,{
1.57 raeburn 131: mt => 'Account requests in the following domain: [_1] have been reviewed.',
132: args => ["\n$contextdesc\n"],
1.43 raeburn 133: });
134: if (ref($textstr) eq 'ARRAY') {
135: push(@rawmsg,@{$textstr});
136: }
1.1 raeburn 137: } elsif ($context eq 'enroller') {
138: $rawsubj = 'Enrollment request';
1.12 raeburn 139: if ($crstype eq 'community') {
140: $msgtxt = 'Your request for enrollment in the following community: [_1]requested on [_2]has been reviewed by a Coordinator.'
141: } else {
142: $msgtxt = 'Your request for enrollment in the following course: [_1]requested on [_2]has been reviewed by a Course Coordinator.';
143: }
1.1 raeburn 144: push(@rawmsg,{
1.12 raeburn 145: mt => $msgtxt,
1.2 raeburn 146: args => ["\n ".$contextdesc.",\n",$timestamp.",\n"],
1.1 raeburn 147:
148: });
149: if (ref($textstr) eq 'ARRAY') {
150: push(@rawmsg,@{$textstr});
151: }
152: } elsif ($context eq 'courserequestor') {
1.12 raeburn 153: if ($crstype eq 'Community') {
154: $rawsubj = 'Community request';
155: $msgtxt = 'Your request for creation of the following community: [_1]requested on [_2]has been reviewed by a Domain Coordinator.';
156: } else {
157: $rawsubj = 'Course request';
158: $msgtxt = 'Your request for creation of the following course: [_1]requested on [_2]has been reviewed by a Domain Coordinator.';
159: }
1.1 raeburn 160: push(@rawmsg,{
1.12 raeburn 161: mt => $msgtxt,
1.2 raeburn 162: args => ["\n".$contextdesc.",\n",$timestamp.",\n"],
1.1 raeburn 163:
164: });
165: if (ref($textstr) eq 'ARRAY') {
166: push(@rawmsg,@{$textstr});
167: }
1.26 raeburn 168: } elsif ($context eq 'pendingrequestor') {
169: if ($crstype eq 'Community') {
170: $rawsubj = 'Community request';
171: } else {
172: $rawsubj = 'Processed course request';
173: }
174: if (ref($textstr) eq 'ARRAY') {
175: push(@rawmsg,@{$textstr});
176: }
1.1 raeburn 177: } elsif ($context eq 'coursereq') {
1.12 raeburn 178: if ($crstype eq 'community') {
179: $rawsubj = 'Community request to review';
180: $msgtxt = 'Creation of the following community: [_1]was requested by [_2] on [_3].';
181: } else {
182: $rawsubj = 'Course request to review';
183: $msgtxt = 'Creation of the following course: [_1]was requested by [_2] on [_3].';
184: }
1.1 raeburn 185: push(@rawmsg,{
1.12 raeburn 186: mt => $msgtxt,
1.2 raeburn 187: args => ["\n $contextdesc\n",$textstr,$timestamp],
1.1 raeburn 188: },
189: {
1.12 raeburn 190: mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.',
1.31 raeburn 191: args => ["\n","\n\n","\n\n"],
1.1 raeburn 192: });
193: } elsif ($context eq 'selfenrollreq') {
194: $rawsubj = 'Self-enrollment request';
1.12 raeburn 195: if ($crstype eq 'community') {
1.31 raeburn 196: $msgtxt = 'Enrollment in the following community: [_1]was requested by [_2] on [_3].'
1.12 raeburn 197: } else {
1.31 raeburn 198: $msgtxt = 'Enrollment in the following course: [_1]was requested by [_2] on [_3].'
1.12 raeburn 199: }
1.1 raeburn 200: push(@rawmsg,{
1.12 raeburn 201: mt => $msgtxt,
1.2 raeburn 202: args => ["\n $contextdesc\n",$textstr,$timestamp."\n"],
203: });
1.12 raeburn 204: my $directions;
205: if ($crstype eq 'community') {
206: $directions = 'As Coordinator, use: [_1]Main Menu -> Manage Community Users -> Enrollment Requests[_2]to display a list of pending enrollment requests, which you can either approve or reject.';
1.2 raeburn 207: } else {
1.12 raeburn 208: $directions = 'As Course Coordinator, use: [_1]Main Menu -> Manage Course Users -> Enrollment Requests[_2]to display a list of pending enrollment requests, which you can either approve or reject.';
209: }
210: push(@rawmsg,
1.1 raeburn 211: {
1.12 raeburn 212: mt => $directions,
1.2 raeburn 213: args => [" \n\n","\n"],
1.1 raeburn 214: });
1.30 raeburn 215: } elsif ($context eq 'authorreq') {
1.42 bisitz 216: $rawsubj = 'Authoring Space request to review';
1.31 raeburn 217: $msgtxt = 'Assignment of an author role in the [_1] domain[_2]was requested by [_3] on [_4].';
1.30 raeburn 218: push(@rawmsg,{
219: mt => $msgtxt,
220: args => [$contextdesc,"\n",$textstr,$timestamp],
221: },
222: {
1.42 bisitz 223: mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring Space requests[_3]to display a list of pending requests, which you can either approve or reject.',
1.30 raeburn 224: args => ["\n","\n\n ","\n\n"],
225: });
226: } elsif ($context eq 'requestauthor') {
1.42 bisitz 227: $rawsubj = 'Authoring Space request';
228: $msgtxt = 'Your request for an Authoring Space requested on [_1]has been reviewed by a Domain Coordinator.';
1.30 raeburn 229: push(@rawmsg,{
230: mt => $msgtxt,
231: args => [$timestamp."\n"],
232: });
233: if (ref($textstr) eq 'ARRAY') {
234: push(@rawmsg,@{$textstr});
235: }
1.43 raeburn 236: } elsif ($context eq 'usernamereq') {
237: $rawsubj = 'LON-CAPA account request';
238: $msgtxt = 'Creation of a LON-CAPA account in the [_1] domain[_2]was requested by [_3] on [_4].';
239: push(@rawmsg,{
240: mt => $msgtxt,
241: args => [$contextdesc,"\n",$textstr,$timestamp],
242: },
243: {
244: mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users
245: -> LON-CAPA account requests[_3]to display a list of pending requests, which you can either approve or reject.',
246: args => ["\n","\n\n ","\n\n"],
247: });
248: } elsif ($context eq 'requestusername') {
249: $rawsubj = 'LON-CAPA account request';
250: $msgtxt = 'Your request for a LON-CAPA account requested on [_1]has been reviewed by a Domain Coordinator.';
251: push(@rawmsg,{
252: mt => $msgtxt,
253: args => [$timestamp."\n"],
254: });
255: if (ref($textstr) eq 'ARRAY') {
256: push(@rawmsg,@{$textstr});
257: }
1.39 raeburn 258: } elsif ($context eq 'uniquecode') {
259: $rawsubj = 'Course Identifier';
260: if (ref($textstr) eq 'ARRAY') {
261: push(@rawmsg,@{$textstr});
262: }
1.41 raeburn 263: } elsif ($context eq 'queuedcrsreq') {
264: $rawsubj = 'Course Request Queued';
265: if (ref($textstr) eq 'ARRAY') {
266: push(@rawmsg,@{$textstr});
267: }
268: } elsif ($context eq 'createdcrsreq') {
269: $rawsubj = 'Course Creation Information';
270: if (ref($textstr) eq 'ARRAY') {
271: push(@rawmsg,@{$textstr});
272: }
1.1 raeburn 273: }
274: my @to_notify = split(/,/,$notifylist);
275: my $numsent = 0;
276: my @recusers;
277: my @recudoms;
278: foreach my $cc (@to_notify) {
279: my ($ccname,$ccdom) = split(/:/,$cc);
280: if (!exists($msgcc->{$ccname.':'.$ccdom})) {
281: push(@recusers,$ccname);
282: push(@recudoms,$ccdom);
283: $msgcc->{$ccname.':'.$ccdom}='';
284: $numsent ++;
285: }
286: }
287: my %reciphash = (
288: cc => $msgcc,
289: );
1.43 raeburn 290: my ($uname,$udom,$need_temp_env);
1.1 raeburn 291: if ($sender =~ /:/) {
292: ($uname,$udom) = split(/:/,$sender);
1.43 raeburn 293: if ($context eq 'usernamereq') {
294: unless ($env{'user.name'} && $env{'user.domain'}) {
295: $need_temp_env = 1;
296: }
297: }
1.2 raeburn 298: } elsif ($context eq 'course') {
1.1 raeburn 299: $uname = $sender;
300: my %courseinfo = &Apache::lonnet::coursedescription($cid);
301: $udom = $courseinfo{'num'};
302: }
303: my %sentmessage;
304: my $stamp = time;
305: my $msgcount = &Apache::lonmsg::get_uniq();
306: my $sender_lh = &Apache::loncommon::user_lang($uname,$udom,$cid);
1.59 ! raeburn 307: $subject = &mt_user($sender_lh,$rawsubj);
1.1 raeburn 308: $message = '';
309: foreach my $item (@rawmsg) {
310: if (ref($item) eq 'HASH') {
1.59 ! raeburn 311: $message .= &mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n";
1.1 raeburn 312: }
313: }
1.43 raeburn 314: &Apache::lonmsg::process_sent_mail($subject,'',$numsent,$stamp,$uname,$udom,$msgcount,$cid,$$,$message,
315: \@recusers,\@recudoms,undef,undef,undef,undef,$senderuname,$senderudom);
1.1 raeburn 316: my ($recipid,$recipstatus) = &Apache::lonmsg::store_recipients($subject,$uname,$udom,\%reciphash);
317: my $status;
1.43 raeburn 318: if ($need_temp_env) {
319: $env{'user.name'} = $uname;
320: $env{'user.domain'} = $udom;
321: }
1.1 raeburn 322: foreach my $recip (sort(keys(%{$msgcc}))) {
323: my ($ccname,$ccdom) = split(/:/,$recip);
324: my $recip_lh = &Apache::loncommon::user_lang($ccname,$ccdom,$cid);
1.59 ! raeburn 325: my $subject = &mt_user($sender_lh,$rawsubj);
1.1 raeburn 326: my $message = '';
327: foreach my $item (@rawmsg) {
328: if (ref($item) eq 'HASH') {
1.59 ! raeburn 329: $message .= &mt_user($sender_lh,$item->{mt},
! 330: @{$item->{args}})."\n";
1.1 raeburn 331: }
332: }
1.10 raeburn 333: if ($context eq 'coursemanagers') {
1.1 raeburn 334: if ($approvedlist) {
1.59 ! raeburn 335: $message .= "\n\n".&mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist;
1.1 raeburn 336: }
337: if ($rejectedlist) {
1.59 ! raeburn 338: $message .= "\n\n".&mt_user($sender_lh,'Rejected enrollments:')."\n".$rejectedlist;
1.1 raeburn 339: }
340: } elsif ($context eq 'domainmanagers') {
341: if ($approvedlist) {
1.59 ! raeburn 342: $message .= "\n\n".&mt_user($sender_lh,'Approved course requests:')."\n".$approvedlist;
1.1 raeburn 343: }
344: if ($rejectedlist) {
1.59 ! raeburn 345: $message .= "\n\n".&mt_user($sender_lh,'Rejected course requests:')."\n".$rejectedlist;
1.1 raeburn 346: }
1.30 raeburn 347: } elsif ($context eq 'authormanagers') {
348: if ($approvedlist) {
1.59 ! raeburn 349: $message .= "\n\n".&mt_user($sender_lh,'Approved author role requests:')."\n".$approvedlist;
1.30 raeburn 350: }
351: if ($rejectedlist) {
1.59 ! raeburn 352: $message .= "\n\n".&mt_user($sender_lh,'Rejected author role requests:')."\n".$rejectedlist;
1.30 raeburn 353: }
1.43 raeburn 354: } elsif ($context eq 'usernamemanagers') {
355: if ($approvedlist) {
1.59 ! raeburn 356: $message .= "\n\n".&mt_user($sender_lh,'Approved LON-CAPA account requests:')."\n".$approvedlist;
1.43 raeburn 357: }
358: if ($rejectedlist) {
1.59 ! raeburn 359: $message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$rejectedlist;
1.43 raeburn 360: }
1.1 raeburn 361: }
1.43 raeburn 362: $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,
363: \%sentmessage,undef,undef,undef,1,$recipid).',';
1.1 raeburn 364: }
365: $status =~ s/,$//;
1.43 raeburn 366: if ($need_temp_env) {
367: undef($env{'user.name'});
368: undef($env{'user.domain'});
369: }
1.1 raeburn 370: return ($recipstatus,$status);
371: }
372:
373: sub display_queued_requests {
374: my ($context,$dom,$cnum) = @_;
1.2 raeburn 375: my ($namespace,$formaction,$nextelement,%requesthash);
1.1 raeburn 376: if ($context eq 'course') {
377: $formaction = '/adm/createuser';
378: $namespace = 'selfenrollrequests';
379: %requesthash = &Apache::lonnet::dump($namespace,$dom,$cnum);
1.2 raeburn 380: $nextelement = '<input type="hidden" name="state" value="done" />';
1.30 raeburn 381: } elsif ($context eq 'requestauthor') {
382: $formaction = '/adm/createuser';
383: $namespace = 'requestauthorqueue';
384: %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
385: $nextelement = '<input type="hidden" name="state" value="done" />';
1.43 raeburn 386: } elsif ($context eq 'requestusername') {
387: $formaction = '/adm/createuser';
388: $namespace = 'usernamequeue';
389: %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
390: $nextelement = '<input type="hidden" name="state" value="done" />';
1.1 raeburn 391: } else {
392: $formaction = '/adm/createcourse';
393: $namespace = 'courserequestqueue';
1.23 raeburn 394: my $disposition = 'approval';
1.24 raeburn 395: my $nextphase = 'requestchange';
1.23 raeburn 396: if ($context eq 'pending') {
397: $disposition = 'pending';
1.24 raeburn 398: $nextphase = 'requestvalidation';
1.56 raeburn 399: } elsif ($context eq 'displaypending') {
400: $disposition = 'pending';
1.23 raeburn 401: }
402: %requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_'.$disposition);
1.24 raeburn 403: $nextelement = '<input type="hidden" name="phase" value="'.$nextphase.'" />';
1.1 raeburn 404: }
1.23 raeburn 405: my ($output,%queue_by_date);
1.1 raeburn 406: if (keys(%requesthash) > 0) {
1.2 raeburn 407: $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".
408: '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
1.23 raeburn 409: $nextelement."\n";
1.1 raeburn 410: foreach my $item (keys(%requesthash)) {
1.23 raeburn 411: my ($timestamp,$entry,$pending);
1.1 raeburn 412: if ($context eq 'course') {
413: ($timestamp, my $usec) = split(/:/,$requesthash{$item});
414: $entry = $item.':'.$usec;
1.30 raeburn 415: } elsif ($context eq 'requestauthor') {
416: $timestamp = $requesthash{$item};
417: ($entry) = ($item =~ /^($match_username)_approval$/);
1.43 raeburn 418: } elsif ($context eq 'requestusername') {
419: $timestamp = $requesthash{$item};
420: ($entry) = (&unescape($item) =~ /^($match_username)_approval$/);
1.1 raeburn 421: } else {
422: $timestamp = $requesthash{$item}{'timestamp'};
423: if (ref($requesthash{$item}) eq 'HASH') {
1.2 raeburn 424: my ($cnum,$disposition) = split('_',$item);
425: $entry = $cnum.':'.$requesthash{$item}{'ownername'}.':'.
1.23 raeburn 426: $requesthash{$item}{'ownerdom'}.':';
1.56 raeburn 427: if (($context eq 'pending') || ($context eq 'displaypending')) {
1.23 raeburn 428: $entry .= $requesthash{$item}{'instcode'};
429: } else {
430: $entry .= $requesthash{$item}{'crstype'};
431: }
432: $entry .= ':'.$requesthash{$item}{'description'};
1.1 raeburn 433: }
434: }
435: if ($entry ne '') {
1.23 raeburn 436: if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {
437: push(@{$queue_by_date{$timestamp}},$entry);
1.1 raeburn 438: } else {
1.23 raeburn 439: $queue_by_date{$timestamp} = [$entry];
1.1 raeburn 440: }
441: }
442: }
1.23 raeburn 443: if (keys(%queue_by_date) > 0) {
444: if ($context eq 'course') {
445: $output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';
1.56 raeburn 446: } elsif (($context eq 'pending') || ($context eq 'displaypending')) {
1.23 raeburn 447: $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
448: '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
1.56 raeburn 449: &mt('Validation is attempted when the request is submitted.').' '.
450: &mt('If unvalidated, the request will be held in a queue.').' '.
451: &mt('Validation of pending requests is automatically repeated daily.').'</p>';
1.30 raeburn 452: } elsif ($context eq 'requestauthor') {
1.42 bisitz 453: $output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>';
1.43 raeburn 454: } elsif ($context eq 'requestusername') {
455: $output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';
1.23 raeburn 456: } else {
1.30 raeburn 457: $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
1.23 raeburn 458: }
459: $output .= &build_queue_display($dom,$context,\%queue_by_date).
460: '<input type="hidden" name="queue" value="approval" />';
461: } else {
462: $output .= '<div class="LC_info">';
463: if ($context eq 'course') {
464: $output .= &mt('There are currently no enrollment requests awaiting approval.');
465: } elsif ($context eq 'pending') {
466: $output .= &mt('There are currently no requests for official courses awaiting validation.');
1.30 raeburn 467: } elsif ($context eq 'requestauthor') {
1.42 bisitz 468: $output .= &mt('There are currently no requests for Authoring Space awaiting approval.');
1.43 raeburn 469: } elsif ($context eq 'requestusername') {
470: $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
1.23 raeburn 471: } elsif ($context eq 'domain') {
472: $output .= &mt('There are currently no course or community requests awaiting approval.');
473: }
474: $output .= '</div>';
475: }
476: if ($context eq 'pending') {
1.24 raeburn 477: $output .= '<br /><input type="submit" name="validationcheck" value="'.
478: &mt('Validate').'" /><br />'."\n".
1.56 raeburn 479: '<p>'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '.
480: &mt('Unvalidated requests will be listed for manual approval/rejection.').'</p>';
481: } elsif (($context ne 'helpdesk') && ($context ne 'displaypending')) {
1.23 raeburn 482: $output .= '<br /><input type="submit" name="processqueue" value="'.&mt('Save').'" />';
483: }
484: $output .= '</form>';
485: } else {
486: $output .= '<div class="LC_info">';
487: if ($context eq 'course') {
488: $output .= &mt('There are currently no enrollment requests awaiting approval.');
1.56 raeburn 489: } elsif (($context eq 'pending') || ($context eq 'displaypending')) {
1.23 raeburn 490: $output .= &mt('There are currently no requests for official courses awaiting validation.');
1.43 raeburn 491: } elsif ($context eq 'requestauthor') {
492: $output .= &mt('There are currently no requests for Authoring Space awaiting approval.');
493: } elsif ($context eq 'requestusername') {
494: $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
1.23 raeburn 495: } else {
496: $output .= &mt('There are currently no course or community requests awaiting approval.');
497: }
498: $output .= '</div>';
499: }
500: return $output;
501: }
1.1 raeburn 502:
1.23 raeburn 503: sub build_queue_display {
504: my ($dom,$context,$queue) = @_;
505: return unless (ref($queue) eq 'HASH');
506: my %crstypes;
507: my $output = &Apache::loncommon::start_data_table().
508: &Apache::loncommon::start_data_table_header_row();
1.56 raeburn 509: unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) {
1.23 raeburn 510: $output .= '<th>'.&mt('Action').'</th>';
511: }
512: $output .= '<th>'.&mt('Requestor').'</th>';
513: if ($context eq 'course') {
514: $output .= '<th>'.&mt('Section').'</th>'.
515: '<th>'.&mt('Date requested').'</th>';
1.30 raeburn 516: } elsif ($context eq 'requestauthor') {
517: $output .= '<th>'.&mt('Date requested').'</th>';
1.43 raeburn 518: } elsif ($context eq 'requestusername') {
519: $output .= '<th>'.&mt('Date requested').'</th>'.
520: '<th>'.&mt('Details').'</th>';
1.56 raeburn 521: } elsif ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') {
1.23 raeburn 522: $output .= '<th>'.&mt('Institutional code').'</th>'.
523: '<th>'.&mt('Date requested').'</th>'.
524: '<th>'.&mt('Details').'</th>';
525: } else {
526: %crstypes = &Apache::lonlocal::texthash (
527: official => 'Official course',
528: unofficial => 'Unofficial course',
529: community => 'Community',
1.38 raeburn 530: textbook => 'Textbook course',
1.53 raeburn 531: placement => 'Placement test',
1.23 raeburn 532: );
533: $output .= '<th>'.&mt('Type').'</th>'.
534: '<th>'.&mt('Date requested').'</th>'.
535: '<th>'.&mt('Details').'</th>';
536: }
537: $output .= &Apache::loncommon::end_data_table_header_row();
538: my @sortedtimes = sort {$a <=> $b} (keys(%{$queue}));
539: my $count = 0;
540: foreach my $item (@sortedtimes) {
541: if (ref($queue->{$item}) eq 'ARRAY') {
542: foreach my $request (sort(@{$queue->{$item}})) {
543: my ($row,$approve,$reject,$showtime,$showsec,$namelink,
544: $detailslink,$crstype,$instcode);
545: $showtime = &Apache::lonlocal::locallocaltime($item);
546: if ($context eq 'course') {
547: my ($puname,$pudom,$pusec) = split(/:/,$request);
548: $approve = $count.':'.$puname.':'.$pudom.':'.$pusec;
549: $reject = $puname.':'.$pudom;
550: $showsec = $pusec;
551: if ($showsec eq '') {
552: $showsec = &mt('none');
553: }
554: $namelink = &Apache::loncommon::aboutmewrapper(
555: &Apache::loncommon::plainname($puname,$pudom),
556: $puname,$pudom);
1.30 raeburn 557: } elsif ($context eq 'requestauthor') {
558: if (&Apache::lonnet::homeserver($request,$dom) ne 'no_host') {
559: $approve = $count.':'.$request;
560: $reject = $request;
561: $namelink = &Apache::loncommon::aboutmewrapper(
562: &Apache::loncommon::plainname($request,$dom),
563: $request,$dom);
564: }
1.43 raeburn 565: } elsif ($context eq 'requestusername') {
566: if (&Apache::lonnet::homeserver($request,$dom) eq 'no_host') {
567: my $queued = 'approval';
568: $approve = $count.':'.$request;
569: $reject = $request;
570: $detailslink='<a href="javascript:openusernamereqdisplay('.
571: "'$dom','$request','$queued'".');">'.$request.'</a>';
572: $namelink = $request;
573: }
1.23 raeburn 574: } else {
575: my ($cnum,$ownername,$ownerdom,$type,$cdesc);
1.43 raeburn 576: my $queued = 'approval';
1.56 raeburn 577: if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') {
1.23 raeburn 578: ($cnum,$ownername,$ownerdom,$instcode,$cdesc)=split(/:/,$request,5);
1.43 raeburn 579: $queued = 'pending';
1.1 raeburn 580: } else {
1.23 raeburn 581: ($cnum,$ownername,$ownerdom,$type,$cdesc)=split(/:/,$request,5);
1.1 raeburn 582: $crstype = $type;
583: if (defined($crstypes{$type})) {
584: $crstype = $crstypes{$type};
585: }
586: }
1.23 raeburn 587: $detailslink='<a href="javascript:opencoursereqdisplay('.
1.43 raeburn 588: "'$dom','$cnum','$queued'".');">'.$cdesc.'</a>';
1.23 raeburn 589: $approve = $count.':'.$cnum;
590: $reject = $cnum;
591: $namelink = &Apache::loncommon::aboutmewrapper(
592: &Apache::loncommon::plainname($ownername,$ownerdom),
593: $ownername,$ownerdom);
594: }
1.56 raeburn 595: unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) {
1.1 raeburn 596: $row = '<td><span class="LC_nobreak"><label>'.
1.30 raeburn 597: '<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'.
598: '<label>'.(' 'x2).
599: '<input type="radio" value="'.$reject.'" name="'.$count.'radioreq" />'.&mt('Reject').'</label>'.
600: '<label>'.(' 'x2).
1.29 golterma 601: '<input type="radio" value="'."later:".$reject.'" name="'.$count.'radioreq" checked />'.&mt('Decide Later').
602: '</label></span><br /></td>';
1.1 raeburn 603: }
1.23 raeburn 604: $row .= '<td>'.$namelink.'</td>'."\n";
605: if ($context eq 'course') {
606: $row .= '<td>'.$showsec.'</td>'."\n".
607: '<td>'.$showtime.'</td>'."\n";
1.30 raeburn 608: } elsif ($context eq 'requestauthor') {
609: $row .= '<td>'.$showtime.'</td>'."\n";
1.43 raeburn 610: } elsif ($context eq 'requestusername') {
611: $row .= '<td>'.$showtime.'</td>'."\n".
612: '<td>'.$detailslink.'</td>'."\n";
1.23 raeburn 613: } else {
1.56 raeburn 614: if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') {
1.23 raeburn 615: $row .= '<td>'.$instcode.'</td>'."\n";
616: } else {
617: $row .= '<td>'.$crstype.'</td>'."\n";
618: }
619: $row .= '<td>'.$showtime.'</td>'."\n".
620: '<td>'.$detailslink.'</td>'."\n";
621: }
622: $output .= &Apache::loncommon::start_data_table_row()."\n".
623: $row.
624: &Apache::loncommon::end_data_table_row()."\n";
625: $count ++;
1.1 raeburn 626: }
627: }
628: }
1.23 raeburn 629: $output .= &Apache::loncommon::end_data_table();
1.1 raeburn 630: return $output;
631: }
632:
633: sub update_request_queue {
634: my ($context,$cdom,$cnum,$coursedesc) = @_;
635: my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace,
1.26 raeburn 636: $stucounts,$idx,$classlist,%requesthash,$cid,$domdesc,$now,
637: $sender,$approvedmsg,$rejectedmsg,$beneficiary,
1.2 raeburn 638: @existing,@missingreq,@invalidusers,@limitexceeded,@completed,
1.19 raeburn 639: @processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,
1.30 raeburn 640: @rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,
641: %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
1.39 raeburn 642: $firsturl,$uniquecode,%codes);
1.29 golterma 643: my $count=0;
1.43 raeburn 644: while (my $item = $env{'form.'.$count.'radioreq'}) {
645: if ($item =~ /^\d+:/) {
646: push(@approvals,$item);
647: } elsif ($item !~ /^later:/) {
648: push(@rejections,$item);
1.29 golterma 649: }
1.43 raeburn 650: $count ++;
1.29 golterma 651: }
652:
1.1 raeburn 653: $now = time;
654: $sender = $env{'user.name'}.':'.$env{'user.domain'};
655: if ($context eq 'course') {
656: $namespace = 'selfenrollrequests';
657: $beneficiary = 'enroller';
658: $cid = $env{'request.course.id'};
1.12 raeburn 659: $crstype = lc(&Apache::loncommon::course_type());
1.54 raeburn 660: $firsturl = &Apache::lonnet::course_portal_url($cnum,$cdom);
1.1 raeburn 661: %requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum);
662: $access_start = $env{'course.'.$cid.'.internal.selfenroll_start_access'};
663: $access_end = $env{'course.'.$cid.'.internal.selfenroll_end_access'};
664: $limit = $env{'course.'.$cid.'.internal.selfenroll_limit'};
665: $cap = $env{'course.'.$cid.'.internal.selfenroll_cap'};
666: $notifylist = $env{'course.'.$cid.'.internal.selfenroll_notifylist'};
667: ($stucounts,$idx,$classlist) = &get_student_counts($cdom,$cnum);
668: $approvedmsg = [{
669: mt => 'Your request for enrollment has been approved.',
670: },
671: {
1.28 raeburn 672: mt => 'Visit [_1] to log-in and access the course',
1.25 raeburn 673: args => [$firsturl],
1.1 raeburn 674: }];
675: $rejectedmsg = [{
676: mt => 'Your request for enrollment has not been approved.',
677: }];
1.30 raeburn 678: } elsif ($context eq 'requestauthor') {
679: $namespace = 'requestauthorqueue';
680: $beneficiary = 'requestauthor';
681: %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom);
682: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
683: if (ref($domdefs{'requestauthor'}) eq 'HASH') {
684: if (ref($domdefs{'requestauthor'}{'notify'}) eq 'HASH') {
685: $notifylist = $domdefs{'requestauthor'}{'notify'}{'approval'};
686: }
687: }
688: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
1.54 raeburn 689: $firsturl = &Apache::lonnet::course_portal_url($domconfiguser,$cdom);
1.30 raeburn 690: $approvedmsg = [{
1.42 bisitz 691: mt => 'Your request for Authoring Space has been approved.',
1.30 raeburn 692: },
693: {
694: mt => 'Visit [_1] to log-in and select your author role',
695: args => [$firsturl],
696: }];
697: $rejectedmsg = [{
1.42 bisitz 698: mt => 'Your request for Authoring Space has not been approved.',
1.30 raeburn 699: }];
700: $domdesc = &Apache::lonnet::domain($cdom);
1.43 raeburn 701: } elsif ($context eq 'requestusername') {
702: $namespace = 'usernamequeue';
703: $beneficiary = 'requestusername';
704: %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom);
705: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$cdom);
706: if (ref($domconfig{'usercreation'}) eq 'HASH') {
707: if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
708: if (ref($domconfig{'usercreation'}{'cancreate'}{'notify'}) eq 'HASH') {
709: $notifylist = $domconfig{'usercreation'}{'cancreate'}{'notify'}{'approval'};
710: }
711: }
712: }
713: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
1.54 raeburn 714: $firsturl = &Apache::lonnet::course_portal_url($domconfiguser,$cdom);
1.43 raeburn 715: $approvedmsg = [{
716: mt => 'Your request for a LON-CAPA account has been approved.',
717: },
718: {
719: mt => 'Visit [_1] to log-in.',
720: args => [$firsturl],
721: }];
722: $rejectedmsg = [{
723: mt => 'Your request for a LON-CAPA account has not been approved.',
724: }];
725: $domdesc = &Apache::lonnet::domain($cdom);
1.1 raeburn 726: } else {
1.2 raeburn 727: $domdesc = &Apache::lonnet::domain($cdom);
728: $namespace = 'courserequestqueue';
729: $beneficiary = 'courserequestor';
1.23 raeburn 730: $queue = 'approval';
731: if ($env{'form.queue'} eq 'pending') {
732: $queue = 'pending';
733: }
734: %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom,'_'.$queue);
1.2 raeburn 735: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
736: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
737: if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') {
738: $notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
739: }
740: }
1.12 raeburn 741: $approvalmsg{'course'} =
742: [{
1.2 raeburn 743: mt => 'Your course request has been approved.',
744: },
745: {
1.28 raeburn 746: mt => 'Visit [_1] to log-in and access the course',
747: args => [],
1.2 raeburn 748: }];
1.12 raeburn 749: $rejectionmsg{'course'} =
750: [{
1.2 raeburn 751: mt => 'Your course request has not been approved.',
752: }];
1.12 raeburn 753:
754: $approvalmsg{'community'} =
755: [{
756: mt => 'Your community request has been approved.',
757: },
758: {
1.28 raeburn 759: mt => 'Visit [_1] to log-in and access the community',
760: args => [],
1.12 raeburn 761: }];
762:
763: $rejectionmsg{'community'} =
764: [{
765: mt => 'Your community request has not been approved.',
766: }];
767:
1.2 raeburn 768: %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
769: my @roles = &Apache::lonuserutils::roles_by_context('course');
770: foreach my $role (@roles) {
771: $courseroles{$role}=&Apache::lonnet::plaintext($role,'Course');
772: }
773: foreach my $role (@roles) {
774: $communityroles{$role}=&Apache::lonnet::plaintext($role,'Community');
775: }
1.1 raeburn 776: }
777: foreach my $item (sort {$a <=> $b} @approvals) {
778: if ($context eq 'course') {
779: my ($num,$uname,$udom,$usec) = split(/:/,$item);
780: my $uhome = &Apache::lonnet::homeserver($uname,$udom);
781: if ($uhome ne 'no_host') {
782: if (exists($requesthash{$uname.':'.$udom})) {
783: if (exists($classlist->{$uname.':'.$udom})) {
784: if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
785: if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') ||
786: ($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Future')) {
787: push(@existing,$uname.':'.$udom);
788: next;
789: }
790: }
791: }
792: } else {
793: push(@missingreq,$uname.':'.$udom);
794: next;
795: }
796: if (!grep(/^\Q$item\E$/,@rejections)) {
797: if ($limit eq 'allstudents') {
798: if ($stucounts->{$limit} >= $cap) {
799: push(@limitexceeded,$uname.':'.$udom);
800: last;
801: }
802: } elsif ($limit eq 'selfenrolled') {
803: if ($stucounts->{$limit} >= $cap) {
804: push(@limitexceeded,$uname.':'.$udom);
805: last;
806: }
807: }
808: my $result =
809: &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$usec,$access_end,$access_start,'selfenroll',undef,$cdom.'_'.$cnum,1);
810: if ($result eq 'ok') {
1.2 raeburn 811: push(@completed,$uname.':'.$udom);
1.1 raeburn 812: $stucounts->{'allstudents'} ++;
813: $stucounts->{'selfenrolled'} ++;
814: &send_selfserve_notification($uname.':'.$udom,$approvedmsg,
1.26 raeburn 815: $cid,$coursedesc,$now,$beneficiary,$sender,
816: undef,undef,$crstype);
1.2 raeburn 817: my %userrequest = (
818: $cdom.'_'.$cnum => {
819: timestamp => $now,
820: section => $usec,
821: adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
822: status => 'approved',
823: }
824: );
1.1 raeburn 825: my $userresult =
826: &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
827: if ($userresult ne 'ok') {
828: push(@warn_approves,$uname.':'.$udom);
829: }
830: } else {
1.2 raeburn 831: push(@processing_errors,$uname.':'.$udom);
1.1 raeburn 832: }
833: }
834: } else {
835: push(@invalidusers,$uname.':'.$udom);
836: }
1.30 raeburn 837: } elsif ($context eq 'requestauthor') {
838: my ($num,$uname) = split(/:/,$item);
839: my $uhome = &Apache::lonnet::homeserver($uname,$cdom);
840: if ($uhome ne 'no_host') {
841: my ($user_is_adv,$user_is_author) = &Apache::lonnet::is_advanced_user($cdom,$uname);
842: if ($user_is_author) {
843: push(@existing,$uname);
844: } elsif (&Apache::lonnet::usertools_access($uname,$cdom,'requestauthor',
845: undef,'requestauthor')) {
846: if (&Apache::lonnet::allowed('cau',$cdom)) {
847: if (&Apache::lonnet::assignrole($cdom,$uname,'/'.$cdom.'/','au',undef,time,undef,undef,'requestauthor') eq 'ok') {
848: push(@completed,$uname);
849: &send_selfserve_notification($uname.':'.$cdom,
850: $approvedmsg,undef,undef,$now,
851: $beneficiary,$sender);
852: my %userrequest = (
853: author => {
854: timestamp => $now,
855: adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
856: status => 'approved',
857: },
858: author_status => 'approved',
859: );
860: my $userresult =
861: &Apache::lonnet::put('requestauthor',\%userrequest,$cdom,$uname);
862: if ($userresult ne 'ok') {
1.43 raeburn 863: push(@warn_approves,$uname.':'.$cdom);
1.30 raeburn 864: }
865: } else {
866: push(@processing_errors,$uname);
867: }
868: } else {
869: push(@nopermissions,$uname);
870: }
871: } else {
872: push(@nopermissions,$uname);
873: }
874: } else {
875: push(@invalidusers,$uname.':'.$cdom);
876: }
877: push(@toremove,(@invalidusers,@nopermissions));
1.43 raeburn 878: } elsif ($context eq 'requestusername') {
879: my ($num,$uname) = split(/:/,$item);
880: my $dbname = 'nohist_requestedusernames';
881: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
882: my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser);
1.58 raeburn 883:
1.43 raeburn 884: if (ref($curr{$uname}) eq 'HASH') {
1.58 raeburn 885: my ($logtoken,$serverid,$encpass,$courseid,$id,$firstname,
886: $middlename,$lastname,$generation,$inststatus,$email);
1.43 raeburn 887: $curr{$uname}{'timestamp'} = $now;
888: $curr{$uname}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'};
889: $courseid = $curr{$uname}{'courseid'};
890: $id = $curr{$uname}{'id'};
891: $firstname = $curr{$uname}{'firstname'};
892: $middlename = $curr{$uname}{'middlename'};
893: $lastname = $curr{$uname}{'lastname'};
894: $generation = $curr{$uname}{'generation'};
1.46 raeburn 895: $inststatus = $curr{$uname}{'inststatus'};
1.43 raeburn 896:
1.58 raeburn 897: if ($curr{$uname}{'email'} ne '') {
898: $email = $curr{$uname}{'email'};
899: } elsif ($uname =~ /^[^\@]+\@[^\@]+$/) {
900: $email = $uname;
901: }
902:
903: my $upass;
904: if ($curr{$uname}{'tmpinfo'}) {
905: my ($key,$caller)=split(/&/,$curr{$uname}{'tmpinfo'});
906: if ($caller eq 'createaccount') {
907: if ($curr{$uname}{'upass'} eq '') {
908: $upass = $curr{$uname}{'upass'};
909: } else {
910: $upass = &Apache::loncommon::des_decrypt($key,$curr{$uname}{'upass'});
911: }
912: } else {
913: push(@processing_errors,$uname);
914: }
915: } else {
916: $upass = $curr{$uname}{'upass'};
917: }
918: if ($upass eq '') {
919: push(@processing_errors,$uname);
920: } else {
1.43 raeburn 921: undef($curr{$uname}{'upass'});
922: my $result =
923: &Apache::lonnet::modifyuser($cdom,$uname,$id,'internal',$upass,
924: $firstname,$middlename,$lastname,
1.58 raeburn 925: $generation,undef,undef,$email);
1.43 raeburn 926: if ($result eq 'ok') {
927: $curr{$uname}{'status'} = 'created';
928: push(@completed,$uname);
929: my $uhome = &Apache::lonnet::homeserver($uname,$cdom);
930: if ($uhome eq 'no_host') {
931: push(@warn_approves,$uname);
932: } else {
1.44 raeburn 933: unless (($inststatus eq 'default') || ($inststatus eq '')) {
934: &Apache::lonnet::put('environment',{inststatus => $inststatus},$cdom,$uname);
935: }
1.43 raeburn 936: &send_selfserve_notification($uname.':'.$cdom,
937: $approvedmsg,undef,undef,$now,
938: $beneficiary,$sender);
939: if (&Apache::lonnet::put($dbname,\%curr,$cdom,$domconfiguser) ne 'ok') {
940: push(@warn_approves,$uname);
941: }
942: }
943: } else {
944: push(@processing_errors,$uname);
945: }
946: }
947: } else {
948: push(@invalidusers,$uname);
949: }
950: push(@toremove,@invalidusers);
1.1 raeburn 951: } else {
1.2 raeburn 952: my ($num,$cnum) = split(':',$item);
1.23 raeburn 953: if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
1.2 raeburn 954: if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
1.23 raeburn 955: my $ownername = $requesthash{$cnum.'_'.$queue}{'ownername'};
956: my $ownerdom = $requesthash{$cnum.'_'.$queue}{'ownerdom'};
957: $crstype = $requesthash{$cnum.'_'.$queue}{'crstype'};
958: my $coursedesc = $requesthash{$cnum.'_'.$queue}{'description'};
1.2 raeburn 959: my $longroles = \%courseroles;
960: if ($crstype eq 'community') {
961: $longroles = \%communityroles;
962: }
1.5 raeburn 963: my $cancreate;
964: if ($cdom eq $ownerdom) {
965: if (&Apache::lonnet::usertools_access($ownername,$ownerdom,$crstype,
966: undef,'requestcourses')) {
967: $cancreate = 1;
968: }
969: } else {
970: my %userenv = &Apache::lonnet::userenvironment($ownerdom,$ownername,'reqcrsotherdom.'.$crstype);
971: if ($userenv{'reqcrsotherdom.'.$crstype}) {
972: my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
973: if (grep(/^\Q$cdom\E:/,@doms)) {
974: $cancreate = 1;
975: }
976: }
977: }
978: if ($cancreate) {
1.2 raeburn 979: my $requestkey = $cdom.'_'.$cnum;
980: my %history =
981: &Apache::lonnet::restore($requestkey,'courserequests',
982: $ownerdom,$ownername);
983: if ((ref($history{'details'}) eq 'HASH') &&
1.23 raeburn 984: ($history{'disposition'} eq $queue)) {
1.59 ! raeburn 985: my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,
! 986: $keysmsg,$code,%customitems);
! 987: my $clonemsg = [];
1.41 raeburn 988: my $fullname = '';
989: my $inprocess = &Apache::lonnet::auto_crsreq_update($cdom,$cnum,$crstype,'process',$ownername,
990: $ownerdom,$fullname,$coursedesc);
991: if (ref($inprocess) eq 'HASH') {
992: foreach my $key (keys(%{$inprocess})) {
993: if (exists($history{'details'}{$key})) {
994: $customitems{$key} = $history{'details'}{$key};
995: }
996: }
997: }
1.50 raeburn 998: if ($history{'details'}{'clonecrs'}) {
999: $customitems{'_LC_clonefrom'} = $history{'details'}{'clonedom'}.'_'.$history{'details'}{'clonecrs'};
1000: }
1.59 ! raeburn 1001: my ($result,$postprocess) = &course_creation($cdom,$cnum,$context,$history{'details'},
! 1002: \$logmsg,$clonemsg,\$newusermsg,\$addresult,\$enrollcount,
1.41 raeburn 1003: \$response,\$keysmsg,\%domdefs,$longroles,\$code,\%customitems);
1.2 raeburn 1004: if ($result eq 'created') {
1.12 raeburn 1005: if ($crstype eq 'community') {
1006: $approvedmsg = $approvalmsg{'community'};
1007: } else {
1008: $approvedmsg = $approvalmsg{'course'};
1009: }
1.54 raeburn 1010: my $firsturl = &Apache::lonnet::course_portal_url($cnum,$cdom);
1.28 raeburn 1011: if (ref($approvedmsg) eq 'ARRAY') {
1012: if (ref($approvedmsg->[1]) eq 'HASH') {
1013: $approvedmsg->[1]->{'args'} = [$firsturl];
1014: }
1.59 ! raeburn 1015: if ((ref($clonemsg) eq 'ARRAY') && (@{$clonemsg})) {
! 1016: push(@{$approvedmsg},@{$clonemsg});
! 1017: }
1.39 raeburn 1018: if ($code) {
1019: push(@{$approvedmsg},
1020: {
1021: mt => 'Students can automatically select your course by entering this code: [_1]',
1022: args => [$code],
1023: });
1024: $codes{$cnum} = $code;
1025: }
1.41 raeburn 1026: if (ref($postprocess) eq 'HASH') {
1027: if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
1028: foreach my $item (@{$postprocess->{'createdmsg'}}) {
1029: if (ref($item) eq 'HASH') {
1030: if ($item->{'mt'} ne '') {
1031: push(@{$approvedmsg},$item);
1032: }
1033: }
1034: }
1035: }
1036: }
1.28 raeburn 1037: }
1.2 raeburn 1038: push(@completed,$cnum);
1.19 raeburn 1039:
1.23 raeburn 1040: unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_'.$queue],$cdom) eq 'ok') {
1.19 raeburn 1041: push(@warn_dels,$cnum);
1042: }
1.26 raeburn 1043: &send_selfserve_notification($ownername.':'.$ownerdom,
1044: $approvedmsg,$cid,$coursedesc,$now,
1045: $beneficiary,$sender,undef,undef,$crstype);
1.2 raeburn 1046: my %reqhash = (
1047: reqtime => $history{'reqtime'},
1048: crstype => $history{'crstype'},
1049: details => $history{'details'},
1050: disposition => $history{'disposition'},
1051: status => 'created',
1052: adjudicator => $env{'user.name'}.':'.
1053: $env{'user.domain'},
1054: );
1055: my $userresult =
1056: &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
1057: 'courserequests',$ownerdom,$ownername);
1058: if ($userresult eq 'ok') {
1059: my %status = (
1060: 'status:'.$cdom.':'.$cnum => 'created'
1061: );
1062: my $statusresult =
1063: &Apache::lonnet::put('courserequests',\%status,
1064: $ownerdom,$ownername);
1065: if ($statusresult ne 'ok') {
1066: push(@warn_approves,$cnum);
1067: }
1068: }
1069: if ($userresult ne 'ok') {
1070: push(@warn_approves,$cnum);
1071: }
1072: } else {
1073: push(@processing_errors,$cnum);
1074: }
1075: } else {
1076: push(@processing_errors,$cnum);
1077: }
1078: } else {
1.5 raeburn 1079: push(@nopermissions,$cnum);
1.2 raeburn 1080: }
1081: } else {
1082: push(@existing,$cnum);
1083: }
1084: } else {
1085: push(@missingreq,$cnum);
1086: }
1.1 raeburn 1087: }
1088: }
1.2 raeburn 1089: my @changes = (@completed,@rejections);
1090: if ($context eq 'domain') {
1.23 raeburn 1091: @changes = map {$_.'_'.$queue} (@changes);
1.30 raeburn 1092: } elsif ($context eq 'requestauthor') {
1093: @changes = map {$_.'_approval'} (@changes);
1.43 raeburn 1094: } elsif ($context eq 'requestusername') {
1095: @changes = map {&escape($_).'_approval'} (@changes);
1.2 raeburn 1096: }
1.1 raeburn 1097: if (@rejections) {
1.3 raeburn 1098: foreach my $item (@rejections) {
1.30 raeburn 1099: if (($context eq 'course') || ($context eq 'requestauthor')) {
1.43 raeburn 1100: my ($user,$uname,$udom,%userrequest,$key,$dbname);
1.30 raeburn 1101: if ($context eq 'requestauthor') {
1102: $uname = $item;
1103: $udom = $cdom;
1104: $user = $uname.':'.$udom;
1105: $key = 'author';
1.43 raeburn 1106: $dbname = 'requestauthor';
1.30 raeburn 1107: } else {
1108: $user = $item;
1109: ($uname,$udom) = split(/:/,$user);
1110: $key = $cdom.'_'.$cnum;
1.43 raeburn 1111: $dbname = $namespace;
1.30 raeburn 1112: }
1.2 raeburn 1113: &send_selfserve_notification($user,$rejectedmsg,$cid,$coursedesc,
1.26 raeburn 1114: $now,$beneficiary,$sender,undef,undef,
1115: $crstype);
1.30 raeburn 1116: %userrequest = (
1117: $key => {
1.1 raeburn 1118: timestamp => $now,
1119: adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
1.30 raeburn 1120: status => 'rejection',
1.1 raeburn 1121: }
1122: );
1.30 raeburn 1123: if ($context eq 'requestauthor') {
1124: $userrequest{'author_status'} = 'rejection';
1125: }
1.1 raeburn 1126: my $userresult =
1.43 raeburn 1127: &Apache::lonnet::put($dbname,\%userrequest,$udom,$uname);
1.1 raeburn 1128: if ($userresult ne 'ok') {
1.30 raeburn 1129: push(@warn_rejects,$item);
1.1 raeburn 1130: }
1.43 raeburn 1131: } elsif ($context eq 'requestusername') {
1132: my ($uname,$udom,$dbname);
1133: $uname = $item;
1134: $udom = $cdom;
1135: $dbname = 'nohist_requestedusernames';
1136: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
1137: my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser);
1138: if (ref($curr{$uname}) eq 'HASH') {
1139: $curr{$uname}{'status'} = 'rejected';
1140: $curr{$uname}{'timestamp'} = $now;
1141: $curr{$uname}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'};
1142: undef($curr{$uname}{'tmpinfo'});
1143: undef($curr{$uname}{'upass'});
1144: }
1145: my $userresult =
1146: &Apache::lonnet::put($dbname,\%curr,$cdom,$domconfiguser);
1147: if ($userresult ne 'ok') {
1148: push(@warn_rejects,$uname);
1149: }
1.1 raeburn 1150: } else {
1.3 raeburn 1151: my $cnum = $item;
1.23 raeburn 1152: if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
1.3 raeburn 1153: if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
1154: my $requestkey = $cdom.'_'.$cnum;
1.23 raeburn 1155: my $ownername = $requesthash{$cnum.'_'.$queue}{'ownername'};
1156: my $ownerdom = $requesthash{$cnum.'_'.$queue}{'ownerdom'};
1157: my $coursedesc = $requesthash{$cnum.'_'.$queue}{'description'};
1158: $crstype = $requesthash{$cnum.'_'.$queue}{'crstype'};
1.12 raeburn 1159: if ($crstype eq 'community') {
1160: $rejectedmsg = $rejectionmsg{'community'};
1161: } else {
1162: $rejectedmsg = $rejectionmsg{'course'};
1163: }
1.2 raeburn 1164: &send_selfserve_notification($ownername.':'.$ownerdom,$rejectedmsg,
1165: $cid,$coursedesc,$now,$beneficiary,
1.12 raeburn 1166: $sender,undef,undef,$crstype);
1.2 raeburn 1167: my %history =
1.3 raeburn 1168: &Apache::lonnet::restore($requestkey,'courserequests',
1.2 raeburn 1169: $ownerdom,$ownername);
1170: if ((ref($history{'details'}) eq 'HASH') &&
1.23 raeburn 1171: ($history{'disposition'} eq $queue)) {
1.2 raeburn 1172: my %reqhash = (
1173: reqtime => $history{'reqtime'},
1174: crstype => $history{'crstype'},
1175: details => $history{'details'},
1176: disposition => $history{'disposition'},
1177: status => 'rejected',
1178: adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
1179: );
1180: my $userresult =
1.3 raeburn 1181: &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
1182: 'courserequests',$ownerdom,$ownername);
1183: if ($userresult eq 'ok') {
1184: my %status = (
1185: 'status:'.$cdom.':'.$cnum => 'rejected'
1186: );
1187: my $statusresult =
1188: &Apache::lonnet::put('courserequests',\%status,
1189: $ownerdom,$ownername);
1190: if ($statusresult ne 'ok') {
1191: push(@warn_rejects,$cnum);
1192: }
1193: } else {
1194: push(@warn_rejects,$cnum);
1.2 raeburn 1195: }
1.23 raeburn 1196: unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_'.$queue],$cdom) eq 'ok') {
1.19 raeburn 1197: push(@warn_dels,$cnum);
1198: }
1.3 raeburn 1199: } else {
1200: push(@warn_rejects,$cnum);
1.2 raeburn 1201: }
1.3 raeburn 1202: } else {
1203: push(@existing,$cnum);
1.2 raeburn 1204: }
1.3 raeburn 1205: } else {
1206: push(@rejectionerrors,$cnum);
1.2 raeburn 1207: }
1.1 raeburn 1208: }
1209: }
1210: }
1.30 raeburn 1211: if (@toremove) {
1.43 raeburn 1212: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
1.30 raeburn 1213: foreach my $item (@toremove) {
1.43 raeburn 1214: if ($context eq 'requestauthor') {
1215: my %userrequest = (
1216: author => {
1217: timestamp => $now,
1218: adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
1219: status => 'deleted',
1220: },
1221: author_status => 'deleted',
1222: );
1223: &Apache::lonnet::put('requestauthor',\%userrequest,$cdom,$item);
1224: } elsif ($context eq 'requestusername') {
1225: my $dbname = 'nohist_requestedusernames';
1226: my %curr = &Apache::lonnet::get($dbname,[$item],$cdom,$domconfiguser);
1227: if (ref($curr{$item}) eq 'HASH') {
1228: $curr{$item}{'status'} = 'deleted';
1229: $curr{$item}{'timestamp'} = $now;
1230: $curr{$item}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'};
1231: undef($curr{$item}{'upass'});
1232: undef($curr{$item}{'tmpinfo'});
1233: }
1234: }
1.30 raeburn 1235: }
1236: @toremove = map {$_.'_approval'} (@toremove);
1237: my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom);
1238: }
1.1 raeburn 1239: if (@changes) {
1240: my $delresult;
1241: if ($context eq 'course') {
1242: $delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum);
1243: } else {
1244: $delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom);
1245: }
1246: if ($delresult eq 'ok') {
1247: my $namelink =
1248: &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}).' ('.$env{'user.name'}.':'.$env{'user.domain'}.')';
1249: my ($chgmsg,$approvedlist,$rejectedlist);
1250: if ($context eq 'course') {
1251: $chgmsg = "'Action was taken on the following enrollment requests by [_1].',$namelink";
1.2 raeburn 1252: if (@completed) {
1253: $approvedlist = join("\n",@completed);
1.12 raeburn 1254: if ($crstype eq 'community') {
1255: $output .= '<p>'.&mt('The following were enrolled in the community:').'<ul>';
1256: } else {
1257: $output .= '<p>'.&mt('The following were enrolled in the course:').'<ul>';
1258: }
1.2 raeburn 1259: foreach my $user (@completed) {
1.1 raeburn 1260: my ($uname,$udom) = split(/:/,$user);
1261: my $userlink =
1262: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
1263: $output .= '<li>'.$userlink.'</li>';
1264: }
1265: $output .= '</ul></p>';
1266: }
1267: if (@rejections) {
1268: $rejectedlist = join("\n",@rejections);
1269: $output .= '<p>'.&mt('The following enrollment requests were rejected:').'<ul>';
1270: foreach my $user (@rejections) {
1271: $output .= '<li>'.$user.'</li>';
1272: }
1273: $output .= '</ul></p>';
1274: }
1.2 raeburn 1275: if ($notifylist ne '') {
1276: &send_selfserve_notification($notifylist,$chgmsg,$cid,$coursedesc,
1277: $now,'coursemanagers',$sender,
1.12 raeburn 1278: $approvedlist,$rejectedlist,$crstype);
1.2 raeburn 1279: }
1.30 raeburn 1280: } elsif ($context eq 'requestauthor') {
1.42 bisitz 1281: $chgmsg = "'Action was taken on the following Authoring Space requests by [_1].',$namelink";
1.30 raeburn 1282: if (@completed) {
1283: $approvedlist = join("\n",@completed);
1284: $output .= '<p>'.&mt('The following requests were approved:').'<ul>';
1285: foreach my $uname (@completed) {
1286: my $userlink =
1287: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1288: $output .= '<li>'.$userlink.'</li>';
1289:
1290: }
1291: $output .= '</ul></p>';
1292: }
1293: if (@rejections) {
1294: $rejectedlist = join("\n",@rejections);
1295: $output .= '<p>'.&mt('The following requests were rejected:').'<ul>';
1296: foreach my $uname (@rejections) {
1297: my $userlink =
1298: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1299: $output .= '<li>'.$userlink.'</li>';
1300: }
1301: $output .= '</ul></p>';
1302: }
1303: if ($notifylist ne '') {
1304: &send_selfserve_notification($notifylist,$chgmsg,undef,$domdesc,
1305: $now,'authormanagers',$sender,
1306: $approvedlist,$rejectedlist);
1307: }
1.43 raeburn 1308: } elsif ($context eq 'requestusername') {
1309: $chgmsg = "'Action was taken on the following LON-CAPA account requests by [_1].',$namelink";
1310: if (@completed) {
1311: $approvedlist = join("\n",@completed);
1312: $output .= '<p>'.&mt('The following requests were approved:').'<ul>';
1313: foreach my $uname (@completed) {
1314: $output .= '<li>'.$uname.'</li>';
1315:
1316: }
1317: $output .= '</ul></p>';
1318: }
1319: if (@rejections) {
1320: $rejectedlist = join("\n",@rejections);
1321: $output .= '<p>'.&mt('The following requests were rejected:').'<ul>';
1322: foreach my $uname (@rejections) {
1323: $output .= '<li>'.$uname.'</li>';
1324: }
1325: $output .= '</ul></p>';
1326: }
1327: if ($notifylist ne '') {
1328: &send_selfserve_notification($notifylist,$chgmsg,undef,$domdesc,
1329: $now,'usernamemanagers',$sender,
1330: $approvedlist,$rejectedlist);
1331: }
1.1 raeburn 1332: } else {
1.12 raeburn 1333: $chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
1.2 raeburn 1334: if (@completed) {
1335: $approvedlist = join("\n",@completed);
1.12 raeburn 1336: $output .= '<p>'.&mt('The following courses/communities were created:').'<ul>';
1.2 raeburn 1337: foreach my $cnum (@completed) {
1338: my $showcourse;
1.23 raeburn 1339: if (ref($requesthash{$cnum.'_'.$queue})) {
1340: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1.2 raeburn 1341: } else {
1342: $showcourse = $cnum;
1343: }
1344: my $syllabuslink =
1345: &Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
1.40 raeburn 1346: if ($codes{$cnum}) {
1.49 raeburn 1347: $syllabuslink .= ' '.&mt('Unique code: [_1]',$codes{$cnum});
1.39 raeburn 1348: }
1.2 raeburn 1349: $output .= '<li>'.$syllabuslink.'</li>';
1350: }
1351: $output .= '</ul></p>';
1352: }
1353: if (@rejections) {
1354: $rejectedlist = join("\n",@rejections);
1355: $output .= '<p>'.&mt('The following requests were rejected:').'<ul>';
1356: foreach my $cnum (@rejections) {
1357: my $showcourse;
1.23 raeburn 1358: if (ref($requesthash{$cnum.'_'.$queue})) {
1359: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1.2 raeburn 1360: } else {
1361: $showcourse = $cnum;
1362: }
1363: $output .= '<li>'.$showcourse.'</li>';
1364: }
1365: $output .= '</ul></p>';
1366: }
1367: if ($notifylist ne '') {
1368: &send_selfserve_notification($notifylist,$chgmsg,$cid,$domdesc,
1369: $now,'domainmanagers',$sender,
1.12 raeburn 1370: $approvedlist,$rejectedlist,$crstype);
1.2 raeburn 1371: }
1.1 raeburn 1372: }
1.43 raeburn 1373: } else {
1374: if (($context eq 'requestauthor') || ($context eq 'requestusername')) {
1375: push(@warn_dels,@changes);
1376: }
1.1 raeburn 1377: }
1378: }
1379: if (@existing) {
1380: if ($context eq 'course') {
1381: $output .= '<p>'.&mt('The following enrollment requests were deleted because the user is already enrolled in the course:').'<ul>';
1382: foreach my $user (@existing) {
1383: $output .= '<li>'.$user.'</li>';
1384: }
1385: $output .= '</ul></p>';
1.30 raeburn 1386: } elsif ($context eq 'requestauthor') {
1.42 bisitz 1387: $output .= '<p>'.&mt('Authoring Space requests from the following users were deleted because one already exists:').'<ul>';
1.30 raeburn 1388: foreach my $uname (@existing) {
1389: my $userlink =
1390: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1391: $output .= '<li>'.$userlink.'</li>';
1392: }
1393: $output .= '</ul></p>';
1.1 raeburn 1394: } else {
1.12 raeburn 1395: $output .= '<p>'.&mt('The following course/community creation requests were deleted because the course or community has already been created:').'<ul>';
1.2 raeburn 1396: foreach my $cnum (@existing) {
1397: my $showcourse;
1398: my %coursehash = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);
1399: if ($coursehash{'description'} ne '') {
1400: $showcourse = $coursehash{'description'};
1401: } else {
1402: $showcourse = $cnum;
1403: }
1404: $output .= '<li>'.$showcourse.'</li>';
1405: }
1406: $output .= '</ul></p>';
1.1 raeburn 1407: }
1408: }
1409: if (@missingreq) {
1410: if ($context eq 'course') {
1411: $output .= '<p>'.&mt('The following enrollment requests were ignored because the request is no longer in the enrollment queue:').'<ul>';
1412: foreach my $user (@missingreq) {
1413: $output .= '<li>'.$user.'</li>';
1414: }
1415: $output .= '</ul></p>';
1.30 raeburn 1416: } elsif ($context eq 'requestauthor') {
1417: $output .= '<p>'.&mt('The following requests were ignored because the request is no longer in the queue:').'<ul>';
1418: foreach my $uname (@missingreq) {
1419: my $userlink =
1420: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1421: $output .= '<li>'.$userlink.'</li>';
1422: }
1423: $output .= '</ul></p>';
1.2 raeburn 1424: } else {
1.12 raeburn 1425: $output .= '<p>'.&mt('The following course/community creation requests were ignored because the request is no longer in the queue:').'<ul>';
1.2 raeburn 1426: foreach my $cnum (@missingreq) {
1427: $output .= '<li>'.$cnum.'</li>';
1428: }
1429: $output .= '</ul></p>';
1.1 raeburn 1430: }
1431: }
1432: if (@invalidusers) {
1433: if ($context eq 'course') {
1434: $output .= '<p>'.&mt('The following enrollment requests were deleted because the requestor does not have a LON-CAPA account:').'<ul>';
1435: foreach my $user (@invalidusers) {
1436: $output .= '<li>'.$user.'</li>';
1437: }
1438: $output .= '</ul></p>';
1.30 raeburn 1439: } elsif ($context eq 'requestauthor') {
1.42 bisitz 1440: $output .= '<p>'.&mt('The following Authoring Space requests were deleted because the requestor does not have a LON-CAPA account:').'<ul>';
1.30 raeburn 1441: foreach my $uname (@invalidusers) {
1442: my $userlink =
1443: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1444: $output .= '<li>'.$userlink.'</li>';
1445: }
1446: $output .= '</ul></p>';
1.1 raeburn 1447: }
1448: }
1449: if (@limitexceeded) {
1450: if ($context eq 'course') {
1451: $output .= '<p>'.&mt('The following enrollment requests were skipped because the enrollment limit has been reached for the course:').'<ul>';
1452: foreach my $user (@limitexceeded) {
1453: $output .= '<li>'.$user.'</li>';
1454: }
1455: $output .= '</ul></p>';
1456: }
1457: }
1.5 raeburn 1458: if (@nopermissions) {
1.30 raeburn 1459: if ($context eq 'course') {
1460: $output .= '<p>'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'<ul>';
1461: foreach my $cnum (@nopermissions) {
1462: my $showcourse;
1463: if (ref($requesthash{$cnum.'_'.$queue})) {
1464: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1465: } else {
1466: $showcourse = $cnum;
1467: }
1468: $output .= '<li>'.$showcourse.'</li>';
1469: }
1470: $output .= '</ul></p>';
1471: } elsif ($context eq 'requestauthor') {
1.42 bisitz 1472: $output .= '<p>'.&mt('The following requests could not be processed because the requestor does not have rights to request an Authoring Space:').'<ul>';
1.30 raeburn 1473: foreach my $uname (@nopermissions) {
1474: my $userlink =
1475: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1476: $output .= '<li>'.$userlink.'</li>';
1.5 raeburn 1477: }
1.30 raeburn 1478: $output .= '</ul></p>';
1.5 raeburn 1479: }
1480: }
1.2 raeburn 1481: if (@processing_errors) {
1.1 raeburn 1482: if ($context eq 'course') {
1483: $output .= '<p>'.&mt('The following enrollment requests could not be processed because an error occurred:').'<ul>';
1.2 raeburn 1484: foreach my $user (@processing_errors) {
1.1 raeburn 1485: $output .= '<li>'.$user.'</li>';
1486: }
1487: $output .= '</ul></p>';
1.30 raeburn 1488: } elsif ($context eq 'requestauthor') {
1489: $output .= '<p>'.&mt('The following requests could not be processed because an error occurred:').'<ul>';
1490: foreach my $uname (@processing_errors) {
1491: my $userlink =
1492: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1493: $output .= '<li>'.$userlink.'</li>';
1494: }
1495: $output .= '</ul></p>';
1.43 raeburn 1496: } elsif ($context eq 'requestusername') {
1497: $output .= '<p>'.&mt('The following requests could not be processed because an error occurred:').'<ul>';
1498: foreach my $uname (@processing_errors) {
1499: $output .= '<li>'.$uname.'</li>';
1500: }
1501: $output .= '</ul></p>';
1.1 raeburn 1502: } else {
1.12 raeburn 1503: $output .= '<p>'.&mt('The following course/community creation requests could not be processed because an error occurred:').'<ul>';
1.2 raeburn 1504: foreach my $cnum (@processing_errors) {
1505: my $showcourse;
1.23 raeburn 1506: if (ref($requesthash{$cnum.'_'.$queue})) {
1507: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1.2 raeburn 1508: } else {
1509: $showcourse = $cnum;
1510: }
1511: $output .= '<li>'.$showcourse.'</li>';
1512: }
1513: $output .= '</ul></p>';
1.1 raeburn 1514: }
1515: }
1.3 raeburn 1516: if (@rejectionerrors) {
1.12 raeburn 1517: $output .= '<p>'.&mt('The following course/community creation request rejections could not be fully processed because an error occurred:').'<ul>';
1.3 raeburn 1518: foreach my $cnum (@rejectionerrors) {
1519: my $showcourse;
1.23 raeburn 1520: if (ref($requesthash{$cnum.'_'.$queue})) {
1521: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1.3 raeburn 1522: } else {
1523: $showcourse = $cnum;
1524: }
1525: $output .= '<li>'.$showcourse.'</li>';
1526: }
1527: $output .= '</ul></p>';
1528: }
1.2 raeburn 1529: if (@warn_approves || @warn_rejects) {
1.1 raeburn 1530: if ($context eq 'course') {
1531: $output .= '<p>'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'<ul>';
1532: foreach my $user (@warn_approves) {
1533: $output .= '<li>'.$user.'</li>';
1534: }
1535: $output .= '</ul></p>';
1.30 raeburn 1536: } elsif ($context eq 'requestauthor') {
1537: $output .= '<p>'.&mt("For the following users, an error occurred when updating the user's own author request record:").'<ul>';
1538: foreach my $uname (@warn_approves,@warn_rejects) {
1539: my $userlink =
1540: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1541: $output .= '<li>'.$userlink.'</li>';
1542: }
1543: $output .= '</ul></p>';
1.43 raeburn 1544: } elsif ($context eq 'requestusername') {
1545: $output .= '<p>'.&mt("For the following users, an error occurred when updating the account request record for the user:").'<ul>';
1546: foreach my $uname (@warn_approves,@warn_rejects) {
1547: $output .= '<li>'.$uname.'</li>';
1548: }
1549: $output .= '</ul></p>';
1.1 raeburn 1550: } else {
1.12 raeburn 1551: $output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';
1.2 raeburn 1552: foreach my $cnum (@warn_approves,@warn_rejects) {
1553: my $showcourse;
1.23 raeburn 1554: if (ref($requesthash{$cnum.'_'.$queue})) {
1555: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1.2 raeburn 1556: } else {
1557: $showcourse = $cnum;
1558: }
1559: $output .= '<li>'.$showcourse.'</li>';
1.1 raeburn 1560: }
1561: $output .= '</ul></p>';
1562: }
1563: }
1.19 raeburn 1564: if (@warn_dels) {
1.30 raeburn 1565: if ($context eq 'requestauthor') {
1566: $output .= '<p>'.&mt("For the following requests an error occurred when removing the request from the queue:").'<ul>';
1567: foreach my $uname (@warn_dels) {
1568: my $userlink =
1569: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
1570: $output .= '<li>'.$userlink.'</li>';
1571: }
1572: $output .= '</ul></p>';
1.43 raeburn 1573: } elsif ($context eq 'requestusername') {
1574: $output .= '<p>'.&mt("For the following requests an error occurred when removing the request from the queue:").'<ul>';
1575: foreach my $item (@warn_dels) {
1576: my ($escuname) = split(/_/,$item);
1577: $output .= '<li>'.&unescape($escuname).'</li>';
1578: }
1579: $output .= '</ul></p>';
1.30 raeburn 1580: } else {
1.36 bisitz 1581: $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>';
1.30 raeburn 1582: foreach my $cnum (@warn_dels) {
1583: my $showcourse;
1584: if (ref($requesthash{$cnum.'_'.$queue})) {
1585: $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
1586: } else {
1587: $showcourse = $cnum;
1588: }
1589: $output .= '<li>'.$showcourse.'</li>';
1.19 raeburn 1590: }
1.30 raeburn 1591: $output .= '</ul></p>';
1.19 raeburn 1592: }
1593: }
1.1 raeburn 1594: return $output;
1595: }
1596:
1597: sub get_student_counts {
1598: my ($cdom,$cnum) = @_;
1599: my (%idx,%stucounts);
1600: my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
1601: $idx{'type'} = &Apache::loncoursedata::CL_TYPE();
1602: $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
1603: while (my ($student,$data) = each(%$classlist)) {
1604: if (($data->[$idx{'status'}] eq 'Active') ||
1605: ($data->[$idx{'status'}] eq 'Future')) {
1606: if ($data->[$idx{'type'}] eq 'selfenroll') {
1607: $stucounts{'selfenroll'} ++;
1608: }
1609: $stucounts{'allstudents'} ++;
1610: }
1611: }
1612: return (\%stucounts,\%idx,$classlist);
1613: }
1614:
1.2 raeburn 1615: sub course_creation {
1.59 ! raeburn 1616: my ($dom,$cnum,$context,$details,$logmsg,$clonemsg,$newusermsg,$addresult,
! 1617: $enrollcount,$output,$keysmsg,$domdefs,$longroles,$coderef,$customhash,
! 1618: $callercontext,$user_lh) = @_;
1.2 raeburn 1619: unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') &&
1620: (ref($longroles) eq 'HASH')) {
1.53 raeburn 1621: return ('error: Invalid request');
1.2 raeburn 1622: }
1623: my ($result,$ownername,$ownerdom);
1624: my $crstype = $details->{'crstype'};
1.41 raeburn 1625: my $coursedesc = $details->{'cdescr'};
1.47 raeburn 1626: my $accessstart = $details->{'accessstart'};
1627: my $accessend = $details->{'accessend'};
1628: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
1.40 raeburn 1629: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
1630: if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
1631: if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
1632: $details->{'uniquecode'} = 1;
1633: }
1634: }
1635: }
1.2 raeburn 1636: if ($context eq 'domain') {
1637: $ownername = $details->{'owner'};
1638: $ownerdom = $details->{'domain'};
1639: } else {
1640: $ownername = $env{'user.name'};
1641: $ownerdom = $env{'user.domain'};
1642: }
1.41 raeburn 1643: my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
1.2 raeburn 1644: my $owneremail;
1645: my %emails = &Apache::loncommon::getemails($ownername,$ownerdom);
1646: foreach my $email ('permanentemail','critnotification','notification') {
1647: $owneremail = $emails{$email};
1648: last if ($owneremail ne '');
1649: }
1.8 raeburn 1650: my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs);
1.2 raeburn 1651: my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',
1.59 ! raeburn 1652: \%reqdetails,$longroles,$logmsg,$clonemsg,$newusermsg,$addresult,
! 1653: $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,
! 1654: $coderef,$callercontext,$user_lh);
1.41 raeburn 1655: my $postprocess;
1.2 raeburn 1656: if ($cid eq "/$dom/$cnum") {
1657: $result = 'created';
1.41 raeburn 1658: my $code;
1659: if (ref($coderef)) {
1660: $code = $$coderef;
1661: }
1662: $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,
1.47 raeburn 1663: $ownerdom,$fullname,$coursedesc,$code,
1664: $accessstart,$accessend,$customhash);
1.2 raeburn 1665: } else {
1666: $result = 'error: '.$cid;
1667: }
1.41 raeburn 1668: return ($result,$postprocess);
1.2 raeburn 1669: }
1670:
1671: sub build_batchcreatehash {
1.8 raeburn 1672: my ($dom,$context,$details,$owneremail,$domdefs) = @_;
1.2 raeburn 1673: my %batchhash;
1.59 ! raeburn 1674: my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift tinyurls enrollstart enrollend accessstart accessend sections crosslists users uniquecode};
1.2 raeburn 1675: if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {
1.17 raeburn 1676: my $emailenc = &escape($owneremail);
1.2 raeburn 1677: my $owner = $details->{'owner'}.':'.$details->{'domain'};
1678: foreach my $item (@items) {
1679: $batchhash{$item} = $details->{$item};
1680: }
1681: $batchhash{'title'} = $details->{'cdescr'};
1682: $batchhash{'coursecode'} = $details->{'instcode'};
1.35 raeburn 1683: if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
1684: $batchhash{'defaultcredits'} = $details->{'defaultcredits'};
1685: }
1.2 raeburn 1686: $batchhash{'emailenc'} = $emailenc;
1687: $batchhash{'adds'} = $details->{'autoadds'};
1688: $batchhash{'drops'} = $details->{'autodrops'};
1689: $batchhash{'authtype'} = $domdefs->{'auth_def'};
1690: $batchhash{'authparam'} = $domdefs->{'auth_arg_def'};
1691: if ($details->{'crstype'} eq 'community') {
1692: $batchhash{'crstype'} = 'Community';
1.53 raeburn 1693: } elsif ($details->{'crstype'} eq 'placement') {
1694: $batchhash{'crstype'} = 'Placement';
1.2 raeburn 1695: } else {
1.41 raeburn 1696: if ($details->{'crstype'} eq 'textbook') {
1697: if ($details->{'clonecrs'} && $details->{'clonedom'}) {
1698: my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});
1699: $batchhash{'textbook'} = $clonedfrom{'description'};
1700: }
1701: }
1.2 raeburn 1702: $batchhash{'crstype'} = 'Course';
1703: }
1.8 raeburn 1704: my ($owner_firstname,$owner_lastname);
1705: if ($context eq 'domain') {
1706: my %userenv = &Apache::lonnet::userenvironment($details->{'domain'},
1707: $details->{'owner'},
1708: 'firstname','lastname');
1709: $owner_firstname = $userenv{'firstname'};
1710: $owner_lastname = $userenv{'lastname'};
1711: } else {
1712: $owner_firstname = $env{'environment.firstname'};
1713: $owner_lastname = $env{'environment.lastname'};
1714: }
1715: if (ref($details->{'personnel'}) eq 'HASH') {
1716: %{$batchhash{'users'}} = %{$details->{'personnel'}};
1717: if (ref($batchhash{'users'}) eq 'HASH') {
1718: foreach my $userkey (keys(%{$batchhash{'users'}})) {
1719: if (ref($batchhash{'users'}{$userkey}) eq 'HASH') {
1720: if (ref($batchhash{'users'}{$userkey}{'roles'}) eq 'ARRAY') {
1721: foreach my $role (@{$batchhash{'users'}{$userkey}{'roles'}}) {
1722: my $start = '';
1723: my $end = '';
1724: if ($role eq 'st') {
1725: $start = $details->{'accessstart'};
1726: $end = $details->{'accessend'};
1727: }
1728: $batchhash{'users'}{$userkey}{$role}{'start'} = $start;
1729: $batchhash{'users'}{$userkey}{$role}{'end'} = $end;
1730: }
1731: }
1732: }
1733: }
1734: }
1735: }
1736: $batchhash{'users'}{$owner}{firstname} = $owner_firstname;
1737: $batchhash{'users'}{$owner}{lastname} = $owner_lastname;
1738: $batchhash{'users'}{$owner}{emailenc} = $emailenc;
1739: $batchhash{'users'}{$owner}{owneremail} = $owneremail;
1.55 raeburn 1740: $batchhash{'setcomment'} = 1;
1.2 raeburn 1741: }
1742: return %batchhash;
1743: }
1744:
1.4 raeburn 1745: sub can_clone_course {
1.51 raeburn 1746: my ($uname,$udom,$clonecrs,$clonedom,$crstype,$dom,$instcode) = @_;
1.4 raeburn 1747: my $canclone;
1.11 raeburn 1748: my $ccrole = 'cc';
1.12 raeburn 1749: if ($crstype eq 'community') {
1.11 raeburn 1750: $ccrole = 'co';
1751: }
1.4 raeburn 1752: my %roleshash = &Apache::lonnet::get_my_roles($uname,$udom,'userroles',['active'],
1.11 raeburn 1753: [$ccrole],[$clonedom]);
1754: if (exists($roleshash{$clonecrs.':'.$clonedom.':'.$ccrole})) {
1.4 raeburn 1755: $canclone = 1;
1756: } else {
1.51 raeburn 1757: my %courseenv = &Apache::lonnet::userenvironment($clonedom,$clonecrs,
1758: ('cloners','internal.coursecode'));
1.4 raeburn 1759: my $cloners = $courseenv{'cloners'};
1.51 raeburn 1760: my $clonefromcode = $courseenv{'internal.coursecode'};
1.4 raeburn 1761: if ($cloners ne '') {
1762: my @cloneable = split(',',$cloners);
1763: if (grep(/^\*$/,@cloneable)) {
1764: $canclone = 1;
1.51 raeburn 1765: } elsif (grep(/^\*:\Q$udom\E$/,@cloneable)) {
1766: $canclone = 1;
1767: } elsif (grep(/^\Q$uname\E:\Q$udom\E$/,@cloneable)) {
1768: $canclone = 1;
1.4 raeburn 1769: }
1.51 raeburn 1770: unless ($canclone) {
1771: if (($clonefromcode) && ($instcode) && ($clonedom eq $dom)) {
1772: my (%gotdomdefaults,%gotcodedefaults);
1773: foreach my $cloner (@cloneable) {
1774: if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) &&
1775: ($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) {
1776: if ($cloner =~ /\=/) {
1777: my (%codedefaults,@code_order);
1778: if (ref($gotcodedefaults{$clonedom}) eq 'HASH') {
1779: if (ref($gotcodedefaults{$clonedom}{'defaults'}) eq 'HASH') {
1780: %codedefaults = %{$gotcodedefaults{$clonedom}{'defaults'}};
1781: }
1782: if (ref($gotcodedefaults{$clonedom}{'order'}) eq 'ARRAY') {
1783: @code_order = @{$gotcodedefaults{$dom}{'order'}};
1784: }
1785: } else {
1786: &Apache::lonnet::auto_instcode_defaults($clonedom,
1787: \%codedefaults,
1788: \@code_order);
1789: $gotcodedefaults{$clonedom}{'defaults'} = \%codedefaults;
1790: $gotcodedefaults{$clonedom}{'order'} = \@code_order;
1791: }
1792: if (@code_order > 0) {
1793: if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order,
1794: $cloner,$clonefromcode,$instcode)) {
1795: $canclone = 1;
1796: last;
1797: }
1798: }
1799: }
1800: }
1801: }
1802: }
1.4 raeburn 1803: }
1.51 raeburn 1804: } else {
1805: my %domdefs = &Apache::lonnet::get_domain_defaults($clonedom);
1806: if ($domdefs{'canclone'}) {
1807: unless ($domdefs{'canclone'} eq 'none') {
1808: if ($domdefs{'canclone'} eq 'domain') {
1809: if ($udom eq $clonedom) {
1810: $canclone = 1;
1811: }
1812: } elsif (($clonefromcode) && ($instcode) &&
1813: ($clonedom eq $dom)) {
1814: if (&Apache::lonnet::default_instcode_cloning($clonedom,$domdefs{'canclone'},
1815: $clonefromcode,$instcode)) {
1816: $canclone = 1;
1817: }
1818: }
1819: }
1.4 raeburn 1820: }
1821: }
1.18 raeburn 1822: unless ($canclone) {
1823: if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) {
1.20 bisitz 1824: $canclone = 1;
1.18 raeburn 1825: }
1826: }
1.4 raeburn 1827: }
1828: return $canclone;
1829: }
1830:
1.13 raeburn 1831: sub get_processtype {
1.30 raeburn 1832: my ($context,$uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_;
1.13 raeburn 1833: return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
1834: if ($uname eq '' || $udom eq '') {
1835: $uname = $env{'user.name'};
1836: $udom = $env{'user.domain'};
1837: $isadv = $env{'user.adv'};
1838: }
1.30 raeburn 1839: my (%userenv,%settings,$val,@options,$envkey);
1840: if ($context eq 'course') {
1841: @options = ('autolimit','validate','approval');
1842: $envkey = 'requestcourses.'.$crstype;
1843: if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
1844: if (ref($domconfig->{'requestcourses'}->{$crstype}) eq 'HASH') {
1845: %settings = %{$domconfig->{'requestcourses'}->{$crstype}};
1846: }
1847: }
1848: } else {
1849: @options = ('automatic','approval');
1850: $envkey = 'requestauthor';
1851: if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
1852: %settings = %{$domconfig->{'requestauthor'}};
1853: }
1854: }
1855: if (($dom eq $udom) || ($context eq 'requestauthor')) {
1.13 raeburn 1856: %userenv =
1.30 raeburn 1857: &Apache::lonnet::userenvironment($udom,$uname,$envkey,'inststatus');
1858: if ($userenv{$envkey}) {
1859: $val = $userenv{$envkey};
1.13 raeburn 1860: @{$inststatuses} = ('_custom_');
1861: } else {
1.30 raeburn 1862: my %alltasks;
1863: if (($isadv) && ($settings{'_LC_adv'} ne '')) {
1.33 raeburn 1864: $val = $settings{'_LC_adv'};
1.30 raeburn 1865: @{$inststatuses} = ('_LC_adv_');
1866: } else {
1867: if ($userenv{'inststatus'} ne '') {
1868: @{$inststatuses} = split(',',$userenv{'inststatus'});
1869: } else {
1870: @{$inststatuses} = ('default');
1871: }
1872: foreach my $status (@{$inststatuses}) {
1873: if (exists($settings{$status})) {
1874: my $value = $settings{$status};
1875: next unless ($value);
1876: unless (exists($alltasks{$value})) {
1877: if (ref($alltasks{$value}) eq 'ARRAY') {
1878: unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
1879: push(@{$alltasks{$value}},$status);
1.13 raeburn 1880: }
1.30 raeburn 1881: } else {
1882: @{$alltasks{$value}} = ($status);
1.13 raeburn 1883: }
1884: }
1.30 raeburn 1885: }
1886: }
1887: my $maxlimit = 0;
1888: if ($context eq 'course') {
1889: foreach my $key (sort(keys(%alltasks))) {
1890: if ($key =~ /^autolimit=(\d*)$/) {
1891: if ($1 eq '') {
1892: $val ='autolimit=';
1893: last;
1894: } elsif ($1 > $maxlimit) {
1895: $maxlimit = $1;
1.13 raeburn 1896: }
1897: }
1.30 raeburn 1898: }
1899: }
1900: if (($context eq 'requestauthor') || (!$val)) {
1901: if ($context eq 'course' && $maxlimit) {
1902: $val = 'autolimit='.$maxlimit;
1903: } else {
1904: foreach my $option (@options) {
1905: if ($alltasks{$option}) {
1906: $val = $option;
1907: last;
1.13 raeburn 1908: }
1909: }
1910: }
1911: }
1912: }
1913: }
1914: } else {
1915: %userenv = &Apache::lonnet::userenvironment($udom,$uname,'reqcrsotherdom.'.$crstype);
1916: if ($userenv{'reqcrsotherdom.'.$crstype}) {
1917: my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
1918: my $optregex = join('|',@options);
1919: foreach my $item (@doms) {
1920: my ($extdom,$extopt) = split(':',$item);
1921: if ($extdom eq $dom) {
1922: if ($extopt =~ /^($optregex)(=?\d*)$/) {
1923: $val = $1.$2;
1924: }
1925: last;
1926: }
1927: }
1928: @{$inststatuses} = ('_external_');
1929: }
1930: }
1931: return $val;
1932: }
1933:
1.14 raeburn 1934: sub queued_selfenrollment {
1935: my ($notitle) = @_;
1936: my $output;
1937: my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests');
1938: my %reqs_by_date;
1939: foreach my $item (keys(%selfenrollrequests)) {
1940: if (ref($selfenrollrequests{$item}) eq 'HASH') {
1941: if ($selfenrollrequests{$item}{'status'} eq 'request') {
1942: if ($selfenrollrequests{$item}{'timestamp'}) {
1943: push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item);
1944: }
1945: }
1946: }
1947: }
1948: if (keys(%reqs_by_date)) {
1949: unless ($notitle) {
1.32 raeburn 1950: $output .= '<br /><b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />';
1.14 raeburn 1951: }
1952: $output .= &Apache::loncommon::start_data_table().
1953: &Apache::loncommon::start_data_table_header_row().
1954: '<th>'.&mt('Date requested').'</th><th>'.&mt('Course title').'</th>'.
1955: '<th>'.&mt('User role').'</th><th>'.&mt('Section').'</th>'.
1956: &Apache::loncommon::end_data_table_header_row();
1957: my @sorted = sort { $a <=> $b } (keys(%reqs_by_date));
1958: foreach my $item (@sorted) {
1959: if (ref($reqs_by_date{$item}) eq 'ARRAY') {
1960: foreach my $crs (@{$reqs_by_date{$item}}) {
1961: my %courseinfo = &Apache::lonnet::coursedescription($crs);
1962: my $usec = $selfenrollrequests{$crs}{'section'};
1.16 raeburn 1963: my $rolename = &Apache::lonnet::plaintext('st',$courseinfo{'type'},$crs);
1.14 raeburn 1964: if ($usec eq '') {
1965: $usec = &mt('No section');
1966: }
1967: $output .= &Apache::loncommon::start_data_table_row().
1968: '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
1969: '<td>'.$courseinfo{'description'}.'</td>'.
1970: '<td>'.$rolename.'</td><td>'.$usec.'</td>'.
1971: &Apache::loncommon::end_data_table_row();
1972: }
1973: }
1974: }
1975: $output .= &Apache::loncommon::end_data_table();
1976: }
1977: return $output;
1978: }
1979:
1.19 raeburn 1980: sub update_coursereq_status {
1.26 raeburn 1981: my ($reqhash,$dom,$cnum,$reqstatus,$context,$udom,$uname) = @_;
1.19 raeburn 1982: my ($storeresult,$statusresult,$output);
1983: my $requestkey = $dom.'_'.$cnum;
1984: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
1985: $storeresult = &Apache::lonnet::store_userdata($reqhash,$requestkey,
1.26 raeburn 1986: 'courserequests',$udom,$uname);
1.19 raeburn 1987: if ($storeresult eq 'ok') {
1988: my %status = (
1989: 'status:'.$dom.':'.$cnum => $reqstatus,
1990: );
1.26 raeburn 1991: $statusresult = &Apache::lonnet::put('courserequests',\%status,$udom,$uname);
1.19 raeburn 1992: }
1993: } else {
1994: $storeresult = 'error: invalid requestkey format';
1995: }
1996: if ($storeresult ne 'ok') {
1997: $output = &mt('An error occurred saving a record of the details of your request: [_1].',$storeresult);
1998: if ($context eq 'domain') {
1999: $output .= "\n";
2000: } else {
2001: $output = '<span class="LC_warning">'.$output.'</span><br />';
2002: }
1.26 raeburn 2003: &Apache::lonnet::logthis("Error saving course request - $requestkey for $uname:$udom - $storeresult");
1.19 raeburn 2004: } elsif ($statusresult ne 'ok') {
2005: $output = &mt('An error occurred saving a record of the status of your request: [_1].',$statusresult);
2006: if ($context eq 'domain') {
2007: $output .= "\n";
2008: } else {
2009: $output = '<span class="LC_warning">'.$output.'</span><br />';
2010: }
1.26 raeburn 2011: &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $uname:$udom) - $statusresult");
1.19 raeburn 2012: }
2013: return ($storeresult,$output);
2014: }
2015:
1.23 raeburn 2016: sub process_official_reqs {
1.26 raeburn 2017: my ($context,$dom,$dcname,$dcdom) = @_;
1.23 raeburn 2018: my $reqsnamespace = 'courserequestqueue';
2019: my %requesthash =
1.24 raeburn 2020: &Apache::lonnet::dump_dom($reqsnamespace,$dom,'_pending');
1.23 raeburn 2021: my (%newcids,%longroles,%stillpending);
2022: my @courseroles = ('cc','in','ta','ep','ad','st');
2023: foreach my $role (@courseroles) {
2024: $longroles{$role}=&Apache::lonnet::plaintext($role);
2025: }
2026: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
1.59 ! raeburn 2027: my ($output,$linefeed,$user_lh);
1.23 raeburn 2028: if ($context eq 'auto') {
2029: $linefeed = "\n";
1.59 ! raeburn 2030: $user_lh = &Apache::loncommon::user_lang($dcname,$dcdom);
1.23 raeburn 2031: } else {
2032: $linefeed = '<br />'."\n";
2033: }
2034: foreach my $key (keys(%requesthash)) {
2035: my ($cnum,$status) = split('_',$key);
2036: next if (&Apache::lonnet::homeserver($cnum,$dom) ne 'no_host');
2037: if (ref($requesthash{$key}) eq 'HASH') {
2038: my $ownername = $requesthash{$key}{'ownername'};
2039: my $ownerdom = $requesthash{$key}{'ownerdom'};
2040: next if (&Apache::lonnet::homeserver($ownername,$ownerdom) eq 'no_host');
2041: my $inststatus;
2042: my %userenv =
2043: &Apache::lonnet::get('environment',['inststatus'],
2044: $ownerdom,$ownername);
2045: my ($tmp) = keys(%userenv);
2046: if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
2047: $inststatus = $userenv{'inststatus'};
2048: } else {
2049: undef(%userenv);
2050: }
2051: my $reqkey = $dom.'_'.$cnum;
2052: my %history = &Apache::lonnet::restore($reqkey,'courserequests',
2053: $ownerdom,$ownername);
2054: if (ref($history{'details'}) eq 'HASH') {
2055: my $instcode = $history{'details'}{'instcode'};
2056: my $crstype = $history{'details'}{'crstype'};
2057: my $reqtime = $history{'details'}{'reqtime'};
2058: my $cdescr = $history{'details'}{'cdescr'};
2059: my @currsec;
2060: my $sections = $history{'details'}{'sections'};
2061: if (ref($sections) eq 'HASH') {
2062: foreach my $i (sort(keys(%{$sections}))) {
2063: if (ref($sections->{$i}) eq 'HASH') {
2064: my $sec = $sections->{$i}{'inst'};
2065: if (!grep(/^\Q$sec\E$/,@currsec)) {
2066: push(@currsec,$sec);
2067: }
2068: }
2069: }
2070: }
2071: my $instseclist = join(',',@currsec);
2072: my ($validationchk,$disposition,$reqstatus,$message,
2073: $validation,$validationerror);
2074: $validationchk =
2075: &Apache::lonnet::auto_courserequest_validation($dom,
2076: $ownername.':'.$ownerdom,$crstype,$inststatus,
2077: $instcode,$instseclist);
2078: if ($validationchk =~ /:/) {
2079: ($validation,$message) = split(':',$validationchk);
2080: } else {
2081: $validation = $validationchk;
2082: }
2083: if ($validation =~ /^error(.*)$/) {
2084: $disposition = 'approval';
2085: $validationerror = $1;
2086: } else {
2087: $disposition = $validation;
2088: }
2089: $reqstatus = $disposition;
2090: if ($disposition eq 'process') {
1.39 raeburn 2091: my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code);
1.59 ! raeburn 2092: my $clonemsg = [];
1.41 raeburn 2093: my %customitems;
2094: my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
2095: my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$ownername,
2096: $ownerdom,$fullname,$cdescr);
2097: if (ref($inprocess) eq 'HASH') {
2098: foreach my $key (keys(%{$inprocess})) {
2099: if (exists($history{'details'}{$key})) {
2100: $customitems{$key} = $history{'details'}{$key};
2101: }
2102: }
2103: }
1.50 raeburn 2104: if ($history{'details'}{'clonecrs'}) {
2105: $customitems{'_LC_clonefrom'} = $history{'details'}{'clonedom'}.'_'.$history{'details'}{'clonecrs'};
2106: }
1.41 raeburn 2107: my ($result,$postprocess) =
1.59 ! raeburn 2108: &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,$clonemsg,\$newusermsg,
! 2109: \$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
! 2110: \$code,\%customitems,$context,$user_lh);
1.23 raeburn 2111: if ($result eq 'created') {
2112: $disposition = 'created';
2113: $reqstatus = 'created';
1.26 raeburn 2114: my $cid = $dom.'_'.$cnum;
2115: push(@{$newcids{$instcode}},$cid);
2116: if ($dcname && $dcdom) {
1.54 raeburn 2117: my $firsturl = &Apache::lonnet::course_portal_url($cnum,$dom);
1.26 raeburn 2118: my $beneficiary = 'pendingrequestor';
2119: my $now = time;
2120: my $owner = $ownername.':'.$ownerdom;
2121: my $approvedmsg =
2122: [{
1.27 raeburn 2123: mt => 'Your requested course: [_1], (queued pending validation) has now been created.',
2124: args => [$cdescr],
1.59 ! raeburn 2125: }];
! 2126: if ((ref($clonemsg) eq 'ARRAY') && (@{$clonemsg})) {
! 2127: push(@{$approvedmsg},@{$clonemsg});
! 2128: }
! 2129: push(@{$approvedmsg},
1.26 raeburn 2130: {
1.28 raeburn 2131: mt => 'Visit [_1] to log-in and access the course.',
1.26 raeburn 2132: args => [$firsturl],
1.27 raeburn 2133: },
2134: {
1.59 ! raeburn 2135: mt => 'If currently logged-in to LON-CAPA, log-out and log-in again to select your new course role.',
! 2136: args => [],
! 2137: }
! 2138: );
1.26 raeburn 2139: my $sender = $dcname.':'.$dcdom;
1.41 raeburn 2140: if (ref($postprocess) eq 'HASH') {
2141: if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
2142: foreach my $item (@{$postprocess->{'createdmsg'}}) {
2143: if (ref($item) eq 'HASH') {
2144: if ($item->{'mt'} ne '') {
2145: push(@{$approvedmsg},$item);
2146: }
2147: }
2148: }
2149: }
1.48 raeburn 2150: if (ref($postprocess->{'createdactions'}) eq 'HASH') {
2151: if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') {
2152: &postprocess_crsenv($dom,$cnum,$postprocess->{'createdactions'}{'environment'});
2153: }
2154: }
1.41 raeburn 2155: }
1.26 raeburn 2156: &send_selfserve_notification($owner,$approvedmsg,
2157: $cid,$cdescr,$now,
2158: $beneficiary,$sender,
2159: undef,undef,$crstype);
2160: }
1.23 raeburn 2161: }
2162: } elsif ($disposition eq 'rejected') {
2163: $output .= &mt('Queued course request for [_1] submitted by [_2] with status [_3] rejected when validating.',$instcode,$ownername.':'.$ownerdom,$inststatus).$linefeed;
2164: } elsif ($disposition eq 'approval') {
2165: $output .= &mt('Queued course request for [_1] submitted by [_2] with status [_3] switched to "approval by DC" because of validation error: [_4].',$instcode,$ownername.':'.$ownerdom,$inststatus,$validationerror).$linefeed;
2166:
2167: my $requestid = $cnum.'_'.$disposition;
2168: my $request = {
2169: $requestid => {
2170: timestamp => $reqtime,
2171: crstype => $crstype,
2172: ownername => $ownername,
2173: ownerdom => $ownerdom,
2174: description => $cdescr,
2175: },
2176: };
2177: my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,$dom);
2178: unless ($putresult eq 'ok') {
2179: $output .= &mt("An error occurred saving the modified course request for [_1] submitted by [_2] in the domain's courserequestqueue.db.",$instcode,$ownername.':'.$ownerdom).$linefeed;
2180: }
2181: } elsif ($disposition eq 'pending') {
2182: my $instcode = $requesthash{$key}{'instcode'};
2183: my $description = $requesthash{$key}{'description'};
2184: my $timestamp = $requesthash{$key}{'timestamp'};
2185: my $entry = $cnum.':'.$ownername.':'.$ownerdom.':'.
2186: $instcode.':'.$description;
2187: if (ref($stillpending{$timestamp}) eq 'ARRAY') {
2188: push(@{$stillpending{$timestamp}},$entry);
2189: } else {
2190: $stillpending{$timestamp} = [$entry];
2191: }
2192: }
2193: unless ($disposition eq 'pending') {
2194: my ($statusresult,$output) =
2195: &update_coursereq_status(\%requesthash,$dom,$cnum,
1.26 raeburn 2196: $reqstatus,'domain',$ownerdom,
2197: $ownername);
1.23 raeburn 2198: unless (&Apache::lonnet::del_dom($reqsnamespace,[$cnum.'_pending'],$dom) eq 'ok') {
2199: $output .= &mt('An error occurred when removing the request for [_1] submitted by [_2] from the pending queue.',$instcode,$ownername.':'.$ownerdom).$linefeed;
2200: }
2201: }
2202: }
2203: }
2204: }
2205: foreach my $key (sort(keys(%newcids))) {
2206: if (ref($newcids{$key}) eq 'ARRAY') {
2207: $output .= "created course from queued request: $key - ".join(', ',@{$newcids{$key}}).$linefeed;
2208: my $newcourse = &LONCAPA::escape($key.':'.$newcids{$key});
2209: }
2210: }
2211: unless ($context eq 'auto') {
2212: if (keys(%stillpending) > 0) {
2213: $output .= '<form method="post" name="changequeue" action="/adm/createcourse" />'."\n".
2214: '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
2215: '<input type="hidden" name="phase" value="requestchange" />'.
2216: '<p>'.&mt('For the following requests, the requestor could [_1]not[_2] be validated as official course personnel, so the request remains in the pending queue.','<b>','</b>').'<br />'.&mt('Requests may be left in the queue, or you can manually approve or reject them.').'</p>'.
2217: &build_queue_display($dom,'stillpending',\%stillpending).
2218: '<br /><input type="hidden" name="queue" value="pending" />'."\n".
2219: '<input type="submit" name="processqueue" value="'.&mt('Save').'" />'.
2220: '</form>';
2221: }
2222: }
2223: return $output;
2224: }
2225:
1.48 raeburn 2226: sub postprocess_crsenv {
2227: my ($dom,$cnum,$postprocessenv) = @_;
2228: if (ref($postprocessenv) eq 'HASH') {
2229: my $cid = $dom.'_'.$cnum;
2230: my %settablecrsenv = (
2231: 'internal.selfenroll_types' => 1,
2232: 'internal.selfenroll_registered' => 1,
2233: 'internal.selfenroll_section' => 1,
2234: 'internal.selfenroll_start_access' => 1,
2235: 'internal.selfenroll_end_access' => 1,
2236: 'internal.selfenroll_limit' => 1,
2237: 'internal.selfenroll_cap' => 1,
2238: 'internal.selfenroll_approval' => 1,
2239: 'internal.selfenroll_notifylist' => 1,
2240: );
2241: my %needcrsidput = (
2242: 'internal.selfenroll_types' => 1,
2243: 'internal.selfenroll_start_date' => 1,
2244: 'internal. selfenroll_end_date' => 1,
2245: );
2246: my (@needupdate,%newcrsenv);
2247: foreach my $key (keys(%{$postprocessenv})) {
2248: if ($settablecrsenv{$key}) {
2249: $newcrsenv{$key} = $postprocessenv->{$key};
2250: if ($needcrsidput{$key}) {
2251: push(@needupdate,$key);
2252: }
2253: }
2254: if (keys(%newcrsenv)) {
2255: my $putresult = &Apache::lonnet::put('environment',\%newcrsenv,$dom,$cnum);
2256: if ($putresult eq 'ok') {
2257: if (@needupdate) {
2258: my %crsinfo =
2259: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',$cnum,undef,undef,'.');
2260: if (ref($crsinfo{$cid}) eq 'HASH') {
2261: foreach my $key (@needupdate) {
2262: $crsinfo{$cid}{$key} = $newcrsenv{$key};
2263: }
2264: my $chome = &Apache::lonnet::homeserver($cnum,$dom);
2265: &Apache::lonnet::courseidput($dom,\%crsinfo,$chome,'notime');
2266: }
2267: }
2268: }
2269: }
2270: }
2271: }
2272: return;
2273: }
2274:
2275:
1.45 raeburn 2276: sub requestcourses_validation_types {
2277: my @items = ('url','fields','button','markup');
2278: my %names = &Apache::lonlocal::texthash (
2279: url => 'Web address of validation server/script',
2280: fields => 'Form fields to send to validator',
2281: button => 'Text for validation button',
2282: markup => 'Validation description (HTML)',
2283: );
2284: my @fields = ('owner','course','coursetype','description');
2285: return (\@items,\%names,\@fields);
2286: }
2287:
1.31 raeburn 2288: sub is_active_author {
2289: if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) {
2290: if ((!$1 || $1 < time) &&
2291: (!$2 || $2 > time)) {
2292: return 1;
2293: }
2294: }
2295: }
2296:
2297: sub author_prompt {
2298: my ($is_active_author,$offer_author);
2299: if ($env{'environment.canrequest.author'}) {
2300: unless (&is_active_author()) {
1.32 raeburn 2301: unless (&reqauthor_check() =~ /^approval:\d+$/) {
2302: $offer_author = 1;
1.31 raeburn 2303: }
2304: }
2305: }
2306: return $offer_author;
2307: }
2308:
2309: sub reqauthor_check {
2310: my $queued = $env{'environment.requestauthorqueued'};
2311: my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'],
2312: $env{'user.domain'},$env{'user.name'});
2313: my $reqstatus = $reqauthor{'author_status'};
2314: if (($reqstatus eq '' && $queued ne '') ||
2315: ($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) {
2316: if (ref($reqauthor{'author'}) eq 'HASH') {
2317: $queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'};
2318: } else {
2319: undef($queued);
2320: }
2321: &Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued});
2322: }
2323: return $queued;
2324: }
2325:
2326: sub process_reqauthor {
2327: my ($dispositionref,$updateref) = @_;
2328: if (&is_active_author()) {
2329: return '<span class="LC_warning">'.
1.42 bisitz 2330: &mt('An Authoring Space has already been assigned to you.').'<br />'.
1.31 raeburn 2331: &mt('Please select the Author role from your [_1]roles page[_2].','<a href="/adm/roles">',
2332: '</a>').'</span>';
2333: }
2334: unless ($env{'environment.canrequest.author'}) {
2335: return '<span class="LC_warning">'.
1.42 bisitz 2336: &mt('You do not currently have rights to request an Authoring Space.').'<br />'.
1.37 raeburn 2337: &mt('Please contact the [_1]helpdesk[_2] for assistance.','<a href="/adm/helpdesk">',
1.31 raeburn 2338: '</a>').'</span>';
2339: }
2340: my $queued = &reqauthor_check();
2341: if ($queued =~ /^approval:(\d+)$/) {
2342: my $timestamp = $1;
2343: return '<span class="LC_info">'.
1.42 bisitz 2344: &mt('A request for Authoring Space submitted on [_1] is awaiting approval',
1.31 raeburn 2345: &Apache::lonlocal::locallocaltime($timestamp)).
2346: '</span>';
2347: } elsif ($queued =~ /^approved:(\d+)$/) {
2348: my $timestamp = $1;
2349: my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
2350: ['active'],['au'],[$env{'user.domain'}]);
2351: if (keys(%roleshash) > 0) {
2352: return '<span class="LC_info">'.
1.42 bisitz 2353: &mt('A request for Authoring Space submitted on [_1] has been approved.',
1.31 raeburn 2354: &Apache::lonlocal::locallocaltime($timestamp)).
2355: '</span>';
2356: }
2357: }
2358: my ($output,@inststatuses,%domconfig);
2359: %domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'],
2360: $env{'user.domain'});
2361: my $val = &get_processtype('requestauthor',$env{'user.name'},$env{'user.domain'},
2362: $env{'user.adv'},$env{'user.domain'},undef,
2363: \@inststatuses,\%domconfig);
2364: my $now = time;
2365: if ($val eq 'automatic') {
2366: my $start = $now-1;
2367: if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/',
2368: 'au',undef,$start,undef,undef,'requestauthor') eq 'ok') {
2369: $output = '<span class="LC_info">'.
1.42 bisitz 2370: &mt('Access to Authoring Space has been activated').'</span><br />';
1.31 raeburn 2371: &Apache::lonroles::update_session_roles();
2372: &Apache::lonnet::appenv({'user.update.time' => $now});
2373: if (ref($updateref)) {
2374: $$updateref = $now;
2375: }
2376: if (ref($dispositionref)) {
2377: $$dispositionref = 'created';
2378: }
2379: } else {
2380: $output = '<span class="LC_info">'.
1.42 bisitz 2381: &mt('An error occurred while activating your access to Authoring Space');
1.31 raeburn 2382: }
2383: } elsif ($val eq 'approval') {
2384: my $domconfiguser = &Apache::lonnet::get_domainconfiguser($env{'user.domain'});
2385: if (&Apache::lonnet::put('requestauthorqueue',{ $env{'user.name'}.'_'.$val => $now },
2386: $env{'user.domain'},$domconfiguser) eq 'ok') {
2387: my %userrequest = (
2388: author => {
2389: timestamp => $now,
2390: status => $val,
2391: },
2392: author_status => $val,
2393: );
2394: my $req_notifylist;
2395: if (ref($domconfig{'requestauthor'}) eq 'HASH') {
2396: if (ref($domconfig{'requestauthor'}{'notify'}) eq 'HASH') {
2397: my $req_notifylist = $domconfig{'requestauthor'}{'notify'}{'approval'};
2398: if ($req_notifylist) {
2399: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
2400: $env{'user.domain'});
2401: my $sender = $env{'user.name'}.':'.$env{'user.domain'};
2402: my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
2403: &send_selfserve_notification($req_notifylist,
2404: "$fullname ($env{'user.name'}:$env{'user.domain'})",
2405: undef,$domdesc,$now,'authorreq',$sender);
2406: }
2407: }
2408: }
2409: my $userresult =
2410: &Apache::lonnet::put('requestauthor',\%userrequest,$env{'user.domain'},$env{'user.name'});
2411: $output = '<span class="LC_info">'.
1.42 bisitz 2412: &mt('Your request for Authoring Space has been submitted for approval.').
1.31 raeburn 2413: '</span>';
2414: &Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now});
2415: } else {
2416: $output = '<span class="LC_info">'.
1.42 bisitz 2417: &mt('An error occurred saving your request for Authoring Space.').
1.31 raeburn 2418: '</span>';
2419: }
2420: }
2421: return $output;
2422: }
2423:
1.1 raeburn 2424: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>