Esempio n. 1
0
$mode = mysql_clean($mode);
switch ($mode) {
    case "subscribe":
        $to = post('to');
        $insert_id = subscribe_user($to);
        if (error()) {
            echo json_encode(array('error' => error()));
        }
        if (msg()) {
            $output = subscription_buttons($to);
            echo json_encode(array('success' => msg(), 'output' => $output));
        }
        break;
    case "unsubscribe":
        $to = post('to');
        unsubscribe_user($to);
        if (error()) {
            echo json_encode(array('error' => error()));
        }
        if (msg()) {
            $output = subscription_buttons($to);
            echo json_encode(array('success' => msg(), 'output' => $output));
        }
        break;
    case "subscription_options":
        $position = post('position') ? post('position') : "bottom";
        $list = subscriptions_types_list(post('user'));
        $params['file'] = 'subscriptions/options_list.html';
        $params['classes'] = 'subscriptions-options options-list ' . post('id') . ' option-position-' . $position;
        $params['id'] = post('user') . '-' . post('subscription') . '-list';
        $params['subscribed_content_list'] = $list;
            }
        }
    }
    if ($confirm == 2) {
        $subscribe = get('subscribe');
        $unsubscribe = get('unsubscribe');
        if ($subscribe || $unsubscribe) {
            $sub_id = get('owner');
            $sub = get_user_details($sub_id);
            if ($sub) {
                $is_subscribed = is_user_subscribed($sub['userid']);
                if ($subscribe and !$is_subscribed) {
                    subscribe_user($sub_id);
                } else {
                    if ($unsubscribe and $is_subscribed) {
                        unsubscribe_user($sub_id);
                    }
                }
                if (!error()) {
                    $success = true;
                }
                if ($success) {
                    redirect_to(BASEURL . '/manage_subscriptions.php');
                }
            }
        }
    }
    $order = return_object_order('manage_subscriptions');
    $subscriptions = get_user_subscriptions($user['userid'], null, $order);
    assign('subscriptions', $subscriptions);
}