Skip to content
Permalink
Browse files

Dev: change db field type to "text" only when question is set to be e…

…ncrypted
  • Loading branch information...
dominikvitt committed May 22, 2019
1 parent abfdd04 commit 3f37ed81d63d7083015e42861efcd1b722c6f412
Showing with 9 additions and 9 deletions.
  1. +9 −9 application/models/SurveyActivator.php
@@ -119,7 +119,7 @@ protected function prepareTableDefinition()
break;
case Question::QT_N_NUMERICAL:
case Question::QT_K_MULTIPLE_NUMERICAL_QUESTION:
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "decimal (30,10)";
break;
case Question::QT_S_SHORT_FREE_TEXT:
$aTableDefinition[$aRow['fieldname']] = "text";
@@ -130,7 +130,7 @@ protected function prepareTableDefinition()
case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS:
case Question::QT_O_LIST_WITH_COMMENT:
if ($aRow['aid'] != 'other' && strpos($aRow['aid'], 'comment') === false && strpos($aRow['aid'], 'othercomment') === false) {
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "string(5)";
} else {
$aTableDefinition[$aRow['fieldname']] = "text";
}
@@ -143,21 +143,21 @@ protected function prepareTableDefinition()
$aTableDefinition[$aRow['fieldname']] = "text";
break;
case Question::QT_D_DATE:
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "datetime";
break;
case Question::QT_5_POINT_CHOICE:
case Question::QT_G_GENDER_DROPDOWN:
case Question::QT_Y_YES_NO_RADIO:
case Question::QT_X_BOILERPLATE_QUESTION:
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "string(1)";
break;
case Question::QT_I_LANGUAGE:
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "string(20)";
break;
case Question::QT_VERTICAL_FILE_UPLOAD:
$this->createSurveyDir = true;
if (strpos($aRow['fieldname'], "_")) {
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "integer";
} else {
$aTableDefinition[$aRow['fieldname']] = "text";
}
@@ -173,7 +173,7 @@ protected function prepareTableDefinition()
}
break;
case "token":
$aTableDefinition[$aRow['fieldname']] = 'text'.$this->collation;
$aTableDefinition[$aRow['fieldname']] = 'string(35)'.$this->collation;

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jun 12, 2019

Collaborator

This one can/must be encrypted if needed , no ?

About encrypt : i think collation is needed, else you have more collision … no ?

This comment has been minimized.

Copy link
@dominikvitt

dominikvitt Jun 12, 2019

Author Contributor

Token probably don't need to be encrypted, only responses and respondent personal information are important.

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jun 12, 2019

Collaborator

Right :) totally right, it's more a "internal" use 👍

break;
case Question::QT_ASTERISK_EQUATION:
$aTableDefinition[$aRow['fieldname']] = "text";
@@ -202,10 +202,10 @@ protected function prepareTableDefinition()
$oQuestionAttribute->value = $nrOfAnswers;
$oQuestionAttribute->save();
}
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "string(5)";
break;
default:
$aTableDefinition[$aRow['fieldname']] = "text";
$aTableDefinition[$aRow['fieldname']] = (array_key_exists('encrypted', $aRow) && $aRow['encrypted'] == 'Y') ? "text" : "string(5)";
}
if (!$this->survey->isAnonymized && !array_key_exists('token', $aTableDefinition)) {
$aTableDefinition['token'] = 'string(35)'.$this->collation;

0 comments on commit 3f37ed8

Please sign in to comment.
You can’t perform that action at this time.