Skip to content

Commit

Permalink
~ Compatibility with Akeeba Subscriptions 7 for data export and user …
Browse files Browse the repository at this point in the history
…anonymisation (Users model has been removed)
  • Loading branch information
Nicholas K. Dionysopoulos committed Jul 12, 2019
1 parent b160e68 commit 6cf6876
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Akeeba Data Compliance 1.1.1
+ Rewritten cookie plugin to work with caching enabled
+ Consent can be transcribed from Joomla's privacy consent user profile field (migration from Joomla to DataCompliance)
~ Transcribing consent given during subscription only applies to Akeeba Subscriptions 5 and 6
~ Compatibility with Akeeba Subscriptions 7 for data export and user anonymisation (Users model has been removed)
# User Profile fields not displayed correctly when using an Edit Profile menu item

Akeeba Data Compliance 1.1.0
Expand Down
38 changes: 27 additions & 11 deletions plugins/datacompliance/akeebasubs/akeebasubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,17 @@ public function onDataComplianceExportUser(int $userID): SimpleXMLElement
}
}

/** @var \Akeeba\Subscriptions\Admin\Model\Users $user */
$user = $container->factory->model('Users')->tmpInstance();
$db = $container->db;
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__akeebasubs_users'))
->where($db->qn('akeebasubs_user_id') . ' = ' . $db->q($userID));

try
{
$user->findOrFail(['user_id' => $userID]);
$userData = $db->setQuery($query)->loadAssoc();

Export::adoptChild($domainUserInfo, Export::exportItemFromDataModel($user));
Export::adoptChild($domainUserInfo, Export::exportItemFromArray($userData));
}
catch (Exception $e)
{
Expand All @@ -340,16 +343,18 @@ private function anonymizeUser($user_id)
{
$container = Container::getInstance('com_akeebasubs', [], 'admin');

/** @var \Akeeba\Subscriptions\Admin\Model\Users $user */
$user = $container->factory->model('Users')->tmpInstance();

Log::add("Anonymizing Akeeba Subscriptions user information for user #{$user_id}.", Log::DEBUG, 'com_datacompliance');

$db = $container->db;
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__akeebasubs_users'))
->where($db->qn('akeebasubs_user_id') . ' = ' . $db->q($user_id));

try
{
$user->findOrFail(['user_id' => $user_id]);

$user->save([
$userData = $db->setQuery($query)->loadAssoc();
$newData = [
'isbusiness' => 0,
'businessname' => '',
'occupation' => '',
Expand All @@ -365,7 +370,18 @@ private function anonymizeUser($user_id)
'params' => [],
'notes' => 'This record has been pseudonymized per GDPR requirements',
'needs_logout' => 0,
]);
];

foreach ($newData as $k => $v)
{
if (array_key_exists($k, $userData))
{
$userData[$k] = $v;
}
}

$userData = (object)$userData;
$db->updateObject('#__akeebasubs_users', $userData, 'akeebasubs_user_id');
}
catch (Exception $e)
{
Expand Down

0 comments on commit 6cf6876

Please sign in to comment.