AntonLV преди 7 години
родител
ревизия
b6c1850191

+ 4 - 1
install/sql/system.sql

@@ -481,8 +481,11 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 
 (@iCategoryId, 'sys_per_page_search_keyword_single', '_adm_stg_cpt_option_sys_per_page_search_keyword_single', '24', 'digit', '', '', '', 20),
 (@iCategoryId, 'sys_per_page_search_keyword_plural', '_adm_stg_cpt_option_sys_per_page_search_keyword_plural', '3', 'digit', '', '', '', 21),
+
 (@iCategoryId, 'sys_metatags_hashtags_max', '_adm_stg_cpt_option_sys_metatags_hashtags_max', '9', 'digit', '', '', '', 30),
-(@iCategoryId, 'sys_metatags_mentions_max', '_adm_stg_cpt_option_sys_metatags_mentions_max', '9', 'digit', '', '', '', 31);
+(@iCategoryId, 'sys_metatags_mentions_max', '_adm_stg_cpt_option_sys_metatags_mentions_max', '9', 'digit', '', '', '', 31),
+
+(@iCategoryId, 'sys_profile_bot', '_adm_stg_cpt_option_sys_profile_bot', '', 'select', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:23:"get_options_profile_bot";s:5:"class";s:13:"TemplServices";}', '', '', 40);
 
 --
 -- CATEGORY: Storage

+ 19 - 3
modules/base/general/classes/BxBaseModGeneralAlertsResponse.php

@@ -63,14 +63,24 @@ class BxBaseModGeneralAlertsResponse extends BxDolAlertsResponse
         if(!isset($aContentInfo[$CNF['FIELD_STATUS']]) || $aContentInfo[$CNF['FIELD_STATUS']] != 'awaiting')
             return;
 
+        $iNow = time();
+        $bNotify = $iNow - $aContentInfo[$CNF['FIELD_ADDED']] > $this->_oModule->_oConfig->getDpnTime();
+        $iSystemBotProfileId = (int)getParam('sys_profile_bot');
+
         if(!$bResult) {
-            if((int)$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'failed'), array($CNF['FIELD_ID'] => $iContentId)) > 0)
+            if((int)$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'failed'), array($CNF['FIELD_ID'] => $iContentId)) > 0) {
                 $this->_oModule->onFailed($iContentId);
 
+                if($bNotify)
+                    bx_alert($this->_oModule->getName(), 'publish_failed', $aContentInfo[$CNF['FIELD_ID']], $iSystemBotProfileId, array(
+                        'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
+                        'privacy_view' => BX_DOL_PG_ALL
+                    ));
+            }
+
             return;
         }
 
-        $iNow = time();
         if(isset($CNF['FIELD_PUBLISHED']) && isset($aContentInfo[$CNF['FIELD_PUBLISHED']]) && $aContentInfo[$CNF['FIELD_PUBLISHED']] > $iNow)
             return;
 
@@ -87,9 +97,15 @@ class BxBaseModGeneralAlertsResponse extends BxDolAlertsResponse
 
         if(!$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'active'), array($CNF['FIELD_ID'] => $iContentId))) 
             return;
-        
+
         $this->_oModule->onPublished($iContentId);
 
+        if($bNotify)
+            bx_alert($this->_oModule->getName(), 'publish_succeeded', $aContentInfo[$CNF['FIELD_ID']], $iSystemBotProfileId, array(
+                'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
+                'privacy_view' => BX_DOL_PG_ALL
+            ));
+
         /*
          * Process metas.
          * Note. It's essential to process metas a the very end, 

+ 18 - 4
modules/base/general/classes/BxBaseModGeneralConfig.php

@@ -19,6 +19,13 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
     protected $_aJsObjects;
     protected $_aGridObjects;
 
+    /**
+     * Delayed Publishing Notification Time (in seconds)
+     * If video transcoding takes more than specified amount of time
+     * then author will be notified about publishing (failure).
+     */
+    protected $_iDpnTime;
+
     function __construct($aModule)
     {
         parent::__construct($aModule);
@@ -30,6 +37,8 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
         $this->_aJsClasses = array();
         $this->_aJsObjects = array();
         $this->_aGridObjects = array();
+
+        $this->_iDpnTime = 3600;
     }
 
     public function getObject($sType = '')
@@ -40,7 +49,7 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
         return isset($this->_aObjects[$sType]) ? $this->_aObjects[$sType] : '';
     }
 
-	public function getPrefix($sType = '')
+    public function getPrefix($sType = '')
     {
     	if(empty($sType))
             return $this->_aPrefixes;
@@ -48,19 +57,19 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
         return isset($this->_aPrefixes[$sType]) ? $this->_aPrefixes[$sType] : '';
     }
 
-	public function getJsClass($sType)
+    public function getJsClass($sType)
     {
         return isset($this->_aJsClasses[$sType]) ? $this->_aJsClasses[$sType] : '';
     }
 
     public function getJsObject($sType)
     {
-		return isset($this->_aJsObjects[$sType]) ? $this->_aJsObjects[$sType] : '';
+        return isset($this->_aJsObjects[$sType]) ? $this->_aJsObjects[$sType] : '';
     }
 
     public function getGridObject($sType)
     {
-		return isset($this->_aGridObjects[$sType]) ? $this->_aGridObjects[$sType] : '';
+        return isset($this->_aGridObjects[$sType]) ? $this->_aGridObjects[$sType] : '';
     }
 
     /*
@@ -87,6 +96,11 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
 
         return $sResult;
     }
+
+    public function getDpnTime()
+    {
+        return $this->_iDpnTime;
+    }
 }
 
 /** @} */

+ 31 - 2
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -805,7 +805,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if(BxDolPrivacy::getObjectInstance($sEventPrivacy) === false)
             $sEventPrivacy = '';
 
-        return array(
+        $aResult = array(
             'handlers' => array(
                 array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
                 array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
@@ -857,6 +857,25 @@ class BxBaseModGeneralModule extends BxDolModule
                 array('unit' => $sModule, 'action' => 'doVoteDown'),
             )
         );
+
+        if(!empty($this->_oConfig->CNF['FIELDS_DELAYED_PROCESSING'])) {
+            $aResult = array_merge($aResult, array(
+                'handlers' => array(
+                    array('group' => $sModule . '_object_publish_failed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_failed', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_failed', 'module_class' => 'Module', 'module_event_privacy' => ''),
+                    array('group' => $sModule . '_object_publish_succeeded', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_succeeded', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_succeeded', 'module_class' => 'Module', 'module_event_privacy' => ''),
+                ),
+                'settings' => array(
+                    array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_failed', 'types' => array('personal')),
+                    array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_succeeded', 'types' => array('personal')),
+                ),
+                'alerts' => array(
+                    array('unit' => $sModule, 'action' => 'publish_failed'),
+                    array('unit' => $sModule, 'action' => 'publish_succeeded'),
+                )
+            ));
+        }
+
+        return $aResult;
     }
 
     /**
@@ -898,7 +917,17 @@ class BxBaseModGeneralModule extends BxDolModule
         );
     }
 
-	/**
+    public function serviceGetNotificationsPostPublishFailed($aEvent)
+    {
+        return $this->serviceGetNotificationsPost($aEvent);
+    }
+
+    public function serviceGetNotificationsPostPublishSucceeded($aEvent)
+    {
+        return $this->serviceGetNotificationsPost($aEvent);
+    }
+
+    /**
      * Entry post comment for Notifications module
      */
     public function serviceGetNotificationsComment($aEvent)

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1414,6 +1414,7 @@
     <string name="_adm_stg_cpt_option_sys_metatags_hashtags_max"><![CDATA[Max number of hashtags per post]]></string>
     <string name="_adm_stg_cpt_option_sys_metatags_mentions_max"><![CDATA[Max number of mentions per post]]></string>
     <string name="_adm_stg_cpt_option_sys_search_keyword_min_len"><![CDATA[Keyword min length in site search]]></string>
+    <string name="_adm_stg_cpt_option_sys_profile_bot"><![CDATA[System bot profile]]></string>
 	<string name="_adm_stg_cpt_type_system"><![CDATA[System]]></string>
 	<string name="_adm_stg_scs_save"><![CDATA[Settings were successfully saved]]></string>
 	<string name="_adm_stg_err_save_error_message"><![CDATA[Error in '{0}': {1}]]></string>

+ 15 - 1
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -323,7 +323,21 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
         if($this->_isInContext($aEvent))
             return '_bx_ntfs_txt_object_added_in_context';
 
-    	return '_bx_ntfs_txt_object_added';
+        $sKey = '';
+        switch($aEvent['action']) {
+            case 'publish_failed':
+                $sKey = '_bx_ntfs_txt_object_publish_failed';
+                break;
+
+            case 'publish_succeeded':
+                $sKey = '_bx_ntfs_txt_object_publish_succeeded';
+                break;
+
+            default:
+                $sKey = '_bx_ntfs_txt_object_added';
+        }
+
+    	return $sKey;
     }
 
     protected function _getContentLink(&$aEvent)

+ 2 - 0
modules/boonex/notifications/install/langs/en.xml

@@ -97,6 +97,8 @@
     <string name="_bx_ntfs_txt_msg_no_results"><![CDATA[Empty]]></string>
     <string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{object_owner_name}</b> added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_publish_failed"><![CDATA[Failed to publish your {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_publish_succeeded"><![CDATA[Your {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> was published successfully]]></string>
     <string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 
     <string name="_bx_ntfs_push_new_event_subject"><![CDATA[New on "{0}"]]></string>

+ 2 - 0
modules/boonex/russian/data/langs/bx_notifications/ru.xml

@@ -91,6 +91,8 @@
     <string name="_bx_ntfs_txt_msg_no_results"><![CDATA[Пусто]]></string>
     <string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{object_owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> в <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_publish_failed"><![CDATA[Ошибка при публикации: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_publish_succeeded"><![CDATA[Успешная публикация: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 
     <string name="_bx_ntfs_push_new_event_subject"><![CDATA[Новое на сайте "{0}"]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1401,6 +1401,7 @@
     <string name="_adm_stg_cpt_option_sys_metatags_hashtags_max"><![CDATA[Максимальное число хэш-тагов в одной публикации]]></string>
     <string name="_adm_stg_cpt_option_sys_metatags_mentions_max"><![CDATA[Максимальное число упоминаний кого-либо в одной публикации]]></string>
     <string name="_adm_stg_cpt_option_sys_search_keyword_min_len"><![CDATA[Минимальная длина слова в поиске по сайту]]></string>
+    <string name="_adm_stg_cpt_option_sys_profile_bot"><![CDATA[Профиль системного бота]]></string>
 	<string name="_adm_stg_cpt_type_system"><![CDATA[Система]]></string>
 	<string name="_adm_stg_scs_save"><![CDATA[Настройки удачно сохранены]]></string>
 	<string name="_adm_stg_err_save_error_message"><![CDATA[Ошибка в '{0}': {1}]]></string>

+ 8 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1507,6 +1507,9 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
                 array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
 
+                array('group' => $sModule . '_object_publish_failed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_failed', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_failed', 'module_class' => 'Module'),
+                array('group' => $sModule . '_object_publish_succeeded', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_succeeded', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_succeeded', 'module_class' => 'Module'),
+
                 array('group' => $sModule . '_repost', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'repost', 'module_name' => $sModule, 'module_method' => 'get_notifications_repost', 'module_class' => 'Module'),
                 array('group' => $sModule . '_repost', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete_repost'),
 
@@ -1525,6 +1528,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             ),
             'settings' => array(
                 array('group' => 'content', 'unit' => $sModule, 'action' => 'post_common', 'types' => array('personal', 'follow_member', 'follow_context')),
+                array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_failed', 'types' => array('personal')),
+                array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_succeeded', 'types' => array('personal')),
                 array('group' => 'content', 'unit' => $sModule, 'action' => 'repost', 'types' => array('follow_member', 'follow_context')),
                 array('group' => 'comment', 'unit' => $sModule, 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
                 array('group' => 'vote', 'unit' => $sModule, 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
@@ -1534,8 +1539,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             ),
             'alerts' => array(
                 array('unit' => $sModule, 'action' => 'post_common'),
+                array('unit' => $sModule, 'action' => 'publish_failed'),
+                array('unit' => $sModule, 'action' => 'publish_succeeded'),
                 array('unit' => $sModule, 'action' => 'delete'),
-                
+
                 array('unit' => $sModule, 'action' => 'repost'),
                 array('unit' => $sModule, 'action' => 'delete_repost'),
                 

+ 23 - 4
modules/boonex/timeline/classes/BxTimelineResponse.php

@@ -164,14 +164,25 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
         if(!isset($aContentInfo[$CNF['FIELD_STATUS']]) || $aContentInfo[$CNF['FIELD_STATUS']] != 'awaiting')
             return;
 
+        $iNow = time();
+        $bNotify = $iNow - $aContentInfo[$CNF['FIELD_ADDED']] > $this->_oModule->_oConfig->getDpnTime();
+        $iSystemBotProfileId = (int)getParam('sys_profile_bot');
+        $iAuthorProfileId = $aContentInfo[$CNF['FIELD_' . ((int)$aContentInfo[$CNF['FIELD_SYSTEM']] == 0 ? 'OBJECT_ID' : 'OWNER_ID')]];
+
         if(!$bResult) {
-            if((int)$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'failed'), array($CNF['FIELD_ID'] => $iContentId)) > 0)
+            if((int)$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'failed'), array($CNF['FIELD_ID'] => $iContentId)) > 0) {
                 $this->_oModule->onFailed($iContentId);
 
+                if($bNotify)
+                    bx_alert($this->_oModule->getName(), 'publish_failed', $aContentInfo[$CNF['FIELD_ID']], $iSystemBotProfileId, array(
+                        'object_author_id' => $iAuthorProfileId,
+                        'privacy_view' => BX_DOL_PG_ALL
+                    ));
+            }
+
             return;
         }
 
-        $iNow = time();
         if(isset($CNF['FIELD_PUBLISHED']) && isset($aContentInfo[$CNF['FIELD_PUBLISHED']]) && $aContentInfo[$CNF['FIELD_PUBLISHED']] > $iNow)
             return;
 
@@ -181,8 +192,16 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
             if(!$oTranscoder->isFileReady($iMediaToCheck))
                 return;
 
-        if((int)$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'active'), array($CNF['FIELD_ID'] => $iContentId)) > 0)
-            $this->_oModule->onPublished($iContentId);
+        if(!$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => 'active'), array($CNF['FIELD_ID'] => $iContentId)))
+            return;
+
+        $this->_oModule->onPublished($iContentId);
+
+        if($bNotify)
+            bx_alert($this->_oModule->getName(), 'publish_succeeded', $aContentInfo[$CNF['FIELD_ID']], $iSystemBotProfileId, array(
+                'object_author_id' => $iAuthorProfileId,
+                'privacy_view' => BX_DOL_PG_ALL
+            ));
     }
 }
 

+ 19 - 0
template/scripts/BxBaseServices.php

@@ -275,6 +275,25 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         return "<script>addToHomescreen();</script>";
     }
 
+    public function serviceGetOptionsProfileBot()
+    {
+        $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 serviceGetOptionsEmbedDefault()
     {
         $aResults = array(