public function getOwnerUser() { if (!is_null($this->getOwnerId())) { return UserPeer::retrieveByPk($this->getOwnerId()); } return null; }
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 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 getUserFullname() { $userid = $this->getUserId(); // Serves as an intermediary between the users and tbe databbase $user = UserPeer::retrieveByPk($userid); return $user->__toString(); }
public function executeDelete() { $user = UserPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($user); $user->delete(); return $this->redirect('user/list'); }
public function getSubscriber() { if ($this->isAuthenticated()) { return UserPeer::retrieveByPk($this->getSubscriberId()); } else { return null; } }
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); }
public function getProfile() { $user = UserPeer::retrieveByPk($this->getAttribute('profile', '', 'manager')); if ($user) { $user->setActivity(date('r')); $user->save(); } return $user; }
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')); }
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'); }
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'); }
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"); } }
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; }
/** * 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; }
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; } }
public function executeSendDeleteMessage(sfWebRequest $request) { $this->forward404Unless($this->user = UserPeer::retrieveByPk($request->getParameter('userId')), sprintf('Object user does not exist (%s).', $request->getParameter('userId'))); $this->forward404Unless($this->room = RoomPeer::retrieveByPk($request->getParameter('roomId')), sprintf('Object room does not exist (%s).', $request->getParameter('roomId'))); $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($this->getUser()->getAttribute('activityId')), sprintf('Object activity does not exist (%s).', $this->getUser()->getAttribute('activityId'))); $sender = $this->getUser()->getTemposUser(); $this->form = new MessageForm(); $this->form->setRecipient($this->user); $this->form->setSender($sender); }
public function getSubscriber() { return UserPeer::retrieveByPk($this->getSubscriberId()); }
public function executeKill(sfWebRequest $request) { $user = UserPeer::retrieveByPk($request->getParameter('username')); $arr = array(); if (!$user) { $arr["result"] = false; $arr["message"] = "Invalid username"; $this->renderText(json_encode($arr)); return sfView::NONE; } if (!$user->getCurrentGameId()) { $arr["result"] = false; $arr["message"] = "You are dead, you cannot kill."; $this->renderText(json_encode($arr)); return sfView::NONE; } TargetPeer::killTarget($user->getId()); $user->setKills($user->getKills() + 1); $user->save(); $arr["result"] = true; if (count(GameMemberPeer::getMemberIdsInGame($user->getCurrentGameId())) < 2) { GameMemberPeer::setMemberInactive($user->getId(), $user->getCurrentGameId()); $user->setWins($user->getWins() + 1); $user->setCurrentGameId(null); $user->save(); $arr["message"] = "You have won! Game is over!"; $arr["win"] = true; } else { $arr["message"] = "Target Killed, new one will be assigned soon!"; $arr["win"] = false; } $this->renderText(json_encode($arr)); return sfView::NONE; }
protected function handleZoneParameters(sfWebRequest $request) { if ($request->hasParameter('self')) { $this->getUser()->getAttributeHolder()->remove('userId'); $this->getUser()->getAttributeHolder()->remove('usergroupId'); } $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($request->getParameter('activityId')), sprintf('Object activity does not exist (%s).', $request->getParameter('activityId'))); if ($this->getUser()->hasAttribute('userId')) { $this->forward404Unless($this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId')), sprintf('Object usergroup does not exist (%s).', $this->getUser()->getAttribute('usergroupId'))); $this->forward404Unless($this->usergroup->hasActivity($this->activity->getId()), sprintf('User group does not have this entry (\'%s\')', $this->activity->getName())); $this->forward404Unless($this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId')), sprintf('Object user does not exist (%s).', $this->getUser()->getAttribute('userId'))); $this->forward404Unless($this->user->isMember($this->usergroup), 'The user is not member of the specified usergroup.'); $this->forward404Unless($this->getUser()->getTemposUser()->isLeader($this->usergroup), 'The logged user is not leader of the specified usergroup.'); $this->person = $this->user; } else { $this->forward404Unless($this->person = $this->getUser()->getPerson(), 'No user or card logged-in.'); } $this->forward404Unless($this->person->hasActivity($this->activity->getId()), sprintf('Cannot access entry ("%s").', $this->activity)); $this->getUser()->setAttribute('activityId', $this->activity->getId()); }
public function executeConfirm(sfWebRequest $request) { $this->user = UserPeer::retrieveByPk($request->getParameter('id')); }
if (count($expert_cats) >= 1) { $_SESSION['temp1'] = array(); $i = 0; $j = 0; $k = 0; $_l = 1; $_h = 1; $_Tutor = array(); $_NonTutor = array(); if (empty($_COOKIE["onoff"])) { $_all_users = $newOnlineUser; } else { $_all_users = $expert_cats; } foreach ($_all_users as $key => $user) { $_user = UserPeer::retrieveByPk($user['userid']); if ($_user->getType() == 5) { $_Tutor[$_l] = array("score" => $user['score'], "userid" => $user['userid'], "category" => $user['category']); $_l++; } else { $_NonTutor[$_h] = array("score" => $user['score'], "userid" => $user['userid'], "category" => $user['category']); $_h++; } } asort($_Tutor); arsort($_Tutor); asort($_NonTutor); arsort($_NonTutor); $_dv = 1; $_vd = 1; foreach ($_NonTutor as $key => $user) {
<?php $user = UserPeer::retrieveByPk($object['ID']); include_partial('userBlock', array('user' => $user, 'ajaxAdd' => true));
public function executeUpdateAccount() { $user = UserPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($user); $user->setId($this->getRequestParameter('id')); $user->setLogin($this->getRequestParameter('login')); if ($this->getRequestParameter('password')) { $user->setPassword($this->getRequestParameter('password')); } $user->save(); $this->getContext()->getUser()->signIn($user); #$this->setTemplate('index'); return $this->redirect('default/index'); #return; }