Example #1
0
        $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) {
        $response->status = 409;
        $response->message = 'Already rated';
        $response->json($response);
    }
    if ((int) $api->getInputVal('score') > 5 || !$model->ratingCreate($api->getInputs())) {
        $response->status = 500;
        $response->message = 'Unable to rate the module';
        $response->json($response);
    }
    $input['id'] = $db->inserId();
    $response->data = $input;
    $response->json($response);
} elseif ($route->match('api-skins', null)) {
    $response->data = $model->skinsAll(array('active' => 1));