/**
  * @param array $settings
  */
 private function _get_bookmarks(array $settings)
 {
     $sql_array = $this->_get_bookmarks_sql();
     $this->forum_data->query()->set_sorting('t.topic_last_post_time')->fetch_custom($sql_array)->build(true, false);
     $topic_data = $this->forum_data->get_topic_data($settings['max_topics']);
     return array_values($topic_data);
 }
 /**
  * @return array|null
  */
 private function _get_topic_data()
 {
     $sql_array = array('WHERE' => array('t.poll_start <> 0'));
     $this->_limit_by_group($sql_array);
     $this->forum_data->query()->fetch_forum($this->settings['forum_ids'])->fetch_topic_type($this->settings['topic_type'])->fetch_topic($this->_get_array($this->settings['topic_ids']))->fetch_topic_poster($this->_get_array($this->settings['user_ids']))->set_sorting($this->_get_sorting())->fetch_custom($sql_array)->build();
     $topic_data = $this->forum_data->get_topic_data(1);
     return array_shift($topic_data);
 }
 /**
  * @param array $topic_data
  * @return array
  */
 private function _get_post_data(array $topic_data)
 {
     if ($this->settings['display_preview']) {
         $post_data = $this->forum->get_post_data($this->settings['display_preview']);
     } else {
         $post_data = array_fill_keys(array_keys($topic_data), array(array('post_text' => '', 'bbcode_uid' => '', 'bbcode_bitfield' => '')));
     }
     return $post_data;
 }
 /**
  * @param array $settings
  * @return array
  */
 private function _get_topics(array $settings)
 {
     if ($settings['topics_only']) {
         $sorting = 't.topic_last_post_time';
         $sql_array = $this->_get_topics_sql();
     } else {
         $sorting = 'p.post_time';
         $sql_array = $this->_get_posts_sql();
     }
     $this->forum_data->query()->set_sorting($sorting)->fetch_custom($sql_array)->build(true, false);
     $topic_data = $this->forum_data->get_topic_data($settings['max_topics']);
     return array_values($topic_data);
 }
 /**
  * @return array
  */
 private function _get_posts_data()
 {
     $range_info = $this->date_range->get($this->settings['date_range']);
     $allowed_forums = $this->_get_allowed_forums();
     $post_ids = array_filter(explode(',', $this->settings['post_ids']));
     $sql_array = $this->forum_data->query()->fetch_forum($allowed_forums)->fetch_topic_type($this->settings['topic_type'])->fetch_date_range($range_info['start'], $range_info['stop'])->build()->get_sql_array();
     $sql_array['SELECT'] = '';
     $sql_array['WHERE'] .= ' AND p.topic_id = t.topic_id AND p.post_attachment <> 0';
     if ($this->settings['first_only']) {
         $sql_array['WHERE'] .= " AND p.post_id = t.topic_first_post_id";
     }
     return $this->forum_data->get_post_data(false, $post_ids, $this->settings['limit'], 0, $sql_array);
 }