public static function commentsUpdate($id, $status = null, $text = null, $authorName = null, $authorEmail = null, $authorWebsite = null)
{
// authorize
if (BaseAPI::isAuthorized() && BaseAPI::isValidRequestMethod('POST')) {
// redefine
$id = (int) $id;
if ($status !== null) {
$status = (string) $status;
}
if ($text !== null) {
$text = (string) $text;
}
if ($authorName !== null) {
$authorName = (string) $authorName;
}
if ($authorEmail !== null) {
$authorEmail = (string) $authorEmail;
}
if ($authorWebsite !== null) {
$authorWebsite = (string) $authorWebsite;
}
// validate
if ($status === null && $text === null && $authorName === null && $authorEmail === null && $authorWebsite === null) {
return BaseAPI::output(BaseAPI::ERROR, array('message' => 'No data provided.'));
}
// update
if ($text !== null || $authorName !== null || $authorEmail != null || $authorWebsite !== null) {
$item['id'] = (int) $id;
if ($text !== null) {
$item['text'] = $text;
}
if ($authorName !== null) {
$item['author'] = $authorName;
}
if ($authorEmail !== null) {
$item['email'] = $authorEmail;
}
if ($authorWebsite !== null) {
$item['website'] = $authorWebsite;
}
// update the comment
BackendBlogModel::updateComment($item);
}
// change the status if needed
if ($status !== null) {
BackendBlogModel::updateCommentStatuses(array($id), $status);
}
}
}