- * Increments likes count for video with the specified id and returns to
- * the client as plain text the number if likes.
+ * Increments (dis)likes count for video with the specified id and returns to
+ * the client as plain text the number if likes.
+ *
+ * @param string $action 'like' or 'dislike'
+ * @param string $video_id
+ * @param string $user_id
+ */
+ public function ajax_vote($action, $video_id)
+ {
+ $video_id = intval($video_id);
+ $user_id = $this->session->userdata('user_id');
+ $this->load->model('videos_model');
+
+ $res = $this->videos_model->vote($video_id, $user_id,
+ (strcmp($action, 'like') == 0 ? TRUE : FALSE));
+
+ if ($res !== -1)
+ echo $res;
+ }
+ /**
+ * Increments (dis)likes count for a comment with a specified id and returns
+ * to the client as plain text the number if likes.