/**
  * Конфиг данных для комментариев сервиса
  *
  * @return array
  */
 public function model()
 {
     if (empty($this->_options['commune_id'])) {
         $this->_options['commune_id'] = commune::getCommuneIDByThemeID($this->_options['theme_id']);
     }
     $table = commune::getTableName('commune_messages', $this->_options['commune_id']);
     $user_table = commune::getTableName('commune_users_messages', $this->_options['commune_id'], false, true);
     return array('resource_id' => $this->_options['theme_id'], 'comments' => array('insert_table' => $table, 'table' => 'commune_messages', 'fields' => array('id' => 'id', 'resource' => 'theme_id', 'author' => 'user_id', 'parent_id' => 'parent_id', 'parent_id2' => 'parent_id', 'msgtext' => 'msgtext', 'yt' => 'youtube_link', 'created_time' => 'created_time', 'modified' => 'modified_id', 'modified_time' => 'modified_time', 'deleted' => 'deleted_id', 'deleted_time' => 'deleted_time', 'reason' => 'deleted_reason', 'rating' => 'rating', 'access' => 'mod_access', 'mod_access' => 'mod_access', 'moderator_status' => 'moderator_status'), 'expr' => array('parent_id' => $this->_resource_id ? "CASE WHEN commune_messages.parent_id = {$this->_resource_id} THEN NULL ELSE commune_messages.parent_id END" : null), 'where' => array("commune_messages.parent_id IS NOT NULL"), 'set' => 'SET enable_sort = false; SET enable_hashjoin = false'), 'attaches' => array('file_table' => 'file_commune', 'table' => 'file_commune', 'fields' => array('comment' => 'src_id', 'small' => 'small', 'inline' => 'inline', 'sort' => 'sort')), 'users' => array('table' => $user_table, 'fields' => array('user' => 'user_id', 'comment' => 'message_id', 'lvt' => 'last_viewed_time', 'hidden' => 'hidden_threads', 'user_rating' => 'rating'), 'inner_fields' => array('cm.warn_count' => 'warn_count', 'cm.commune_id' => 'resource_id', 'cm.id' => 'member_id', 'cm.is_banned' => 'is_banned'), 'inner' => array("INNER JOIN commune_themes ct ON ct.id = commune_messages.theme_id", "LEFT JOIN commune_members cm ON cm.user_id = commune_messages.user_id AND cm.commune_id = ct.commune_id")), 'moderation_rec_type' => user_content::MODER_COMMUNITY, 'moderation_sort_order' => 3, 'permissions' => hasPermissions('communes') || hasPermissions('comments'));
 }