Example #1
0
        $response->message = 'Unable to send verification request';
        $response->data = $api->getErrors();
        $response->json($response);
    }
    $response->json($response);
} elseif ($route->match('moduleupdate', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST, $model->getWhitelist('modules'));
    $where = $user->role > 1 ? array('id' => $api->getInputVal('id'), 'user_id' => $user->id) : array('id' => $api->getInputVal('id'));
    $module = $model->moduleFind($where);
    if (!$module) {
        $response->status = 403;
        $response->message = 'Forbidden';
        $response->json($response);
    }
    $model->moduleUpdate($api->getInputs(), array('id' => $api->getInputVal('id')));
    $response->json($response);
} elseif ($route->match('moduledelete', null)) {
    $api->setInputs($_POST);
    $where = $user->role === 1 ? array('id' => $api->getInputVal('id')) : array('id' => $api->getInputVal('id'), 'user_id' => $user->id);
    $module = $model->moduleFind($where);
    if (!$module) {
        $response->status = 404;
        $response->message = 'Not found';
        $response->json($response);
    }
    $model->moduleDelete(array('id' => $api->getInputVal('id')));
    $model->tokenDelete(array('module_id' => $api->getInputVal('id')));
    $model->langDelete(array('id' => $api->getInputVal('id')));
    $model->commentDelete(array('module_id' => $api->getInputVal('id')));
    $model->ratingDelete(array('module_id' => $api->getInputVal('id')));