public function executeIndex(sfWebRequest $request) { if ($this->getRequest()->getMethod() == sfRequest::POST) { $username = $request->getParameter('username'); $password = $request->getParameter('password'); $password = Login::EncryptPassword($password); // Get Record From Database $c = new Criteria(); $c->add(UserPeer::USER, $username); $c->add(UserPeer::PASSWORD, $password); $user = UserPeer::doSelectOne($c); //Set Global Attributes if ($user) { //$this->getUser ()->setFlash ( 'SUCCESS_MESSAGE', Constant::LOGIN_OK ); sfContext::getInstance()->getUser()->setAttribute('USER_ID', $user->getId()); sfContext::getInstance()->getUser()->setAttribute('USERNAME', $user->getUser()); sfContext::getInstance()->getUser()->setAttribute('NAME', $user->getEmployee()->getName()); sfContext::getInstance()->getUser()->setAttribute('ROLE', $user->getRole()); sfContext::getInstance()->getUser()->setAttribute('LOGGED_IN', true); sfContext::getInstance()->getUser()->setAuthenticated(true); $this->redirect('Home/index'); } else { $this->getUser()->setFlash('ERROR_MESSAGE', Constant::LOGIN_INVALID_USER_EMAIL_PASSWORD); sfContext::getInstance()->getUser()->setAuthenticated(false); } } // end if }
public function execute(&$value, &$error) { $c = new Criteria(); $c->add(UserPeer::EMAIL, $value); $users = UserPeer::doSelect($c); // if it's unique if (0 === count($users)) { return true; } else { if (count($users) > 1) { $error = $this->getParameter('unique_error'); return false; } else { $user = array_pop($users); /* @var $user User */ $loggedInUser = sfContext::getInstance()->getUser()->getRaykuUser(); if ($loggedInUser instanceof User) { // if the logged in user matches the found user, then it's allowed to be the same email address if ($loggedInUser->equals($user)) { return true; } else { $error = $this->getParameter('unique_error'); return false; } } else { // we're not logged in, so die throw new sfValidatorException('you need to be logged in to validate your email address'); } } } $error = $this->getParameter('unique_error'); return false; }
public function getAllInterestedUsers() { $c = new Criteria(); $c->addJoin(UserPeer::ID, InterestPeer::USER_ID, Criteria::LEFT_JOIN); $c->add(InterestPeer::QUESTION_ID, $this->getId()); return UserPeer::doSelect($c); }
/** * Execute this validator. * * @param mixed A file or parameter value/array. * @param error An error message reference. * * @return bool true, if this validator executes successfully, otherwise * false. */ public function execute(&$value, &$error) { $actionName = $this->getContext()->getActionStack()->getFirstEntry()->getActionName(); if (isset($actionName) and 'add' == $actionName) { $addError = $this->getContext()->getRequest()->getError('nickname'); if (isset($addError)) { $error = $addError; return false; } //see if there are other errors if (count($this->getContext()->getRequest()->getErrorNames())) { $error = null; return false; } } $password_param = $this->getParameterHolder()->get('password'); $password = $this->getContext()->getRequest()->getParameter($password_param); $login = $value; // anonymous is not a real user if ($login == 'anonymous') { $error = $this->getParameterHolder()->get('login_error'); return false; } if ($user = UserPeer::getAuthenticatedUser($login, $password)) { $this->getContext()->getUser()->signIn($user); return true; } $error = $this->getParameterHolder()->get('login_error'); return false; }
public function executeChangepassword() { $oldpass = $this->getRequestParameter('oldpassword'); $newpass = $this->getRequestParameter('newpassword'); if ($oldpass) { $user = UserPeer::retrieveByPK($this->getUser()->getAttribute('userid')); $salt = md5(sfConfig::get('app_salt_password')); if (sha1($salt . $oldpass) == $user->getPassword()) { $user->setPassword($newpass); $user->save(); $this->setFlash('changepassword', 'Password changed successfully.'); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $personal = PersonalPeer::doSelectOne($c); $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname(); $sendermail = sfConfig::get('app_from_mail'); $sendername = sfConfig::get('app_from_name'); $to = $personal->getEmail(); $subject = "Password change request for ITBHU Global Org"; $body = ' Dear ' . $name . ', Someone, probably you have changed the password. If its not you, please contact admin as soon as practical. Admin, ITBHU Global '; $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body); } else { $this->setFlash('changepasswordErr', 'Incorrect Old Password'); } } }
public function executeLogin(sfWebRequest $request) { if (helperFunctions::isLoggedIn($request)) { $this->redirect("siteadmin/index"); } if ($request->isMethod(sfRequest::POST) && $request->hasParameter('username') && $request->hasParameter('password')) { $username = $request->getParameter("username"); $password = $request->getParameter("password"); if (helperFunctions::isMaliciousString($username) || helperFunctions::isMaliciousString($password)) { $this->error = "* Malicious keywords detected. Do not attempt this again!"; } else { $conn = Propel::getConnection(); $admin = UserPeer::retrieveByPK($username, $conn); if (!is_object($admin) || $admin->getPassword() != $password) { $this->error = "* Incorrect credentials."; } elseif ($admin->getTypeId() != EnumItemPeer::USER_ADMIN) { $this->error = "* You do not have enough clearance to access this section."; } else { $this->getResponse()->setCookie('username', $username); // redirect to whatever page the user came from if ($request->hasParameter("redirect")) { $redirect = $request->getParameter("redirect"); } else { $redirect = "siteadmin/index"; } $this->redirect($redirect); } } } }
public function getNonMembers($c = null) { $c = UserPeer::getNonUsergroupCriteria($this->getId(), $c); $c->addAscendingOrderByColumn(UserPeer::FAMILY_NAME); $c->addAscendingOrderByColumn(UserPeer::SURNAME); return UserPeer::doSelect($c); }
public function getOwnerUser() { if (!is_null($this->getOwnerId())) { return UserPeer::retrieveByPk($this->getOwnerId()); } return null; }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $duration = $values['duration']; if (is_null($duration)) { return $values; } $date = $values['date']; if (is_null($date)) { return $values; } $date = strtotime($date); $activity = ActivityPeer::retrieveByPK($values['Activity_id']); $roomId = isset($values['Room_id']) ? $values['Room_id'] : null; $reservation_id = isset($values['id']) ? $values['id'] : null; if (!is_null($activity)) { if (!is_null($values['User_id'])) { $user = UserPeer::retrieveByPK($values['User_id']); $subscriptions = $user->getActiveSubscriptions($date, $activity->getId(), $roomId); } else { if (!is_null($values['Card_id'])) { $card = CardPeer::retrieveByPK($values['Card_id']); $subscriptions = $card->getActiveSubscriptions($date, $activity->getId(), $roomId); } else { /* Trick to enforce potential new login objects (Like User or Card) to update this function */ /* This way, the validator will always throw. */ $subscriptions = null; } } $valid = false; $maxAvailableDuration = 0; if (!empty($subscriptions)) { foreach ($subscriptions as $subscription) { $remainingCredit = $subscription->getRemainingCredit($duration, $reservation_id); if ($remainingCredit >= 0) { $valid = true; break; } else { if ($maxAvailableDuration < abs($remainingCredit)) { /* We keep the maximum duration number for the reservation */ $maxAvailableDuration = abs($remainingCredit); } } } } if (!$valid) { $error = new sfValidatorError($this, 'invalid', array('remaining_credit' => $maxAvailableDuration)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } } return $values; }
public function getUserFullname() { $userid = $this->getUserId(); // Serves as an intermediary between the users and tbe databbase $user = UserPeer::retrieveByPk($userid); return $user->__toString(); }
public function execute(&$value, &$error) { $id = $this->getContext()->getRequest()->getParameter('id'); $name = $value; $c = new Criteria(); $c->add(UserPeer::USERNAME, $name); $user = UserPeer::doSelectOne($c); $condition = true; if ($user) { if ($id && $id == $user->getId()) { $condition = true; } else { $error = 'User ' . $user->getUsername() . ' already Exist.'; $condition = false; } } $roles = RolePeer::doSelect(new Criteria()); $found = false; foreach ($roles as $role) { if ($this->getContext()->getRequest()->getParameter($role->getName(), 0) == 1) { $found = true; } } if (!$found) { $error = 'Please select atleast one role'; $condition = false; } return $condition; }
public function executeSubscription(sfWebRequest $request) { $params = $request->getParameter('email'); $form = new SubscriptionForm(); if ($request->isMethod('post')) { $email = $params; try { if (empty($obj)) { $obj = new Subscription(); $obj->setEmail($email)->save(); } } catch (Exception $e) { } $contacts = UserPeer::getAllContact(); $backEmail = $contacts->getEmail(); $message = "E-mail: " . $email . "<br/>"; // почта, на которую придет письмо $mail_to = $backEmail; // тема письма $subject = "Новый подписчик"; // заголовок письма $headers = "Content-type: text/html; charset=utf-8\r\n"; // кодировка письма // отправляем письмо mail($mail_to, $subject, $message, $headers); } $this->form = $form; }
public function validateLogin() { $result = false; if ($login = $this->getRequestParameter('login')) { $password = $this->getRequestParameter('password'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); if ($user) { if ($user->getPublicationStatus() != "ACTIVE") { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Not-active", $culture), UtilsHelper::MSG_INFO); } elseif (sha1($user->getSalt() . $password) == $user->getSha1Password()) { $this->getUser()->setAttribute('pass', $password); $this->getUser()->signIn($user); // redirect to dashboard $this->showDashboard(); $result = true; } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { if ($this->getUser()->isAuthenticated()) { // redirect to dashboard $this->showDashboard(); } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $params = $request->getParameter('phone'); $form = new CallbackForm(); if ($request->isMethod('post')) { $phone = $params; try { if (empty($obj)) { $obj = new Callback(); $obj->setPhone($phone)->save(); } } catch (Exception $e) { } $contacts = UserPeer::getAllContact(); $backEmail = $contacts->getEmail(); $message = "Телефон: " . $phone . "<br/>"; // почта, на которую придет письмо $mail_to = $backEmail; // тема письма $subject = "Заказ звонка"; // заголовок письма $headers = "Content-type: text/html; charset=utf-8\r\n"; // кодировка письма // отправляем письмо mail($mail_to, $subject, $message, $headers); } $this->form = $form; }
public function getInviterDetails($member_id, $chatroom_id) { if ($this->checkInvited($member_id, $chatroom_id) == 'true') { $inviter_id = InviteMember::getInviterId($member_id, $chatroom_id); return UserPeer::getMemberDetailsFromId($inviter_id); } }
public function executeLogin(sfWebRequest $request) { if ($this->getUser()->isAuthenticated()) { $this->redirect('default/index'); } if ($request->isMethod('post')) { $login = $request->getParameter('login'); $psw = $request->getParameter('psw'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $c->add(UserPeer::PSW, $psw); $user = UserPeer::doSelectOne($c); if (false == empty($user)) { $this->getUser()->setAuthenticated(true); $this->getUser()->addCredentials($user->getStatus()); $this->getUser()->setCulture('ru_UA'); $this->getUser()->setAttribute('user', $user); if (!empty($remember)) { $data = array('login' => $user->getLogin(), 'email' => $user->getEmail(), 'psw' => $user->getPsw(), 'status' => $user->getStatus()); $values = base64_encode(serialize($data)); $this->getResponse()->setCookie('user', $values, time() + 2592000); $this->redirect('default/index'); } else { $this->redirect('default/index'); } } } }
static function getUserByLoginAndPassowrd($login, $psw) { $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $c->add(UserPeer::PSW, $psw); return UserPeer::doSelectOne($c); }
public function execute(&$value, &$error) { $password_param = $this->getParameter('password'); sfContext::getInstance()->getLogger()->info("{myLoginValidator} password_param {$password_param}"); $password = $this->getContext()->getRequest()->getParameter($password_param); $login = $value; sfContext::getInstance()->getLogger()->info("{myLoginValidator} validate login:{$value}, password: {$password}"); // anonymous is not a real user if ($login == 'anonymous') { $error = $this->getParameter('login_error'); return false; } $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); // nickname exists? if ($user) { // password is OK? if ($password == $user->getPassword()) { $this->getContext()->getUser()->setAuthenticated(true); return true; } } $error = $this->getParameter('login_error'); return false; }
public function login($sUsername, $sPassword) { $oUser = UserQuery::create()->filterByUsername($sUsername)->findOne(); if ($oUser === null) { $oUser = UserQuery::create()->filterByEmail($sUsername)->find(); if (count($oUser) === 1) { $oUser = $oUser[0]; } else { return 0; } } if (!PasswordHash::comparePassword($sPassword, $oUser->getPassword())) { if (PasswordHash::comparePasswordFallback($sPassword, $oUser->getPassword())) { $oUser->setPassword($sPassword); UserPeer::ignoreRights(true); $oUser->save(); return $this->login($sUsername, $sPassword); } if ($oUser->getPassword() === '*') { return self::USER_NEEDS_PASSWORD_RESET; } return 0; } if ($oUser->getDigestHA1() === null && Settings::getSetting('security', 'generate_digest_secrets', false) === true) { $oUser->setPassword($sPassword); UserPeer::ignoreRights(true); $oUser->save(); } return $this->loginUser($oUser); }
public function executeChangepassword(sfWebRequest $request) { $this->form = new ChangePasswordForm(); $this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('user_id')); if ($request->isMethod('post')) { // if the form is submitted $this->form->bind($request->getParameter('changepassword')); if ($this->form->isValid()) { $pass_parameters = $request->getParameter('changepassword'); $password = new Password($pass_parameters['new_password']); $current_password = new Password($pass_parameters['password']); if ($this->user->checkPassword($current_password)) { $this->user->setPassword($password); $this->getUser()->setFlash('notice', "You have changed your password successfully"); } else { $this->getUser()->setFlash('notice', "Please type your existing password correctly"); $this->redirect('user/changepassword'); } $this->redirect('user/show?id=' . $this->user->getId()); } } else { // not a post, just a get // $this->setTemplate('changepassword'); } }
public function executeDelete(sfWebRequest $request) { $request->checkCSRFProtection(); $this->forward404Unless($user = UserPeer::retrieveByPk($request->getParameter('id')), sprintf('Object user does not exist (%s).', $request->getParameter('id'))); $user->delete(); $this->redirect('user/index'); }
public function executeHeader() { $this->modname = $this->getContext()->getModuleName(); $this->actname = $this->getContext()->getActionName(); $this->fullaction = $this->modname . "*" . $this->actname; if ($this->fullaction === "user*lorform" || $this->fullaction === "user*composemail") { $this->modname = 'search'; } if ($this->getUser()->hasCredential('masterauth')) { $c = new Criteria(); $c->add(UserPeer::AUTHCODE, sfConfig::get('app_authcode_masterauth')); $c->add(UserPeer::ISLOCKED, '2'); $this->claimed = UserPeer::doCount($c); } else { $c = new Criteria(); $c->add(UserPeer::ISLOCKED, '2'); $this->claimed = UserPeer::doCount($c); } if ($this->getUser()->hasCredential('masterauth')) { $c = new Criteria(); $c->add(UserPeer::AUTHCODE, sfConfig::get('app_authcode_masterauth')); $c->add(UserPeer::ISLOCKED, '3'); $this->newreg = UserPeer::doCount($c); } else { $c = new Criteria(); $c->add(UserPeer::ISLOCKED, '3'); $this->newreg = UserPeer::doCount($c); } }
public function executeRaykupoints() { $this->amount = $this->getRequestParameter('amount'); $this->currentpoints = $this->getRequestParameter('raykupoints'); $expert_id = $this->getUSer()->getRaykuUserId(); $c = new Criteria(); $c->add(UserPeer::ID, $this->getUser()->getRaykuUserId()); $user = UserPeer::doSelectOne($c); $points = $user->getPoints() + $this->currentpoints; $user->setPoints($points); $user->save(); $expertsdebit = new ExpertsDebitDetails(); $expertsdebit->setExpertId($expert_id); $expertsdebit->setAmount($this->amount); $expertsdebit->setTime(date('Y-m-d H:i:s')); $expertsdebit->save(); $c = new Criteria(); $c->add(ExpertsFinalCreditPeer::EXPERT_ID, $expert_id); $current = ExpertsFinalCreditPeer::doSelectOne($c); if ($current != NULL) { $finalamount = $current->getAmount() - $this->amount; $current->setAmount($finalamount); $current->save(); } }
public function execute($filterChain) { // execute this filter only once if ($this->isFirstCall()) { $user = sfContext::getInstance()->getUser(); if (!$user->isAuthenticated()) { $cookie = $this->getContext()->getRequest()->getCookie('rayku'); if ($cookie) { $value = unserialize(base64_decode($cookie)); $c = new Criteria(); $c->add(UserPeer::COOKIE_KEY, $value[0]); $c->add(UserPeer::USERNAME, $value[1]); $raykuUser = UserPeer::doSelectOne($c); if ($raykuUser instanceof User) { // sign in StatsD::increment("login.remember_me_success"); $user->signIn($raykuUser); } else { StatsD::increment("login.remember_me_failure"); } } } } // Execute next filter $filterChain->execute(); }
public function executeAjaxGivePoints() { $c = new Criteria(); $c->add(UserPeer::USERNAME, $this->getRequestParameter('username')); $user = UserPeer::doSelectOne($c); $user->sendPointsFromAdmin($this->getRequestParameter('points')); }
public function executePasswordRequest() { if ($this->getRequest()->getMethod() != sfRequest::POST) { // display the form return sfView::SUCCESS; } // handle the form submission $c = new Criteria(); $c->add(UserPeer::EMAIL, $this->getRequestParameter('email')); $user = UserPeer::doSelectOne($c); // email exists? if ($user) { // set new random password $password = substr(md5(rand(100000, 999999)), 0, 6); $user->setPassword($password); $this->getRequest()->setAttribute('password', $password); $this->getRequest()->setAttribute('nickname', $user->getNickname()); $raw_email = $this->sendEmail('mail', 'sendPassword'); //$this->getLogger()->debug($raw_email); // save new password $user->save(); return 'MailSent'; } else { $this->getRequest()->setError('email', 'There is no Registry user with this email address. Please try again'); return sfView::SUCCESS; } }
private function toggleAdministrator($administrator) { $user = UserPeer::getUserFromNickname($this->getRequestParameter('nickname')); $this->forward404Unless($user); $user->setIsAdministrator($administrator); $user->save(); $this->redirect($this->getRequest()->getReferer()); }
/** * Get value of a int key ENUM * @param int $v * @throws PropelException - if the key is not accepted by this enum * @return string */ public static function getAnsweredValue($v) { $valueSet = UserPeer::getValueSet(UserPeer::ANSWERED); if (!isset($valueSet[$v])) { throw new PropelException('Unknown stored enum key: ' . $v); } return $valueSet[$v]; }
public function getUserCount() { // select count(*) from user where domainname_id = $this->getId() $criteria = new Criteria(); $criteria->add(UserPeer::DOMAINNAME_ID, $this->getId()); // do the counting on the user model return UserPeer::doCount($criteria); }
public function executeShow() { $this->subscriber = UserPeer::retrieveByNickname($this->getRequestParameter('nickname')); $this->forward404Unless($this->subscriber); $this->interests = $this->subscriber->getInterestsJoinQuestion(); $this->answers = $this->subscriber->getAnswersJoinQuestion(); $this->questions = $this->subscriber->getQuestions(); }