Browse Source

#1678 - Allow to edit 'author' field by admin/moderator in content modules

RomanL 4 years ago
parent
commit
879d9f16dc

+ 15 - 2
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -29,9 +29,14 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
     protected $_aTrackFieldsChanges;
     
     protected $_iContentId;
+    
+    protected $_bAllowChangeUserForAdmins;
 
     public function __construct($aInfo, $oTemplate = false)
     {
+        if (!isset($this->_bAllowChangeUserForAdmins))
+            $this->_bAllowChangeUserForAdmins = true;
+        
         parent::__construct($aInfo, $oTemplate);
 
         $this->_oModule = BxDolModule::getInstance($this->MODULE);
@@ -65,8 +70,16 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
             $this->aInputs[$CNF['FIELD_LOCATION_PREFIX']]['manual_input'] = true;
         }
         
-        if ($this->_oModule->checkAllowedEditAnyEntry(false) === CHECK_ACTION_RESULT_ALLOWED && isset($CNF['FIELD_AUTHOR']) && isset($this->aParams['view_mode']) && $this->aParams['view_mode'] != 1){
-            $this->aInputs = array_merge([
+        // add ability to change author by admins in some apps
+        if (
+            $this->_oModule->checkAllowedEditAnyEntry(false) === CHECK_ACTION_RESULT_ALLOWED &&
+            isset($CNF['FIELD_AUTHOR']) && 
+            (
+                (isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT']) && $this->aParams['display'] == $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT']) ||
+                (isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']) && $this->aParams['display'] == $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'])
+            ) && 
+            $this->_bAllowChangeUserForAdmins){
+                $this->aInputs = array_merge([
                 $CNF['FIELD_AUTHOR'] => [
                     'type' => 'custom',
                     'name' => $CNF['FIELD_AUTHOR'],

+ 3 - 0
modules/base/groups/classes/BxBaseModGroupsFormEntry.php

@@ -16,6 +16,9 @@ class BxBaseModGroupsFormEntry extends BxBaseModProfileFormEntry
 {
     public function __construct($aInfo, $oTemplate = false)
     {
+        if (!isset($this->_bAllowChangeUserForAdmins))
+            $this->_bAllowChangeUserForAdmins = true;
+        
         parent::__construct($aInfo, $oTemplate);
 
         $CNF = &$this->_oModule->_oConfig->CNF;

+ 4 - 1
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -18,7 +18,10 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
     protected $_aImageFields = array ();
 
     public function __construct($aInfo, $oTemplate = false)
-    {
+    {   
+        if (!isset($this->_bAllowChangeUserForAdmins))
+            $this->_bAllowChangeUserForAdmins = false;
+        
         parent::__construct($aInfo, $oTemplate);
 
         $this->_sAuthorKey = 'profile_id';

+ 2 - 0
modules/boonex/organizations/classes/BxOrgsFormEntry.php

@@ -16,6 +16,8 @@ class BxOrgsFormEntry extends BxBaseModGroupsFormEntry
 {
     public function __construct($aInfo, $oTemplate = false)
     {
+        $this->_bAllowChangeUserForAdmins = true;
+        
         $this->MODULE = 'bx_organizations';
         parent::__construct($aInfo, $oTemplate);
     }