public static function createInheritedAccount()
    {
        if (!Podium::getInstance()->user->isGuest) {
            $transaction = static::getDb()->beginTransaction();
            try {
                $newUser = new static;
                $newUser->setScenario('installation');
                $newUser->inherited_id = Podium::getInstance()->user->id;
                $newUser->status = self::STATUS_ACTIVE;
                $newUser->role = self::ROLE_MEMBER;
                $newUser->generateUsername();
                if (!$newUser->save()) {
                    throw new Exception('Account creating error');
                }
                if (!Podium::getInstance()->rbac->assign(Podium::getInstance()->rbac->getRole(Rbac::ROLE_USER), $newUser->id)) {
                    throw new Exception('User role assigning error');
                }
                PodiumCache::clearAfter('activate');
                Log::info('Inherited account created', $newUser->id, __METHOD__);
                $transaction->commit();
                return true;
            } catch (Exception $e) {
                $transaction->rollBack();
                Log::error($e->getMessage(), null, __METHOD__);
            }
        }
        return false;
    }
public static function createInheritedAccount()
    {
        if (!Podium::getInstance()->user->isGuest) {
            $transaction = static::getDb()->beginTransaction();
            try {
                $newUser = new static;
                $newUser->setScenario('installation');
                $newUser->inherited_id = Podium::getInstance()->user->id;
                $newUser->status = self::STATUS_ACTIVE;
                $newUser->role = self::ROLE_MEMBER;
                $newUser->generateUsername();
                if (!$newUser->save()) {
                    throw new Exception('Account creating error');
                }
                if (!Podium::getInstance()->rbac->assign(Podium::getInstance()->rbac->getRole(Rbac::ROLE_USER), $newUser->id)) {
                    throw new Exception('User role assigning error');
                }
                PodiumCache::clearAfter('activate');
                Log::info('Inherited account created', $newUser->id, __METHOD__);
                $transaction->commit();
                return true;
            } catch (Exception $e) {
                $transaction->rollBack();
                Log::error($e->getMessage(), null, __METHOD__);
            }
        }
        return false;
    }
public static function createInheritedAccount ( ) { if ( ! Podium :: getInstance ( ) -> user -> isGuest ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { $ newUser = new static ; $ newUser -> setScenario ( 'installation' ) ; $ newUser -> inherited_id = Podium :: getInstance ( ) -> user -> id ; $ newUser -> status = self :: STATUS_ACTIVE ; $ newUser -> role = self :: ROLE_MEMBER ; $ newUser -> generateUsername ( ) ; if ( ! $ newUser -> save ( ) ) { throw new Exception ( 'Account creating error' ) ; } if ( ! Podium :: getInstance ( ) -> rbac -> assign ( Podium :: getInstance ( ) -> rbac -> getRole ( Rbac :: ROLE_USER ) , $ newUser -> id ) ) { throw new Exception ( 'User role assigning error' ) ; } PodiumCache :: clearAfter ( 'activate' ) ; Log :: info ( 'Inherited account created' , $ newUser -> id , __METHOD__ ) ; $ transaction -> commit ( ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } } return false ; }
Creates inherited account.
@return bool
@since 0.2
Creates inherited account .