本文整理汇总了PHP中UserPeer::retrieveByPK方法的典型用法代码示例。如果您正苦于以下问题:PHP UserPeer::retrieveByPK方法的具体用法?PHP UserPeer::retrieveByPK怎么用?PHP UserPeer::retrieveByPK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPeer
的用法示例。
在下文中一共展示了UserPeer::retrieveByPK方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeShow
public function executeShow()
{
$userid = $this->getUser()->getAttribute('userid');
$user = UserPeer::retrieveByPK($userid);
$c = new Criteria();
$c->add(AddressPeer::USER_ID, $user->getId());
$c->add(AddressPeer::TYPE, 0);
$this->addressh = AddressPeer::doSelectOne($c);
$c->clear();
$c->add(AddressPeer::USER_ID, $user->getId());
$c->add(AddressPeer::TYPE, 1);
$this->addressw = AddressPeer::doSelectOne($c);
$c->clear();
$c->add(AddressPeer::USER_ID, $user->getId());
$c->add(AddressPeer::TYPE, 2);
$this->addressp = AddressPeer::doSelectOne($c);
$this->userid = $userid;
//$this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id'));
//$this->forward404Unless($this->address);
$c->clear();
$c->add(UserchapterregionPeer::USER_ID, $userid);
$this->ucrs = UserchapterregionPeer::doSelect($c);
$regions = RegionPeer::doSelect(new Criteria());
$regionlist = array();
$regionlist[] = "Select a Region";
foreach ($regions as $region) {
$regionlist[$region->getId()] = $region->getName();
}
$this->regionlist = $regionlist;
}
示例2: 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);
}
}
}
}
示例3: 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');
}
}
}
示例4: getRaykuUser
/**
* Returns logged person User object from database
*
* @return User
*/
public function getRaykuUser()
{
if (is_null(self::$raykuUser)) {
self::$raykuUser = UserPeer::retrieveByPK($this->getRaykuUserId());
}
return self::$raykuUser;
}
示例5: 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;
}
示例6: getUserLink
function getUserLink($userId = null)
{
if (is_null($userId)) {
$userId = $this->getUserId();
}
sfProjectConfiguration::getActive()->loadHelpers(array('Tag', 'Url'));
$user = UserPeer::retrieveByPK($userId);
return !$user ? '<i>Deleted account</i>' : link_to($user->getUsername(), '@profile?username=' . $user->getUsername());
}
示例7: 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']);
$hours_per_week = $user->getHoursPerWeek($activity->getId(), $roomId);
$total = $user->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id);
} else {
if (!is_null($values['Card_id'])) {
$card = CardPeer::retrieveByPK($values['Card_id']);
$hours_per_week = $card->getHoursPerWeek($activity->getId(), $roomId);
$total = $card->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id);
} else {
/* Trick to enforce potential new login objects (Like User or Card) to update this function */
/* This way, the validator will always throw. */
$hours_per_week = null;
$total = null;
}
}
if (empty($total)) {
$total = 0;
}
if ($hours_per_week < 0 || is_null($hours_per_week)) {
$error = new sfValidatorError($this, 'no_hours_per_week', array());
if ($this->getOption('throw_global_error')) {
throw $error;
}
throw new sfValidatorErrorSchema($this, array('duration' => $error));
}
if ($total + $duration > $hours_per_week * 60) {
$error = new sfValidatorError($this, 'invalid', array('minutes_per_week' => $hours_per_week * 60, 'total' => $total));
if ($this->getOption('throw_global_error')) {
throw $error;
}
throw new sfValidatorErrorSchema($this, array('duration' => $error));
}
}
return $values;
}
示例8: triggerEvent
/**
* Triggers a system event.
*
* This will create a SystemEventInstance instance and notify any remote
* systems if they have active SystemEventSubscription objects.
*
* Each subscriber will be sent a unique SystemEventInstanceMessage.
*
* eg.
*
* $message = new stdClass();
* $message->user_id = 54;
* $message->city = 'Vancouver';
* \SystemEventPeer::triggerEvent( 'new_user_signed_up', $message );
*
*
*
* @param string $event_unique_key
* @param stdClass $message
* @param integer $user_id
*
* @throws \Exception if system event is not known
* @throws \Exception if $message is not a stdClass (if not null)
* @throws \Exception if $user_id is provided (not null) but not found
*
* @return SystemEventInstance
*/
public static function triggerEvent($event_unique_key, $message = null, $user_id = null)
{
//validate the arguments
$system_event = \SystemEventPeer::retrieveByUniqueKey($event_unique_key);
if (!$system_event) {
throw new \Exception('Unknown System Event: ' . $event_unique_key);
}
if (!is_null($message)) {
if (!$message instanceof \stdClass) {
throw new \Exception('Message must be a stdClass.');
}
} else {
$message = new \stdClass();
}
if (!is_null($user_id)) {
$user = \UserPeer::retrieveByPK($user_id);
if (!$user) {
throw new \Exception('Unknown User.');
}
} else {
$user = \sfContext::getInstance()->getUser()->getProfile();
if (!$user) {
throw new \Exception('User must be logged in or you must provide a user_id to triggerError()');
}
$user_id = $user->getId();
}
//record the event
$system_event_instance = new \SystemEventInstance();
$system_event_instance->setMessage(json_encode($message));
if (isset($user)) {
$system_event_instance->setUser($user);
}
$system_event_instance->setSystemEvent($system_event);
$system_event_instance->save();
//get the subscribers for this event
$system_event_subscriptions = \SystemEventSubscriptionPeer::getSubscriptionsForEvent($system_event->getId(), $user_id);
//notify each of the subscribers
foreach ($system_event_subscriptions as $system_event_subscription) {
$system_event_subscription->saveSystemEventNotification($system_event_instance);
}
}
示例9:
/**
* This method just returns the user instance that
* corresponds to the given username.
*
*/
public function &loadUserByUsername($username)
{
//get the user from the database
$user = UserPeer::retrieveByPK($username);
return $user;
}
示例10: getUser
/**
* Get the associated User object
*
* @param Connection Optional Connection object.
* @return User The associated User object.
* @throws PropelException
*/
public function getUser($con = null)
{
// include the related Peer class
include_once 'src/model/whiteboard/om/BaseUserPeer.php';
if ($this->aUser === null && $this->user_id !== null) {
$this->aUser = UserPeer::retrieveByPK($this->user_id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = UserPeer::retrieveByPK($this->user_id, $con);
$obj->addUsers($this);
*/
}
return $this->aUser;
}
示例11: setUser
public function setUser( $userId )
{
$this->user = \UserPeer::retrieveByPK( $userId );
}
示例12: unset
<?php
if ($_SESSION['edit_error']) {
unset($_SESSION['edit_error']);
?>
<p style="font-size:14px;color:red;padding-top:15px;" align="center"><em>Your editing privilages for this post has expired, sorry!</em></p>
<?php
}
?>
<div class="box">
<div class="top"></div>
<div class="content">
<div class="userinfo">
<?php
$user = UserPeer::retrieveByPK($post->getPosterId());
?>
<div class="avatar-holder" style="float:none !important;"> <?php
echo avatar_tag_for_user($user);
?>
</div>
<div class="spacer"></div>
<?php
$connection = RaykuCommon::getDatabaseConnection();
$query = mysql_query("select * from user_score where user_id=" . $user->getId(), $connection) or die(mysql_error());
$row = mysql_fetch_assoc($query);
?>
<?php
if ($user->getType() == 5) {
示例13: array_merge
if (count($_StickieId) > 0 && count($_Non_StickieId) > 0) {
$threads = array_merge($_StickieId, $_Non_StickieId);
} else {
if (count($_StickieId) > 0 && count($_Non_StickieId) == 0) {
$threads = $_StickieId;
} else {
if (count($_StickieId) == 0 && count($_Non_StickieId) > 0) {
$threads = $_Non_StickieId;
}
}
}
foreach ($threads as $thread) {
$_class = '';
$thread = ThreadPeer::retrieveByPK($thread);
$post = PostPeer::getFirstForThreadId($thread->getId());
$user = UserPeer::retrieveByPK($thread->getPosterId());
if (!empty($_StickieId)) {
if (in_array($thread->getId(), $_StickieId)) {
$_class = "background-color:#E6F8FF";
}
}
?>
<div class="entry" style="<?php
echo $_class;
?>
">
<div class="information" >
<?php
echo link_to($thread, '@view_thread?thread_id=' . $thread->getId(), array('class' => 'threadttle'));
?>
<div class="threadst">
示例14:
}
}
if (!isset($vocabulary)) {
if ($concept) {
$vocabulary = $concept->getVocabulary();
}
}
$tab = false;
break;
case 'user':
$showBc = true;
$showUserBc = true;
if (!isset($user)) {
$id = 'show' == $action && !$historydetail ? $sf_params->get('id') : $paramId;
if ($id) {
$user = UserPeer::retrieveByPK($id);
}
}
if ($user) {
$objectId = $user->getID();
}
break;
case 'version':
$showBc = true;
$showVocabularyBc = true;
$showVersionBc = true;
if (!isset($vocabulary_has_version)) {
$id = 'show' == $action ? $sf_params->get('id') : $paramId;
if ($id) {
$vocabulary_has_version = VocabularyHasVersionPeer::retrieveByPK($id);
}
示例15: executeAssignrole
public function executeAssignrole()
{
$roleid = $this->getRequestParameter('role');
$userid = $this->getRequestParameter('assignee');
$user = UserPeer::retrieveByPK($userid);
$c = new Criteria();
$c->add(UserrolePeer::USER_ID, $userid);
$c->add(UserrolePeer::ROLE_ID, $roleid);
$userrole = UserrolePeer::doSelectOne($c);
if ($userrole) {
$this->setFlash('notice', 'This role is already assigned for <b>' . $user->getFullname() . '</b>');
$this->redirect('/search/result');
}
$userrole = new Userrole();
$userrole->setUserId($userid);
$userrole->setRoleId($roleid);
$userrole->save();
$this->setFlash('notice', 'Role assigned successfully for <b>' . $user->getFullname() . '</b>');
$this->redirect('/search/result');
}