Exemplo n.º 1
0
        $response->json($response);
    }
    $input = array('installed' => (int) $module->installed + 1);
    $model->moduleUpdate($input, array('id' => $api->getInputVal('id')));
    $response->json($response);
} elseif ($route->match('api-comments-create', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    if (!$model->commentCreate($api->getInputs())) {
        $response->status = 500;
        $response->message = 'Unable to add a comment';
        $response->json($response);
    }
    if ($api->getInputVal('type') != 1 && ($module = $model->moduleFindJoin(array('m.id' => $api->getInputVal('module_id'))))) {
        $email = array('from' => '*****@*****.**', 'from_name' => $api->getInputVal('name'), 'to' => $module->mail, 'subject' => $module->title . ' - new comment', 'body' => $api->getInputVal('content'));
        $api->sendEmail($email);
    }
    $input['id'] = $db->inserId();
    $response->data = $input;
    $response->json($response);
} elseif ($route->match('api-comments', 1)) {
    // Prepare and sanitize post input
    $api->setInputs(array('module_id' => $route->getParam(0)));
    $response->data = $model->commentsAll($api->getInputs());
    $response->json($response);
} elseif ($route->match('api-rating-create', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    // Already rated
    $rating = $model->ratingFind(array('module_id' => $api->getInputVal('module_id'), 'remote_id' => $api->getInputVal('remote_id')));
    if ($rating) {