AntonLV hace 7 años
padre
commit
e59bae24fd

+ 33 - 0
modules/boonex/channels/classes/BxCnlAlertsResponse.php

@@ -21,6 +21,12 @@ class BxCnlAlertsResponse extends BxBaseModGroupsAlertsResponse
     {
     {
         parent::response($oAlert);
         parent::response($oAlert);
 
 
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);           	
+        if(method_exists($this, $sMethod))
+            return $this->$sMethod($oAlert);
+        
         $aProfileModulesAutofollowLabels = array('bx_persons', 'bx_organizations');
         $aProfileModulesAutofollowLabels = array('bx_persons', 'bx_organizations');
         if (in_array($oAlert->sUnit, $aProfileModulesAutofollowLabels) && in_array($oAlert->sAction, array('added', 'edited'))) {
         if (in_array($oAlert->sUnit, $aProfileModulesAutofollowLabels) && in_array($oAlert->sAction, array('added', 'edited'))) {
             $this->_oModule->followLabels($oAlert->sUnit, $oAlert->iObject);
             $this->_oModule->followLabels($oAlert->sUnit, $oAlert->iObject);
@@ -59,6 +65,33 @@ class BxCnlAlertsResponse extends BxBaseModGroupsAlertsResponse
             }
             }
         }
         }
     }
     }
+
+    protected function _processSystemSaveSetting($oAlert)
+    {
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        switch($oAlert->aExtras['option']) {
+            case $CNF['PARAM_DEFAULT_AUTHOR']:
+                $bChanged = $oAlert->aExtras['value'] != $oAlert->aExtras['value_prior'];
+                if($bChanged) {
+                    $oStudioWidget = new BxTemplStudioWidgets($this->MODULE);
+                    if($oStudioWidget)
+                        $oStudioWidget->updateCache();
+                }
+
+                if(empty($oAlert->aExtras['value']) || !$bChanged)
+                    break;
+
+                $aSet = array($CNF['FIELD_AUTHOR'] => (int)$oAlert->aExtras['value']);
+                $this->_oModule->_oDb->updateEntriesBy($aSet, array($CNF['FIELD_AUTHOR'] => (int)$oAlert->aExtras['value_prior']));
+
+                $aOperators = BxDolAccountQuery::getInstance()->getOperators();
+                if(count($aOperators) > 0)
+                     $this->_oModule->_oDb->updateEntriesBy($aSet, array($CNF['FIELD_AUTHOR'] => BxDolProfile::getInstanceByAccount(array_shift($aOperators))->id()));
+                break;
+                
+        }
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 1 - 0
modules/boonex/channels/classes/BxCnlConfig.php

@@ -62,6 +62,7 @@ class BxCnlConfig extends BxBaseModProfileConfig
             'URL_MANAGE_COMMON' => 'page.php?i=channels-manage',
             'URL_MANAGE_COMMON' => 'page.php?i=channels-manage',
             'URL_MANAGE_ADMINISTRATION' => 'page.php?i=channels-administration',
             'URL_MANAGE_ADMINISTRATION' => 'page.php?i=channels-administration',
 
 
+            'PARAM_DEFAULT_AUTHOR' => 'bx_channels_default_author',
             'PARAM_NUM_RSS' => 'bx_channels_num_rss',
             'PARAM_NUM_RSS' => 'bx_channels_num_rss',
             'PARAM_NUM_CONNECTIONS_QUICK' => 'bx_channels_num_connections_quick',
             'PARAM_NUM_CONNECTIONS_QUICK' => 'bx_channels_num_connections_quick',
 
 

+ 43 - 10
modules/boonex/channels/classes/BxCnlModule.php

@@ -35,6 +35,8 @@ class BxCnlModule extends BxBaseModGroupsModule
      */
      */
     function processHashtag($sHashtag, $sModuleName, $iContentId, $iAuthorId)
     function processHashtag($sHashtag, $sModuleName, $iContentId, $iAuthorId)
     {
     {
+        $CNF = &$this->_oConfig->CNF;
+
         /*
         /*
          * Note! For now metatag object name is used here as module name, because usually it's equal to module's name. This should be changed in Ticket #1596
          * Note! For now metatag object name is used here as module name, because usually it's equal to module's name. This should be changed in Ticket #1596
          * For now if module cannot be created then a channel for such tag shouldn't be created too.
          * For now if module cannot be created then a channel for such tag shouldn't be created too.
@@ -52,17 +54,18 @@ class BxCnlModule extends BxBaseModGroupsModule
 
 
         $aCheck = checkActionModule($this->_iProfileId, 'create channel auto', $this->getName(), false);
         $aCheck = checkActionModule($this->_iProfileId, 'create channel auto', $this->getName(), false);
         $mixedCnlId = $this->_oDb->getChannelIdByName($sHashtag);
         $mixedCnlId = $this->_oDb->getChannelIdByName($sHashtag);
-        if (empty($mixedCnlId) && ($aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)){
-            $CNF = &$this->_oConfig->CNF;
-            $oAccountQuery = BxDolAccountQuery::getInstance();
-            $aOperators = $oAccountQuery->getOperators();
-            if(count($aOperators) > 0){
-                $oProfile = BxDolProfile::getInstanceByAccount($aOperators[0]);
-                $aContent = $this->serviceEntityAdd($oProfile->id(), array($CNF['FIELD_NAME'] => $sHashtag));
-                checkActionModule($this->_iProfileId, 'create channel auto', $this->getName(), true);
-                if (isset($aContent['content']) && isset($aContent['content']['id']))
-                    $mixedCnlId = $aContent['content']['id'];
+        if(empty($mixedCnlId) && ($aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)) {
+            $iProfileId = (int)$this->_oDb->getParam($CNF['PARAM_DEFAULT_AUTHOR']);
+            if(empty($iProfileId)) {
+                $aOperators = BxDolAccountQuery::getInstance()->getOperators();
+                if(count($aOperators) > 0)
+                    $iProfileId = BxDolProfile::getInstanceByAccount(array_shift($aOperators))->id();
             }
             }
+
+            $aContent = $this->serviceEntityAdd($iProfileId, array($CNF['FIELD_NAME'] => $sHashtag));
+            checkActionModule($this->_iProfileId, 'create channel auto', $this->getName(), true);
+            if(isset($aContent['content']) && isset($aContent['content']['id']))
+                $mixedCnlId = $aContent['content']['id'];
         }
         }
 
 
         if(empty($mixedCnlId) || (int)$this->_oDb->checkContentInChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId) != 0)
         if(empty($mixedCnlId) || (int)$this->_oDb->checkContentInChannel($iContentId, $mixedCnlId, $sModuleName, $iAuthorId) != 0)
@@ -114,6 +117,36 @@ class BxCnlModule extends BxBaseModGroupsModule
         return $this->_oDb->removeContentFromChannel($iContentId, $sModuleName);
         return $this->_oDb->removeContentFromChannel($iContentId, $sModuleName);
     }
     }
 
 
+    public function serviceGetWidgetNotices()
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $iResult = 0;
+        if(empty($this->_oDb->getParam($CNF['PARAM_DEFAULT_AUTHOR'])))
+            $iResult += 1;
+
+        return $iResult;
+    }
+
+    public function serviceGetOptionsDefaultAuthor()
+    {
+        $aResult = array(
+            array('key' => '', 'value' => _t('_Select_one'))
+        );
+
+        $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
+        foreach($aAccountsIds as $iAccountId) {
+            $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds();
+            foreach($aProfilesIds as $iProfileId)
+                $aResult[] = array(
+                    'key' => $iProfileId,
+                    'value' => BxDolProfile::getInstance($iProfileId)->getDisplayName()
+                );
+        }
+
+        return $aResult;
+    }
+
     public function serviceEntityBreadcrumb($iContentId = 0)
     public function serviceEntityBreadcrumb($iContentId = 0)
     {
     {
     	if(!$iContentId)
     	if(!$iContentId)

+ 9 - 7
modules/boonex/channels/install/langs/en.xml

@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources name="en" flag="gb" title="English">
 <resources name="en" flag="gb" title="English">
-	<string name="_bx_channels"><![CDATA[Channels]]></string>
-	<string name="_bx_channels_cmts"><![CDATA[Channels' Comments]]></string>
-	
-	<string name="_bx_channels_option_num_connections_quick"><![CDATA[Number of items in friends block]]></string>
-	<string name="_bx_channels_option_per_page_browse"><![CDATA[Number of items per page]]></string>
-	<string name="_bx_channels_option_num_rss"><![CDATA[Number of items in RSS feed]]></string>
+    <string name="_bx_channels"><![CDATA[Channels]]></string>
+    <string name="_bx_channels_cmts"><![CDATA[Channels' Comments]]></string>
+
+    <string name="_bx_channels_option_default_author"><![CDATA[Default author for automatically created channels]]></string>
+    <string name="_bx_channels_option_num_connections_quick"><![CDATA[Number of items in friends block]]></string>
+    <string name="_bx_channels_option_per_page_browse"><![CDATA[Number of items per page]]></string>
+    <string name="_bx_channels_option_num_rss"><![CDATA[Number of items in RSS feed]]></string>
     <string name="_bx_channels_option_searchable_fields"><![CDATA[Searchable fields]]></string>
     <string name="_bx_channels_option_searchable_fields"><![CDATA[Searchable fields]]></string>
     <string name="_bx_channels_option_labels_autofollow"><![CDATA[Auto-follow channels when used as labels in profiles]]></string>
     <string name="_bx_channels_option_labels_autofollow"><![CDATA[Auto-follow channels when used as labels in profiles]]></string>
-	
+
 	<string name="_bx_channels_form_profile"><![CDATA[Channels]]></string>
 	<string name="_bx_channels_form_profile"><![CDATA[Channels]]></string>
 	<string name="_bx_channels_form_profile_display_add"><![CDATA[Add Channel]]></string>
 	<string name="_bx_channels_form_profile_display_add"><![CDATA[Add Channel]]></string>
 	<string name="_bx_channels_form_profile_display_edit"><![CDATA[Edit Channel]]></string>
 	<string name="_bx_channels_form_profile_display_edit"><![CDATA[Edit Channel]]></string>
@@ -227,6 +228,7 @@
 	<string name="_bx_channels_txt_sample_vote_single"><![CDATA[vote to channel]]></string>
 	<string name="_bx_channels_txt_sample_vote_single"><![CDATA[vote to channel]]></string>
         <string name="_bx_channels_txt_sample_score_up_single"><![CDATA[score up vote to channel]]></string>
         <string name="_bx_channels_txt_sample_score_up_single"><![CDATA[score up vote to channel]]></string>
         <string name="_bx_channels_txt_sample_score_down_single"><![CDATA[score down vote to channel]]></string>
         <string name="_bx_channels_txt_sample_score_down_single"><![CDATA[score down vote to channel]]></string>
+        <string name="_bx_channels_msg_empty_author"><![CDATA['Default author for automatically created channels' is empty. You need to select some profile in this setting.]]></string>
 
 
     <string name="_bx_channels_txt_ntfs_timeline_post_common"><![CDATA[New post <b class="bx-ntfs-content-entry">{subentry_sample}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b> channel timeline]]></string>
     <string name="_bx_channels_txt_ntfs_timeline_post_common"><![CDATA[New post <b class="bx-ntfs-content-entry">{subentry_sample}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b> channel timeline]]></string>
     <string name="_bx_channels_ntfs_txt_subobject_added"><![CDATA[New content <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b> channel]]></string>
     <string name="_bx_channels_ntfs_txt_subobject_added"><![CDATA[New content <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b> channel]]></string>

+ 9 - 8
modules/boonex/channels/install/sql/enable.sql

@@ -10,14 +10,15 @@ INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
 VALUES (@iTypeId, 'bx_channels', '_bx_channels', 1);
 VALUES (@iTypeId, 'bx_channels', '_bx_channels', 1);
 SET @iCategId = LAST_INSERT_ID();
 SET @iCategId = LAST_INSERT_ID();
 
 
-INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
-('bx_channels_num_connections_quick', '6', @iCategId, '_bx_channels_option_num_connections_quick', 'digit', '', '', '', 10),
-('bx_channels_per_page_browse', '24', @iCategId, '_bx_channels_option_per_page_browse', 'digit', '', '', '', 11),
-('bx_channels_num_rss', '10', @iCategId, '_bx_channels_option_num_rss', 'digit', '', '', '', 12),
-('bx_channels_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', 15),
-('bx_channels_per_page_browse_recommended', '10', @iCategId, '_sys_option_per_page_browse_recommended', 'digit', '', '', '', 16),
-('bx_channels_searchable_fields', 'channel_name', @iCategId, '_bx_channels_option_searchable_fields', 'list', 'a:2:{s:6:"module";s:11:"bx_channels";s:6:"method";s:21:"get_searchable_fields";}', '', '', 30),
-('bx_channels_labels_autofollow', 'on', @iCategId, '_bx_channels_option_labels_autofollow', 'checkbox', '', '', '', 40);
+INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `extra`, `check`, `check_params`, `check_error`, `order`) VALUES
+('bx_channels_default_author', '', @iCategId, '_bx_channels_option_default_author', 'select', 'a:2:{s:6:"module";s:11:"bx_channels";s:6:"method";s:26:"get_options_default_author";}', '', '', '', 1),
+('bx_channels_num_connections_quick', '6', @iCategId, '_bx_channels_option_num_connections_quick', 'digit', '', '', '', '', 10),
+('bx_channels_per_page_browse', '24', @iCategId, '_bx_channels_option_per_page_browse', 'digit', '', '', '', '', 11),
+('bx_channels_num_rss', '10', @iCategId, '_bx_channels_option_num_rss', 'digit', '', '', '', '', 12),
+('bx_channels_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', '', 15),
+('bx_channels_per_page_browse_recommended', '10', @iCategId, '_sys_option_per_page_browse_recommended', 'digit', '', '', '', '', 16),
+('bx_channels_searchable_fields', 'channel_name', @iCategId, '_bx_channels_option_searchable_fields', 'list', 'a:2:{s:6:"module";s:11:"bx_channels";s:6:"method";s:21:"get_searchable_fields";}', '', '', '', 30),
+('bx_channels_labels_autofollow', 'on', @iCategId, '_bx_channels_option_labels_autofollow', 'checkbox', '', '', '', '', 40);
 
 
 
 
 -- PAGES
 -- PAGES

+ 2 - 3
modules/boonex/channels/install/sql/install.sql

@@ -288,7 +288,6 @@ SET @iPageId = LAST_INSERT_ID();
 SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
 SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
 SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
 SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
 INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
 INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
-(@iPageId, 'bx_channels', '{url_studio}module.php?name=bx_channels', '', 'bx_channels@modules/boonex/channels/|std-icon.svg', '_bx_channels', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
+(@iPageId, 'bx_channels', '{url_studio}module.php?name=bx_channels', '', 'bx_channels@modules/boonex/channels/|std-icon.svg', '_bx_channels', 'a:4:{s:6:"module";s:11:"bx_channels";s:6:"method";s:18:"get_widget_notices";s:6:"params";a:0:{}s:5:"class";s:6:"Module";}', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
 INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
 INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
-(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));
-
+(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));

+ 6 - 4
modules/boonex/russian/data/langs/bx_channels/ru.xml

@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources name="ru" flag="ru" title="Russian">
 <resources name="ru" flag="ru" title="Russian">
-	<string name="_bx_channels"><![CDATA[Каналы]]></string>
-	<string name="_bx_channels_cmts"><![CDATA[Каналы - Комментарии]]></string>
+    <string name="_bx_channels"><![CDATA[Каналы]]></string>
+    <string name="_bx_channels_cmts"><![CDATA[Каналы - Комментарии]]></string>
 
 
-	<string name="_bx_channels_option_num_connections_quick"><![CDATA[Количество элементов в блоке друзей]]></string>
-	<string name="_bx_channels_option_per_page_browse"><![CDATA[Количество элементов на странице]]></string>
+    <string name="_bx_channels_option_default_author"><![CDATA[Автор по умолчанию для автоматически создаваемых каналов]]></string>
+    <string name="_bx_channels_option_num_connections_quick"><![CDATA[Количество элементов в блоке друзей]]></string>
+    <string name="_bx_channels_option_per_page_browse"><![CDATA[Количество элементов на странице]]></string>
     <string name="_bx_channels_option_num_rss"><![CDATA[Количество элементов в ленте RSS]]></string>
     <string name="_bx_channels_option_num_rss"><![CDATA[Количество элементов в ленте RSS]]></string>
     <string name="_bx_channels_option_searchable_fields"><![CDATA[Поля для поиска]]></string>
     <string name="_bx_channels_option_searchable_fields"><![CDATA[Поля для поиска]]></string>
     <string name="_bx_channels_option_labels_autofollow"><![CDATA[Автоматически подписывать на каналы указанные в метках профайла]]></string>
     <string name="_bx_channels_option_labels_autofollow"><![CDATA[Автоматически подписывать на каналы указанные в метках профайла]]></string>
@@ -227,6 +228,7 @@
     <string name="_bx_channels_txt_sample_vote_single"><![CDATA[голос за канал]]></string>
     <string name="_bx_channels_txt_sample_vote_single"><![CDATA[голос за канал]]></string>
     <string name="_bx_channels_txt_sample_score_up_single"><![CDATA[голос за канал]]></string>
     <string name="_bx_channels_txt_sample_score_up_single"><![CDATA[голос за канал]]></string>
     <string name="_bx_channels_txt_sample_score_down_single"><![CDATA[голос против канала]]></string>
     <string name="_bx_channels_txt_sample_score_down_single"><![CDATA[голос против канала]]></string>
+    <string name="_bx_channels_msg_empty_author"><![CDATA['Автор по умолчанию для автоматически создаваемых каналов' пуст. Вам нужно выбрать профиль в этой настройке.]]></string>
 	
 	
     <string name="_bx_channels_txt_ntfs_timeline_post_common"><![CDATA[В канале <b class="bx-ntfs-content-profile">{owner_name}</b> новая публикация <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
     <string name="_bx_channels_txt_ntfs_timeline_post_common"><![CDATA[В канале <b class="bx-ntfs-content-profile">{owner_name}</b> новая публикация <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
     <string name="_bx_channels_ntfs_txt_subobject_added"><![CDATA[В канале <b class="bx-ntfs-content-profile">{owner_name}</b> новая публикация <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_channels_ntfs_txt_subobject_added"><![CDATA[В канале <b class="bx-ntfs-content-profile">{owner_name}</b> новая публикация <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>

+ 12 - 6
studio/classes/BxDolStudioSettings.php

@@ -259,8 +259,8 @@ class BxDolStudioSettings extends BxTemplStudioPage
             foreach($aOptions as $aOption) {
             foreach($aOptions as $aOption) {
                 $aData[$aOption['name']] = $this->getSubmittedValue($aOption, $oForm);
                 $aData[$aOption['name']] = $this->getSubmittedValue($aOption, $oForm);
                 if($aData[$aOption['name']] === false && !empty($this->sErrorMessage)) {
                 if($aData[$aOption['name']] === false && !empty($this->sErrorMessage)) {
-                	$this->sCategory = $sCategory;
-					return $this->getJsResult(_t('_adm_stg_err_save_error_message', _t($aOption['caption']), _t($this->sErrorMessage)), false, false, '', $sEvalRenewToken);
+                    $this->sCategory = $sCategory;
+                    return $this->getJsResult(_t('_adm_stg_err_save_error_message', _t($aOption['caption']), _t($this->sErrorMessage)), false, false, '', $sEvalRenewToken);
                 }
                 }
 
 
                 if(!empty($aOption['check'])) {
                 if(!empty($aOption['check'])) {
@@ -290,11 +290,17 @@ class BxDolStudioSettings extends BxTemplStudioPage
                 else
                 else
                     $aData[$aOption['name']] = $this->getEmptyValue($aOption);
                     $aData[$aOption['name']] = $this->getEmptyValue($aOption);
 
 
+                $mixedValue = $this->oDb->getParam($aOption['name']);
                 if($this->oDb->setParam($aOption['name'], $aData[$aOption['name']], $iMixId)) {
                 if($this->oDb->setParam($aOption['name'], $aData[$aOption['name']], $iMixId)) {
-                	$aCategoryInfo = array();
-		            $this->oDb->getCategories(array('type' => 'by_name', 'value' => $sCategory), $aCategoryInfo, false);
-
-	        		bx_alert('system', 'save_setting', 0, 0, array('category' => $aCategoryInfo, 'option' => $aOption['name'], 'value' => $aData[$aOption['name']]));
+                    $aCategoryInfo = array();
+                    $this->oDb->getCategories(array('type' => 'by_name', 'value' => $sCategory), $aCategoryInfo, false);
+
+                    bx_alert('system', 'save_setting', 0, 0, array(
+                        'category' => $aCategoryInfo, 
+                        'option' => $aOption['name'], 
+                        'value' => $aData[$aOption['name']],
+                        'value_prior' => $mixedValue
+                    ));
                 }
                 }
             }
             }
         }
         }