Skip to content

Commit

Permalink
Dev Fixed issue where a token could not be resumed.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Oct 3, 2013
1 parent 6d11b66 commit 9e41c97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion application/controllers/survey/index.php
Expand Up @@ -494,7 +494,7 @@ function sendreq(surveyid)
{
// check also if it is allowed to change survey after completion
if ($thissurvey['alloweditaftercompletion'] == 'Y' ) {
$tokenInstance = Token::model($surveyid)->usable()->findByAttributes(array('token' => $token));
$tokenInstance = Token::model($surveyid)->editable()->findByAttributes(array('token' => $token));
} else {
$tokenInstance = Token::model($surveyid)->usable()->incomplete()->findByAttributes(array('token' => $token));
}
Expand Down
7 changes: 5 additions & 2 deletions application/models/Token.php
Expand Up @@ -142,8 +142,11 @@ public function scopes()
'condition' => 'completed = "N"'
),
'usable' => array(
'condition' => 'usesleft > 0 AND COALESCE(validfrom, NOW()) >= NOW() AND COALESCE(validfrom, NOW()) <= NOW()'
)
'condition' => 'usesleft > 0 AND COALESCE(validuntil, NOW()) >= NOW() AND COALESCE(validfrom, NOW()) <= NOW()'
),
'editable' => array(
'condition' => 'COALESCE(validuntil, NOW()) >= NOW() AND COALESCE(validfrom, NOW()) <= NOW()'
)

This comment has been minimized.

Copy link
@c-schmitz

c-schmitz Oct 14, 2013

Contributor

NOW() is propietary to MySQL and won't work with at least with MSSQL and maybe other DBs.

);
}
public function summary()
Expand Down

3 comments on commit 9e41c97

@mennodekker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SamMousa
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking into it right now. Also I'll use PHP to create the date format. Since we can have a time offset configured in LS the current behavior was actualy incorrect in cases where the db-time wasnt the same as the PHP time.

@SamMousa
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.