public function isValid($recipientId, $content = null) { $model = new SmsCounter(); $client = $this->_client; $validator_config = json_decode($this->_rowService['validator_config']); //diee($validator_config); $serviceParams = $validator_config->Limit; $counterMonth = $model->getCounterForSet('month', $recipientId, $client['id'], $this->_rowService['id']); if ($counterMonth && $serviceParams->limit_month) { $validatorMonth = new Logic_Validate_ExpiryMonth(); if ($serviceParams->limit_month <= $counterMonth->count_value && !$validatorMonth->isValid($counterMonth->count_at_first)) { $this->_error('Osiagnieto limit miesieczny (' . $serviceParams->limit_month . ') na usluge ' . $this->_rowService['service_name'] . ' dla klienta ' . $client['client_name'], 430); return false; } } $counterDay = $model->getCounter('day', $recipientId, $client['id'], $this->_rowService['id']); if ($counterDay && $serviceParams->limit_day) { $validatorDay = new Logic_Validate_ExpiryDay(); if ($serviceParams->limit_day <= $counterDay->count_value && !$validatorDay->isValid($counterMonth->count_at_first)) { $this->_error('Osiagnieto limit dzienny (' . $serviceParams->limit_day . ') na usluge ' . $this->_rowService['service_name'] . ' dla klienta ' . $client['client_name'], 431); return false; } } return true; }
public function isValid($recipientId, $content = null) { $model = new SmsCounter(); $client = $this->_client; $validator_config = json_decode($this->_rowService['validator_config']); $serviceParams = $validator_config->Content; //diee($recipientId . ' ' . $client['id'] . ' ' . $this->_rowService['id'] . ' ' . md5($content)); $counterContent = $model->getCounterWithContent('day', $recipientId, $client['id'], $this->_rowService['id'], md5($content)); //diee($counterContent); if ($counterContent && $serviceParams->limit_day_duplicate) { $validatorDay = new Logic_Validate_ExpiryDay(); if ($serviceParams->limit_day_duplicate <= $counterContent->subcounter && !$validatorDay->isValid($counterContent->count_at_first)) { throw new Logic_WebService_Sms_Exception('Osiagnieto limit dzienny dubli (' . $serviceParams->limit_day_duplicate . ') na usluge ' . $this->_rowService['service_name'] . ' dla klienta ' . $client['client_name'], 432); return false; } } return true; }
/** * @param Logic_WebService_Element_Client $client * @param Logic_WebService_Element_Service $service * @param Logic_WebService_Sms_Content $content * @throws Logic_WebService_Sms_Exception * @return void */ public function checkLimitByContent(Logic_WebService_Element_Client $client, Logic_WebService_Element_Service $service, Logic_WebService_Sms_Content $content) { $model = new SmsCounter(); $clientParams = $client->getParams(); $serviceParams = $service->getParams(); $counterContent = $model->getCounterWithContent('day', $this->_recipient->id, $clientParams->id, $serviceParams->id, $content->getHash()); if ($counterContent && $serviceParams->limit_day_duplicate) { $validatorDay = new Logic_Validate_ExpiryDay(); if ($serviceParams->limit_day_duplicate <= $counterContent->subcounter && !$validatorDay->isValid($counterContent->count_at_first)) { throw new Logic_WebService_Sms_Exception('Osiagnieto limit dzienny dubli (' . $serviceParams->limit_day_duplicate . ') na usluge ' . $serviceParams->service_name . ' dla klienta ' . $clientParams->client_name, 432); } } }