Skip to content

Commit

Permalink
[survey_accounts] Remove all traces of emails from the database (#7248)
Browse files Browse the repository at this point in the history
Removing all traces of stored emails in the database without affecting emailing functionality.
  • Loading branch information
ridz1208 committed Dec 23, 2020
1 parent 109a515 commit 37c0196
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
2 changes: 2 additions & 0 deletions SQL/Archive/21.0/Cleanup/2020-12-18-Remove_survey_emails.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE participant_accounts DROP COLUMN Email;
DELETE FROM history WHERE tbl='participant_accounts' AND col='Email';
4 changes: 0 additions & 4 deletions modules/survey_accounts/jsx/surveyAccountsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ class SurveyAccountsIndex extends Component {
type: 'select',
options: options.visits,
}},
{label: 'Email', show: true, filter: {
name: 'email',
type: 'text',
}},
{label: 'Instrument', show: true, filter: {
name: 'instrument',
type: 'select',
Expand Down
29 changes: 15 additions & 14 deletions modules/survey_accounts/php/addsurvey.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class AddSurvey extends \NDB_Form
$db = \Database::singleton();

$numCandidates = $db->pselectOne(
"SELECT COUNT(*) FROM candidate
WHERE PSCID=:v_PSCID
"SELECT COUNT(*) FROM candidate
WHERE PSCID=:v_PSCID
AND CandID=:v_CandID AND Active='Y'",
array(
'v_PSCID' => $values['PSCID'],
Expand All @@ -78,9 +78,9 @@ class AddSurvey extends \NDB_Form
}

$numSessions = $db->pselectOne(
"SELECT COUNT(*) FROM session
WHERE CandID=:v_CandID
AND UPPER(Visit_label)=UPPER(:v_VL)
"SELECT COUNT(*) FROM session
WHERE CandID=:v_CandID
AND UPPER(Visit_label)=UPPER(:v_VL)
AND Active='Y'",
array(
'v_CandID' => $values['CandID'],
Expand All @@ -99,8 +99,8 @@ class AddSurvey extends \NDB_Form
$instrument_list = $db->pselect(
"SELECT f.Test_name FROM flag f
JOIN session s on s.ID = f.SessionID
WHERE s.CandID=:v_CandID
AND UPPER(s.Visit_label)=UPPER(:v_VL)
WHERE s.CandID=:v_CandID
AND UPPER(s.Visit_label)=UPPER(:v_VL)
AND s.Active='Y'",
array(
'v_CandID' => $values['CandID'],
Expand Down Expand Up @@ -160,7 +160,9 @@ class AddSurvey extends \NDB_Form
*/
function _process($values)
{
$db = \Database::singleton();
$db = \Database::singleton();
$email = $values['Email'];
unset($values['Email']);
$SessionID = $db->pselectOne(
"SELECT ID FROM session".
" WHERE CandID=:v_CandID AND Visit_label=:v_VL",
Expand Down Expand Up @@ -190,11 +192,11 @@ class AddSurvey extends \NDB_Form

$key = $this->_generateSurveyKey();

$email = false;
$sendEmail = false;
if (isset($_REQUEST['send_email'])) {
$email = true;
$sendEmail = true;
}
if ($email) {
if ($sendEmail) {
$status = 'Sent';
} else {
$status = 'Created';
Expand All @@ -206,7 +208,6 @@ class AddSurvey extends \NDB_Form
array(
'SessionID' => $SessionID,
'Test_name' => $values['Test_name'],
'Email' => $values['Email'],
'Status' => $status,
'OneTimePassword' => $key,
'CommentID' => $commentID,
Expand All @@ -218,7 +219,7 @@ class AddSurvey extends \NDB_Form
}
$this->tpl_data['success'] = true;

if ($email) {
if ($sendEmail) {
$config = \NDB_Config::singleton();
$www = $config->getSetting("www");

Expand All @@ -228,7 +229,7 @@ class AddSurvey extends \NDB_Form
urlencode($key),
'EmailForm' => $values['email_dialog'],
);
\Email::send($values['Email'], 'new_survey.tpl', $msg_data);
\Email::send($email, 'new_survey.tpl', $msg_data);
}
}

Expand Down
3 changes: 1 addition & 2 deletions modules/survey_accounts/php/survey_accounts.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Survey_Accounts extends \NDB_Menu_Filter
function _setupVariables()
{
// the base query
$query = " FROM participant_accounts p
$query = " FROM participant_accounts p
JOIN session s ON (p.SessionID=s.ID)
JOIN candidate c ON (c.CandID=s.CandID)
WHERE c.Active = 'Y'
Expand All @@ -57,7 +57,6 @@ class Survey_Accounts extends \NDB_Menu_Filter
$this->columns = array(
'c.PSCID AS PSCID',
's.Visit_label AS Visit',
'p.Email as Email',
'p.Test_name as SurveyName',
'p.OneTimePassword as URL',
'p.Status',
Expand Down

0 comments on commit 37c0196

Please sign in to comment.