本文整理汇总了PHP中UserPeer::retrieveByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP UserPeer::retrieveByPk方法的具体用法?PHP UserPeer::retrieveByPk怎么用?PHP UserPeer::retrieveByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPeer
的用法示例。
在下文中一共展示了UserPeer::retrieveByPk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOwnerUser
public function getOwnerUser()
{
if (!is_null($this->getOwnerId())) {
return UserPeer::retrieveByPk($this->getOwnerId());
}
return null;
}
示例2: executeDelete
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');
}
示例3: executeChangepassword
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');
}
}
示例4: getUserFullname
public function getUserFullname()
{
$userid = $this->getUserId();
// Serves as an intermediary between the users and tbe databbase
$user = UserPeer::retrieveByPk($userid);
return $user->__toString();
}
示例5: executeDelete
public function executeDelete()
{
$user = UserPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($user);
$user->delete();
return $this->redirect('user/list');
}
示例6: getSubscriber
public function getSubscriber()
{
if ($this->isAuthenticated()) {
return UserPeer::retrieveByPk($this->getSubscriberId());
} else {
return null;
}
}
示例7: executeListExtend
public function executeListExtend(sfWebRequest $request)
{
$id = $request->getParameter('id');
$user = UserPeer::retrieveByPk($id);
$user->displayExtendExpiresAt();
$this->getUser()->setFlash('notice', 'Account expriry time has been extended successfully.');
$this->redirect('user/ListShow?id=' . $id);
}
示例8: getProfile
public function getProfile()
{
$user = UserPeer::retrieveByPk($this->getAttribute('profile', '', 'manager'));
if ($user) {
$user->setActivity(date('r'));
$user->save();
}
return $user;
}
示例9: executeNavigation
public function executeNavigation()
{
$this->person = $this->getUser()->getPerson();
$activityId = $this->getUser()->getAttribute('activityId');
if ($this->getUser()->hasActivity($activityId)) {
$this->activity = ActivityPeer::retrieveByPk($activityId);
} else {
$this->activity = null;
}
$this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId'));
$this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId'));
}
示例10: executeDelete
public function executeDelete(sfWebRequest $request)
{
$user = UserPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('id')));
if ($user) {
$user->setStatus(Constant::RECORD_STATUS_DELETED);
if ($user->save()) {
$this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_STATUS_DELETED_SUCCESSFULLY);
} else {
$this->getUser()->setFlash('ERROR_MESSAGE', Constant::DB_ERROR);
}
} else {
$this->getUser()->setFlash('ERROR_MESSAGE', Constant::INVALID_REQUEST);
}
$this->redirect('User/list');
}
示例11: executeCreate
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post'));
if ($request->hasParameter('userId')) {
$this->forward404Unless($this->user = UserPeer::retrieveByPk($request->getParameter('userId')), sprintf('Object user does not exist (%s).', $request->getParameter('userId')));
$this->form = new SubscriptionForm();
$this->processForm($request, $this->form);
$this->form->setDefaultUser($this->user);
} elseif ($request->hasParameter('cardId')) {
$this->forward404Unless($this->card = CardPeer::retrieveByPk($request->getParameter('cardId')), sprintf('Object card does not exist (%s).', $request->getParameter('cardId')));
$this->form = new SubscriptionForm();
$this->processForm($request, $this->form);
$this->form->setDefaultCard($this->card);
} else {
$this->forward404('No user or card specified.');
}
$this->setTemplate('new');
}
示例12: executeDelete
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')));
try {
$user->delete();
$par = "";
if ($request->hasParameter("page")) {
$par = "?page=" . $request->getParameter("page");
}
$this->redirect('adminuser/index' . $par);
} catch (Exception $e) {
$this->globalErrors = $e->getMessage();
$this->user_list = $this->getUserList();
$values = array('edit' => 'true');
$this->form = new UserForm($user, $values);
$this->setTemplate("index");
}
}
示例13: 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');
}
$id = $values['id'];
$user = UserPeer::retrieveByPk($id);
if (!is_null($id) && !is_null($user)) {
$password = $values[$this->getOption('password_field')];
if (!empty($password) && !$user->checkPassword($password)) {
$error = new sfValidatorError($this, 'invalid', array());
if ($this->getOption('throw_global_error')) {
throw $error;
}
throw new sfValidatorErrorSchema($this, array($this->getOption('password_field') => $error));
}
}
return $values;
}
示例14: getUser
/**
* Get the associated User object
*
* @param PropelPDO Optional Connection object.
* @return User The associated User object.
* @throws PropelException
*/
public function getUser(PropelPDO $con = null)
{
if ($this->aUser === null && $this->user_id !== null) {
$this->aUser = UserPeer::retrieveByPk($this->user_id);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aUser->addComments($this);
*/
}
return $this->aUser;
}
示例15: ChangePassword
public static function ChangePassword($old_password, $new_password)
{
//get User ID from session and get user object
$user_id = sfContext::getInstance()->getUser()->getAttribute('USER_ID');
$user = UserPeer::retrieveByPk($user_id);
//Get post data
//if old password is correct then set new one
if (strcmp($user->getPassword(), self::EncryptPassword($old_password)) == 0) {
$new_password = self::EncryptPassword($new_password);
$user->setPassword($new_password);
//Save password
if ($user->save()) {
return Constant::LOGIN_PASSWORD_CHANGED_SUCCESS;
} else {
return Constant::DB_ERROR;
}
} else {
return Constant::LOGIN_INVALID_OLD_PASSWORD;
}
}