Skip to content

Commit

Permalink
Ticket #3029 - Orgs: ability to move org to another owner.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Mar 12, 2024
1 parent d24b784 commit 3f7b668
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
14 changes: 12 additions & 2 deletions modules/base/groups/classes/BxBaseModGroupsFormEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges =
{
$CNF = &$this->_oModule->_oConfig->CNF;

if(isset($CNF['FIELD_PUBLISHED'])){
if(isset($CNF['FIELD_PUBLISHED'])) {
if(empty($aValsToAdd[$CNF['FIELD_PUBLISHED']]) && isset($this->aInputs[$CNF['FIELD_PUBLISHED']])) {
$iPublished = $this->getCleanValue($CNF['FIELD_PUBLISHED']);
if(empty($iPublished))
Expand All @@ -87,7 +87,17 @@ function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges =
}
}

return parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
$aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);

$mixedResult = parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
if($mixedResult && ($iAuthorId = (int)$this->getCleanValue($CNF['FIELD_AUTHOR'])) && (int)$aContentInfo[$CNF['FIELD_AUTHOR']] != $iAuthorId) {
$oProfileAuthor = BxDolProfile::getInstance($iAuthorId);
$oProfileContent = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
if($oProfileAuthor !== false && $oProfileContent !== false)
$oProfileContent->move($oProfileAuthor->getAccountId());
}

return $mixedResult;
}

protected function genCustomInputInitialMembers ($aInput)
Expand Down
17 changes: 0 additions & 17 deletions modules/boonex/organizations/classes/BxOrgsFormEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ public function __construct($aInfo, $oTemplate = false)
$this->MODULE = 'bx_organizations';
parent::__construct($aInfo, $oTemplate);
}

public function update ($iContentId, $aValsToAdd = [], &$aTrackTextFieldsChanges = null)
{
$CNF = &$this->_oModule->_oConfig->CNF;

$aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);

$mixedResult = parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
if($mixedResult && ($iAuthorId = (int)$this->getCleanValue($CNF['FIELD_AUTHOR'])) && (int)$aContentInfo[$CNF['FIELD_AUTHOR']] != $iAuthorId) {
$oProfileAuthor = BxDolProfile::getInstance($iAuthorId);
$oProfileContent = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
if($oProfileAuthor !== false && $oProfileContent !== false)
$oProfileContent->move($oProfileAuthor->getAccountId());
}

return $mixedResult;
}
}

/** @} */

0 comments on commit 3f7b668

Please sign in to comment.