src/snac/server/database/DBUser.php
/**
     * Add a user record.
     *
     * Minimal requirements are username which must be unique. We plan to use email as username, but calling
     * code creates the User object, so this code will just use what getUserName() returns.
     *
     * user->active does not default to true. In retrospect this seems like a dubious feature that should be
     * discussed. Currently, if you want your new user to be active then $user->setUserActive(true) before
     * calling createUser().
     *
     * Param $user is not modified, although it is cloned and the clone has the userID added, and the clone is
     * returned on success.
     *
     * Affiliation is a Constellation, but only has the minimal summary fields. We save the Constellation ID
     * aka ic_id aka getID() to the database.
     *
     * Return the new user object on success.
     *
     * Calling code had better do some sanity checking. This does not set the password. The password is not
     * part of a user object. We could add an optional arg, but for now, call writePassword()
     *
     * @param \snac\data\User $user A user object.
     * @param boolean $saveRole optionsl If true, save the roles of this user
     *
     * @return \snac\data\User Return the cloned User with the userID set (and all other fields populated)
     */
Add a user record.
Minimal requirements are username which must be unique. We plan to use email as username, but calling
code creates the User object, so this code will just use what getUserName() returns.

user->active does not default to true. In retrospect this seems like a dubious feature that should be
discussed. Currently, if you want your new user to be active then $user->setUserActive(true) before
calling createUser().

Param $user is not modified, although it is cloned and the clone has the userID added, and the clone is
returned on success.

Affiliation is a Constellation, but only has the minimal summary fields. We save the Constellation ID
aka ic_id aka getID() to the database.

Return the new user object on success.

Calling code had better do some sanity checking. This does not set the password. The password is not
part of a user object. We could add an optional arg, but for now, call writePassword()

@param \snac\data\User $user A user object.
@param boolean $saveRole optionsl If true, save the roles of this user

@return \snac\data\User Return the cloned User with the userID set (and all other fields populated)
Add a user record . Minimal requirements are username which must be unique . We plan to use email as username but calling code creates the User object so this code will just use what getUserName () returns . user - > active does not default to true . In retrospect this seems like a dubious feature that should be discussed . Currently if you want your new user to be active then $user - > setUserActive ( true ) before calling createUser () . Param $user is not modified although it is cloned and the clone has the userID added and the clone is returned on success . Affiliation is a Constellation but only has the minimal summary fields . We save the Constellation ID aka ic_id aka getID () to the database . Return the new user object on success . Calling code had better do some sanity checking . This does not set the password . The password is not part of a user object . We could add an optional arg but for now call writePassword () @param \ snac \ data \ User $user A user object . @param boolean $saveRole optionsl If true save the roles of this user @return \ snac \ data \ User Return the cloned User with the userID set ( and all other fields populated )
public function createUser($user, $saveRole=false)
    {
        if (! $this->userExists($user))
        {
            $appUserID = $this->sql->insertUser($user->getUserName(),
                                                $user->getFirstName(),
                                                $user->getLastName(),
                                                $user->getFullName(),
                                                $user->getAvatar(),
                                                $user->getAvatarSmall(),
                                                $user->getAvatarLarge(),
                                                $user->getEmail(),
                                                $user->getWorkEmail(),
                                                $user->getWorkPhone(),
                                                $user->getAffiliation()==null?null:$user->getAffiliation()->getID(),
                                                $user->getPreferredRules(),
                                                $user->getUserActive());
            $newUser = clone($user);
            $newUser->setUserID($appUserID);
            if ($saveRole) {
                foreach($user->getRoleList() as $role) {
                    $this->addRoleToUser($newUser, $role);
                }
                $newUser = $this->readUser($newUser);
            }
            return $newUser;
        }
        return false;
    }
public function createUser ( $ user , $ saveRole = false ) { if ( ! $ this -> userExists ( $ user ) ) { $ appUserID = $ this -> sql -> insertUser ( $ user -> getUserName ( ) , $ user -> getFirstName ( ) , $ user -> getLastName ( ) , $ user -> getFullName ( ) , $ user -> getAvatar ( ) , $ user -> getAvatarSmall ( ) , $ user -> getAvatarLarge ( ) , $ user -> getEmail ( ) , $ user -> getWorkEmail ( ) , $ user -> getWorkPhone ( ) , $ user -> getAffiliation ( ) == null ? null : $ user -> getAffiliation ( ) -> getID ( ) , $ user -> getPreferredRules ( ) , $ user -> getUserActive ( ) ) ; $ newUser = clone ( $ user ) ; $ newUser -> setUserID ( $ appUserID ) ; if ( $ saveRole ) { foreach ( $ user -> getRoleList ( ) as $ role ) { $ this -> addRoleToUser ( $ newUser , $ role ) ; } $ newUser = $ this -> readUser ( $ newUser ) ; } return $ newUser ; } return false ; }
Add a user record.
Add a user record .
/*
             * Admins can run this on behalf of another user. It requires authorization to save roles and save
             * groups.
             */ // go through the original passed-in user and add their roles to the system // This method will munge the list of roles attached to the user (Side-effect-full) // read the full user back out to return // $this->addDefaultRole($newUser);