Skip to content

Commit

Permalink
Added feature #2923: Individual validity time for a token
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@6786 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed May 6, 2009
1 parent b0c44a9 commit 30e1507
Show file tree
Hide file tree
Showing 10 changed files with 777 additions and 423 deletions.
6 changes: 3 additions & 3 deletions admin/fck_LimeReplacementFields.php
Expand Up @@ -117,7 +117,7 @@
$replFields[]=array('TOKEN:FIRSTNAME',$clang->gT("Firstname from token"));
$replFields[]=array('TOKEN:LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('TOKEN:EMAIL',$clang->gT("Email from the token"));
$attributes=GetTokenFieldsAndNames($surveyid);
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array('TOKEN:'.strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
Expand All @@ -139,7 +139,7 @@
$replFields[]=array('LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('SURVEYNAME',$clang->gT("Name of the survey"));
$replFields[]=array('SURVEYDESCRIPTION',$clang->gT("Description of the survey"));
$attributes=GetTokenFieldsAndNames($surveyid);
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
Expand All @@ -158,7 +158,7 @@
$replFields[]=array('TOKEN:FIRSTNAME',$clang->gT("Firstname from token"));
$replFields[]=array('TOKEN:LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('TOKEN:EMAIL',$clang->gT("Email from the token"));
$attributes=GetTokenFieldsAndNames($surveyid);
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array('TOKEN:'.strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
Expand Down
24 changes: 22 additions & 2 deletions admin/install/upgrade-mysql.php
Expand Up @@ -276,10 +276,10 @@ function db_upgrade($oldversion) {
{
// Add new tokens setting
modify_database("","ALTER TABLE `prefix_surveys` ADD `usetokens` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_surveys` ADD `attributedescriptions` TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `attributedescriptions` TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute1`"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute2`"); echo $modifyoutput; flush();

upgrade_token_tables134();
modify_database("","update `prefix_settings_global` set `stg_value`='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
Expand Down Expand Up @@ -369,6 +369,8 @@ function upgrade_token_tables128()
}




function upgrade_survey_tables133()
{
$surveyidquery = "SELECT sid,additional_languages FROM ".db_table_name('surveys');
Expand All @@ -379,6 +381,24 @@ function upgrade_survey_tables133()
}
}


// Add the reminders tracking fields
function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `validfrom` Datetime"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `validuntil` Datetime"); echo $modifyoutput; flush();
}
}
}

function fix_mysql_collation()
{
global $connect, $modifyoutput, $dbprefix;
Expand Down
18 changes: 15 additions & 3 deletions admin/install/upgrade-odbc_mssql.php
Expand Up @@ -286,6 +286,7 @@ function db_upgrade($oldversion) {
modify_database("", "ALTER TABLE [prefix_surveys] ADD [attributedescriptions] TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute1]"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute2]"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update [prefix_settings_global] set [stg_value]='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
Expand Down Expand Up @@ -348,7 +349,7 @@ function upgrade_token_tables125()
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD COLUMN [emailstatus] VARCHAR(300) DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [emailstatus] VARCHAR(300) DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}

Expand All @@ -359,8 +360,8 @@ function upgrade_token_tables128()
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD COLUMN [remindersent] VARCHAR(17) DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD COLUMN [remindercount] int DEFAULT '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [remindersent] VARCHAR(17) DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [remindercount] int DEFAULT '0'"); echo $modifyoutput; flush();
}
}

Expand Down Expand Up @@ -389,6 +390,17 @@ function upgrade_survey_tables133a()
}


function upgrade_token_tables134()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [validfrom] DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [validuntil] DATETIME"); echo $modifyoutput; flush();
}
}

function mssql_drop_constraint($fieldname, $tablename)
{
global $dbprefix, $connect, $modifyoutput;
Expand Down
17 changes: 17 additions & 0 deletions admin/install/upgrade-postgres.php
Expand Up @@ -112,6 +112,7 @@ function db_upgrade($oldversion) {
modify_database("", "ALTER TABLE prefix_surveys ADD attributedescriptions TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute1"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute2"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update prefix_settings_global set stg_value='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
Expand Down Expand Up @@ -168,4 +169,20 @@ function upgrade_survey_tables133()
}
}

function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv0." ADD validfrom datetime"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv0." ADD validuntil datetime"); echo $modifyoutput; flush();
}
}
}

?>
5 changes: 5 additions & 0 deletions admin/styles/default/adminstyle.css
Expand Up @@ -520,3 +520,8 @@ font-size:12px;
outline-color:#D2E0F2;
padding: 2px 5px;
}

.annotation
{
font-size:10px;
}

0 comments on commit 30e1507

Please sign in to comment.