Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(enhancement): cleanup invitations when purging a user
Browse files Browse the repository at this point in the history
database kept cleaner
  • Loading branch information
btry committed Dec 16, 2016
1 parent 617425f commit 63570ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hook.php
Expand Up @@ -64,6 +64,21 @@ function plugin_storkmdm_postinit() {

}

/**
* Actions done when a profile_user is being purged
*/
function plugin_storkmdm_hook_pre_profileuser_purge(CommonDBTM $item) {
$config = Config::getConfigurationValues('storkmdm', array('guest_profiles_id', 'registered_profiles_id'));
$guestProfileId = $config['guest_profiles_id'];

if ($item->getField('profiles_id') == $guestProfileId) {
$invitation = new PluginStorkmdmInvitation();
if (!$invitation->deleteByCriteria(array('users_id' => $item->getField('users_id')))) {
$item->input = false;
}
}
}

/**
* Define Dropdown tables to be managed in GLPI
* @return translated[]
Expand Down
1 change: 1 addition & 0 deletions setup.php
Expand Up @@ -131,6 +131,7 @@ function plugin_init_storkmdm() {
$PLUGIN_HOOKS['pre_item_purge']['storkmdm'] = array(
'PluginStorkmdmInvitation' => array('PluginStorkmdmInvitation', 'hook_pre_self_purge'),
'Document' => array('PluginStorkmdmInvitation', 'hook_pre_document_purge'),
'Profile_User' => 'plugin_storkmdm_hook_pre_profileuser_purge',
);

// Add css and js resources if the requested page needs them
Expand Down

0 comments on commit 63570ad

Please sign in to comment.