<?php

class AddressSourceType
{

    const USER = 0;
    const CSV_IMPORT = 1;
    const XING_IMPORT = 2;
    const GOOGLE_IMPORT = 3;
    const SYSTEM = 4;
    const LDAP = 5;
    const ICLOUD = 6;
    // least source Type (used to return translation tags in a foreach like : foreach (range(0,AddressSourceType::TOTAL)) )
    const TOTAL = self::ICLOUD;

    public static function getSourceName($source, $translated = true)
    {
        switch ($source) {
            case self::SYSTEM:
                return $translated ? __("ADDRESS_SOURCE_TYPE_SYSTEM") : "ADDRESS_SOURCE_TYPE_SYSTEM";
            case self::GOOGLE_IMPORT:
                return $translated ? __("ADDRESS_SOURCE_TYPE_GOOGLE_PLUS") : "ADDRESS_SOURCE_TYPE_GOOGLE_PLUS";
            case self::XING_IMPORT :
                return $translated ? __("ADDRESS_SOURCE_TYPE_XING") : "ADDRESS_SOURCE_TYPE_XING";
            case self::CSV_IMPORT:
                return $translated ? __("ADDRESS_SOURCE_TYPE_CSV") : "ADDRESS_SOURCE_TYPE_CSV";
            case self::LDAP:
                return $translated ? __("ADDRESS_SOURCE_TYPE_LDAP") : "ADDRESS_SOURCE_TYPE_LDAP";
            case self::ICLOUD:
                return $translated ? __("ADDRESS_SOURCE_TYPE_ICLOUD") : "ADDRESS_SOURCE_TYPE_ICLOUD";
            default:
                return $translated ? __("ADDRESS_SOURCE_TYPE_USER") : "ADDRESS_SOURCE_TYPE_USER";
        }
    }

    public static function getIcon($source)
    {
        switch ($source) {
            case self::SYSTEM:
                return "icon-cogs";
            case self::GOOGLE_IMPORT:
                return "icon-google-plus";
            case self::XING_IMPORT :
                return 'icon-xing';
            case self::LDAP :
            case self::CSV_IMPORT:
                return 'icon-file';
            case self::ICLOUD:
                return 'icon-apple';
            default:
                return 'icon-user';
        }
    }

    // used in ThirdPartyCredential.php
    public static function getSourceTypeFromProvider($provider)
    {
        switch ($provider) {
            case 'XING' :
                return self::XING_IMPORT;
            case 'google' : // <- kommt das überhaupt vor ? 
            case 'Google' :
                return self::GOOGLE_IMPORT;
            case 'iCloud' :
                return self::ICLOUD;
            default :
                return null;
        }
    }
}
