- Дописаны дополнительные условия проверки передаемых параметров. email теперь...

- Дописаны дополнительные условия проверки передаемых параметров. email теперь определяется одним из двух возможных способов, получением его через params или через message
parent 95a3970a
......@@ -80,18 +80,26 @@ class CheckPresenceTime extends ConditionBase implements ConditionInterface {
* @param TriggerSchedule $message
* @return bool
*/
public function check($message){
$user = User::find()->where(['email' => $message->email])->one();
if (!is_null($message->trigger_id) && !is_null($user)) {
/** @var TriggerCondition[] $conditions */
$conditions = TriggerCondition::find()->where(['trigger_id'=>$message->trigger_id, 'condition_id' => self::CONDITION_ID])->all();
foreach($conditions as $condition) {
$urlParam = TriggerParam::find()->where(['condition_id' => $condition->getPrimaryKey(), 'key' => 'url', 'value' => \Yii::$app->request->getUrl()])->one();
$timeParam = TriggerParam::find()->where(['condition_id' => $condition->getPrimaryKey(), 'key' => 'time'])->one();
if (!is_null($urlParam) && !is_null($timeParam)) {
$sumTime = TriggerLogs::getSummaryTimeByUrl($urlParam, $user->getPrimaryKey());
if ($sumTime >= $timeParam) {
return true;
public function check($message=null, $params = array()){
$email = null;
if (!is_null($message))
$email = $message->email;
elseif(array_key_exists('email', $params)) {
$email = $params['email'];
}
if (!is_null($email)) {
$user = User::find()->where(['email' => $email])->one();
if (!is_null($message->trigger_id) && !is_null($user)) {
/** @var TriggerCondition[] $conditions */
$conditions = TriggerCondition::find()->where(['trigger_id'=>$message->trigger_id, 'condition_id' => self::CONDITION_ID])->all();
foreach($conditions as $condition) {
$urlParam = TriggerParam::find()->where(['condition_id' => $condition->getPrimaryKey(), 'key' => 'url', 'value' => \Yii::$app->request->getUrl()])->one();
$timeParam = TriggerParam::find()->where(['condition_id' => $condition->getPrimaryKey(), 'key' => 'time'])->one();
if (!is_null($urlParam) && !is_null($timeParam)) {
$sumTime = TriggerLogs::getSummaryTimeByUrl($urlParam, $user->getPrimaryKey());
if ($sumTime >= $timeParam) {
return true;
}
}
}
}
......
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 to comment