static function get_profile_document($userId){
        $user = Pluf_Shortcuts_GetObjectOr404('User', $userId);
        // Find collection profile
        $collection = Collection_Shortcuts_GetCollectionByName(User_Constants::PROFILE_COLLECTION_NAME);
        if($collection === null){
            $collection = new Collection_Collection();
            $collection->name = User_Constants::PROFILE_COLLECTION_NAME;
            $collection->title= 'Collection for saving profile of users';
            $collection->create();
        }
        $cprofile = new Profile();
        $cprofile = $cprofile->getOne('user = ' . $userId);
        if($cprofile === null){
            // create cprofile and document for profile of user
            $document = new Collection_Document();
            $document->collection = $collection;
            $document->create();
            $cprofile = new Profile();
            $cprofile->user = $user;
            $cprofile->profile = $document;
            $cprofile->create();
        }
        $profileDoc = new Collection_Document($cprofile->profile);
        return $profileDoc;
    }
static function get_profile_document($userId){
        $user = Pluf_Shortcuts_GetObjectOr404('User', $userId);
        // Find collection profile
        $collection = Collection_Shortcuts_GetCollectionByName(User_Constants::PROFILE_COLLECTION_NAME);
        if($collection === null){
            $collection = new Collection_Collection();
            $collection->name = User_Constants::PROFILE_COLLECTION_NAME;
            $collection->title= 'Collection for saving profile of users';
            $collection->create();
        }
        $cprofile = new Profile();
        $cprofile = $cprofile->getOne('user = ' . $userId);
        if($cprofile === null){
            // create cprofile and document for profile of user
            $document = new Collection_Document();
            $document->collection = $collection;
            $document->create();
            $cprofile = new Profile();
            $cprofile->user = $user;
            $cprofile->profile = $document;
            $cprofile->create();
        }
        $profileDoc = new Collection_Document($cprofile->profile);
        return $profileDoc;
    }
static function get_profile_document ( $ userId ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User' , $ userId ) ; // Find collection profile $ collection = Collection_Shortcuts_GetCollectionByName ( User_Constants :: PROFILE_COLLECTION_NAME ) ; if ( $ collection === null ) { $ collection = new Collection_Collection ( ) ; $ collection -> name = User_Constants :: PROFILE_COLLECTION_NAME ; $ collection -> title = 'Collection for saving profile of users' ; $ collection -> create ( ) ; } $ cprofile = new Profile ( ) ; $ cprofile = $ cprofile -> getOne ( 'user = ' . $ userId ) ; if ( $ cprofile === null ) { // create cprofile and document for profile of user $ document = new Collection_Document ( ) ; $ document -> collection = $ collection ; $ document -> create ( ) ; $ cprofile = new Profile ( ) ; $ cprofile -> user = $ user ; $ cprofile -> profile = $ document ; $ cprofile -> create ( ) ; } $ profileDoc = new Collection_Document ( $ cprofile -> profile ) ; return $ profileDoc ; }
Fetch profile of the user

If the profile does not exist then, a new profile will be crated.
@param integer $userId
@return Collection_Document
Fetch profile of the user