本文整理汇总了PHP中BaseUser::save方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseUser::save方法的具体用法?PHP BaseUser::save怎么用?PHP BaseUser::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseUser
的用法示例。
在下文中一共展示了BaseUser::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Adds a forum assigned to the user when it is created
*
* @return bool
*/
public function save(PropelPDO $con = null)
{
//Check if it's a new user before saving
$new = $this->isNew();
$this->setLastActivityAt(time());
//Save and return false on an error
if (!parent::save($con)) {
return false;
}
//If it was new...
if ($new) {
//Create a forum for it
$forum = new Forum();
$forum->setName($this->getName());
$forum->setType(Forum::TYPE_USER_FORUM);
$forum->setEntityId($this->getId());
//If the forum didn't work
if (!$forum->save()) {
//Delete the group and return false
$this->delete();
return false;
}
}
return true;
}
示例2: save
public function save(Doctrine_Connection $con = null)
{
// a new record?
if (!$this->getId()) {
$this->setUid(UserTable::getMaxUid() + 1);
}
if (!$this->getDomainnameId()) {
// get the default domainname
$domainname = DomainnameTable::getDefaultDomainname();
$this->setDomainnameId($domainname->getId());
}
if (!$this->getLogin()) {
$this->generateLogin();
}
if (!$this->getEmailLocalPart()) {
$this->generateEmailLocalPart();
}
if (!$this->getCryptPassword()) {
$password = new Password();
$this->setPasswordObject($password);
$this->generated_password = $password->getPassword();
}
// linking a one-on-one sfGuardUser
$sfguard_user = $this->getSfGuardUser();
$sfguard_user->setUsername($this->getLogin());
$sfguard_user->setIsActive(true);
$sfguard_user->save();
$this->setSfguarduserId($sfguard_user->getId());
return parent::save();
}
示例3: createTempUser
protected function createTempUser()
{
$email = uniqid() . '@' . uniqid() . '.com';
$pass = 'test1234';
$user = new \BaseUser();
$user->email = $email;
$user->raw_password = $pass;
$user->save();
return $user;
}
示例4: save
/**
* Overrides save() in App_Model
*
* @param array $data
* @access public
* @return int
*/
public function save(array $data)
{
$id = parent::save($data);
if (isset($data['groups']) && is_array($data['groups']) && !empty($data['groups'])) {
$groups = $data['groups'];
} else {
$groups = array();
}
$userGroupModel = new BackofficeUserGroup();
$userGroupModel->saveForUser($groups, $id);
return $id;
}
示例5: save
public function save($connection = null)
{
parent::save($connection);
foreach ($this->aclUserGroups as $aclUserGroup) {
$aclUserGroup->user = $this;
try {
$aclUserGroup->save();
} catch (PropelException $e) {
}
}
foreach ($this->aclPermissions as $aclPermission) {
$aclPermission->user = $this;
try {
$aclPermission->save();
} catch (PropelException $e) {
}
}
return $this;
}
示例6: save
public function save($con = null, $parent = null)
{
try {
$con = Propel::getConnection();
$con->begin();
if (trim($this->__toString()) != "") {
$this->setLabel($this->__toString());
}
switch ($this->getType()) {
case "admin":
//case "site_admin":
$this->setBackend(1);
break;
default:
$this->setBackend(0);
}
if ($this->getLogin() == "") {
$this->setLogin($this->getEmail());
}
if (!$this->getId()) {
$this->setId(Document::getGenericDocument($this)->getId());
}
/*if (!$this->getPublicationStatus())
{
$this->setPublicationStatus(UtilsHelper::STATUS_ACTIVE);
}*/
parent::save($con);
// create relationship
if (!$parent && !Document::getParentOf($this->getId())) {
$parent = Rootfolder::getRootfolder($this);
}
Relation::saveRelation($parent, $this);
$con->commit();
Document::cacheObj($this, get_class($this));
return true;
} catch (Exception $e) {
$con->rollback();
throw $e;
}
}
示例7: save
public function save(PropelPDO $con = null)
{
if (!$this->getId()) {
$this->setUid(UserPeer::getMaxUid() + 1);
$password = new Password();
$this->generated_password = $password->getPassword();
$this->setNtPassword($password->getNtHash());
$this->setUnixPassword($password->getNtHash());
$this->setCryptPassword($password->getCryptHash());
$this->setLmPassword($password->getLmHash());
}
if (!$this->getDomainnameId()) {
// get the default domainname
$domainname = DomainnamePeer::getDefaultDomainname();
$this->setDomainnameId($domainname->getId());
}
if (!$this->getLogin()) {
$this->generateLogin();
}
if (!$this->getEmailLocalPart()) {
$this->generateEmailLocalPart();
}
return parent::save();
}
示例8: save
/**
* Save user into the database
*
* @param void
* @return boolean
*/
function save()
{
$modified_fields = $this->modified_fields;
$is_new = $this->isNew();
if ($is_new && $this->getToken() == '') {
$this->resetToken();
}
// if
$save = parent::save();
if ($save && !is_error($save)) {
if ($is_new || in_array('email', $modified_fields) || in_array('first_name', $modified_fields) || in_array('last_name', $modified_fields)) {
$content = $this->getEmail();
if ($this->getFirstName() || $this->getLastName()) {
$content .= "\n\n" . trim($this->getFirstName() . ' ' . $this->getLastName());
}
// if
search_index_set($this->getId(), 'User', $content);
cache_remove_by_pattern('object_assignments_*_rendered');
}
// if
// Role changed?
if (in_array('role_id', $modified_fields)) {
clean_user_permissions_cache($this);
}
// if
}
// if
return $save;
}
示例9: save
/**
* Save
*
*/
function save()
{
if ($this->isNew()) {
$max_users = config_option('max_users');
if ($max_users && Users::count() >= $max_users) {
throw new Exception(lang("maximum number of users reached error"));
}
}
parent::save();
// update logged_user info in global cache
if (logged_user() instanceof User && $this->getId() == logged_user()->getId() && GlobalCache::isAvailable()) {
GlobalCache::update('logged_user_' . $this->getId(), $this);
}
}
示例10: save
public function save(Doctrine_Connection $conn = null)
{
if (!$this->getHash()) {
$this->setHash(md5(uniqid(rand(), true)));
}
if (!$this->getApiKey()) {
$this->setApiKey(md5(uniqid(rand(), true)));
}
if (!$this->exists()) {
$this->setCreatedAt(date('Y-m-d H:i:s'));
$this->sendActivationEmail();
}
$this->setUpdatedAt(date('Y-m-d H:i:s'));
parent::save($conn);
}