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) { $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);