Example #1
0
 /**
  * @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());
     }
 }
Example #2
0
 public function UpdateServiceGroup($id, array $values)
 {
     $serviceIds = is_array($values['ws_service_id']) ? $values['ws_service_id'] : array($values['ws_service_id']);
     unset($values['ws_service_id']);
     $this->_model->getDefaultAdapter()->beginTransaction();
     $this->_model->updateGroup($id, $values);
     $hasWsServiceModel = new WsServiceGroupHasWsService();
     $hasWsServiceModel->deleteByGroup($id);
     foreach ($serviceIds as $serviceId) {
         $test = $hasWsServiceModel->createRow(array('ws_service_id' => $serviceId, 'ws_service_group_id' => $id))->save();
     }
     try {
         $this->_model->getDefaultAdapter()->commit();
     } catch (Exception $exc) {
         $this->_model->getDefaultAdapter()->rollBack();
         throw new Logic_Exception("Cannot update service group data!", 0, $exc);
     }
 }
Example #3
0
 /**
  * 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']);
 }