示例#1
0
 /**
  * Aktualizacja zapytania
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id kontaktu do poprawienia
  * @return integer ilość poprawionych wierszy
  */
 public function updateFeedback($form, $id)
 {
     $feedback = new Feedback();
     $data = $feedback->findOne($id);
     $data->setFromArray($form->getValues());
     return $data->save();
 }
示例#2
0
文件: Message.php 项目: knatorski/SMS
 /**
  * Aktualizacja komunikatu
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id komunikatu do poprawienia
  * @return integer ilość poprawionych wierszy
  */
 public function updateMessage($form, $id)
 {
     $komunikat = new Message();
     $data = $komunikat->findOne($id);
     $data->setFromArray($form->getValues());
     return $data->save();
 }
示例#3
0
文件: Roles.php 项目: knatorski/SMS
 public function getValues()
 {
     $values = parent::getValues();
     $tmp = array();
     foreach ($values as $name => $value) {
         if ($value == 1) {
             $tmp[] = $this->cbidfromname($name);
         }
     }
     return $tmp;
 }
示例#4
0
 /**
  * Ustawia wartosci filtrow
  *
  * Nie wymaga przeslania danych via POST
  *
  * @param Zend_Controller_Request_Http $request
  * @return Logic_Search_Abstract
  */
 public function setFilterDataFromRequest(Zend_Controller_Request_Http $request)
 {
     if (!is_object($this->_form)) {
         throw new Logic_Search_Exception('Nie ustanowiono obiektu formularza filtrow');
     }
     if ($this->_form->isValid($request->getParams())) {
         $this->saveFilterData($this->_form->getValues());
     }
     $this->_form->setDefaults($this->getFilterData());
     return $this;
 }
示例#5
0
 public function getValues()
 {
     $values = parent::getValues();
     $tmp = array();
     foreach ($values as $name => $value) {
         if ($value) {
             $tmp_name = explode('_', $name);
             $tmp[$tmp_name[0]][] = $tmp_name[1];
         }
     }
     return $tmp;
 }
示例#6
0
 /**
  * @param Base_Form_Abstract $form
  * @return mixed
  */
 protected function _createDictionary($form)
 {
     $dictionary = new Dictionary();
     $values = $form->getValues();
     $new_id = $dictionary->getAdapter()->query('SELECT MAX(id)+1 as max FROM dictionary')->fetch();
     $values['id'] = $new_id['max'];
     $val['created_by'] = Zend_Auth::getInstance()->getIdentity()->id;
     $data = $dictionary->createRow($values);
     $id = $data->save();
     $logger = Zend_Registry::get('logger');
     $message['messages']['Dictionary'][$id] = 'Dictionary added.';
     Zend_Registry::set('logger', array_merge($logger, $message));
     return $id;
 }
示例#7
0
 /**
  * @param integer $id
  * @param Base_Form_Abstract $form
  * @throws Logic_Ws_Exception
  * @return void
  */
 public function updateClient($id, Base_Form_Abstract $form)
 {
     $values = $form->getValues();
     $ipAddress = $values['ip_address'];
     unset($values['ip_address']);
     if (empty($values['code'])) {
         unset($values['code']);
     }
     $clientIpModel = new WsClientHasWsSaveip();
     try {
         if (intval($values['shipping_type']) === Logic_Ws_ServiceSet_ServiceSet::SHIPPING_TYPE_API && !empty($values['code'])) {
             $values['code'] = sha1($values['code']);
         }
         $oldRow = $this->findOne($id);
         $oldRow->setFromArray($values);
         $oldRow->save();
         $clientIpModel->deleteIP($id);
         foreach ($ipAddress as $val) {
             if (intval($val) > 0) {
                 $clientIpModel->insertClientIP(array('ws_client_id' => $id, 'ws_saveip_id' => $val));
             }
         }
     } catch (Exception $e) {
         throw new Logic_Ws_Exception($e->getMessage());
     }
 }
示例#8
0
 public function getValues($suppressArrayNotation = true)
 {
     $values = parent::getValues($suppressArrayNotation);
     $values['user'] = Zend_Controller_Action_HelperBroker::getStaticHelper('IdConvert')->hexToStr($values['user']);
     return $values;
 }
示例#9
0
 /**
  * Aktualizacja roli i jej uprawnień
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id edytowanej roli
  * @return integer liczba zmienionych wierszy
  */
 public function updateRole($form, $id)
 {
     $roleModel = new Role();
     $roleGroupModel = new RoleGroup();
     $dane = $values = $form->getValues();
     $subForms = $form->getSubForms();
     foreach ($subForms as $subForm) {
         unset($dane[get_class($subForm)]);
     }
     $roleModel->getAdapter()->beginTransaction();
     try {
         $tmp = $roleModel->update($dane, 'id = ' . $id);
         $roleGroupModel->delete('id_role = ' . $id);
         foreach ($subForms as $subForm) {
             $groups = $values[get_class($subForm)];
             foreach ($groups['group'] as $group) {
                 $subValues['id_group'] = $group;
                 $subValues['id_role'] = $id;
                 $row = $roleGroupModel->createRow($subValues);
                 $row->save();
             }
         }
         $roleModel->getAdapter()->commit();
         $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager');
         $cache = $cm->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     } catch (Exception $e) {
         $roleModel->getAdapter()->rollBack();
         throw $e;
     }
     return $tmp;
 }
示例#10
0
文件: Filter.php 项目: knatorski/SMS
 /**
  * Aktualizacja ról, które mają dostęp do filtra
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id filtra
  * @return integer ilość poprawionych wierszy
  */
 public function shareFilter($form, $id)
 {
     $model = new RoleFilterResource();
     $values = $form->getValues();
     $model->getAdapter()->beginTransaction();
     $filters = $model->fetchAll('id_filter = ' . $id);
     foreach ($filters as $filter) {
         $filter->delete();
     }
     $ret = 0;
     try {
         foreach ($values as $role_id) {
             $tmp = $model->createRow(array('id_filter' => $id, 'id_role' => $role_id));
             $tmp->save();
             $ret++;
         }
         $model->getAdapter()->commit();
         $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager');
         $cache = $cm->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     } catch (Exception $e) {
         $model->getAdapter()->rollBack();
     }
     return $ret;
 }
示例#11
0
 /**
  * 
  * @param Base_Form_Abstract $form
  * @param type $id
  * @throws Logic_Ws_Exception
  */
 public function updateIP(Base_Form_Abstract $form, $id)
 {
     $values = $form->getValues();
     $clients = $values['clients'];
     unset($values['clients']);
     $clientIpModel = new WsClientHasWsSaveip();
     try {
         $oldRow = $this->findOne($id);
         $oldRow->setFromArray($values);
         $oldRow->save();
         $clientIpModel->deleteClients($id);
         foreach ($clients as $val) {
             $clientIpModel->insertClientIP(array('ws_client_id' => $val, 'ws_saveip_id' => $id));
         }
     } catch (Exception $e) {
         throw new Logic_Ws_Exception($e->getMessage());
     }
 }
示例#12
0
文件: Generic.php 项目: knatorski/SMS
 public function getValues($suppressArrayNotation = true)
 {
     $values = parent::getValues($suppressArrayNotation);
     $values['ip'] = $this->getValue('ip');
     return $values;
 }
示例#13
0
 /**
  * Zapisywanie winformacji o wysyłce
  * @param Base_Form_Abstract $form
  * @return type
  * @throws Logic_Ws_Exception
  */
 public function sendAndSaveComplaint(Base_Form_Abstract $form, $complaint_id)
 {
     $values = $form->getValues();
     $identity = Zend_Auth::getInstance()->getIdentity();
     $values['created_by'] = $identity->id;
     if (!empty($identity->email)) {
         $values['replyto'] = $identity->email;
     } else {
         throw new Logic_Ws_Exception('Replyer mail empty. Cannot send complaint!');
     }
     $cfg = Zend_Registry::get('config');
     $values['recipient_mail'] = $cfg['complaint']['recipient'];
     $this->sendComplaint($values, $complaint_id);
     $row = $this->findOne($complaint_id);
     $row->setFromArray(array('send_at' => date('c'), 'send_by' => $identity->id));
     $id = $row->save();
 }
示例#14
0
文件: User.php 项目: knatorski/SMS
 /**
  * Aktualizacja zasobów(grup) dla profilu
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id profilu
  * @return integer ilość poprawionych wierszy
  */
 public function _updateGroupResource($form, $id)
 {
     $profileResourceDenyModel = new ProfileResourceDeny();
     $values = $form->getValues();
     $profileResourceDenyModel->delete('id_profile = ' . $id);
     $profileResourceDenyModel->getAdapter()->beginTransaction();
     $tmp = 0;
     $ret = 0;
     try {
         foreach ($values['group'] as $group_id) {
             $tmp = $profileResourceDenyModel->insert(array('id_profile' => $id, 'id_group' => $group_id));
         }
         $ret += $tmp;
         $tmp = 0;
         $profileResourceDenyModel->getAdapter()->commit();
         $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     } catch (Exception $e) {
         $profileResourceDenyModel->getAdapter()->rollBack();
     }
     return $ret;
 }