فهرست منبع

Ticket #4558 - Build-in API support: Notifications settings.

AntonLV 2 سال پیش
والد
کامیت
4214a4801b

+ 21 - 0
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -106,6 +106,7 @@ class BxNtfsModule extends BxBaseModNotificationsModule
             'GetUnreadNotificationsNum' => '',
             'GetUnreadNotificationsNumEx' => '',
             'MarkAsRead' => '',
+            'EnableSetting' => '',
             'ChangeSetting' => '',
         ];
     }
@@ -689,6 +690,26 @@ class BxNtfsModule extends BxBaseModNotificationsModule
         return $this->_oDb->markAsRead($iOwnerId, $aEvent['id']) !== false;
     }
 
+    public function serviceEnableSetting($mixedParams)
+    {
+        if(!is_array($mixedParams))
+            $mixedParams = json_decode($mixedParams, true);
+
+        if(!isset($mixedParams['id'], $mixedParams['value']))
+            return false;
+
+        $iId = (int)$mixedParams['id'];
+        $iValue = (int)$mixedParams['value'];
+        $bAdministration = isset($mixedParams['admin']) && $mixedParams['admin'];
+
+        if(!$this->_oConfig->isSettingsGrouped())
+            $mixedResult = $this->_oDb->updateSetting(['active' => $iValue], ['id' => $iId]);
+        else 
+            $mixedResult = $this->enableSettingsLike($iId, $iValue, $bAdministration);
+
+        return $mixedResult !== false;
+    }
+            
     public function serviceChangeSetting($mixedParams)
     {
         if(!is_array($mixedParams))

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

@@ -69,7 +69,7 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
             $oGrid->setUserId($iUserId);
 
         return !$this->_bIsApi ? $oGrid->getCode() : [
-            bx_api_get_block('notifications_settings', $oGrid->getCodeApi(true), ['ext' => ['request_url' => '/api.php?r=' . $this->_oConfig->getName() . '/change_setting/&params[]=']])
+            bx_api_get_block('notifications_settings', $oGrid->getCodeApi(true), ['ext' => ['request_url' => '/api.php?r=' . $this->_oConfig->getName() . '/enable_setting/&params[]=']])
         ];
     }