1
0
AntonLV 8 жил өмнө
parent
commit
5d46cda6d2

+ 17 - 10
modules/boonex/acl/classes/BxAclResponse.php

@@ -11,8 +11,8 @@
 
 class BxAclResponse extends BxDolAlertsResponse
 {
-	protected $MODULE;
-	protected $_oModule;
+    protected $MODULE;
+    protected $_oModule;
 
     public function __construct()
     {
@@ -29,14 +29,21 @@ class BxAclResponse extends BxDolAlertsResponse
      */
     public function response($oAlert)
     {
-    	if($oAlert->sUnit != 'system' || !in_array($oAlert->sAction, array('page_output_block_acl_level')))
-    		return;
-
-		switch($oAlert->sAction) {
-			case 'page_output_block_acl_level':
-				$oAlert->aExtras['block_code'] .= $this->_oModule->serviceGetMembershipActions((int)$oAlert->aExtras['block_owner']);
-				break;
-		}
+        $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);           	
+        if(!method_exists($this, $sMethod))
+            return;
+
+        $this->$sMethod($oAlert);
+    }
+
+    protected function _processSystemPageOutputBlockAclLevel($oAlert)
+    {
+        $oAlert->aExtras['block_code'] .= $this->_oModule->serviceGetMembershipActions((int)$oAlert->aExtras['block_owner']);
+    }
+
+    protected function _processAclDeleted($oAlert)
+    {
+        $this->_oModule->_oDb->deletePrices(array('level_id' => $oAlert->iObject));
     }
 }
 

+ 2 - 1
modules/boonex/acl/install/sql/enable.sql

@@ -35,4 +35,5 @@ INSERT INTO `sys_alerts_handlers`(`name`, `class`, `file`, `service_call`) VALUE
 SET @iHandler := LAST_INSERT_ID();
 
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
-('system', 'page_output_block_acl_level', @iHandler);
+('system', 'page_output_block_acl_level', @iHandler),
+('acl', 'deleted', @iHandler);

+ 13 - 1
studio/classes/BxDolStudioPermissionsLevels.php

@@ -28,6 +28,12 @@ class BxDolStudioPermissionsLevels extends BxTemplStudioGrid
         if($aLevel['removable'] != 'yes' || $this->oDb->isLevelUsed($aLevel['id']))
             return false;
 
+        // create system event before deletion
+        $isStopDeletion = false;
+        bx_alert('acl', 'before_delete', $aLevel['id'], 0, array('level' => $aLevel, 'stop_deletion' => &$isStopDeletion));
+        if($isStopDeletion)
+            return false;
+
         if(is_numeric($aLevel['icon'])) {
             if(!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$aLevel['icon'], 0))
                 return false;
@@ -37,7 +43,13 @@ class BxDolStudioPermissionsLevels extends BxTemplStudioGrid
         $oLanguage->deleteLanguageString($aLevel['name']);
         $oLanguage->deleteLanguageString($aLevel['description']);
 
-        return $this->oDb->deleteLevel(array('type' => 'by_id', 'value' => $aLevel['id']));
+        $bResult = $this->oDb->deleteLevel(array('type' => 'by_id', 'value' => $aLevel['id']));
+        if($bResult) {
+            // create system event
+            bx_alert('acl', 'deleted', $aLevel['id'], 0, array('level' => $aLevel));
+        }
+
+        return $bResult;
     }
 
     protected function _switcherChecked2State($isChecked)

+ 14 - 1
studio/template/scripts/BxBaseStudioPermissionsLevels.php

@@ -66,6 +66,9 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels
 
             $iId = (int)$oForm->insert(array('ID' => $iId, 'Icon' => $mixedIcon, 'Order' => $this->oDb->getLevelOrderMax() + 1));
             if($iId != 0) {
+                $aLevel = array();
+                $this->oDb->getLevels(array('type' => 'by_id', 'value' => (int)$iId), $aLevel, false);
+
             	$iActionsFrom = (int)$oForm->getCleanValue('Actions');
             	if($iActionsFrom > 0) {
             		$aActions = array();
@@ -80,6 +83,9 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels
             			));
             	}
 
+                // create system event
+                bx_alert('acl', 'added', $iId, 0, array('level' => $aLevel));
+
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
             }
             else
@@ -162,8 +168,15 @@ class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels
             $fQuotaMaxFileSize = round($oForm->getCleanValue('QuotaMaxFileSize'), 1);
             BxDolForm::setSubmittedValue('QuotaMaxFileSize', self::$iBinMB * $fQuotaMaxFileSize, $oForm->aFormAttrs['method']);
 
-            if($oForm->update($iId) !== false)
+            if($oForm->update($iId) !== false) {
+                $aLevel = array();
+                $this->oDb->getLevels(array('type' => 'by_id', 'value' => (int)$iId), $aLevel, false);
+
+                // create system event
+                bx_alert('acl', 'edited', $iId, 0, array('level' => $aLevel));
+
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
+            }
             else
                 $aRes = array('msg' => _t('_adm_prm_err_level_edit'));