Просмотр исходного кода

#22 - problem with persons deletion and some other actions

Alex Trofimov 12 лет назад
Родитель
Сommit
6a779284d0

+ 16 - 7
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -234,8 +234,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolPro
 
         // owner (checked by account! not as profile as ususal) always have access
         bx_import('BxDolProfile');
-        $oProfileAurhor = BxDolProfile::getInstance($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']]);
-        if ($oProfileAurhor->getAccountId() == $this->_iAccountId)
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
+        if (!$oProfile)
+            return _t('_sys_txt_error_occured');
+
+        if ($oProfile->getAccountId() == $this->_iAccountId)
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return _t('_sys_txt_access_denied');
@@ -252,8 +255,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolPro
 
         // owner (checked by account! not as profile as ususal) always have access
         bx_import('BxDolProfile');
-        $oProfileAurhor = BxDolProfile::getInstance($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']]);
-        if ($oProfileAurhor->getAccountId() == $this->_iAccountId)
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
+        if (!$oProfile)
+            return _t('_sys_txt_error_occured');
+
+        if ($oProfile->getAccountId() == $this->_iAccountId)
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return _t('_sys_txt_access_denied');
@@ -269,11 +275,14 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolPro
             return CHECK_ACTION_RESULT_ALLOWED;
 
         // check ACL and owner (checked by account! not as profile as ususal)
+        $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
+
         bx_import('BxDolProfile');
-        $oProfileAurhor = BxDolProfile::getInstance($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']]);
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
+        if (!$oProfile)
+            return _t('_sys_txt_error_occured');
 
-        $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
-        if ($oProfileAurhor->getAccountId() == $this->_iAccountId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+        if ($oProfile->getAccountId() == $this->_iAccountId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return _t('_sys_txt_access_denied');

+ 1 - 3
modules/base/profile/classes/BxBaseModProfilePageEntry.php

@@ -22,7 +22,6 @@ class BxBaseModProfilePageEntry extends BxBaseModGeneralPageEntry
 {
     protected $_aProfileInfo;
     protected $_oProfile;
-    protected $_oProfileAuthor;
 
     public function __construct($aObject, $oTemplate = false)
     {
@@ -45,7 +44,6 @@ class BxBaseModProfilePageEntry extends BxBaseModGeneralPageEntry
         if ($this->_oProfile) {
             $this->_aProfileInfo = $this->_oProfile->getInfo();
             $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']);
-            $this->_oProfileAuthor = $this->_aContentInfo ? BxDolProfile::getInstance($this->_aContentInfo[$CNF['FIELD_AUTHOR']]) : false;
         }
 
         if (!$this->_aContentInfo || !$this->_oProfile)
@@ -65,7 +63,7 @@ class BxBaseModProfilePageEntry extends BxBaseModGeneralPageEntry
         $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name is also suported
 
         // display message if profile isn't active
-        if (bx_get_logged_profile_id() == $this->_oProfileAuthor->id() && !empty($CNF['INFORMERS']['status'])) {
+        if (bx_get_logged_profile_id() == $this->_oProfile->id() && !empty($CNF['INFORMERS']['status'])) {
             $sStatus = $this->_aContentInfo['profile_status'];
             if (isset($CNF['INFORMERS']['status']['map'][$sStatus]))
                 $aInformers[] = array ('name' => $CNF['INFORMERS']['status']['name'], 'msg' => _t($CNF['INFORMERS']['status']['map'][$sStatus]), 'type' => BX_INFORMER_ALERT);