Skip to content

Commit

Permalink
Fixed issue #6604: The Survey URL sent with the registration mail is …
Browse files Browse the repository at this point in the history
…not working
  • Loading branch information
c-schmitz committed Sep 28, 2012
1 parent 09d50b5 commit 3344db6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 55 deletions.
60 changes: 11 additions & 49 deletions application/config/routes.php
Expand Up @@ -10,70 +10,32 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There area two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/


//Compatibility with classic modrewrite
$route['(:num)/lang-(:any)/tk-(:any)'] = "survey/sid/$1/lang/$2/token/$3"; //This one must be first
$route['(:num)/lang-(:any)'] = "survey/sid/$1/lang/$2";
$route['(:num)/tk-(:any)'] = "survey/sid/$1/token/$2";
$route['(:num)'] = "survey/sid/$1";
$route['<_sid:\d+>/lang-<_lang:\w+>/tk-<_token:\w+>'] = "survey/index/sid/<_sid>/lang/<_lang>/token/<_token>"; //This one must be first
$route['<_sid:\d+>/lang-<_lang:\w+>'] = "survey/index/sid/<_sid>/lang/<_lang>";
$route['<_sid:\d+>/tk-<_token:\w+>'] = "survey/index/sid/<_sid>/token/<_token>";
$route['<_sid:\d+>'] = "survey/index/sid/<_sid>";

//Admin Routes
$route['admin/index'] = "admin";
$route['admin/<action:\w+>/<sa:\w+>/*'] = 'admin/<action>/sa/<sa>';

//question
$route['admin/question/newquestion/(:num)/(:num)'] = "admin/question/index/addquestion/$1/$2";
$route['admin/question/editquestion/(:num)/(:num)/(:num)'] = "admin/question/index/editquestion/$1/$2/$3";
$route['admin/question/addquestion/<_sid:\d+>/<_gid:\d+>'] = "admin/question/addquestion/surveyid/<_sid>/gid/<_gid>";
$route['admin/question/editquestion/<_sid:\d+>/<_gid:\d+>/<_qid:\d+>'] = "admin/question/editquestion/surveyid/<_sid>/gid/<_gid>/qid/<_qid>";

$route['admin/labels/<action:\w+>'] = "admin/labels/index/<action>";
$route['admin/labels/<action:\w+>/<lid:\d+>'] = "admin/labels/index/<action>/<id>";
$route['admin/labels/<_action:\w+>'] = "admin/labels/index/<_action>";
$route['admin/labels/<_action:\w+>/<_lid:\d+>'] = "admin/labels/index/<_action>/<_lid>";

$route['<controller:\w+>/<action:\w+>'] = '<controller>/<action>';
$route['<_controller:\w+>/<_action:\w+>'] = '<_controller>/<_action>';

//Expression Manager tests
$route['admin/expressions'] = "admin/expressions/index";

//optout
$route['optout/(:num)/(:any)/(:any)'] = "optout/index/$1/$2/$3";
$route['optout/<_sid:\d+>/(:any)/(:any)'] = "optout/index/<_sid>/$2/$3";

return $route;
8 changes: 3 additions & 5 deletions application/helpers/frontend_helper.php
Expand Up @@ -1538,14 +1538,12 @@ function buildsurveysession($surveyid,$previewGroup=false)
//check if token actually does exist
// check also if it is allowed to change survey after completion
if ($thissurvey['alloweditaftercompletion'] == 'Y' ) {
$tkquery = "SELECT COUNT(*) FROM {{tokens_".$surveyid."}} WHERE token='".trim(strip_tags($clienttoken))."'";
$oTokenEntry = Tokens_dynamic::model($surveyid)->find('token=:token', array(':token'=>trim(strip_tags($clienttoken))));
} else {
$tkquery = "SELECT COUNT(*) FROM {{tokens_".$surveyid."}} WHERE token='".trim(strip_tags($clienttoken))."' AND (completed = 'N' or completed='')";
$oTokenEntry = Tokens_dynamic::model($surveyid)->find("token=:token AND (completed = 'N' or completed='')", array(':token'=>trim(strip_tags($clienttoken))));
}

$tkresult = dbExecuteAssoc($tkquery); //Checked
$tkexist = reset($tkresult->read());
if (!$tkexist || ($areTokensUsed && $thissurvey['alloweditaftercompletion'] != 'Y') )
if (is_null($oTokenEntry) || ($areTokensUsed && $thissurvey['alloweditaftercompletion'] != 'Y') )
{
//TOKEN DOESN'T EXIST OR HAS ALREADY BEEN USED. EXPLAIN PROBLEM AND EXIT

Expand Down
2 changes: 1 addition & 1 deletion application/models/Tokens_dynamic.php
Expand Up @@ -121,7 +121,7 @@ public function summary()
* (some older tokens tables dont' get udated properly)
*
*/
public function checkColumns() {
public function checkColumns() {
$sid = self::$sid;
$surveytable='{{tokens_'.$sid.'}}';
$columncheck=array("tid", "participant_id", "firstname", "lastname", "email", "emailstatus","token","language","blacklisted","sent","remindersent","completed","usesleft","validfrom","validuntil");
Expand Down

0 comments on commit 3344db6

Please sign in to comment.