Kronolith::_notificationPref PHP Méthode

_notificationPref() public static méthode

Returns whether a user wants email notifications for a calendar.
public static _notificationPref ( string $user, string $mode, string $calendar = null ) : mixed
$user string A user name.
$mode string The check "mode". If "owner", the method checks if the user wants notifications only for calendars he owns. If "read", the method checks if the user wants notifications for all calendars he has read access to, or only for shown calendars and the specified calendar is currently shown.
$calendar string The name of the calendar if mode is "read".
Résultat mixed The user's email, time, and language preferences if they want a notification for this calendar.
    public static function _notificationPref($user, $mode, $calendar = null)
    {
        $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $user));
        $vals = array('lang' => $prefs->getValue('language'), 'tf' => $prefs->getValue('twentyFour'), 'df' => $prefs->getValue('date_format'));
        if ($prefs->getValue('event_notification_exclude_self') && $user == $GLOBALS['registry']->getAuth()) {
            return false;
        }
        switch ($prefs->getValue('event_notification')) {
            case 'owner':
                return $mode == 'owner' ? $vals : false;
            case 'read':
                return $mode == 'read' ? $vals : false;
            case 'show':
                if ($mode == 'read') {
                    $display_calendars = unserialize($prefs->getValue('display_cals'));
                    return in_array($calendar, $display_calendars) ? $vals : false;
                }
        }
        return false;
    }