-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresetModuleData.php
41 lines (32 loc) · 1016 Bytes
/
resetModuleData.php
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
<?php
/** @var \Vanderbilt\BigDataImportExternalModule $module
*
*/
$settings = $module->getProjectSettings();
# Ignore settings that are not relevant
unset($settings["enabled"]);
unset($settings["version"]);
unset($settings["import-email"]);
unset($settings["import-from"]);
$num = count($settings);
if($num == 0) {
echo json_encode(array(
'status' => 'warning',
'message' => 'There is no module data yet to be reset.'
));
exit();
}
# Remove project setting with specified key from current project
foreach ($settings as $key => $value) {
$module->removeProjectSetting($key);
}
# Send response and log
$icon = '<span class="fa-stack fa-2x"><i class="fas fa-circle fa-stack-2x"></i><i class="fas fa-redo fa-stack-1x fa-inverse"></i></span>';
$logtext = "The module has been reset. {$icon}</div>";
$module->log($logtext);
$message = 'Reset was successful. '.$num.' rows have been reset.';
echo json_encode(array(
'status' => 'success',
'message' => $message
));
?>