Beispiel #1
0
/**
 * Get a map of notification types available to our member.
 *
 * @param  ?MEMBER		Member this is for (NULL: just check globally)
 * @return array			Map of notification types (integer code to language string code)
 */
function _get_available_notification_types($member_id_of = NULL)
{
    $__notification_types = array(A_INSTANT_EMAIL => 'INSTANT_EMAIL', A_INSTANT_PT => 'INSTANT_PT', A_INSTANT_SMS => 'INSTANT_SMS', A_DAILY_EMAIL_DIGEST => 'DAILY_EMAIL_DIGEST', A_WEEKLY_EMAIL_DIGEST => 'WEEKLY_EMAIL_DIGEST', A_MONTHLY_EMAIL_DIGEST => 'MONTHLY_EMAIL_DIGEST');
    $_notification_types = array();
    foreach ($__notification_types as $possible => $ntype) {
        if (_notification_setting_available($possible, $member_id_of)) {
            $_notification_types[$possible] = $ntype;
        }
    }
    return $_notification_types;
}
Beispiel #2
0
/**
 * Enable notifications for a member on a notification type+category.
 *
 * @param  ID_TEXT		The notification code to use
 * @param  ?SHORT_TEXT	The category within the notification code (NULL: none)
 * @param  ?MEMBER		The member being signed up (NULL: current member)
 * @param  ?integer		Setting to use (NULL: default)
 */
function enable_notifications($notification_code, $notification_category, $member_id = NULL, $setting = NULL)
{
    if (is_null($member_id)) {
        $member_id = get_member();
    }
    if (is_guest($member_id)) {
        return;
    }
    if (is_null($setting)) {
        $ob = _get_notification_ob_for_code($notification_code);
        if (is_null($ob)) {
            warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
        }
        $setting = $ob->get_default_auto_setting($notification_code, $notification_category);
        if (!_notification_setting_available($setting, $member_id)) {
            $setting = _find_member_statistical_notification_type($member_id);
        }
    }
    $db = substr($notification_code, 0, 4) == 'ocf_' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB'];
    $db->query_delete('notifications_enabled', array('l_member_id' => $member_id, 'l_notification_code' => substr($notification_code, 0, 80), 'l_code_category' => is_null($notification_category) ? '' : $notification_category));
    $db->query_insert('notifications_enabled', array('l_member_id' => $member_id, 'l_notification_code' => substr($notification_code, 0, 80), 'l_code_category' => is_null($notification_category) ? '' : $notification_category, 'l_setting' => $setting));
    if ($notification_code == 'comment_posted' && get_forum_type() == 'ocf') {
        $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier(get_option('comments_forum_name'), $notification_category);
        if (!is_null($topic_id)) {
            enable_notifications('ocf_topic', strval($topic_id), $member_id);
        }
    }
    global $NOTIFICATION_SETTING_CACHE;
    $NOTIFICATION_SETTING_CACHE = array();
}