public static function add_comment(comment_object $comment) { $sql = "INSERT INTO \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t`comments`(\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`comment_parent_id`,\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`comment_content`,\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`comment_add_datetime`,\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`file_id`,\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`user_id`\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t" . database_essence::prepare($comment->get_parent_id()) . ",\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t" . database_essence::prepare($comment->get_content()) . ",\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t" . database_essence::prepare($comment->get_file_id()) . ",\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t" . database_essence::prepare($comment->get_user_id()) . "\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t)"; if ($comment_id = database_essence::insert($sql, 'comments')) { return $comment_id; } return null; }
public static function add_comment($file_id = 0, $comment_parent_id = 0) { if (!($me = session_essence::get('me'))) { request_essence::load_request(); } if ($file_id) { if ($file = file_model::get_file_by_id($file_id)) { if ($comment_parent_id > 0) { if (!($comment = comment_model::get_comment_by_id($comment_parent_id))) { request_essence::load_request(); } else { if ($comment->get_file_id() != $file_id) { request_essence::load_request(); } } } $comment = new comment_object(); $comment->set_parent_id($comment_parent_id); $comment->set_content(data_essence::get('post', 'comment-content', array('trim', 'striptags'))); $comment->set_file_id($file_id); $comment->set_user_id($me->get_id()); if (comment_model::add_comment($comment)) { request_essence::load_request('file', 'view', array($file_id)); } else { request_essence::load_request(); } } else { request_essence::load_request(); } } else { request_essence::load_request(); } }