Skip to content

Commit

Permalink
Fixed issue #13084: Import old tokens table - display issue + text me…
Browse files Browse the repository at this point in the history
…ssage

Dev: Renamed token table to survey participants table all over the software to reduce confusion
  • Loading branch information
lacrioque committed Dec 22, 2017
1 parent 44877dd commit 8fd54d5
Show file tree
Hide file tree
Showing 31 changed files with 126 additions and 126 deletions.
2 changes: 1 addition & 1 deletion application/controllers/OptoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function actiontokens()
}

/**
* This function is run when opting out of an individual token table. The other function /optout/participants
* This function is run when opting out of an individual survey participants table. The other function /optout/participants
* opts the user out of ALL survey invitations from the system
*/
function actionremovetokens()
Expand Down
12 changes: 6 additions & 6 deletions application/controllers/admin/checkintegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function fixredundancy()
foreach ($aDelete['redundanttokentables'] as $aTokenTable) {
if (in_array($aTokenTable['table'], $oldsmultidelete)) {
Yii::app()->db->createCommand()->dropTable($aTokenTable['table']);
$aData['messages'][] = sprintf(gT('Deleting token table: %s'), $aTokenTable['table']);
$aData['messages'][] = sprintf(gT('Deleting survey participants table: %s'), $aTokenTable['table']);
}
}
}
Expand All @@ -71,7 +71,7 @@ public function fixredundancy()
}
}
if (count($aData['messages']) == 0) {
$aData['messages'][] = gT('No old survey or token table selected.');
$aData['messages'][] = gT('No old survey or survey participants table selected.');
}
$this->_renderWrappedTemplate('checkintegrity', 'fix_view', $aData);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ private function _deleteOrphanTokenTables(array $tokenTables, array $aData)
{
foreach ($tokenTables as $aTokenTable) {
Yii::app()->db->createCommand()->dropTable($aTokenTable);
$aData['messages'][] = gT('Deleting orphan token table:').' '.$aTokenTable;
$aData['messages'][] = gT('Deleting orphan survey participants table:').' '.$aTokenTable;
}
return $aData;
}
Expand Down Expand Up @@ -432,7 +432,7 @@ protected function _checkintegrity()
}
}

/*** Check for active token tables with missing survey entry ***/
/*** Check for active survey participants tables with missing survey entry ***/
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\_%'));
foreach ($aResult->readAll() as $aRow) {
$sTableName = (string) substr(reset($aRow), strlen($sDBPrefix));
Expand Down Expand Up @@ -823,7 +823,7 @@ protected function _checkintegrity()
}

/**********************************************************************/
/* CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT TOKEN TABLES */
/* CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT Survey participants tableS */
/**********************************************************************/
//1: Get distinct list of survey_link survey ids, check if tokens
// table still exists for each one, and remove if not
Expand All @@ -835,7 +835,7 @@ protected function _checkintegrity()
/* CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT TOKEN ENTRIES */
/**********************************************************************/
//1: For each survey_link, see if the matching entry still exists in
// the token table and remove if it doesn't.
// the survey participants table and remove if it doesn't.


/* Show a alert message is some fix is done */
Expand Down
10 changes: 5 additions & 5 deletions application/controllers/admin/conditionsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class conditionsaction extends Survey_Common_Action
private $language;

/**
* True if there exists a token table for this survey
* True if there exists a survey participants table for this survey
* @var boolean
*/
private $tokenTableExists;
Expand Down Expand Up @@ -509,9 +509,9 @@ public function index($subaction, $iSurveyID = null, $gid = null, $qid = null)
$rightOperandType = 'tokenAttr';
$aTokenAttrNames = $this->tokenFieldsAndNames;
if ($this->tokenTableExists) {
$thisAttrName = HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description'])." [".gT("From token table")."]";
$thisAttrName = HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description'])." [".gT("From survey participants table")."]";
} else {
$thisAttrName = HTMLEscape($extractedTokenAttr[1])." [".gT("Inexistant token table")."]";
$thisAttrName = HTMLEscape($extractedTokenAttr[1])." [".gT("Inexistant survey participants table")."]";
}
$data['target'] = $thisAttrName;
} elseif (isset($canswers)) {
Expand Down Expand Up @@ -2041,9 +2041,9 @@ protected function getAttributeName($extractedTokenAttr)
}

if ($this->tokenTableExists) {
$thisAttrName .= " [".gT("From token table")."]";
$thisAttrName .= " [".gT("From survey participants table")."]";
} else {
$thisAttrName .= " [".gT("Inexistant token table")."]";
$thisAttrName .= " [".gT("Inexistant survey participants table")."]";
}

return $thisAttrName;
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/dataentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ public function insert()
}

if ($tccount < 1) {
// token doesn't exist in token table
// token doesn't exist in survey participants table
$lastanswfortoken = 'UnknownToken';
} elseif ($survey->isAnonymized) {
// token exist but survey is anonymous, check completed state
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public function vvexport()
$firstline .= $s;
if ($vvVersion == 2) {
$fieldcode = viewHelper::getFieldCode($fielddata, array("LEMcompat"=>true));
$fieldcode = ($fieldcode) ? $fieldcode : $field; // $fieldcode is empty for token if there are no token table
$fieldcode = ($fieldcode) ? $fieldcode : $field; // $fieldcode is empty for token if there are no survey participants table
} else {
$fieldcode = $field;
}
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/participantsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public function deleteParticipant()
if ($selectoption == 'po') {
$deletedParticipants = Participant::model()->deleteParticipants($participantIds);
}
// Deletes from central and token table
// Deletes from central and survey participants table
else if ($selectoption == 'ptt') {
$deletedParticipants = Participant::model()->deleteParticipantToken($participantIds);
}
Expand Down Expand Up @@ -2245,7 +2245,7 @@ public function addToTokenattmap()

// TODO: This code can't be reached
echo "<p>";
printf(gT("%s participants have been copied to the survey token table"), "<span class='badge alert-success'>".$response['success']."</span>");
printf(gT("%s participants have been copied to the survey survey participants table"), "<span class='badge alert-success'>".$response['success']."</span>");
echo "</p>";
if ($response['duplicate'] > 0) {
echo "<p>";
Expand Down
28 changes: 14 additions & 14 deletions application/controllers/admin/tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function index($surveyid)
$aData['token_bar']['buttons']['view'] = true;


// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
// CHECK TO SEE IF A Survey participants table EXISTS FOR THIS SURVEY
if (!$survey->hasTokensTable) {
//If no tokens table exists
$this->_newtokentable($iSurveyId);
Expand All @@ -78,7 +78,7 @@ public function bounceprocessing($iSurveyId)
$iSurveyId = (int) $iSurveyId;
$survey = Survey::model()->findByPk($iSurveyId);
if (!$survey->hasTokensTable) {
eT("No token table.");
eT("No survey participants table.");
return;
}
$thissurvey = getSurveyInfo($iSurveyId);
Expand Down Expand Up @@ -380,7 +380,7 @@ public function editMultiple()
$aResults = array();

if (Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update')) {
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
// CHECK TO SEE IF A Survey participants table EXISTS FOR THIS SURVEY
if (tableExists('{{tokens_'.$iSurveyId.'}}')) {

// First we create the array of fields to update
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public function managetokenattributes($iSurveyId)
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
// CHECK TO SEE IF A Survey participants table EXISTS FOR THIS SURVEY
$bTokenExists = $survey->hasTokensTable;
if (!$bTokenExists) {
//If no tokens table exists
Expand Down Expand Up @@ -1078,7 +1078,7 @@ public function updatetokenattributes($iSurveyId)
}

Yii::app()->db->schema->getTable($survey->tokensTableName, true); // Refresh schema cache just in case the table existed in the past
LimeExpressionManager::SetDirtyFlag(); // so that knows that token tables have changed
LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed

Yii::app()->session['flashmessage'] = sprintf(gT("%s field(s) were successfully added."), $number2add);
Yii::app()->getController()->redirect(array("/admin/tokens/sa/managetokenattributes/surveyid/$iSurveyId"));
Expand All @@ -1094,9 +1094,9 @@ public function deletetokenattributes($iSurveyId)
{
$iSurveyId = (int) $iSurveyId;
$survey = Survey::model()->findByPk($iSurveyId);
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
// CHECK TO SEE IF A Survey participants table EXISTS FOR THIS SURVEY
if (!$survey->hasTokensTable) {
Yii::app()->session['flashmessage'] = gT("No token table.");
Yii::app()->session['flashmessage'] = gT("No survey participants table.");
$this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update')) {
Expand Down Expand Up @@ -1555,7 +1555,7 @@ public function exportdialog($iSurveyId)
$aData['token_bar']['exportbutton']['form'] = true;
$aData['token_bar']['closebutton']['url'] = 'admin/tokens/sa/index/surveyid/'.$iSurveyId; // Close button

// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
// CHECK TO SEE IF A Survey participants table EXISTS FOR THIS SURVEY
$iSurveyId = (int) $iSurveyId;
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'export')) {
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
Expand Down Expand Up @@ -1632,7 +1632,7 @@ public function exportdialog($iSurveyId)
'tokendeleteexported'=>array(
'type'=>'checkbox',
'label'=>gT('Delete exported tokens:'),
'help'=>'Attention: If selected the exported tokens are deleted permanently from the token table.',
'help'=>'Attention: If selected the exported tokens are deleted permanently from the survey participants table.',
),
);
$this->_renderWrappedTemplate('token', array('exportdialog'), $aData);
Expand Down Expand Up @@ -2300,7 +2300,7 @@ public function kill($iSurveyId)
. gT("Main Admin Screen")."' onclick=\"window.open('".Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/".$iSurveyId)."', '_top')\" />"
)), $aData);

LimeExpressionManager::SetDirtyFlag(); // so that knows that token tables have changed
LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed
}
}

Expand Down Expand Up @@ -2445,7 +2445,7 @@ private function _newtokentable($iSurveyId)
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}

//The token table already exist ?
//The survey participants table already exist ?
if ($survey->hasTokensTable) {
Yii::app()->session['flashmessage'] = gT("Tokens already exist for this survey.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
Expand All @@ -2460,7 +2460,7 @@ private function _newtokentable($iSurveyId)
if (Yii::app()->request->getPost('createtable') == "Y") {
Token::createTable($iSurveyId);
$aData['sidemenu']['state'] = false;
LimeExpressionManager::SetDirtyFlag(); // LimeExpressionManager needs to know about the new token table
LimeExpressionManager::SetDirtyFlag(); // LimeExpressionManager needs to know about the new survey participants table
$this->_renderWrappedTemplate('token', array('message' =>array(
'title' => gT("Survey participants"),
'message' => gT("A participant table has been created for this survey.")." (\"".Yii::app()->db->tablePrefix."tokens_$iSurveyId\")<br /><br />\n"
Expand Down Expand Up @@ -2506,12 +2506,12 @@ private function _newtokentable($iSurveyId)
$aData['sidemenu']['state'] = false;
$this->_renderWrappedTemplate('token', array('message' => array(
'title' => gT("Import old tokens"),
'message' => gT("A token table has been created for this survey and the old tokens were imported.")." (\"".Yii::app()->db->tablePrefix."tokens_$iSurveyId"."\")<br /><br />\n"
'message' => gT("A survey participants table has been created for this survey and the old tokens were imported.")." (\"".Yii::app()->db->tablePrefix."tokens_$iSurveyId"."\")<br /><br />\n"
. "<input type='submit' class='btn btn-default' value='"
. gT("Continue")."' onclick=\"window.open('".$this->getController()->createUrl("admin/tokens/sa/index/surveyid/$iSurveyId")."', '_top')\" />\n"
)),['surveyid' => $iSurveyId]);

LimeExpressionManager::SetDirtyFlag(); // so that knows that token tables have changed
LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed
} else {
Yii::app()->loadHelper('database');
$result = Yii::app()->db->createCommand(dbSelectTablesLike("{{old_tokens_".intval($iSurveyId)."_%}}"))->queryAll();
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/export/SurveyObj.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SurveyObj


/**
* When relevant holds the available fields from the token table
* When relevant holds the available fields from the survey participants table
*
* @var array[fieldname][localised description]
*/
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/export/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ final public function write(SurveyObj $oSurvey, $sLanguageCode, FormattingOption
break;
}
} else {
//Token table value
//Survey participants table value
$elementArray[] = $value;
}
}
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/admin/import_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function importSurveyFile($sFullFilePath, $bTranslateLinksFields, $sNewSurveyNam
$aImportResults = array_merge($aTokenCreateResults, $aImportResults);
$aTokenImportResults = XMLImportTokens(Yii::app()->getConfig('tempdir').DIRECTORY_SEPARATOR.$aFile['filename'], $aImportResults['newsid']);
} else {
$aTokenImportResults['warnings'][] = gT("Unable to create token table");
$aTokenImportResults['warnings'][] = gT("Unable to create survey participants table");

}

Expand Down Expand Up @@ -1574,7 +1574,7 @@ function XMLImportTokens($sFullFilePath, $iSurveyID, $sCreateMissingAttributeFie
foreach ($xml->tokens->fields->fieldname as $sFieldName) {
$aXLMFieldNames[] = (string) $sFieldName;
}
// Get a list of all fieldnames in the token table
// Get a list of all fieldnames in the survey participants table
$aTokenFieldNames = Yii::app()->db->getSchema()->getTable($survey->tokensTableName, true);
$aTokenFieldNames = array_keys($aTokenFieldNames->columns);
$aFieldsToCreate = array_diff($aXLMFieldNames, $aTokenFieldNames);
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,7 @@ function tableExists($sTableName)
}

// Returns false if the survey is anonymous,
// and a token table exists: in this case the completed field of a token
// and a survey participants table exists: in this case the completed field of a token
// will contain 'Y' instead of the submitted date to ensure privacy
// Returns true otherwise
function isTokenCompletedDatestamped($thesurvey)
Expand Down Expand Up @@ -2971,7 +2971,7 @@ function filterForAttributes($fieldname)
}

/**
* Retrieves the attribute field names from the related token table
* Retrieves the attribute field names from the related survey participants table
*
* @param mixed $iSurveyID The survey ID
* @return array The fieldnames
Expand Down Expand Up @@ -3008,7 +3008,7 @@ function getParticipantAttributes($iSurveyID)


/**
* Retrieves the attribute names from the related token table
* Retrieves the attribute names from the related survey participants table
*
* @param mixed $surveyid The survey ID
* @param boolean $bOnlyAttributes Set this to true if you only want the fieldnames of the additional attribue fields - defaults to false
Expand Down
Loading

0 comments on commit 8fd54d5

Please sign in to comment.