diff --git a/application/models/Tokens_dynamic.php b/application/models/Tokens_dynamic.php index 4be0e6de568..681b12aeff5 100644 --- a/application/models/Tokens_dynamic.php +++ b/application/models/Tokens_dynamic.php @@ -337,6 +337,26 @@ function createTokens($iSurveyID) return array($newtokencount,count($tkresult)); } + + + /** + * This method is invoked before saving a record (after validation, if any). + * The default implementation raises the {@link onBeforeSave} event. + * You may override this method to do any preparation work for record saving. + * Use {@link isNewRecord} to determine whether the saving is + * for inserting or updating record. + * Make sure you call the parent implementation so that the event is raised properly. + * @return boolean whether the saving should be executed. Defaults to true. + */ + public function beforeSave() + { + // Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected + if ($this->usesleft>0) + { + $this->completed='N'; + } + return parent::beforeSave(); + } public function search() {