forked from vanderbilt-redcap/email-alerts-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddQueue.php
More file actions
81 lines (69 loc) · 2.54 KB
/
Copy pathaddQueue.php
File metadata and controls
81 lines (69 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Vanderbilt\EmailTriggerExternalModule;
use ExternalModules\AbstractExternalModule;
use ExternalModules\ExternalModules;
require_once __DIR__.'/vendor/autoload.php';
$project_id = $_GET['pid'];
$index = $_REQUEST['index_modal_queue'];
$times_sent = $_REQUEST['times_sent'];
$last_sent = $_REQUEST['last_sent'];
$queue_ids = $_POST['queue_ids'];
$event_id = $_POST['queue_event_select'];
$queue_instances = $_POST['queue_instances'];
if($queue_instances == "") {
$instance = "1";
}if (strpos($queue_instances, ";") !== false) {
$instance = explode(";", $queue_instances);
} else if (strpos($queue_instances, ",") !== false) {
$instance = explode(",", $queue_instances);
} else if (strpos($queue_instances, "\n") !== false) {
$instance = explode("\n", $queue_instances);
}else if ($queue_instances != ""){
$instance = $queue_instances;
}
$failed_records = array();
if (strpos($queue_ids, ";") !== false) {
$record = explode(";", $queue_ids);
} else if (strpos($queue_ids, ",") !== false) {
$record = explode(",", $queue_ids);
} else if (strpos($queue_ids, "\n") !== false) {
$record = explode("\n", $queue_ids);
} else if ($queue_ids != "") {
if(is_array($instance)){
foreach ($instance as $one_instance){
$failed = $module->addQueueEmailFromInterface($project_id, $index, $queue_ids, $times_sent, $event_id, $last_sent, $one_instance);
if($failed != ""){
array_push($failed_records,$failed);
}
}
}else{
$failed = $module->addQueueEmailFromInterface($project_id, $index, $queue_ids, $times_sent, $event_id, $last_sent, $instance);
if($failed != ""){
array_push($failed_records,$failed);
}
}
} else {
//ERROR
$message = "Incorrect format. Couldn't generate PDF.";
}
if ($record != "") {
foreach ($record as $id) {
if(is_array($instance)){
foreach ($instance as $one_instance){
$failed = $module->addQueueEmailFromInterface($project_id, $index, $id, $times_sent, $event_id, $last_sent, $one_instance);
if($failed != ""){
array_push($failed_records,$failed);
}
}
}else{
$failed = $module->addQueueEmailFromInterface($project_id, $index, $id, $times_sent, $event_id, $last_sent, $instance);
if($failed != ""){
array_push($failed_records,$failed);
}
}
}
}
echo json_encode(array(
'status' => 'success',
'failed_records' => $failed_records
));