Skip to content

Commit

Permalink
Changed: accounts merging: take into account the COI table.
Browse files Browse the repository at this point in the history
  • Loading branch information
devletech committed Jul 11, 2022
1 parent 7ddf4a5 commit ce1bc23
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Security
-->
## Unreleased
### Changed
- Accounts merging: take into account the COI table.

## 1.0.31 - 2022-06-28
### Added
Expand Down
8 changes: 8 additions & 0 deletions library/Episciences/Merge/MergingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public static function updateDataTables(int $mergerUid = 0, int $keeperUid = 0):
$affected_rows['NEWS'] = 0;
$affected_rows['PAPERS'] = 0;
$affected_rows['USER'] = 0;
$affected_rows[T_PAPER_CONFLICTS] = 0;

try { //USER_ROLES table
$rowNb = Episciences_UsersManager::updateRolesUid($mergerUid, $keeperUid);
Expand Down Expand Up @@ -225,6 +226,11 @@ public static function updateDataTables(int $mergerUid = 0, int $keeperUid = 0):
$exception[] = self::showException($e);
}

// COI tables
$rowNb = Episciences_Paper_ConflictsManager::updateRegistrant($mergerUid, $keeperUid);
$affected_rows[T_PAPER_CONFLICTS] += $rowNb;
$rowTotal += $rowNb;

try { //USER table
// if keeper not found: the account will be translated
$keeperUser = new Episciences_User();
Expand All @@ -245,6 +251,8 @@ public static function updateDataTables(int $mergerUid = 0, int $keeperUid = 0):
} catch (Exception $e) {
$exception[] = self::showException($e);
}


$affected_rows['Affected rows in database'] = $rowTotal;
if ($rowTotal) {
$result = self::SUCCESS;
Expand Down
23 changes: 23 additions & 0 deletions library/Episciences/Paper/ConflictsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,27 @@ private static function findQuery(): \Zend_Db_Select
->join(['u' => T_USERS], 'u.UID = c.by', ['SCREEN_NAME']);
}


public static function updateRegistrant(int $oldUid = 0, int $newUid = 0): int
{

if ($oldUid === 0 || $newUid === 0) {
return 0;
}

$nbAffectedRows = 0;

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$data['by'] = $newUid;
$where['by = ?'] = $oldUid;
try {
$nbAffectedRows = $db->update(self::TABLE, $data, $where);
} catch (Zend_Db_Adapter_Exception $e) {
trigger_error($e->getMessage());
}

return $nbAffectedRows;

}

}

0 comments on commit ce1bc23

Please sign in to comment.