<?php
/**
 * created by aheadware GmbH
 */

class TB_Server_Core_ResponseProcessor
{
    /**
     * @param TB_Shared_Ent_Core_Account $account
     * @return array
     */
    public static function processTB_Shared_Ent_Core_Account( TB_Shared_Ent_Core_Account $account )
    {
        $arr = $account->asArray();

        $arr[ 'pass' ] = NULL;

        return $arr;
    }

    /**
     * @param TB_Shared_Ent_Core_Account $account
     * @return array
     */
    public static function processTB_Shared_Ent_TeamData_Profile( TB_Shared_Ent_TeamData_Profile $profile )
    {
        $sessionProfile = TB_Server_Core_Session::get()->getProfile();

        if ( false === $sessionProfile->canAccessProfile( $profile ) )
        {
            $profile->anonymize();
        }
        if ( false === $sessionProfile->canAdministrateProfile( $profile ) &&
             false === $profile->canAdministrateProfile( $sessionProfile ) )
        {
            $profile->anonymizeAddressData();
        }
        if ( false === $sessionProfile->isOwnProfile( $profile ) )
        {
            $profile->public_id = '';
        }
        return $profile->asArray();
    }

}