Example #1
0
 * -----------------------------------------------------------------
 * @package      rmcommon
 * @author       Eduardo Cortés
 * @copyright    Eduardo Cortés
 * @license      GPL 2
 * @link         http://eduardocortes.mx
 * @link         http://rmcommon.com
 */
if ('cu-notification-subscribe' == $page) {
    // Process subscriptions
    class Response
    {
        use RMModuleAjax;
    }
    $response = new Response();
    $response->prepare_ajax_response();
    $result = RMNotifications::get()->subscribe();
    if (FALSE === $result) {
        $response->ajax_response(__('Sorry, your request could not be processed.', 'rmcommon'), 1, 0);
    }
    $message = 'subscribed' == $result->status ? __('Subscribed', 'rmcommon') : __('Subscription cancelled', 'rmcommon');
    $response->ajax_response($message, 0, 0, $event);
} elseif ('cu-notification-list' == $page) {
    // Show subscriptions list
    global $xoopsUser, $cuSettings;
    if (!$xoopsUser) {
        RMUris::redirect_with_message(__('You need to register/login to view this page.', 'rmcommon'), XOOPS_URL, RMMSG_WARN);
    }
    $subscriptions = RMNotifications::get()->subscriptions();
    if (empty($subscriptions)) {
        RMUris::redirect_with_message(__('You are not subscribed to any notification event.', 'rmcommon'), XOOPS_URL, RMMSG_WARN);