本文整理汇总了PHP中UserPeer类的典型用法代码示例。如果您正苦于以下问题:PHP UserPeer类的具体用法?PHP UserPeer怎么用?PHP UserPeer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserPeer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeIndex
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
}
示例2: execute
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;
}
示例3: getAllInterestedUsers
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);
}
示例4: execute
/**
* 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;
}
示例5: executeChangepassword
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');
}
}
}
示例6: executeLogin
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);
}
}
}
}
示例7: getNonMembers
public function getNonMembers($c = null)
{
$c = UserPeer::getNonUsergroupCriteria($this->getId(), $c);
$c->addAscendingOrderByColumn(UserPeer::FAMILY_NAME);
$c->addAscendingOrderByColumn(UserPeer::SURNAME);
return UserPeer::doSelect($c);
}
示例8: getOwnerUser
public function getOwnerUser()
{
if (!is_null($this->getOwnerId())) {
return UserPeer::retrieveByPk($this->getOwnerId());
}
return null;
}
示例9: doClean
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;
}
示例10: getUserFullname
public function getUserFullname()
{
$userid = $this->getUserId();
// Serves as an intermediary between the users and tbe databbase
$user = UserPeer::retrieveByPk($userid);
return $user->__toString();
}
示例11: execute
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;
}
示例12: executeSubscription
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;
}
示例13: validateLogin
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();
}
}
}
示例14: executeIndex
/**
* 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;
}
示例15: getInviterDetails
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);
}
}