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; }
/** * @param Logic_WebService_Element_Client $client * @param Logic_WebService_Element_Service $service * @throws Logic_WebService_Sms_Exception * @return void */ public function checkLimit(Logic_WebService_Element_Client $client, Logic_WebService_Element_Service $service) { $model = new SmsCounter(); $clientParams = $client->getParams(); $serviceParams = $service->getParams(); $counterMonth = $model->getCounter('month', $this->_recipient->id, $clientParams->id, $serviceParams->id); if ($counterMonth && $serviceParams->limit_month) { $validatorMonth = new Logic_Validate_ExpiryMonth(); if ($serviceParams->limit_month <= $counterMonth->count_value && !$validatorMonth->isValid($counterMonth->count_at_first)) { throw new Logic_WebService_Sms_Exception('Osiagnieto limit miesieczny (' . $serviceParams->limit_month . ') na usluge ' . $serviceParams->service_name . ' dla klienta ' . $clientParams->client_name, 430); } } $counterDay = $model->getCounter('day', $this->_recipient->id, $clientParams->id, $serviceParams->id); if ($counterDay && $serviceParams->limit_day) { $validatorDay = new Logic_Validate_ExpiryDay(); if ($serviceParams->limit_day <= $counterDay->count_value && !$validatorDay->isValid($counterMonth->count_at_first)) { throw new Logic_WebService_Sms_Exception('Osiagnieto limit dzienny (' . $serviceParams->limit_day . ') na usluge ' . $serviceParams->service_name . ' dla klienta ' . $clientParams->client_name, 431); } } }