/** * 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; }
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(); }
protected function createTempUser() { $email = uniqid() . '@' . uniqid() . '.com'; $pass = '******'; $user = new \BaseUser(); $user->email = $email; $user->raw_password = $pass; $user->save(); return $user; }
/** * 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; }
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; }
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; } }
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(); }
/** * 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; }
/** * 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); } }
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); }