Skip to content

Commit

Permalink
New feature: Allow user to enter to the survey after registering. Opt…
Browse files Browse the repository at this point in the history
…ion in survey setting
  • Loading branch information
Shnoulle committed Dec 15, 2012
1 parent 9c44470 commit 2504b03
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.10a";
$config['dbversionnumber'] = 167;
$config['dbversionnumber'] = 168;
$config['buildnumber'] = '';
$config['updatable'] = true;

Expand Down
28 changes: 24 additions & 4 deletions application/controllers/RegisterController.php
Expand Up @@ -212,15 +212,35 @@ function actionIndex($surveyid = null)
."SET sent='$dNow' WHERE tid=$iTokenID";
dbExecuteAssoc($query) or show_error("Unable to execute this query : $query<br />"); //Checked
$sHTML = "<center>".$clang->gT("Thank you for registering to participate in this survey.")."<br /><br />\n";
$sHTML = $clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.")."<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
$sHTML = ReplaceFields($sHTML, $aReplacementFields);
if($thissurvey['directregister']!="Y")
{
$sHTML .= $clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.")."<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
}
else
{
$registerurl=Yii::app()->getController()->createUrl("{$surveyid}/lang-{$sLanguage}/tk-{$sNewToken}");
$sHTML .= sprintf($clang->gT("An email has been sent to the address you provided with access details for this survey. <a href='%s'>You can enter to this survey now</a>.",'unescaped'),$registerurl);
$sHTML .= "<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
}
$sHTML .= "<br /><br /></center>\n";

}
else
{
$sHTML = "Email Error";
$sHTML = "<center>".$clang->gT("Thank you for registering to participate in this survey.")."<br /><br />\n";
if($aSurveyInfo['directregister']!="Y")
{
$sHTML .= $clang->gT("We are sorry, an error occured when attempting to send email.")."<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
}
else
{
$registerurl=Yii::app()->getController()->createUrl("{$iSurveyID}/lang-{$sLanguage}/tk-{$sNewToken}");
$sHTML .= sprintf($clang->gT("An error occured when attempting to send email. <a href='%s'>You can enter to this survey now</a>.",'unescaped'),$registerurl);
$sHTML .= "<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
}
$sHTML .= "<br /><br /></center>\n";
}

$sHTML = ReplaceFields($sHTML, $aReplacementFields);
//PRINT COMPLETED PAGE
if (!$thissurvey['template'])
{
Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/database.php
Expand Up @@ -975,6 +975,7 @@ function index($sa = null)
'publicgraphs'=> Yii::app()->request->getPost('publicgraphs'),
'usecookie'=> Yii::app()->request->getPost('usecookie'),
'allowregister'=> Yii::app()->request->getPost('allowregister'),
'directregister'=> Yii::app()->request->getPost('directregister'),
'allowsave'=> Yii::app()->request->getPost('allowsave'),
'navigationdelay'=> Yii::app()->request->getPost('navigationdelay'),
'printanswers'=> Yii::app()->request->getPost('printanswers'),
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -1119,6 +1119,7 @@ private function _fetchSurveyInfo($action, $iSurveyID=null)
$esrow['autoredirect'] = 'N';
$esrow['tokenlength'] = 15;
$esrow['allowregister'] = 'N';
$esrow['directregister'] = 'N';
$esrow['usecookie'] = 'N';
$esrow['usecaptcha'] = 'D';
$esrow['htmlemail'] = 'Y';
Expand Down Expand Up @@ -1568,6 +1569,7 @@ function insert($iSurveyID=null)
'usecookie' => $_POST['usecookie'],
'emailnotificationto' => $_POST['emailnotificationto'],
'allowregister' => $_POST['allowregister'],
'directregister' => $_POST['directregister'],
'allowsave' => $_POST['allowsave'],
'navigationdelay' => $_POST['navigationdelay'],
'autoredirect' => $_POST['autoredirect'],
Expand Down
4 changes: 4 additions & 0 deletions application/core/Survey_Common_Action.php
Expand Up @@ -725,6 +725,10 @@ function _surveysummary($iSurveyID, $action=null, $gid=null)
{
$surveysummary2 .= $clang->gT("If tokens are used, the public may register for this survey") . "<br />";
}
if ($surveyinfo['directregister'] == "Y")
{
$surveysummary2 .= $clang->gT("If public may register for this survey,they can answer without email confirmation.") . "<br />";
}
if ($surveyinfo['allowsave'] == "Y" && $surveyinfo['tokenanswerspersistence'] == 'N')
{
$surveysummary2 .= $clang->gT("Participants can save partially finished surveys") . "<br />\n";
Expand Down
1 change: 1 addition & 0 deletions application/helpers/admin/survey_helper.php
Expand Up @@ -32,6 +32,7 @@ function getSurveyDefaultSettings()
'autoredirect' => 'N',
'tokenlength' => 15,
'allowregister' => 'N',
'directregister' => 'N',
'usecookie' => 'N',
'usecaptcha' => 'D',
'htmlemail' => 'Y',
Expand Down
6 changes: 6 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1083,6 +1083,12 @@ function db_upgrade_all($oldversion) {
// Add attachment text field to survey table.
addColumn('{{surveys_languagesettings}}', 'attachments', 'text');
Yii::app()->db->createCommand()->update('{{settings_global}}',array('stg_value'=>167),"stg_name='DBVersion'");
}
if ($oldversion < 168)
{
// Add directregister text field to survey table.
addColumn('{{surveys}}','directregister',"{$sVarchar}(1) default 'N'");
Yii::app()->db->createCommand()->update('{{settings_global}}',array('stg_value'=>168),"stg_name='DBVersion'");
}
}
catch(Exception $e)
Expand Down
1 change: 1 addition & 0 deletions application/models/Survey.php
Expand Up @@ -108,6 +108,7 @@ public function rules()
array('datestamp', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('usecookie', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('allowregister', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('directregister', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('allowsave', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('autoredirect', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('allowprev', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
Expand Down
3 changes: 2 additions & 1 deletion installer/sql/create-mssql.sql
Expand Up @@ -384,6 +384,7 @@ CREATE TABLE [prefix_surveys] (
[datestamp] varchar(1) NOT NULL default 'N',
[usecookie] varchar(1) NOT NULL default 'N',
[allowregister] varchar(1) NOT NULL default 'N',
[directregister] varchar(1) NOT NULL default 'N',
[allowsave] varchar(1) NOT NULL default 'Y',
[autonumber_start] int NOT NULL default '0',
[autoredirect] varchar(1) NOT NULL default 'N',
Expand Down Expand Up @@ -618,4 +619,4 @@ INSERT INTO [prefix_question_type_groups] ([id], [name], [order], [system]) VALU
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '167');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '168');
3 changes: 2 additions & 1 deletion installer/sql/create-mysql.sql
Expand Up @@ -389,6 +389,7 @@ CREATE TABLE `prefix_surveys` (
`datestamp` varchar(1) NOT NULL default 'N',
`usecookie` varchar(1) NOT NULL default 'N',
`allowregister` varchar(1) NOT NULL default 'N',
`directregister` varchar(1) NOT NULL default 'N',
`allowsave` varchar(1) NOT NULL default 'Y',
`autonumber_start` int(11) NOT NULL default '0',
`autoredirect` varchar(1) NOT NULL default 'N',
Expand Down Expand Up @@ -626,4 +627,4 @@ INSERT INTO `prefix_question_type_groups` (`id`, `name`, `order`, `system`) VALU
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '167');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '168');
3 changes: 2 additions & 1 deletion installer/sql/create-pgsql.sql
Expand Up @@ -395,6 +395,7 @@ CREATE TABLE prefix_surveys (
datestamp character varying(1) DEFAULT 'N' NOT NULL,
usecookie character varying(1) DEFAULT 'N' NOT NULL,
allowregister character varying(1) DEFAULT 'N' NOT NULL,
directregister character varying(1) DEFAULT 'N' NOT NULL,
allowsave character varying(1) DEFAULT 'Y' NOT NULL,
autonumber_start integer DEFAULT 0 NOT NULL,
autoredirect character varying(1) DEFAULT 'N' NOT NULL,
Expand Down Expand Up @@ -627,4 +628,4 @@ INSERT INTO prefix_question_type_groups (id, name, "order", system) VALUES
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '167');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '168');

0 comments on commit 2504b03

Please sign in to comment.