Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
eac8b60
Fix issue where module is unable to move checkbox data over; Fix issu…
Mar 7, 2022
c673869
Update DataEntryTriggerBuilder.php
Mar 8, 2022
efae8db
Added functionality to save survey url
Mar 8, 2022
793e6d6
Fixed bugs with saving survey url
Mar 8, 2022
85d0fe4
Saving url autocomplete fixes
Mar 8, 2022
2ca0d0d
Bug Fixes
Mar 8, 2022
9f54442
Bug fix for survey generation
Mar 8, 2022
3d04922
Minor updates
Mar 8, 2022
e33b219
Updated module to use event ID in survey url generation
Mar 9, 2022
d19fb2f
Added condition for survey generation
Mar 9, 2022
6d2a63b
Made form field optional
Mar 9, 2022
e6d3a88
Added checks to form validation
Mar 9, 2022
b7958fc
Updated form text
Mar 9, 2022
4cddc10
Changed incorrect assignment operator
Mar 11, 2022
7d1c600
Added HTML and Jquery for new feature
Mar 12, 2022
54c02dc
Implemented prefix/postfix backend functionality
Mar 14, 2022
d0cdd69
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
e92629f
Fixed "else if" statement
Mar 14, 2022
cd88a46
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
5dcd807
Changed JQuery attr function to prop
Mar 14, 2022
aa927d3
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
3717367
Moved checked attribute in HTML
Mar 14, 2022
e025169
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
7a6fce6
Fixed error with appending prefix to linking ID.
Mar 14, 2022
8cef3e1
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
acf4cbb
Updated HTML text
Mar 14, 2022
1d5d8ea
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
e3f42c4
Removed a reference to "event_1_arm_1"; HTML change
Mar 14, 2022
209089d
Merge branch 'save-survey-url' into staging
Mar 14, 2022
ae3159c
Fixed bug with moving data between two classic projects
Mar 14, 2022
38cd52b
Merge branch 'master' into staging
Mar 14, 2022
0d5c6c7
Updated HTML text
Mar 14, 2022
44fa553
Merge branch 'generate-custom-record-id' into staging
Mar 14, 2022
5bd4af1
Added "z-index" css to modals
Mar 31, 2022
b6f1374
Updated README.md
Mar 31, 2022
cd51e61
Started implementing new functionality
Apr 6, 2022
f662756
Added checking of empty record values when importing
Apr 7, 2022
776eabd
Removed filtering for empty record values when importing
Apr 7, 2022
44b80a6
Added destination event for form when moving whole instruments
Apr 7, 2022
d64f81f
Form now populates saved events to move instruments to.
Apr 7, 2022
2df5805
UI changes
Apr 7, 2022
121436b
Added missing semicolon
Apr 7, 2022
e62a694
UI Changes
Apr 7, 2022
43f8f4d
Fixed JS error
Apr 7, 2022
b8c7945
Updated backend of module
Apr 7, 2022
deb6a3f
Updated form validation
Apr 7, 2022
de03786
UI Changes
Apr 7, 2022
6fc217d
Updated HTML ID
Apr 7, 2022
2a66f65
Updated JS
Apr 7, 2022
520b02b
Merge branch 'move-whole-instruments-to-any-event' into staging
Apr 7, 2022
28630db
Updated form UI
Apr 11, 2022
b608ff0
More form UI changes
Apr 11, 2022
6f681b6
Started updating UI for multi arm compatibility
May 4, 2022
5c5f100
Removed PHP injection in functions.js
May 4, 2022
aef6dbf
Fixed bug with appending strings in JS; Added html
May 4, 2022
0b2adb1
Update functions.js
May 4, 2022
f300fd4
Update functions.js
May 4, 2022
c051345
Update functions.js
May 4, 2022
275a56a
Update functions.js
May 4, 2022
ad245ea
Updated UI to include generating survey urls with multi-arm compatibi…
May 4, 2022
b446c74
Update functions.js
May 4, 2022
fbe7522
Update functions.js
May 4, 2022
1d371e0
Added border to properly group triggers/data
May 4, 2022
45a2bd3
Fixing JS and HTML names for multi-arm compatibility
May 4, 2022
d052686
Update script.php
May 4, 2022
f86baac
Updating UI for multi-arm compattibility
May 4, 2022
5d78fbc
Updates to populating autocomplete items
May 4, 2022
a2493d0
Updating error checking
May 5, 2022
ceed238
Updates to form validation
May 5, 2022
5e31421
Form validation updates
May 5, 2022
8761d8b
Redid names for form submission
May 5, 2022
00b324f
Update functions.js
May 5, 2022
49c232b
Update functions.js
May 5, 2022
39334de
Reworked error handling
May 5, 2022
2a9df3d
Update SubmitForm.php
May 5, 2022
2dfe7a5
More form validation updates
May 5, 2022
b4a6d3c
Update SubmitForm.php
May 5, 2022
7bb33c6
Form validation fixes
May 5, 2022
6249fcf
Validation fixes
May 5, 2022
8628aa4
Update script.php
May 5, 2022
b22dc96
Updated form loading for existing DET
May 5, 2022
39a8469
Update index.php
May 5, 2022
fd049cc
Updated UI text
May 5, 2022
ee5c38a
Updated form names in index.php
May 6, 2022
6f9b6fe
More UI Change; commented release notes functionality
May 6, 2022
f271b86
Added class names to form items
May 6, 2022
c78ca10
Added alert to appear when errors present
May 6, 2022
7a81a38
Updated redcap_save_record to have multi-arm compatibility
May 6, 2022
9c9490f
Fixed issues with moving data, and autocomplete item functionality
May 9, 2022
9029c2d
Initialize variable at beginning for for-loop
May 9, 2022
6afe122
Update DataEntryTriggerBuilder.php
May 9, 2022
3978a74
Replaced framework method with REDCap plugin method
May 9, 2022
bd014f0
Added "Confirm the following" functionality to be multi-arm compatible
May 9, 2022
b56399d
Update index.php
May 9, 2022
0864952
Update index.php
May 9, 2022
6585e69
Update index.php
May 9, 2022
324b449
Update index.php
May 9, 2022
58ef4a2
Update functions.js
May 9, 2022
dda6544
Made changes to add multi-project compatibility
May 10, 2022
e8cd6cb
Update index.php
May 10, 2022
089bd5e
Update JS
May 10, 2022
a449b67
Update JS
May 10, 2022
c084b06
Update JS for projects
May 10, 2022
80dea03
Added logging
May 10, 2022
b5a3ed2
Update JS
May 10, 2022
48d3bee
More updates for multi-project compatibility
May 10, 2022
ec7197e
Update functions.js
May 10, 2022
ba613b9
Update script.php
May 10, 2022
2a06800
Update script.php
May 10, 2022
28ac9b4
Updating JS to populate forms, when DET already exists
May 10, 2022
56c600f
Update script.php
May 10, 2022
1ae2af5
Update script.php
May 10, 2022
90fc4c4
Update script.php
May 10, 2022
dc09b51
Removed unnecessary for loop
May 10, 2022
ed2e772
Update script.php
May 10, 2022
4dd3151
Update script.php
May 10, 2022
1862bbe
Update script.php
May 10, 2022
4c78140
Update functions.js
May 10, 2022
8bebb06
Update functions.js
May 10, 2022
9b5ad90
Update functions.js
May 10, 2022
16693d9
Update functions.js
May 10, 2022
6636fd6
Updated addTrigger function
May 11, 2022
975f047
Added ajax call to update autocomplete items when opening modals
May 11, 2022
fb86423
Fixed issues with ajax call when opening modals
May 11, 2022
deaf681
Bound new click event to update autocomplete items for modals
May 11, 2022
d93617a
Updated function
May 11, 2022
06dc758
Updated ajax call
May 11, 2022
bb42739
Update script.php
May 11, 2022
4bc02f0
Update index.php
May 11, 2022
94b1af0
Update index.php
May 17, 2022
8e08aa1
Update script.php
May 17, 2022
261c8f4
Added text to form
May 17, 2022
32f2385
Added trigger numbering
May 17, 2022
bcac7fe
Fixed trigger numbering
May 17, 2022
44e4e59
Update functions.js
May 18, 2022
f6139d1
Removed redundant code
May 19, 2022
43d8d8a
Updated setting event when moving data
May 20, 2022
569661b
Update DataEntryTriggerBuilder.php
May 20, 2022
c69ef0c
Moved when to set event name
May 20, 2022
bcee637
Creating empty record for event, if it doesn't exist
May 20, 2022
ac092a9
Update index.php
May 20, 2022
30328c2
Updated README, and photots
May 25, 2022
02eadeb
Updated README.md and added photots
May 25, 2022
3b6dfe4
Update README.md
May 25, 2022
5f0884d
Update README.md
May 25, 2022
1f1eeb4
Update README.md
May 25, 2022
b120441
Update README.md
May 25, 2022
60976f8
Update README.md
May 25, 2022
1920629
Update README.md
May 25, 2022
bdb468e
Update README.md
May 31, 2022
eebaf2b
Added acknowledgement, fixed bug with DAGS not moving
Jun 3, 2022
a2e9544
Updated README, and config.json
Aug 19, 2022
dfdc966
Update config.json
Aug 19, 2022
82ce854
Update DataEntryTriggerBuilder.php
Aug 23, 2022
bc02050
Update DataEntryTriggerBuilder.php
Aug 29, 2022
cd8001b
Update index.php
Sep 1, 2022
ca7f7c2
Update DataEntryTriggerBuilder.php
Sep 2, 2022
09db455
Updated README and composer.lock
Sep 7, 2022
67e3209
Update DataEntryTriggerBuilder.php
Sep 12, 2022
1a77037
Update DataEntryTriggerBuilder.php
Sep 12, 2022
4183ce8
Update DataEntryTriggerBuilder.php
Sep 14, 2022
38fa20e
Update DataEntryTriggerBuilder.php
Oct 4, 2022
c96e050
Release Notes Update
Mar 15, 2023
3fb689a
Update functions.js
Mar 15, 2023
5ef1403
Update config.json
Mar 15, 2023
b9ab1a2
Update config.json
Mar 15, 2023
c3db69f
Update config.json
Mar 29, 2023
fe04b64
Updated logging
Mar 30, 2023
af00b27
Update config.json and README
Mar 30, 2023
eb1f087
Update index.php
Sep 15, 2023
8204108
Update config.json
Sep 15, 2023
e183f34
Added CSRF Tokens to all ajax calls
Oct 24, 2023
1015283
Updated bootstrap to Boostrap 5
Oct 24, 2023
e0e13b5
Fixed issue with saved settings not parsing or saving correctly as JSON
Oct 25, 2023
2c83898
Update DataEntryTriggerBuilder.php
Oct 25, 2023
eb45a09
Format Change Handling
Oct 30, 2023
89327be
Update DataEntryTriggerBuilder.php
Dec 1, 2023
bcb61f2
New Feature, and Updated Composer Files
Dec 6, 2023
14d7025
Update DataEntryTriggerBuilder.php
Dec 7, 2023
67cd46d
Update config.json
Dec 7, 2023
0f291b2
Update index.php
Dec 8, 2023
1c8e90c
Update index.php
Jun 19, 2024
4cfa5ad
PHP 8 Compatibility Updates
fom-ds-redcap Aug 26, 2024
5a8a098
Update index.php
fom-ds-redcap Aug 27, 2024
6230dc2
Update index.php
fom-ds-redcap Aug 27, 2024
84c4182
Update DataEntryTriggerBuilder.php
fom-ds-redcap Aug 28, 2024
1ff5d14
Update DataEntryTriggerBuilder.php
fom-ds-redcap Aug 28, 2024
b37cbc8
Update config.json
fom-ds-redcap Aug 28, 2024
01c12ee
Update DataEntryTriggerBuilder.php
fom-ds-redcap Aug 28, 2024
333e217
Update index.php
fom-ds-redcap Jan 9, 2025
49eaf39
Update DataEntryTriggerBuilder.php
fom-ds-redcap Feb 27, 2025
ad1c155
Update DataEntryTriggerBuilder.php
fom-ds-redcap Feb 27, 2025
4601ce1
Added option to move data access groups conditionally
fom-ds-redcap Jun 19, 2025
74982e7
Made [redcap_data_access_group] lowercase, Updated UI
fom-ds-redcap Jun 25, 2025
1bd3c61
Updated functionality to move DAGs
fom-ds-redcap Jul 2, 2025
ac54954
Updated text to move DAGs
fom-ds-redcap Jul 3, 2025
58736e1
Bug Fix
fom-ds-redcap Jul 8, 2025
ae2c88d
Update index.php
fom-ds-redcap Oct 30, 2025
078e0ea
Update DataEntryTriggerBuilder.php
fom-ds-redcap Dec 10, 2025
3768258
Increased trigger limit
fom-ds-redcap Dec 10, 2025
beb5d31
Update functions.js
fom-ds-redcap Dec 10, 2025
7e94318
Added option to give your DET a title
fom-ds-redcap Dec 11, 2025
7594e63
Added title option to each trigger
fom-ds-redcap Dec 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,462 changes: 826 additions & 636 deletions DataEntryTriggerBuilder.php

Large diffs are not rendered by default.

83 changes: 56 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,87 @@
# Data Entry Trigger Builder Instructions
# Data Entry Trigger Builder

1. Make sure the module has been enabled in your project. After, navigate to External Modules, in your REDCap sidebar. Only administrators can see the link.
## Acknowledgement

![Step1](imgs/step1.jpg)
Some functionality within the module has been inspired by work done by Andy Martin (https://github.com/123andy), Jae Lee, and Ihab Zeedia at Stanford University.

2. Select your destination project. Your current project is automatically used as the source. If you’ve exported your DET settings from another project, you may import them, instead.
## Important

![Step2](imgs/step2.jpg)
This modules is an updated version of the module developed at BC Children's Hospital Research Institute. When switching from the previous module (https://github.com/BCCHR-IT/data-entry-trigger-builder), you'll have to enter your previous settings again, by hand. This is because the settings are stored as JSON in REDCap, and the structure of the JSON object has changed with ours. The module will not function otherwise.

3. Determine which fields you’ll use to link your source and destination projects. These fields will be used to link records between the projects, when at least one trigger condition is met.
## Instructions

![Step3](imgs/step3.jpg)
1. Make sure the module has been enabled in your project. After, navigate to External Modules, in your REDCap sidebar. Only administrators with "Access to all projects and data with maximum user privileges" can see the link.

4. Add a trigger to move data. Multiple conditions can be chained in one trigger using && (AND), or || (OR). See the table attached to the module, for allowed qualifiers.
![CustomApplicationLink](imgs/customApplicationLink.jpg)

![Step4](imgs/step4.jpg)
2. Add a trigger to move data. Multiple conditions can be chained in one trigger using && (AND), or || (OR). See the table attached to the module, for allowed qualifiers. If you’ve exported your DET settings from another project, you may import them, instead.

![AddTrigger](imgs/addTrigger.png)

The following form will appear.

![AddTriggerForm](imgs/addTriggerForm.png)

Start by creating a trigger. Data movement will occur when your trigger is met.

![CreateTrigger](imgs/createTrigger.png)

3. Select your destination project. Your current project is automatically used as the source.

![SelectDestination](imgs/selectDestination.png)

4. Determine which fields you’ll use to link your source and destination projects. These fields will be used to link records between the projects, when at least one trigger condition is met.

![RecordLinkage](imgs/recordLinkage.png)

(OPTIONAL) Decide whether you want to append a static prefix, or postfix to the linking value.

![PrefixPostfix](imgs/addPrefixPostfix.png)

5. Add data to move when the condition is true.

![Step5](imgs/step5.jpg)
![DataMovement](imgs/dataMovement.png)

Or create an empty record

5.
1. Add an instrument to move. This can only work if there’s a one-to-one relationship between the selected instrument and another instrument in the destination project. Meaning all fields in the source instrument, must exist in the destination instrument.
2. Add a field to move. You can choose to pipe a field, or manually set a value to move. (i.e set completion status to ‘2’)
![CreateEmptyRecord](imgs/createEmptyRecords.png)

Data Movement Options:

- Add an instrument to move. All fields in the chosen instrument must exist in the destination project, for the chosen event.
- Add a field to move. You can choose to pipe a field, or manually set a value to move. (i.e set completion status to ‘2’)

![Step5b](imgs/step5b.jpg)
![AddField](imgs/addField.jpg)

6. The module will allow up to ten triggers that each move their own data.
6. (OPTIONAL) Determine whether the module will pull the url for a survey into your source project, and where to save it.

![Step6](imgs/step6.jpg)
![GenerateSurveyUrl](imgs/generateSurveyURLs.png)

7. Determine whether you want blank fields to overwrite data in the destination project.

![Step7](imgs/step7.jpg)
![OverwriteData](imgs/overwriteData.jpg)

8. Determine whether you want to import DAGs to the destination project. This will only work if the DAGs are identical between projects.

![Step8](imgs/step8.jpg)
![ImportDAGs](imgs/importDAGs.jpg)

9. The module will allow up to 10 triggers that each move their own data.

9. Save your DET. If it passes validation, then it will automatically run every time data is entered via a survey or data entry. Otherwise errors will be returned to you for correction. The DET will not save until your errors are corrected.
10. Save your DET. If it passes validation, then it will automatically run every time data is entered via a survey or data entry. Otherwise errors will be returned to you for correction. The DET will not save until your errors are corrected.

10. Once your DET is created, refresh the page, then you can export the settings as a JSON string.
11. Once your DET is created, refresh the page, then you can export the settings as a JSON string.

![Step9](imgs/step9.JPG)
![ExportSettings](imgs/exportSettings.JPG)

11. The module logs all DET activity. It will log successes, warnings, and errors. You may check there whenever you want to check on the status of your DET.
12. The module logs all DET errors. You may check there whenever you want to check on the status of your DET.

# Warnings

1. Any changes made to the REDCap project, after the DET has been created, has the potential to break it. After you’ve updated your project, please make sure to update the DET in accordance with your changes.
- Any changes made to the REDCap project, after the DET has been created, has the potential to break it. After you’ve updated your project, please make sure to update the DET in accordance with your changes.
- Functionality developed at BCCHR to export your settings to a word document has been disabled, as it has not been made compatible with the new JSON structure.
- Module now logs to the external module logs, rather than a project's regular logs.

# Limitations

1. Is not compatible with repeatable instruments.
2. Can only be used within the same instance of REDCap.
3. Can have a maximum of 10 triggers, with unlimited data to pipe.
4. Is not compatible with mult-arm projects at the moment.
- Is not compatible with repeatable instruments.
- Can have a maximum of 10 triggers, with unlimited data to pipe.
143 changes: 72 additions & 71 deletions SubmitForm.php
Original file line number Diff line number Diff line change
@@ -1,133 +1,134 @@
<?php

/**
* Before sainv the DET settings, validate, and return any errors.
*/

$data_entry_trigger_builder = new BCCHR\DataEntryTriggerBuilder\DataEntryTriggerBuilder();

$settings = $_POST;
$settings = $_POST["triggers"];

$dest_project_pid = $settings["dest-project"];
if (!empty($settings["linkSourceEvent"]) && !$data_entry_trigger_builder->isValidEvent($settings["linkSourceEvent"]))
foreach($settings as $index => $trigger_obj)
{
$errors["linkSourceEvent"] = "Invalid event!";
}
$dest_project_pid = $trigger_obj["dest-project"];

if (!$data_entry_trigger_builder->isValidField($settings["linkSource"]))
{
$errors["linkSource"] = "Invalid field!";
}
$err = $data_entry_trigger_builder->validateSyntax($trigger_obj["trigger"]);
if (!empty($err))
{
$errors[$index]["trigger_errors"] = $err;
}

if (!empty($settings["linkDestEvent"]) && !$data_entry_trigger_builder->isValidEvent($settings["linkDestEvent"], $dest_project_pid))
{
$errors["linkDestEvent"] = "Invalid event!";
}
if (!empty($trigger_obj["linkSourceEvent"]) && !$data_entry_trigger_builder->isValidEvent($trigger_obj["linkSourceEvent"]))
{
$errors[$index]["linkSourceEvent"] = "Invalid event!";
}

if (!$data_entry_trigger_builder->isValidField($settings["linkDest"], $dest_project_pid))
{
$errors["linkDest"] = "Invalid field!";
}
if (!$data_entry_trigger_builder->isValidField($trigger_obj["linkSource"]))
{
$errors[$index]["linkSource"] = "Invalid field!";
}

foreach($settings["triggers"] as $index => $trigger)
{
if (!empty($trigger))
if (!empty($trigger_obj["linkDestEvent"]) && !$data_entry_trigger_builder->isValidEvent($trigger_obj["linkDestEvent"], $dest_project_pid))
{
$err = $data_entry_trigger_builder->validateSyntax($trigger);
if (!empty($err))
{
$trigger_errors[$index] = $err;
}
$errors[$index]["linkDestEvent"] = "Invalid event!";
}
}

foreach($settings["pipingSourceEvents"] as $index => $fields)
{
foreach($fields as $i => $field)
if (!$data_entry_trigger_builder->isValidField($trigger_obj["linkDest"], $dest_project_pid))
{
$errors[$index]["linkDest"] = "Invalid field!";
}

foreach($trigger_obj["pipingSourceEvents"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidEvent($field))
{
$errors["pipingSourceEvents"][$index][$i] = "$field is an invalid event!";
$errors[$index]["pipingSourceEvents"][$n] = "$field is an invalid event!";
}
}
}

foreach($settings["pipingSourceFields"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["pipingSourceFields"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidField($field))
{
$errors["pipingSourceFields"][$index][$i] = "$field is an invalid field!";
$errors[$index]["pipingSourceFields"][$n] = "$field is an invalid field!";
}
}
}

foreach($settings["pipingDestEvents"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["pipingDestEvents"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidEvent($field, $dest_project_pid))
{
$errors["pipingDestEvents"][$index][$i] = "$field is an invalid event!";
$errors[$index]["pipingDestEvents"][$n] = "$field is an invalid event!";
}
}
}

foreach($settings["pipingDestFields"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["pipingDestFields"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidField($field, $dest_project_pid))
{
$errors["pipingDestFields"][$index][$i] = "$field is an invalid field!";
$errors[$index]["pipingDestFields"][$n] = "$field is an invalid field!";
}
}
}

foreach($settings["setDestEvents"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["setDestEvents"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidEvent($field, $dest_project_pid))
{
$errors["setDestEvents"][$index][$i] = "$field is an invalid event!";
$errors[$index]["setDestEvents"][$n] = "$field is an invalid event!";
}
}
}

foreach($settings["setDestFields"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["setDestFields"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidField($field, $dest_project_pid))
{
$errors["setDestFields"][$index][$i] = "$field is an invalid field!";
$errors[$index]["setDestFields"][$n] = "$field is an invalid field!";
}
}
}

foreach($settings["sourceInstrEvents"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["sourceInstrEvents"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidEvent($field, $dest_project_pid))
if(!$data_entry_trigger_builder->isValidEvent($field))
{
$errors["sourceInstrEvents"][$index][$i] = "$field is an invalid event!";
$errors[$index]["sourceInstrEvents"][$n] = "$field is an invalid event!";
}
}
}

foreach($settings["sourceInstr"] as $index => $fields)
{
foreach($fields as $i => $field)
foreach($trigger_obj["sourceInstr"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidInstrument($field, $dest_project_pid))
if(!$data_entry_trigger_builder->isValidInstrument($field))
{
$errors["sourceInstr"][$index][$i] = "$field is an invalid instrument!";
$errors[$index]["sourceInstr"][$n] = "$field is an invalid instrument!";
}
}
}

if (!empty($trigger_errors))
{
$errors["trigger_errors"] = $trigger_errors;
foreach($trigger_obj["destInstrEvents"] as $n => $field)
{
if(!$data_entry_trigger_builder->isValidEvent($field, $dest_project_pid))
{
$errors[$index]["destInstrEvents"][$n] = "$field is an invalid event!";
}
}

if (!empty($trigger_obj["surveyUrlEvent"]) && !$data_entry_trigger_builder->isValidEvent($trigger_obj["surveyUrlEvent"], $dest_project_pid))
{
$errors[$index]["surveyUrlEvent"] = "Invalid event!";
}

if (!empty($trigger_obj["surveyUrl"]) && !$data_entry_trigger_builder->isValidInstrument($trigger_obj["surveyUrl"], $dest_project_pid))
{
$errors[$index]["surveyUrl"] = "Invalid instrument!";
}

if (!empty($trigger_obj["saveUrlEvent"]) && !$data_entry_trigger_builder->isValidEvent($trigger_obj["saveUrlEvent"]))
{
$errors[$index]["saveUrlEvent"] = "Invalid event!";
}

if (!empty($trigger_obj["saveUrlField"]) && !$data_entry_trigger_builder->isValidField($trigger_obj["saveUrlField"]))
{
$errors[$index]["saveUrlField"] = "Invalid field!";
}
}

if (!empty($errors))
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"require": {
"phpoffice/phpword": "^0.18.1"
},
"config": {
"platform": {
"php": "7.4.21"
}
}
}
Loading