Skip to content

Commit 3b3936f

Browse files
committed
Merge branch 'release/2.0.4'
2 parents c49e0d4 + 617e0d2 commit 3b3936f

File tree

6 files changed

+83
-21
lines changed

6 files changed

+83
-21
lines changed

AUTHORS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# AUTHORS
2+
3+
Warn User of Pending Suspension would not be possible without generous contributions from our authors and funders.
4+
5+
David R Nelson, Director of the University of Florida Clinical Translational Science Institute, provides funding support for the UF CTSI REDCap team via UF CTSA Award and matching funds from the UF Office of Research.
6+
7+
We want to thank our developers Kyle Chesney kyle.chesney@ufl.edu, Taryn Stoffs tls@ufl.edu, Philip Chase pbc@ufl.edu, Marly Cormar marlycormar@ufl.edu, Tiago Bember tbembersimeao@ufl.edu, and Christopher Barnes cpb@ufl.edu for their contributions to the project.

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
All notable changes to the REDCap Warn Users of Pending Suspension project will be documented in this file.
33

44

5-
## [2.0.2] - 2019-10-01
5+
## [2.0.4] - 2020-02-03
6+
### Changed
7+
- Revise the developer testing instructions (Philip Chase)
8+
- Stop calling ExternalModules class directly to address an issue reported in REDCap 9.6.3 (Kyle Chesney)
9+
10+
### Added
11+
- Add AUTHORS.md (Philip Chase)
12+
13+
14+
## [2.0.3] - 2019-10-01
615
### Changed
716
- Ensure project_contact_email is from global scope (Kyle Chesney)
817
- Correct wording. (Marly Cormar)

ExternalModule.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace SuspensionWarning\ExternalModule;
88

99
use ExternalModules\AbstractExternalModule;
10-
use ExternalModules\ExternalModules;
1110
use REDCap;
1211
use Logging;
1312

@@ -94,7 +93,7 @@ function warn_users_account_suspension_cron()
9493
) as my_user_info
9594
where '$suspend_users_inactive_days' - DATEDIFF(NOW(), user_last_date) = '$day';";
9695

97-
$q = ExternalModules::query($sql);
96+
$q = $this->query($sql);
9897

9998
while ($row = db_fetch_assoc($q))
10099
{

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,25 @@ To test WUPS, you need to turn on a few REDCap features it interacts with. You
9090
update redcap_config set value="1" where field_name = "suspend_users_inactive_send_email";
9191
update redcap_config set value="30" where field_name = "suspend_users_inactive_days";
9292

93-
As this tool sends emails, make sure the field that will be used for the **Sender Email** address is configured correctly in your module configuration.
93+
This module has to be configured before you can do anything with it. The instructions that follow assume the module has been configured as described in _Email Configuration Example_ above. The _Days Before Suspension_ setting of `10, 12, 20` is especially important. As this tool sends emails, also make sure the field that will be used for the **Sender Email** address is configured correctly in your module configuration.
9494

95-
You'll also need some test users. To revise the set of test users `alice`, `bob`, `dan`, and `carol` to receive messages based on the above configuration, change their `user_lastlogin` and `user_lastactivity` dates as follows:
95+
You'll need some test users. Assuming you have a set of test users `alice`, `bob`, `carol`, and `dan` you can configure them to receive alerts _today_ by adjusting their `user_lastlogin` and `user_lastactivity` dates as follows:
9696

9797
update redcap_user_information set user_lastlogin = date_add(now(), interval -22 day), user_lastactivity = date_add(now(), interval -10 day) where username='alice';
9898
update redcap_user_information set user_lastlogin = date_add(now(), interval -18 day), user_lastactivity = NULL where username='bob';
9999
update redcap_user_information set user_lastlogin = date_add(now(), interval -10 day), user_lastactivity = date_add(now(), interval -25 day) where username='carol';
100100
update redcap_user_information set user_lastlogin = null, user_lastactivity = date_add(now(), interval -20 day) where username='dan';
101101

102-
update redcap_user_information set user_email = 'you@example.org' where username in ("alice", "bob", "carol", "dan");
102+
If you are testing REDCap under [redcap-docker-compose](https://github.com/123andy/redcap-docker-compose), the automatic table-based user creation tools can make these users for you. If you are testing under a [redcap_deployment](https://github.com/ctsit/redcap_deployment) Vagrant VM, the above set of test users can be created via the SQL file at [https://github.com/ctsit/redcap_deployment/blob/master/deploy/files/test\_with\_table\_based\_authentication.sql](https://github.com/ctsit/redcap_deployment/blob/master/deploy/files/test_with_table_based_authentication.sql). People testing in other environments will need to design their own set of test cases.
103+
104+
To get the alerts from these test users, you'll want to update their email addresses with _your_ email address. e.g.,
103105

104-
When tested, each of the aforementioned users should get a message. FYI, the above set of test users can be created via the SQL file at [https://github.com/ctsit/redcap_deployment/blob/master/deploy/files/test\_with\_table\_based\_authentication.sql](https://github.com/ctsit/redcap_deployment/blob/master/deploy/files/test_with_table_based_authentication.sql). That SQL file works great for users of the redcap_deployment project. Other users might want to be cautious as the SQL makes some assumptions.
106+
update redcap_user_information set user_email = 'you@example.org' where username in ("alice", "bob", "carol", "dan");
105107

106-
The final step to facilitate testing is to turn the frequency of the cron job up. You'll need to change `cron_frequency` and `cron_max_run_time` so that the cron job runs more often. Here's the lazy developer's SQL method to do that:
108+
The final step to facilitate testing is to adjust the frequency of the cron job. The external module framework monitors the cron configuration settings in a module's `config.json`. If you change the cron frequency in that file to 60 seconds, the EM framework will, shortly thereafter, do the same to the module's cron job:
107109

108-
update redcap_crons set cron_frequency = 60, cron_max_run_time = 10 where cron_name = "warn_users_account_suspension_cron";
110+
"cron_frequency": "60",
109111

110-
Revert the setting to the defaults with this SQL when you are done with testing:
112+
Turn that value back down to `86400` (that's the number of seconds in one day) when you are done to get back to the normal configuration.
111113

112-
update redcap_crons set cron_frequency = 86400, cron_max_run_time = 1200 where cron_name = "warn_users_account_suspension_cron";
114+
All of these SQL commands and more are rolled up in [developer_testing_commands.sql](developer_testing_commands.sql). Open this file in your favorite SQL tool and run the commands one section at a time to see the relevant database state.

config.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
],
88
"enable-every-page-hooks-on-system-pages": true,
99
"authors": [
10-
{
11-
"name": "Marly Cormar",
12-
"email": "marlycormar@ufl.edu",
13-
"institution": "University of Florida - CTSI"
14-
},
1510
{
1611
"name": "Philip Chase",
1712
"email": "pbc@ufl.edu",
@@ -22,11 +17,6 @@
2217
"email": "tls@ufl.edu",
2318
"institution": "University of Florida - CTSI"
2419
},
25-
{
26-
"name": "Tiago Bember",
27-
"email": "tbembersimeao@ufl.edu",
28-
"institution": "University of Florida - CTSI"
29-
},
3020
{
3121
"name": "Kyle Chesney",
3222
"email": "kyle.chesney@ufl.edu",

developer_testing_commands.sql

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- Execute these SQL commands to (re)configure and test WUPS
2+
3+
-- configure
4+
update redcap_config set value="all" where field_name = "suspend_users_inactive_type";
5+
update redcap_config set value="1" where field_name = "suspend_users_inactive_send_email";
6+
update redcap_config set value="30" where field_name = "suspend_users_inactive_days";
7+
8+
update redcap_user_information set user_lastlogin = date_add(now(), interval -22 day), user_lastactivity = date_add(now(), interval -10 day) where username='alice';
9+
update redcap_user_information set user_lastlogin = date_add(now(), interval -18 day), user_lastactivity = NULL where username='bob';
10+
update redcap_user_information set user_lastlogin = date_add(now(), interval -10 day), user_lastactivity = date_add(now(), interval -25 day) where username='carol';
11+
update redcap_user_information set user_lastlogin = null, user_lastactivity = date_add(now(), interval -20 day) where username='dan';
12+
13+
update redcap_user_information set user_email = 'pbc@ufl.edu' where username in ("admin","alice", "bob", "carol", "dan");
14+
15+
update redcap_crons set cron_frequency = 60, cron_max_run_time = 10 where cron_name = "warn_users_account_suspension_cron";
16+
17+
-- Adjust the cron frequency now!
18+
update redcap_crons set cron_frequency = 60 where cron_id > 34;
19+
20+
-- reset everyone's last login and last activity dates
21+
update redcap_user_information set user_lastlogin = date_add(now(), interval -22 day), user_lastactivity = date_add(now(), interval -10 day) where username='alice';
22+
update redcap_user_information set user_lastlogin = date_add(now(), interval -18 day), user_lastactivity = NULL where username='bob';
23+
update redcap_user_information set user_lastlogin = date_add(now(), interval -10 day), user_lastactivity = date_add(now(), interval -25 day) where username='carol';
24+
update redcap_user_information set user_lastlogin = null, user_lastactivity = date_add(now(), interval -20 day) where username='dan';
25+
26+
-- Verify the above query worked
27+
select * from (
28+
select username, user_email, user_sponsor, user_firstname, user_lastname, user_lastactivity, user_lastlogin,
29+
(case
30+
when user_lastactivity is not null and user_lastlogin is not null then greatest(user_lastlogin, user_lastactivity)
31+
when user_lastactivity is not null then user_lastactivity
32+
when user_lastlogin is not null then user_lastlogin
33+
when user_creation is not null then user_creation
34+
end) as user_last_date
35+
from redcap_user_information
36+
where user_suspended_time is null
37+
) as my_user_info
38+
where 30 - DATEDIFF(NOW(), user_last_date) in (10,12,20);
39+
40+
-- verify the module has a cron job
41+
SELECT * FROM `redcap_crons`
42+
WHERE cron_id > 34
43+
order by cron_id desc;
44+
45+
-- verify the module's config
46+
select * from redcap_external_module_settings
47+
where external_module_id in (
48+
SELECT external_module_id FROM `redcap_external_modules`
49+
where directory_prefix = 'warn_users_of_pending_suspension');
50+
51+
-- verify the cron history
52+
SELECT * FROM `redcap_crons_history` as ch
53+
inner join redcap_crons as c on (ch.cron_id = c.cron_id)
54+
WHERE c.cron_name = 'warn_users_account_suspension_cron'
55+
order by ch_id desc;

0 commit comments

Comments
 (0)