Esempio n. 1
0
 public function removeclientAction()
 {
     $request = $this->getRequest();
     $id = $this->_helper->IdConvert->hexToStr($request->getParam('id'));
     if (empty($id)) {
         $this->_helper->messenger->error('Nie podano parametru ID');
         return $this->_helper->redirector('index');
     }
     try {
         $db = $this->_model->getDefaultAdapter();
         $db->beginTransaction();
         $model = new WsClientHasServiceSet();
         $model->deleteClient($id);
         $db->commit();
         $this->_helper->messenger->success();
         $this->_helper->redirector('index');
         return;
     } catch (Logic_Ws_Exception $e) {
         $db->rollBack();
         $this->_helper->error(MSG_ERROR, $e);
     }
 }
Esempio n. 2
0
 /**
  * Aktualizacja uprawnień do grup sms
  *
  * @param Logic_Ws_Client_Permissions_Form_GroupSms $form formularz z danymi do zapisania
  * @param integer $id id edytowanego clienta
  * @param string $namespace rodzaj uprawnienia
  */
 public function updatePermissionsToGroup($form, $id)
 {
     $data = $form->getValues();
     $this->getAdapter()->beginTransaction();
     try {
         $newData = array();
         foreach ($data as $key => $value) {
             $namespaceSet = explode('_', $key);
             if ($namespaceSet[0] != 'limits') {
                 $newData[$namespaceSet[0]][$namespaceSet[1]]['value'] = $value;
             } else {
                 $newData[$namespaceSet[1]][$namespaceSet[2]][$namespaceSet[0]] = $value;
             }
         }
         $unset = false;
         foreach ($newData as $namespace => $row) {
             $groupModel = new WsClientHasServiceGroup();
             $referencesColumn = 'id_service_group';
             if ($namespace == Wsclient::GROUP_SERVICE_SET) {
                 $groupModel = new WsClientHasServiceSet();
                 $wsServiceSetLimit = new WsServiceSetLimits();
                 $wsServiceSetLimit->deleteLimits($id);
                 $referencesColumn = 'id_service_set';
             }
             if (!$unset || $namespace == Wsclient::GROUP_SERVICE_SET) {
                 if ($namespace == Wsclient::GROUP_EMAIL || $namespace == Wsclient::GROUP_SMS) {
                     $unset = true;
                 }
                 $groupModel->removeClientPermisions($id);
             }
             foreach ($row as $rowId => $val) {
                 if ($val['value']) {
                     $values[$referencesColumn] = $rowId;
                     $values['id_client'] = $id;
                     $row = $groupModel->createRow($values);
                     $row->save();
                     if ($val['limits']) {
                         $value = $val['limits'];
                         $value['ws_service_set_id'] = $rowId;
                         $value['ws_client_id'] = $id;
                         $wsServiceSetLimit->addLimits($value);
                     }
                 }
             }
         }
         $this->getAdapter()->commit();
     } catch (Exception $e) {
         $this->getAdapter()->rollBack();
         throw $e;
     }
 }
Esempio n. 3
0
 /**
  * Metoda sprawdza uprawnienia do grupy sms
  * @param integer $id id grupy sms
  * @param string $group rodzaj grupy
  * @return boolean
  */
 public function checkAccessToGroup($id, $group)
 {
     if (!$this->_client) {
         throw new Logic_Exception('Brak instancji klienta!');
     }
     $clientId = $this->_client->id;
     switch ($group) {
         case Wsclient::GROUP_EMAIL:
         case Wsclient::GROUP_SMS:
             $model = new WsClientHasServiceGroup();
             break;
         case Wsclient::GROUP_SERVICE_SET:
             $model = new WsClientHasServiceSet();
             break;
         default:
             throw new Logic_Exception('Nieznany rodzaj grupy!');
             break;
     }
     $result = $model->checkAccessForClient($id, $clientId);
     if ($result) {
         return true;
     } else {
         return false;
     }
 }