ActivityModel::notificationPreference PHP Метод

notificationPreference() публичный статический Метод

Get default notification preference for an activity type.
С версии: 2.0.0
public static notificationPreference ( string $ActivityType, array $Preferences, string $Type = null ) : boolean | bool[]
$ActivityType string
$Preferences array
$Type string One of the following: - Popup: Popup a notification. - Email: Email the notification. - NULL: True if either notification is true. - both: Return an array of (Popup, Email).
Результат boolean | bool[]
    public static function notificationPreference($ActivityType, $Preferences, $Type = null)
    {
        if (is_numeric($Preferences)) {
            $User = Gdn::userModel()->getID($Preferences);
            if (!$User) {
                return $Type == 'both' ? [false, false] : false;
            }
            $Preferences = val('Preferences', $User);
        }
        if ($Type === null) {
            $Result = self::notificationPreference($ActivityType, $Preferences, 'Email') || self::notificationPreference($ActivityType, $Preferences, 'Popup');
            return $Result;
        } elseif ($Type === 'both') {
            $Result = [self::notificationPreference($ActivityType, $Preferences, 'Popup'), self::notificationPreference($ActivityType, $Preferences, 'Email')];
            return $Result;
        }
        $ConfigPreference = c("Preferences.{$Type}.{$ActivityType}", '0');
        if ((int) $ConfigPreference === 2) {
            $Preference = true;
            // This preference is forced on.
        } elseif ($ConfigPreference !== false) {
            $Preference = val($Type . '.' . $ActivityType, $Preferences, $ConfigPreference);
        } else {
            $Preference = false;
        }
        return $Preference;
    }