Example #1
0
 private function _terms_summary_validate()
 {
     $validatorChain = new RM_Validate('Terms');
     $result = $validatorChain->addValidator(new Zend_Validate_NotEmpty())->isValid($this->_request->getParam('terms', null));
     if (!$result) {
         $this->_errors = array_merge($this->_errors, $validatorChain->getErrors());
     }
     return $result;
 }
Example #2
0
 /**
  * @param Zend_Request_Interface $request
  * @return bool
  */
 private function _validateDates($request)
 {
     $values = $request->getParam('search');
     $start = $values['start_datetime'];
     $end = $values['end_datetime'];
     if ($start !== null && $end !== null && strtotime($start) > strtotime($end)) {
         $this->_errors[] = 'StartDateShouldBeBeforeEndDate';
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Username should be non empty and alpha numeric
  *
  * @return bool
  */
 private function _username_user_validate()
 {
     $validatorChain = new RM_Validate('Username');
     $result = $validatorChain->addValidator(new Zend_Validate_Alnum())->isValid($this->_request->getParam('username', null));
     if (!$result) {
         $this->_errors = array_merge($this->_errors, $validatorChain->getErrors());
     }
     return $result;
 }
Example #4
0
 function _validateUnit()
 {
     $unitModel = new RM_Units();
     $unit = $unitModel->find($this->_request->getParam('unit_id', null))->current();
     if ($unit == null) {
         $this->_errors[] = 'SelectedUnitDoesNotExists';
         return false;
     }
     return true;
 }
Example #5
0
 /**
  * Create and return new user row from information from reguest.
  * This method is not saving row objcet into database.
  *
  * @param Zend_Request_Interface $request
  * @param int $groupID [optional] default RM_UserGroups::REGULAR
  * @param bool $resmania - if true force system to create resmania user instead of cms user
  */
 function createNewUser($request, $groupID = RM_UserGroups::REGULAR, $resmania = false)
 {
     $fields = $this->_getFieldsByGroup($groupID);
     $notRequestFields = array('group_id', 'cms_id');
     $data = array();
     $data['group_id'] = $groupID;
     foreach ($fields as $field) {
         if ($field->view_new == '1' && in_array($field->column_name, $notRequestFields) === false) {
             $data[$field->column_name] = $request->getParam($field->column_name);
         }
     }
     $config = new RM_Config();
     if ($config->getValue('rm_config_enable_cms_user_creation') && $resmania == false) {
         $connectorObj =& RM_Environment::getConnector();
         $users = $connectorObj->getUsersModel();
         $userInfo = $users->createRow($data);
     } else {
         $userInfo = $this->createRow($data);
     }
     return $userInfo;
 }
Example #6
0
 /**
  * IMPORTANT side effect. This method will automatically authenticate using to CMS if
  * enable_cms_integration is on in config.
  *
  * @param Zend_Request_Interface $request
  * @return bool
  */
 function validate($request)
 {
     $result = true;
     //We check username for alphanumeric
     $username = $request->getParam('username', null);
     $validatorChain = new RM_Validate('Username');
     $usernameResult = $validatorChain->addValidator(new Zend_Validate_Alnum())->isValid($username);
     if (!$usernameResult) {
         $this->_errors = $validatorChain->getErrors();
         $result = false;
     }
     //We check password for alphanumeric
     $password = $request->getParam('password', null);
     $validatorChain = new RM_Validate('Password');
     $passwordResult = $validatorChain->addValidator(new Zend_Validate_Alnum())->isValid($password);
     if (!$passwordResult) {
         $this->_errors = array_merge($this->_errors, $validatorChain->getErrors());
         $result = false;
     }
     $config = new RM_Config();
     $isCmsAuthentication = $config->getValue('rm_config_enable_cms_integration');
     if ($isCmsAuthentication) {
         $authenticationResult = RM_Environment::getConnector()->authenticate($request->getParam('username'), $request->getParam('password'));
         if ($authenticationResult !== true) {
             if (is_object($authenticationResult)) {
                 $this->_errors[] = $authenticationResult->getMessage();
             } else {
                 $this->_errors[] = 'UserNotFound';
             }
             $result = false;
         }
     } else {
         $userModel = new RM_Users();
         $user = $userModel->getBy($request->getParam('username'));
         if ($user === null) {
             $this->_errors[] = 'UserNotFound';
             $result = false;
         }
         //Finally we tries to find existing user in database with the same username/password
         $userModel = new RM_Users();
         $user = $userModel->getBy($request->getParam('username'), $request->getParam('password'));
         if ($user === null) {
             $this->_errors[] = 'WrongPassword';
             $result = false;
         }
     }
     return $result;
 }