public function addNewPropertyAction()
 {
     $request = $this->getRequest();
     $dataResponse = array();
     if ($request->isPost()) {
         $pipelineId = $request->getParam('pipelineId');
         $propertyName = $request->getParam('newPropertyName');
         $propertyValue = $request->getParam('newPropertyValue');
         $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'pipeline_property', 'field' => 'sistem_name'));
         $systemName = $this->_getSistemNameProperty($propertyName);
         if ($systemName != '' && $validator->isValid(strtolower($systemName))) {
             $newProperty = $this->_createNewProperty($propertyName);
             if (!is_null($newProperty) && $request->getParam('pipelineId') != 0) {
                 $newPropertyValue = $this->_createPropertyValue($pipelineId, $newProperty->getId(), $propertyValue);
                 if (!is_null($newPropertyValue)) {
                     $dataResponse['property'] = array('propertyValueId' => $newPropertyValue->getId(), 'propertyName' => $newProperty->getName(), 'propertyValue' => $newPropertyValue->getValue());
                 }
             }
         } else {
             $alert = '<div class="alert alert-danger" role="alert">
                         <h4 class="text-center">Cвойство <a href="/admin/pipeline-property/">"' . $request->getParam('newPropertyName') . '"</a> уже существует.</h4>
                       </div>';
             $dataResponse['errorMessage'] = $alert;
         }
     }
     echo $this->_helper->json($dataResponse);
 }
Esempio n. 2
0
 public function isValid($value)
 {
     $valid = parent::isValid($value);
     if ($valid === false) {
         $this->_error(self::USERNAME_NOT_UNIQUE);
     }
     return $valid;
 }
Esempio n. 3
0
 /**
  * Validates email address
  *
  * @return boolean
  */
 protected function _validateEmail()
 {
     $validator = new Zend_Validate_EmailAddress();
     $msg = Sanmax_MessageStack::getInstance('SxCms_User');
     if (!$validator->isValid($this->_user->getEmail())) {
         $msg->addMessage('email', $validator->getMessages());
     }
     $exclude = array('field' => 'user_id', 'value' => (int) $this->_user->getId());
     $validator = new Zend_Validate_Db_NoRecordExists('User', 'email', $exclude);
     if (!$validator->isValid($this->_user->getEmail())) {
         $msg->addMessage('email', $validator->getMessages(), 'common');
     }
     return false == $msg->getMessages('email');
 }
Esempio n. 4
0
 public function checkEmail($email)
 {
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($email)) {
         // email address appears to be valid
         $validatorEmail = new Zend_Validate_Db_NoRecordExists(array('table' => 'usuario_login', 'field' => 'email'));
         if ($validatorEmail->isValid($email)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Esempio n. 5
0
 public function redirectsAction()
 {
     $redirectForm = new Application_Form_Redirect();
     $pageMapper = Application_Model_Mappers_PageMapper::getInstance();
     $redirectMapper = Application_Model_Mappers_RedirectMapper::getInstance();
     $redirectForm->setToasterPages($pageMapper->fetchIdUrlPairs());
     $redirectForm->setDefault('fromUrl', 'http://');
     if (!$this->getRequest()->isPost()) {
         $this->view->redirects = $redirectMapper->fetchRedirectMap();
     } else {
         if ($redirectForm->isValid($this->getRequest()->getParams())) {
             $data = $redirectForm->getValues();
             $redirect = new Application_Model_Models_Redirect();
             $fromUrlPath = Tools_System_Tools::getUrlPath($data['fromUrl']);
             $inDbValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'redirect', 'field' => 'from_url'));
             if (!$inDbValidator->isValid($fromUrlPath)) {
                 $this->_helper->response->fail(implode('<br />', $inDbValidator->getMessages()));
                 exit;
             }
             $redirect->setFromUrl(Tools_System_Tools::getUrlPath($data['fromUrl']));
             $redirect->setDomainFrom(Tools_System_Tools::getUrlScheme($data['fromUrl']) . '://' . Tools_System_Tools::getUrlHost($data['fromUrl']) . '/');
             if (intval($data['toUrl'])) {
                 $page = $pageMapper->find($data['toUrl']);
                 $redirect->setDomainTo($this->_helper->website->getUrl());
                 $redirect->setToUrl($page->getUrl());
                 $redirect->setPageId($page->getId());
             } else {
                 $urlValidator = new Validators_UrlRegex();
                 if (!$urlValidator->isValid($data['toUrl'])) {
                     $this->_helper->response->fail('External url <br />' . implode('<br />', $urlValidator->getMessages()));
                     exit;
                 }
                 $redirect->setDomainTo(Tools_System_Tools::getUrlScheme($data['toUrl']) . '://' . Tools_System_Tools::getUrlHost($data['toUrl']) . '/');
                 $redirect->setToUrl(Tools_System_Tools::getUrlPath($data['toUrl']));
                 $redirect->setPageId(null);
             }
             $redirectMapper->save($redirect);
             $this->_helper->cache->clean('toaster_301redirects', '301redirects');
             $this->_helper->response->success('Redirect saved');
         } else {
             $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessagesIntoHtml($redirectForm->getMessages(), get_class($redirectForm)));
             exit;
         }
     }
     $this->view->helpSection = '301s';
     $this->view->form = $redirectForm;
 }
 public function newAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'pipeline_property', 'field' => 'sistem_name'));
         if ($validator->isValid(strtolower($request->getParam('newPropertySystemName')))) {
             $newProperty = $this->_createNewProperty();
             if (!is_null($newProperty) && $request->getParam('pipelineId') != 0) {
                 $newPropertyValue = $this->_createNewPropertyValue($newProperty->getId());
                 echo $this->_helper->json($this->_createDataHtml($newProperty, $newPropertyValue));
             }
         } else {
             // username is invalid; print the reason
             $messages = $validator->getMessages();
             foreach ($messages as $message) {
                 $message = '<tr><td colspan="3"><div class="alert alert-danger" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $message . '</div></td></tr>';
                 echo $this->_helper->json($message);
             }
         }
     }
 }
Esempio n. 7
0
 public function validaUserNameAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     header('Cache-Control: no-cache');
     header('Content-type: application/xml; charset="utf-8"', true);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $login = $data["login"];
         $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'usuario_login', 'field' => 'login'));
         if ($validator->isValid($login)) {
             // email address appears to be valid
             echo $this->view->json(1);
         } else {
             echo $this->view->json(0);
         }
     }
 }
 public function socialAction()
 {
     header('Content-type: text/html; charset=UTF-8');
     $token = $_POST['access_token'];
     $host = $_SERVER['SERVER_NAME'];
     $url = 'http://login4play.com/token.php?token=' . $token . '&host=' . $host;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     curl_close($ch);
     $data = json_decode($result, true);
     $username = $data['given_name'];
     $password = $data['uid'];
     $email = $data['email'];
     $network = $data['network'];
     $date = $date = time();
     $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'users', 'field' => 'pass'));
     if ($validator->isValid(md5($password))) {
         $user = new Application_Model_DbTable_User();
         $user->addUser($username, md5($password), $email, $date, $network);
     }
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
     $authAdapter->setTableName('users')->setIdentityColumn('login')->setCredentialColumn('pass');
     $authAdapter->setIdentity($username)->setCredential(md5($password));
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $identity = $authAdapter->getResultRowObject();
         $authStorage = $auth->getStorage();
         $authStorage->write($identity);
         $this->_helper->redirector('index', 'index', 'default');
     } else {
         $this->view->errMessage = 'Ви ввели не правильний логін або пароль!';
     }
 }
Esempio n. 9
0
 /**
  * Test when adapter is provided
  *
  * @return void
  */
 public function testAdapterProvidedNoResult()
 {
     //clear the default adapter to ensure provided one is used
     Zend_Db_Table_Abstract::setDefaultAdapter(null);
     try {
         $validator = new Zend_Validate_Db_NoRecordExists('users', 'field1', null, $this->_adapterNoResult);
         $this->assertTrue($validator->isValid('value1'));
     } catch (Exception $e) {
         $this->markTestSkipped('No database available');
     }
 }
Esempio n. 10
0
 function editAction()
 {
     $this->view->title = $this->view->translate('Edit OfficeHierarchy');
     $officehierarchy = new Officehierarchy_Model_Officehierarchy();
     $this->view->officeHierarchySelect = $officehierarchy->fetchAllHierarchy();
     //get posted office id
     $noOfficeLevel = $this->_request->getPost('officeNo');
     //form instance for edit
     $form1 = new Officehierarchy_Form_Hierarchy1($noOfficeLevel, $noOfficeLevel);
     $this->view->form1 = $form1;
     $this->view->form1->officeNo->setValue($noOfficeLevel);
     $this->view->Edit = $this->_request->getPost('Next');
     //get confirmation
     $this->view->Confirm = $this->_request->getPost('Confirm');
     $this->view->noOfficeLevel = $noOfficeLevel;
     if ($this->_request->getPost('Next')) {
         $highlevel = $officehierarchy->findhighlevel();
         $officeLevel = $this->_request->getPost('officeLevel');
         foreach ($highlevel as $highlevel1) {
             $high = $highlevel1->high;
         }
         // if($high!=$highlevel){
         $this->view->officeLevel = $officeLevel;
         $formData = $this->_request->getPost();
         $this->view->form1->officeLevel->setValue($officeLevel);
         for ($i = 1; $i <= $noOfficeLevel; $i++) {
             $a = 'officeType' . $i;
             $b = 'officeCode' . $i;
             $c = 'id' . $i;
             $d = 'hierarchyLevel' . $i;
             if ($i <= $officeLevel) {
                 $this->view->form1->{$a}->setValue($this->_request->getPost('officeType' . $i));
                 $this->view->form1->{$b}->setAttrib('size', '2');
                 $this->view->form1->{$a}->setAttrib('readonly', 'true');
                 $this->view->form1->{$b}->setAttrib('readonly', 'true');
                 $this->view->form1->{$a}->setAttrib('class', 'txt_put nonEditing');
                 $this->view->form1->{$b}->setAttrib('class', 'txt_put nonEditing');
                 $this->view->form1->{$b}->setValue($this->_request->getPost('officeCode' . $i));
                 $this->view->form1->{$d}->setValue($this->_request->getPost('hierarchyLevel' . $i));
                 $this->view->form1->{$c}->setValue($this->_request->getPost('id' . $i));
             } else {
                 if ($i == $officeLevel + 1) {
                     $validator = new Zend_Validate_Db_NoRecordExists('ourbank_officehierarchy', 'type');
                     $validator1 = new Zend_Validate_Db_NoRecordExists('ourbank_officehierarchy', 'short_name');
                     $officeType = $this->_request->getPost('officeType' . $noOfficeLevel);
                     $officeCode = $this->_request->getPost('officeCode' . $noOfficeLevel);
                     if ($validator->isValid($officeType)) {
                         if ($validator1->isValid($officeCode)) {
                             $this->view->form1->{$a}->setValue($this->_request->getPost('officeType' . $noOfficeLevel));
                             $this->view->form1->{$b}->setAttrib('size', '2');
                             $this->view->form1->{$a}->setAttrib('readonly', 'true');
                             $this->view->form1->{$b}->setAttrib('readonly', 'true');
                             $this->view->form1->{$a}->setAttrib('class', 'txt_put editing');
                             $this->view->form1->{$b}->setAttrib('class', 'txt_put editing');
                             $this->view->form1->{$b}->setValue($this->_request->getPost('officeCode' . $noOfficeLevel));
                             $this->view->form1->{$c}->setValue($this->_request->getPost('id' . $noOfficeLevel));
                             $this->view->form1->{$d}->setValue($officeLevel + 1);
                         } else {
                             $messages = $officeCode . 'alreadyexisting';
                             $this->_redirect("officehierarchy?Existed=" . $messages);
                         }
                     } else {
                         $messages = $officeType . 'alreadyexisting';
                         $this->_redirect("officehierarchy?Existed=" . $messages);
                     }
                 } else {
                     $officeLevel++;
                     $this->view->form1->{$a}->setValue($this->_request->getPost('officeType' . $officeLevel));
                     $this->view->form1->{$b}->setAttrib('size', '2');
                     $this->view->form1->{$a}->setAttrib('readonly', 'true');
                     $this->view->form1->{$b}->setAttrib('readonly', 'true');
                     $this->view->form1->{$a}->setAttrib('class', 'txt_put nonEditing');
                     $this->view->form1->{$b}->setAttrib('class', 'txt_put nonEditing');
                     $this->view->form1->{$b}->setValue($this->_request->getPost('officeCode' . $officeLevel));
                     $this->view->form1->{$c}->setValue($this->_request->getPost('id' . $officeLevel));
                     $this->view->form1->{$d}->setValue($officeLevel + 1);
                 }
             }
         }
         $this->view->form1->Edit->setName('Confirm');
         $this->view->form1->Edit->setLabel('confirm');
         $this->view->form1->Edit->setAttrib('class', 'officesubmit');
         //set validation
         $this->view->form1->officeLevel->setRequired(true)->addValidators(array(array('NotEmpty'), array('stringLength', false, array(1, 2)), array('Digits')));
     }
     //         else{ echo "Choose low level hierarchy";}
     //             }
     //get confirmation and update
     if ($this->_request->isPost() && $this->_request->getPost('Confirm')) {
         $formData = $this->_request->getPost();
         $officeLevel = $this->_request->getPost('officeLevel');
         if ($form1->isValid($formData)) {
             if ($officeLevel) {
                 //increment of office id, code, and office type
                 for ($i = 1; $i <= $this->_request->getPost('officeNo'); $i++) {
                     if ($i <= $officeLevel) {
                         $officeType = ucwords($form1->getValue('officeType' . $i));
                         $id = $form1->getValue('id' . $i);
                         $officeCode = ucwords($form1->getValue('officeCode' . $i));
                         $level = $form1->getValue('hierarchyLevel' . $i);
                         $data = array('type' => $officeType, 'Hierarchy_level' => $level, 'short_name' => $officeCode);
                         $officehierarchy->officeUpdate($id, $data);
                     } else {
                         if ($i == $officeLevel + 1) {
                             $officeType = ucwords($form1->getValue('officeType' . $i));
                             $officeCode = ucwords($form1->getValue('officeCode' . $i));
                             $level = $form1->getValue('hierarchyLevel' . $i);
                             $createdby = $this->view->createdby;
                             $data = array('id' => '', 'type' => $officeType, 'Hierarchy_level' => $level, 'created_userid' => $createdby, 'createddate' => date("Y-m-d"), 'short_name' => $officeCode);
                             $date = date("Y-m-d");
                             $officehierarchy->officeInsert($data);
                         } else {
                             $officeType = ucwords($form1->getValue('officeType' . $i));
                             $id = $form1->getValue('id' . $i);
                             $officeCode = ucwords($form1->getValue('officeCode' . $i));
                             $level = $form1->getValue('hierarchyLevel' . $i);
                             $date = date("Y-m-d");
                             $data = array('type' => $officeType, 'Hierarchy_level' => $level, 'short_name' => $officeCode);
                             $officehierarchy->officeUpdate($id, $data);
                         }
                     }
                 }
             }
             $this->_redirect('officehierarchy');
         }
     }
     //validate update confirmation
     if ($this->_request->isPost() && $this->_request->getPost('update')) {
         //edit form instance of office hierarchy
         $form1 = new Officehierarchy_Form_EditHierarchy();
         $this->view->form1 = $form1;
         $formData = $this->_request->getPost();
         if ($form1->isValid($formData)) {
             $validator = new Zend_Validate_Db_NoRecordExists('ourbank_officehierarchy', 'type');
             $validator1 = new Zend_Validate_Db_NoRecordExists('ourbank_officehierarchy', 'short_name');
             $id = $form1->getValue('id');
             $officeType = ucwords($form1->getValue('officeType'));
             $officeCode = ucwords($form1->getValue('officeCode'));
             //get new form data
             $data = array('type' => $officeType, 'short_name' => $officeCode);
             $officehierarchy = new Officehierarchy_Model_Officehierarchy();
             $result = $officehierarchy->fetchOneOfficeHierarchy($id);
             //fetch existing data
             foreach ($result as $hierarchyArray) {
                 $oldData = array('type' => $hierarchyArray->officetype, 'short_name' => $hierarchyArray->officeshort_name);
             }
             //compare entered and existing data
             $match = array();
             foreach ($oldData as $key => $val) {
                 if ($val != $data[$key]) {
                     $match[] = $key;
                 }
             }
             //count no.of existing data matching
             if (count($match) <= 0) {
                 $this->view->updatEerror = 'updatemessage';
                 $this->view->form1->Edit->setName('update');
                 $this->view->form1->Edit->setLabel('update');
                 $this->view->form1->Edit->setAttrib('class', 'officesubmit');
                 $this->_redirect("officehierarchy");
             } else {
                 if ($validator->isValid($officeType) || $validator1->isValid($officeCode)) {
                     $officehierarchy = new Officehierarchy_Model_Officehierarchy();
                     $editOfficeHierarchy = $officehierarchy->editOfficeHierarchy($id);
                     foreach ($editOfficeHierarchy as $editOfficeHierarchyArray) {
                         if ($editOfficeHierarchyArray->officetype != $officeType || $editOfficeHierarchyArray->officeshort_name != $officeCode) {
                             $officehierarchy->officeUpdate($id, $data);
                             $this->_redirect('officehierarchy');
                         } else {
                             $this->view->form1->Edit->setName('update');
                             $this->view->form1->Edit->setLabel($this->view->ZendTranslate->_("update"));
                             $this->view->form1->Edit->setAttrib('class', 'officesubmit');
                             $messages = $officeType . ' (OR) ' . $officeCode . ' ' . 'alreadyexisting';
                             $this->_redirect("officehierarchy?Existed=" . $messages);
                         }
                     }
                 } else {
                     $this->view->form1->Edit->setName('update');
                     $this->view->form1->Edit->setLabel('update');
                     $this->view->form1->Edit->setAttrib('class', 'officesubmit');
                     //existing message
                     $messages = $officeType . ' (OR) ' . $officeCode . 'alreadyexisting';
                     $this->_redirect("officehierarchy?Existed=" . $messages);
                 }
             }
         } else {
             $messages = 'noProperData';
             $this->_redirect("officehierarchy?Existed=" . $messages);
         }
     }
 }
Esempio n. 11
0
 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @param  array $context
  * @return boolean
  * @throws \Zend_Validate_Exception If validation of $value is impossible
  */
 public function isValid($value, $context = array())
 {
     /**
      * Check for an adapter being defined. if not, fetch the default adapter.
      */
     if ($this->_adapter === null) {
         $this->_adapter = \Zend_Db_Table_Abstract::getDefaultAdapter();
         if (null === $this->_adapter) {
             require_once 'Zend/Validate/Exception.php';
             throw new \Zend_Validate_Exception('No database adapter present');
         }
     }
     if ($this->_postName && isset($context[$this->_postName])) {
         $context[$this->_postName] = $value;
     }
     $includes = array();
     if ($this->_checkFields) {
         foreach ($this->_checkFields as $dbField => $postVar) {
             if (isset($context[$postVar]) && strlen($context[$postVar])) {
                 $condition = $this->_adapter->quoteIdentifier($dbField) . ' = ?';
                 $includes[] = $this->_adapter->quoteInto($condition, $context[$postVar]);
             } else {
                 $includes[] = $this->_adapter->quoteIdentifier($dbField) . ' IS NULL';
             }
         }
     } else {
         // Quick check, only one _keyFields element
         if ($this->_keyFields && count($this->_keyFields) == 1) {
             $postVar = reset($this->_keyFields);
             $dbField = key($this->_keyFields);
             // _keyFields is the same as data field and value is set
             if ($dbField == $this->_field && isset($context[$postVar]) && strlen($context[$postVar])) {
                 // The if the content is identical, we known this check to return
                 // true. No need to check the database.
                 if ($value == $context[$postVar]) {
                     return true;
                 }
             }
         }
     }
     $excludes = array();
     if ($this->_keyFields) {
         foreach ($this->_keyFields as $dbField => $postVar) {
             if (isset($context[$postVar]) && strlen($context[$postVar])) {
                 $condition = $this->_adapter->quoteIdentifier($dbField) . ' = ?';
                 $excludes[] = $this->_adapter->quoteInto($condition, $context[$postVar]);
             } else {
                 // If one of the key values is empty, do not check for the combination
                 // (i.e. probably this is an insert, but in any case, no check).
                 $excludes = array();
                 break;
             }
         }
     }
     if ($includes || $excludes) {
         if ($includes) {
             $this->_exclude = implode(' AND ', $includes);
             if ($excludes) {
                 $this->_exclude .= ' AND ';
             }
         } else {
             // Clear cached query
             $this->_exclude = '';
         }
         if ($excludes) {
             $this->_exclude .= 'NOT (' . implode(' AND ', $excludes) . ')';
         }
     } else {
         $this->_exclude = null;
     }
     // Clear cached query
     $this->_select = null;
     // \MUtil_Echo::track($this->_exclude, $this->_checkFields, $this->_keyFields, $context, $_POST);
     return parent::isValid($value, $context);
 }
Esempio n. 12
0
 public function przypomnijhasloAction()
 {
     // action body
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $post = $this->_request->getPost();
         $return = array('email' => true);
         $ile_poprawnych = count($return);
         $zwroconych = 0;
         // email
         $empty = new Zend_Validate_NotEmpty();
         $isvalidEmail = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL);
         $emailIsNotExist = new Zend_Validate_Db_NoRecordExists(array('table' => 'ts_wydania_prenumerata_users_pl', 'field' => 'email', 'exclude' => '(czy_aktywne<>"Y") AND (email="' . $post['email'] . '")'));
         //$return['email'] = !$emailIsExist->isValid($post['email']);
         if (!$empty->isValid($post['email'])) {
             $return['email'] = 'null';
         } elseif (!$isvalidEmail->isValid($post['email'])) {
             $return['email'] = 'wrong';
         } elseif ($emailIsNotExist->isValid($post['email'])) {
             $return['email'] = 'unexist';
         } else {
             $zwroconych++;
         }
         /**/
         // finalizowanie
         if ($ile_poprawnych == $zwroconych) {
             try {
                 $salt = TS_Salt::getSalt3();
                 $User = new Application_Model_DbTable_UzytkownicyWww();
                 //$post["email"] = $User->getAdapter()->quote($post["email"]);
                 $dane = array('salt' => $salt);
                 $User->update($dane, array('email = ?' => $post["email"]));
                 //$request = Zend_Controller_Front::getInstance()->getRequest();
                 //$baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
                 $baseUrl = $this->view->serverUrl() . $this->view->baseUrl();
                 $mail = new TS_Mail();
                 $mail_dane = array('to' => $post['email'], 'subject' => 'Zmiana hasła', 'view' => array('script' => 'zmianahasla', 'params' => array('salt' => $baseUrl . '/user-przypomnijhaslopotwierdz.htm?salt=' . $salt)));
                 $mail->send($mail_dane);
             } catch (Exception $ex) {
                 die($ex->getMessage());
             }
         }
         /**/
         echo json_encode($return);
     } else {
         $this->view->podajmaila = new Application_Form_PodajMaila();
     }
 }
Esempio n. 13
0
 /**
  * Check uniqueness of one of the record's fields.
  * 
  * @uses Zend_Validate_Db_NoRecordExists
  * @param string $field
  * @param mixed $value Optional If null, this will check the value of the
  * record's $field.  Otherwise check the uniqueness of this value for the
  * given field.
  * @return boolean
  */
 protected function fieldIsUnique($field, $value = null)
 {
     $value = $value ? $value : $this->{$field};
     if ($value === null) {
         throw new Omeka_Record_Exception("Cannot check uniqueness of NULL value.");
     }
     $validatorOptions = array('table' => $this->getTable()->getTableName(), 'field' => $field, 'adapter' => $this->getDb()->getAdapter());
     // If this record already exists, exclude it from the validation
     if ($this->exists()) {
         $validatorOptions['exclude'] = array('field' => 'id', 'value' => $this->id);
     }
     $validator = new Zend_Validate_Db_NoRecordExists($validatorOptions);
     return $validator->isValid($value);
 }
Esempio n. 14
0
 public function disponibleLogin2($login)
 {
     $v = new Zend_Validate_Db_NoRecordExists(array('table' => $this->_name, 'field' => 'login'));
     return $v->isValid($login);
 }
Esempio n. 15
0
 /**
  * Validate
  * 
  * @param string $value
  */
 public function isValid($value)
 {
     // Установим значения
     $this->_setValue($value);
     list($this->_valueKey1, $this->_valueKey2) = explode('[;]', $value);
     $adapter = $this->_adapter;
     if ($this->_id) {
         $clause = $adapter->quoteInto($adapter->quoteIdentifier($this->_fieldKey2) . ' = ?', $this->_valueKey2) . ' AND ' . $adapter->quoteInto($adapter->quoteIdentifier('id') . ' <> ?', $this->_id);
     } else {
         $clause = $adapter->quoteInto($adapter->quoteIdentifier($this->_fieldKey2) . ' = ?', $this->_valueKey2);
     }
     $validator = new Zend_Validate_Db_NoRecordExists(array('table' => $this->_table, 'field' => $this->_fieldKey1, 'exclude' => $clause, 'adapter' => $adapter));
     if ($validator->isValid($this->_valueKey1)) {
         // Составной ключ не существует в таблице
         return true;
     } else {
         // Ошибка валидации (нарушение уникальности), в таблице уже есть такой составной ключ
         $messageKey = self::RECORD_EXISTS;
         $value = $this->_messageTemplates[$messageKey];
         $this->_error($messageKey);
         return false;
     }
 }
Esempio n. 16
0
 /**
  * Valida
  *
  * @param  string $nombre
  * @return boolean
  */
 public function valida($nombre)
 {
     $v = new Zend_Validate_Db_NoRecordExists(array('table' => 'categoria', 'field' => 'nombre'));
     return $v->isValid($nombre) ? "OK" : "ERROR";
 }
Esempio n. 17
0
	public function dataValidator($formData,$formType)
	{
		$errorMsg = null;
		$trigger = 0;
		//check length of password
		$length = strlen($formData['password']);
		if($length < 6 || $length > 12)
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_system_user_length."<br/>".$errorMsg;
		}
		//check password and password_repeat
		if($formData['password'] != $formData['password_repeat'])
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_system_user_password_differ."<br/>".$errorMsg;
			}
		//check if username has been taken
		$validator = new Zend_Validate_Db_NoRecordExists(
			array(
				'table' => 'sy_users',
				'field' => 'username'
			)
		);
		if (!$validator->isValid($formData['username']))
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_system_user_username_ocuppied."<br/>".$errorMsg;
		} 
		//check if contactId is occupied 
		$validator = new Zend_Validate_Db_NoRecordExists(
			array(
				'table' => 'sy_users',
				'field' => 'contactId'
			)
		);
		if (!$validator->isValid($formData['contactId']))
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_system_user_contactId_ocuppied."<br/>".$errorMsg;
		} 
		if($formData['contactId'] == null)
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_system_user_contact_notFound."<br/>".$errorMsg;
			}

		$array['trigger'] = $trigger;
		$array['errorMsg'] = $errorMsg;
		return $array;
	}
 /**
  * @param $value string
  * @param $table
  * @param $field string
  * @return bool
  */
 private function _validateColumn($value, $table, $field)
 {
     $validator = new Zend_Validate_Db_NoRecordExists(array('table' => $table, 'field' => $field));
     return $validator->isValid($value);
 }