public function indexAction() { $request = $this->getRequest(); $phoneNumber = $this->_helper->IdConvert->hexToStr($request->getParam('phone_number')); $client = Logic_Client::getInstance(); $form = new Logic_Ws_Service_Form_Sms_SendSingle(); $form->populate(array('add_recipient' => $phoneNumber)); if ($request->isPost()) { $values = $request->getPost(); if ($form->isValid($values)) { $values = $form->getValues(); try { $http = new Zend_Controller_Request_Http(); $ip = $http->getServer('SERVER_ADDR'); $loadBalancer = $client->getLoadBalancer(Wsclient::GROUP_SMS, $values['ws_service_group_id']); $sms = new Logic_Sms($loadBalancer->getService(), $ip); $textMethod = true === boolval($values['is_confidental']) ? 'textconfidental' : 'text'; $response = $sms->{$textMethod}($values['add_recipient'], $values['msg_content_sub']['message_content'], array('zeroClass' => $values['message_class_zero'], 'advancedEncoding' => $values['extending_encoding_characters'])); } catch (Exception $exc) { $this->_helper->messenger->error("Nie udało sie wysłać wiadomości SMS"); if (is_object($sms)) { $this->_helper->messenger->error($sms->getCheckerErrorsAsString()); } return $this->_redirect('smsstandardsend'); } $this->_helper->messenger->success("Pomyślnie wysłano wiadomość teskstową"); return $this->_redirect('smsstandardsend'); } } $this->view->form = $form; }
public function baseInit() { $client = Logic_Client::getInstance(); $this->addElement('select', 'ws_addressbook_id', array('label' => 'Adresy', 'MultiOptions' => $this->addClearStart($client->getAddressBookAsDict()))); $this->addElement('button', 'add_ws_addressbook_id', array('label' => 'Dodaj')); $this->addElement('button', 'del_ws_addressbook_id', array('label' => 'Usuń')); }
/** * @todo Implementacja autoryzacji po SOAP */ public function authenticateSoapClient($clientHash, $serviceHash) { try { $client = Logic_Client::getInstance($clientHash); if ($client->getClient()->shipping_type != Logic_Ws_ServiceSet_ServiceSet::SHIPPING_TYPE_API) { throw new Logic_WebService_Exception('Ustawiony Klient nie pozwala na użycie usług w trybie API.', '410'); } $sg = new WsServiceGroup(); $sgRow = $sg->fetchRow("code ilike '" . $serviceHash . "' and ghost = false"); if (is_null($sgRow)) { throw new Logic_WebService_Exception('Nie rozpoznano grupy usług.', '410'); } if ($client->checkAccessToGroup($sgRow->id, $this->serviceGroup)) { $ip = Zend_Controller_Front::getInstance()->getRequest()->getServer('REMOTE_ADDR'); $client->checkIpAccess($ip); if ($this->serviceGroup == 'sms') { $loadBalancer = $client->getLoadBalancer($this->serviceGroup, $sgRow->id); $service = $loadBalancer->getService(); } else { $service = $client->getMailService($sgRow->id); } $className = 'Logic_' . ucfirst($this->serviceGroup); $this->_instance = new $className($service, $ip); } else { throw new Logic_WebService_Exception('Ustawiony Klient nie posiada dostępu do wskazanej grupy.', '410'); } } catch (Exception $exc) { throw new Logic_WebService_Exception($exc->getMessage(), $exc->getCode()); } }
/** * @return void */ public final function baseInit() { $this->_preInit(); $client = Logic_Client::getInstance(); $this->addElement('checkbox', 'is_confidental', array('label' => "Treść wiadomości poufna", 'value' => "0")); $this->addElement('select', 'ws_service_group_id', array('label' => "Grupa Usług", 'required' => true, 'MultiOptions' => $this->addClearStart($client->getGroupListAsDict(Wsclient::GROUP_SMS)))); $this->addElement('checkbox', 'extending_encoding_characters', array('label' => 'Użyj rozszerzonego kodowania znaków')); $this->_postInit(); }
public function text($phone_no, $content) { $hash = $this->hashContent($content); $recipientID = $this->getRecipientId($phone_no); $smsStorageId = $this->_saveStorage($recipientID, Logic_Client::getInstance()->getClient()->id, $this->getItemId(), $hash, $content, $this->internalPackageId); $client = $this->_createSoapRequest(); $sms = new Logic_Sms_Operator_Orange_SMSMessage($content, self::$_earliestDeliveryTime, self::$_expiryDate, self::$_priority, $phone_no, $originator, self::$_senderAddress, self::$_flash, self::$_deliveryNotification); $return = $client->SubmitShortMessage($sms); $this->_saveStorageStatus($smsStorageId, $return, $recipientID, Logic_Client::getInstance()->getClient()->id, $this->getItemId(), $hash); return $return; }
/** * @return void */ public function baseInit() { $dict = new Base_Dictionary(); $client = Logic_Client::getInstance(); $config = Zend_Registry::get('config'); $this->addElement('text', 'name', array('required' => true, 'label' => 'Nazwa wysyłki')); $this->addElement('select', 'ws_service_set_id', array('label' => 'Wysyłka', 'required' => true, 'MultiOptions' => $this->addClearStart($client->getGroupListAsDict(Wsclient::GROUP_SERVICE_SET)), 'attribs' => array('onchange' => 'getServiceSetOptions();'))); $this->addElement('file', 'addressbook_import_csv', array('label' => 'CSV z listą kontaktów do zaimportowania', 'required' => true, 'decorators' => $this->_fileDecorator, 'validators' => array(array('Extension', false, 'csv'), array('Size', false, $config['uploads']['maxfilesize'])))); $this->submit(false, 'save_send', 'Wyślij'); $this->submit(); $this->cancel(); }
/** * @return void */ public function baseInit() { $dictionary = new Base_Dictionary(); $client = Logic_Client::getInstance(); $this->addElement('text', 'name', array('label' => 'Nazwa', 'required' => true)); $this->addElement('select', 'ws_service_group_id', array('required' => true, 'label' => 'Grupa', 'multiOptions' => $this->addClearStart($client->getGroupListAsDict(Wsclient::GROUP_SMS)))); $this->addElement('multiselect', 'shipping_type', array('required' => true, 'label' => 'Rodzaj wysyłki', 'MultiOptions' => $this->addClearStart($dictionary->setSource('shipping_type')->getDictionary()))); $this->addElement('textarea', 'message', array('rows' => '15', 'cols' => '70', 'label' => 'Treść:')); $this->addElement('select', 'mpk_code', array('required' => true, 'label' => 'Oddział wg MPK', 'multiOptions' => $this->addClearStart($dictionary->setSource(new BranchMpk(), array('ghost = false'), 'mpk', 'mpk', array('branch_name'))->getDictionary()))); $this->addElement('select', 'file_type', array('required' => false, 'label' => 'Typ wysyłki:', 'multioptions' => $this->addClearStart($dictionary->setSource('service_import_file_type')->getDictionary()))); $this->addElement('select', 'delimiter', array('label' => "Separator pola", 'MultiOptions' => $this->addClearStart($dictionary->setSource('csv_delimeter')->getDictionary()))); $this->addDisplayGroup(array($this->file_type, $this->delimiter), 'file-type'); $this->submit(); $this->cancel(); }
public function baseInit() { $client = Logic_Client::getInstance(); $this->addElement('textarea', 'message_content', array('label' => 'Treść wiadomości', 'class' => 'message_content', 'required' => true, 'style' => 'width: 80%; height: 150px;', 'decorators' => array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form_element_div full_width')), array('Label', array('tag' => 'div', 'class' => 'form_element_label_div')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'full_width row'))), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, $this->_msgLengthMax))), 'attribs' => array('maxlength' => $this->_msgLengthMax))); // $this->addElement('text', 'message_content_limit', array( // 'label' => 'Pozostało znaków:', // 'class' => 'message_content_limit', // 'attribs' => array('disabled' => 'disabled'), // 'value' => $this->_msgLengthMax, // )); // // $this->addElement('text', 'message_quantity', array( // 'label' => 'Liczba wiadomości:', // 'class' => 'message_quantity', // 'validators' => array( // 'Int', // array( // 'validator' => 'Between', // 'options' => array( // 'min' => 1, // 'max' => 10, // 'inclusive' => true, // ), // ), // ), // 'value' => 1 // )); // // $this->addElement('text', 'message_signature', array( // 'label' => 'Podpis:', // 'class' => 'message_signature', // 'validators' => array( // array('StringLength', false, array('min' => '2', 'max' => '40')) // ) // )); // // // $this->addElement('select', 'overwrite_sender', array( // 'label' => 'Nadpis numeru nadawcy', // 'MultiOptions' => array() // )); $this->addElement('select', 'template_id', array('label' => 'Szablon', 'MultiOptions' => $this->addClearStart($client->getTemplateAsDict()), 'attribs' => array('onchange' => 'templateChoose(this)'))); }
public function test($mode, $packageDataId, $packageId) { $package = new Logic_Package($mode); $wsPackage = new WsPackage(); $wsPackageRow = $wsPackage->findOne($packageId); $package->updatePackageStatus($packageId, WsPackageStatus::STATUS_STARTED); $wsServiceSetRow = $wsPackageRow->findParentRow('WsServiceSet'); $rawData = $package->getRawDataToSend($packageDataId); // $client = Logic_Client::getInstanceByUser($package->getLastPackageStatus($packageId)->created_by); $client = Logic_Client::getInstance(); switch ($mode) { case Logic_Package::SMS_MODE: $loadBalancer = $client->getLoadBalancer(Wsclient::GROUP_SMS, $wsServiceSetRow->ws_service_group_id); $hasErrors = false; $service = $loadBalancer->getService(); do { if (null === $service) { $package->updatePackageDataStatus($packageDataId, array('id_status' => WsPackageStatus::STATUS_ERROR)); throw new Exception("Unable to get service! Check backup service!"); } $sms = new Logic_Sms($service, $wsPackageRow->ip); try { if ($wsPackageRow->getLastStatus->id_status == WsPackageStatus::STATUS_STARTED) { $response = $sms->package($rawData, $packageId); $package->updatePackageDataStatus($packageDataId, array('id_status' => WsPackageStatus::STATUS_SENT, 'external_package_id' => $response->packageId, 'ws_service_id' => $service->id)); $package->confirmPackageSend($wsPackageRow); } break; } catch (Exception $exc) { $package->updatePackageDataStatus($packageDataId, array('id_status' => WsPackageStatus::STATUS_ERROR)); $hasErrors = true; $service = $loadBalancer->getService(); sleep(1); } } while (true === $hasErrors || !(true === is_object($response) && true === property_exists($response, 'packageId'))); break; } unset($client); return rand(1, 999999); }
private function _saveStorage(array $dataToSave) { $model = new MailStorage(); $client = Logic_Client::getInstance(); $data = array_merge($dataToSave, array('ws_client_id' => $client->getClient()->id, 'ws_service_id' => $this->_serviceInstance->getServiceId())); return $model->addMail($data); }
protected function _getBasicClientData() { $client = Logic_Client::getInstance(); return array('ws_client_id' => $client->getClient()->id, 'ws_service_sms_id' => $this->_serviceInstance->getServiceId(), 'ws_service_group_sms_id' => $client->getCurrentServiceGroup()->id); }
public function baseInit() { $dict = new Base_Dictionary(); $date = new Zend_Date(); $user = Zend_Auth::getInstance()->getIdentity(); $client = Logic_Client::getInstance(); $wsServiceSet = $client->getGroupListAsDict(Wsclient::GROUP_SERVICE_SET); $config = Zend_Registry::get('config'); $this->addElement('text', 'name', array('required' => true, 'label' => 'Nazwa wysyłki')); $this->datee(false, "send_start", "Początek wysyłki"); $this->send_start->setValue($date->getDate()->toString('YYYY-MM-dd'))->addValidator('Callback', false, array('callback' => function ($value) { $date = new Zend_Date(); $date2 = clone $date; return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd')->getTimestamp(); })); $this->timee(false, "time_send_start", "Okno czasowe od"); $this->time_send_start->setValue('8:00'); $this->timee(false, "time_send_end", "Okno czasowe do"); $this->time_send_end->setValue('20:00'); $this->time_send_end->addValidator('Callback', false, array('callback' => function ($value) { return strtotime($value) > strtotime($this->time_send_start->getValue()); })); $this->datetimee(false, 'expiry_date', "Ważność wiadomości", false, array('value' => '')); $this->expiry_date->addValidator('Callback', false, array('callback' => function ($value) { $date = new Zend_Date(); $date2 = clone $date; $date2->setDate($value, 'YYYY-MM-dd HH:mm'); $date->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm'); return $date->getTimestamp() <= $date2->getTimestamp() && $date->addHour(72)->getTimestamp() >= $date2->getTimestamp(); })); $this->expiry_date->getValidator('Callback')->setMessages(array(Zend_Validate_Callback::INVALID_VALUE => "Data ważności wiadmości może wynosić maksymalnie 72 godziny")); $this->addElement('checkbox', 'repeat_message', array('label' => 'Powtarzaj tą wiadomość', 'attribs' => array('onchange' => 'checkPackageOptions();'))); $this->repeat_message->addValidator('Callback', false, array('callback' => function ($value) { if ($value) { $this->repeat_interval->setRequired(true); $this->repeat_count->setRequired(true); $this->repeat_end->setRequired(true); } return true; })); $this->addElement('radio', 'repeat_interval', array('MultiOptions' => $dict->setSource('package_repeat')->getDictionary(), 'attribs' => array('disable' => 'disable'), 'attribs' => array('onchange' => 'checkPackageOptions();'))); $this->repeat_interval->addValidator('Callback', false, array('callback' => function ($value) { if ($value == 5) { $this->repeat_days->setRequired(true); } elseif ($value == 4) { $this->repeat_day_interval->setRequired(true); } return true; })); $this->addElement('multiselect', 'repeat_days', array('MultiOptions' => $dict->setSource('day_of_week')->getDictionary(), 'attribs' => array('disable' => 'disable'))); $this->addElement('text', 'repeat_day_interval', array('label' => 'Powtarzań wiadomość co (liczba dni)', 'attribs' => array('disable' => 'disable'))); $this->addElement('text', 'repeat_count', array('label' => 'Ilość powtórzeń wiadomości', 'attribs' => array('disable' => 'disable'))); $this->datetimee(false, "repeat_end", "Powtarzań do", false, array('value' => '', 'attribs' => array('disabled' => 'disabled'))); $this->repeat_end->addValidator('Callback', false, array('callback' => function ($value) { $date = new Zend_Date(); $date2 = clone $date; $date->setDate($value, 'YYYY-MM-dd HH:mm'); $date2->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm'); return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd HH:mm')->getTimestamp(); })); $this->addElement('select', 'ws_service_set_id', array('label' => 'Wysyłka', 'required' => true, 'MultiOptions' => $this->addClearStart($wsServiceSet), 'attribs' => array('onchange' => 'getServiceSetOptions();'))); $this->addElement('select', 'file_type', array('required' => true, 'label' => 'Typ wysyłki:', 'multioptions' => $this->addClearStart($dict->setSource('service_import_file_type')->getDictionary()))); $this->addElement('file', 'addressbook_import_csv', array('label' => 'CSV z listą kontaktów do zaimportowania', 'decorators' => $this->_fileDecorator, 'validators' => array(array('Extension', false, 'csv'), array('Size', false, $config['uploads']['maxfilesize'])))); $this->addElement('select', 'delimeter', array('label' => "Separator pola", 'MultiOptions' => $this->addClearStart($dict->setSource('csv_delimeter')->getDictionary()))); $this->addElement('select', 'phone_heders', array('label' => "Kolumna z kontaktami")); $this->addElement('select', 'ws_addressbook_id', array('label' => 'Adresy', 'MultiOptions' => $this->addClearStart($dict->setSource(new Addressbook(), array('created_by =' . (int) $user->id, 'ghost=false'), 'id', 'id', array('addressbook_name'))->getDictionary()))); $this->addDisplayGroup(array($this->addressbook_import_csv, $this->delimeter, $this->phone_heders), 'tags_import'); $this->addElement('select', 'message_heders', array('label' => "Kolumna z wiadomością")); $this->submit(false, 'save_send', 'Wyślij'); $this->submit(); $this->cancel(); }
public function createRecipient($key, array $additionalData = array()) { $data = array_merge(array('phone_number' => $key, 'ws_client_id' => Logic_Client::getInstance()->getClient()->id), $additionalData); $row = $this->createRow($data); return $row->save(); }
public function loginAction() { $request = $this->getRequest(); if ($request->isXmlHttpRequest()) { $this->_helper->layout()->disableLayout(); $this->view->block_redirect = '/auth/login/msg/' . $request->getParam('msg', ''); } else { $ip = $this->_helper->currentip(); $form = new Logic_User_Form_Login(); $this->view->form = $form; $identity = Zend_Auth::getInstance()->getIdentity(); if (is_null($identity)) { $layout = Zend_Layout::getMvcInstance(); $layout->setLayout('_layouts/login'); } if (null !== ($identity = Zend_Auth::getInstance()->getIdentity())) { return $this->_redirect($identity->defaultAction); } if ($request->getParam('msg', false) == 'blocked') { $this->_helper->messenger('error', 'System blocked.'); } if ($request->isPost() and !strstr($_SERVER['SERVER_NAME'], 'szkolenia')) { if ($form->isValid($request->getPost())) { $values = $form->getValues(); $config = Zend_Registry::get('config'); switch ($config['auth']['method']) { case "LDAP": default: $adapter = new Logic_Auth_Adapter_Ldap(); break; case "DB": $user = new User(); $adapter = new Logic_Auth_Adapter_RemoteUserDbTable($user->getAdapter(), 'user', 'login', 'password', 'MD5(?)'); break; } $adapter->setIdentity($values['login'])->setCredential($values['password']); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (!$result->isValid() && $request->getParam('msg', false) != 'blocked') { switch ($result->getCode()) { case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: $uzytkownik = new Logic_User(); $uzytkownik->failedLogin($values['login'], md5($values['password'])); $this->_helper->messenger('error', 'Error while logging in. Specified account doesnt exist or account is inactive.'); break; default: $this->_helper->messenger('error', 'Error while logging in.'); break; } } else { $storage = $auth->getStorage(); $storageRow = $auth->getIdentity(); $uzytkownik = new Logic_User(); $uzytkownik->login($values['login'], md5($values['password'])); $uriSessionCheck = new Zend_Session_Namespace('prevUri'); if (isset($uriSessionCheck->uri) && $uriSessionCheck->uri != '/' && $uriSessionCheck->uri != '') { $action = $uriSessionCheck->uri; Zend_Session::namespaceUnset('prevUri'); } else { $action = $uzytkownik->getDefaultAction(); $action = $action ? $action : '/'; } $userProfiles = $uzytkownik->getProfiles(Zend_Auth::getInstance()->getIdentity()->id); $userProfile = $userProfiles->current(); $action = $userProfile->landing; try { Logic_Client::getInstance(); } catch (Exception $exc) { $this->_helper->messenger('info', 'Brak ustawionego Klienta. Niektóre funkcjonalności nie będą dostępne.'); } $storageRow->defaultAction = $action; $storage->write($storageRow); Zend_Session::setOptions(array('remember_me_seconds' => 7200)); return $this->_redirect($action); } } } } }
/** * Zwraca liczbę dubli * @param type $content * @param type $recipientId * @return integer */ private function _checkDoubles() { $model = new RecipientDuplicateMessages(); try { $count = $model->getAmountOfDuplicates($this->_messageContent->getContentToSend(), $this->_idRecipient); } catch (Exception $exc) { throw new Logic_Service_Exception("Cannot modify value of duplicate entry!", null, $exc); } $limits = Logic_Client::getInstance()->getServiceGroupLimits(); if (!is_null($limits['duplicate']) && $count > $limits['duplicate']) { $this->addCheckerError('Limit dubli dziennych został wyczerpany dla aktualnego odbiorcy!', __METHOD__); return false; } return true; }
public function text($phone_no, $content, $numberMask = null) { $hash = $this->hashContent($content); $recipientID = $this->getRecipientId($phone_no); $smsStorageId = $this->_saveStorage($recipientID, Logic_Client::getInstance()->getClient()->id, $this->getItemId(), $hash, $content, $this->internalPackageId); $url = $this->_createCurlRequest('wyslij_sms', $numberMask); $url .= $this->_paramToUri('numer', $phone_no); $url .= $this->_paramToUri('wiadomosc', $this->_contentToSms($content)); if ($this->_dryRunMode) { $url .= $this->_paramToUri('test', 1); } $return = $this->_send($url); $this->_saveStorageStatus($smsStorageId, $return, $recipientID, Logic_Client::getInstance()->getClient()->id, $this->getItemId(), $hash); return $return; }
/** * Wysyłanie reklamacji mailsoap * @param type $values */ public function sendComplaint($values, $complaint_id) { $sgm = new WsServiceGroup(); $sgid = $sgm->fetchRow(array('ghost = false', "code ilike 'complaint_mail_group'"))->id; $client = Logic_Client::getInstance(); $service = $client->getMailService($sgid); $c = new Logic_Complaint(); $complaint = $c->getComplaint($complaint_id); $rendered = Logic_Complaint::renderOne($complaint); $fn = 'formularz_reklamacji_' . date('Y-m-d') . '_' . $complaint['special_id'] . '.pdf'; $path = '/tmp/' . $fn; Logic_Complaint::renderPdf($rendered, 'F', $path); $attachments = array(0 => array('name' => $fn, 'type' => 'application/pdf;', 'content' => base64_encode(file_get_contents($path)), 'id' => $complaint['special_id'])); $http = new Zend_Controller_Request_Http(); $ip = $http->getServer('SERVER_ADDR'); $mail = new Logic_Mail($service, $ip); $mail->mail($values['recipient_mail'], array(), array(), $values['mail_subject'], $values['mail_content'], $attachments, 'UTF-8', false, $values['replyto']); }