* http://peoplepods.net http://xoxco.com
*
* core_api_simple/index.php
* Handles simple requests to /api
*
* Documentation for this pod can be found here:
* http://peoplepods.net/readme
/**********************************************/
include_once "../../PeoplePods.php";
$POD = new PeoplePod(array('authSecret' => @$_COOKIE['pp_auth'], 'debug' => 2));
if ($POD->libOptions('enable_core_api_simple')) {
    $method = $_GET['method'];
    $POD->tolog("API CALL METHOD: {$method}");
    if ($method == "alert.markAsRead") {
        if ($POD->isAuthenticated()) {
            $alert = $POD->getAlert(array('id' => $_GET['id']));
            $alert->markAsRead();
            if ($alert->success()) {
                echo json_encode($alert->asArray());
            } else {
                echo json_encode(array('error' => $alert->error(), 'id' => $_GET['id']));
            }
        } else {
            echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['docId']));
        }
    }
    if ($method == "markAsRead") {
        if ($POD->isAuthenticated()) {
            $doc = $POD->getContent(array('id' => $_GET['docId']));
            if ($doc->success()) {
                $doc->markCommentsAsRead();