Explorar el Código

Ticket #3258 - Changes in Notifications based modules.

AntonLV hace 5 años
padre
commit
649197758f

+ 2 - 9
modules/boonex/notifications/classes/BxNtfsCronNotify.php

@@ -51,8 +51,9 @@ class BxNtfsCronNotify extends BxDolCron
         $aDeliveryTypes = array();
 
         $iId = (int)$aEvent['id'];
-        $iSilentMode = $this->_getSilentMode($aEvent['content']);
+        $iSilentMode = $this->_oModule->getSilentMode($aEvent['content']);
         switch($iSilentMode) {
+            case BX_BASE_MOD_NTFS_SLTMODE_ABSOLUTE:
             case BX_NTFS_SLTMODE_ABSOLUTE:
             case BX_NTFS_SLTMODE_SITE:
                 return;
@@ -166,14 +167,6 @@ class BxNtfsCronNotify extends BxDolCron
         }
     }
 
-    protected function _getSilentMode($aContent)
-    {
-        if(isset($aContent['silent_mode']))
-            return (int)$aContent['silent_mode'];
-
-        return BX_NTFS_SLTMODE_DISABLED;
-    }
-
     protected function _addRecipient($iUser, $sSettingType, &$aRecipients)
     {
         if(!isset($aRecipients[$iUser]))

+ 10 - 10
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -30,19 +30,19 @@ define('BX_NTFS_STYPE_OTHER', 'other');
  * SLTMODE - Silent mode:
  * It is needed for alert sending module to tell that the alert should be ignored 
  * with Notifications module completely or partially. Available values: 
- * 1. disabled (value = 0) - all notifications are available;
- * 2. absolute (value = 1) - alert isn't registered which means that there is no notifications at all;
- * 3. on-site only (value = 2) - alert is registered. It means that on-site notification is available while the others are disabled.
- * 4. on-site + email (value = 3) - alert is registered (on-site) and notification via 'email' is enabled.
- * 5. on-site + push (value = 4) - alert is registered (on-site) and notification via 'push' is enabled.
+ * 1. disabled (global, value = 0) - all notifications are available;
+ * 2. absolute (global, value = 1) - alert isn't registered which means that there is no notifications at all;
+ * 3. absolute (for Notifications only, value = 11) - the same as global absolute.
+ * 3. on-site only (value = 12) - alert is registered. It means that on-site notification is available while the others are disabled.
+ * 4. on-site + email (value = 13) - alert is registered (on-site) and notification via 'email' is enabled.
+ * 5. on-site + push (value = 14) - alert is registered (on-site) and notification via 'push' is enabled.
  * 
  * @see BxNtfsResponse::response - 'silent_mode' parameter in Alerts Extras array.
  */
-define('BX_NTFS_SLTMODE_DISABLED', 0);
-define('BX_NTFS_SLTMODE_ABSOLUTE', 1);
-define('BX_NTFS_SLTMODE_SITE', 2);
-define('BX_NTFS_SLTMODE_SITE_EMAIL', 3);
-define('BX_NTFS_SLTMODE_SITE_PUSH', 4);
+define('BX_NTFS_SLTMODE_ABSOLUTE', 11);
+define('BX_NTFS_SLTMODE_SITE', 12);
+define('BX_NTFS_SLTMODE_SITE_EMAIL', 13);
+define('BX_NTFS_SLTMODE_SITE_PUSH', 14);
 
 class BxNtfsModule extends BxBaseModNotificationsModule
 {

+ 4 - 12
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -33,8 +33,8 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         if(empty($aHandler) || !is_array($aHandler))
             return;
 
-        $iSilentMode = $this->_getSilentMode($oAlert->aExtras);
-        if($iSilentMode == BX_NTFS_SLTMODE_ABSOLUTE)
+        $iSilentMode = $this->_oModule->getSilentMode($oAlert->aExtras);
+        if(in_array($iSilentMode, array(BX_BASE_MOD_NTFS_SLTMODE_ABSOLUTE, BX_NTFS_SLTMODE_ABSOLUTE)))
             return;
 
         switch($aHandler['type']) {
@@ -236,8 +236,8 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
     {
         $aResult = array();
 
-        $iSilentMode = $this->_getSilentMode($aExtras);
-        if($iSilentMode != BX_NTFS_SLTMODE_DISABLED)
+        $iSilentMode = $this->_oModule->getSilentMode($aExtras);
+        if($iSilentMode != BX_BASE_MOD_NTFS_SLTMODE_DISABLED)
             $aResult['silent_mode'] = $iSilentMode;
 
         if(!empty($aAdd) && is_array($aAdd))
@@ -245,14 +245,6 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
 
         return !empty($aResult) && is_array($aResult) ? serialize($aResult) : '';
     }
-
-    protected function _getSilentMode($aExtras)
-    {
-        if(isset($aExtras['silent_mode']))
-            return (int)$aExtras['silent_mode'];
-
-        return BX_NTFS_SLTMODE_DISABLED;
-    }
 }
 
 /** @} */

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

@@ -23,7 +23,6 @@ bx_import('BxBaseModNotificationsModule');
  * 
  * @see BxBaseModNotificationsModule and BxTimelineResponse::response - 'silent_mode' parameter in Alerts Extras array.
  */
-define('BX_TIMELINE_SLTMODE_DISABLED', 0);
 define('BX_TIMELINE_SLTMODE_ABSOLUTE', 21);
 
 define('BX_TIMELINE_TYPE_ITEM', 'view_item');

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

@@ -40,8 +40,8 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
         if(empty($aHandler) || !is_array($aHandler))
             return;
 
-        $iSilentMode = $this->_getSilentMode($oAlert->aExtras);
-        if(in_array($iSilentMode, array(BX_TIMELINE_SLTMODE_ABSOLUTE)))
+        $iSilentMode = $this->_oModule->getSilentMode($oAlert->aExtras);
+        if(in_array($iSilentMode, array(BX_BASE_MOD_NTFS_SLTMODE_ABSOLUTE, BX_TIMELINE_SLTMODE_ABSOLUTE)))
             return;
 
         switch($aHandler['type']) {
@@ -204,14 +204,6 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
         $this->_clearCache();
     }
 
-    protected function _getSilentMode($aExtras)
-    {
-        if(isset($aExtras['silent_mode']))
-            return (int)$aExtras['silent_mode'];
-
-        return BX_TIMELINE_SLTMODE_DISABLED;
-    }
-
     protected function _clearCache()
     {
         //--- Clear item cache.