jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337796 )
Change subject: PageAssignments: added hook listener for user delete and group delete/rename. ...................................................................... PageAssignments: added hook listener for user delete and group delete/rename. Fix for issue ERM5343 Change-Id: I25fbd862c9e0faa8b5f6518ccc8bf607f649d315 --- M PageAssignments/extension.json M PageAssignments/includes/PageAssignmentsHooks.php 2 files changed, 61 insertions(+), 1 deletion(-) Approvals: Robert Vogel: Looks good to me, approved jenkins-bot: Verified diff --git a/PageAssignments/extension.json b/PageAssignments/extension.json index 39666bc..dde01be 100644 --- a/PageAssignments/extension.json +++ b/PageAssignments/extension.json @@ -67,7 +67,10 @@ "ViewPAStateBarBodyElement": "includes/views/ViewPAStateBarBodyElement.php", "PageAssignmentsNotificationFormatter": "includes/notifications/PageAssignmentsNotificationFormatter.php", "PageAssignmentsEmailSingle": "includes/notifications/PageAssignmentsEmailSingle.php", - "BSPageAssignmentsMigrateRespEditors": "maintenance/BSPageAssignmentsMigrateRespEditors.php" + "BSPageAssignmentsMigrateRespEditors": "maintenance/BSPageAssignmentsMigrateRespEditors.php", + "BSUserManagerAfterDeleteUser": "PageAssignmentsHooks::onBSUserManagerAfterDeleteUser", + "BSGroupManagerGroupNameChanged": "PageAssignmentsHooks::onBSGroupManagerGroupNameChanged", + "BSGroupManagerGroupDeleted": "PageAssignmentsHooks::onBSGroupManagerGroupDeleted" }, "ResourceModules": { "ext.pageassignments.styles": { diff --git a/PageAssignments/includes/PageAssignmentsHooks.php b/PageAssignments/includes/PageAssignmentsHooks.php index 3b84f2f..53213b8 100644 --- a/PageAssignments/includes/PageAssignmentsHooks.php +++ b/PageAssignments/includes/PageAssignmentsHooks.php @@ -145,4 +145,61 @@ ); return true; } + + /** + * Deletes all page assignments on user deleted. + * @param UserManager $oUserManager + * @param User $oUser + * @param &$oStatus + * @return bool + */ + public static function onBSUserManagerAfterDeleteUser( $oUserManager, $oUser, &$oStatus, $oPerformer ) { + $dbr = wfGetDB( DB_MASTER ); + $dbr->delete( + 'bs_pageassignments', + array( + 'pa_assignee_key' => $oUser->getName(), + 'pa_assignee_type' => 'user' + ) + ); + return true; + } + + /** + * Updates all page assignments on group name change. + * @param string $sGroup + * @param string $sNewGroup + * @return bool + */ + public static function onBSGroupManagerGroupNameChanged( $sGroup, $sNewGroup ) { + $dbr = wfGetDB( DB_MASTER ); + $dbr->update( + 'bs_pageassignments', + array( + 'pa_assignee_key' => $sNewGroup, + ), + array( + 'pa_assignee_key' => $sGroup, + 'pa_assignee_type' => 'group' + ) + ); + return true; + } + + /** + * Deletes all page assignments on group deleted. + * @param string $sGroup + * @return bool + */ + public static function onBSGroupManagerGroupDeleted( $sGroup) { + $dbr = wfGetDB( DB_MASTER ); + $dbr->delete( + 'bs_pageassignments', + array( + 'pa_assignee_key' => $sGroup, + 'pa_assignee_type' => 'group' + ) + ); + return true; + } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/337796 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I25fbd862c9e0faa8b5f6518ccc8bf607f649d315 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: master Gerrit-Owner: Nasty <kon...@hallowelt.com> Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits