function getSerieContributionComments() { global $current_user; /* @var $current_user CurrentUser */ $id_serie = isset($this->params['serie_id']) ? (int) $this->params['serie_id'] : false; if (!$id_serie) { return; } $data = Database::sql2row('SELECT * FROM `series` WHERE `id`=' . $id_serie); if (!count($data)) { throw new Exception('serie #' . $id_serie . ' not exists'); } $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : 20; $pagingName = isset($this->params['paging_parameter_name']) ? $this->params['paging_parameter_name'] : 'p'; $cond->setPaging(1000, $per_page, $pagingName); $limit = $cond->getMongoLimit(); list($comments, $count) = MongoDatabase::getSerieComments($id_serie, $per_page, $limit); $uids = array(); $comments['comments'] = isset($comments['comments']) ? $comments['comments'] : array(); foreach ($comments['comments'] as &$comment) { $comment['commenter_id'] = $comment['user_id']; $comment['type'] = 'serie'; $comment['time'] = date('Y/m/d H:i:s', $comment['time']); $uids[$comment['user_id']] = $comment['user_id']; } $cond = new Conditions(); $cond->setPaging($count, $per_page, $pagingName); $this->data['conditions'] = $cond->getConditions(); $this->data['comments'] = isset($comments['comments']) ? $comments['comments'] : array(); $this->data['comments']['title'] = 'Обсуждение серии «' . $data['title'] . '»'; $this->data['comments']['count'] = $count; $this->data['users'] = $this->getCommentsUsers($uids); }