-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathhooks.php
More file actions
184 lines (146 loc) · 8.11 KB
/
hooks.php
File metadata and controls
184 lines (146 loc) · 8.11 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
// **********************************************************************************************
// This file is the HOOKS FUNCTIONS file that holds the functions for all hooks used by REDCap.
// NOTE: Most hooks point to a PHP file (named after the hook function) that sits inside a
// project-level sub-directory in the /redcap/hooks folder, so if you wish to utilize a hook
// for a specific project, create a sub-directory in the /redcap/hooks folder named
// "pid{$project_id}" with a PHP file named after the hook function inside it, and then that PHP
// file will be called when REDCap calls the hook for that project.
// **********************************************************************************************
require_once dirname(__FILE__) . '/classes/ExternalModules.php';
use ExternalModules\ExternalModules;
// REDCAP_EVERY_PAGE_BEFORE_RENDER
function redcap_every_page_before_render($project_id=null)
{
if ($project_id !== null) {
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
}
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_EVERY_PAGE_TOP
function redcap_every_page_top($project_id=null)
{
if ($project_id !== null) {
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
}
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_DATA_ENTRY_FORM
function redcap_data_entry_form($project_id, $record, $instrument, $event_id, $group_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_DATA_ENTRY_FORM TOP
function redcap_data_entry_form_top($project_id, $record, $instrument, $event_id, $group_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_SAVE_RECORD
function redcap_save_record($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_SURVEY_COMPLETE
function redcap_survey_complete($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_SURVEY_PAGE
function redcap_survey_page($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_SURVEY_PAGE TOP
function redcap_survey_page_top($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// ADD/EDIT RECORDS PAGE
function redcap_add_edit_records_page($project_id, $instrument, $event_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_USER_RIGHTS
function redcap_user_rights($project_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_PROJECT_HOME_PAGE
function redcap_project_home_page($project_id)
{
// Set the full path of the project handler PHP script located inside the
// project-specific sub-folder, which itself exists in the main Hooks folder.
$project_handler_script = APP_PATH_DOCROOT . "/../hooks/pid{$project_id}/".__FUNCTION__.".php";
// Check if the project handler PHP script exists for this project, and if so,
// then "include" the script to execute it. If not, do nothing.
if (file_exists($project_handler_script)) include $project_handler_script;
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_CUSTOM_VERIFY_USERNAME
function redcap_custom_verify_username($user)
{
ExternalModules::callHook(__FUNCTION__, func_get_args());
}
// REDCAP_CONTROL_CENTER
function redcap_control_center()
{
ExternalModules::callHook(__FUNCTION__, func_get_args());
}