Commit a675c044 by Denis Chenu

[feature] Allow to use beforeTokenSave event

parent 117153ac
Showing with 9 additions and 23 deletions
...@@ -4,8 +4,8 @@ Only partial changelog, [commit history](https://framagit.org/SondagePro-LimeSur ...@@ -4,8 +4,8 @@ Only partial changelog, [commit history](https://framagit.org/SondagePro-LimeSur
## Not released ## Not released
### Fix ### Feature
- Use Token model, allowing to use beforeTokenSave event
- Really allow to use all other plugins in Command - Really allow to use all other plugins in Command
## [0.4.0] - 2017-03-16 ## [0.4.0] - 2017-03-16
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @copyright 2016 AXA Insurance (Gulf) B.S.C. <http://www.axa-gulf.com> for initial version * @copyright 2016 AXA Insurance (Gulf) B.S.C. <http://www.axa-gulf.com> for initial version
* @copyright 2016-2017 Extract Recherche Marketing for cronTypes and BatchSize * @copyright 2016-2017 Extract Recherche Marketing for cronTypes and BatchSize
* @license AGPL v3 * @license AGPL v3
* @version 1.0.0 * @version 1.0.1
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by * it under the terms of the GNU Affero General Public License as published by
...@@ -674,7 +674,7 @@ class sendMailCron extends \ls\pluginmanager\PluginBase ...@@ -674,7 +674,7 @@ class sendMailCron extends \ls\pluginmanager\PluginBase
$oCriteria->params=$aParams; $oCriteria->params=$aParams;
# Send email # Send email
// Find all token // Find all token
$oTokens=TokenDynamic::model($iSurvey)->findAll($oCriteria); $oTokens=Token::model($iSurvey)->findAll($oCriteria);
$aCountMail['total']=count($oTokens); $aCountMail['total']=count($oTokens);
$this->sendMailCronLog("Sending $sType",1); $this->sendMailCronLog("Sending $sType",1);
foreach ($oTokens as $iToken) foreach ($oTokens as $iToken)
...@@ -683,7 +683,7 @@ class sendMailCron extends \ls\pluginmanager\PluginBase ...@@ -683,7 +683,7 @@ class sendMailCron extends \ls\pluginmanager\PluginBase
if($this->stopSendMailAction($aCountMail,$iSurvey,$sType)){ if($this->stopSendMailAction($aCountMail,$iSurvey,$sType)){
return; return;
} }
$oToken=TokenDynamic::model($iSurvey)->findByPk($iToken->tid); $oToken=Token::model($iSurvey)->findByPk($iToken->tid);
/* Find if need to already started or not */ /* Find if need to already started or not */
if($controlResponse){ if($controlResponse){
$oResponse=SurveyDynamic::model($iSurvey)->find("token=:token",array(":token"=>$oToken->token)); $oResponse=SurveyDynamic::model($iSurvey)->find("token=:token",array(":token"=>$oToken->token));
...@@ -801,28 +801,14 @@ class sendMailCron extends \ls\pluginmanager\PluginBase ...@@ -801,28 +801,14 @@ class sendMailCron extends \ls\pluginmanager\PluginBase
$this->currentBatchSize++; $this->currentBatchSize++;
$this->currentSurveyBatchSize++; $this->currentSurveyBatchSize++;
if(!$this->simulate){ if(!$this->simulate){
$oCommand=Yii::app()->db->createCommand();
if($sType=='invite'){ if($sType=='invite'){
$oCommand->update( $oToken->sent=dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
"{{tokens_{$iSurvey}}}",
array(
'sent'=>dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")),
),
"tid=:tid",
array(":tid"=>$oToken->tid)
);
} }
if($sType=='remind'){ if($sType=='remind'){
$oCommand->update( $oToken->remindersent=dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
"{{tokens_{$iSurvey}}}", $oToken->remindercount++;
array(
'remindersent'=>dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")),
'remindercount'=>$oToken->remindercount+1,
),
"tid=:tid",
array(":tid"=>$oToken->tid)
);
} }
$oToken->save();
} }
}else{ }else{
$sTo=implode(";",$aTo); $sTo=implode(";",$aTo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment