public function validate($messageManager) { $field = $this->form->getField($this->fieldName); $fieldValue = $field->getValue(); $userDAO = new UserDAO(); $userRecord = $userDAO->getRecordById($this->userId); if ($userRecord['userPassword'] != $fieldValue) { $messageManager->addMessage('invalidPassword', array($this->fieldName => $field->getCaption())); } }
public function validate($messageManager) { $userId = $this->form->getField('userId')->getValue(); if (!empty($userId)) { $userDAO = new UserDAO(); $user = $userDAO->getRecordById($userId); if (empty($user['id'])) { $messageManager->addMessage('errorInvalidUserId'); } if ($user['userState'] != 'active') { $messageManager->addMessage('errorUserInactive'); } } }
protected function changeUserCredits(&$user, $change, $newPackageId = null) { $user = $this->userDAO->getRecordById($user['id']); // nie chcemy nulla... if (empty($user['userCredits'])) { $user['userCredits'] = 0; } $userOld = $user; // kopia, nie referencja $package = $this->creditsPackageDAO->getLastActiveCreditsPackage($user['id'], $newPackageId); if (empty($package['id'])) { $user['userCredits'] = 0; } if ($user['userCredits'] + $change < 0) { if ($userOld != $user) { $this->userDAO->save($user); } return false; } $user['userCredits'] = $user['userCredits'] + $change; $this->userDAO->save($user); return true; }