Exemple #1
0
/**
 * Subscribes or unsubscribes the specified email address to/from the specified list
 * @param gu_list $list The list
 * @param string $address The email address
 * @param bool $subscribe TRUE if address should be subscribed, FALSE if it should be unsubscribed
 */
function gu_ajax_subscribe($list, $address, $subscribe = TRUE)
{
    if (!$list) {
        return gu_ajax_return('alert("' . t('Invalid list') . '")');
    }
    $list_ids = array($list->get_id());
    if (!gu_subscription_process($address, $list_ids, $subscribe)) {
        gu_ajax_return('alert("' . addslashes(strip_tags($_SERVER['GU_ERROR_MSG'])) . '")');
    }
    gu_ajax_return('alert("' . ($subscribe ? t('Subscription') : t('Unsubscription')) . t(' successful!') . '")');
}
Exemple #2
0
    } elseif (strpos($var, 'subscribe_submit') !== FALSE) {
        $posted_action = 'subscribe';
    }
}
// Check if we've got what we need to do a posted (un)subscription
if ($posted_action != '' && $posted_address != '' && count($posted_lists) > 0) {
    gu_subscription_process($posted_address, $posted_lists, $posted_action == 'subscribe');
}
// Get querystring variables
$list_id = is_get_var('list') ? (int) get_get_var('list') : 0;
$address = is_get_var('addr') ? get_get_var('addr') : '';
$action = is_get_var('action') ? get_get_var('action') : '';
// Check if we've got what we need to do a querystring (un)subscription
if ($list_id > 0 && $address != '' && $action != '') {
    $list_ids = array($list_id);
    gu_subscription_process($address, $list_ids, $subscribe == 'subscribe');
}
// Check to see if a single valid list was specified
if ($list_id > 0 || count($posted_lists) == 1) {
    if ($list_id == 0) {
        $list_id = $posted_lists[0];
    }
    $list = gu_list::get($list_id, FALSE);
} else {
    // Load all non-private lists
    $lists = gu_list::get_all(FALSE, FALSE);
}
if ($address == '' && $posted_address != '') {
    $address = $posted_address;
}
?>