Prechádzať zdrojové kódy

Ticket #3647 - Notifications based: Reinit handlers action in Studio.

AntonLV 4 rokov pred
rodič
commit
b1eff0985b

+ 72 - 0
modules/base/notifications/classes/BxBaseModNotificationsStudioPage.php

@@ -0,0 +1,72 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    BaseNotifications Base classes for Notifications like modules
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxBaseModNotificationsStudioPage extends BxTemplStudioModule
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    public function __construct($sModule, $mixedPageName, $sPage = "")
+    {
+        $this->_oModule = BxDolModule::getInstance($this->_sModule);
+
+        parent::__construct($sModule, $mixedPageName, $sPage);
+    }
+
+    public function checkAction()
+    {
+    	$sAction = bx_get($this->sParamPrefix . '_action');
+    	if($sAction === false)
+            return false;
+
+        if(empty($this->aModule) || !is_array($this->aModule))
+            return array('code' => 1, 'message' => _t('_sys_request_page_not_found_cpt'));
+
+        $sAction = bx_process_input($sAction);
+
+        $aResult = array('code' => 2, 'message' => _t('_adm_mod_err_cannot_process_action'));
+        switch($sAction) {
+            case 'reinit':
+                $aConfig = BxDolInstallerUtils::getModuleConfig($this->_oModule->_aModule);
+                if(empty($aConfig) || !is_array($aConfig))
+                    break;
+
+                $oInstallerDb = bx_instance('BxDolStudioInstallerQuery');               
+
+                $aRelation = $oInstallerDb->getRelationsBy(array('type' => 'module', 'value' => $aConfig['name']));
+                if(empty($aRelation))
+                    break;
+
+                $aOperations = ['disable', 'enable'];
+                foreach($aOperations as $sOperation) {
+                    if(empty($aRelation['on_' . $sOperation]))
+                        break 2;
+
+                    $aModules = $oInstallerDb->getModulesBy(array('type' => 'all', 'active' => 1));
+                    foreach($aModules as $aModule) {
+                        $aModuleConfig = BxDolInstallerUtils::getModuleConfig($aModule);
+                        if(!empty($aModuleConfig['relations']) && is_array($aModuleConfig['relations']) && in_array($aConfig['name'], $aModuleConfig['relations']))
+                            bx_srv_ii($aConfig['name'], $aRelation['on_' . $sOperation], [$aModule['uri']]);
+                    }
+                }
+
+                $aResult = ['code' => 0, 'message' => _t('_adm_txt_modules_process_action_success')];
+                break;
+
+            default:
+                $aResult = parent::checkAction();
+        }
+
+        return $aResult;
+    }
+}
+
+/** @} */

+ 2 - 6
modules/boonex/notifications/classes/BxNtfsStudioPage.php

@@ -9,15 +9,11 @@
  * @{
  */
 
-class BxNtfsStudioPage extends BxTemplStudioModule
+class BxNtfsStudioPage extends BxBaseModNotificationsStudioPage
 {
-    protected $_sModule;
-    protected $_oModule;
-
-    function __construct($sModule, $mixedPageName, $sPage = "")
+    public function __construct($sModule, $mixedPageName, $sPage = "")
     {
     	$this->_sModule = 'bx_notifications';
-    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
 
         parent::__construct($sModule, $mixedPageName, $sPage);
 

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

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Timeline Timeline
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxTimelineStudioPage extends BxBaseModNotificationsStudioPage
+{
+    public function __construct($sModule, $mixedPageName, $sPage = "")
+    {
+    	$this->_sModule = 'bx_timeline';
+
+        parent::__construct($sModule, $mixedPageName, $sPage);
+    }
+}
+
+/** @} */