-
Notifications
You must be signed in to change notification settings - Fork 4
/
configEmail.php
54 lines (50 loc) · 1.74 KB
/
configEmail.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
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
use \Vanderbilt\CareerDevLibrary\Application;
use \Vanderbilt\CareerDevLibrary\CelebrationsEmail;
use \Vanderbilt\CareerDevLibrary\Sanitizer;
require_once(__DIR__."/small_base.php");
require_once(__DIR__."/classes/Autoload.php");
$handler = new CelebrationsEmail($token, $server, $pid, []);
$action = Sanitizer::sanitize($_POST['action']);
if ($action == "delete") {
$settingName = Sanitizer::sanitizeWithoutChangingQuotes($_POST['name']);
$handler->deleteConfiguration($settingName);
echo "Done.";
} else if ($action == "add") {
$settingName = Sanitizer::sanitizeWithoutChangingQuotes($_POST['name']);
$content = Sanitizer::sanitize($_POST['content']);
$scope = "";
$what = "";
if ($content == "new_grants") {
$scope = "New";
$what = "Grants";
} else if ($content == "all_pubs") {
$scope = "All";
$what = "Publications";
} else if ($content == "first_last_author_pubs") {
$scope = "First/Last Author";
$what = "Publications";
} else if ($content == "high_impact_pubs") {
$scope = "High-Impact";
$what = "Publications";
}
if ($scope && $what) {
$setting = [
"who" => Sanitizer::sanitize($_POST['who']),
"when" => Sanitizer::sanitize($_POST['when']),
"what" => $what,
"scope" => $scope,
"grants" => Sanitizer::sanitize($_POST['grants']),
];
$handler->addOrModifyConfiguration($settingName, $setting);
echo "Done.";
} else {
echo "ERROR: Wrong request.";
}
} else if ($action == "changeEmail") {
$email = Sanitizer::sanitize($_POST['email']);
$handler->saveEmail($email);
echo "Done.";
} else {
echo "ERROR: Improper action.";
}