AntonLV 7 anos atrás
pai
commit
f68f1bcc96

+ 19 - 8
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -196,6 +196,8 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         if($sResult)
             return array('code' => 4, 'message' => $sResult);
 
+        list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+
         /*
          * Process metas.
          * Note. It's essential to process metas a the very end, 
@@ -204,7 +206,9 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
          */
         $this->_oModule->processMetasAdd($iContentId);
 
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        // Create alert about the completed action.
+        $this->_oModule->alertAfterAdd($aContentInfo);
+
         return array('code' => 0, 'message' => '', 'content' => $aContentInfo);
     }
 
@@ -256,6 +260,8 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         if ($sResult)
             return $this->prepareResponse($sResult, $bAsJson, 'msg');
 
+        list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+
         /*
          * Process metas.
          * Note. It's essential to process metas a the very end, 
@@ -264,14 +270,16 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
          */
         $this->_oModule->processMetasAdd($iContentId);
 
-        // perform action
+        // Perform ACL action
         $this->_oModule->$sCheckFunction(true);
 
-        // redirect
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        // Create alert about the completed action.
+        $this->_oModule->alertAfterAdd($aContentInfo);
+
+        // Redirect
         $this->redirectAfterAdd($aContentInfo);
     }
-    
+
     public function redirectAfterAdd($aContentInfo)
     {
     	$CNF = &$this->_oModule->_oConfig->CNF;
@@ -340,11 +348,14 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
          * processed and are ready to be passed to alert. 
          */
         $this->_oModule->processMetasEdit($iContentId, $oForm);
-        
-        // perform action
+
+        // Perform ACL action
         $this->_oModule->$sCheckFunction($aContentInfo, true);
+
+        // Create alert about the completed action.
+        $this->_oModule->alertAfterEdit($aContentInfo);
         
-        // redirect
+        // Redirect
         $this->redirectAfterEdit($aContentInfo);
     }
 

+ 4 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -1455,6 +1455,10 @@ class BxBaseModGeneralModule extends BxDolModule
     }
 
     // ====== COMMON METHODS
+    public function alertAfterAdd($aContentInfo) {}
+    
+    public function alertAfterEdit($aContentInfo) {}
+
     public function onPublished($iContentId) {}
 
     public function onFailed($iContentId) {}

+ 0 - 11
modules/base/profile/classes/BxBaseModProfileFormsEntryHelper.php

@@ -123,10 +123,6 @@ class BxBaseModProfileFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         if(isset($CNF['FIELD_ALLOW_POST_TO']) && !empty($aContentInfo[$CNF['FIELD_ALLOW_POST_TO']]) && ($oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_POST'])) !== false)
             $oPrivacy->reassociateGroupCustomWithContent($oProfile->id(), $iContentId, (int)$aContentInfo[$CNF['FIELD_ALLOW_POST_TO']]);
 
-        // create an alert
-        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']]);
-        bx_alert('profile', 'edit', $oProfile->id(), 0, array('content' => $iContentId, 'module' => $this->_oModule->getName()));
-
         return '';
     }
 
@@ -172,13 +168,6 @@ class BxBaseModProfileFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         if(isset($CNF['FIELD_ALLOW_POST_TO']) && !empty($aContentInfo[$CNF['FIELD_ALLOW_POST_TO']]) && ($oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_POST'])) !== false)
             $oPrivacy->associateGroupCustomWithContent($oProfile->id(), $iContentId, (int)$aContentInfo[$CNF['FIELD_ALLOW_POST_TO']]);
 
-        // alert
-        $aParams = array();        
-        if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
-            $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
-
-        bx_alert($this->_oModule->getName(), 'added', $iContentId, false, $aParams);
-
         // switch context to the created profile
         if ($this->_oModule->serviceActAsProfile()) {
             $oAccount = BxDolAccount::getInstance($iAccountId);

+ 29 - 1
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1322,7 +1322,35 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
 		return $oProfile->id() == $iLogged;
     }
-    
+
+    // ====== COMMON METHODS
+    public function alertAfterAdd($aContentInfo)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sModule = $this->getName();
+        $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
+
+        $aParams = array();        
+        if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
+            $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
+
+        bx_alert($sModule, 'added', $iContentId, false, $aParams);
+    }
+
+    public function alertAfterEdit($aContentInfo)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sModule = $this->getName();
+        $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
+
+        $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sModule);
+
+        bx_alert($sModule, 'edited', $iContentId);
+        bx_alert('profile', 'edit', $oProfile->id(), 0, array('content' => $iContentId, 'module' => $sModule));
+    }
+
     public function getProfileByCurrentUrl ()
     {
         $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);

+ 0 - 6
modules/base/text/classes/BxBaseModTextFormsEntryHelper.php

@@ -76,9 +76,6 @@ class BxBaseModTextFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         if ($oProfile->isActive() && !empty($aTrackTextFieldsChanges['changed_fields']))
             $oProfile->disapprove(BX_PROFILE_ACTION_AUTO);
 
-        // alert
-        $this->_oModule->alertAfterEdit($aContentInfo);
-
         return '';
     }
 
@@ -103,9 +100,6 @@ class BxBaseModTextFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
                 $oForm->processPolls($CNF['FIELD_POLL'], $iContentId);
         }
 
-        // alert
-        $this->_oModule->alertAfterAdd($aContentInfo);
-
         return '';
     }