Skip to content

Commit

Permalink
Merge branch 'master' into 192_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TMSWhite committed Apr 13, 2012
2 parents 8064a3e + c604fa6 commit 6464521
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions admin/tokens.php
Expand Up @@ -505,6 +505,8 @@
$query = db_rename_table(returnglobal('oldtable') , db_table_name_nq("tokens_$surveyid"));
$result=$connect->Execute($query) or safe_die("Failed Rename!<br />".$query."<br />".$connect->ErrorMsg());

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

$tokenoutput .= "\t</div><div class='messagebox ui-corner-all'>\n"
."<div class='header ui-widget-header'>".$clang->gT("Import old tokens")."</div>"
."<br />".$clang->gT("A token table has been created for this survey and the old tokens were imported.")." (\"".$dbprefix."tokens_$surveyid\")<br /><br />\n"
Expand Down Expand Up @@ -1371,6 +1373,7 @@
} else {
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't deactivate because:<br />\n".htmlspecialchars($connect->ErrorMsg())." - Query: ".htmlspecialchars($deactivatequery)." <br /><br />\n<a href='$scriptname?sid=$surveyid'>Admin</a>\n");
}
LimeExpressionManager::SetDirtyFlag(); // so that knows that token tables have changed

$tokenoutput .= '<br />'.$clang->gT("The tokens table has now been removed and tokens are no longer required to access this survey.")."<br /> ".$clang->gT("A backup of this table has been made and can be accessed by your system administrator.")."<br />\n"
."(\"{$dbprefix}old_tokens_{$surveyid}_$date\")"."<br /><br />\n"
Expand Down Expand Up @@ -2268,6 +2271,8 @@
."\t\t<br /><input type='button' value='".$clang->gT("Back to attribute field management.")."' onclick=\"window.open('$scriptname?action=tokens&amp;sid=$surveyid&amp;subaction=managetokenattributes', '_top')\" />\n";
}
$tokenoutput .= "\t</div>";

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


Expand Down
19 changes: 10 additions & 9 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -2374,22 +2374,23 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
}
else
{
// Explicitly set all tokens to blank
// Read list of available tokens from the tokens table so that preview and error checking works correctly
$attrs = GetAttributeFieldNames($surveyid,false);

$blankVal = array(
'code'=>'',
'type'=>'',
'jsName_on'=>'',
'jsName'=>'',
'readWrite'=>'N',
);
$this->knownVars['TOKEN:FIRSTNAME'] = $blankVal;
$this->knownVars['TOKEN:LASTNAME'] = $blankVal;
$this->knownVars['TOKEN:EMAIL'] = $blankVal;
$this->knownVars['TOKEN:USESLEFT'] = $blankVal;
$this->knownVars['TOKEN:TOKEN'] = $blankVal;
for ($i=1;$i<=100;++$i) // TODO - is there a way to know how many attributes are set? Looks like max is 100
{
$this->knownVars['TOKEN:ATTRIBUTE_' . $i] = $blankVal;

foreach ($attrs as $key)
{
if (preg_match('/^(firstname|lastname|email|usesleft|token|attribute_\d+)$/',$key))
{
$this->knownVars['TOKEN:' . strtoupper($key)] = $blankVal;
}
}
}
// set default value for reserved 'this' variable
Expand Down
8 changes: 6 additions & 2 deletions common_functions.php
Expand Up @@ -6514,15 +6514,19 @@ function filterforattributes ($fieldname)
* @param mixed $surveyid The survey ID
* @return array The fieldnames
*/
function GetAttributeFieldNames($surveyid)
function GetAttributeFieldNames($surveyid,$filter=true)
{
global $dbprefix, $connect;
if (tableExists('tokens_'.$surveyid) === false)
{
return Array();
}
$tokenfieldnames = array_values($connect->MetaColumnNames("{$dbprefix}tokens_$surveyid", true));
return array_filter($tokenfieldnames,'filterforattributes');
if ($filter)
{
return array_filter($tokenfieldnames,'filterforattributes');
}
return $tokenfieldnames;
}

/**
Expand Down

0 comments on commit 6464521

Please sign in to comment.