Przeglądaj źródła

Ticket #4589 - Timeline: mysql error when FULLTEXT search is enabled.

AntonLV 2 lat temu
rodzic
commit
81b1c2d1d1

+ 7 - 1
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -9,6 +9,8 @@
     <string name="_bx_timeline_options_category_card"><![CDATA[Карточка]]></string>
     <string name="_bx_timeline_options_category_cache"><![CDATA[Кэш]]></string>
     <string name="_bx_timeline_options_category_post"><![CDATA[Создание сообщения]]></string>
+    <string name="_bx_timeline_options_category_feed_hot"><![CDATA['Горячая' хроника]]></string>
+    <string name="_bx_timeline_options_category_feed_for_you"><![CDATA[Лента 'Для Вас']]></string>
 
     <string name="_bx_timeline_option_enable_auto_approve"><![CDATA[Автоматически активировать сообщение после создания]]></string>
     <string name="_bx_timeline_option_enable_edit"><![CDATA[Разрешить пользователю изменять собственные сообщения]]></string>
@@ -28,6 +30,7 @@
     <string name="_bx_timeline_option_rss_length"><![CDATA[Количество элементов в RSS-ленте]]></string>
     <string name="_bx_timeline_option_live_updates_length"><![CDATA[Количество элементов в выборке авто обновления]]></string>
     <string name="_bx_timeline_option_events_hide"><![CDATA[Показывать события]]></string>
+    <string name="_bx_timeline_option_searchable_fields"><![CDATA[Поля для поиска по ключевому слову]]></string>
     <string name="_bx_timeline_option_enable_brief_cards"><![CDATA[Включить лаконичные карточки]]></string>
     <string name="_bx_timeline_option_title_chars"><![CDATA[Количество символов в автогенерируемом заголовке сообщения]]></string>
     <string name="_bx_timeline_option_title_chars_short"><![CDATA[Количество символов в автогенерируемом укороченном заголовке сообщения]]></string>
@@ -74,7 +77,7 @@
     <string name="_bx_timeline_option_extenals_every_feed_preload"><![CDATA[Показывать внешнее событие как каждое N-е в ленте контекст (профиль) + подписки при включенной 'Бесконечной прокрутке']]></string>
     <string name="_bx_timeline_option_extenals_every_hot_preload"><![CDATA[Показывать внешнее событие как каждое N-е в hot timeline при включенной 'Бесконечной прокрутке']]></string>
     <string name="_bx_timeline_option_extenals_every_feed_and_hot_preload"><![CDATA[Показывать внешнее событие как каждое N-е в ленте 'Для тебя' при включенной 'Бесконечной прокрутке']]></string>
-    <string name="_bx_timeline_option_for_you_sources"><![CDATA[Лента «Для Вас» состоит из]]></string>
+    <string name="_bx_timeline_option_for_you_sources"><![CDATA[Лента 'Для Вас' состоит из]]></string>
     <string name="_bx_timeline_option_for_you_sources_err"><![CDATA[Для фида должен быть включен хотя бы один источник.]]></string>
     <string name="_bx_timeline_option_for_you_sources_feed"><![CDATA[Лента контекст (профиль) + подписки]]></string>
     <string name="_bx_timeline_option_for_you_sources_hot"><![CDATA['Горячая' хроника]]></string>
@@ -413,6 +416,9 @@
     <string name="_bx_timeline_txt_some_text_here"><![CDATA[Поделитесь своими мыслями]]></string>
     <string name="_bx_timeline_txt_show"><![CDATA[Показать]]></string>
     <string name="_bx_timeline_txt_new_content"><![CDATA[Новый контент]]></string>
+    <string name="_bx_timeline_txt_filters"><![CDATA[Фильтры]]></string>
+    <string name="_bx_timeline_txt_title"><![CDATA[Заголовок]]></string>
+    <string name="_bx_timeline_txt_description"><![CDATA[Описание]]></string>
 
     <string name="_bx_timeline_txt_do_repost"><![CDATA[Сделать репост]]></string>
     <string name="_bx_timeline_txt_do_repost_with"><![CDATA[Сделать репост с текстом]]></string>

+ 14 - 6
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -101,6 +101,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
             // database tables
             'TABLE_ENTRIES' => $aModule['db_prefix'] . 'events',
+            'TABLE_ENTRIES_FULLTEXT' => 'search_fields',
 
             // database fields
             'FIELD_ID' => 'id',
@@ -141,6 +142,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
             // some params
             'PARAM_AUTO_APPROVE' => $this->_sName . '_enable_auto_approve',
+            'PARAM_SEARCHABLE_FIELDS' => $this->_sName . '_searchable_fields',
 
             // objects
             'OBJECT_STORAGE' => $this->_sName . '_photos',
@@ -161,6 +163,12 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'OBJECT_UPLOADER_VIDEO_RECORD' => $this->_sName . '_record_video',
             'OBJECT_UPLOADER_FILE_HTML5' => $this->_sName . '_html5_file',
             'OBJECT_UPLOADER_FILE_SIMPLE' => $this->_sName . '_simple_file',
+            'OBJECT_FORM_ENTRY' => $this->_sName . '_post',
+            'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => $this->_sName . '_post_view',
+            'OBJECT_FORM_ENTRY_DISPLAY_ADD' => $this->_sName . '_post_add',
+            'OBJECT_FORM_ENTRY_DISPLAY_ADD_PUBLIC' => $this->_sName . '_post_add_public',
+            'OBJECT_FORM_ENTRY_DISPLAY_ADD_PROFILE' => $this->_sName . '_post_add_profile',
+            'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => $this->_sName . '_post_edit',
             'OBJECT_GRID_ADMINISTRATION' => $this->_sName . '_administration',
             'OBJECT_GRID_COMMON' => $this->_sName . '_common',
             'OBJECT_GRID_MUTE' => $this->_sName . '_mute',
@@ -269,14 +277,14 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'menu_item_meta' => $this->_sName . '_menu_item_meta',
             'menu_post_attachments' => $this->CNF['OBJECT_MENU_ENTRY_ATTACHMENTS'],
 
-            'form_post' => $this->_sName . '_post',
+            'form_post' => $this->CNF['OBJECT_FORM_ENTRY'],
             'form_attach_link' => $this->_sName . '_attach_link',
             'form_repost' => $this->_sName . '_repost',
-            'form_display_post_add' => $this->_sName . '_post_add',
-            'form_display_post_add_public' => $this->_sName . '_post_add_public',
-            'form_display_post_add_profile' => $this->_sName . '_post_add_profile',
-            'form_display_post_edit' => $this->_sName . '_post_edit',
-            'form_display_post_view' => $this->_sName . '_post_view',
+            'form_display_post_add' => $this->CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'],
+            'form_display_post_view' => $this->CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW'],
+            'form_display_post_add_public' => $this->CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD_PUBLIC'],
+            'form_display_post_add_profile' => $this->CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD_PROFILE'],
+            'form_display_post_edit' => $this->CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'],
             'form_display_attach_link_add' => $this->_sName . '_attach_link_add',
             'form_display_repost_with' => $this->_sName . '_repost_with',
             'form_display_repost_to' => $this->_sName . '_repost_to',

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -1176,7 +1176,7 @@ class BxTimelineDb extends BxBaseModNotificationsDb
 
                 $bForYou = $aParams['type'] == BX_TIMELINE_TYPE_FOR_YOU;
                 $aForYouSources = $bForYou ? $this->_oConfig->getForYouSources() : [];
-//var_dump($bForYou, $aForYouSources); exit;
+
                 $mixedJoinSubclause = [];
                 $mixedWhereSubclause = [];
 

+ 22 - 0
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1520,6 +1520,28 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return $this->_oTemplate->unit($aEvent, true, $sUnitTemplate);
     }
+    
+    public function serviceGetSearchableFields ($aInputsAdd = [])
+    {
+        $CNF = $this->_oConfig->CNF;
+
+        foreach(['PUBLIC', 'PROFILE'] as $sDisplay) {
+            $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD_' . $sDisplay], $this->_oTemplate);
+            if(!$oForm || empty($oForm->aInputs))
+                continue;
+
+            $aInputsAdd = array_merge($aInputsAdd, $oForm->aInputs);
+        }
+
+        $aResult = parent::serviceGetSearchableFields($aInputsAdd);
+        if(isset($aResult['text']))
+            unset($aResult['text']);
+
+        return array_merge($aResult, [
+            $CNF['FIELD_TITLE'] => _t('_bx_timeline_txt_title'),
+            $CNF['FIELD_TEXT'] => _t('_bx_timeline_txt_description'),
+        ]);
+    }
 
     /**
      * @page service Service Calls

+ 10 - 0
modules/boonex/timeline/classes/BxTimelineResponse.php

@@ -279,6 +279,16 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
         return $this->_oModule->serviceFeedsMenuDelete($sName);
     }
 
+    protected function _processSystemSaveSetting($oAlert)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if($CNF['PARAM_SEARCHABLE_FIELDS'] != $oAlert->aExtras['option'])
+            return;
+
+        $this->_oModule->_oDb->alterFulltextIndex();
+    }
+
     protected function _processAccountConfirm($oAlert)
     {
         $this->_clearCache();

+ 6 - 1
modules/boonex/timeline/classes/BxTimelineSearchResult.php

@@ -24,7 +24,7 @@ class BxTimelineSearchResult extends BxBaseModNotificationsSearchResult
             'title' => _t('_bx_timeline_page_title_browse'),
             'table' => 'bx_timeline_events',
             'ownFields' => array('id', 'owner_id', 'type', 'action', 'object_id', 'object_privacy_view', 'content', 'title', 'description', 'views', 'rate', 'votes', 'rrate', 'rvotes', 'score', 'sc_up', 'sc_down', 'comments', 'reports', 'reposts', 'date', 'status', 'status_admin', 'pinned', 'sticked', 'promoted'),
-            'searchFields' => array('title'),
+            'searchFields' => array(),
             'restriction' => array(
                 'internal' => array('value' => 'timeline_common_post', 'field' => 'type', 'operator' => '='),
                 'status' => array('value' => BX_TIMELINE_STATUS_ACTIVE, 'field' => 'status', 'operator' => '='),
@@ -39,6 +39,11 @@ class BxTimelineSearchResult extends BxBaseModNotificationsSearchResult
         $this->sFilterName = 'bx_timeline_filter';
         $this->oModule = $this->getMain();
 
+        $CNF = &$this->oModule->_oConfig->CNF;
+
+        $sSearchFields = getParam($CNF['PARAM_SEARCHABLE_FIELDS']);
+        $this->aCurrent['searchFields'] = !empty($sSearchFields) ? explode(',', $sSearchFields) : '';
+
         switch ($sMode) {
 
             case '': // search results

+ 3 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -30,6 +30,7 @@
     <string name="_bx_timeline_option_rss_length"><![CDATA[The length of RSS feed]]></string>
     <string name="_bx_timeline_option_live_updates_length"><![CDATA[The length of Live Updates selection]]></string>
     <string name="_bx_timeline_option_events_hide"><![CDATA[Show events]]></string>
+    <string name="_bx_timeline_option_searchable_fields"><![CDATA[Searchable fields for keyword search]]></string>
     <string name="_bx_timeline_option_enable_brief_cards"><![CDATA[Enable brief cards]]></string>
     <string name="_bx_timeline_option_title_chars"><![CDATA[Number of characters in auto-generated update's title]]></string>
     <string name="_bx_timeline_option_title_chars_short"><![CDATA[Number of characters in auto-generated update's short title]]></string>
@@ -431,6 +432,8 @@
     <string name="_bx_timeline_txt_show"><![CDATA[Show]]></string>
     <string name="_bx_timeline_txt_new_content"><![CDATA[New content]]></string>
     <string name="_bx_timeline_txt_filters"><![CDATA[Filters]]></string>
+    <string name="_bx_timeline_txt_title"><![CDATA[Title]]></string>
+    <string name="_bx_timeline_txt_description"><![CDATA[Description]]></string>
 
     <string name="_bx_timeline_txt_do_repost"><![CDATA[Repost]]></string>
     <string name="_bx_timeline_txt_do_repost_with"><![CDATA[Repost with Text]]></string>

+ 3 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -305,7 +305,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_timeline_enable_content_own_actions', '', @iCategId, '_bx_timeline_option_enable_content_own_actions', 'checkbox', '', '', '', '', 4),
 ('bx_timeline_enable_repost_own_actions', 'on', @iCategId, '_bx_timeline_option_enable_repost_own_actions', 'checkbox', '', '', '', '', 5),
 ('bx_timeline_enable_hide_upon_delete', '', @iCategId, '_bx_timeline_option_enable_hide_upon_delete', 'checkbox', '', '', '', '', 6),
-('bx_timeline_events_hide', CONCAT_WS(',', @iHdrIdComment), @iCategId, '_bx_timeline_option_events_hide', 'rlist', '', '', '', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:21:"get_actions_checklist";}', 7);
+('bx_timeline_events_hide', CONCAT_WS(',', @iHdrIdComment), @iCategId, '_bx_timeline_option_events_hide', 'rlist', '', '', '', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:21:"get_actions_checklist";}', 7),
+('bx_timeline_searchable_fields', 'title,description', @iCategId, '_bx_timeline_option_searchable_fields', 'list', '', '', '', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:21:"get_searchable_fields";}', 8);
 
 -- Category: Browse
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
@@ -518,6 +519,7 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 ('system', 'clear_cache', @iHandler),
 ('system', 'enable', @iHandler),
 ('system', 'disable', @iHandler),
+('system', 'save_setting', @iHandler),
 
 ('account', 'confirm', @iHandler),
 ('account', 'unconfirm', @iHandler),