privacy.php
2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* @package Joomla.Administrator
* @subpackage com_privacy
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
/**
* Privacy component helper.
*
* @since 3.9.0
*/
class PrivacyHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 3.9.0
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_PRIVACY_SUBMENU_DASHBOARD'),
'index.php?option=com_privacy&view=dashboard',
$vName === 'dashboard'
);
JHtmlSidebar::addEntry(
JText::_('COM_PRIVACY_SUBMENU_REQUESTS'),
'index.php?option=com_privacy&view=requests',
$vName === 'requests'
);
JHtmlSidebar::addEntry(
JText::_('COM_PRIVACY_SUBMENU_CAPABILITIES'),
'index.php?option=com_privacy&view=capabilities',
$vName === 'capabilities'
);
JHtmlSidebar::addEntry(
JText::_('COM_PRIVACY_SUBMENU_CONSENTS'),
'index.php?option=com_privacy&view=consents',
$vName === 'consents'
);
}
/**
* Render the data request as a XML document.
*
* @param PrivacyExportDomain[] $exportData The data to be exported.
*
* @return string
*
* @since 3.9.0
*/
public static function renderDataAsXml(array $exportData)
{
$export = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><data-export />');
foreach ($exportData as $domain)
{
$xmlDomain = $export->addChild('domain');
$xmlDomain->addAttribute('name', $domain->name);
$xmlDomain->addAttribute('description', $domain->description);
foreach ($domain->getItems() as $item)
{
$xmlItem = $xmlDomain->addChild('item');
if ($item->id)
{
$xmlItem->addAttribute('id', $item->id);
}
foreach ($item->getFields() as $field)
{
$xmlItem->{$field->name} = $field->value;
}
}
}
$dom = new DOMDocument;
$dom->loadXML($export->asXML());
$dom->formatOutput = true;
return $dom->saveXML();
}
/**
* Gets the privacyconsent system plugin extension id.
*
* @return integer The privacyconsent system plugin extension id.
*
* @since 3.9.2
*/
public static function getPrivacyConsentPluginId()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
->where($db->quoteName('element') . ' = ' . $db->quote('privacyconsent'));
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $result;
}
}