本文整理汇总了PHP中sfGuardUser::setUpdatedAt方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setUpdatedAt方法的具体用法?PHP sfGuardUser::setUpdatedAt怎么用?PHP sfGuardUser::setUpdatedAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setUpdatedAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLdap
/**
*
* @param sfWebRequest $request
* @param LdapForm $form
*/
protected function processLdap(sfWebRequest $request, LdapForm $form)
{
$form->bind($request->getParameter('signin'));
if ($form->isValid()) {
$values = $form->getValues();
// Check if user already exists in the DB
$user = Doctrine::getTable('sfGuardUser')->findOneByUsername($values["username"]);
// If not, create an account for him
if (empty($user)) {
$datetime = date("Y-m-d H:i:s");
// Create entry in sfGuardUser
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setEmailAddress($values["username"]);
$sfGuardUser->setUsername($values["username"]);
$sfGuardUser->setFirstName($values["firstname"]);
$sfGuardUser->setLastName($values["lastname"]);
$sfGuardUser->setCreatedAt($datetime);
$sfGuardUser->setUpdatedAt($datetime);
$sfGuardUser->save();
// Additional informations for user's profile
$sfGuardUserProfile = new sfGuardUserProfile();
$sfGuardUserProfile->setUserId($sfGuardUser->getId());
$sfGuardUserProfile->setToken(MiscUtils::generateToken());
$sfGuardUserProfile->setSecurityLevel(sfConfig::get("app_security_level_new_user", 0));
$sfGuardUserProfile->save();
$permission = Doctrine_Core::getTable("sfGuardPermission")->findOneByName(sfConfig::get("app_permission_new_user", "User"));
if (!$permission) {
$this->getUser()->setFlash("error", "Unable to set permissions for this account! Contact your administrator.");
$sfGuardUserProfile->delete();
$sfGuardUser->delete();
return;
}
// Give basic permissions for user
$sfGuardPermission = new sfGuardUserPermission();
$sfGuardPermission->setUserId($sfGuardUser->getId());
$sfGuardPermission->setPermissionId($permission->getId());
$sfGuardPermission->setCreatedAt($datetime);
$sfGuardPermission->setUpdatedAt($datetime);
$sfGuardPermission->save();
$userGroup = Doctrine_Core::getTable("sfGuardGroup")->findOneByName(sfConfig::get("app_project_group"));
if (!$userGroup) {
$this->getUser()->setFlash("error", "Unable to set project group for this account! Contact your administrator.");
$sfGuardUserProfile->delete();
$sfGuardUser->delete();
$sfGuardPermission->delete();
return;
}
// Create new entry into sfGuardUserGroup table
$sfGuardGroup = new sfGuardUserGroup();
$sfGuardGroup->setUserId($sfGuardUser->getId());
$sfGuardGroup->setGroupId($userGroup->getId());
$sfGuardGroup->setCreatedAt($datetime);
$sfGuardGroup->setUpdatedAt($datetime);
$sfGuardGroup->save();
$user = $sfGuardUser;
}
$this->getUser()->signIn($user, array_key_exists('remember', $values) ? $values['remember'] : false);
// Set the tow previous referer to the same value for:
// 1) redirect to previous user's location
// 2) avoid redirect loop in signin
$this->getUser()->setReferer($this->getUser()->getReferer());
// Redirect to referer
return $this->redirect($this->getUser()->getReferer());
}
}