Skip to content

Commit

Permalink
Merge pull request pkp#1736 from kaitlinnewson/6088-3_4_0
Browse files Browse the repository at this point in the history
pkp/pkp-lib#6088 set sequence for featured monographs
  • Loading branch information
bozana authored Oct 23, 2024
2 parents f7e5034 + 07634b0 commit 9f1b2ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/v1/_submissions/BackendSubmissionsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function saveDisplayFlags($slimRequest, $response, $args)
if (!empty($params['featured'])) {
foreach ($params['featured'] as $feature) {
$featureDao->insertFeature($submissionId, $feature['assoc_type'], $feature['assoc_id'], $feature['seq']);
$featureDao->resequenceByAssoc($feature['assoc_type'], $feature['assoc_id']);
}
}
/** @var NewReleaseDAO */
Expand Down Expand Up @@ -179,10 +180,9 @@ public function saveFeaturedOrder($slimRequest, $response, $args)
}
/** @var FeatureDAO */
$featureDao = DAORegistry::getDAO('FeatureDAO');
$featureDao->deleteByAssoc($assocType, $assocId);
if (!empty($params['featured'])) {
foreach ($params['featured'] as $feature) {
$featureDao->insertFeature($feature['id'], $assocType, $assocId, $feature['seq']);
$featureDao->setSequencePosition($feature['id'], $assocType, $assocId, $feature['seq']);
}
}

Expand Down
10 changes: 4 additions & 6 deletions classes/press/FeatureDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,17 @@ public function resequenceByAssoc($assocType, $assocId)
);

$returner = [];
$i = 2;
foreach ($result as $row) {
foreach ($result as $key => $value) {
$this->update(
'UPDATE features SET seq = ? WHERE submission_id = ? AND assoc_type = ? AND assoc_id = ?',
[
$i,
$row->submission_id,
$key + 1,
$value->submission_id,
(int) $assocType,
(int) $assocId
]
);
$returner[$row->submission_id] = $i;
$i += 2;
$returner[$value->submission_id] = $key;
}
return $returner;
}
Expand Down

0 comments on commit 9f1b2ed

Please sign in to comment.