public static function update($request, $match)
    {
        // Check access
        if(isset($match['userId'])){
            $user = Pluf_Shortcuts_GetObjectOr404('User_Account', $match['userId']);
        }else{
            $user = $request->user;
        }
        $profile = null;
        if (array_key_exists('profileId', $match)) {
            $profile = Pluf_Shortcuts_GetObjectOr404('User_Profile', $match['profileId']);
            if($profile->account_id !== $user->id){
                throw new Pluf_HTTP_Error404('You are not allowed to change this profile.');
            }
            $form = Pluf_Shortcuts_GetFormForUpdateModel($profile, $request->REQUEST, array());
            $profile = $form->save();
        }else{
            $profile = self::getProfileOfUser($user);
            if ($profile === null) {
                $profile = new User_Profile();
                $profile->account_id = $user;
                $form = Pluf_Shortcuts_GetFormForModel($profile, $request->REQUEST, array());
                $profile = $form->save();
            } else {
                $form = Pluf_Shortcuts_GetFormForUpdateModel($profile, $request->REQUEST, array());
                $profile = $form->save();
            }
        }
        return $profile;
    }
public static function update($request, $match)
    {
        // Check access
        if(isset($match['userId'])){
            $user = Pluf_Shortcuts_GetObjectOr404('User_Account', $match['userId']);
        }else{
            $user = $request->user;
        }
        $profile = null;
        if (array_key_exists('profileId', $match)) {
            $profile = Pluf_Shortcuts_GetObjectOr404('User_Profile', $match['profileId']);
            if($profile->account_id !== $user->id){
                throw new Pluf_HTTP_Error404('You are not allowed to change this profile.');
            }
            $form = Pluf_Shortcuts_GetFormForUpdateModel($profile, $request->REQUEST, array());
            $profile = $form->save();
        }else{
            $profile = self::getProfileOfUser($user);
            if ($profile === null) {
                $profile = new User_Profile();
                $profile->account_id = $user;
                $form = Pluf_Shortcuts_GetFormForModel($profile, $request->REQUEST, array());
                $profile = $form->save();
            } else {
                $form = Pluf_Shortcuts_GetFormForUpdateModel($profile, $request->REQUEST, array());
                $profile = $form->save();
            }
        }
        return $profile;
    }
public static function update ( $ request , $ match ) { // Check access if ( isset ( $ match [ 'userId' ] ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } $ profile = null ; if ( array_key_exists ( 'profileId' , $ match ) ) { $ profile = Pluf_Shortcuts_GetObjectOr404 ( 'User_Profile' , $ match [ 'profileId' ] ) ; if ( $ profile -> account_id !== $ user -> id ) { throw new Pluf_HTTP_Error404 ( 'You are not allowed to change this profile.' ) ; } $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } else { $ profile = self :: getProfileOfUser ( $ user ) ; if ( $ profile === null ) { $ profile = new User_Profile ( ) ; $ profile -> account_id = $ user ; $ form = Pluf_Shortcuts_GetFormForModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } else { $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } } return $ profile ; }
Update profile of specified user.
In this server each user has at most one profile.

@param Pluf_HTTP_Request $request
@param array $match
@param array $p
@throws Pluf_Exception
@return Pluf_HTTP_Response_Json
Update profile of specified user . In this server each user has at most one profile .